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 */
76 /* make compatible with old code */
77 #define alc_apply_pincfgs snd_hda_apply_pincfgs
78 #define alc_apply_fixup snd_hda_apply_fixup
79 #define alc_pick_fixup snd_hda_pick_fixup
80 #define alc_fixup hda_fixup
81 #define alc_pincfg hda_pintbl
82 #define alc_model_fixup hda_model_fixup
84 #define ALC_FIXUP_PINS HDA_FIXUP_PINS
85 #define ALC_FIXUP_VERBS HDA_FIXUP_VERBS
86 #define ALC_FIXUP_FUNC HDA_FIXUP_FUNC
88 #define ALC_FIXUP_ACT_PRE_PROBE HDA_FIXUP_ACT_PRE_PROBE
89 #define ALC_FIXUP_ACT_PROBE HDA_FIXUP_ACT_PROBE
90 #define ALC_FIXUP_ACT_INIT HDA_FIXUP_ACT_INIT
91 #define ALC_FIXUP_ACT_BUILD HDA_FIXUP_ACT_BUILD
94 #define MAX_NID_PATH_DEPTH 5
103 /* Widget connection path
105 * For output, stored in the order of DAC -> ... -> pin,
106 * for input, pin -> ... -> ADC.
108 * idx[i] contains the source index number to select on of the widget path[i];
109 * e.g. idx[1] is the index of the DAC (path[0]) selected by path[1] widget
110 * multi[] indicates whether it's a selector widget with multi-connectors
111 * (i.e. the connection selection is mandatory)
112 * vol_ctl and mute_ctl contains the NIDs for the assigned mixers
116 hda_nid_t path
[MAX_NID_PATH_DEPTH
];
117 unsigned char idx
[MAX_NID_PATH_DEPTH
];
118 unsigned char multi
[MAX_NID_PATH_DEPTH
];
119 unsigned int ctls
[NID_PATH_NUM_CTLS
]; /* NID_PATH_XXX_CTL */
124 struct hda_gen_spec gen
;
126 /* codec parameterization */
127 const struct snd_kcontrol_new
*mixers
[5]; /* mixer arrays */
128 unsigned int num_mixers
;
129 unsigned int beep_amp
; /* beep amp value, set via set_beep_amp() */
131 char stream_name_analog
[32]; /* analog PCM stream */
132 const struct hda_pcm_stream
*stream_analog_playback
;
133 const struct hda_pcm_stream
*stream_analog_capture
;
134 const struct hda_pcm_stream
*stream_analog_alt_playback
;
135 const struct hda_pcm_stream
*stream_analog_alt_capture
;
137 char stream_name_digital
[32]; /* digital PCM stream */
138 const struct hda_pcm_stream
*stream_digital_playback
;
139 const struct hda_pcm_stream
*stream_digital_capture
;
142 struct hda_multi_out multiout
; /* playback set-up
143 * max_channels, dacs must be set
144 * dig_out_nid and hp_nid are optional
146 hda_nid_t alt_dac_nid
;
147 hda_nid_t slave_dig_outs
[3]; /* optional - for auto-parsing */
151 unsigned int num_adc_nids
;
152 hda_nid_t adc_nids
[AUTO_CFG_MAX_OUTS
];
153 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
154 hda_nid_t mixer_nid
; /* analog-mixer NID */
156 /* capture setup for dynamic dual-adc switch */
158 unsigned int cur_adc_stream_tag
;
159 unsigned int cur_adc_format
;
162 struct hda_input_mux input_mux
;
163 unsigned int cur_mux
[3];
164 hda_nid_t ext_mic_pin
;
165 hda_nid_t dock_mic_pin
;
166 hda_nid_t int_mic_pin
;
169 const struct hda_channel_mode
*channel_mode
;
170 int num_channel_mode
;
171 int const_channel_count
; /* min. channel count (for speakers) */
172 int ext_channel_count
; /* current channel count for multi-io */
174 /* PCM information */
175 struct hda_pcm pcm_rec
[3]; /* used in alc_build_pcms() */
177 /* dynamic controls, init_verbs and input_mux */
178 struct auto_pin_cfg autocfg
;
179 struct alc_customize_define cdefine
;
180 struct snd_array kctls
;
181 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
182 hda_nid_t imux_pins
[HDA_MAX_NUM_INPUTS
];
183 unsigned int dyn_adc_idx
[HDA_MAX_NUM_INPUTS
];
184 int int_mic_idx
, ext_mic_idx
, dock_mic_idx
; /* for auto-mic */
185 hda_nid_t inv_dmic_pin
;
186 hda_nid_t shared_mic_vref_pin
;
187 int inv_dmic_split_idx
; /* used internally for inv_dmic_split */
191 hda_nid_t all_dacs
[16];
194 struct snd_array paths
;
197 void (*init_hook
)(struct hda_codec
*codec
);
199 void (*power_hook
)(struct hda_codec
*codec
);
201 void (*shutup
)(struct hda_codec
*codec
);
202 void (*automute_hook
)(struct hda_codec
*codec
);
204 /* for pin sensing */
205 unsigned int hp_jack_present
:1;
206 unsigned int line_jack_present
:1;
207 unsigned int master_mute
:1;
208 unsigned int auto_mic
:1;
209 unsigned int automute_speaker
:1; /* automute speaker outputs */
210 unsigned int automute_lo
:1; /* automute LO outputs */
211 unsigned int detect_hp
:1; /* Headphone detection enabled */
212 unsigned int detect_lo
:1; /* Line-out detection enabled */
213 unsigned int automute_speaker_possible
:1; /* there are speakers and either LO or HP */
214 unsigned int automute_lo_possible
:1; /* there are line outs and HP */
215 unsigned int keep_vref_in_automute
:1; /* Don't clear VREF in automute */
218 unsigned int need_dac_fix
:1; /* need to limit DACs for multi channels */
219 unsigned int no_analog
:1; /* digital I/O only */
220 unsigned int dyn_adc_switch
:1; /* switch ADCs (for ALC275) */
221 unsigned int shared_mic_hp
:1; /* HP/Mic-in sharing */
222 unsigned int inv_dmic_fixup
:1; /* has inverted digital-mic workaround */
223 unsigned int inv_dmic_muted
:1; /* R-ch of inv d-mic is muted? */
224 unsigned int no_primary_hp
:1; /* Don't prefer HP pins to speaker pins */
225 unsigned int multi_cap_vol
:1; /* allow multiple capture xxx volumes */
226 unsigned int inv_dmic_split
:1; /* inverted dmic w/a for conexant */
228 unsigned int parse_flags
; /* passed to snd_hda_parse_pin_defcfg() */
231 int codec_variant
; /* flag for other variants */
233 /* for virtual master */
234 hda_nid_t vmaster_nid
;
235 struct hda_vmaster_mute_hook vmaster_mute
;
237 struct hda_loopback_check loopback
;
239 struct hda_amp_list loopback_list
[8];
244 unsigned int pll_coef_idx
, pll_coef_bit
;
249 struct alc_multi_io multi_io
[4];
252 struct snd_array bind_ctls
;
255 static bool check_amp_caps(struct hda_codec
*codec
, hda_nid_t nid
,
256 int dir
, unsigned int bits
)
260 if (get_wcaps(codec
, nid
) & (1 << (dir
+ 1)))
261 if (query_amp_caps(codec
, nid
, dir
) & bits
)
266 #define nid_has_mute(codec, nid, dir) \
267 check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE)
268 #define nid_has_volume(codec, nid, dir) \
269 check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS)
271 static struct nid_path
*
272 get_nid_path(struct hda_codec
*codec
, hda_nid_t from_nid
, hda_nid_t to_nid
);
273 static void activate_path(struct hda_codec
*codec
, struct nid_path
*path
,
274 bool enable
, bool add_aamix
);
279 static int alc_mux_enum_info(struct snd_kcontrol
*kcontrol
,
280 struct snd_ctl_elem_info
*uinfo
)
282 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
283 struct alc_spec
*spec
= codec
->spec
;
284 return snd_hda_input_mux_info(&spec
->input_mux
, uinfo
);
287 static int alc_mux_enum_get(struct snd_kcontrol
*kcontrol
,
288 struct snd_ctl_elem_value
*ucontrol
)
290 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
291 struct alc_spec
*spec
= codec
->spec
;
292 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
294 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
298 static hda_nid_t
get_adc_nid(struct hda_codec
*codec
, int adc_idx
, int imux_idx
)
300 struct alc_spec
*spec
= codec
->spec
;
301 if (spec
->dyn_adc_switch
)
302 adc_idx
= spec
->dyn_adc_idx
[imux_idx
];
303 return spec
->adc_nids
[adc_idx
];
306 static bool alc_dyn_adc_pcm_resetup(struct hda_codec
*codec
, int cur
)
308 struct alc_spec
*spec
= codec
->spec
;
309 hda_nid_t new_adc
= spec
->adc_nids
[spec
->dyn_adc_idx
[cur
]];
311 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
312 /* stream is running, let's swap the current ADC */
313 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
314 spec
->cur_adc
= new_adc
;
315 snd_hda_codec_setup_stream(codec
, new_adc
,
316 spec
->cur_adc_stream_tag
, 0,
317 spec
->cur_adc_format
);
323 static void call_update_outputs(struct hda_codec
*codec
);
324 static void alc_inv_dmic_sync(struct hda_codec
*codec
, bool force
);
325 static void alc_inv_dmic_sync_adc(struct hda_codec
*codec
, int adc_idx
);
327 /* for shared I/O, change the pin-control accordingly */
328 static void update_shared_mic_hp(struct hda_codec
*codec
, bool set_as_mic
)
330 struct alc_spec
*spec
= codec
->spec
;
332 hda_nid_t pin
= spec
->autocfg
.inputs
[1].pin
;
333 /* NOTE: this assumes that there are only two inputs, the
334 * first is the real internal mic and the second is HP/mic jack.
337 val
= snd_hda_get_default_vref(codec
, pin
);
339 /* This pin does not have vref caps - let's enable vref on pin 0x18
340 instead, as suggested by Realtek */
341 if (val
== AC_PINCTL_VREF_HIZ
&& spec
->shared_mic_vref_pin
) {
342 const hda_nid_t vref_pin
= spec
->shared_mic_vref_pin
;
343 unsigned int vref_val
= snd_hda_get_default_vref(codec
, vref_pin
);
344 if (vref_val
!= AC_PINCTL_VREF_HIZ
)
345 snd_hda_set_pin_ctl(codec
, vref_pin
, PIN_IN
| (set_as_mic
? vref_val
: 0));
348 val
= set_as_mic
? val
| PIN_IN
: PIN_HP
;
349 snd_hda_set_pin_ctl(codec
, pin
, val
);
351 spec
->automute_speaker
= !set_as_mic
;
352 call_update_outputs(codec
);
355 /* select the given imux item; either unmute exclusively or select the route */
356 static int alc_mux_select(struct hda_codec
*codec
, unsigned int adc_idx
,
357 unsigned int idx
, bool force
)
359 struct alc_spec
*spec
= codec
->spec
;
360 const struct hda_input_mux
*imux
;
361 struct nid_path
*path
;
363 imux
= &spec
->input_mux
;
364 if (!imux
->num_items
)
367 if (idx
>= imux
->num_items
)
368 idx
= imux
->num_items
- 1;
369 if (spec
->cur_mux
[adc_idx
] == idx
&& !force
)
372 path
= get_nid_path(codec
, spec
->imux_pins
[spec
->cur_mux
[adc_idx
]],
373 spec
->adc_nids
[adc_idx
]);
377 activate_path(codec
, path
, false, false);
379 spec
->cur_mux
[adc_idx
] = idx
;
381 if (spec
->shared_mic_hp
)
382 update_shared_mic_hp(codec
, spec
->cur_mux
[adc_idx
]);
384 if (spec
->dyn_adc_switch
)
385 alc_dyn_adc_pcm_resetup(codec
, idx
);
387 path
= get_nid_path(codec
, spec
->imux_pins
[idx
],
388 get_adc_nid(codec
, adc_idx
, idx
));
393 activate_path(codec
, path
, true, false);
394 alc_inv_dmic_sync(codec
, true);
398 static int alc_mux_enum_put(struct snd_kcontrol
*kcontrol
,
399 struct snd_ctl_elem_value
*ucontrol
)
401 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
402 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
403 return alc_mux_select(codec
, adc_idx
,
404 ucontrol
->value
.enumerated
.item
[0], false);
408 * set up the input pin config (depending on the given auto-pin type)
410 static void alc_set_input_pin(struct hda_codec
*codec
, hda_nid_t nid
,
413 unsigned int val
= PIN_IN
;
414 if (auto_pin_type
== AUTO_PIN_MIC
)
415 val
|= snd_hda_get_default_vref(codec
, nid
);
416 snd_hda_set_pin_ctl(codec
, nid
, val
);
420 * Append the given mixer and verb elements for the later use
421 * The mixer array is referred in build_controls(), and init_verbs are
424 static void add_mixer(struct alc_spec
*spec
, const struct snd_kcontrol_new
*mix
)
426 if (snd_BUG_ON(spec
->num_mixers
>= ARRAY_SIZE(spec
->mixers
)))
428 spec
->mixers
[spec
->num_mixers
++] = mix
;
432 * GPIO setup tables, used in initialization
434 /* Enable GPIO mask and set output */
435 static const struct hda_verb alc_gpio1_init_verbs
[] = {
436 {0x01, AC_VERB_SET_GPIO_MASK
, 0x01},
437 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
438 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
442 static const struct hda_verb alc_gpio2_init_verbs
[] = {
443 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
444 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
445 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02},
449 static const struct hda_verb alc_gpio3_init_verbs
[] = {
450 {0x01, AC_VERB_SET_GPIO_MASK
, 0x03},
451 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x03},
452 {0x01, AC_VERB_SET_GPIO_DATA
, 0x03},
457 * Fix hardware PLL issue
458 * On some codecs, the analog PLL gating control must be off while
459 * the default value is 1.
461 static void alc_fix_pll(struct hda_codec
*codec
)
463 struct alc_spec
*spec
= codec
->spec
;
468 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_COEF_INDEX
,
470 val
= snd_hda_codec_read(codec
, spec
->pll_nid
, 0,
471 AC_VERB_GET_PROC_COEF
, 0);
472 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_COEF_INDEX
,
474 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_PROC_COEF
,
475 val
& ~(1 << spec
->pll_coef_bit
));
478 static void alc_fix_pll_init(struct hda_codec
*codec
, hda_nid_t nid
,
479 unsigned int coef_idx
, unsigned int coef_bit
)
481 struct alc_spec
*spec
= codec
->spec
;
483 spec
->pll_coef_idx
= coef_idx
;
484 spec
->pll_coef_bit
= coef_bit
;
489 * Jack detections for HP auto-mute and mic-switch
492 /* check each pin in the given array; returns true if any of them is plugged */
493 static bool detect_jacks(struct hda_codec
*codec
, int num_pins
, hda_nid_t
*pins
)
497 for (i
= 0; i
< num_pins
; i
++) {
498 hda_nid_t nid
= pins
[i
];
501 present
|= snd_hda_jack_detect(codec
, nid
);
506 /* standard HP/line-out auto-mute helper */
507 static void do_automute(struct hda_codec
*codec
, int num_pins
, hda_nid_t
*pins
,
508 bool mute
, bool hp_out
)
510 struct alc_spec
*spec
= codec
->spec
;
511 unsigned int pin_bits
= mute
? 0 : (hp_out
? PIN_HP
: PIN_OUT
);
514 for (i
= 0; i
< num_pins
; i
++) {
515 hda_nid_t nid
= pins
[i
];
519 /* don't reset VREF value in case it's controlling
520 * the amp (see alc861_fixup_asus_amp_vref_0f())
522 if (spec
->keep_vref_in_automute
) {
523 val
= snd_hda_codec_read(codec
, nid
, 0,
524 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
529 snd_hda_set_pin_ctl(codec
, nid
, val
);
533 /* Toggle outputs muting */
534 static void update_outputs(struct hda_codec
*codec
)
536 struct alc_spec
*spec
= codec
->spec
;
539 /* Control HP pins/amps depending on master_mute state;
540 * in general, HP pins/amps control should be enabled in all cases,
541 * but currently set only for master_mute, just to be safe
543 if (!spec
->shared_mic_hp
) /* don't change HP-pin when shared with mic */
544 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.hp_pins
),
545 spec
->autocfg
.hp_pins
, spec
->master_mute
, true);
547 if (!spec
->automute_speaker
)
550 on
= spec
->hp_jack_present
| spec
->line_jack_present
;
551 on
|= spec
->master_mute
;
552 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.speaker_pins
),
553 spec
->autocfg
.speaker_pins
, on
, false);
555 /* toggle line-out mutes if needed, too */
556 /* if LO is a copy of either HP or Speaker, don't need to handle it */
557 if (spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.hp_pins
[0] ||
558 spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.speaker_pins
[0])
560 if (!spec
->automute_lo
)
563 on
= spec
->hp_jack_present
;
564 on
|= spec
->master_mute
;
565 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.line_out_pins
),
566 spec
->autocfg
.line_out_pins
, on
, false);
569 static void call_update_outputs(struct hda_codec
*codec
)
571 struct alc_spec
*spec
= codec
->spec
;
572 if (spec
->automute_hook
)
573 spec
->automute_hook(codec
);
575 update_outputs(codec
);
578 /* standard HP-automute helper */
579 static void alc_hp_automute(struct hda_codec
*codec
, struct hda_jack_tbl
*jack
)
581 struct alc_spec
*spec
= codec
->spec
;
583 spec
->hp_jack_present
=
584 detect_jacks(codec
, ARRAY_SIZE(spec
->autocfg
.hp_pins
),
585 spec
->autocfg
.hp_pins
);
586 if (!spec
->detect_hp
|| (!spec
->automute_speaker
&& !spec
->automute_lo
))
588 call_update_outputs(codec
);
591 /* standard line-out-automute helper */
592 static void alc_line_automute(struct hda_codec
*codec
, struct hda_jack_tbl
*jack
)
594 struct alc_spec
*spec
= codec
->spec
;
596 if (spec
->autocfg
.line_out_type
== AUTO_PIN_SPEAKER_OUT
)
598 /* check LO jack only when it's different from HP */
599 if (spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.hp_pins
[0])
602 spec
->line_jack_present
=
603 detect_jacks(codec
, ARRAY_SIZE(spec
->autocfg
.line_out_pins
),
604 spec
->autocfg
.line_out_pins
);
605 if (!spec
->automute_speaker
|| !spec
->detect_lo
)
607 call_update_outputs(codec
);
610 /* standard mic auto-switch helper */
611 static void alc_mic_automute(struct hda_codec
*codec
, struct hda_jack_tbl
*jack
)
613 struct alc_spec
*spec
= codec
->spec
;
614 hda_nid_t
*pins
= spec
->imux_pins
;
618 if (snd_BUG_ON(spec
->int_mic_idx
< 0 || spec
->ext_mic_idx
< 0))
621 if (snd_hda_jack_detect(codec
, pins
[spec
->ext_mic_idx
]))
622 alc_mux_select(codec
, 0, spec
->ext_mic_idx
, false);
623 else if (spec
->dock_mic_idx
>= 0 &&
624 snd_hda_jack_detect(codec
, pins
[spec
->dock_mic_idx
]))
625 alc_mux_select(codec
, 0, spec
->dock_mic_idx
, false);
627 alc_mux_select(codec
, 0, spec
->int_mic_idx
, false);
630 /* update the master volume per volume-knob's unsol event */
631 static void alc_update_knob_master(struct hda_codec
*codec
, struct hda_jack_tbl
*jack
)
634 struct snd_kcontrol
*kctl
;
635 struct snd_ctl_elem_value
*uctl
;
637 kctl
= snd_hda_find_mixer_ctl(codec
, "Master Playback Volume");
640 uctl
= kzalloc(sizeof(*uctl
), GFP_KERNEL
);
643 val
= snd_hda_codec_read(codec
, jack
->nid
, 0,
644 AC_VERB_GET_VOLUME_KNOB_CONTROL
, 0);
645 val
&= HDA_AMP_VOLMASK
;
646 uctl
->value
.integer
.value
[0] = val
;
647 uctl
->value
.integer
.value
[1] = val
;
648 kctl
->put(kctl
, uctl
);
652 static void alc880_unsol_event(struct hda_codec
*codec
, unsigned int res
)
654 /* For some reason, the res given from ALC880 is broken.
655 Here we adjust it properly. */
656 snd_hda_jack_unsol_event(codec
, res
>> 2);
659 /* additional initialization for ALC888 variants */
660 static void alc888_coef_init(struct hda_codec
*codec
)
664 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 0);
665 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
666 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
667 if ((tmp
& 0xf0) == 0x20)
669 snd_hda_codec_read(codec
, 0x20, 0,
670 AC_VERB_SET_PROC_COEF
, 0x830);
673 snd_hda_codec_read(codec
, 0x20, 0,
674 AC_VERB_SET_PROC_COEF
, 0x3030);
677 /* additional initialization for ALC889 variants */
678 static void alc889_coef_init(struct hda_codec
*codec
)
682 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
683 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
684 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
685 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_PROC_COEF
, tmp
|0x2010);
688 /* turn on/off EAPD control (only if available) */
689 static void set_eapd(struct hda_codec
*codec
, hda_nid_t nid
, int on
)
691 if (get_wcaps_type(get_wcaps(codec
, nid
)) != AC_WID_PIN
)
693 if (snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_EAPD
)
694 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_EAPD_BTLENABLE
,
698 /* turn on/off EAPD controls of the codec */
699 static void alc_auto_setup_eapd(struct hda_codec
*codec
, bool on
)
701 /* We currently only handle front, HP */
702 static hda_nid_t pins
[] = {
703 0x0f, 0x10, 0x14, 0x15, 0
706 for (p
= pins
; *p
; p
++)
707 set_eapd(codec
, *p
, on
);
710 /* generic shutup callback;
711 * just turning off EPAD and a little pause for avoiding pop-noise
713 static void alc_eapd_shutup(struct hda_codec
*codec
)
715 alc_auto_setup_eapd(codec
, false);
719 /* generic EAPD initialization */
720 static void alc_auto_init_amp(struct hda_codec
*codec
, int type
)
724 alc_auto_setup_eapd(codec
, true);
727 snd_hda_sequence_write(codec
, alc_gpio1_init_verbs
);
730 snd_hda_sequence_write(codec
, alc_gpio2_init_verbs
);
733 snd_hda_sequence_write(codec
, alc_gpio3_init_verbs
);
735 case ALC_INIT_DEFAULT
:
736 switch (codec
->vendor_id
) {
738 snd_hda_codec_write(codec
, 0x1a, 0,
739 AC_VERB_SET_COEF_INDEX
, 7);
740 tmp
= snd_hda_codec_read(codec
, 0x1a, 0,
741 AC_VERB_GET_PROC_COEF
, 0);
742 snd_hda_codec_write(codec
, 0x1a, 0,
743 AC_VERB_SET_COEF_INDEX
, 7);
744 snd_hda_codec_write(codec
, 0x1a, 0,
745 AC_VERB_SET_PROC_COEF
,
754 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
755 alc889_coef_init(codec
);
758 alc888_coef_init(codec
);
760 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
763 snd_hda_codec_write(codec
, 0x20, 0,
764 AC_VERB_SET_COEF_INDEX
, 7);
765 tmp
= snd_hda_codec_read(codec
, 0x20, 0,
766 AC_VERB_GET_PROC_COEF
, 0);
767 snd_hda_codec_write(codec
, 0x20, 0,
768 AC_VERB_SET_COEF_INDEX
, 7);
769 snd_hda_codec_write(codec
, 0x20, 0,
770 AC_VERB_SET_PROC_COEF
,
780 * Auto-Mute mode mixer enum support
782 static int alc_automute_mode_info(struct snd_kcontrol
*kcontrol
,
783 struct snd_ctl_elem_info
*uinfo
)
785 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
786 struct alc_spec
*spec
= codec
->spec
;
787 static const char * const texts3
[] = {
788 "Disabled", "Speaker Only", "Line Out+Speaker"
791 if (spec
->automute_speaker_possible
&& spec
->automute_lo_possible
)
792 return snd_hda_enum_helper_info(kcontrol
, uinfo
, 3, texts3
);
793 return snd_hda_enum_bool_helper_info(kcontrol
, uinfo
);
796 static int alc_automute_mode_get(struct snd_kcontrol
*kcontrol
,
797 struct snd_ctl_elem_value
*ucontrol
)
799 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
800 struct alc_spec
*spec
= codec
->spec
;
801 unsigned int val
= 0;
802 if (spec
->automute_speaker
)
804 if (spec
->automute_lo
)
807 ucontrol
->value
.enumerated
.item
[0] = val
;
811 static int alc_automute_mode_put(struct snd_kcontrol
*kcontrol
,
812 struct snd_ctl_elem_value
*ucontrol
)
814 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
815 struct alc_spec
*spec
= codec
->spec
;
817 switch (ucontrol
->value
.enumerated
.item
[0]) {
819 if (!spec
->automute_speaker
&& !spec
->automute_lo
)
821 spec
->automute_speaker
= 0;
822 spec
->automute_lo
= 0;
825 if (spec
->automute_speaker_possible
) {
826 if (!spec
->automute_lo
&& spec
->automute_speaker
)
828 spec
->automute_speaker
= 1;
829 spec
->automute_lo
= 0;
830 } else if (spec
->automute_lo_possible
) {
831 if (spec
->automute_lo
)
833 spec
->automute_lo
= 1;
838 if (!spec
->automute_lo_possible
|| !spec
->automute_speaker_possible
)
840 if (spec
->automute_speaker
&& spec
->automute_lo
)
842 spec
->automute_speaker
= 1;
843 spec
->automute_lo
= 1;
848 call_update_outputs(codec
);
852 static const struct snd_kcontrol_new alc_automute_mode_enum
= {
853 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
854 .name
= "Auto-Mute Mode",
855 .info
= alc_automute_mode_info
,
856 .get
= alc_automute_mode_get
,
857 .put
= alc_automute_mode_put
,
860 static struct snd_kcontrol_new
*
861 alc_kcontrol_new(struct alc_spec
*spec
, const char *name
,
862 const struct snd_kcontrol_new
*temp
)
864 struct snd_kcontrol_new
*knew
= snd_array_new(&spec
->kctls
);
869 knew
->name
= kstrdup(name
, GFP_KERNEL
);
871 knew
->name
= kstrdup(knew
->name
, GFP_KERNEL
);
877 static int alc_add_automute_mode_enum(struct hda_codec
*codec
)
879 struct alc_spec
*spec
= codec
->spec
;
881 if (!alc_kcontrol_new(spec
, NULL
, &alc_automute_mode_enum
))
887 * Check the availability of HP/line-out auto-mute;
888 * Set up appropriately if really supported
890 static int alc_init_automute(struct hda_codec
*codec
)
892 struct alc_spec
*spec
= codec
->spec
;
893 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
899 if (cfg
->line_out_pins
[0])
901 if (cfg
->speaker_pins
[0])
903 if (present
< 2) /* need two different output types */
906 if (!cfg
->speaker_pins
[0] &&
907 cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
908 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
909 sizeof(cfg
->speaker_pins
));
910 cfg
->speaker_outs
= cfg
->line_outs
;
913 if (!cfg
->hp_pins
[0] &&
914 cfg
->line_out_type
== AUTO_PIN_HP_OUT
) {
915 memcpy(cfg
->hp_pins
, cfg
->line_out_pins
,
916 sizeof(cfg
->hp_pins
));
917 cfg
->hp_outs
= cfg
->line_outs
;
920 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
921 hda_nid_t nid
= cfg
->hp_pins
[i
];
922 if (!is_jack_detectable(codec
, nid
))
924 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
926 snd_hda_jack_detect_enable_callback(codec
, nid
, ALC_HP_EVENT
,
931 if (cfg
->line_out_type
== AUTO_PIN_LINE_OUT
&& cfg
->line_outs
) {
932 if (cfg
->speaker_outs
)
933 for (i
= 0; i
< cfg
->line_outs
; i
++) {
934 hda_nid_t nid
= cfg
->line_out_pins
[i
];
935 if (!is_jack_detectable(codec
, nid
))
937 snd_printdd("realtek: Enable Line-Out "
938 "auto-muting on NID 0x%x\n", nid
);
939 snd_hda_jack_detect_enable_callback(codec
, nid
, ALC_FRONT_EVENT
,
943 spec
->automute_lo_possible
= spec
->detect_hp
;
946 spec
->automute_speaker_possible
= cfg
->speaker_outs
&&
947 (spec
->detect_hp
|| spec
->detect_lo
);
949 spec
->automute_lo
= spec
->automute_lo_possible
;
950 spec
->automute_speaker
= spec
->automute_speaker_possible
;
952 if (spec
->automute_speaker_possible
|| spec
->automute_lo_possible
) {
953 /* create a control for automute mode */
954 err
= alc_add_automute_mode_enum(codec
);
961 /* return the position of NID in the list, or -1 if not found */
962 static int find_idx_in_nid_list(hda_nid_t nid
, const hda_nid_t
*list
, int nums
)
965 for (i
= 0; i
< nums
; i
++)
971 /* check whether all auto-mic pins are valid; setup indices if OK */
972 static bool alc_auto_mic_check_imux(struct hda_codec
*codec
)
974 struct alc_spec
*spec
= codec
->spec
;
975 const struct hda_input_mux
*imux
;
977 imux
= &spec
->input_mux
;
978 spec
->ext_mic_idx
= find_idx_in_nid_list(spec
->ext_mic_pin
,
979 spec
->imux_pins
, imux
->num_items
);
980 spec
->int_mic_idx
= find_idx_in_nid_list(spec
->int_mic_pin
,
981 spec
->imux_pins
, imux
->num_items
);
982 spec
->dock_mic_idx
= find_idx_in_nid_list(spec
->dock_mic_pin
,
983 spec
->imux_pins
, imux
->num_items
);
984 if (spec
->ext_mic_idx
< 0 || spec
->int_mic_idx
< 0)
985 return false; /* no corresponding imux */
987 snd_hda_jack_detect_enable_callback(codec
, spec
->ext_mic_pin
,
988 ALC_MIC_EVENT
, alc_mic_automute
);
989 if (spec
->dock_mic_pin
)
990 snd_hda_jack_detect_enable_callback(codec
, spec
->dock_mic_pin
,
997 * Check the availability of auto-mic switch;
998 * Set up if really supported
1000 static int alc_init_auto_mic(struct hda_codec
*codec
)
1002 struct alc_spec
*spec
= codec
->spec
;
1003 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1004 hda_nid_t fixed
, ext
, dock
;
1007 spec
->ext_mic_idx
= spec
->int_mic_idx
= spec
->dock_mic_idx
= -1;
1009 fixed
= ext
= dock
= 0;
1010 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
1011 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
1012 unsigned int defcfg
;
1013 defcfg
= snd_hda_codec_get_pincfg(codec
, nid
);
1014 switch (snd_hda_get_input_pin_attr(defcfg
)) {
1015 case INPUT_PIN_ATTR_INT
:
1017 return 0; /* already occupied */
1018 if (cfg
->inputs
[i
].type
!= AUTO_PIN_MIC
)
1019 return 0; /* invalid type */
1022 case INPUT_PIN_ATTR_UNUSED
:
1023 return 0; /* invalid entry */
1024 case INPUT_PIN_ATTR_DOCK
:
1026 return 0; /* already occupied */
1027 if (cfg
->inputs
[i
].type
> AUTO_PIN_LINE_IN
)
1028 return 0; /* invalid type */
1033 return 0; /* already occupied */
1034 if (cfg
->inputs
[i
].type
!= AUTO_PIN_MIC
)
1035 return 0; /* invalid type */
1046 if (!is_jack_detectable(codec
, ext
))
1047 return 0; /* no unsol support */
1048 if (dock
&& !is_jack_detectable(codec
, dock
))
1049 return 0; /* no unsol support */
1051 /* check imux indices */
1052 spec
->ext_mic_pin
= ext
;
1053 spec
->int_mic_pin
= fixed
;
1054 spec
->dock_mic_pin
= dock
;
1056 if (!alc_auto_mic_check_imux(codec
))
1060 spec
->num_adc_nids
= 1;
1061 spec
->cur_mux
[0] = spec
->int_mic_idx
;
1062 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
1069 * Realtek SSID verification
1072 /* Could be any non-zero and even value. When used as fixup, tells
1073 * the driver to ignore any present sku defines.
1075 #define ALC_FIXUP_SKU_IGNORE (2)
1077 static void alc_fixup_sku_ignore(struct hda_codec
*codec
,
1078 const struct hda_fixup
*fix
, int action
)
1080 struct alc_spec
*spec
= codec
->spec
;
1081 if (action
== HDA_FIXUP_ACT_PRE_PROBE
) {
1082 spec
->cdefine
.fixup
= 1;
1083 spec
->cdefine
.sku_cfg
= ALC_FIXUP_SKU_IGNORE
;
1087 static int alc_auto_parse_customize_define(struct hda_codec
*codec
)
1089 unsigned int ass
, tmp
, i
;
1091 struct alc_spec
*spec
= codec
->spec
;
1093 spec
->cdefine
.enable_pcbeep
= 1; /* assume always enabled */
1095 if (spec
->cdefine
.fixup
) {
1096 ass
= spec
->cdefine
.sku_cfg
;
1097 if (ass
== ALC_FIXUP_SKU_IGNORE
)
1102 ass
= codec
->subsystem_id
& 0xffff;
1103 if (ass
!= codec
->bus
->pci
->subsystem_device
&& (ass
& 1))
1107 if (codec
->vendor_id
== 0x10ec0260)
1109 ass
= snd_hda_codec_get_pincfg(codec
, nid
);
1112 printk(KERN_INFO
"hda_codec: %s: SKU not ready 0x%08x\n",
1113 codec
->chip_name
, ass
);
1119 for (i
= 1; i
< 16; i
++) {
1123 if (((ass
>> 16) & 0xf) != tmp
)
1126 spec
->cdefine
.port_connectivity
= ass
>> 30;
1127 spec
->cdefine
.enable_pcbeep
= (ass
& 0x100000) >> 20;
1128 spec
->cdefine
.check_sum
= (ass
>> 16) & 0xf;
1129 spec
->cdefine
.customization
= ass
>> 8;
1131 spec
->cdefine
.sku_cfg
= ass
;
1132 spec
->cdefine
.external_amp
= (ass
& 0x38) >> 3;
1133 spec
->cdefine
.platform_type
= (ass
& 0x4) >> 2;
1134 spec
->cdefine
.swap
= (ass
& 0x2) >> 1;
1135 spec
->cdefine
.override
= ass
& 0x1;
1137 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1138 nid
, spec
->cdefine
.sku_cfg
);
1139 snd_printd("SKU: port_connectivity=0x%x\n",
1140 spec
->cdefine
.port_connectivity
);
1141 snd_printd("SKU: enable_pcbeep=0x%x\n", spec
->cdefine
.enable_pcbeep
);
1142 snd_printd("SKU: check_sum=0x%08x\n", spec
->cdefine
.check_sum
);
1143 snd_printd("SKU: customization=0x%08x\n", spec
->cdefine
.customization
);
1144 snd_printd("SKU: external_amp=0x%x\n", spec
->cdefine
.external_amp
);
1145 snd_printd("SKU: platform_type=0x%x\n", spec
->cdefine
.platform_type
);
1146 snd_printd("SKU: swap=0x%x\n", spec
->cdefine
.swap
);
1147 snd_printd("SKU: override=0x%x\n", spec
->cdefine
.override
);
1152 /* return true if the given NID is found in the list */
1153 static bool found_in_nid_list(hda_nid_t nid
, const hda_nid_t
*list
, int nums
)
1155 return find_idx_in_nid_list(nid
, list
, nums
) >= 0;
1158 /* check subsystem ID and set up device-specific initialization;
1159 * return 1 if initialized, 0 if invalid SSID
1161 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1162 * 31 ~ 16 : Manufacture ID
1164 * 7 ~ 0 : Assembly ID
1165 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1167 static int alc_subsystem_id(struct hda_codec
*codec
,
1168 hda_nid_t porta
, hda_nid_t porte
,
1169 hda_nid_t portd
, hda_nid_t porti
)
1171 unsigned int ass
, tmp
, i
;
1173 struct alc_spec
*spec
= codec
->spec
;
1175 if (spec
->cdefine
.fixup
) {
1176 ass
= spec
->cdefine
.sku_cfg
;
1177 if (ass
== ALC_FIXUP_SKU_IGNORE
)
1182 ass
= codec
->subsystem_id
& 0xffff;
1183 if ((ass
!= codec
->bus
->pci
->subsystem_device
) && (ass
& 1))
1186 /* invalid SSID, check the special NID pin defcfg instead */
1188 * 31~30 : port connectivity
1191 * 19~16 : Check sum (15:1)
1196 if (codec
->vendor_id
== 0x10ec0260)
1198 ass
= snd_hda_codec_get_pincfg(codec
, nid
);
1199 snd_printd("realtek: No valid SSID, "
1200 "checking pincfg 0x%08x for NID 0x%x\n",
1204 if ((ass
>> 30) != 1) /* no physical connection */
1209 for (i
= 1; i
< 16; i
++) {
1213 if (((ass
>> 16) & 0xf) != tmp
)
1216 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1217 ass
& 0xffff, codec
->vendor_id
);
1221 * 2 : 0 --> Desktop, 1 --> Laptop
1222 * 3~5 : External Amplifier control
1225 tmp
= (ass
& 0x38) >> 3; /* external Amp control */
1228 spec
->init_amp
= ALC_INIT_GPIO1
;
1231 spec
->init_amp
= ALC_INIT_GPIO2
;
1234 spec
->init_amp
= ALC_INIT_GPIO3
;
1238 spec
->init_amp
= ALC_INIT_DEFAULT
;
1242 /* is laptop or Desktop and enable the function "Mute internal speaker
1243 * when the external headphone out jack is plugged"
1245 if (!(ass
& 0x8000))
1248 * 10~8 : Jack location
1249 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1251 * 15 : 1 --> enable the function "Mute internal speaker
1252 * when the external headphone out jack is plugged"
1254 if (!spec
->autocfg
.hp_pins
[0] &&
1255 !(spec
->autocfg
.line_out_pins
[0] &&
1256 spec
->autocfg
.line_out_type
== AUTO_PIN_HP_OUT
)) {
1258 tmp
= (ass
>> 11) & 0x3; /* HP to chassis */
1269 if (found_in_nid_list(nid
, spec
->autocfg
.line_out_pins
,
1270 spec
->autocfg
.line_outs
))
1272 spec
->autocfg
.hp_pins
[0] = nid
;
1277 /* Check the validity of ALC subsystem-id
1278 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
1279 static void alc_ssid_check(struct hda_codec
*codec
, const hda_nid_t
*ports
)
1281 if (!alc_subsystem_id(codec
, ports
[0], ports
[1], ports
[2], ports
[3])) {
1282 struct alc_spec
*spec
= codec
->spec
;
1283 snd_printd("realtek: "
1284 "Enable default setup for auto mode as fallback\n");
1285 spec
->init_amp
= ALC_INIT_DEFAULT
;
1290 * COEF access helper functions
1292 static int alc_read_coef_idx(struct hda_codec
*codec
,
1293 unsigned int coef_idx
)
1296 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
,
1298 val
= snd_hda_codec_read(codec
, 0x20, 0,
1299 AC_VERB_GET_PROC_COEF
, 0);
1303 static void alc_write_coef_idx(struct hda_codec
*codec
, unsigned int coef_idx
,
1304 unsigned int coef_val
)
1306 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
,
1308 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_PROC_COEF
,
1312 /* a special bypass for COEF 0; read the cached value at the second time */
1313 static unsigned int alc_get_coef0(struct hda_codec
*codec
)
1315 struct alc_spec
*spec
= codec
->spec
;
1317 spec
->coef0
= alc_read_coef_idx(codec
, 0);
1321 static void alc_auto_set_output_and_unmute(struct hda_codec
*codec
,
1322 hda_nid_t pin
, int pin_type
,
1324 static hda_nid_t
alc_auto_look_for_dac(struct hda_codec
*codec
, hda_nid_t pin
,
1326 static bool parse_nid_path(struct hda_codec
*codec
, hda_nid_t from_nid
,
1327 hda_nid_t to_nid
, int with_aa_mix
,
1328 struct nid_path
*path
);
1329 static struct nid_path
*add_new_nid_path(struct hda_codec
*codec
,
1330 hda_nid_t from_nid
, hda_nid_t to_nid
,
1334 * Digital I/O handling
1337 /* set right pin controls for digital I/O */
1338 static void alc_auto_init_digital(struct hda_codec
*codec
)
1340 struct alc_spec
*spec
= codec
->spec
;
1344 for (i
= 0; i
< spec
->autocfg
.dig_outs
; i
++) {
1345 pin
= spec
->autocfg
.dig_out_pins
[i
];
1348 alc_auto_set_output_and_unmute(codec
, pin
, PIN_OUT
, 0);
1350 pin
= spec
->autocfg
.dig_in_pin
;
1352 snd_hda_set_pin_ctl(codec
, pin
, PIN_IN
);
1355 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1356 static void alc_auto_parse_digital(struct hda_codec
*codec
)
1358 struct alc_spec
*spec
= codec
->spec
;
1362 /* support multiple SPDIFs; the secondary is set up as a slave */
1364 for (i
= 0; i
< spec
->autocfg
.dig_outs
; i
++) {
1365 hda_nid_t pin
= spec
->autocfg
.dig_out_pins
[i
];
1366 dig_nid
= alc_auto_look_for_dac(codec
, pin
, true);
1369 if (!add_new_nid_path(codec
, dig_nid
, pin
, 2))
1372 spec
->multiout
.dig_out_nid
= dig_nid
;
1373 spec
->dig_out_type
= spec
->autocfg
.dig_out_type
[0];
1375 spec
->multiout
.slave_dig_outs
= spec
->slave_dig_outs
;
1376 if (nums
>= ARRAY_SIZE(spec
->slave_dig_outs
) - 1)
1378 spec
->slave_dig_outs
[nums
- 1] = dig_nid
;
1383 if (spec
->autocfg
.dig_in_pin
) {
1384 dig_nid
= codec
->start_nid
;
1385 for (i
= 0; i
< codec
->num_nodes
; i
++, dig_nid
++) {
1386 struct nid_path
*path
;
1387 unsigned int wcaps
= get_wcaps(codec
, dig_nid
);
1388 if (get_wcaps_type(wcaps
) != AC_WID_AUD_IN
)
1390 if (!(wcaps
& AC_WCAP_DIGITAL
))
1392 path
= add_new_nid_path(codec
, spec
->autocfg
.dig_in_pin
,
1395 path
->active
= true;
1396 spec
->dig_in_nid
= dig_nid
;
1404 * capture mixer elements
1406 #define alc_cap_vol_info snd_hda_mixer_amp_volume_info
1407 #define alc_cap_vol_get snd_hda_mixer_amp_volume_get
1408 #define alc_cap_vol_tlv snd_hda_mixer_amp_tlv
1410 typedef int (*put_call_t
)(struct snd_kcontrol
*kcontrol
,
1411 struct snd_ctl_elem_value
*ucontrol
);
1413 static int alc_cap_put_caller(struct snd_kcontrol
*kcontrol
,
1414 struct snd_ctl_elem_value
*ucontrol
,
1415 put_call_t func
, int type
)
1417 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1418 struct alc_spec
*spec
= codec
->spec
;
1419 const struct hda_input_mux
*imux
;
1420 struct nid_path
*path
;
1421 int i
, adc_idx
, err
= 0;
1423 imux
= &spec
->input_mux
;
1424 adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
1425 mutex_lock(&codec
->control_mutex
);
1426 codec
->cached_write
= 1;
1427 for (i
= 0; i
< imux
->num_items
; i
++) {
1428 path
= get_nid_path(codec
, spec
->imux_pins
[i
],
1429 get_adc_nid(codec
, adc_idx
, i
));
1430 if (!path
->ctls
[type
])
1432 kcontrol
->private_value
= path
->ctls
[type
];
1433 err
= func(kcontrol
, ucontrol
);
1438 codec
->cached_write
= 0;
1439 mutex_unlock(&codec
->control_mutex
);
1440 snd_hda_codec_resume_amp(codec
);
1441 if (err
>= 0 && type
== NID_PATH_MUTE_CTL
&&
1442 spec
->inv_dmic_fixup
&& spec
->inv_dmic_muted
)
1443 alc_inv_dmic_sync_adc(codec
, adc_idx
);
1447 static int alc_cap_vol_put(struct snd_kcontrol
*kcontrol
,
1448 struct snd_ctl_elem_value
*ucontrol
)
1450 return alc_cap_put_caller(kcontrol
, ucontrol
,
1451 snd_hda_mixer_amp_volume_put
,
1455 /* capture mixer elements */
1456 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1457 #define alc_cap_sw_get snd_hda_mixer_amp_switch_get
1459 static int alc_cap_sw_put(struct snd_kcontrol
*kcontrol
,
1460 struct snd_ctl_elem_value
*ucontrol
)
1462 return alc_cap_put_caller(kcontrol
, ucontrol
,
1463 snd_hda_mixer_amp_switch_put
,
1467 static void alc_inv_dmic_sync_adc(struct hda_codec
*codec
, int adc_idx
)
1469 struct alc_spec
*spec
= codec
->spec
;
1470 struct hda_input_mux
*imux
= &spec
->input_mux
;
1471 struct nid_path
*path
;
1476 for (i
= 0; i
< imux
->num_items
; i
++) {
1477 if (spec
->imux_pins
[i
] == spec
->inv_dmic_pin
)
1480 if (i
>= imux
->num_items
)
1483 path
= get_nid_path(codec
, spec
->inv_dmic_pin
,
1484 get_adc_nid(codec
, adc_idx
, i
));
1485 val
= path
->ctls
[NID_PATH_MUTE_CTL
];
1488 nid
= get_amp_nid_(val
);
1489 dir
= get_amp_direction_(val
);
1490 parm
= AC_AMP_SET_RIGHT
|
1491 (dir
== HDA_OUTPUT
? AC_AMP_SET_OUTPUT
: AC_AMP_SET_INPUT
);
1493 /* we care only right channel */
1494 val
= snd_hda_codec_amp_read(codec
, nid
, 1, dir
, 0);
1495 if (val
& 0x80) /* if already muted, we don't need to touch */
1498 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
1503 * Inverted digital-mic handling
1505 * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch"
1506 * gives the additional mute only to the right channel of the digital mic
1507 * capture stream. This is a workaround for avoiding the almost silence
1508 * by summing the stereo stream from some (known to be ForteMedia)
1511 * The logic is to call alc_inv_dmic_sync() after each action (possibly)
1512 * modifying ADC amp. When the mute flag is set, it mutes the R-channel
1513 * without caching so that the cache can still keep the original value.
1514 * The cached value is then restored when the flag is set off or any other
1515 * than d-mic is used as the current input source.
1517 static void alc_inv_dmic_sync(struct hda_codec
*codec
, bool force
)
1519 struct alc_spec
*spec
= codec
->spec
;
1522 if (!spec
->inv_dmic_fixup
)
1524 if (!spec
->inv_dmic_muted
&& !force
)
1526 nums
= spec
->dyn_adc_switch
? 1 : spec
->num_adc_nids
;
1527 for (src
= 0; src
< nums
; src
++) {
1528 bool dmic_fixup
= false;
1530 if (spec
->inv_dmic_muted
&&
1531 spec
->imux_pins
[spec
->cur_mux
[src
]] == spec
->inv_dmic_pin
)
1533 if (!dmic_fixup
&& !force
)
1535 alc_inv_dmic_sync_adc(codec
, src
);
1539 static int alc_inv_dmic_sw_get(struct snd_kcontrol
*kcontrol
,
1540 struct snd_ctl_elem_value
*ucontrol
)
1542 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1543 struct alc_spec
*spec
= codec
->spec
;
1545 ucontrol
->value
.integer
.value
[0] = !spec
->inv_dmic_muted
;
1549 static int alc_inv_dmic_sw_put(struct snd_kcontrol
*kcontrol
,
1550 struct snd_ctl_elem_value
*ucontrol
)
1552 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1553 struct alc_spec
*spec
= codec
->spec
;
1554 unsigned int val
= !ucontrol
->value
.integer
.value
[0];
1556 if (val
== spec
->inv_dmic_muted
)
1558 spec
->inv_dmic_muted
= val
;
1559 alc_inv_dmic_sync(codec
, true);
1563 static const struct snd_kcontrol_new alc_inv_dmic_sw
= {
1564 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1565 .name
= "Inverted Internal Mic Capture Switch",
1566 .info
= snd_ctl_boolean_mono_info
,
1567 .get
= alc_inv_dmic_sw_get
,
1568 .put
= alc_inv_dmic_sw_put
,
1571 static int alc_add_inv_dmic_mixer(struct hda_codec
*codec
, hda_nid_t nid
)
1573 struct alc_spec
*spec
= codec
->spec
;
1575 if (!alc_kcontrol_new(spec
, NULL
, &alc_inv_dmic_sw
))
1577 spec
->inv_dmic_fixup
= 1;
1578 spec
->inv_dmic_muted
= 0;
1579 spec
->inv_dmic_pin
= nid
;
1583 /* typically the digital mic is put at node 0x12 */
1584 static void alc_fixup_inv_dmic_0x12(struct hda_codec
*codec
,
1585 const struct alc_fixup
*fix
, int action
)
1587 if (action
== ALC_FIXUP_ACT_PROBE
)
1588 alc_add_inv_dmic_mixer(codec
, 0x12);
1592 * virtual master controls
1596 * slave controls for virtual master
1598 static const char * const alc_slave_pfxs
[] = {
1599 "Front", "Surround", "Center", "LFE", "Side",
1600 "Headphone", "Speaker", "Mono", "Line Out",
1601 "CLFE", "Bass Speaker", "PCM",
1606 * build control elements
1609 static void alc_free_kctls(struct hda_codec
*codec
);
1611 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1612 /* additional beep mixers; the actual parameters are overwritten at build */
1613 static const struct snd_kcontrol_new alc_beep_mixer
[] = {
1614 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT
),
1615 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT
),
1620 static int alc_build_controls(struct hda_codec
*codec
)
1622 struct alc_spec
*spec
= codec
->spec
;
1625 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1626 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
1630 if (spec
->multiout
.dig_out_nid
) {
1631 err
= snd_hda_create_dig_out_ctls(codec
,
1632 spec
->multiout
.dig_out_nid
,
1633 spec
->multiout
.dig_out_nid
,
1634 spec
->pcm_rec
[1].pcm_type
);
1637 if (!spec
->no_analog
) {
1638 err
= snd_hda_create_spdif_share_sw(codec
,
1642 spec
->multiout
.share_spdif
= 1;
1645 if (spec
->dig_in_nid
) {
1646 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
1651 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1652 /* create beep controls if needed */
1653 if (spec
->beep_amp
) {
1654 const struct snd_kcontrol_new
*knew
;
1655 for (knew
= alc_beep_mixer
; knew
->name
; knew
++) {
1656 struct snd_kcontrol
*kctl
;
1657 kctl
= snd_ctl_new1(knew
, codec
);
1660 kctl
->private_value
= spec
->beep_amp
;
1661 err
= snd_hda_ctl_add(codec
, 0, kctl
);
1668 /* if we have no master control, let's create it */
1669 if (!spec
->no_analog
&&
1670 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
1671 unsigned int vmaster_tlv
[4];
1672 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
1673 HDA_OUTPUT
, vmaster_tlv
);
1674 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
1675 vmaster_tlv
, alc_slave_pfxs
,
1680 if (!spec
->no_analog
&&
1681 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
1682 err
= __snd_hda_add_vmaster(codec
, "Master Playback Switch",
1683 NULL
, alc_slave_pfxs
,
1685 true, &spec
->vmaster_mute
.sw_kctl
);
1688 if (spec
->vmaster_mute
.hook
)
1689 snd_hda_add_vmaster_hook(codec
, &spec
->vmaster_mute
, true);
1692 alc_free_kctls(codec
); /* no longer needed */
1694 if (spec
->shared_mic_hp
) {
1696 int nid
= spec
->autocfg
.inputs
[1].pin
;
1697 err
= snd_hda_jack_add_kctl(codec
, nid
, "Headphone Mic", 0);
1700 err
= snd_hda_jack_detect_enable(codec
, nid
, 0);
1705 err
= snd_hda_jack_add_kctls(codec
, &spec
->autocfg
);
1709 alc_apply_fixup(codec
, ALC_FIXUP_ACT_BUILD
);
1718 static void alc_auto_init_std(struct hda_codec
*codec
);
1720 static int alc_init(struct hda_codec
*codec
)
1722 struct alc_spec
*spec
= codec
->spec
;
1724 if (spec
->init_hook
)
1725 spec
->init_hook(codec
);
1728 alc_auto_init_amp(codec
, spec
->init_amp
);
1730 snd_hda_gen_apply_verbs(codec
);
1731 alc_auto_init_std(codec
);
1733 if (spec
->vmaster_mute
.sw_kctl
&& spec
->vmaster_mute
.hook
)
1734 snd_hda_sync_vmaster_hook(&spec
->vmaster_mute
);
1736 alc_apply_fixup(codec
, ALC_FIXUP_ACT_INIT
);
1738 hda_call_check_power_status(codec
, 0x01);
1743 static int alc_check_power_status(struct hda_codec
*codec
, hda_nid_t nid
)
1745 struct alc_spec
*spec
= codec
->spec
;
1746 return snd_hda_check_amp_list_power(codec
, &spec
->loopback
, nid
);
1751 * Analog playback callbacks
1753 static int alc_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
1754 struct hda_codec
*codec
,
1755 struct snd_pcm_substream
*substream
)
1757 struct alc_spec
*spec
= codec
->spec
;
1758 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
1762 static int alc_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
1763 struct hda_codec
*codec
,
1764 unsigned int stream_tag
,
1765 unsigned int format
,
1766 struct snd_pcm_substream
*substream
)
1768 struct alc_spec
*spec
= codec
->spec
;
1769 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
1770 stream_tag
, format
, substream
);
1773 static int alc_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
1774 struct hda_codec
*codec
,
1775 struct snd_pcm_substream
*substream
)
1777 struct alc_spec
*spec
= codec
->spec
;
1778 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
1784 static int alc_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
1785 struct hda_codec
*codec
,
1786 struct snd_pcm_substream
*substream
)
1788 struct alc_spec
*spec
= codec
->spec
;
1789 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
1792 static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
1793 struct hda_codec
*codec
,
1794 unsigned int stream_tag
,
1795 unsigned int format
,
1796 struct snd_pcm_substream
*substream
)
1798 struct alc_spec
*spec
= codec
->spec
;
1799 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
1800 stream_tag
, format
, substream
);
1803 static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
1804 struct hda_codec
*codec
,
1805 struct snd_pcm_substream
*substream
)
1807 struct alc_spec
*spec
= codec
->spec
;
1808 return snd_hda_multi_out_dig_cleanup(codec
, &spec
->multiout
);
1811 static int alc_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
1812 struct hda_codec
*codec
,
1813 struct snd_pcm_substream
*substream
)
1815 struct alc_spec
*spec
= codec
->spec
;
1816 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
1822 static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
1823 struct hda_codec
*codec
,
1824 unsigned int stream_tag
,
1825 unsigned int format
,
1826 struct snd_pcm_substream
*substream
)
1828 struct alc_spec
*spec
= codec
->spec
;
1830 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
+ 1],
1831 stream_tag
, 0, format
);
1835 static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
1836 struct hda_codec
*codec
,
1837 struct snd_pcm_substream
*substream
)
1839 struct alc_spec
*spec
= codec
->spec
;
1841 snd_hda_codec_cleanup_stream(codec
,
1842 spec
->adc_nids
[substream
->number
+ 1]);
1846 /* analog capture with dynamic dual-adc changes */
1847 static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
1848 struct hda_codec
*codec
,
1849 unsigned int stream_tag
,
1850 unsigned int format
,
1851 struct snd_pcm_substream
*substream
)
1853 struct alc_spec
*spec
= codec
->spec
;
1854 spec
->cur_adc
= spec
->adc_nids
[spec
->dyn_adc_idx
[spec
->cur_mux
[0]]];
1855 spec
->cur_adc_stream_tag
= stream_tag
;
1856 spec
->cur_adc_format
= format
;
1857 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
1861 static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
1862 struct hda_codec
*codec
,
1863 struct snd_pcm_substream
*substream
)
1865 struct alc_spec
*spec
= codec
->spec
;
1866 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
1871 static const struct hda_pcm_stream dyn_adc_pcm_analog_capture
= {
1875 .nid
= 0, /* fill later */
1877 .prepare
= dyn_adc_capture_pcm_prepare
,
1878 .cleanup
= dyn_adc_capture_pcm_cleanup
1884 static const struct hda_pcm_stream alc_pcm_analog_playback
= {
1888 /* NID is set in alc_build_pcms */
1890 .open
= alc_playback_pcm_open
,
1891 .prepare
= alc_playback_pcm_prepare
,
1892 .cleanup
= alc_playback_pcm_cleanup
1896 static const struct hda_pcm_stream alc_pcm_analog_capture
= {
1900 /* NID is set in alc_build_pcms */
1903 static const struct hda_pcm_stream alc_pcm_analog_alt_playback
= {
1907 /* NID is set in alc_build_pcms */
1910 static const struct hda_pcm_stream alc_pcm_analog_alt_capture
= {
1911 .substreams
= 2, /* can be overridden */
1914 /* NID is set in alc_build_pcms */
1916 .prepare
= alc_alt_capture_pcm_prepare
,
1917 .cleanup
= alc_alt_capture_pcm_cleanup
1921 static const struct hda_pcm_stream alc_pcm_digital_playback
= {
1925 /* NID is set in alc_build_pcms */
1927 .open
= alc_dig_playback_pcm_open
,
1928 .close
= alc_dig_playback_pcm_close
,
1929 .prepare
= alc_dig_playback_pcm_prepare
,
1930 .cleanup
= alc_dig_playback_pcm_cleanup
1934 static const struct hda_pcm_stream alc_pcm_digital_capture
= {
1938 /* NID is set in alc_build_pcms */
1941 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
1942 static const struct hda_pcm_stream alc_pcm_null_stream
= {
1948 static int alc_build_pcms(struct hda_codec
*codec
)
1950 struct alc_spec
*spec
= codec
->spec
;
1951 struct hda_pcm
*info
= spec
->pcm_rec
;
1952 const struct hda_pcm_stream
*p
;
1953 bool have_multi_adcs
;
1956 codec
->num_pcms
= 1;
1957 codec
->pcm_info
= info
;
1959 if (spec
->no_analog
)
1962 snprintf(spec
->stream_name_analog
, sizeof(spec
->stream_name_analog
),
1963 "%s Analog", codec
->chip_name
);
1964 info
->name
= spec
->stream_name_analog
;
1966 if (spec
->multiout
.num_dacs
> 0) {
1967 p
= spec
->stream_analog_playback
;
1969 p
= &alc_pcm_analog_playback
;
1970 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
1971 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dac_nids
[0];
1972 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
=
1973 spec
->multiout
.max_channels
;
1974 if (spec
->autocfg
.line_out_type
== AUTO_PIN_SPEAKER_OUT
&&
1975 spec
->autocfg
.line_outs
== 2)
1976 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].chmap
=
1979 if (spec
->num_adc_nids
) {
1980 p
= spec
->stream_analog_capture
;
1982 if (spec
->dyn_adc_switch
)
1983 p
= &dyn_adc_pcm_analog_capture
;
1985 p
= &alc_pcm_analog_capture
;
1987 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
1988 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
1991 if (spec
->channel_mode
) {
1992 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= 0;
1993 for (i
= 0; i
< spec
->num_channel_mode
; i
++) {
1994 if (spec
->channel_mode
[i
].channels
> info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
) {
1995 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= spec
->channel_mode
[i
].channels
;
2001 /* SPDIF for stream index #1 */
2002 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
2003 snprintf(spec
->stream_name_digital
,
2004 sizeof(spec
->stream_name_digital
),
2005 "%s Digital", codec
->chip_name
);
2006 codec
->num_pcms
= 2;
2007 codec
->slave_dig_outs
= spec
->multiout
.slave_dig_outs
;
2008 info
= spec
->pcm_rec
+ 1;
2009 info
->name
= spec
->stream_name_digital
;
2010 if (spec
->dig_out_type
)
2011 info
->pcm_type
= spec
->dig_out_type
;
2013 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
2014 if (spec
->multiout
.dig_out_nid
) {
2015 p
= spec
->stream_digital_playback
;
2017 p
= &alc_pcm_digital_playback
;
2018 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2019 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
2021 if (spec
->dig_in_nid
) {
2022 p
= spec
->stream_digital_capture
;
2024 p
= &alc_pcm_digital_capture
;
2025 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2026 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
2028 /* FIXME: do we need this for all Realtek codec models? */
2029 codec
->spdif_status_reset
= 1;
2032 if (spec
->no_analog
)
2035 /* If the use of more than one ADC is requested for the current
2036 * model, configure a second analog capture-only PCM.
2038 have_multi_adcs
= (spec
->num_adc_nids
> 1) &&
2039 !spec
->dyn_adc_switch
&& !spec
->auto_mic
;
2040 /* Additional Analaog capture for index #2 */
2041 if (spec
->alt_dac_nid
|| have_multi_adcs
) {
2042 codec
->num_pcms
= 3;
2043 info
= spec
->pcm_rec
+ 2;
2044 info
->name
= spec
->stream_name_analog
;
2045 if (spec
->alt_dac_nid
) {
2046 p
= spec
->stream_analog_alt_playback
;
2048 p
= &alc_pcm_analog_alt_playback
;
2049 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2050 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
2053 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
2054 alc_pcm_null_stream
;
2055 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= 0;
2057 if (have_multi_adcs
) {
2058 p
= spec
->stream_analog_alt_capture
;
2060 p
= &alc_pcm_analog_alt_capture
;
2061 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2062 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
2064 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
=
2065 spec
->num_adc_nids
- 1;
2067 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
2068 alc_pcm_null_stream
;
2069 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= 0;
2076 static inline void alc_shutup(struct hda_codec
*codec
)
2078 struct alc_spec
*spec
= codec
->spec
;
2080 if (spec
&& spec
->shutup
)
2081 spec
->shutup(codec
);
2082 snd_hda_shutup_pins(codec
);
2085 static void alc_free_kctls(struct hda_codec
*codec
)
2087 struct alc_spec
*spec
= codec
->spec
;
2089 if (spec
->kctls
.list
) {
2090 struct snd_kcontrol_new
*kctl
= spec
->kctls
.list
;
2092 for (i
= 0; i
< spec
->kctls
.used
; i
++)
2093 kfree(kctl
[i
].name
);
2095 snd_array_free(&spec
->kctls
);
2098 static void alc_free_bind_ctls(struct hda_codec
*codec
)
2100 struct alc_spec
*spec
= codec
->spec
;
2101 if (spec
->bind_ctls
.list
) {
2102 struct hda_bind_ctls
**ctl
= spec
->bind_ctls
.list
;
2104 for (i
= 0; i
< spec
->bind_ctls
.used
; i
++)
2107 snd_array_free(&spec
->bind_ctls
);
2110 static void alc_free(struct hda_codec
*codec
)
2112 struct alc_spec
*spec
= codec
->spec
;
2117 alc_free_kctls(codec
);
2118 alc_free_bind_ctls(codec
);
2119 snd_array_free(&spec
->paths
);
2120 snd_hda_gen_free(&spec
->gen
);
2122 snd_hda_detach_beep_device(codec
);
2126 static void alc_power_eapd(struct hda_codec
*codec
)
2128 alc_auto_setup_eapd(codec
, false);
2131 static int alc_suspend(struct hda_codec
*codec
)
2133 struct alc_spec
*spec
= codec
->spec
;
2135 if (spec
&& spec
->power_hook
)
2136 spec
->power_hook(codec
);
2142 static int alc_resume(struct hda_codec
*codec
)
2144 msleep(150); /* to avoid pop noise */
2145 codec
->patch_ops
.init(codec
);
2146 snd_hda_codec_resume_amp(codec
);
2147 snd_hda_codec_resume_cache(codec
);
2148 alc_inv_dmic_sync(codec
, true);
2149 hda_call_check_power_status(codec
, 0x01);
2156 static const struct hda_codec_ops alc_patch_ops
= {
2157 .build_controls
= alc_build_controls
,
2158 .build_pcms
= alc_build_pcms
,
2161 .unsol_event
= snd_hda_jack_unsol_event
,
2163 .resume
= alc_resume
,
2166 .suspend
= alc_suspend
,
2167 .check_power_status
= alc_check_power_status
,
2169 .reboot_notify
= alc_shutup
,
2173 /* replace the codec chip_name with the given string */
2174 static int alc_codec_rename(struct hda_codec
*codec
, const char *name
)
2176 kfree(codec
->chip_name
);
2177 codec
->chip_name
= kstrdup(name
, GFP_KERNEL
);
2178 if (!codec
->chip_name
) {
2186 * Rename codecs appropriately from COEF value
2188 struct alc_codec_rename_table
{
2189 unsigned int vendor_id
;
2190 unsigned short coef_mask
;
2191 unsigned short coef_bits
;
2195 static struct alc_codec_rename_table rename_tbl
[] = {
2196 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
2197 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
2198 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
2199 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
2200 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
2201 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
2202 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
2203 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
2204 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
2205 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
2206 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
2207 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
2208 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
2209 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
2210 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
2211 { } /* terminator */
2214 static int alc_codec_rename_from_preset(struct hda_codec
*codec
)
2216 const struct alc_codec_rename_table
*p
;
2218 for (p
= rename_tbl
; p
->vendor_id
; p
++) {
2219 if (p
->vendor_id
!= codec
->vendor_id
)
2221 if ((alc_get_coef0(codec
) & p
->coef_mask
) == p
->coef_bits
)
2222 return alc_codec_rename(codec
, p
->name
);
2228 * Automatic parse of I/O pins from the BIOS configuration
2233 ALC_CTL_WIDGET_MUTE
,
2238 static const struct snd_kcontrol_new alc_control_templates
[] = {
2239 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2240 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2241 HDA_BIND_MUTE(NULL
, 0, 0, 0),
2242 HDA_BIND_VOL(NULL
, 0),
2243 HDA_BIND_SW(NULL
, 0),
2246 /* add dynamic controls */
2247 static int add_control(struct alc_spec
*spec
, int type
, const char *name
,
2248 int cidx
, unsigned long val
)
2250 struct snd_kcontrol_new
*knew
;
2252 knew
= alc_kcontrol_new(spec
, name
, &alc_control_templates
[type
]);
2256 if (get_amp_nid_(val
))
2257 knew
->subdevice
= HDA_SUBDEV_AMP_FLAG
;
2258 knew
->private_value
= val
;
2262 static int add_control_with_pfx(struct alc_spec
*spec
, int type
,
2263 const char *pfx
, const char *dir
,
2264 const char *sfx
, int cidx
, unsigned long val
)
2267 snprintf(name
, sizeof(name
), "%s %s %s", pfx
, dir
, sfx
);
2268 return add_control(spec
, type
, name
, cidx
, val
);
2271 #define add_pb_vol_ctrl(spec, type, pfx, val) \
2272 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
2273 #define add_pb_sw_ctrl(spec, type, pfx, val) \
2274 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
2275 #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
2276 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
2277 #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
2278 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
2280 static const char * const channel_name
[4] = {
2281 "Front", "Surround", "CLFE", "Side"
2284 static const char *alc_get_line_out_pfx(struct alc_spec
*spec
, int ch
,
2285 bool can_be_master
, int *index
)
2287 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2290 if (cfg
->line_outs
== 1 && !spec
->multi_ios
&&
2291 !cfg
->hp_outs
&& !cfg
->speaker_outs
&& can_be_master
)
2292 return spec
->vmaster_mute
.hook
? "PCM" : "Master";
2294 /* if there is really a single DAC used in the whole output paths,
2295 * use it master (or "PCM" if a vmaster hook is present)
2297 if (spec
->multiout
.num_dacs
== 1 && !spec
->mixer_nid
&&
2298 !spec
->multiout
.hp_out_nid
[0] && !spec
->multiout
.extra_out_nid
[0])
2299 return spec
->vmaster_mute
.hook
? "PCM" : "Master";
2301 switch (cfg
->line_out_type
) {
2302 case AUTO_PIN_SPEAKER_OUT
:
2303 if (cfg
->line_outs
== 1)
2305 if (cfg
->line_outs
== 2)
2306 return ch
? "Bass Speaker" : "Speaker";
2308 case AUTO_PIN_HP_OUT
:
2309 /* for multi-io case, only the primary out */
2310 if (ch
&& spec
->multi_ios
)
2315 if (cfg
->line_outs
== 1 && !spec
->multi_ios
)
2319 if (ch
>= ARRAY_SIZE(channel_name
)) {
2324 return channel_name
[ch
];
2328 /* add the powersave loopback-list entry */
2329 static void add_loopback_list(struct alc_spec
*spec
, hda_nid_t mix
, int idx
)
2331 struct hda_amp_list
*list
;
2333 if (spec
->num_loopbacks
>= ARRAY_SIZE(spec
->loopback_list
) - 1)
2335 list
= spec
->loopback_list
+ spec
->num_loopbacks
;
2337 list
->dir
= HDA_INPUT
;
2339 spec
->num_loopbacks
++;
2340 spec
->loopback
.amplist
= spec
->loopback_list
;
2343 #define add_loopback_list(spec, mix, idx) /* NOP */
2346 /* create input playback/capture controls for the given pin */
2347 static int new_analog_input(struct hda_codec
*codec
, hda_nid_t pin
,
2348 const char *ctlname
, int ctlidx
,
2351 struct alc_spec
*spec
= codec
->spec
;
2352 struct nid_path
*path
;
2356 if (!nid_has_volume(codec
, mix_nid
, HDA_INPUT
) &&
2357 !nid_has_mute(codec
, mix_nid
, HDA_INPUT
))
2358 return 0; /* no need for analog loopback */
2360 path
= add_new_nid_path(codec
, pin
, mix_nid
, 2);
2364 idx
= path
->idx
[path
->depth
- 1];
2365 if (nid_has_volume(codec
, mix_nid
, HDA_INPUT
)) {
2366 val
= HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
);
2367 err
= __add_pb_vol_ctrl(spec
, ALC_CTL_WIDGET_VOL
, ctlname
, ctlidx
, val
);
2370 path
->ctls
[NID_PATH_VOL_CTL
] = val
;
2373 if (nid_has_mute(codec
, mix_nid
, HDA_INPUT
)) {
2374 val
= HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
);
2375 err
= __add_pb_sw_ctrl(spec
, ALC_CTL_WIDGET_MUTE
, ctlname
, ctlidx
, val
);
2378 path
->ctls
[NID_PATH_MUTE_CTL
] = val
;
2381 path
->active
= true;
2382 add_loopback_list(spec
, mix_nid
, idx
);
2386 static int alc_is_input_pin(struct hda_codec
*codec
, hda_nid_t nid
)
2388 unsigned int pincap
= snd_hda_query_pin_caps(codec
, nid
);
2389 return (pincap
& AC_PINCAP_IN
) != 0;
2392 /* check whether the given two widgets can be connected */
2393 static bool is_reachable_path(struct hda_codec
*codec
,
2394 hda_nid_t from_nid
, hda_nid_t to_nid
)
2396 if (!from_nid
|| !to_nid
)
2398 return snd_hda_get_conn_index(codec
, to_nid
, from_nid
, true) >= 0;
2401 /* Parse the codec tree and retrieve ADCs */
2402 static int alc_auto_fill_adc_nids(struct hda_codec
*codec
)
2404 struct alc_spec
*spec
= codec
->spec
;
2406 hda_nid_t
*adc_nids
= spec
->adc_nids
;
2407 int max_nums
= ARRAY_SIZE(spec
->adc_nids
);
2410 nid
= codec
->start_nid
;
2411 for (i
= 0; i
< codec
->num_nodes
; i
++, nid
++) {
2412 unsigned int caps
= get_wcaps(codec
, nid
);
2413 int type
= get_wcaps_type(caps
);
2415 if (type
!= AC_WID_AUD_IN
|| (caps
& AC_WCAP_DIGITAL
))
2417 adc_nids
[nums
] = nid
;
2418 if (++nums
>= max_nums
)
2421 spec
->num_adc_nids
= nums
;
2425 /* filter out invalid adc_nids that don't give all active input pins;
2426 * if needed, check whether dynamic ADC-switching is available
2428 static int check_dyn_adc_switch(struct hda_codec
*codec
)
2430 struct alc_spec
*spec
= codec
->spec
;
2431 struct hda_input_mux
*imux
= &spec
->input_mux
;
2432 hda_nid_t adc_nids
[ARRAY_SIZE(spec
->adc_nids
)];
2438 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
2439 adc
= spec
->adc_nids
[n
];
2440 for (i
= 0; i
< imux
->num_items
; i
++) {
2441 pin
= spec
->imux_pins
[i
];
2442 if (!is_reachable_path(codec
, pin
, adc
))
2445 if (i
>= imux
->num_items
)
2446 adc_nids
[nums
++] = adc
;
2450 if (spec
->shared_mic_hp
) {
2451 spec
->shared_mic_hp
= 0;
2452 imux
->num_items
= 1;
2456 /* check whether ADC-switch is possible */
2457 for (i
= 0; i
< imux
->num_items
; i
++) {
2458 pin
= spec
->imux_pins
[i
];
2459 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
2460 adc
= spec
->adc_nids
[n
];
2461 if (is_reachable_path(codec
, pin
, adc
)) {
2462 spec
->dyn_adc_idx
[i
] = n
;
2468 snd_printdd("realtek: enabling ADC switching\n");
2469 spec
->dyn_adc_switch
= 1;
2470 } else if (nums
!= spec
->num_adc_nids
) {
2471 memcpy(spec
->adc_nids
, adc_nids
, nums
* sizeof(hda_nid_t
));
2472 spec
->num_adc_nids
= nums
;
2475 if (imux
->num_items
== 1 || spec
->shared_mic_hp
) {
2476 snd_printdd("realtek: reducing to a single ADC\n");
2477 spec
->num_adc_nids
= 1; /* reduce to a single ADC */
2480 /* single index for individual volumes ctls */
2481 if (!spec
->dyn_adc_switch
&& spec
->multi_cap_vol
)
2482 spec
->num_adc_nids
= 1;
2487 /* templates for capture controls */
2488 static const struct snd_kcontrol_new cap_src_temp
= {
2489 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2490 .name
= "Input Source",
2491 .info
= alc_mux_enum_info
,
2492 .get
= alc_mux_enum_get
,
2493 .put
= alc_mux_enum_put
,
2496 static const struct snd_kcontrol_new cap_vol_temp
= {
2497 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2498 .name
= "Capture Volume",
2499 .access
= (SNDRV_CTL_ELEM_ACCESS_READWRITE
|
2500 SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
2501 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK
),
2502 .info
= alc_cap_vol_info
,
2503 .get
= alc_cap_vol_get
,
2504 .put
= alc_cap_vol_put
,
2505 .tlv
= { .c
= alc_cap_vol_tlv
},
2508 static const struct snd_kcontrol_new cap_sw_temp
= {
2509 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2510 .name
= "Capture Switch",
2511 .info
= alc_cap_sw_info
,
2512 .get
= alc_cap_sw_get
,
2513 .put
= alc_cap_sw_put
,
2516 static int parse_capvol_in_path(struct hda_codec
*codec
, struct nid_path
*path
)
2521 path
->ctls
[NID_PATH_VOL_CTL
] = path
->ctls
[NID_PATH_MUTE_CTL
] = 0;
2522 for (depth
= 0; depth
< 3; depth
++) {
2523 if (depth
>= path
->depth
)
2525 i
= path
->depth
- depth
- 1;
2526 nid
= path
->path
[i
];
2527 if (!path
->ctls
[NID_PATH_VOL_CTL
]) {
2528 if (nid_has_volume(codec
, nid
, HDA_OUTPUT
))
2529 path
->ctls
[NID_PATH_VOL_CTL
] =
2530 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
2531 else if (nid_has_volume(codec
, nid
, HDA_INPUT
)) {
2532 int idx
= path
->idx
[i
];
2533 if (!depth
&& codec
->single_adc_amp
)
2535 path
->ctls
[NID_PATH_VOL_CTL
] =
2536 HDA_COMPOSE_AMP_VAL(nid
, 3, idx
, HDA_INPUT
);
2539 if (!path
->ctls
[NID_PATH_MUTE_CTL
]) {
2540 if (nid_has_mute(codec
, nid
, HDA_OUTPUT
))
2541 path
->ctls
[NID_PATH_MUTE_CTL
] =
2542 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
2543 else if (nid_has_mute(codec
, nid
, HDA_INPUT
)) {
2544 int idx
= path
->idx
[i
];
2545 if (!depth
&& codec
->single_adc_amp
)
2547 path
->ctls
[NID_PATH_MUTE_CTL
] =
2548 HDA_COMPOSE_AMP_VAL(nid
, 3, idx
, HDA_INPUT
);
2555 static unsigned int amp_val_replace_channels(unsigned int val
, unsigned int chs
);
2557 static int add_single_cap_ctl(struct hda_codec
*codec
, const char *label
,
2558 int idx
, bool is_switch
, unsigned int ctl
)
2560 struct alc_spec
*spec
= codec
->spec
;
2562 int type
= is_switch
? ALC_CTL_WIDGET_MUTE
: ALC_CTL_WIDGET_VOL
;
2563 const char *sfx
= is_switch
? "Switch" : "Volume";
2570 if (idx
== spec
->inv_dmic_split_idx
)
2576 snprintf(tmpname
, sizeof(tmpname
),
2577 "%s Capture %s", label
, sfx
);
2579 snprintf(tmpname
, sizeof(tmpname
),
2581 err
= add_control(spec
, type
, tmpname
, idx
,
2582 amp_val_replace_channels(ctl
, chs
));
2583 if (err
< 0 || chs
== 3)
2586 /* Make independent right kcontrol */
2588 snprintf(tmpname
, sizeof(tmpname
),
2589 "Inverted %s Capture %s", label
, sfx
);
2591 snprintf(tmpname
, sizeof(tmpname
),
2592 "Inverted Capture %s", sfx
);
2593 return add_control(spec
, type
, tmpname
, idx
,
2594 amp_val_replace_channels(ctl
, 2));
2597 /* create single (and simple) capture volume and switch controls */
2598 static int create_single_cap_vol_ctl(struct hda_codec
*codec
, int idx
,
2599 unsigned int vol_ctl
, unsigned int sw_ctl
)
2602 err
= add_single_cap_ctl(codec
, NULL
, idx
, false, vol_ctl
);
2605 err
= add_single_cap_ctl(codec
, NULL
, idx
, true, sw_ctl
);
2611 /* create bound capture volume and switch controls */
2612 static int create_bind_cap_vol_ctl(struct hda_codec
*codec
, int idx
,
2613 unsigned int vol_ctl
, unsigned int sw_ctl
)
2615 struct alc_spec
*spec
= codec
->spec
;
2616 struct snd_kcontrol_new
*knew
;
2619 knew
= alc_kcontrol_new(spec
, NULL
, &cap_vol_temp
);
2623 knew
->private_value
= vol_ctl
;
2624 knew
->subdevice
= HDA_SUBDEV_AMP_FLAG
;
2627 knew
= alc_kcontrol_new(spec
, NULL
, &cap_sw_temp
);
2631 knew
->private_value
= sw_ctl
;
2632 knew
->subdevice
= HDA_SUBDEV_AMP_FLAG
;
2637 /* return the vol ctl when used first in the imux list */
2638 static unsigned int get_first_cap_ctl(struct hda_codec
*codec
, int idx
, int type
)
2640 struct alc_spec
*spec
= codec
->spec
;
2641 struct nid_path
*path
;
2645 path
= get_nid_path(codec
, spec
->imux_pins
[idx
],
2646 get_adc_nid(codec
, 0, idx
));
2649 ctl
= path
->ctls
[type
];
2652 for (i
= 0; i
< idx
- 1; i
++) {
2653 path
= get_nid_path(codec
, spec
->imux_pins
[i
],
2654 get_adc_nid(codec
, 0, i
));
2655 if (path
&& path
->ctls
[type
] == ctl
)
2661 /* create individual capture volume and switch controls per input */
2662 static int create_multi_cap_vol_ctl(struct hda_codec
*codec
)
2664 struct alc_spec
*spec
= codec
->spec
;
2665 struct hda_input_mux
*imux
= &spec
->input_mux
;
2666 int i
, err
, type
, type_idx
= 0;
2667 const char *prev_label
= NULL
;
2669 for (i
= 0; i
< imux
->num_items
; i
++) {
2671 label
= hda_get_autocfg_input_label(codec
, &spec
->autocfg
, i
);
2672 if (prev_label
&& !strcmp(label
, prev_label
))
2678 for (type
= 0; type
< 2; type
++) {
2679 err
= add_single_cap_ctl(codec
, label
, type_idx
, type
,
2680 get_first_cap_ctl(codec
, i
, type
));
2688 static int create_capture_mixers(struct hda_codec
*codec
)
2690 struct alc_spec
*spec
= codec
->spec
;
2691 struct hda_input_mux
*imux
= &spec
->input_mux
;
2692 int i
, n
, nums
, err
;
2694 if (spec
->dyn_adc_switch
)
2697 nums
= spec
->num_adc_nids
;
2699 if (!spec
->auto_mic
&& imux
->num_items
> 1) {
2700 struct snd_kcontrol_new
*knew
;
2701 knew
= alc_kcontrol_new(spec
, NULL
, &cap_src_temp
);
2707 for (n
= 0; n
< nums
; n
++) {
2712 for (i
= 0; i
< imux
->num_items
; i
++) {
2713 struct nid_path
*path
;
2714 path
= get_nid_path(codec
, spec
->imux_pins
[i
],
2715 get_adc_nid(codec
, n
, i
));
2718 parse_capvol_in_path(codec
, path
);
2720 vol
= path
->ctls
[NID_PATH_VOL_CTL
];
2721 else if (vol
!= path
->ctls
[NID_PATH_VOL_CTL
])
2724 sw
= path
->ctls
[NID_PATH_MUTE_CTL
];
2725 else if (sw
!= path
->ctls
[NID_PATH_MUTE_CTL
])
2730 err
= create_single_cap_vol_ctl(codec
, n
, vol
, sw
);
2731 else if (!spec
->multi_cap_vol
)
2732 err
= create_bind_cap_vol_ctl(codec
, n
, vol
, sw
);
2734 err
= create_multi_cap_vol_ctl(codec
);
2742 /* create playback/capture controls for input pins */
2743 static int alc_auto_create_input_ctls(struct hda_codec
*codec
)
2745 struct alc_spec
*spec
= codec
->spec
;
2746 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2747 hda_nid_t mixer
= spec
->mixer_nid
;
2748 struct hda_input_mux
*imux
= &spec
->input_mux
;
2750 int i
, c
, err
, type_idx
= 0;
2751 const char *prev_label
= NULL
;
2753 num_adcs
= alc_auto_fill_adc_nids(codec
);
2757 spec
->inv_dmic_split_idx
= -1;
2758 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2763 pin
= cfg
->inputs
[i
].pin
;
2764 if (!alc_is_input_pin(codec
, pin
))
2767 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
2768 if (spec
->shared_mic_hp
&& !strcmp(label
, "Misc"))
2769 label
= "Headphone Mic";
2770 if (prev_label
&& !strcmp(label
, prev_label
))
2777 if (is_reachable_path(codec
, pin
, mixer
)) {
2778 err
= new_analog_input(codec
, pin
,
2779 label
, type_idx
, mixer
);
2786 for (c
= 0; c
< num_adcs
; c
++) {
2787 struct nid_path
*path
;
2788 hda_nid_t adc
= spec
->adc_nids
[c
];
2790 if (!is_reachable_path(codec
, pin
, adc
))
2792 path
= snd_array_new(&spec
->paths
);
2795 memset(path
, 0, sizeof(*path
));
2796 if (!parse_nid_path(codec
, pin
, adc
, 2, path
)) {
2798 "invalid input path 0x%x -> 0x%x\n",
2805 spec
->imux_pins
[imux
->num_items
] = pin
;
2806 snd_hda_add_imux_item(imux
, label
,
2807 imux
->num_items
, NULL
);
2812 if (spec
->inv_dmic_split
) {
2813 if (cfg
->inputs
[i
].type
== AUTO_PIN_MIC
) {
2814 unsigned int def_conf
= snd_hda_codec_get_pincfg(codec
, pin
);
2815 if (snd_hda_get_input_pin_attr(def_conf
) == INPUT_PIN_ATTR_INT
)
2816 spec
->inv_dmic_split_idx
= i
;
2824 /* create a shared input with the headphone out */
2825 static int alc_auto_create_shared_input(struct hda_codec
*codec
)
2827 struct alc_spec
*spec
= codec
->spec
;
2828 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2829 unsigned int defcfg
;
2832 /* only one internal input pin? */
2833 if (cfg
->num_inputs
!= 1)
2835 defcfg
= snd_hda_codec_get_pincfg(codec
, cfg
->inputs
[0].pin
);
2836 if (snd_hda_get_input_pin_attr(defcfg
) != INPUT_PIN_ATTR_INT
)
2839 if (cfg
->hp_outs
== 1 && cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
)
2840 nid
= cfg
->hp_pins
[0]; /* OK, we have a single HP-out */
2841 else if (cfg
->line_outs
== 1 && cfg
->line_out_type
== AUTO_PIN_HP_OUT
)
2842 nid
= cfg
->line_out_pins
[0]; /* OK, we have a single line-out */
2844 return 0; /* both not available */
2846 if (!(snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_IN
))
2847 return 0; /* no input */
2849 cfg
->inputs
[1].pin
= nid
;
2850 cfg
->inputs
[1].type
= AUTO_PIN_MIC
;
2851 cfg
->num_inputs
= 2;
2852 spec
->shared_mic_hp
= 1;
2853 snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid
);
2857 static int get_pin_type(int line_out_type
)
2859 if (line_out_type
== AUTO_PIN_HP_OUT
)
2865 static void alc_auto_init_analog_input(struct hda_codec
*codec
)
2867 struct alc_spec
*spec
= codec
->spec
;
2868 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2871 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2872 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
2873 if (alc_is_input_pin(codec
, nid
))
2874 alc_set_input_pin(codec
, nid
, cfg
->inputs
[i
].type
);
2876 /* mute loopback inputs */
2877 if (spec
->mixer_nid
) {
2878 struct nid_path
*path
;
2879 path
= get_nid_path(codec
, nid
, spec
->mixer_nid
);
2881 activate_path(codec
, path
, path
->active
, false);
2886 static bool alc_is_dac_already_used(struct hda_codec
*codec
, hda_nid_t nid
)
2888 struct alc_spec
*spec
= codec
->spec
;
2891 for (i
= 0; i
< spec
->paths
.used
; i
++) {
2892 struct nid_path
*path
= snd_array_elem(&spec
->paths
, i
);
2893 if (path
->path
[0] == nid
)
2899 /* look for an empty DAC slot */
2900 static hda_nid_t
alc_auto_look_for_dac(struct hda_codec
*codec
, hda_nid_t pin
,
2903 struct alc_spec
*spec
= codec
->spec
;
2907 for (i
= 0; i
< spec
->num_all_dacs
; i
++) {
2908 hda_nid_t nid
= spec
->all_dacs
[i
];
2909 if (!nid
|| alc_is_dac_already_used(codec
, nid
))
2911 cap_digital
= !!(get_wcaps(codec
, nid
) & AC_WCAP_DIGITAL
);
2912 if (is_digital
!= cap_digital
)
2914 if (is_reachable_path(codec
, nid
, pin
))
2920 /* called recursively */
2921 static bool __parse_nid_path(struct hda_codec
*codec
,
2922 hda_nid_t from_nid
, hda_nid_t to_nid
,
2923 int with_aa_mix
, struct nid_path
*path
, int depth
)
2925 struct alc_spec
*spec
= codec
->spec
;
2929 if (to_nid
== spec
->mixer_nid
) {
2932 with_aa_mix
= 2; /* mark aa-mix is included */
2935 nums
= snd_hda_get_connections(codec
, to_nid
, conn
, ARRAY_SIZE(conn
));
2936 for (i
= 0; i
< nums
; i
++) {
2937 if (conn
[i
] != from_nid
) {
2938 /* special case: when from_nid is 0,
2939 * try to find an empty DAC
2942 get_wcaps_type(get_wcaps(codec
, conn
[i
])) != AC_WID_AUD_OUT
||
2943 alc_is_dac_already_used(codec
, conn
[i
]))
2946 /* aa-mix is requested but not included? */
2947 if (!(spec
->mixer_nid
&& with_aa_mix
== 1))
2950 if (depth
>= MAX_NID_PATH_DEPTH
)
2952 for (i
= 0; i
< nums
; i
++) {
2954 type
= get_wcaps_type(get_wcaps(codec
, conn
[i
]));
2955 if (type
== AC_WID_AUD_OUT
|| type
== AC_WID_AUD_IN
||
2958 if (__parse_nid_path(codec
, from_nid
, conn
[i
],
2959 with_aa_mix
, path
, depth
+ 1))
2965 path
->path
[path
->depth
] = conn
[i
];
2966 path
->idx
[path
->depth
+ 1] = i
;
2967 if (nums
> 1 && get_wcaps_type(get_wcaps(codec
, to_nid
)) != AC_WID_AUD_MIX
)
2968 path
->multi
[path
->depth
+ 1] = 1;
2973 /* parse the widget path from the given nid to the target nid;
2974 * when @from_nid is 0, try to find an empty DAC;
2975 * when @with_aa_mix is 0, paths with spec->mixer_nid are excluded.
2976 * when @with_aa_mix is 1, paths without spec->mixer_nid are excluded.
2977 * when @with_aa_mix is 2, no special handling about spec->mixer_nid.
2979 static bool parse_nid_path(struct hda_codec
*codec
, hda_nid_t from_nid
,
2980 hda_nid_t to_nid
, int with_aa_mix
,
2981 struct nid_path
*path
)
2983 if (__parse_nid_path(codec
, from_nid
, to_nid
, with_aa_mix
, path
, 1)) {
2984 path
->path
[path
->depth
] = to_nid
;
2987 snd_printdd("path: depth=%d, %02x/%02x/%02x/%02x/%02x\n",
2988 path
->depth
, path
->path
[0], path
->path
[1],
2989 path
->path
[2], path
->path
[3], path
->path
[4]);
2996 static hda_nid_t
get_dac_if_single(struct hda_codec
*codec
, hda_nid_t pin
)
2998 struct alc_spec
*spec
= codec
->spec
;
3000 hda_nid_t nid_found
= 0;
3002 for (i
= 0; i
< spec
->num_all_dacs
; i
++) {
3003 hda_nid_t nid
= spec
->all_dacs
[i
];
3004 if (!nid
|| alc_is_dac_already_used(codec
, nid
))
3006 if (is_reachable_path(codec
, nid
, pin
)) {
3015 static bool is_ctl_used(struct hda_codec
*codec
, unsigned int val
, int type
)
3017 struct alc_spec
*spec
= codec
->spec
;
3020 for (i
= 0; i
< spec
->paths
.used
; i
++) {
3021 struct nid_path
*path
= snd_array_elem(&spec
->paths
, i
);
3022 if (path
->ctls
[type
] == val
)
3028 /* badness definition */
3030 /* No primary DAC is found for the main output */
3031 BAD_NO_PRIMARY_DAC
= 0x10000,
3032 /* No DAC is found for the extra output */
3033 BAD_NO_DAC
= 0x4000,
3034 /* No possible multi-ios */
3035 BAD_MULTI_IO
= 0x103,
3036 /* No individual DAC for extra output */
3037 BAD_NO_EXTRA_DAC
= 0x102,
3038 /* No individual DAC for extra surrounds */
3039 BAD_NO_EXTRA_SURR_DAC
= 0x101,
3040 /* Primary DAC shared with main surrounds */
3041 BAD_SHARED_SURROUND
= 0x100,
3042 /* Primary DAC shared with main CLFE */
3043 BAD_SHARED_CLFE
= 0x10,
3044 /* Primary DAC shared with extra surrounds */
3045 BAD_SHARED_EXTRA_SURROUND
= 0x10,
3046 /* Volume widget is shared */
3047 BAD_SHARED_VOL
= 0x10,
3050 static hda_nid_t
alc_look_for_out_mute_nid(struct hda_codec
*codec
,
3051 struct nid_path
*path
);
3052 static hda_nid_t
alc_look_for_out_vol_nid(struct hda_codec
*codec
,
3053 struct nid_path
*path
);
3055 static struct nid_path
*add_new_nid_path(struct hda_codec
*codec
,
3056 hda_nid_t from_nid
, hda_nid_t to_nid
,
3059 struct alc_spec
*spec
= codec
->spec
;
3060 struct nid_path
*path
;
3062 if (from_nid
&& to_nid
&& !is_reachable_path(codec
, from_nid
, to_nid
))
3065 path
= snd_array_new(&spec
->paths
);
3068 memset(path
, 0, sizeof(*path
));
3069 if (parse_nid_path(codec
, from_nid
, to_nid
, with_aa_mix
, path
))
3076 /* get the path between the given NIDs;
3077 * passing 0 to either @pin or @dac behaves as a wildcard
3079 static struct nid_path
*
3080 get_nid_path(struct hda_codec
*codec
, hda_nid_t from_nid
, hda_nid_t to_nid
)
3082 struct alc_spec
*spec
= codec
->spec
;
3085 for (i
= 0; i
< spec
->paths
.used
; i
++) {
3086 struct nid_path
*path
= snd_array_elem(&spec
->paths
, i
);
3087 if (path
->depth
<= 0)
3089 if ((!from_nid
|| path
->path
[0] == from_nid
) &&
3090 (!to_nid
|| path
->path
[path
->depth
- 1] == to_nid
))
3096 /* look for widgets in the path between the given NIDs appropriate for
3097 * volume and mute controls, and assign the values to ctls[].
3099 * When no appropriate widget is found in the path, the badness value
3100 * is incremented depending on the situation. The function returns the
3101 * total badness for both volume and mute controls.
3103 static int assign_out_path_ctls(struct hda_codec
*codec
, hda_nid_t pin
,
3106 struct nid_path
*path
= get_nid_path(codec
, dac
, pin
);
3112 return BAD_SHARED_VOL
* 2;
3113 nid
= alc_look_for_out_vol_nid(codec
, path
);
3115 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
3116 if (is_ctl_used(codec
, val
, NID_PATH_VOL_CTL
))
3117 badness
+= BAD_SHARED_VOL
;
3119 path
->ctls
[NID_PATH_VOL_CTL
] = val
;
3121 badness
+= BAD_SHARED_VOL
;
3122 nid
= alc_look_for_out_mute_nid(codec
, path
);
3124 unsigned int wid_type
= get_wcaps_type(get_wcaps(codec
, nid
));
3125 if (wid_type
== AC_WID_PIN
|| wid_type
== AC_WID_AUD_OUT
||
3126 nid_has_mute(codec
, nid
, HDA_OUTPUT
))
3127 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
3129 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_INPUT
);
3130 if (is_ctl_used(codec
, val
, NID_PATH_MUTE_CTL
))
3131 badness
+= BAD_SHARED_VOL
;
3133 path
->ctls
[NID_PATH_MUTE_CTL
] = val
;
3135 badness
+= BAD_SHARED_VOL
;
3139 struct badness_table
{
3140 int no_primary_dac
; /* no primary DAC */
3141 int no_dac
; /* no secondary DACs */
3142 int shared_primary
; /* primary DAC is shared with main output */
3143 int shared_surr
; /* secondary DAC shared with main or primary */
3144 int shared_clfe
; /* third DAC shared with main or primary */
3145 int shared_surr_main
; /* secondary DAC sahred with main/DAC0 */
3148 static struct badness_table main_out_badness
= {
3149 .no_primary_dac
= BAD_NO_PRIMARY_DAC
,
3150 .no_dac
= BAD_NO_DAC
,
3151 .shared_primary
= BAD_NO_PRIMARY_DAC
,
3152 .shared_surr
= BAD_SHARED_SURROUND
,
3153 .shared_clfe
= BAD_SHARED_CLFE
,
3154 .shared_surr_main
= BAD_SHARED_SURROUND
,
3157 static struct badness_table extra_out_badness
= {
3158 .no_primary_dac
= BAD_NO_DAC
,
3159 .no_dac
= BAD_NO_DAC
,
3160 .shared_primary
= BAD_NO_EXTRA_DAC
,
3161 .shared_surr
= BAD_SHARED_EXTRA_SURROUND
,
3162 .shared_clfe
= BAD_SHARED_EXTRA_SURROUND
,
3163 .shared_surr_main
= BAD_NO_EXTRA_SURR_DAC
,
3166 /* try to assign DACs to pins and return the resultant badness */
3167 static int alc_auto_fill_dacs(struct hda_codec
*codec
, int num_outs
,
3168 const hda_nid_t
*pins
, hda_nid_t
*dacs
,
3169 const struct badness_table
*bad
)
3171 struct alc_spec
*spec
= codec
->spec
;
3172 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3180 for (i
= 0; i
< num_outs
; i
++) {
3181 hda_nid_t pin
= pins
[i
];
3183 dacs
[i
] = alc_auto_look_for_dac(codec
, pin
, false);
3184 if (!dacs
[i
] && !i
) {
3185 for (j
= 1; j
< num_outs
; j
++) {
3186 if (is_reachable_path(codec
, dacs
[j
], pin
)) {
3195 if (is_reachable_path(codec
, dacs
[0], pin
))
3197 else if (cfg
->line_outs
> i
&&
3198 is_reachable_path(codec
, spec
->private_dac_nids
[i
], pin
))
3199 dac
= spec
->private_dac_nids
[i
];
3202 badness
+= bad
->shared_primary
;
3204 badness
+= bad
->shared_surr
;
3206 badness
+= bad
->shared_clfe
;
3207 } else if (is_reachable_path(codec
, spec
->private_dac_nids
[0], pin
)) {
3208 dac
= spec
->private_dac_nids
[0];
3209 badness
+= bad
->shared_surr_main
;
3211 badness
+= bad
->no_primary_dac
;
3213 badness
+= bad
->no_dac
;
3215 if (!add_new_nid_path(codec
, dac
, pin
, 0))
3218 badness
+= assign_out_path_ctls(codec
, pin
, dac
);
3224 static int alc_auto_fill_multi_ios(struct hda_codec
*codec
,
3225 hda_nid_t reference_pin
,
3226 bool hardwired
, int offset
);
3228 static bool alc_map_singles(struct hda_codec
*codec
, int outs
,
3229 const hda_nid_t
*pins
, hda_nid_t
*dacs
)
3233 for (i
= 0; i
< outs
; i
++) {
3237 dac
= get_dac_if_single(codec
, pins
[i
]);
3240 if (add_new_nid_path(codec
, dac
, pins
[i
], 0)) {
3248 /* fill in the dac_nids table from the parsed pin configuration */
3249 static int fill_and_eval_dacs(struct hda_codec
*codec
,
3250 bool fill_hardwired
,
3251 bool fill_mio_first
)
3253 struct alc_spec
*spec
= codec
->spec
;
3254 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3255 int i
, err
, badness
;
3257 /* set num_dacs once to full for alc_auto_look_for_dac() */
3258 spec
->multiout
.num_dacs
= cfg
->line_outs
;
3259 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3260 memset(spec
->private_dac_nids
, 0, sizeof(spec
->private_dac_nids
));
3261 memset(spec
->multiout
.hp_out_nid
, 0, sizeof(spec
->multiout
.hp_out_nid
));
3262 memset(spec
->multiout
.extra_out_nid
, 0, sizeof(spec
->multiout
.extra_out_nid
));
3263 spec
->multi_ios
= 0;
3264 snd_array_free(&spec
->paths
);
3267 /* fill hard-wired DACs first */
3268 if (fill_hardwired
) {
3271 mapped
= alc_map_singles(codec
, cfg
->line_outs
,
3273 spec
->private_dac_nids
);
3274 mapped
|= alc_map_singles(codec
, cfg
->hp_outs
,
3276 spec
->multiout
.hp_out_nid
);
3277 mapped
|= alc_map_singles(codec
, cfg
->speaker_outs
,
3279 spec
->multiout
.extra_out_nid
);
3280 if (fill_mio_first
&& cfg
->line_outs
== 1 &&
3281 cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3282 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], true, 0);
3289 badness
+= alc_auto_fill_dacs(codec
, cfg
->line_outs
, cfg
->line_out_pins
,
3290 spec
->private_dac_nids
,
3293 /* re-count num_dacs and squash invalid entries */
3294 spec
->multiout
.num_dacs
= 0;
3295 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3296 if (spec
->private_dac_nids
[i
])
3297 spec
->multiout
.num_dacs
++;
3299 memmove(spec
->private_dac_nids
+ i
,
3300 spec
->private_dac_nids
+ i
+ 1,
3301 sizeof(hda_nid_t
) * (cfg
->line_outs
- i
- 1));
3302 spec
->private_dac_nids
[cfg
->line_outs
- 1] = 0;
3306 if (fill_mio_first
&&
3307 cfg
->line_outs
== 1 && cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3308 /* try to fill multi-io first */
3309 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], false, 0);
3312 /* we don't count badness at this stage yet */
3315 if (cfg
->line_out_type
!= AUTO_PIN_HP_OUT
) {
3316 err
= alc_auto_fill_dacs(codec
, cfg
->hp_outs
, cfg
->hp_pins
,
3317 spec
->multiout
.hp_out_nid
,
3318 &extra_out_badness
);
3323 if (cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3324 err
= alc_auto_fill_dacs(codec
, cfg
->speaker_outs
,
3326 spec
->multiout
.extra_out_nid
,
3327 &extra_out_badness
);
3332 if (cfg
->line_outs
== 1 && cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3333 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], false, 0);
3338 if (cfg
->hp_outs
&& cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
3339 /* try multi-ios with HP + inputs */
3341 if (cfg
->line_outs
>= 3)
3343 err
= alc_auto_fill_multi_ios(codec
, cfg
->hp_pins
[0], false,
3350 if (spec
->multi_ios
== 2) {
3351 for (i
= 0; i
< 2; i
++)
3352 spec
->private_dac_nids
[spec
->multiout
.num_dacs
++] =
3353 spec
->multi_io
[i
].dac
;
3354 spec
->ext_channel_count
= 2;
3355 } else if (spec
->multi_ios
) {
3356 spec
->multi_ios
= 0;
3357 badness
+= BAD_MULTI_IO
;
3363 #define DEBUG_BADNESS
3365 #ifdef DEBUG_BADNESS
3366 #define debug_badness snd_printdd
3368 #define debug_badness(...)
3371 static void debug_show_configs(struct alc_spec
*spec
, struct auto_pin_cfg
*cfg
)
3373 debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3374 cfg
->line_out_pins
[0], cfg
->line_out_pins
[1],
3375 cfg
->line_out_pins
[2], cfg
->line_out_pins
[2],
3376 spec
->multiout
.dac_nids
[0],
3377 spec
->multiout
.dac_nids
[1],
3378 spec
->multiout
.dac_nids
[2],
3379 spec
->multiout
.dac_nids
[3]);
3380 if (spec
->multi_ios
> 0)
3381 debug_badness("multi_ios(%d) = %x/%x : %x/%x\n",
3383 spec
->multi_io
[0].pin
, spec
->multi_io
[1].pin
,
3384 spec
->multi_io
[0].dac
, spec
->multi_io
[1].dac
);
3385 debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3386 cfg
->hp_pins
[0], cfg
->hp_pins
[1],
3387 cfg
->hp_pins
[2], cfg
->hp_pins
[2],
3388 spec
->multiout
.hp_out_nid
[0],
3389 spec
->multiout
.hp_out_nid
[1],
3390 spec
->multiout
.hp_out_nid
[2],
3391 spec
->multiout
.hp_out_nid
[3]);
3392 debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3393 cfg
->speaker_pins
[0], cfg
->speaker_pins
[1],
3394 cfg
->speaker_pins
[2], cfg
->speaker_pins
[3],
3395 spec
->multiout
.extra_out_nid
[0],
3396 spec
->multiout
.extra_out_nid
[1],
3397 spec
->multiout
.extra_out_nid
[2],
3398 spec
->multiout
.extra_out_nid
[3]);
3401 /* find all available DACs of the codec */
3402 static void alc_fill_all_nids(struct hda_codec
*codec
)
3404 struct alc_spec
*spec
= codec
->spec
;
3406 hda_nid_t nid
= codec
->start_nid
;
3408 spec
->num_all_dacs
= 0;
3409 memset(spec
->all_dacs
, 0, sizeof(spec
->all_dacs
));
3410 for (i
= 0; i
< codec
->num_nodes
; i
++, nid
++) {
3411 if (get_wcaps_type(get_wcaps(codec
, nid
)) != AC_WID_AUD_OUT
)
3413 if (spec
->num_all_dacs
>= ARRAY_SIZE(spec
->all_dacs
)) {
3414 snd_printk(KERN_ERR
"hda: Too many DACs!\n");
3417 spec
->all_dacs
[spec
->num_all_dacs
++] = nid
;
3421 static int alc_auto_fill_dac_nids(struct hda_codec
*codec
)
3423 struct alc_spec
*spec
= codec
->spec
;
3424 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3425 struct auto_pin_cfg
*best_cfg
;
3426 int best_badness
= INT_MAX
;
3428 bool fill_hardwired
= true, fill_mio_first
= true;
3429 bool best_wired
= true, best_mio
= true;
3430 bool hp_spk_swapped
= false;
3432 alc_fill_all_nids(codec
);
3434 best_cfg
= kmalloc(sizeof(*best_cfg
), GFP_KERNEL
);
3440 badness
= fill_and_eval_dacs(codec
, fill_hardwired
,
3446 debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n",
3447 cfg
->line_out_type
, fill_hardwired
, fill_mio_first
,
3449 debug_show_configs(spec
, cfg
);
3450 if (badness
< best_badness
) {
3451 best_badness
= badness
;
3453 best_wired
= fill_hardwired
;
3454 best_mio
= fill_mio_first
;
3458 fill_mio_first
= !fill_mio_first
;
3459 if (!fill_mio_first
)
3461 fill_hardwired
= !fill_hardwired
;
3462 if (!fill_hardwired
)
3466 hp_spk_swapped
= true;
3467 if (cfg
->speaker_outs
> 0 &&
3468 cfg
->line_out_type
== AUTO_PIN_HP_OUT
) {
3469 cfg
->hp_outs
= cfg
->line_outs
;
3470 memcpy(cfg
->hp_pins
, cfg
->line_out_pins
,
3471 sizeof(cfg
->hp_pins
));
3472 cfg
->line_outs
= cfg
->speaker_outs
;
3473 memcpy(cfg
->line_out_pins
, cfg
->speaker_pins
,
3474 sizeof(cfg
->speaker_pins
));
3475 cfg
->speaker_outs
= 0;
3476 memset(cfg
->speaker_pins
, 0, sizeof(cfg
->speaker_pins
));
3477 cfg
->line_out_type
= AUTO_PIN_SPEAKER_OUT
;
3478 fill_hardwired
= true;
3481 if (cfg
->hp_outs
> 0 &&
3482 cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
3483 cfg
->speaker_outs
= cfg
->line_outs
;
3484 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
3485 sizeof(cfg
->speaker_pins
));
3486 cfg
->line_outs
= cfg
->hp_outs
;
3487 memcpy(cfg
->line_out_pins
, cfg
->hp_pins
,
3488 sizeof(cfg
->hp_pins
));
3490 memset(cfg
->hp_pins
, 0, sizeof(cfg
->hp_pins
));
3491 cfg
->line_out_type
= AUTO_PIN_HP_OUT
;
3492 fill_hardwired
= true;
3500 fill_and_eval_dacs(codec
, best_wired
, best_mio
);
3502 debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n",
3503 cfg
->line_out_type
, best_wired
, best_mio
);
3504 debug_show_configs(spec
, cfg
);
3506 if (cfg
->line_out_pins
[0]) {
3507 struct nid_path
*path
= get_nid_path(codec
,
3508 spec
->multiout
.dac_nids
[0],
3509 cfg
->line_out_pins
[0]);
3511 spec
->vmaster_nid
= alc_look_for_out_vol_nid(codec
, path
);
3518 /* replace the channels in the composed amp value with the given number */
3519 static unsigned int amp_val_replace_channels(unsigned int val
, unsigned int chs
)
3521 val
&= ~(0x3U
<< 16);
3526 static int alc_auto_add_vol_ctl(struct hda_codec
*codec
,
3527 const char *pfx
, int cidx
,
3529 struct nid_path
*path
)
3534 val
= path
->ctls
[NID_PATH_VOL_CTL
];
3537 val
= amp_val_replace_channels(val
, chs
);
3538 return __add_pb_vol_ctrl(codec
->spec
, ALC_CTL_WIDGET_VOL
, pfx
, cidx
, val
);
3541 /* return the channel bits suitable for the given path->ctls[] */
3542 static int get_default_ch_nums(struct hda_codec
*codec
, struct nid_path
*path
,
3545 int chs
= 1; /* mono (left only) */
3547 hda_nid_t nid
= get_amp_nid_(path
->ctls
[type
]);
3548 if (nid
&& (get_wcaps(codec
, nid
) & AC_WCAP_STEREO
))
3549 chs
= 3; /* stereo */
3554 static int alc_auto_add_stereo_vol(struct hda_codec
*codec
,
3555 const char *pfx
, int cidx
,
3556 struct nid_path
*path
)
3558 int chs
= get_default_ch_nums(codec
, path
, NID_PATH_VOL_CTL
);
3559 return alc_auto_add_vol_ctl(codec
, pfx
, cidx
, chs
, path
);
3562 /* create a mute-switch for the given mixer widget;
3563 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
3565 static int alc_auto_add_sw_ctl(struct hda_codec
*codec
,
3566 const char *pfx
, int cidx
,
3568 struct nid_path
*path
)
3571 int type
= ALC_CTL_WIDGET_MUTE
;
3575 val
= path
->ctls
[NID_PATH_MUTE_CTL
];
3578 val
= amp_val_replace_channels(val
, chs
);
3579 if (get_amp_direction_(val
) == HDA_INPUT
) {
3580 hda_nid_t nid
= get_amp_nid_(val
);
3581 int nums
= snd_hda_get_num_conns(codec
, nid
);
3583 type
= ALC_CTL_BIND_MUTE
;
3587 return __add_pb_sw_ctrl(codec
->spec
, type
, pfx
, cidx
, val
);
3590 static int alc_auto_add_stereo_sw(struct hda_codec
*codec
, const char *pfx
,
3591 int cidx
, struct nid_path
*path
)
3593 int chs
= get_default_ch_nums(codec
, path
, NID_PATH_MUTE_CTL
);
3594 return alc_auto_add_sw_ctl(codec
, pfx
, cidx
, chs
, path
);
3597 static hda_nid_t
alc_look_for_out_mute_nid(struct hda_codec
*codec
,
3598 struct nid_path
*path
)
3602 for (i
= path
->depth
- 1; i
>= 0; i
--) {
3603 if (nid_has_mute(codec
, path
->path
[i
], HDA_OUTPUT
))
3604 return path
->path
[i
];
3605 if (i
!= path
->depth
- 1 && i
!= 0 &&
3606 nid_has_mute(codec
, path
->path
[i
], HDA_INPUT
))
3607 return path
->path
[i
];
3612 static hda_nid_t
alc_look_for_out_vol_nid(struct hda_codec
*codec
,
3613 struct nid_path
*path
)
3617 for (i
= path
->depth
- 1; i
>= 0; i
--) {
3618 if (nid_has_volume(codec
, path
->path
[i
], HDA_OUTPUT
))
3619 return path
->path
[i
];
3624 /* add playback controls from the parsed DAC table */
3625 static int alc_auto_create_multi_out_ctls(struct hda_codec
*codec
,
3626 const struct auto_pin_cfg
*cfg
)
3628 struct alc_spec
*spec
= codec
->spec
;
3629 int i
, err
, noutputs
;
3631 noutputs
= cfg
->line_outs
;
3632 if (spec
->multi_ios
> 0 && cfg
->line_outs
< 3)
3633 noutputs
+= spec
->multi_ios
;
3635 for (i
= 0; i
< noutputs
; i
++) {
3639 struct nid_path
*path
;
3641 dac
= spec
->multiout
.dac_nids
[i
];
3644 if (i
>= cfg
->line_outs
) {
3645 pin
= spec
->multi_io
[i
- 1].pin
;
3647 name
= channel_name
[i
];
3649 pin
= cfg
->line_out_pins
[i
];
3650 name
= alc_get_line_out_pfx(spec
, i
, true, &index
);
3653 path
= get_nid_path(codec
, dac
, pin
);
3656 if (!name
|| !strcmp(name
, "CLFE")) {
3658 err
= alc_auto_add_vol_ctl(codec
, "Center", 0, 1, path
);
3661 err
= alc_auto_add_vol_ctl(codec
, "LFE", 0, 2, path
);
3664 err
= alc_auto_add_sw_ctl(codec
, "Center", 0, 1, path
);
3667 err
= alc_auto_add_sw_ctl(codec
, "LFE", 0, 2, path
);
3671 err
= alc_auto_add_stereo_vol(codec
, name
, index
, path
);
3674 err
= alc_auto_add_stereo_sw(codec
, name
, index
, path
);
3682 static int alc_auto_create_extra_out(struct hda_codec
*codec
, hda_nid_t pin
,
3683 hda_nid_t dac
, const char *pfx
,
3686 struct nid_path
*path
;
3689 path
= get_nid_path(codec
, dac
, pin
);
3692 /* bind volume control will be created in the case of dac = 0 */
3694 err
= alc_auto_add_stereo_vol(codec
, pfx
, cidx
, path
);
3698 err
= alc_auto_add_stereo_sw(codec
, pfx
, cidx
, path
);
3704 static struct hda_bind_ctls
*new_bind_ctl(struct hda_codec
*codec
,
3706 struct hda_ctl_ops
*ops
)
3708 struct alc_spec
*spec
= codec
->spec
;
3709 struct hda_bind_ctls
**ctlp
, *ctl
;
3710 ctlp
= snd_array_new(&spec
->bind_ctls
);
3713 ctl
= kzalloc(sizeof(*ctl
) + sizeof(long) * (nums
+ 1), GFP_KERNEL
);
3720 /* add playback controls for speaker and HP outputs */
3721 static int alc_auto_create_extra_outs(struct hda_codec
*codec
, int num_pins
,
3722 const hda_nid_t
*pins
,
3723 const hda_nid_t
*dacs
,
3726 struct alc_spec
*spec
= codec
->spec
;
3727 struct hda_bind_ctls
*ctl
;
3731 if (!num_pins
|| !pins
[0])
3734 if (num_pins
== 1) {
3735 hda_nid_t dac
= *dacs
;
3737 dac
= spec
->multiout
.dac_nids
[0];
3738 return alc_auto_create_extra_out(codec
, *pins
, dac
, pfx
, 0);
3741 for (i
= 0; i
< num_pins
; i
++) {
3743 if (dacs
[num_pins
- 1])
3744 dac
= dacs
[i
]; /* with individual volumes */
3747 if (num_pins
== 2 && i
== 1 && !strcmp(pfx
, "Speaker")) {
3748 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3750 } else if (num_pins
>= 3) {
3751 snprintf(name
, sizeof(name
), "%s %s",
3752 pfx
, channel_name
[i
]);
3753 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3756 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3762 if (dacs
[num_pins
- 1])
3765 /* Let's create a bind-controls for volumes */
3766 ctl
= new_bind_ctl(codec
, num_pins
, &snd_hda_bind_vol
);
3770 for (i
= 0; i
< num_pins
; i
++) {
3772 struct nid_path
*path
;
3773 if (!pins
[i
] || !dacs
[i
])
3775 path
= get_nid_path(codec
, dacs
[i
], pins
[i
]);
3778 vol
= alc_look_for_out_vol_nid(codec
, path
);
3781 HDA_COMPOSE_AMP_VAL(vol
, 3, 0, HDA_OUTPUT
);
3784 snprintf(name
, sizeof(name
), "%s Playback Volume", pfx
);
3785 err
= add_control(spec
, ALC_CTL_BIND_VOL
, name
, 0, (long)ctl
);
3792 static int alc_auto_create_hp_out(struct hda_codec
*codec
)
3794 struct alc_spec
*spec
= codec
->spec
;
3795 return alc_auto_create_extra_outs(codec
, spec
->autocfg
.hp_outs
,
3796 spec
->autocfg
.hp_pins
,
3797 spec
->multiout
.hp_out_nid
,
3801 static int alc_auto_create_speaker_out(struct hda_codec
*codec
)
3803 struct alc_spec
*spec
= codec
->spec
;
3804 return alc_auto_create_extra_outs(codec
, spec
->autocfg
.speaker_outs
,
3805 spec
->autocfg
.speaker_pins
,
3806 spec
->multiout
.extra_out_nid
,
3810 /* check whether a control with the given (nid, dir, idx) was assigned */
3811 static bool is_ctl_associated(struct hda_codec
*codec
, hda_nid_t nid
,
3814 struct alc_spec
*spec
= codec
->spec
;
3817 for (i
= 0; i
< spec
->paths
.used
; i
++) {
3818 struct nid_path
*p
= snd_array_elem(&spec
->paths
, i
);
3821 for (type
= 0; type
< NID_PATH_NUM_CTLS
; type
++) {
3822 unsigned int val
= p
->ctls
[type
];
3823 if (get_amp_nid_(val
) == nid
&&
3824 get_amp_direction_(val
) == dir
&&
3825 get_amp_index_(val
) == idx
)
3832 /* can have the amp-in capability? */
3833 static bool has_amp_in(struct hda_codec
*codec
, struct nid_path
*path
, int idx
)
3835 hda_nid_t nid
= path
->path
[idx
];
3836 unsigned int caps
= get_wcaps(codec
, nid
);
3837 unsigned int type
= get_wcaps_type(caps
);
3839 if (!(caps
& AC_WCAP_IN_AMP
))
3841 if (type
== AC_WID_PIN
&& idx
> 0) /* only for input pins */
3846 /* can have the amp-out capability? */
3847 static bool has_amp_out(struct hda_codec
*codec
, struct nid_path
*path
, int idx
)
3849 hda_nid_t nid
= path
->path
[idx
];
3850 unsigned int caps
= get_wcaps(codec
, nid
);
3851 unsigned int type
= get_wcaps_type(caps
);
3853 if (!(caps
& AC_WCAP_OUT_AMP
))
3855 if (type
== AC_WID_PIN
&& !idx
) /* only for output pins */
3860 /* check whether the given (nid,dir,idx) is active */
3861 static bool is_active_nid(struct hda_codec
*codec
, hda_nid_t nid
,
3862 unsigned int idx
, unsigned int dir
)
3864 struct alc_spec
*spec
= codec
->spec
;
3867 for (n
= 0; n
< spec
->paths
.used
; n
++) {
3868 struct nid_path
*path
= snd_array_elem(&spec
->paths
, n
);
3871 for (i
= 0; i
< path
->depth
; i
++) {
3872 if (path
->path
[i
] == nid
) {
3873 if (dir
== HDA_OUTPUT
|| path
->idx
[i
] == idx
)
3882 /* get the default amp value for the target state */
3883 static int get_amp_val_to_activate(struct hda_codec
*codec
, hda_nid_t nid
,
3884 int dir
, bool enable
)
3887 unsigned int val
= 0;
3889 caps
= query_amp_caps(codec
, nid
, dir
);
3890 if (caps
& AC_AMPCAP_NUM_STEPS
) {
3893 val
= (caps
& AC_AMPCAP_OFFSET
) >> AC_AMPCAP_OFFSET_SHIFT
;
3895 if (caps
& AC_AMPCAP_MUTE
) {
3897 val
|= HDA_AMP_MUTE
;
3902 /* initialize the amp value (only at the first time) */
3903 static void init_amp(struct hda_codec
*codec
, hda_nid_t nid
, int dir
, int idx
)
3905 int val
= get_amp_val_to_activate(codec
, nid
, dir
, false);
3906 snd_hda_codec_amp_init_stereo(codec
, nid
, dir
, idx
, 0xff, val
);
3909 static void activate_amp(struct hda_codec
*codec
, hda_nid_t nid
, int dir
,
3910 int idx
, bool enable
)
3913 if (is_ctl_associated(codec
, nid
, dir
, idx
) ||
3914 is_active_nid(codec
, nid
, dir
, idx
))
3916 val
= get_amp_val_to_activate(codec
, nid
, dir
, enable
);
3917 snd_hda_codec_amp_stereo(codec
, nid
, dir
, idx
, 0xff, val
);
3920 static void activate_amp_out(struct hda_codec
*codec
, struct nid_path
*path
,
3923 hda_nid_t nid
= path
->path
[i
];
3924 init_amp(codec
, nid
, HDA_OUTPUT
, 0);
3925 activate_amp(codec
, nid
, HDA_OUTPUT
, 0, enable
);
3928 static void activate_amp_in(struct hda_codec
*codec
, struct nid_path
*path
,
3929 int i
, bool enable
, bool add_aamix
)
3931 struct alc_spec
*spec
= codec
->spec
;
3935 hda_nid_t nid
= path
->path
[i
];
3937 nums
= snd_hda_get_connections(codec
, nid
, conn
, ARRAY_SIZE(conn
));
3938 type
= get_wcaps_type(get_wcaps(codec
, nid
));
3939 if (type
== AC_WID_PIN
||
3940 (type
== AC_WID_AUD_IN
&& codec
->single_adc_amp
)) {
3946 for (n
= 0; n
< nums
; n
++)
3947 init_amp(codec
, nid
, HDA_INPUT
, n
);
3949 if (is_ctl_associated(codec
, nid
, HDA_INPUT
, idx
))
3952 /* here is a little bit tricky in comparison with activate_amp_out();
3953 * when aa-mixer is available, we need to enable the path as well
3955 for (n
= 0; n
< nums
; n
++) {
3956 if (n
!= idx
&& (!add_aamix
|| conn
[n
] != spec
->mixer_nid
))
3958 activate_amp(codec
, nid
, HDA_INPUT
, n
, enable
);
3962 static void activate_path(struct hda_codec
*codec
, struct nid_path
*path
,
3963 bool enable
, bool add_aamix
)
3968 path
->active
= false;
3970 for (i
= path
->depth
- 1; i
>= 0; i
--) {
3971 if (enable
&& path
->multi
[i
])
3972 snd_hda_codec_write_cache(codec
, path
->path
[i
], 0,
3973 AC_VERB_SET_CONNECT_SEL
,
3975 if (has_amp_in(codec
, path
, i
))
3976 activate_amp_in(codec
, path
, i
, enable
, add_aamix
);
3977 if (has_amp_out(codec
, path
, i
))
3978 activate_amp_out(codec
, path
, i
, enable
);
3982 path
->active
= true;
3985 /* configure the path from the given dac to the pin as the proper output */
3986 static void alc_auto_set_output_and_unmute(struct hda_codec
*codec
,
3987 hda_nid_t pin
, int pin_type
,
3990 struct nid_path
*path
;
3992 snd_hda_set_pin_ctl_cache(codec
, pin
, pin_type
);
3993 path
= get_nid_path(codec
, dac
, pin
);
3998 activate_path(codec
, path
, true, true);
4001 static void alc_auto_init_multi_out(struct hda_codec
*codec
)
4003 struct alc_spec
*spec
= codec
->spec
;
4004 int pin_type
= get_pin_type(spec
->autocfg
.line_out_type
);
4007 for (i
= 0; i
<= HDA_SIDE
; i
++) {
4008 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
4010 alc_auto_set_output_and_unmute(codec
, nid
, pin_type
,
4011 spec
->multiout
.dac_nids
[i
]);
4016 static void alc_auto_init_extra_out(struct hda_codec
*codec
)
4018 struct alc_spec
*spec
= codec
->spec
;
4022 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
4023 if (spec
->autocfg
.line_out_type
== AUTO_PIN_HP_OUT
)
4025 pin
= spec
->autocfg
.hp_pins
[i
];
4028 dac
= spec
->multiout
.hp_out_nid
[i
];
4030 if (i
> 0 && spec
->multiout
.hp_out_nid
[0])
4031 dac
= spec
->multiout
.hp_out_nid
[0];
4033 dac
= spec
->multiout
.dac_nids
[0];
4035 alc_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, dac
);
4037 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++) {
4038 if (spec
->autocfg
.line_out_type
== AUTO_PIN_SPEAKER_OUT
)
4040 pin
= spec
->autocfg
.speaker_pins
[i
];
4043 dac
= spec
->multiout
.extra_out_nid
[i
];
4045 if (i
> 0 && spec
->multiout
.extra_out_nid
[0])
4046 dac
= spec
->multiout
.extra_out_nid
[0];
4048 dac
= spec
->multiout
.dac_nids
[0];
4050 alc_auto_set_output_and_unmute(codec
, pin
, PIN_OUT
, dac
);
4054 /* check whether the given pin can be a multi-io pin */
4055 static bool can_be_multiio_pin(struct hda_codec
*codec
,
4056 unsigned int location
, hda_nid_t nid
)
4058 unsigned int defcfg
, caps
;
4060 defcfg
= snd_hda_codec_get_pincfg(codec
, nid
);
4061 if (get_defcfg_connect(defcfg
) != AC_JACK_PORT_COMPLEX
)
4063 if (location
&& get_defcfg_location(defcfg
) != location
)
4065 caps
= snd_hda_query_pin_caps(codec
, nid
);
4066 if (!(caps
& AC_PINCAP_OUT
))
4074 * When hardwired is set, try to fill ony hardwired pins, and returns
4075 * zero if any pins are filled, non-zero if nothing found.
4076 * When hardwired is off, try to fill possible input pins, and returns
4077 * the badness value.
4079 static int alc_auto_fill_multi_ios(struct hda_codec
*codec
,
4080 hda_nid_t reference_pin
,
4081 bool hardwired
, int offset
)
4083 struct alc_spec
*spec
= codec
->spec
;
4084 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4085 int type
, i
, j
, dacs
, num_pins
, old_pins
;
4086 unsigned int defcfg
= snd_hda_codec_get_pincfg(codec
, reference_pin
);
4087 unsigned int location
= get_defcfg_location(defcfg
);
4090 old_pins
= spec
->multi_ios
;
4095 for (type
= AUTO_PIN_LINE_IN
; type
>= AUTO_PIN_MIC
; type
--) {
4096 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
4097 if (cfg
->inputs
[i
].type
!= type
)
4099 if (can_be_multiio_pin(codec
, location
,
4100 cfg
->inputs
[i
].pin
))
4107 dacs
= spec
->multiout
.num_dacs
;
4108 for (type
= AUTO_PIN_LINE_IN
; type
>= AUTO_PIN_MIC
; type
--) {
4109 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
4110 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
4113 if (cfg
->inputs
[i
].type
!= type
)
4115 if (!can_be_multiio_pin(codec
, location
, nid
))
4117 for (j
= 0; j
< spec
->multi_ios
; j
++) {
4118 if (nid
== spec
->multi_io
[j
].pin
)
4121 if (j
< spec
->multi_ios
)
4124 if (offset
&& offset
+ spec
->multi_ios
< dacs
) {
4125 dac
= spec
->private_dac_nids
[offset
+ spec
->multi_ios
];
4126 if (!is_reachable_path(codec
, dac
, nid
))
4130 dac
= get_dac_if_single(codec
, nid
);
4132 dac
= alc_auto_look_for_dac(codec
, nid
, false);
4137 if (!add_new_nid_path(codec
, dac
, nid
, 0)) {
4141 spec
->multi_io
[spec
->multi_ios
].pin
= nid
;
4142 spec
->multi_io
[spec
->multi_ios
].dac
= dac
;
4144 if (spec
->multi_ios
>= 2)
4150 badness
= BAD_MULTI_IO
;
4151 if (old_pins
== spec
->multi_ios
) {
4153 return 1; /* nothing found */
4155 return badness
; /* no badness if nothing found */
4157 if (!hardwired
&& spec
->multi_ios
< 2) {
4158 /* cancel newly assigned paths */
4159 spec
->paths
.used
-= spec
->multi_ios
- old_pins
;
4160 spec
->multi_ios
= old_pins
;
4164 /* assign volume and mute controls */
4165 for (i
= old_pins
; i
< spec
->multi_ios
; i
++)
4166 badness
+= assign_out_path_ctls(codec
, spec
->multi_io
[i
].pin
,
4167 spec
->multi_io
[i
].dac
);
4172 static int alc_auto_ch_mode_info(struct snd_kcontrol
*kcontrol
,
4173 struct snd_ctl_elem_info
*uinfo
)
4175 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
4176 struct alc_spec
*spec
= codec
->spec
;
4178 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
4180 uinfo
->value
.enumerated
.items
= spec
->multi_ios
+ 1;
4181 if (uinfo
->value
.enumerated
.item
> spec
->multi_ios
)
4182 uinfo
->value
.enumerated
.item
= spec
->multi_ios
;
4183 sprintf(uinfo
->value
.enumerated
.name
, "%dch",
4184 (uinfo
->value
.enumerated
.item
+ 1) * 2);
4188 static int alc_auto_ch_mode_get(struct snd_kcontrol
*kcontrol
,
4189 struct snd_ctl_elem_value
*ucontrol
)
4191 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
4192 struct alc_spec
*spec
= codec
->spec
;
4193 ucontrol
->value
.enumerated
.item
[0] = (spec
->ext_channel_count
- 1) / 2;
4197 static int alc_set_multi_io(struct hda_codec
*codec
, int idx
, bool output
)
4199 struct alc_spec
*spec
= codec
->spec
;
4200 hda_nid_t nid
= spec
->multi_io
[idx
].pin
;
4201 struct nid_path
*path
;
4203 path
= get_nid_path(codec
, spec
->multi_io
[idx
].dac
, nid
);
4207 if (path
->active
== output
)
4211 snd_hda_set_pin_ctl_cache(codec
, nid
, PIN_OUT
);
4212 activate_path(codec
, path
, true, true);
4214 activate_path(codec
, path
, false, true);
4215 snd_hda_set_pin_ctl_cache(codec
, nid
,
4216 spec
->multi_io
[idx
].ctl_in
);
4221 static int alc_auto_ch_mode_put(struct snd_kcontrol
*kcontrol
,
4222 struct snd_ctl_elem_value
*ucontrol
)
4224 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
4225 struct alc_spec
*spec
= codec
->spec
;
4228 ch
= ucontrol
->value
.enumerated
.item
[0];
4229 if (ch
< 0 || ch
> spec
->multi_ios
)
4231 if (ch
== (spec
->ext_channel_count
- 1) / 2)
4233 spec
->ext_channel_count
= (ch
+ 1) * 2;
4234 for (i
= 0; i
< spec
->multi_ios
; i
++)
4235 alc_set_multi_io(codec
, i
, i
< ch
);
4236 spec
->multiout
.max_channels
= max(spec
->ext_channel_count
,
4237 spec
->const_channel_count
);
4238 if (spec
->need_dac_fix
)
4239 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
4243 static const struct snd_kcontrol_new alc_auto_channel_mode_enum
= {
4244 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4245 .name
= "Channel Mode",
4246 .info
= alc_auto_ch_mode_info
,
4247 .get
= alc_auto_ch_mode_get
,
4248 .put
= alc_auto_ch_mode_put
,
4251 static int alc_auto_add_multi_channel_mode(struct hda_codec
*codec
)
4253 struct alc_spec
*spec
= codec
->spec
;
4255 if (spec
->multi_ios
> 0) {
4256 if (!alc_kcontrol_new(spec
, NULL
, &alc_auto_channel_mode_enum
))
4262 static void alc_auto_init_multi_io(struct hda_codec
*codec
)
4264 struct alc_spec
*spec
= codec
->spec
;
4267 for (i
= 0; i
< spec
->multi_ios
; i
++) {
4268 hda_nid_t pin
= spec
->multi_io
[i
].pin
;
4269 struct nid_path
*path
;
4270 path
= get_nid_path(codec
, spec
->multi_io
[i
].dac
, pin
);
4273 if (!spec
->multi_io
[i
].ctl_in
)
4274 spec
->multi_io
[i
].ctl_in
=
4275 snd_hda_codec_update_cache(codec
, pin
, 0,
4276 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
4277 activate_path(codec
, path
, path
->active
, true);
4282 * initialize ADC paths
4284 static void alc_auto_init_input_src(struct hda_codec
*codec
)
4286 struct alc_spec
*spec
= codec
->spec
;
4287 struct hda_input_mux
*imux
= &spec
->input_mux
;
4288 struct nid_path
*path
;
4291 if (spec
->dyn_adc_switch
)
4294 nums
= spec
->num_adc_nids
;
4296 for (c
= 0; c
< nums
; c
++) {
4297 for (i
= 0; i
< imux
->num_items
; i
++) {
4298 path
= get_nid_path(codec
, spec
->imux_pins
[i
],
4299 get_adc_nid(codec
, c
, i
));
4301 bool active
= path
->active
;
4302 if (i
== spec
->cur_mux
[c
])
4304 activate_path(codec
, path
, active
, false);
4309 alc_inv_dmic_sync(codec
, true);
4310 if (spec
->shared_mic_hp
)
4311 update_shared_mic_hp(codec
, spec
->cur_mux
[0]);
4314 /* add mic boosts if needed */
4315 static int alc_auto_add_mic_boost(struct hda_codec
*codec
)
4317 struct alc_spec
*spec
= codec
->spec
;
4318 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4322 const char *prev_label
= NULL
;
4324 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
4325 if (cfg
->inputs
[i
].type
> AUTO_PIN_MIC
)
4327 nid
= cfg
->inputs
[i
].pin
;
4328 if (get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
) {
4330 char boost_label
[32];
4331 struct nid_path
*path
;
4334 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
4335 if (spec
->shared_mic_hp
&& !strcmp(label
, "Misc"))
4336 label
= "Headphone Mic";
4337 if (prev_label
&& !strcmp(label
, prev_label
))
4343 snprintf(boost_label
, sizeof(boost_label
),
4344 "%s Boost Volume", label
);
4345 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_INPUT
);
4346 err
= add_control(spec
, ALC_CTL_WIDGET_VOL
,
4347 boost_label
, type_idx
, val
);
4351 path
= get_nid_path(codec
, nid
, 0);
4353 path
->ctls
[NID_PATH_BOOST_CTL
] = val
;
4360 * standard auto-parser initializations
4362 static void alc_auto_init_std(struct hda_codec
*codec
)
4364 alc_auto_init_multi_out(codec
);
4365 alc_auto_init_extra_out(codec
);
4366 alc_auto_init_multi_io(codec
);
4367 alc_auto_init_analog_input(codec
);
4368 alc_auto_init_input_src(codec
);
4369 alc_auto_init_digital(codec
);
4370 /* call init functions of standard auto-mute helpers */
4371 alc_hp_automute(codec
, NULL
);
4372 alc_line_automute(codec
, NULL
);
4373 alc_mic_automute(codec
, NULL
);
4377 * Digital-beep handlers
4379 #ifdef CONFIG_SND_HDA_INPUT_BEEP
4380 #define set_beep_amp(spec, nid, idx, dir) \
4381 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4383 static const struct snd_pci_quirk beep_white_list
[] = {
4384 SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
4385 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
4386 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
4387 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
4388 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
4389 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
4390 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
4394 static inline int has_cdefine_beep(struct hda_codec
*codec
)
4396 struct alc_spec
*spec
= codec
->spec
;
4397 const struct snd_pci_quirk
*q
;
4398 q
= snd_pci_quirk_lookup(codec
->bus
->pci
, beep_white_list
);
4401 return spec
->cdefine
.enable_pcbeep
;
4404 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
4405 #define has_cdefine_beep(codec) 0
4408 /* parse the BIOS configuration and set up the alc_spec */
4409 /* return 1 if successful, 0 if the proper config is not found,
4410 * or a negative error code
4412 static int alc_parse_auto_config(struct hda_codec
*codec
,
4413 const hda_nid_t
*ignore_nids
,
4414 const hda_nid_t
*ssid_nids
)
4416 struct alc_spec
*spec
= codec
->spec
;
4417 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4420 err
= snd_hda_parse_pin_defcfg(codec
, cfg
, ignore_nids
,
4424 if (!cfg
->line_outs
) {
4425 if (cfg
->dig_outs
|| cfg
->dig_in_pin
) {
4426 spec
->multiout
.max_channels
= 2;
4427 spec
->no_analog
= 1;
4430 return 0; /* can't find valid BIOS pin config */
4433 if (!spec
->no_primary_hp
&&
4434 cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
&&
4435 cfg
->line_outs
<= cfg
->hp_outs
) {
4436 /* use HP as primary out */
4437 cfg
->speaker_outs
= cfg
->line_outs
;
4438 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
4439 sizeof(cfg
->speaker_pins
));
4440 cfg
->line_outs
= cfg
->hp_outs
;
4441 memcpy(cfg
->line_out_pins
, cfg
->hp_pins
, sizeof(cfg
->hp_pins
));
4443 memset(cfg
->hp_pins
, 0, sizeof(cfg
->hp_pins
));
4444 cfg
->line_out_type
= AUTO_PIN_HP_OUT
;
4447 err
= alc_auto_fill_dac_nids(codec
);
4450 err
= alc_auto_add_multi_channel_mode(codec
);
4453 err
= alc_auto_create_multi_out_ctls(codec
, cfg
);
4456 err
= alc_auto_create_hp_out(codec
);
4459 err
= alc_auto_create_speaker_out(codec
);
4462 err
= alc_auto_create_shared_input(codec
);
4465 err
= alc_auto_create_input_ctls(codec
);
4469 /* check the multiple speaker pins */
4470 if (cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
)
4471 spec
->const_channel_count
= cfg
->line_outs
* 2;
4473 spec
->const_channel_count
= cfg
->speaker_outs
* 2;
4475 if (spec
->multi_ios
> 0)
4476 spec
->multiout
.max_channels
= max(spec
->ext_channel_count
,
4477 spec
->const_channel_count
);
4479 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
4482 alc_auto_parse_digital(codec
);
4485 alc_ssid_check(codec
, ssid_nids
);
4487 if (!spec
->no_analog
) {
4488 err
= alc_init_automute(codec
);
4492 err
= check_dyn_adc_switch(codec
);
4496 if (!spec
->shared_mic_hp
) {
4497 err
= alc_init_auto_mic(codec
);
4502 err
= create_capture_mixers(codec
);
4506 err
= alc_auto_add_mic_boost(codec
);
4511 if (spec
->kctls
.list
)
4512 add_mixer(spec
, spec
->kctls
.list
);
4517 /* common preparation job for alc_spec */
4518 static int alc_alloc_spec(struct hda_codec
*codec
, hda_nid_t mixer_nid
)
4520 struct alc_spec
*spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4526 codec
->single_adc_amp
= 1;
4527 spec
->mixer_nid
= mixer_nid
;
4528 snd_hda_gen_init(&spec
->gen
);
4529 snd_array_init(&spec
->kctls
, sizeof(struct snd_kcontrol_new
), 32);
4530 snd_array_init(&spec
->bind_ctls
, sizeof(struct hda_bind_ctls
*), 8);
4531 snd_array_init(&spec
->paths
, sizeof(struct nid_path
), 8);
4533 err
= alc_codec_rename_from_preset(codec
);
4541 static int alc880_parse_auto_config(struct hda_codec
*codec
)
4543 static const hda_nid_t alc880_ignore
[] = { 0x1d, 0 };
4544 static const hda_nid_t alc880_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
4545 return alc_parse_auto_config(codec
, alc880_ignore
, alc880_ssids
);
4554 ALC880_FIXUP_MEDION_RIM
,
4557 ALC880_FIXUP_EAPD_COEF
,
4558 ALC880_FIXUP_TCL_S700
,
4559 ALC880_FIXUP_VOL_KNOB
,
4560 ALC880_FIXUP_FUJITSU
,
4562 ALC880_FIXUP_UNIWILL
,
4563 ALC880_FIXUP_UNIWILL_DIG
,
4565 ALC880_FIXUP_3ST_BASE
,
4567 ALC880_FIXUP_3ST_DIG
,
4568 ALC880_FIXUP_5ST_BASE
,
4570 ALC880_FIXUP_5ST_DIG
,
4571 ALC880_FIXUP_6ST_BASE
,
4573 ALC880_FIXUP_6ST_DIG
,
4576 /* enable the volume-knob widget support on NID 0x21 */
4577 static void alc880_fixup_vol_knob(struct hda_codec
*codec
,
4578 const struct alc_fixup
*fix
, int action
)
4580 if (action
== ALC_FIXUP_ACT_PROBE
)
4581 snd_hda_jack_detect_enable_callback(codec
, 0x21, ALC_DCVOL_EVENT
, alc_update_knob_master
);
4584 static const struct alc_fixup alc880_fixups
[] = {
4585 [ALC880_FIXUP_GPIO1
] = {
4586 .type
= ALC_FIXUP_VERBS
,
4587 .v
.verbs
= alc_gpio1_init_verbs
,
4589 [ALC880_FIXUP_GPIO2
] = {
4590 .type
= ALC_FIXUP_VERBS
,
4591 .v
.verbs
= alc_gpio2_init_verbs
,
4593 [ALC880_FIXUP_MEDION_RIM
] = {
4594 .type
= ALC_FIXUP_VERBS
,
4595 .v
.verbs
= (const struct hda_verb
[]) {
4596 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4597 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
4601 .chain_id
= ALC880_FIXUP_GPIO2
,
4603 [ALC880_FIXUP_LG
] = {
4604 .type
= ALC_FIXUP_PINS
,
4605 .v
.pins
= (const struct alc_pincfg
[]) {
4606 /* disable bogus unused pins */
4607 { 0x16, 0x411111f0 },
4608 { 0x18, 0x411111f0 },
4609 { 0x1a, 0x411111f0 },
4613 [ALC880_FIXUP_W810
] = {
4614 .type
= ALC_FIXUP_PINS
,
4615 .v
.pins
= (const struct alc_pincfg
[]) {
4616 /* disable bogus unused pins */
4617 { 0x17, 0x411111f0 },
4621 .chain_id
= ALC880_FIXUP_GPIO2
,
4623 [ALC880_FIXUP_EAPD_COEF
] = {
4624 .type
= ALC_FIXUP_VERBS
,
4625 .v
.verbs
= (const struct hda_verb
[]) {
4626 /* change to EAPD mode */
4627 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4628 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
4632 [ALC880_FIXUP_TCL_S700
] = {
4633 .type
= ALC_FIXUP_VERBS
,
4634 .v
.verbs
= (const struct hda_verb
[]) {
4635 /* change to EAPD mode */
4636 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4637 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
4641 .chain_id
= ALC880_FIXUP_GPIO2
,
4643 [ALC880_FIXUP_VOL_KNOB
] = {
4644 .type
= ALC_FIXUP_FUNC
,
4645 .v
.func
= alc880_fixup_vol_knob
,
4647 [ALC880_FIXUP_FUJITSU
] = {
4648 /* override all pins as BIOS on old Amilo is broken */
4649 .type
= ALC_FIXUP_PINS
,
4650 .v
.pins
= (const struct alc_pincfg
[]) {
4651 { 0x14, 0x0121411f }, /* HP */
4652 { 0x15, 0x99030120 }, /* speaker */
4653 { 0x16, 0x99030130 }, /* bass speaker */
4654 { 0x17, 0x411111f0 }, /* N/A */
4655 { 0x18, 0x411111f0 }, /* N/A */
4656 { 0x19, 0x01a19950 }, /* mic-in */
4657 { 0x1a, 0x411111f0 }, /* N/A */
4658 { 0x1b, 0x411111f0 }, /* N/A */
4659 { 0x1c, 0x411111f0 }, /* N/A */
4660 { 0x1d, 0x411111f0 }, /* N/A */
4661 { 0x1e, 0x01454140 }, /* SPDIF out */
4665 .chain_id
= ALC880_FIXUP_VOL_KNOB
,
4667 [ALC880_FIXUP_F1734
] = {
4668 /* almost compatible with FUJITSU, but no bass and SPDIF */
4669 .type
= ALC_FIXUP_PINS
,
4670 .v
.pins
= (const struct alc_pincfg
[]) {
4671 { 0x14, 0x0121411f }, /* HP */
4672 { 0x15, 0x99030120 }, /* speaker */
4673 { 0x16, 0x411111f0 }, /* N/A */
4674 { 0x17, 0x411111f0 }, /* N/A */
4675 { 0x18, 0x411111f0 }, /* N/A */
4676 { 0x19, 0x01a19950 }, /* mic-in */
4677 { 0x1a, 0x411111f0 }, /* N/A */
4678 { 0x1b, 0x411111f0 }, /* N/A */
4679 { 0x1c, 0x411111f0 }, /* N/A */
4680 { 0x1d, 0x411111f0 }, /* N/A */
4681 { 0x1e, 0x411111f0 }, /* N/A */
4685 .chain_id
= ALC880_FIXUP_VOL_KNOB
,
4687 [ALC880_FIXUP_UNIWILL
] = {
4688 /* need to fix HP and speaker pins to be parsed correctly */
4689 .type
= ALC_FIXUP_PINS
,
4690 .v
.pins
= (const struct alc_pincfg
[]) {
4691 { 0x14, 0x0121411f }, /* HP */
4692 { 0x15, 0x99030120 }, /* speaker */
4693 { 0x16, 0x99030130 }, /* bass speaker */
4697 [ALC880_FIXUP_UNIWILL_DIG
] = {
4698 .type
= ALC_FIXUP_PINS
,
4699 .v
.pins
= (const struct alc_pincfg
[]) {
4700 /* disable bogus unused pins */
4701 { 0x17, 0x411111f0 },
4702 { 0x19, 0x411111f0 },
4703 { 0x1b, 0x411111f0 },
4704 { 0x1f, 0x411111f0 },
4708 [ALC880_FIXUP_Z71V
] = {
4709 .type
= ALC_FIXUP_PINS
,
4710 .v
.pins
= (const struct alc_pincfg
[]) {
4711 /* set up the whole pins as BIOS is utterly broken */
4712 { 0x14, 0x99030120 }, /* speaker */
4713 { 0x15, 0x0121411f }, /* HP */
4714 { 0x16, 0x411111f0 }, /* N/A */
4715 { 0x17, 0x411111f0 }, /* N/A */
4716 { 0x18, 0x01a19950 }, /* mic-in */
4717 { 0x19, 0x411111f0 }, /* N/A */
4718 { 0x1a, 0x01813031 }, /* line-in */
4719 { 0x1b, 0x411111f0 }, /* N/A */
4720 { 0x1c, 0x411111f0 }, /* N/A */
4721 { 0x1d, 0x411111f0 }, /* N/A */
4722 { 0x1e, 0x0144111e }, /* SPDIF */
4726 [ALC880_FIXUP_3ST_BASE
] = {
4727 .type
= ALC_FIXUP_PINS
,
4728 .v
.pins
= (const struct alc_pincfg
[]) {
4729 { 0x14, 0x01014010 }, /* line-out */
4730 { 0x15, 0x411111f0 }, /* N/A */
4731 { 0x16, 0x411111f0 }, /* N/A */
4732 { 0x17, 0x411111f0 }, /* N/A */
4733 { 0x18, 0x01a19c30 }, /* mic-in */
4734 { 0x19, 0x0121411f }, /* HP */
4735 { 0x1a, 0x01813031 }, /* line-in */
4736 { 0x1b, 0x02a19c40 }, /* front-mic */
4737 { 0x1c, 0x411111f0 }, /* N/A */
4738 { 0x1d, 0x411111f0 }, /* N/A */
4739 /* 0x1e is filled in below */
4740 { 0x1f, 0x411111f0 }, /* N/A */
4744 [ALC880_FIXUP_3ST
] = {
4745 .type
= ALC_FIXUP_PINS
,
4746 .v
.pins
= (const struct alc_pincfg
[]) {
4747 { 0x1e, 0x411111f0 }, /* N/A */
4751 .chain_id
= ALC880_FIXUP_3ST_BASE
,
4753 [ALC880_FIXUP_3ST_DIG
] = {
4754 .type
= ALC_FIXUP_PINS
,
4755 .v
.pins
= (const struct alc_pincfg
[]) {
4756 { 0x1e, 0x0144111e }, /* SPDIF */
4760 .chain_id
= ALC880_FIXUP_3ST_BASE
,
4762 [ALC880_FIXUP_5ST_BASE
] = {
4763 .type
= ALC_FIXUP_PINS
,
4764 .v
.pins
= (const struct alc_pincfg
[]) {
4765 { 0x14, 0x01014010 }, /* front */
4766 { 0x15, 0x411111f0 }, /* N/A */
4767 { 0x16, 0x01011411 }, /* CLFE */
4768 { 0x17, 0x01016412 }, /* surr */
4769 { 0x18, 0x01a19c30 }, /* mic-in */
4770 { 0x19, 0x0121411f }, /* HP */
4771 { 0x1a, 0x01813031 }, /* line-in */
4772 { 0x1b, 0x02a19c40 }, /* front-mic */
4773 { 0x1c, 0x411111f0 }, /* N/A */
4774 { 0x1d, 0x411111f0 }, /* N/A */
4775 /* 0x1e is filled in below */
4776 { 0x1f, 0x411111f0 }, /* N/A */
4780 [ALC880_FIXUP_5ST
] = {
4781 .type
= ALC_FIXUP_PINS
,
4782 .v
.pins
= (const struct alc_pincfg
[]) {
4783 { 0x1e, 0x411111f0 }, /* N/A */
4787 .chain_id
= ALC880_FIXUP_5ST_BASE
,
4789 [ALC880_FIXUP_5ST_DIG
] = {
4790 .type
= ALC_FIXUP_PINS
,
4791 .v
.pins
= (const struct alc_pincfg
[]) {
4792 { 0x1e, 0x0144111e }, /* SPDIF */
4796 .chain_id
= ALC880_FIXUP_5ST_BASE
,
4798 [ALC880_FIXUP_6ST_BASE
] = {
4799 .type
= ALC_FIXUP_PINS
,
4800 .v
.pins
= (const struct alc_pincfg
[]) {
4801 { 0x14, 0x01014010 }, /* front */
4802 { 0x15, 0x01016412 }, /* surr */
4803 { 0x16, 0x01011411 }, /* CLFE */
4804 { 0x17, 0x01012414 }, /* side */
4805 { 0x18, 0x01a19c30 }, /* mic-in */
4806 { 0x19, 0x02a19c40 }, /* front-mic */
4807 { 0x1a, 0x01813031 }, /* line-in */
4808 { 0x1b, 0x0121411f }, /* HP */
4809 { 0x1c, 0x411111f0 }, /* N/A */
4810 { 0x1d, 0x411111f0 }, /* N/A */
4811 /* 0x1e is filled in below */
4812 { 0x1f, 0x411111f0 }, /* N/A */
4816 [ALC880_FIXUP_6ST
] = {
4817 .type
= ALC_FIXUP_PINS
,
4818 .v
.pins
= (const struct alc_pincfg
[]) {
4819 { 0x1e, 0x411111f0 }, /* N/A */
4823 .chain_id
= ALC880_FIXUP_6ST_BASE
,
4825 [ALC880_FIXUP_6ST_DIG
] = {
4826 .type
= ALC_FIXUP_PINS
,
4827 .v
.pins
= (const struct alc_pincfg
[]) {
4828 { 0x1e, 0x0144111e }, /* SPDIF */
4832 .chain_id
= ALC880_FIXUP_6ST_BASE
,
4836 static const struct snd_pci_quirk alc880_fixup_tbl
[] = {
4837 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810
),
4838 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V
),
4839 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1
),
4840 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2
),
4841 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF
),
4842 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG
),
4843 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734
),
4844 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL
),
4845 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB
),
4846 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810
),
4847 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM
),
4848 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734
),
4849 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU
),
4850 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734
),
4851 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU
),
4852 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG
),
4853 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG
),
4854 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG
),
4855 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700
),
4857 /* Below is the copied entries from alc880_quirks.c.
4858 * It's not quite sure whether BIOS sets the correct pin-config table
4859 * on these machines, thus they are kept to be compatible with
4860 * the old static quirks. Once when it's confirmed to work without
4861 * these overrides, it'd be better to remove.
4863 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG
),
4864 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST
),
4865 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG
),
4866 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG
),
4867 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG
),
4868 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG
),
4869 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG
),
4870 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST
),
4871 SND_PCI_QUIRK(0x1039, 0x1234, NULL
, ALC880_FIXUP_6ST_DIG
),
4872 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST
),
4873 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST
),
4874 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST
),
4875 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST
),
4876 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST
),
4877 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG
),
4878 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG
),
4879 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG
),
4880 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG
),
4881 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG
),
4882 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG
),
4883 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG
),
4884 SND_PCI_QUIRK(0x2668, 0x8086, NULL
, ALC880_FIXUP_6ST_DIG
), /* broken BIOS */
4885 SND_PCI_QUIRK(0x8086, 0x2668, NULL
, ALC880_FIXUP_6ST_DIG
),
4886 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4887 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4888 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4889 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4890 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4891 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4892 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4893 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4894 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4895 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4897 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST
),
4898 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG
),
4899 SND_PCI_QUIRK(0xe803, 0x1019, NULL
, ALC880_FIXUP_6ST_DIG
),
4903 static const struct alc_model_fixup alc880_fixup_models
[] = {
4904 {.id
= ALC880_FIXUP_3ST
, .name
= "3stack"},
4905 {.id
= ALC880_FIXUP_3ST_DIG
, .name
= "3stack-digout"},
4906 {.id
= ALC880_FIXUP_5ST
, .name
= "5stack"},
4907 {.id
= ALC880_FIXUP_5ST_DIG
, .name
= "5stack-digout"},
4908 {.id
= ALC880_FIXUP_6ST
, .name
= "6stack"},
4909 {.id
= ALC880_FIXUP_6ST_DIG
, .name
= "6stack-digout"},
4915 * OK, here we have finally the patch for ALC880
4917 static int patch_alc880(struct hda_codec
*codec
)
4919 struct alc_spec
*spec
;
4922 err
= alc_alloc_spec(codec
, 0x0b);
4927 spec
->need_dac_fix
= 1;
4929 alc_pick_fixup(codec
, alc880_fixup_models
, alc880_fixup_tbl
,
4931 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
4933 /* automatic parse from the BIOS config */
4934 err
= alc880_parse_auto_config(codec
);
4938 if (!spec
->no_analog
) {
4939 err
= snd_hda_attach_beep_device(codec
, 0x1);
4942 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
4945 codec
->patch_ops
= alc_patch_ops
;
4946 codec
->patch_ops
.unsol_event
= alc880_unsol_event
;
4949 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
4962 static int alc260_parse_auto_config(struct hda_codec
*codec
)
4964 static const hda_nid_t alc260_ignore
[] = { 0x17, 0 };
4965 static const hda_nid_t alc260_ssids
[] = { 0x10, 0x15, 0x0f, 0 };
4966 return alc_parse_auto_config(codec
, alc260_ignore
, alc260_ssids
);
4973 ALC260_FIXUP_HP_DC5750
,
4974 ALC260_FIXUP_HP_PIN_0F
,
4977 ALC260_FIXUP_GPIO1_TOGGLE
,
4978 ALC260_FIXUP_REPLACER
,
4979 ALC260_FIXUP_HP_B1900
,
4983 static void alc260_gpio1_automute(struct hda_codec
*codec
)
4985 struct alc_spec
*spec
= codec
->spec
;
4986 snd_hda_codec_write(codec
, 0x01, 0, AC_VERB_SET_GPIO_DATA
,
4987 spec
->hp_jack_present
);
4990 static void alc260_fixup_gpio1_toggle(struct hda_codec
*codec
,
4991 const struct alc_fixup
*fix
, int action
)
4993 struct alc_spec
*spec
= codec
->spec
;
4994 if (action
== ALC_FIXUP_ACT_PROBE
) {
4995 /* although the machine has only one output pin, we need to
4996 * toggle GPIO1 according to the jack state
4998 spec
->automute_hook
= alc260_gpio1_automute
;
4999 spec
->detect_hp
= 1;
5000 spec
->automute_speaker
= 1;
5001 spec
->autocfg
.hp_pins
[0] = 0x0f; /* copy it for automute */
5002 snd_hda_jack_detect_enable_callback(codec
, 0x0f, ALC_HP_EVENT
,
5004 snd_hda_gen_add_verbs(&spec
->gen
, alc_gpio1_init_verbs
);
5008 static void alc260_fixup_kn1(struct hda_codec
*codec
,
5009 const struct alc_fixup
*fix
, int action
)
5011 struct alc_spec
*spec
= codec
->spec
;
5012 static const struct alc_pincfg pincfgs
[] = {
5013 { 0x0f, 0x02214000 }, /* HP/speaker */
5014 { 0x12, 0x90a60160 }, /* int mic */
5015 { 0x13, 0x02a19000 }, /* ext mic */
5016 { 0x18, 0x01446000 }, /* SPDIF out */
5017 /* disable bogus I/O pins */
5018 { 0x10, 0x411111f0 },
5019 { 0x11, 0x411111f0 },
5020 { 0x14, 0x411111f0 },
5021 { 0x15, 0x411111f0 },
5022 { 0x16, 0x411111f0 },
5023 { 0x17, 0x411111f0 },
5024 { 0x19, 0x411111f0 },
5029 case ALC_FIXUP_ACT_PRE_PROBE
:
5030 alc_apply_pincfgs(codec
, pincfgs
);
5032 case ALC_FIXUP_ACT_PROBE
:
5033 spec
->init_amp
= ALC_INIT_NONE
;
5038 static const struct alc_fixup alc260_fixups
[] = {
5039 [ALC260_FIXUP_HP_DC5750
] = {
5040 .type
= ALC_FIXUP_PINS
,
5041 .v
.pins
= (const struct alc_pincfg
[]) {
5042 { 0x11, 0x90130110 }, /* speaker */
5046 [ALC260_FIXUP_HP_PIN_0F
] = {
5047 .type
= ALC_FIXUP_PINS
,
5048 .v
.pins
= (const struct alc_pincfg
[]) {
5049 { 0x0f, 0x01214000 }, /* HP */
5053 [ALC260_FIXUP_COEF
] = {
5054 .type
= ALC_FIXUP_VERBS
,
5055 .v
.verbs
= (const struct hda_verb
[]) {
5056 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5057 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3040 },
5061 .chain_id
= ALC260_FIXUP_HP_PIN_0F
,
5063 [ALC260_FIXUP_GPIO1
] = {
5064 .type
= ALC_FIXUP_VERBS
,
5065 .v
.verbs
= alc_gpio1_init_verbs
,
5067 [ALC260_FIXUP_GPIO1_TOGGLE
] = {
5068 .type
= ALC_FIXUP_FUNC
,
5069 .v
.func
= alc260_fixup_gpio1_toggle
,
5071 .chain_id
= ALC260_FIXUP_HP_PIN_0F
,
5073 [ALC260_FIXUP_REPLACER
] = {
5074 .type
= ALC_FIXUP_VERBS
,
5075 .v
.verbs
= (const struct hda_verb
[]) {
5076 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5077 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5081 .chain_id
= ALC260_FIXUP_GPIO1_TOGGLE
,
5083 [ALC260_FIXUP_HP_B1900
] = {
5084 .type
= ALC_FIXUP_FUNC
,
5085 .v
.func
= alc260_fixup_gpio1_toggle
,
5087 .chain_id
= ALC260_FIXUP_COEF
,
5089 [ALC260_FIXUP_KN1
] = {
5090 .type
= ALC_FIXUP_FUNC
,
5091 .v
.func
= alc260_fixup_kn1
,
5095 static const struct snd_pci_quirk alc260_fixup_tbl
[] = {
5096 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1
),
5097 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF
),
5098 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1
),
5099 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750
),
5100 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900
),
5101 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1
),
5102 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1
),
5103 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER
),
5104 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF
),
5110 static int patch_alc260(struct hda_codec
*codec
)
5112 struct alc_spec
*spec
;
5115 err
= alc_alloc_spec(codec
, 0x07);
5121 alc_pick_fixup(codec
, NULL
, alc260_fixup_tbl
, alc260_fixups
);
5122 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5124 /* automatic parse from the BIOS config */
5125 err
= alc260_parse_auto_config(codec
);
5129 if (!spec
->no_analog
) {
5130 err
= snd_hda_attach_beep_device(codec
, 0x1);
5133 set_beep_amp(spec
, 0x07, 0x05, HDA_INPUT
);
5136 codec
->patch_ops
= alc_patch_ops
;
5137 spec
->shutup
= alc_eapd_shutup
;
5139 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5150 * ALC882/883/885/888/889 support
5152 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5153 * configuration. Each pin widget can choose any input DACs and a mixer.
5154 * Each ADC is connected from a mixer of all inputs. This makes possible
5155 * 6-channel independent captures.
5157 * In addition, an independent DAC for the multi-playback (not used in this
5165 ALC882_FIXUP_ABIT_AW9D_MAX
,
5166 ALC882_FIXUP_LENOVO_Y530
,
5167 ALC882_FIXUP_PB_M5210
,
5168 ALC882_FIXUP_ACER_ASPIRE_7736
,
5169 ALC882_FIXUP_ASUS_W90V
,
5171 ALC889_FIXUP_VAIO_TT
,
5172 ALC888_FIXUP_EEE1601
,
5175 ALC883_FIXUP_ACER_EAPD
,
5180 ALC882_FIXUP_ASUS_W2JC
,
5181 ALC882_FIXUP_ACER_ASPIRE_4930G
,
5182 ALC882_FIXUP_ACER_ASPIRE_8930G
,
5183 ALC882_FIXUP_ASPIRE_8930G_VERBS
,
5184 ALC885_FIXUP_MACPRO_GPIO
,
5185 ALC889_FIXUP_DAC_ROUTE
,
5186 ALC889_FIXUP_MBP_VREF
,
5187 ALC889_FIXUP_IMAC91_VREF
,
5188 ALC882_FIXUP_INV_DMIC
,
5189 ALC882_FIXUP_NO_PRIMARY_HP
,
5192 static void alc889_fixup_coef(struct hda_codec
*codec
,
5193 const struct alc_fixup
*fix
, int action
)
5195 if (action
!= ALC_FIXUP_ACT_INIT
)
5197 alc889_coef_init(codec
);
5200 /* toggle speaker-output according to the hp-jack state */
5201 static void alc882_gpio_mute(struct hda_codec
*codec
, int pin
, int muted
)
5203 unsigned int gpiostate
, gpiomask
, gpiodir
;
5205 gpiostate
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5206 AC_VERB_GET_GPIO_DATA
, 0);
5209 gpiostate
|= (1 << pin
);
5211 gpiostate
&= ~(1 << pin
);
5213 gpiomask
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5214 AC_VERB_GET_GPIO_MASK
, 0);
5215 gpiomask
|= (1 << pin
);
5217 gpiodir
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5218 AC_VERB_GET_GPIO_DIRECTION
, 0);
5219 gpiodir
|= (1 << pin
);
5222 snd_hda_codec_write(codec
, codec
->afg
, 0,
5223 AC_VERB_SET_GPIO_MASK
, gpiomask
);
5224 snd_hda_codec_write(codec
, codec
->afg
, 0,
5225 AC_VERB_SET_GPIO_DIRECTION
, gpiodir
);
5229 snd_hda_codec_write(codec
, codec
->afg
, 0,
5230 AC_VERB_SET_GPIO_DATA
, gpiostate
);
5233 /* set up GPIO at initialization */
5234 static void alc885_fixup_macpro_gpio(struct hda_codec
*codec
,
5235 const struct alc_fixup
*fix
, int action
)
5237 if (action
!= ALC_FIXUP_ACT_INIT
)
5239 alc882_gpio_mute(codec
, 0, 0);
5240 alc882_gpio_mute(codec
, 1, 0);
5243 /* Fix the connection of some pins for ALC889:
5244 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
5245 * work correctly (bko#42740)
5247 static void alc889_fixup_dac_route(struct hda_codec
*codec
,
5248 const struct alc_fixup
*fix
, int action
)
5250 if (action
== ALC_FIXUP_ACT_PRE_PROBE
) {
5251 /* fake the connections during parsing the tree */
5252 hda_nid_t conn1
[2] = { 0x0c, 0x0d };
5253 hda_nid_t conn2
[2] = { 0x0e, 0x0f };
5254 snd_hda_override_conn_list(codec
, 0x14, 2, conn1
);
5255 snd_hda_override_conn_list(codec
, 0x15, 2, conn1
);
5256 snd_hda_override_conn_list(codec
, 0x18, 2, conn2
);
5257 snd_hda_override_conn_list(codec
, 0x1a, 2, conn2
);
5258 } else if (action
== ALC_FIXUP_ACT_PROBE
) {
5259 /* restore the connections */
5260 hda_nid_t conn
[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
5261 snd_hda_override_conn_list(codec
, 0x14, 5, conn
);
5262 snd_hda_override_conn_list(codec
, 0x15, 5, conn
);
5263 snd_hda_override_conn_list(codec
, 0x18, 5, conn
);
5264 snd_hda_override_conn_list(codec
, 0x1a, 5, conn
);
5268 /* Set VREF on HP pin */
5269 static void alc889_fixup_mbp_vref(struct hda_codec
*codec
,
5270 const struct alc_fixup
*fix
, int action
)
5272 struct alc_spec
*spec
= codec
->spec
;
5273 static hda_nid_t nids
[2] = { 0x14, 0x15 };
5276 if (action
!= ALC_FIXUP_ACT_INIT
)
5278 for (i
= 0; i
< ARRAY_SIZE(nids
); i
++) {
5279 unsigned int val
= snd_hda_codec_get_pincfg(codec
, nids
[i
]);
5280 if (get_defcfg_device(val
) != AC_JACK_HP_OUT
)
5282 val
= snd_hda_codec_read(codec
, nids
[i
], 0,
5283 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
5284 val
|= AC_PINCTL_VREF_80
;
5285 snd_hda_set_pin_ctl(codec
, nids
[i
], val
);
5286 spec
->keep_vref_in_automute
= 1;
5291 /* Set VREF on speaker pins on imac91 */
5292 static void alc889_fixup_imac91_vref(struct hda_codec
*codec
,
5293 const struct alc_fixup
*fix
, int action
)
5295 struct alc_spec
*spec
= codec
->spec
;
5296 static hda_nid_t nids
[2] = { 0x18, 0x1a };
5299 if (action
!= ALC_FIXUP_ACT_INIT
)
5301 for (i
= 0; i
< ARRAY_SIZE(nids
); i
++) {
5303 val
= snd_hda_codec_read(codec
, nids
[i
], 0,
5304 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
5305 val
|= AC_PINCTL_VREF_50
;
5306 snd_hda_set_pin_ctl(codec
, nids
[i
], val
);
5308 spec
->keep_vref_in_automute
= 1;
5311 /* Don't take HP output as primary
5312 * strangely, the speaker output doesn't work on VAIO Z through DAC 0x05
5314 static void alc882_fixup_no_primary_hp(struct hda_codec
*codec
,
5315 const struct alc_fixup
*fix
, int action
)
5317 struct alc_spec
*spec
= codec
->spec
;
5318 if (action
== ALC_FIXUP_ACT_PRE_PROBE
)
5319 spec
->no_primary_hp
= 1;
5322 static const struct alc_fixup alc882_fixups
[] = {
5323 [ALC882_FIXUP_ABIT_AW9D_MAX
] = {
5324 .type
= ALC_FIXUP_PINS
,
5325 .v
.pins
= (const struct alc_pincfg
[]) {
5326 { 0x15, 0x01080104 }, /* side */
5327 { 0x16, 0x01011012 }, /* rear */
5328 { 0x17, 0x01016011 }, /* clfe */
5332 [ALC882_FIXUP_LENOVO_Y530
] = {
5333 .type
= ALC_FIXUP_PINS
,
5334 .v
.pins
= (const struct alc_pincfg
[]) {
5335 { 0x15, 0x99130112 }, /* rear int speakers */
5336 { 0x16, 0x99130111 }, /* subwoofer */
5340 [ALC882_FIXUP_PB_M5210
] = {
5341 .type
= ALC_FIXUP_VERBS
,
5342 .v
.verbs
= (const struct hda_verb
[]) {
5343 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF50
},
5347 [ALC882_FIXUP_ACER_ASPIRE_7736
] = {
5348 .type
= ALC_FIXUP_FUNC
,
5349 .v
.func
= alc_fixup_sku_ignore
,
5351 [ALC882_FIXUP_ASUS_W90V
] = {
5352 .type
= ALC_FIXUP_PINS
,
5353 .v
.pins
= (const struct alc_pincfg
[]) {
5354 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
5358 [ALC889_FIXUP_CD
] = {
5359 .type
= ALC_FIXUP_PINS
,
5360 .v
.pins
= (const struct alc_pincfg
[]) {
5361 { 0x1c, 0x993301f0 }, /* CD */
5365 [ALC889_FIXUP_VAIO_TT
] = {
5366 .type
= ALC_FIXUP_PINS
,
5367 .v
.pins
= (const struct alc_pincfg
[]) {
5368 { 0x17, 0x90170111 }, /* hidden surround speaker */
5372 [ALC888_FIXUP_EEE1601
] = {
5373 .type
= ALC_FIXUP_VERBS
,
5374 .v
.verbs
= (const struct hda_verb
[]) {
5375 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x0b },
5376 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0838 },
5380 [ALC882_FIXUP_EAPD
] = {
5381 .type
= ALC_FIXUP_VERBS
,
5382 .v
.verbs
= (const struct hda_verb
[]) {
5383 /* change to EAPD mode */
5384 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5385 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
5389 [ALC883_FIXUP_EAPD
] = {
5390 .type
= ALC_FIXUP_VERBS
,
5391 .v
.verbs
= (const struct hda_verb
[]) {
5392 /* change to EAPD mode */
5393 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5394 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
5398 [ALC883_FIXUP_ACER_EAPD
] = {
5399 .type
= ALC_FIXUP_VERBS
,
5400 .v
.verbs
= (const struct hda_verb
[]) {
5401 /* eanable EAPD on Acer laptops */
5402 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5403 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5407 [ALC882_FIXUP_GPIO1
] = {
5408 .type
= ALC_FIXUP_VERBS
,
5409 .v
.verbs
= alc_gpio1_init_verbs
,
5411 [ALC882_FIXUP_GPIO2
] = {
5412 .type
= ALC_FIXUP_VERBS
,
5413 .v
.verbs
= alc_gpio2_init_verbs
,
5415 [ALC882_FIXUP_GPIO3
] = {
5416 .type
= ALC_FIXUP_VERBS
,
5417 .v
.verbs
= alc_gpio3_init_verbs
,
5419 [ALC882_FIXUP_ASUS_W2JC
] = {
5420 .type
= ALC_FIXUP_VERBS
,
5421 .v
.verbs
= alc_gpio1_init_verbs
,
5423 .chain_id
= ALC882_FIXUP_EAPD
,
5425 [ALC889_FIXUP_COEF
] = {
5426 .type
= ALC_FIXUP_FUNC
,
5427 .v
.func
= alc889_fixup_coef
,
5429 [ALC882_FIXUP_ACER_ASPIRE_4930G
] = {
5430 .type
= ALC_FIXUP_PINS
,
5431 .v
.pins
= (const struct alc_pincfg
[]) {
5432 { 0x16, 0x99130111 }, /* CLFE speaker */
5433 { 0x17, 0x99130112 }, /* surround speaker */
5437 .chain_id
= ALC882_FIXUP_GPIO1
,
5439 [ALC882_FIXUP_ACER_ASPIRE_8930G
] = {
5440 .type
= ALC_FIXUP_PINS
,
5441 .v
.pins
= (const struct alc_pincfg
[]) {
5442 { 0x16, 0x99130111 }, /* CLFE speaker */
5443 { 0x1b, 0x99130112 }, /* surround speaker */
5447 .chain_id
= ALC882_FIXUP_ASPIRE_8930G_VERBS
,
5449 [ALC882_FIXUP_ASPIRE_8930G_VERBS
] = {
5450 /* additional init verbs for Acer Aspire 8930G */
5451 .type
= ALC_FIXUP_VERBS
,
5452 .v
.verbs
= (const struct hda_verb
[]) {
5453 /* Enable all DACs */
5454 /* DAC DISABLE/MUTE 1? */
5455 /* setting bits 1-5 disables DAC nids 0x02-0x06
5456 * apparently. Init=0x38 */
5457 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x03 },
5458 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0000 },
5459 /* DAC DISABLE/MUTE 2? */
5460 /* some bit here disables the other DACs.
5462 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x08 },
5463 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0000 },
5465 * This laptop has a stereo digital microphone.
5466 * The mics are only 1cm apart which makes the stereo
5467 * useless. However, either the mic or the ALC889
5468 * makes the signal become a difference/sum signal
5469 * instead of standard stereo, which is annoying.
5470 * So instead we flip this bit which makes the
5471 * codec replicate the sum signal to both channels,
5472 * turning it into a normal mono mic.
5474 /* DMIC_CONTROL? Init value = 0x0001 */
5475 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x0b },
5476 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0003 },
5477 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5478 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5482 .chain_id
= ALC882_FIXUP_GPIO1
,
5484 [ALC885_FIXUP_MACPRO_GPIO
] = {
5485 .type
= ALC_FIXUP_FUNC
,
5486 .v
.func
= alc885_fixup_macpro_gpio
,
5488 [ALC889_FIXUP_DAC_ROUTE
] = {
5489 .type
= ALC_FIXUP_FUNC
,
5490 .v
.func
= alc889_fixup_dac_route
,
5492 [ALC889_FIXUP_MBP_VREF
] = {
5493 .type
= ALC_FIXUP_FUNC
,
5494 .v
.func
= alc889_fixup_mbp_vref
,
5496 .chain_id
= ALC882_FIXUP_GPIO1
,
5498 [ALC889_FIXUP_IMAC91_VREF
] = {
5499 .type
= ALC_FIXUP_FUNC
,
5500 .v
.func
= alc889_fixup_imac91_vref
,
5502 .chain_id
= ALC882_FIXUP_GPIO1
,
5504 [ALC882_FIXUP_INV_DMIC
] = {
5505 .type
= ALC_FIXUP_FUNC
,
5506 .v
.func
= alc_fixup_inv_dmic_0x12
,
5508 [ALC882_FIXUP_NO_PRIMARY_HP
] = {
5509 .type
= ALC_FIXUP_FUNC
,
5510 .v
.func
= alc882_fixup_no_primary_hp
,
5514 static const struct snd_pci_quirk alc882_fixup_tbl
[] = {
5515 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD
),
5516 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD
),
5517 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD
),
5518 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD
),
5519 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD
),
5520 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD
),
5521 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
5522 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5523 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
5524 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5525 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
5526 ALC882_FIXUP_ACER_ASPIRE_8930G
),
5527 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
5528 ALC882_FIXUP_ACER_ASPIRE_8930G
),
5529 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
5530 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5531 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
5532 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5533 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
5534 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5535 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210
),
5536 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
5537 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5538 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE
),
5539 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G
),
5540 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736
),
5541 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD
),
5542 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V
),
5543 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC
),
5544 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601
),
5545 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT
),
5546 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP
),
5548 /* All Apple entries are in codec SSIDs */
5549 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF
),
5550 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF
),
5551 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF
),
5552 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO
),
5553 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO
),
5554 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO
),
5555 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF
),
5556 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF
),
5557 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD
),
5558 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF
),
5559 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF
),
5560 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF
),
5561 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF
),
5562 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO
),
5563 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF
),
5564 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF
),
5565 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF
),
5566 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO
),
5567 SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF
),
5568 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF
),
5569 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF
),
5570 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF
),
5572 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD
),
5573 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD
),
5574 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3
),
5575 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD
),
5576 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX
),
5577 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD
),
5578 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD
),
5579 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530
),
5580 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF
),
5584 static const struct alc_model_fixup alc882_fixup_models
[] = {
5585 {.id
= ALC882_FIXUP_ACER_ASPIRE_4930G
, .name
= "acer-aspire-4930g"},
5586 {.id
= ALC882_FIXUP_ACER_ASPIRE_8930G
, .name
= "acer-aspire-8930g"},
5587 {.id
= ALC883_FIXUP_ACER_EAPD
, .name
= "acer-aspire"},
5588 {.id
= ALC882_FIXUP_INV_DMIC
, .name
= "inv-dmic"},
5589 {.id
= ALC882_FIXUP_NO_PRIMARY_HP
, .name
= "no-primary-hp"},
5594 * BIOS auto configuration
5596 /* almost identical with ALC880 parser... */
5597 static int alc882_parse_auto_config(struct hda_codec
*codec
)
5599 static const hda_nid_t alc882_ignore
[] = { 0x1d, 0 };
5600 static const hda_nid_t alc882_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5601 return alc_parse_auto_config(codec
, alc882_ignore
, alc882_ssids
);
5606 static int patch_alc882(struct hda_codec
*codec
)
5608 struct alc_spec
*spec
;
5611 err
= alc_alloc_spec(codec
, 0x0b);
5617 switch (codec
->vendor_id
) {
5622 /* ALC883 and variants */
5623 alc_fix_pll_init(codec
, 0x20, 0x0a, 10);
5627 alc_pick_fixup(codec
, alc882_fixup_models
, alc882_fixup_tbl
,
5629 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5631 alc_auto_parse_customize_define(codec
);
5633 /* automatic parse from the BIOS config */
5634 err
= alc882_parse_auto_config(codec
);
5638 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
5639 err
= snd_hda_attach_beep_device(codec
, 0x1);
5642 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
5645 codec
->patch_ops
= alc_patch_ops
;
5647 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5660 static int alc262_parse_auto_config(struct hda_codec
*codec
)
5662 static const hda_nid_t alc262_ignore
[] = { 0x1d, 0 };
5663 static const hda_nid_t alc262_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5664 return alc_parse_auto_config(codec
, alc262_ignore
, alc262_ssids
);
5671 ALC262_FIXUP_FSC_H270
,
5672 ALC262_FIXUP_HP_Z200
,
5674 ALC262_FIXUP_LENOVO_3000
,
5676 ALC262_FIXUP_BENQ_T31
,
5677 ALC262_FIXUP_INV_DMIC
,
5680 static const struct alc_fixup alc262_fixups
[] = {
5681 [ALC262_FIXUP_FSC_H270
] = {
5682 .type
= ALC_FIXUP_PINS
,
5683 .v
.pins
= (const struct alc_pincfg
[]) {
5684 { 0x14, 0x99130110 }, /* speaker */
5685 { 0x15, 0x0221142f }, /* front HP */
5686 { 0x1b, 0x0121141f }, /* rear HP */
5690 [ALC262_FIXUP_HP_Z200
] = {
5691 .type
= ALC_FIXUP_PINS
,
5692 .v
.pins
= (const struct alc_pincfg
[]) {
5693 { 0x16, 0x99130120 }, /* internal speaker */
5697 [ALC262_FIXUP_TYAN
] = {
5698 .type
= ALC_FIXUP_PINS
,
5699 .v
.pins
= (const struct alc_pincfg
[]) {
5700 { 0x14, 0x1993e1f0 }, /* int AUX */
5704 [ALC262_FIXUP_LENOVO_3000
] = {
5705 .type
= ALC_FIXUP_VERBS
,
5706 .v
.verbs
= (const struct hda_verb
[]) {
5707 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF50
},
5711 .chain_id
= ALC262_FIXUP_BENQ
,
5713 [ALC262_FIXUP_BENQ
] = {
5714 .type
= ALC_FIXUP_VERBS
,
5715 .v
.verbs
= (const struct hda_verb
[]) {
5716 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5717 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
5721 [ALC262_FIXUP_BENQ_T31
] = {
5722 .type
= ALC_FIXUP_VERBS
,
5723 .v
.verbs
= (const struct hda_verb
[]) {
5724 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5725 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5729 [ALC262_FIXUP_INV_DMIC
] = {
5730 .type
= ALC_FIXUP_FUNC
,
5731 .v
.func
= alc_fixup_inv_dmic_0x12
,
5735 static const struct snd_pci_quirk alc262_fixup_tbl
[] = {
5736 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200
),
5737 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ
),
5738 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ
),
5739 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN
),
5740 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270
),
5741 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000
),
5742 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ
),
5743 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31
),
5747 static const struct alc_model_fixup alc262_fixup_models
[] = {
5748 {.id
= ALC262_FIXUP_INV_DMIC
, .name
= "inv-dmic"},
5754 static int patch_alc262(struct hda_codec
*codec
)
5756 struct alc_spec
*spec
;
5759 err
= alc_alloc_spec(codec
, 0x0b);
5764 spec
->shared_mic_vref_pin
= 0x18;
5767 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
5772 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
5773 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
5774 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
5775 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PROC_COEF
, tmp
| 0x80);
5778 alc_fix_pll_init(codec
, 0x20, 0x0a, 10);
5780 alc_pick_fixup(codec
, alc262_fixup_models
, alc262_fixup_tbl
,
5782 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5784 alc_auto_parse_customize_define(codec
);
5786 /* automatic parse from the BIOS config */
5787 err
= alc262_parse_auto_config(codec
);
5791 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
5792 err
= snd_hda_attach_beep_device(codec
, 0x1);
5795 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
5798 codec
->patch_ops
= alc_patch_ops
;
5799 spec
->shutup
= alc_eapd_shutup
;
5801 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5813 /* bind Beep switches of both NID 0x0f and 0x10 */
5814 static const struct hda_bind_ctls alc268_bind_beep_sw
= {
5815 .ops
= &snd_hda_bind_sw
,
5817 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT
),
5818 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT
),
5823 static const struct snd_kcontrol_new alc268_beep_mixer
[] = {
5824 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT
),
5825 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw
),
5829 /* set PCBEEP vol = 0, mute connections */
5830 static const struct hda_verb alc268_beep_init_verbs
[] = {
5831 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5832 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5833 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5838 ALC268_FIXUP_INV_DMIC
,
5839 ALC268_FIXUP_HP_EAPD
,
5842 static const struct alc_fixup alc268_fixups
[] = {
5843 [ALC268_FIXUP_INV_DMIC
] = {
5844 .type
= ALC_FIXUP_FUNC
,
5845 .v
.func
= alc_fixup_inv_dmic_0x12
,
5847 [ALC268_FIXUP_HP_EAPD
] = {
5848 .type
= ALC_FIXUP_VERBS
,
5849 .v
.verbs
= (const struct hda_verb
[]) {
5850 {0x15, AC_VERB_SET_EAPD_BTLENABLE
, 0},
5856 static const struct alc_model_fixup alc268_fixup_models
[] = {
5857 {.id
= ALC268_FIXUP_INV_DMIC
, .name
= "inv-dmic"},
5858 {.id
= ALC268_FIXUP_HP_EAPD
, .name
= "hp-eapd"},
5862 static const struct snd_pci_quirk alc268_fixup_tbl
[] = {
5863 /* below is codec SSID since multiple Toshiba laptops have the
5864 * same PCI SSID 1179:ff00
5866 SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD
),
5871 * BIOS auto configuration
5873 static int alc268_parse_auto_config(struct hda_codec
*codec
)
5875 static const hda_nid_t alc268_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5876 struct alc_spec
*spec
= codec
->spec
;
5877 int err
= alc_parse_auto_config(codec
, NULL
, alc268_ssids
);
5879 if (!spec
->no_analog
&& spec
->autocfg
.speaker_pins
[0] != 0x1d) {
5880 add_mixer(spec
, alc268_beep_mixer
);
5881 snd_hda_gen_add_verbs(&spec
->gen
, alc268_beep_init_verbs
);
5889 static int patch_alc268(struct hda_codec
*codec
)
5891 struct alc_spec
*spec
;
5892 int i
, has_beep
, err
;
5894 /* ALC268 has no aa-loopback mixer */
5895 err
= alc_alloc_spec(codec
, 0);
5901 alc_pick_fixup(codec
, alc268_fixup_models
, alc268_fixup_tbl
, alc268_fixups
);
5902 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5904 /* automatic parse from the BIOS config */
5905 err
= alc268_parse_auto_config(codec
);
5910 for (i
= 0; i
< spec
->num_mixers
; i
++) {
5911 if (spec
->mixers
[i
] == alc268_beep_mixer
) {
5918 err
= snd_hda_attach_beep_device(codec
, 0x1);
5921 if (!query_amp_caps(codec
, 0x1d, HDA_INPUT
))
5922 /* override the amp caps for beep generator */
5923 snd_hda_override_amp_caps(codec
, 0x1d, HDA_INPUT
,
5924 (0x0c << AC_AMPCAP_OFFSET_SHIFT
) |
5925 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT
) |
5926 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
5927 (0 << AC_AMPCAP_MUTE_SHIFT
));
5930 codec
->patch_ops
= alc_patch_ops
;
5931 spec
->shutup
= alc_eapd_shutup
;
5933 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5945 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback
= {
5949 .rates
= SNDRV_PCM_RATE_44100
, /* fixed rate */
5950 /* NID is set in alc_build_pcms */
5952 .open
= alc_playback_pcm_open
,
5953 .prepare
= alc_playback_pcm_prepare
,
5954 .cleanup
= alc_playback_pcm_cleanup
5958 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture
= {
5962 .rates
= SNDRV_PCM_RATE_44100
, /* fixed rate */
5963 /* NID is set in alc_build_pcms */
5966 /* different alc269-variants */
5968 ALC269_TYPE_ALC269VA
,
5969 ALC269_TYPE_ALC269VB
,
5970 ALC269_TYPE_ALC269VC
,
5971 ALC269_TYPE_ALC269VD
,
5978 * BIOS auto configuration
5980 static int alc269_parse_auto_config(struct hda_codec
*codec
)
5982 static const hda_nid_t alc269_ignore
[] = { 0x1d, 0 };
5983 static const hda_nid_t alc269_ssids
[] = { 0, 0x1b, 0x14, 0x21 };
5984 static const hda_nid_t alc269va_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5985 struct alc_spec
*spec
= codec
->spec
;
5986 const hda_nid_t
*ssids
;
5988 switch (spec
->codec_variant
) {
5989 case ALC269_TYPE_ALC269VA
:
5990 case ALC269_TYPE_ALC269VC
:
5991 case ALC269_TYPE_ALC280
:
5992 case ALC269_TYPE_ALC284
:
5993 ssids
= alc269va_ssids
;
5995 case ALC269_TYPE_ALC269VB
:
5996 case ALC269_TYPE_ALC269VD
:
5997 case ALC269_TYPE_ALC282
:
5998 ssids
= alc269_ssids
;
6001 ssids
= alc269_ssids
;
6005 return alc_parse_auto_config(codec
, alc269_ignore
, ssids
);
6008 static void alc269vb_toggle_power_output(struct hda_codec
*codec
, int power_up
)
6010 int val
= alc_read_coef_idx(codec
, 0x04);
6015 alc_write_coef_idx(codec
, 0x04, val
);
6018 static void alc269_shutup(struct hda_codec
*codec
)
6020 struct alc_spec
*spec
= codec
->spec
;
6022 if (spec
->codec_variant
!= ALC269_TYPE_ALC269VB
)
6025 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
)
6026 alc269vb_toggle_power_output(codec
, 0);
6027 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
&&
6028 (alc_get_coef0(codec
) & 0x00ff) == 0x018) {
6034 static int alc269_resume(struct hda_codec
*codec
)
6036 struct alc_spec
*spec
= codec
->spec
;
6038 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
)
6039 alc269vb_toggle_power_output(codec
, 0);
6040 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
&&
6041 (alc_get_coef0(codec
) & 0x00ff) == 0x018) {
6045 codec
->patch_ops
.init(codec
);
6047 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
)
6048 alc269vb_toggle_power_output(codec
, 1);
6049 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
&&
6050 (alc_get_coef0(codec
) & 0x00ff) == 0x017) {
6054 snd_hda_codec_resume_amp(codec
);
6055 snd_hda_codec_resume_cache(codec
);
6056 hda_call_check_power_status(codec
, 0x01);
6059 #endif /* CONFIG_PM */
6061 static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec
*codec
,
6062 const struct alc_fixup
*fix
, int action
)
6064 struct alc_spec
*spec
= codec
->spec
;
6066 if (action
== ALC_FIXUP_ACT_PRE_PROBE
)
6067 spec
->parse_flags
= HDA_PINCFG_NO_HP_FIXUP
;
6070 static void alc269_fixup_hweq(struct hda_codec
*codec
,
6071 const struct alc_fixup
*fix
, int action
)
6075 if (action
!= ALC_FIXUP_ACT_INIT
)
6077 coef
= alc_read_coef_idx(codec
, 0x1e);
6078 alc_write_coef_idx(codec
, 0x1e, coef
| 0x80);
6081 static void alc271_fixup_dmic(struct hda_codec
*codec
,
6082 const struct alc_fixup
*fix
, int action
)
6084 static const struct hda_verb verbs
[] = {
6085 {0x20, AC_VERB_SET_COEF_INDEX
, 0x0d},
6086 {0x20, AC_VERB_SET_PROC_COEF
, 0x4000},
6091 if (strcmp(codec
->chip_name
, "ALC271X"))
6093 cfg
= snd_hda_codec_get_pincfg(codec
, 0x12);
6094 if (get_defcfg_connect(cfg
) == AC_JACK_PORT_FIXED
)
6095 snd_hda_sequence_write(codec
, verbs
);
6098 static void alc269_fixup_pcm_44k(struct hda_codec
*codec
,
6099 const struct alc_fixup
*fix
, int action
)
6101 struct alc_spec
*spec
= codec
->spec
;
6103 if (action
!= ALC_FIXUP_ACT_PROBE
)
6106 /* Due to a hardware problem on Lenovo Ideadpad, we need to
6107 * fix the sample rate of analog I/O to 44.1kHz
6109 spec
->stream_analog_playback
= &alc269_44k_pcm_analog_playback
;
6110 spec
->stream_analog_capture
= &alc269_44k_pcm_analog_capture
;
6113 static void alc269_fixup_stereo_dmic(struct hda_codec
*codec
,
6114 const struct alc_fixup
*fix
, int action
)
6118 if (action
!= ALC_FIXUP_ACT_INIT
)
6120 /* The digital-mic unit sends PDM (differential signal) instead of
6121 * the standard PCM, thus you can't record a valid mono stream as is.
6122 * Below is a workaround specific to ALC269 to control the dmic
6123 * signal source as mono.
6125 coef
= alc_read_coef_idx(codec
, 0x07);
6126 alc_write_coef_idx(codec
, 0x07, coef
| 0x80);
6129 static void alc269_quanta_automute(struct hda_codec
*codec
)
6131 update_outputs(codec
);
6133 snd_hda_codec_write(codec
, 0x20, 0,
6134 AC_VERB_SET_COEF_INDEX
, 0x0c);
6135 snd_hda_codec_write(codec
, 0x20, 0,
6136 AC_VERB_SET_PROC_COEF
, 0x680);
6138 snd_hda_codec_write(codec
, 0x20, 0,
6139 AC_VERB_SET_COEF_INDEX
, 0x0c);
6140 snd_hda_codec_write(codec
, 0x20, 0,
6141 AC_VERB_SET_PROC_COEF
, 0x480);
6144 static void alc269_fixup_quanta_mute(struct hda_codec
*codec
,
6145 const struct alc_fixup
*fix
, int action
)
6147 struct alc_spec
*spec
= codec
->spec
;
6148 if (action
!= ALC_FIXUP_ACT_PROBE
)
6150 spec
->automute_hook
= alc269_quanta_automute
;
6153 /* update mute-LED according to the speaker mute state via mic1 VREF pin */
6154 static void alc269_fixup_mic1_mute_hook(void *private_data
, int enabled
)
6156 struct hda_codec
*codec
= private_data
;
6157 unsigned int pinval
= AC_PINCTL_IN_EN
+ (enabled
?
6158 AC_PINCTL_VREF_HIZ
: AC_PINCTL_VREF_80
);
6159 snd_hda_set_pin_ctl_cache(codec
, 0x18, pinval
);
6162 static void alc269_fixup_mic1_mute(struct hda_codec
*codec
,
6163 const struct alc_fixup
*fix
, int action
)
6165 struct alc_spec
*spec
= codec
->spec
;
6166 if (action
== ALC_FIXUP_ACT_PROBE
)
6167 spec
->vmaster_mute
.hook
= alc269_fixup_mic1_mute_hook
;
6170 /* update mute-LED according to the speaker mute state via mic2 VREF pin */
6171 static void alc269_fixup_mic2_mute_hook(void *private_data
, int enabled
)
6173 struct hda_codec
*codec
= private_data
;
6174 unsigned int pinval
= enabled
? 0x20 : 0x24;
6175 snd_hda_set_pin_ctl_cache(codec
, 0x19, pinval
);
6178 static void alc269_fixup_mic2_mute(struct hda_codec
*codec
,
6179 const struct alc_fixup
*fix
, int action
)
6181 struct alc_spec
*spec
= codec
->spec
;
6182 if (action
== ALC_FIXUP_ACT_PROBE
)
6183 spec
->vmaster_mute
.hook
= alc269_fixup_mic2_mute_hook
;
6186 static void alc271_hp_gate_mic_jack(struct hda_codec
*codec
,
6187 const struct alc_fixup
*fix
,
6190 struct alc_spec
*spec
= codec
->spec
;
6192 if (action
== ALC_FIXUP_ACT_PROBE
)
6193 snd_hda_jack_set_gating_jack(codec
, spec
->ext_mic_pin
,
6194 spec
->autocfg
.hp_pins
[0]);
6198 ALC269_FIXUP_SONY_VAIO
,
6199 ALC275_FIXUP_SONY_VAIO_GPIO2
,
6200 ALC269_FIXUP_DELL_M101Z
,
6201 ALC269_FIXUP_SKU_IGNORE
,
6202 ALC269_FIXUP_ASUS_G73JW
,
6203 ALC269_FIXUP_LENOVO_EAPD
,
6204 ALC275_FIXUP_SONY_HWEQ
,
6206 ALC269_FIXUP_PCM_44K
,
6207 ALC269_FIXUP_STEREO_DMIC
,
6208 ALC269_FIXUP_QUANTA_MUTE
,
6209 ALC269_FIXUP_LIFEBOOK
,
6212 ALC269VB_FIXUP_AMIC
,
6213 ALC269VB_FIXUP_DMIC
,
6214 ALC269_FIXUP_MIC1_MUTE_LED
,
6215 ALC269_FIXUP_MIC2_MUTE_LED
,
6216 ALC269_FIXUP_INV_DMIC
,
6217 ALC269_FIXUP_LENOVO_DOCK
,
6218 ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
,
6219 ALC271_FIXUP_AMIC_MIC2
,
6220 ALC271_FIXUP_HP_GATE_MIC_JACK
,
6223 static const struct alc_fixup alc269_fixups
[] = {
6224 [ALC269_FIXUP_SONY_VAIO
] = {
6225 .type
= ALC_FIXUP_VERBS
,
6226 .v
.verbs
= (const struct hda_verb
[]) {
6227 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREFGRD
},
6231 [ALC275_FIXUP_SONY_VAIO_GPIO2
] = {
6232 .type
= ALC_FIXUP_VERBS
,
6233 .v
.verbs
= (const struct hda_verb
[]) {
6234 {0x01, AC_VERB_SET_GPIO_MASK
, 0x04},
6235 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x04},
6236 {0x01, AC_VERB_SET_GPIO_DATA
, 0x00},
6240 .chain_id
= ALC269_FIXUP_SONY_VAIO
6242 [ALC269_FIXUP_DELL_M101Z
] = {
6243 .type
= ALC_FIXUP_VERBS
,
6244 .v
.verbs
= (const struct hda_verb
[]) {
6245 /* Enables internal speaker */
6246 {0x20, AC_VERB_SET_COEF_INDEX
, 13},
6247 {0x20, AC_VERB_SET_PROC_COEF
, 0x4040},
6251 [ALC269_FIXUP_SKU_IGNORE
] = {
6252 .type
= ALC_FIXUP_FUNC
,
6253 .v
.func
= alc_fixup_sku_ignore
,
6255 [ALC269_FIXUP_ASUS_G73JW
] = {
6256 .type
= ALC_FIXUP_PINS
,
6257 .v
.pins
= (const struct alc_pincfg
[]) {
6258 { 0x17, 0x99130111 }, /* subwoofer */
6262 [ALC269_FIXUP_LENOVO_EAPD
] = {
6263 .type
= ALC_FIXUP_VERBS
,
6264 .v
.verbs
= (const struct hda_verb
[]) {
6265 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 0},
6269 [ALC275_FIXUP_SONY_HWEQ
] = {
6270 .type
= ALC_FIXUP_FUNC
,
6271 .v
.func
= alc269_fixup_hweq
,
6273 .chain_id
= ALC275_FIXUP_SONY_VAIO_GPIO2
6275 [ALC271_FIXUP_DMIC
] = {
6276 .type
= ALC_FIXUP_FUNC
,
6277 .v
.func
= alc271_fixup_dmic
,
6279 [ALC269_FIXUP_PCM_44K
] = {
6280 .type
= ALC_FIXUP_FUNC
,
6281 .v
.func
= alc269_fixup_pcm_44k
,
6283 .chain_id
= ALC269_FIXUP_QUANTA_MUTE
6285 [ALC269_FIXUP_STEREO_DMIC
] = {
6286 .type
= ALC_FIXUP_FUNC
,
6287 .v
.func
= alc269_fixup_stereo_dmic
,
6289 [ALC269_FIXUP_QUANTA_MUTE
] = {
6290 .type
= ALC_FIXUP_FUNC
,
6291 .v
.func
= alc269_fixup_quanta_mute
,
6293 [ALC269_FIXUP_LIFEBOOK
] = {
6294 .type
= ALC_FIXUP_PINS
,
6295 .v
.pins
= (const struct alc_pincfg
[]) {
6296 { 0x1a, 0x2101103f }, /* dock line-out */
6297 { 0x1b, 0x23a11040 }, /* dock mic-in */
6301 .chain_id
= ALC269_FIXUP_QUANTA_MUTE
6303 [ALC269_FIXUP_AMIC
] = {
6304 .type
= ALC_FIXUP_PINS
,
6305 .v
.pins
= (const struct alc_pincfg
[]) {
6306 { 0x14, 0x99130110 }, /* speaker */
6307 { 0x15, 0x0121401f }, /* HP out */
6308 { 0x18, 0x01a19c20 }, /* mic */
6309 { 0x19, 0x99a3092f }, /* int-mic */
6313 [ALC269_FIXUP_DMIC
] = {
6314 .type
= ALC_FIXUP_PINS
,
6315 .v
.pins
= (const struct alc_pincfg
[]) {
6316 { 0x12, 0x99a3092f }, /* int-mic */
6317 { 0x14, 0x99130110 }, /* speaker */
6318 { 0x15, 0x0121401f }, /* HP out */
6319 { 0x18, 0x01a19c20 }, /* mic */
6323 [ALC269VB_FIXUP_AMIC
] = {
6324 .type
= ALC_FIXUP_PINS
,
6325 .v
.pins
= (const struct alc_pincfg
[]) {
6326 { 0x14, 0x99130110 }, /* speaker */
6327 { 0x18, 0x01a19c20 }, /* mic */
6328 { 0x19, 0x99a3092f }, /* int-mic */
6329 { 0x21, 0x0121401f }, /* HP out */
6333 [ALC269VB_FIXUP_DMIC
] = {
6334 .type
= ALC_FIXUP_PINS
,
6335 .v
.pins
= (const struct alc_pincfg
[]) {
6336 { 0x12, 0x99a3092f }, /* int-mic */
6337 { 0x14, 0x99130110 }, /* speaker */
6338 { 0x18, 0x01a19c20 }, /* mic */
6339 { 0x21, 0x0121401f }, /* HP out */
6343 [ALC269_FIXUP_MIC1_MUTE_LED
] = {
6344 .type
= ALC_FIXUP_FUNC
,
6345 .v
.func
= alc269_fixup_mic1_mute
,
6347 [ALC269_FIXUP_MIC2_MUTE_LED
] = {
6348 .type
= ALC_FIXUP_FUNC
,
6349 .v
.func
= alc269_fixup_mic2_mute
,
6351 [ALC269_FIXUP_INV_DMIC
] = {
6352 .type
= ALC_FIXUP_FUNC
,
6353 .v
.func
= alc_fixup_inv_dmic_0x12
,
6355 [ALC269_FIXUP_LENOVO_DOCK
] = {
6356 .type
= ALC_FIXUP_PINS
,
6357 .v
.pins
= (const struct alc_pincfg
[]) {
6358 { 0x19, 0x23a11040 }, /* dock mic */
6359 { 0x1b, 0x2121103f }, /* dock headphone */
6363 .chain_id
= ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
6365 [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
] = {
6366 .type
= ALC_FIXUP_FUNC
,
6367 .v
.func
= alc269_fixup_pincfg_no_hp_to_lineout
,
6369 [ALC271_FIXUP_AMIC_MIC2
] = {
6370 .type
= ALC_FIXUP_PINS
,
6371 .v
.pins
= (const struct alc_pincfg
[]) {
6372 { 0x14, 0x99130110 }, /* speaker */
6373 { 0x19, 0x01a19c20 }, /* mic */
6374 { 0x1b, 0x99a7012f }, /* int-mic */
6375 { 0x21, 0x0121401f }, /* HP out */
6379 [ALC271_FIXUP_HP_GATE_MIC_JACK
] = {
6380 .type
= ALC_FIXUP_FUNC
,
6381 .v
.func
= alc271_hp_gate_mic_jack
,
6383 .chain_id
= ALC271_FIXUP_AMIC_MIC2
,
6387 static const struct snd_pci_quirk alc269_fixup_tbl
[] = {
6388 SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC
),
6389 SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC
),
6390 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED
),
6391 SND_PCI_QUIRK(0x103c, 0x1972, "HP Pavilion 17", ALC269_FIXUP_MIC1_MUTE_LED
),
6392 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC
),
6393 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_DMIC
),
6394 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW
),
6395 SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC
),
6396 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC
),
6397 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC
),
6398 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC
),
6399 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC
),
6400 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC
),
6401 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2
),
6402 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ
),
6403 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ
),
6404 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO
),
6405 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z
),
6406 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK
),
6407 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC
),
6408 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK
),
6409 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE
),
6410 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE
),
6411 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE
),
6412 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE
),
6413 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE
),
6414 SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK
),
6415 SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK
),
6416 SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK
),
6417 SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK
),
6418 SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK
),
6419 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K
),
6420 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD
),
6423 /* Below is a quirk table taken from the old code.
6424 * Basically the device should work as is without the fixup table.
6425 * If BIOS doesn't give a proper info, enable the corresponding
6428 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
6430 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC
),
6431 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC
),
6432 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC
),
6433 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC
),
6434 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC
),
6435 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC
),
6436 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC
),
6437 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC
),
6438 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC
),
6439 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC
),
6440 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC
),
6441 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC
),
6442 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC
),
6443 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC
),
6444 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC
),
6445 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC
),
6446 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC
),
6447 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC
),
6448 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC
),
6449 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC
),
6450 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC
),
6451 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC
),
6452 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC
),
6453 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC
),
6454 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC
),
6455 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC
),
6456 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC
),
6457 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC
),
6458 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC
),
6459 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC
),
6460 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC
),
6461 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC
),
6462 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC
),
6463 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC
),
6464 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC
),
6465 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC
),
6466 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC
),
6467 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC
),
6468 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC
),
6473 static const struct alc_model_fixup alc269_fixup_models
[] = {
6474 {.id
= ALC269_FIXUP_AMIC
, .name
= "laptop-amic"},
6475 {.id
= ALC269_FIXUP_DMIC
, .name
= "laptop-dmic"},
6476 {.id
= ALC269_FIXUP_STEREO_DMIC
, .name
= "alc269-dmic"},
6477 {.id
= ALC271_FIXUP_DMIC
, .name
= "alc271-dmic"},
6478 {.id
= ALC269_FIXUP_INV_DMIC
, .name
= "inv-dmic"},
6479 {.id
= ALC269_FIXUP_LENOVO_DOCK
, .name
= "lenovo-dock"},
6484 static void alc269_fill_coef(struct hda_codec
*codec
)
6486 struct alc_spec
*spec
= codec
->spec
;
6489 if (spec
->codec_variant
!= ALC269_TYPE_ALC269VB
)
6492 if ((alc_get_coef0(codec
) & 0x00ff) < 0x015) {
6493 alc_write_coef_idx(codec
, 0xf, 0x960b);
6494 alc_write_coef_idx(codec
, 0xe, 0x8817);
6497 if ((alc_get_coef0(codec
) & 0x00ff) == 0x016) {
6498 alc_write_coef_idx(codec
, 0xf, 0x960b);
6499 alc_write_coef_idx(codec
, 0xe, 0x8814);
6502 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017) {
6503 val
= alc_read_coef_idx(codec
, 0x04);
6504 /* Power up output pin */
6505 alc_write_coef_idx(codec
, 0x04, val
| (1<<11));
6508 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
6509 val
= alc_read_coef_idx(codec
, 0xd);
6510 if ((val
& 0x0c00) >> 10 != 0x1) {
6511 /* Capless ramp up clock control */
6512 alc_write_coef_idx(codec
, 0xd, val
| (1<<10));
6514 val
= alc_read_coef_idx(codec
, 0x17);
6515 if ((val
& 0x01c0) >> 6 != 0x4) {
6516 /* Class D power on reset */
6517 alc_write_coef_idx(codec
, 0x17, val
| (1<<7));
6521 val
= alc_read_coef_idx(codec
, 0xd); /* Class D */
6522 alc_write_coef_idx(codec
, 0xd, val
| (1<<14));
6524 val
= alc_read_coef_idx(codec
, 0x4); /* HP */
6525 alc_write_coef_idx(codec
, 0x4, val
| (1<<11));
6530 static int patch_alc269(struct hda_codec
*codec
)
6532 struct alc_spec
*spec
;
6535 err
= alc_alloc_spec(codec
, 0x0b);
6540 spec
->shared_mic_vref_pin
= 0x18;
6542 alc_pick_fixup(codec
, alc269_fixup_models
,
6543 alc269_fixup_tbl
, alc269_fixups
);
6544 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6546 alc_auto_parse_customize_define(codec
);
6548 switch (codec
->vendor_id
) {
6550 spec
->codec_variant
= ALC269_TYPE_ALC269VA
;
6551 switch (alc_get_coef0(codec
) & 0x00f0) {
6553 if (codec
->bus
->pci
->subsystem_vendor
== 0x1025 &&
6554 spec
->cdefine
.platform_type
== 1)
6555 err
= alc_codec_rename(codec
, "ALC271X");
6556 spec
->codec_variant
= ALC269_TYPE_ALC269VB
;
6559 if (codec
->bus
->pci
->subsystem_vendor
== 0x17aa &&
6560 codec
->bus
->pci
->subsystem_device
== 0x21f3)
6561 err
= alc_codec_rename(codec
, "ALC3202");
6562 spec
->codec_variant
= ALC269_TYPE_ALC269VC
;
6565 spec
->codec_variant
= ALC269_TYPE_ALC269VD
;
6568 alc_fix_pll_init(codec
, 0x20, 0x04, 15);
6572 spec
->init_hook
= alc269_fill_coef
;
6573 alc269_fill_coef(codec
);
6578 spec
->codec_variant
= ALC269_TYPE_ALC280
;
6582 spec
->codec_variant
= ALC269_TYPE_ALC282
;
6586 spec
->codec_variant
= ALC269_TYPE_ALC284
;
6590 /* automatic parse from the BIOS config */
6591 err
= alc269_parse_auto_config(codec
);
6595 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
6596 err
= snd_hda_attach_beep_device(codec
, 0x1);
6599 set_beep_amp(spec
, 0x0b, 0x04, HDA_INPUT
);
6602 codec
->patch_ops
= alc_patch_ops
;
6604 codec
->patch_ops
.resume
= alc269_resume
;
6606 spec
->shutup
= alc269_shutup
;
6608 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6621 static int alc861_parse_auto_config(struct hda_codec
*codec
)
6623 static const hda_nid_t alc861_ignore
[] = { 0x1d, 0 };
6624 static const hda_nid_t alc861_ssids
[] = { 0x0e, 0x0f, 0x0b, 0 };
6625 return alc_parse_auto_config(codec
, alc861_ignore
, alc861_ssids
);
6628 /* Pin config fixes */
6630 ALC861_FIXUP_FSC_AMILO_PI1505
,
6631 ALC861_FIXUP_AMP_VREF_0F
,
6632 ALC861_FIXUP_NO_JACK_DETECT
,
6633 ALC861_FIXUP_ASUS_A6RP
,
6636 /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
6637 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec
*codec
,
6638 const struct alc_fixup
*fix
, int action
)
6640 struct alc_spec
*spec
= codec
->spec
;
6643 if (action
!= ALC_FIXUP_ACT_INIT
)
6645 val
= snd_hda_codec_read(codec
, 0x0f, 0,
6646 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
6647 if (!(val
& (AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
)))
6648 val
|= AC_PINCTL_IN_EN
;
6649 val
|= AC_PINCTL_VREF_50
;
6650 snd_hda_set_pin_ctl(codec
, 0x0f, val
);
6651 spec
->keep_vref_in_automute
= 1;
6654 /* suppress the jack-detection */
6655 static void alc_fixup_no_jack_detect(struct hda_codec
*codec
,
6656 const struct alc_fixup
*fix
, int action
)
6658 if (action
== ALC_FIXUP_ACT_PRE_PROBE
)
6659 codec
->no_jack_detect
= 1;
6662 static const struct alc_fixup alc861_fixups
[] = {
6663 [ALC861_FIXUP_FSC_AMILO_PI1505
] = {
6664 .type
= ALC_FIXUP_PINS
,
6665 .v
.pins
= (const struct alc_pincfg
[]) {
6666 { 0x0b, 0x0221101f }, /* HP */
6667 { 0x0f, 0x90170310 }, /* speaker */
6671 [ALC861_FIXUP_AMP_VREF_0F
] = {
6672 .type
= ALC_FIXUP_FUNC
,
6673 .v
.func
= alc861_fixup_asus_amp_vref_0f
,
6675 [ALC861_FIXUP_NO_JACK_DETECT
] = {
6676 .type
= ALC_FIXUP_FUNC
,
6677 .v
.func
= alc_fixup_no_jack_detect
,
6679 [ALC861_FIXUP_ASUS_A6RP
] = {
6680 .type
= ALC_FIXUP_FUNC
,
6681 .v
.func
= alc861_fixup_asus_amp_vref_0f
,
6683 .chain_id
= ALC861_FIXUP_NO_JACK_DETECT
,
6687 static const struct snd_pci_quirk alc861_fixup_tbl
[] = {
6688 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP
),
6689 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F
),
6690 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT
),
6691 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F
),
6692 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F
),
6693 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505
),
6699 static int patch_alc861(struct hda_codec
*codec
)
6701 struct alc_spec
*spec
;
6704 err
= alc_alloc_spec(codec
, 0x15);
6710 alc_pick_fixup(codec
, NULL
, alc861_fixup_tbl
, alc861_fixups
);
6711 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6713 /* automatic parse from the BIOS config */
6714 err
= alc861_parse_auto_config(codec
);
6718 if (!spec
->no_analog
) {
6719 err
= snd_hda_attach_beep_device(codec
, 0x23);
6722 set_beep_amp(spec
, 0x23, 0, HDA_OUTPUT
);
6725 codec
->patch_ops
= alc_patch_ops
;
6727 spec
->power_hook
= alc_power_eapd
;
6730 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6744 * In addition, an independent DAC
6746 static int alc861vd_parse_auto_config(struct hda_codec
*codec
)
6748 static const hda_nid_t alc861vd_ignore
[] = { 0x1d, 0 };
6749 static const hda_nid_t alc861vd_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
6750 return alc_parse_auto_config(codec
, alc861vd_ignore
, alc861vd_ssids
);
6754 ALC660VD_FIX_ASUS_GPIO1
,
6755 ALC861VD_FIX_DALLAS
,
6758 /* exclude VREF80 */
6759 static void alc861vd_fixup_dallas(struct hda_codec
*codec
,
6760 const struct alc_fixup
*fix
, int action
)
6762 if (action
== ALC_FIXUP_ACT_PRE_PROBE
) {
6763 snd_hda_override_pin_caps(codec
, 0x18, 0x00000734);
6764 snd_hda_override_pin_caps(codec
, 0x19, 0x0000073c);
6768 static const struct alc_fixup alc861vd_fixups
[] = {
6769 [ALC660VD_FIX_ASUS_GPIO1
] = {
6770 .type
= ALC_FIXUP_VERBS
,
6771 .v
.verbs
= (const struct hda_verb
[]) {
6773 {0x01, AC_VERB_SET_GPIO_MASK
, 0x03},
6774 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
6775 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
6779 [ALC861VD_FIX_DALLAS
] = {
6780 .type
= ALC_FIXUP_FUNC
,
6781 .v
.func
= alc861vd_fixup_dallas
,
6785 static const struct snd_pci_quirk alc861vd_fixup_tbl
[] = {
6786 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS
),
6787 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1
),
6788 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS
),
6794 static int patch_alc861vd(struct hda_codec
*codec
)
6796 struct alc_spec
*spec
;
6799 err
= alc_alloc_spec(codec
, 0x0b);
6805 alc_pick_fixup(codec
, NULL
, alc861vd_fixup_tbl
, alc861vd_fixups
);
6806 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6808 /* automatic parse from the BIOS config */
6809 err
= alc861vd_parse_auto_config(codec
);
6813 if (!spec
->no_analog
) {
6814 err
= snd_hda_attach_beep_device(codec
, 0x23);
6817 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
6820 codec
->patch_ops
= alc_patch_ops
;
6822 spec
->shutup
= alc_eapd_shutup
;
6824 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6836 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
6837 * configuration. Each pin widget can choose any input DACs and a mixer.
6838 * Each ADC is connected from a mixer of all inputs. This makes possible
6839 * 6-channel independent captures.
6841 * In addition, an independent DAC for the multi-playback (not used in this
6846 * BIOS auto configuration
6849 static int alc662_parse_auto_config(struct hda_codec
*codec
)
6851 static const hda_nid_t alc662_ignore
[] = { 0x1d, 0 };
6852 static const hda_nid_t alc663_ssids
[] = { 0x15, 0x1b, 0x14, 0x21 };
6853 static const hda_nid_t alc662_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
6854 const hda_nid_t
*ssids
;
6856 if (codec
->vendor_id
== 0x10ec0272 || codec
->vendor_id
== 0x10ec0663 ||
6857 codec
->vendor_id
== 0x10ec0665 || codec
->vendor_id
== 0x10ec0670)
6858 ssids
= alc663_ssids
;
6860 ssids
= alc662_ssids
;
6861 return alc_parse_auto_config(codec
, alc662_ignore
, ssids
);
6864 static void alc272_fixup_mario(struct hda_codec
*codec
,
6865 const struct alc_fixup
*fix
, int action
)
6867 if (action
!= ALC_FIXUP_ACT_PROBE
)
6869 if (snd_hda_override_amp_caps(codec
, 0x2, HDA_OUTPUT
,
6870 (0x3b << AC_AMPCAP_OFFSET_SHIFT
) |
6871 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT
) |
6872 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
6873 (0 << AC_AMPCAP_MUTE_SHIFT
)))
6875 "hda_codec: failed to override amp caps for NID 0x2\n");
6879 ALC662_FIXUP_ASPIRE
,
6880 ALC662_FIXUP_IDEAPAD
,
6882 ALC662_FIXUP_CZC_P10T
,
6883 ALC662_FIXUP_SKU_IGNORE
,
6884 ALC662_FIXUP_HP_RP5800
,
6885 ALC662_FIXUP_ASUS_MODE1
,
6886 ALC662_FIXUP_ASUS_MODE2
,
6887 ALC662_FIXUP_ASUS_MODE3
,
6888 ALC662_FIXUP_ASUS_MODE4
,
6889 ALC662_FIXUP_ASUS_MODE5
,
6890 ALC662_FIXUP_ASUS_MODE6
,
6891 ALC662_FIXUP_ASUS_MODE7
,
6892 ALC662_FIXUP_ASUS_MODE8
,
6893 ALC662_FIXUP_NO_JACK_DETECT
,
6894 ALC662_FIXUP_ZOTAC_Z68
,
6895 ALC662_FIXUP_INV_DMIC
,
6898 static const struct alc_fixup alc662_fixups
[] = {
6899 [ALC662_FIXUP_ASPIRE
] = {
6900 .type
= ALC_FIXUP_PINS
,
6901 .v
.pins
= (const struct alc_pincfg
[]) {
6902 { 0x15, 0x99130112 }, /* subwoofer */
6906 [ALC662_FIXUP_IDEAPAD
] = {
6907 .type
= ALC_FIXUP_PINS
,
6908 .v
.pins
= (const struct alc_pincfg
[]) {
6909 { 0x17, 0x99130112 }, /* subwoofer */
6913 [ALC272_FIXUP_MARIO
] = {
6914 .type
= ALC_FIXUP_FUNC
,
6915 .v
.func
= alc272_fixup_mario
,
6917 [ALC662_FIXUP_CZC_P10T
] = {
6918 .type
= ALC_FIXUP_VERBS
,
6919 .v
.verbs
= (const struct hda_verb
[]) {
6920 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 0},
6924 [ALC662_FIXUP_SKU_IGNORE
] = {
6925 .type
= ALC_FIXUP_FUNC
,
6926 .v
.func
= alc_fixup_sku_ignore
,
6928 [ALC662_FIXUP_HP_RP5800
] = {
6929 .type
= ALC_FIXUP_PINS
,
6930 .v
.pins
= (const struct alc_pincfg
[]) {
6931 { 0x14, 0x0221201f }, /* HP out */
6935 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6937 [ALC662_FIXUP_ASUS_MODE1
] = {
6938 .type
= ALC_FIXUP_PINS
,
6939 .v
.pins
= (const struct alc_pincfg
[]) {
6940 { 0x14, 0x99130110 }, /* speaker */
6941 { 0x18, 0x01a19c20 }, /* mic */
6942 { 0x19, 0x99a3092f }, /* int-mic */
6943 { 0x21, 0x0121401f }, /* HP out */
6947 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6949 [ALC662_FIXUP_ASUS_MODE2
] = {
6950 .type
= ALC_FIXUP_PINS
,
6951 .v
.pins
= (const struct alc_pincfg
[]) {
6952 { 0x14, 0x99130110 }, /* speaker */
6953 { 0x18, 0x01a19820 }, /* mic */
6954 { 0x19, 0x99a3092f }, /* int-mic */
6955 { 0x1b, 0x0121401f }, /* HP out */
6959 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6961 [ALC662_FIXUP_ASUS_MODE3
] = {
6962 .type
= ALC_FIXUP_PINS
,
6963 .v
.pins
= (const struct alc_pincfg
[]) {
6964 { 0x14, 0x99130110 }, /* speaker */
6965 { 0x15, 0x0121441f }, /* HP */
6966 { 0x18, 0x01a19840 }, /* mic */
6967 { 0x19, 0x99a3094f }, /* int-mic */
6968 { 0x21, 0x01211420 }, /* HP2 */
6972 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6974 [ALC662_FIXUP_ASUS_MODE4
] = {
6975 .type
= ALC_FIXUP_PINS
,
6976 .v
.pins
= (const struct alc_pincfg
[]) {
6977 { 0x14, 0x99130110 }, /* speaker */
6978 { 0x16, 0x99130111 }, /* speaker */
6979 { 0x18, 0x01a19840 }, /* mic */
6980 { 0x19, 0x99a3094f }, /* int-mic */
6981 { 0x21, 0x0121441f }, /* HP */
6985 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6987 [ALC662_FIXUP_ASUS_MODE5
] = {
6988 .type
= ALC_FIXUP_PINS
,
6989 .v
.pins
= (const struct alc_pincfg
[]) {
6990 { 0x14, 0x99130110 }, /* speaker */
6991 { 0x15, 0x0121441f }, /* HP */
6992 { 0x16, 0x99130111 }, /* speaker */
6993 { 0x18, 0x01a19840 }, /* mic */
6994 { 0x19, 0x99a3094f }, /* int-mic */
6998 .chain_id
= ALC662_FIXUP_SKU_IGNORE
7000 [ALC662_FIXUP_ASUS_MODE6
] = {
7001 .type
= ALC_FIXUP_PINS
,
7002 .v
.pins
= (const struct alc_pincfg
[]) {
7003 { 0x14, 0x99130110 }, /* speaker */
7004 { 0x15, 0x01211420 }, /* HP2 */
7005 { 0x18, 0x01a19840 }, /* mic */
7006 { 0x19, 0x99a3094f }, /* int-mic */
7007 { 0x1b, 0x0121441f }, /* HP */
7011 .chain_id
= ALC662_FIXUP_SKU_IGNORE
7013 [ALC662_FIXUP_ASUS_MODE7
] = {
7014 .type
= ALC_FIXUP_PINS
,
7015 .v
.pins
= (const struct alc_pincfg
[]) {
7016 { 0x14, 0x99130110 }, /* speaker */
7017 { 0x17, 0x99130111 }, /* speaker */
7018 { 0x18, 0x01a19840 }, /* mic */
7019 { 0x19, 0x99a3094f }, /* int-mic */
7020 { 0x1b, 0x01214020 }, /* HP */
7021 { 0x21, 0x0121401f }, /* HP */
7025 .chain_id
= ALC662_FIXUP_SKU_IGNORE
7027 [ALC662_FIXUP_ASUS_MODE8
] = {
7028 .type
= ALC_FIXUP_PINS
,
7029 .v
.pins
= (const struct alc_pincfg
[]) {
7030 { 0x14, 0x99130110 }, /* speaker */
7031 { 0x12, 0x99a30970 }, /* int-mic */
7032 { 0x15, 0x01214020 }, /* HP */
7033 { 0x17, 0x99130111 }, /* speaker */
7034 { 0x18, 0x01a19840 }, /* mic */
7035 { 0x21, 0x0121401f }, /* HP */
7039 .chain_id
= ALC662_FIXUP_SKU_IGNORE
7041 [ALC662_FIXUP_NO_JACK_DETECT
] = {
7042 .type
= ALC_FIXUP_FUNC
,
7043 .v
.func
= alc_fixup_no_jack_detect
,
7045 [ALC662_FIXUP_ZOTAC_Z68
] = {
7046 .type
= ALC_FIXUP_PINS
,
7047 .v
.pins
= (const struct alc_pincfg
[]) {
7048 { 0x1b, 0x02214020 }, /* Front HP */
7052 [ALC662_FIXUP_INV_DMIC
] = {
7053 .type
= ALC_FIXUP_FUNC
,
7054 .v
.func
= alc_fixup_inv_dmic_0x12
,
7058 static const struct snd_pci_quirk alc662_fixup_tbl
[] = {
7059 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2
),
7060 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE
),
7061 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE
),
7062 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC
),
7063 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE
),
7064 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800
),
7065 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT
),
7066 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2
),
7067 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD
),
7068 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD
),
7069 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD
),
7070 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68
),
7071 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T
),
7074 /* Below is a quirk table taken from the old code.
7075 * Basically the device should work as is without the fixup table.
7076 * If BIOS doesn't give a proper info, enable the corresponding
7079 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1
),
7080 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3
),
7081 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1
),
7082 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3
),
7083 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
7084 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
7085 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
7086 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1
),
7087 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1
),
7088 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
7089 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7
),
7090 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7
),
7091 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8
),
7092 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3
),
7093 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1
),
7094 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
7095 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2
),
7096 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1
),
7097 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
7098 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
7099 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
7100 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
7101 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1
),
7102 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3
),
7103 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2
),
7104 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
7105 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5
),
7106 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
7107 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
7108 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1
),
7109 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
7110 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
7111 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3
),
7112 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3
),
7113 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1
),
7114 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1
),
7115 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1
),
7116 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1
),
7117 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1
),
7118 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
7119 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2
),
7120 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1
),
7121 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
7122 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3
),
7123 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1
),
7124 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1
),
7125 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1
),
7126 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2
),
7127 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
7128 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4
),
7133 static const struct alc_model_fixup alc662_fixup_models
[] = {
7134 {.id
= ALC272_FIXUP_MARIO
, .name
= "mario"},
7135 {.id
= ALC662_FIXUP_ASUS_MODE1
, .name
= "asus-mode1"},
7136 {.id
= ALC662_FIXUP_ASUS_MODE2
, .name
= "asus-mode2"},
7137 {.id
= ALC662_FIXUP_ASUS_MODE3
, .name
= "asus-mode3"},
7138 {.id
= ALC662_FIXUP_ASUS_MODE4
, .name
= "asus-mode4"},
7139 {.id
= ALC662_FIXUP_ASUS_MODE5
, .name
= "asus-mode5"},
7140 {.id
= ALC662_FIXUP_ASUS_MODE6
, .name
= "asus-mode6"},
7141 {.id
= ALC662_FIXUP_ASUS_MODE7
, .name
= "asus-mode7"},
7142 {.id
= ALC662_FIXUP_ASUS_MODE8
, .name
= "asus-mode8"},
7143 {.id
= ALC662_FIXUP_INV_DMIC
, .name
= "inv-dmic"},
7147 static void alc662_fill_coef(struct hda_codec
*codec
)
7151 coef
= alc_get_coef0(codec
);
7153 switch (codec
->vendor_id
) {
7155 if ((coef
& 0x00f0) == 0x0030) {
7156 val
= alc_read_coef_idx(codec
, 0x4); /* EAPD Ctrl */
7157 alc_write_coef_idx(codec
, 0x4, val
& ~(1<<10));
7167 val
= alc_read_coef_idx(codec
, 0xd); /* EAPD Ctrl */
7168 alc_write_coef_idx(codec
, 0xd, val
| (1<<14));
7175 static int patch_alc662(struct hda_codec
*codec
)
7177 struct alc_spec
*spec
;
7180 err
= alc_alloc_spec(codec
, 0x0b);
7186 /* handle multiple HPs as is */
7187 spec
->parse_flags
= HDA_PINCFG_NO_HP_FIXUP
;
7189 alc_fix_pll_init(codec
, 0x20, 0x04, 15);
7191 spec
->init_hook
= alc662_fill_coef
;
7192 alc662_fill_coef(codec
);
7194 alc_pick_fixup(codec
, alc662_fixup_models
,
7195 alc662_fixup_tbl
, alc662_fixups
);
7196 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
7198 alc_auto_parse_customize_define(codec
);
7200 if ((alc_get_coef0(codec
) & (1 << 14)) &&
7201 codec
->bus
->pci
->subsystem_vendor
== 0x1025 &&
7202 spec
->cdefine
.platform_type
== 1) {
7203 if (alc_codec_rename(codec
, "ALC272X") < 0)
7207 /* automatic parse from the BIOS config */
7208 err
= alc662_parse_auto_config(codec
);
7212 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
7213 err
= snd_hda_attach_beep_device(codec
, 0x1);
7216 switch (codec
->vendor_id
) {
7218 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
7223 set_beep_amp(spec
, 0x0b, 0x04, HDA_INPUT
);
7226 set_beep_amp(spec
, 0x0b, 0x03, HDA_INPUT
);
7231 codec
->patch_ops
= alc_patch_ops
;
7232 spec
->shutup
= alc_eapd_shutup
;
7234 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
7247 static int alc680_parse_auto_config(struct hda_codec
*codec
)
7249 return alc_parse_auto_config(codec
, NULL
, NULL
);
7254 static int patch_alc680(struct hda_codec
*codec
)
7258 /* ALC680 has no aa-loopback mixer */
7259 err
= alc_alloc_spec(codec
, 0);
7263 /* automatic parse from the BIOS config */
7264 err
= alc680_parse_auto_config(codec
);
7270 codec
->patch_ops
= alc_patch_ops
;
7278 static const struct hda_codec_preset snd_hda_preset_realtek
[] = {
7279 { .id
= 0x10ec0221, .name
= "ALC221", .patch
= patch_alc269
},
7280 { .id
= 0x10ec0260, .name
= "ALC260", .patch
= patch_alc260
},
7281 { .id
= 0x10ec0262, .name
= "ALC262", .patch
= patch_alc262
},
7282 { .id
= 0x10ec0267, .name
= "ALC267", .patch
= patch_alc268
},
7283 { .id
= 0x10ec0268, .name
= "ALC268", .patch
= patch_alc268
},
7284 { .id
= 0x10ec0269, .name
= "ALC269", .patch
= patch_alc269
},
7285 { .id
= 0x10ec0270, .name
= "ALC270", .patch
= patch_alc269
},
7286 { .id
= 0x10ec0272, .name
= "ALC272", .patch
= patch_alc662
},
7287 { .id
= 0x10ec0275, .name
= "ALC275", .patch
= patch_alc269
},
7288 { .id
= 0x10ec0276, .name
= "ALC276", .patch
= patch_alc269
},
7289 { .id
= 0x10ec0280, .name
= "ALC280", .patch
= patch_alc269
},
7290 { .id
= 0x10ec0282, .name
= "ALC282", .patch
= patch_alc269
},
7291 { .id
= 0x10ec0283, .name
= "ALC283", .patch
= patch_alc269
},
7292 { .id
= 0x10ec0284, .name
= "ALC284", .patch
= patch_alc269
},
7293 { .id
= 0x10ec0290, .name
= "ALC290", .patch
= patch_alc269
},
7294 { .id
= 0x10ec0292, .name
= "ALC292", .patch
= patch_alc269
},
7295 { .id
= 0x10ec0861, .rev
= 0x100340, .name
= "ALC660",
7296 .patch
= patch_alc861
},
7297 { .id
= 0x10ec0660, .name
= "ALC660-VD", .patch
= patch_alc861vd
},
7298 { .id
= 0x10ec0861, .name
= "ALC861", .patch
= patch_alc861
},
7299 { .id
= 0x10ec0862, .name
= "ALC861-VD", .patch
= patch_alc861vd
},
7300 { .id
= 0x10ec0662, .rev
= 0x100002, .name
= "ALC662 rev2",
7301 .patch
= patch_alc882
},
7302 { .id
= 0x10ec0662, .rev
= 0x100101, .name
= "ALC662 rev1",
7303 .patch
= patch_alc662
},
7304 { .id
= 0x10ec0662, .rev
= 0x100300, .name
= "ALC662 rev3",
7305 .patch
= patch_alc662
},
7306 { .id
= 0x10ec0663, .name
= "ALC663", .patch
= patch_alc662
},
7307 { .id
= 0x10ec0665, .name
= "ALC665", .patch
= patch_alc662
},
7308 { .id
= 0x10ec0668, .name
= "ALC668", .patch
= patch_alc662
},
7309 { .id
= 0x10ec0670, .name
= "ALC670", .patch
= patch_alc662
},
7310 { .id
= 0x10ec0680, .name
= "ALC680", .patch
= patch_alc680
},
7311 { .id
= 0x10ec0880, .name
= "ALC880", .patch
= patch_alc880
},
7312 { .id
= 0x10ec0882, .name
= "ALC882", .patch
= patch_alc882
},
7313 { .id
= 0x10ec0883, .name
= "ALC883", .patch
= patch_alc882
},
7314 { .id
= 0x10ec0885, .rev
= 0x100101, .name
= "ALC889A",
7315 .patch
= patch_alc882
},
7316 { .id
= 0x10ec0885, .rev
= 0x100103, .name
= "ALC889A",
7317 .patch
= patch_alc882
},
7318 { .id
= 0x10ec0885, .name
= "ALC885", .patch
= patch_alc882
},
7319 { .id
= 0x10ec0887, .name
= "ALC887", .patch
= patch_alc882
},
7320 { .id
= 0x10ec0888, .rev
= 0x100101, .name
= "ALC1200",
7321 .patch
= patch_alc882
},
7322 { .id
= 0x10ec0888, .name
= "ALC888", .patch
= patch_alc882
},
7323 { .id
= 0x10ec0889, .name
= "ALC889", .patch
= patch_alc882
},
7324 { .id
= 0x10ec0892, .name
= "ALC892", .patch
= patch_alc662
},
7325 { .id
= 0x10ec0899, .name
= "ALC898", .patch
= patch_alc882
},
7326 { .id
= 0x10ec0900, .name
= "ALC1150", .patch
= patch_alc882
},
7330 MODULE_ALIAS("snd-hda-codec-id:10ec*");
7332 MODULE_LICENSE("GPL");
7333 MODULE_DESCRIPTION("Realtek HD-audio codec");
7335 static struct hda_codec_preset_list realtek_list
= {
7336 .preset
= snd_hda_preset_realtek
,
7337 .owner
= THIS_MODULE
,
7340 static int __init
patch_realtek_init(void)
7342 return snd_hda_add_codec_preset(&realtek_list
);
7345 static void __exit
patch_realtek_exit(void)
7347 snd_hda_delete_codec_preset(&realtek_list
);
7350 module_init(patch_realtek_init
)
7351 module_exit(patch_realtek_exit
)