2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for Realtek ALC codecs
6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
8 * Takashi Iwai <tiwai@suse.de>
9 * Jonathan Woithe <jwoithe@just42.net>
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <linux/module.h>
31 #include <sound/core.h>
32 #include <sound/jack.h>
33 #include "hda_codec.h"
34 #include "hda_local.h"
35 #include "hda_auto_parser.h"
39 /* unsol event tags */
40 #define ALC_FRONT_EVENT 0x01
41 #define ALC_DCVOL_EVENT 0x02
42 #define ALC_HP_EVENT 0x04
43 #define ALC_MIC_EVENT 0x08
46 #define GPIO_MASK 0x03
48 /* extra amp-initialization sequence types */
57 struct alc_customize_define
{
59 unsigned char port_connectivity
;
60 unsigned char check_sum
;
61 unsigned char customization
;
62 unsigned char external_amp
;
63 unsigned int enable_pcbeep
:1;
64 unsigned int platform_type
:1;
66 unsigned int override
:1;
67 unsigned int fixup
:1; /* Means that this sku is set by driver, not read from hw */
71 hda_nid_t pin
; /* multi-io widget pin NID */
72 hda_nid_t dac
; /* DAC to be connected */
73 unsigned int ctl_in
; /* cached input-pin control value */
77 ALC_AUTOMUTE_PIN
, /* change the pin control */
78 ALC_AUTOMUTE_AMP
, /* mute/unmute the pin AMP */
79 ALC_AUTOMUTE_MIXER
, /* mute/unmute mixer widget AMP */
82 #define MAX_VOL_NIDS 0x40
84 /* make compatible with old code */
85 #define alc_apply_pincfgs snd_hda_apply_pincfgs
86 #define alc_apply_fixup snd_hda_apply_fixup
87 #define alc_pick_fixup snd_hda_pick_fixup
88 #define alc_fixup hda_fixup
89 #define alc_pincfg hda_pintbl
90 #define alc_model_fixup hda_model_fixup
92 #define ALC_FIXUP_PINS HDA_FIXUP_PINS
93 #define ALC_FIXUP_VERBS HDA_FIXUP_VERBS
94 #define ALC_FIXUP_FUNC HDA_FIXUP_FUNC
96 #define ALC_FIXUP_ACT_PRE_PROBE HDA_FIXUP_ACT_PRE_PROBE
97 #define ALC_FIXUP_ACT_PROBE HDA_FIXUP_ACT_PROBE
98 #define ALC_FIXUP_ACT_INIT HDA_FIXUP_ACT_INIT
99 #define ALC_FIXUP_ACT_BUILD HDA_FIXUP_ACT_BUILD
103 struct hda_gen_spec gen
;
105 /* codec parameterization */
106 const struct snd_kcontrol_new
*mixers
[5]; /* mixer arrays */
107 unsigned int num_mixers
;
108 const struct snd_kcontrol_new
*cap_mixer
; /* capture mixer */
109 unsigned int beep_amp
; /* beep amp value, set via set_beep_amp() */
111 char stream_name_analog
[32]; /* analog PCM stream */
112 const struct hda_pcm_stream
*stream_analog_playback
;
113 const struct hda_pcm_stream
*stream_analog_capture
;
114 const struct hda_pcm_stream
*stream_analog_alt_playback
;
115 const struct hda_pcm_stream
*stream_analog_alt_capture
;
117 char stream_name_digital
[32]; /* digital PCM stream */
118 const struct hda_pcm_stream
*stream_digital_playback
;
119 const struct hda_pcm_stream
*stream_digital_capture
;
122 struct hda_multi_out multiout
; /* playback set-up
123 * max_channels, dacs must be set
124 * dig_out_nid and hp_nid are optional
126 hda_nid_t alt_dac_nid
;
127 hda_nid_t slave_dig_outs
[3]; /* optional - for auto-parsing */
131 unsigned int num_adc_nids
;
132 const hda_nid_t
*adc_nids
;
133 const hda_nid_t
*capsrc_nids
;
134 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
135 hda_nid_t mixer_nid
; /* analog-mixer NID */
136 DECLARE_BITMAP(vol_ctls
, MAX_VOL_NIDS
<< 1);
137 DECLARE_BITMAP(sw_ctls
, MAX_VOL_NIDS
<< 1);
139 /* capture setup for dynamic dual-adc switch */
141 unsigned int cur_adc_stream_tag
;
142 unsigned int cur_adc_format
;
145 unsigned int num_mux_defs
;
146 const struct hda_input_mux
*input_mux
;
147 unsigned int cur_mux
[3];
148 hda_nid_t ext_mic_pin
;
149 hda_nid_t dock_mic_pin
;
150 hda_nid_t int_mic_pin
;
153 const struct hda_channel_mode
*channel_mode
;
154 int num_channel_mode
;
156 int const_channel_count
;
157 int ext_channel_count
;
159 /* PCM information */
160 struct hda_pcm pcm_rec
[3]; /* used in alc_build_pcms() */
162 /* dynamic controls, init_verbs and input_mux */
163 struct auto_pin_cfg autocfg
;
164 struct alc_customize_define cdefine
;
165 struct snd_array kctls
;
166 struct hda_input_mux private_imux
[3];
167 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
168 hda_nid_t private_adc_nids
[AUTO_CFG_MAX_OUTS
];
169 hda_nid_t private_capsrc_nids
[AUTO_CFG_MAX_OUTS
];
170 hda_nid_t imux_pins
[HDA_MAX_NUM_INPUTS
];
171 unsigned int dyn_adc_idx
[HDA_MAX_NUM_INPUTS
];
172 int int_mic_idx
, ext_mic_idx
, dock_mic_idx
; /* for auto-mic */
173 hda_nid_t inv_dmic_pin
;
176 void (*init_hook
)(struct hda_codec
*codec
);
177 #ifdef CONFIG_SND_HDA_POWER_SAVE
178 void (*power_hook
)(struct hda_codec
*codec
);
180 void (*shutup
)(struct hda_codec
*codec
);
181 void (*automute_hook
)(struct hda_codec
*codec
);
183 /* for pin sensing */
184 unsigned int hp_jack_present
:1;
185 unsigned int line_jack_present
:1;
186 unsigned int master_mute
:1;
187 unsigned int auto_mic
:1;
188 unsigned int auto_mic_valid_imux
:1; /* valid imux for auto-mic */
189 unsigned int automute_speaker
:1; /* automute speaker outputs */
190 unsigned int automute_lo
:1; /* automute LO outputs */
191 unsigned int detect_hp
:1; /* Headphone detection enabled */
192 unsigned int detect_lo
:1; /* Line-out detection enabled */
193 unsigned int automute_speaker_possible
:1; /* there are speakers and either LO or HP */
194 unsigned int automute_lo_possible
:1; /* there are line outs and HP */
195 unsigned int keep_vref_in_automute
:1; /* Don't clear VREF in automute */
198 unsigned int no_analog
:1; /* digital I/O only */
199 unsigned int dyn_adc_switch
:1; /* switch ADCs (for ALC275) */
200 unsigned int single_input_src
:1;
201 unsigned int vol_in_capsrc
:1; /* use capsrc volume (ADC has no vol) */
202 unsigned int parse_flags
; /* passed to snd_hda_parse_pin_defcfg() */
203 unsigned int shared_mic_hp
:1; /* HP/Mic-in sharing */
204 unsigned int inv_dmic_fixup
:1; /* has inverted digital-mic workaround */
205 unsigned int inv_dmic_muted
:1; /* R-ch of inv d-mic is muted? */
207 /* auto-mute control */
209 hda_nid_t automute_mixer_nid
[AUTO_CFG_MAX_OUTS
];
212 int codec_variant
; /* flag for other variants */
214 /* for virtual master */
215 hda_nid_t vmaster_nid
;
216 struct hda_vmaster_mute_hook vmaster_mute
;
217 #ifdef CONFIG_SND_HDA_POWER_SAVE
218 struct hda_loopback_check loopback
;
220 struct hda_amp_list loopback_list
[8];
225 unsigned int pll_coef_idx
, pll_coef_bit
;
230 struct alc_multi_io multi_io
[4];
233 struct snd_array bind_ctls
;
236 static bool check_amp_caps(struct hda_codec
*codec
, hda_nid_t nid
,
237 int dir
, unsigned int bits
)
241 if (get_wcaps(codec
, nid
) & (1 << (dir
+ 1)))
242 if (query_amp_caps(codec
, nid
, dir
) & bits
)
247 #define nid_has_mute(codec, nid, dir) \
248 check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE)
249 #define nid_has_volume(codec, nid, dir) \
250 check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS)
255 static int alc_mux_enum_info(struct snd_kcontrol
*kcontrol
,
256 struct snd_ctl_elem_info
*uinfo
)
258 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
259 struct alc_spec
*spec
= codec
->spec
;
260 unsigned int mux_idx
= snd_ctl_get_ioffidx(kcontrol
, &uinfo
->id
);
261 if (mux_idx
>= spec
->num_mux_defs
)
263 if (!spec
->input_mux
[mux_idx
].num_items
&& mux_idx
> 0)
265 return snd_hda_input_mux_info(&spec
->input_mux
[mux_idx
], uinfo
);
268 static int alc_mux_enum_get(struct snd_kcontrol
*kcontrol
,
269 struct snd_ctl_elem_value
*ucontrol
)
271 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
272 struct alc_spec
*spec
= codec
->spec
;
273 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
275 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
279 static bool alc_dyn_adc_pcm_resetup(struct hda_codec
*codec
, int cur
)
281 struct alc_spec
*spec
= codec
->spec
;
282 hda_nid_t new_adc
= spec
->adc_nids
[spec
->dyn_adc_idx
[cur
]];
284 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
285 /* stream is running, let's swap the current ADC */
286 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
287 spec
->cur_adc
= new_adc
;
288 snd_hda_codec_setup_stream(codec
, new_adc
,
289 spec
->cur_adc_stream_tag
, 0,
290 spec
->cur_adc_format
);
296 static inline hda_nid_t
get_capsrc(struct alc_spec
*spec
, int idx
)
298 return spec
->capsrc_nids
?
299 spec
->capsrc_nids
[idx
] : spec
->adc_nids
[idx
];
302 static void call_update_outputs(struct hda_codec
*codec
);
303 static void alc_inv_dmic_sync(struct hda_codec
*codec
, bool force
);
305 /* for shared I/O, change the pin-control accordingly */
306 static void update_shared_mic_hp(struct hda_codec
*codec
, bool set_as_mic
)
308 struct alc_spec
*spec
= codec
->spec
;
310 hda_nid_t pin
= spec
->autocfg
.inputs
[1].pin
;
311 /* NOTE: this assumes that there are only two inputs, the
312 * first is the real internal mic and the second is HP/mic jack.
315 val
= snd_hda_get_default_vref(codec
, pin
);
317 /* This pin does not have vref caps - let's enable vref on pin 0x18
318 instead, as suggested by Realtek */
319 if (val
== AC_PINCTL_VREF_HIZ
) {
320 const hda_nid_t vref_pin
= 0x18;
321 /* Sanity check pin 0x18 */
322 if (get_wcaps_type(get_wcaps(codec
, vref_pin
)) == AC_WID_PIN
&&
323 get_defcfg_connect(snd_hda_codec_get_pincfg(codec
, vref_pin
)) == AC_JACK_PORT_NONE
) {
324 unsigned int vref_val
= snd_hda_get_default_vref(codec
, vref_pin
);
325 if (vref_val
!= AC_PINCTL_VREF_HIZ
)
326 snd_hda_set_pin_ctl(codec
, vref_pin
, PIN_IN
| (set_as_mic
? vref_val
: 0));
330 val
= set_as_mic
? val
| PIN_IN
: PIN_HP
;
331 snd_hda_set_pin_ctl(codec
, pin
, val
);
333 spec
->automute_speaker
= !set_as_mic
;
334 call_update_outputs(codec
);
337 /* select the given imux item; either unmute exclusively or select the route */
338 static int alc_mux_select(struct hda_codec
*codec
, unsigned int adc_idx
,
339 unsigned int idx
, bool force
)
341 struct alc_spec
*spec
= codec
->spec
;
342 const struct hda_input_mux
*imux
;
343 unsigned int mux_idx
;
344 int i
, type
, num_conns
;
347 if (!spec
->input_mux
)
350 mux_idx
= adc_idx
>= spec
->num_mux_defs
? 0 : adc_idx
;
351 imux
= &spec
->input_mux
[mux_idx
];
352 if (!imux
->num_items
&& mux_idx
> 0)
353 imux
= &spec
->input_mux
[0];
354 if (!imux
->num_items
)
357 if (idx
>= imux
->num_items
)
358 idx
= imux
->num_items
- 1;
359 if (spec
->cur_mux
[adc_idx
] == idx
&& !force
)
361 spec
->cur_mux
[adc_idx
] = idx
;
363 if (spec
->shared_mic_hp
)
364 update_shared_mic_hp(codec
, spec
->cur_mux
[adc_idx
]);
366 if (spec
->dyn_adc_switch
) {
367 alc_dyn_adc_pcm_resetup(codec
, idx
);
368 adc_idx
= spec
->dyn_adc_idx
[idx
];
371 nid
= get_capsrc(spec
, adc_idx
);
374 num_conns
= snd_hda_get_num_conns(codec
, nid
);
378 type
= get_wcaps_type(get_wcaps(codec
, nid
));
379 if (type
== AC_WID_AUD_MIX
) {
380 /* Matrix-mixer style (e.g. ALC882) */
381 int active
= imux
->items
[idx
].index
;
382 for (i
= 0; i
< num_conns
; i
++) {
383 unsigned int v
= (i
== active
) ? 0 : HDA_AMP_MUTE
;
384 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, i
,
388 /* MUX style (e.g. ALC880) */
389 snd_hda_codec_write_cache(codec
, nid
, 0,
390 AC_VERB_SET_CONNECT_SEL
,
391 imux
->items
[idx
].index
);
393 alc_inv_dmic_sync(codec
, true);
397 static int alc_mux_enum_put(struct snd_kcontrol
*kcontrol
,
398 struct snd_ctl_elem_value
*ucontrol
)
400 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
401 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
402 return alc_mux_select(codec
, adc_idx
,
403 ucontrol
->value
.enumerated
.item
[0], false);
407 * set up the input pin config (depending on the given auto-pin type)
409 static void alc_set_input_pin(struct hda_codec
*codec
, hda_nid_t nid
,
412 unsigned int val
= PIN_IN
;
413 if (auto_pin_type
== AUTO_PIN_MIC
)
414 val
|= snd_hda_get_default_vref(codec
, nid
);
415 snd_hda_set_pin_ctl(codec
, nid
, val
);
419 * Append the given mixer and verb elements for the later use
420 * The mixer array is referred in build_controls(), and init_verbs are
423 static void add_mixer(struct alc_spec
*spec
, const struct snd_kcontrol_new
*mix
)
425 if (snd_BUG_ON(spec
->num_mixers
>= ARRAY_SIZE(spec
->mixers
)))
427 spec
->mixers
[spec
->num_mixers
++] = mix
;
431 * GPIO setup tables, used in initialization
433 /* Enable GPIO mask and set output */
434 static const struct hda_verb alc_gpio1_init_verbs
[] = {
435 {0x01, AC_VERB_SET_GPIO_MASK
, 0x01},
436 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
437 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
441 static const struct hda_verb alc_gpio2_init_verbs
[] = {
442 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
443 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
444 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02},
448 static const struct hda_verb alc_gpio3_init_verbs
[] = {
449 {0x01, AC_VERB_SET_GPIO_MASK
, 0x03},
450 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x03},
451 {0x01, AC_VERB_SET_GPIO_DATA
, 0x03},
456 * Fix hardware PLL issue
457 * On some codecs, the analog PLL gating control must be off while
458 * the default value is 1.
460 static void alc_fix_pll(struct hda_codec
*codec
)
462 struct alc_spec
*spec
= codec
->spec
;
467 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_COEF_INDEX
,
469 val
= snd_hda_codec_read(codec
, spec
->pll_nid
, 0,
470 AC_VERB_GET_PROC_COEF
, 0);
471 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_COEF_INDEX
,
473 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_PROC_COEF
,
474 val
& ~(1 << spec
->pll_coef_bit
));
477 static void alc_fix_pll_init(struct hda_codec
*codec
, hda_nid_t nid
,
478 unsigned int coef_idx
, unsigned int coef_bit
)
480 struct alc_spec
*spec
= codec
->spec
;
482 spec
->pll_coef_idx
= coef_idx
;
483 spec
->pll_coef_bit
= coef_bit
;
488 * Jack detections for HP auto-mute and mic-switch
491 /* check each pin in the given array; returns true if any of them is plugged */
492 static bool detect_jacks(struct hda_codec
*codec
, int num_pins
, hda_nid_t
*pins
)
496 for (i
= 0; i
< num_pins
; i
++) {
497 hda_nid_t nid
= pins
[i
];
500 present
|= snd_hda_jack_detect(codec
, nid
);
505 /* standard HP/line-out auto-mute helper */
506 static void do_automute(struct hda_codec
*codec
, int num_pins
, hda_nid_t
*pins
,
507 bool mute
, bool hp_out
)
509 struct alc_spec
*spec
= codec
->spec
;
510 unsigned int mute_bits
= mute
? HDA_AMP_MUTE
: 0;
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 switch (spec
->automute_mode
) {
520 case ALC_AUTOMUTE_PIN
:
521 /* don't reset VREF value in case it's controlling
522 * the amp (see alc861_fixup_asus_amp_vref_0f())
524 if (spec
->keep_vref_in_automute
) {
525 val
= snd_hda_codec_read(codec
, nid
, 0,
526 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
531 snd_hda_set_pin_ctl(codec
, nid
, val
);
533 case ALC_AUTOMUTE_AMP
:
534 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
535 HDA_AMP_MUTE
, mute_bits
);
537 case ALC_AUTOMUTE_MIXER
:
538 nid
= spec
->automute_mixer_nid
[i
];
541 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, 0,
542 HDA_AMP_MUTE
, mute_bits
);
543 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, 1,
544 HDA_AMP_MUTE
, mute_bits
);
550 /* Toggle outputs muting */
551 static void update_outputs(struct hda_codec
*codec
)
553 struct alc_spec
*spec
= codec
->spec
;
556 /* Control HP pins/amps depending on master_mute state;
557 * in general, HP pins/amps control should be enabled in all cases,
558 * but currently set only for master_mute, just to be safe
560 if (!spec
->shared_mic_hp
) /* don't change HP-pin when shared with mic */
561 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.hp_pins
),
562 spec
->autocfg
.hp_pins
, spec
->master_mute
, true);
564 if (!spec
->automute_speaker
)
567 on
= spec
->hp_jack_present
| spec
->line_jack_present
;
568 on
|= spec
->master_mute
;
569 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.speaker_pins
),
570 spec
->autocfg
.speaker_pins
, on
, false);
572 /* toggle line-out mutes if needed, too */
573 /* if LO is a copy of either HP or Speaker, don't need to handle it */
574 if (spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.hp_pins
[0] ||
575 spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.speaker_pins
[0])
577 if (!spec
->automute_lo
)
580 on
= spec
->hp_jack_present
;
581 on
|= spec
->master_mute
;
582 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.line_out_pins
),
583 spec
->autocfg
.line_out_pins
, on
, false);
586 static void call_update_outputs(struct hda_codec
*codec
)
588 struct alc_spec
*spec
= codec
->spec
;
589 if (spec
->automute_hook
)
590 spec
->automute_hook(codec
);
592 update_outputs(codec
);
595 /* standard HP-automute helper */
596 static void alc_hp_automute(struct hda_codec
*codec
)
598 struct alc_spec
*spec
= codec
->spec
;
600 spec
->hp_jack_present
=
601 detect_jacks(codec
, ARRAY_SIZE(spec
->autocfg
.hp_pins
),
602 spec
->autocfg
.hp_pins
);
603 if (!spec
->detect_hp
|| (!spec
->automute_speaker
&& !spec
->automute_lo
))
605 call_update_outputs(codec
);
608 /* standard line-out-automute helper */
609 static void alc_line_automute(struct hda_codec
*codec
)
611 struct alc_spec
*spec
= codec
->spec
;
613 /* check LO jack only when it's different from HP */
614 if (spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.hp_pins
[0])
617 spec
->line_jack_present
=
618 detect_jacks(codec
, ARRAY_SIZE(spec
->autocfg
.line_out_pins
),
619 spec
->autocfg
.line_out_pins
);
620 if (!spec
->automute_speaker
|| !spec
->detect_lo
)
622 call_update_outputs(codec
);
625 #define get_connection_index(codec, mux, nid) \
626 snd_hda_get_conn_index(codec, mux, nid, 0)
628 /* standard mic auto-switch helper */
629 static void alc_mic_automute(struct hda_codec
*codec
)
631 struct alc_spec
*spec
= codec
->spec
;
632 hda_nid_t
*pins
= spec
->imux_pins
;
634 if (!spec
->auto_mic
|| !spec
->auto_mic_valid_imux
)
636 if (snd_BUG_ON(!spec
->adc_nids
))
638 if (snd_BUG_ON(spec
->int_mic_idx
< 0 || spec
->ext_mic_idx
< 0))
641 if (snd_hda_jack_detect(codec
, pins
[spec
->ext_mic_idx
]))
642 alc_mux_select(codec
, 0, spec
->ext_mic_idx
, false);
643 else if (spec
->dock_mic_idx
>= 0 &&
644 snd_hda_jack_detect(codec
, pins
[spec
->dock_mic_idx
]))
645 alc_mux_select(codec
, 0, spec
->dock_mic_idx
, false);
647 alc_mux_select(codec
, 0, spec
->int_mic_idx
, false);
650 /* handle the specified unsol action (ALC_XXX_EVENT) */
651 static void alc_exec_unsol_event(struct hda_codec
*codec
, int action
)
655 alc_hp_automute(codec
);
657 case ALC_FRONT_EVENT
:
658 alc_line_automute(codec
);
661 alc_mic_automute(codec
);
664 snd_hda_jack_report_sync(codec
);
667 /* update the master volume per volume-knob's unsol event */
668 static void alc_update_knob_master(struct hda_codec
*codec
, hda_nid_t nid
)
671 struct snd_kcontrol
*kctl
;
672 struct snd_ctl_elem_value
*uctl
;
674 kctl
= snd_hda_find_mixer_ctl(codec
, "Master Playback Volume");
677 uctl
= kzalloc(sizeof(*uctl
), GFP_KERNEL
);
680 val
= snd_hda_codec_read(codec
, nid
, 0,
681 AC_VERB_GET_VOLUME_KNOB_CONTROL
, 0);
682 val
&= HDA_AMP_VOLMASK
;
683 uctl
->value
.integer
.value
[0] = val
;
684 uctl
->value
.integer
.value
[1] = val
;
685 kctl
->put(kctl
, uctl
);
689 /* unsolicited event for HP jack sensing */
690 static void alc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
694 if (codec
->vendor_id
== 0x10ec0880)
698 action
= snd_hda_jack_get_action(codec
, res
);
699 if (action
== ALC_DCVOL_EVENT
) {
700 /* Execute the dc-vol event here as it requires the NID
701 * but we don't pass NID to alc_exec_unsol_event().
702 * Once when we convert all static quirks to the auto-parser,
703 * this can be integerated into there.
705 struct hda_jack_tbl
*jack
;
706 jack
= snd_hda_jack_tbl_get_from_tag(codec
, res
);
708 alc_update_knob_master(codec
, jack
->nid
);
711 alc_exec_unsol_event(codec
, action
);
714 /* call init functions of standard auto-mute helpers */
715 static void alc_inithook(struct hda_codec
*codec
)
717 alc_hp_automute(codec
);
718 alc_line_automute(codec
);
719 alc_mic_automute(codec
);
722 /* additional initialization for ALC888 variants */
723 static void alc888_coef_init(struct hda_codec
*codec
)
727 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 0);
728 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
729 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
730 if ((tmp
& 0xf0) == 0x20)
732 snd_hda_codec_read(codec
, 0x20, 0,
733 AC_VERB_SET_PROC_COEF
, 0x830);
736 snd_hda_codec_read(codec
, 0x20, 0,
737 AC_VERB_SET_PROC_COEF
, 0x3030);
740 /* additional initialization for ALC889 variants */
741 static void alc889_coef_init(struct hda_codec
*codec
)
745 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
746 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
747 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
748 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_PROC_COEF
, tmp
|0x2010);
751 /* turn on/off EAPD control (only if available) */
752 static void set_eapd(struct hda_codec
*codec
, hda_nid_t nid
, int on
)
754 if (get_wcaps_type(get_wcaps(codec
, nid
)) != AC_WID_PIN
)
756 if (snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_EAPD
)
757 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_EAPD_BTLENABLE
,
761 /* turn on/off EAPD controls of the codec */
762 static void alc_auto_setup_eapd(struct hda_codec
*codec
, bool on
)
764 /* We currently only handle front, HP */
765 static hda_nid_t pins
[] = {
766 0x0f, 0x10, 0x14, 0x15, 0
769 for (p
= pins
; *p
; p
++)
770 set_eapd(codec
, *p
, on
);
773 /* generic shutup callback;
774 * just turning off EPAD and a little pause for avoiding pop-noise
776 static void alc_eapd_shutup(struct hda_codec
*codec
)
778 alc_auto_setup_eapd(codec
, false);
782 /* generic EAPD initialization */
783 static void alc_auto_init_amp(struct hda_codec
*codec
, int type
)
787 alc_auto_setup_eapd(codec
, true);
790 snd_hda_sequence_write(codec
, alc_gpio1_init_verbs
);
793 snd_hda_sequence_write(codec
, alc_gpio2_init_verbs
);
796 snd_hda_sequence_write(codec
, alc_gpio3_init_verbs
);
798 case ALC_INIT_DEFAULT
:
799 switch (codec
->vendor_id
) {
801 snd_hda_codec_write(codec
, 0x1a, 0,
802 AC_VERB_SET_COEF_INDEX
, 7);
803 tmp
= snd_hda_codec_read(codec
, 0x1a, 0,
804 AC_VERB_GET_PROC_COEF
, 0);
805 snd_hda_codec_write(codec
, 0x1a, 0,
806 AC_VERB_SET_COEF_INDEX
, 7);
807 snd_hda_codec_write(codec
, 0x1a, 0,
808 AC_VERB_SET_PROC_COEF
,
817 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
818 alc889_coef_init(codec
);
821 alc888_coef_init(codec
);
823 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
826 snd_hda_codec_write(codec
, 0x20, 0,
827 AC_VERB_SET_COEF_INDEX
, 7);
828 tmp
= snd_hda_codec_read(codec
, 0x20, 0,
829 AC_VERB_GET_PROC_COEF
, 0);
830 snd_hda_codec_write(codec
, 0x20, 0,
831 AC_VERB_SET_COEF_INDEX
, 7);
832 snd_hda_codec_write(codec
, 0x20, 0,
833 AC_VERB_SET_PROC_COEF
,
843 * Auto-Mute mode mixer enum support
845 static int alc_automute_mode_info(struct snd_kcontrol
*kcontrol
,
846 struct snd_ctl_elem_info
*uinfo
)
848 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
849 struct alc_spec
*spec
= codec
->spec
;
850 static const char * const texts2
[] = {
851 "Disabled", "Enabled"
853 static const char * const texts3
[] = {
854 "Disabled", "Speaker Only", "Line Out+Speaker"
856 const char * const *texts
;
858 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
860 if (spec
->automute_speaker_possible
&& spec
->automute_lo_possible
) {
861 uinfo
->value
.enumerated
.items
= 3;
864 uinfo
->value
.enumerated
.items
= 2;
867 if (uinfo
->value
.enumerated
.item
>= uinfo
->value
.enumerated
.items
)
868 uinfo
->value
.enumerated
.item
= uinfo
->value
.enumerated
.items
- 1;
869 strcpy(uinfo
->value
.enumerated
.name
,
870 texts
[uinfo
->value
.enumerated
.item
]);
874 static int alc_automute_mode_get(struct snd_kcontrol
*kcontrol
,
875 struct snd_ctl_elem_value
*ucontrol
)
877 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
878 struct alc_spec
*spec
= codec
->spec
;
879 unsigned int val
= 0;
880 if (spec
->automute_speaker
)
882 if (spec
->automute_lo
)
885 ucontrol
->value
.enumerated
.item
[0] = val
;
889 static int alc_automute_mode_put(struct snd_kcontrol
*kcontrol
,
890 struct snd_ctl_elem_value
*ucontrol
)
892 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
893 struct alc_spec
*spec
= codec
->spec
;
895 switch (ucontrol
->value
.enumerated
.item
[0]) {
897 if (!spec
->automute_speaker
&& !spec
->automute_lo
)
899 spec
->automute_speaker
= 0;
900 spec
->automute_lo
= 0;
903 if (spec
->automute_speaker_possible
) {
904 if (!spec
->automute_lo
&& spec
->automute_speaker
)
906 spec
->automute_speaker
= 1;
907 spec
->automute_lo
= 0;
908 } else if (spec
->automute_lo_possible
) {
909 if (spec
->automute_lo
)
911 spec
->automute_lo
= 1;
916 if (!spec
->automute_lo_possible
|| !spec
->automute_speaker_possible
)
918 if (spec
->automute_speaker
&& spec
->automute_lo
)
920 spec
->automute_speaker
= 1;
921 spec
->automute_lo
= 1;
926 call_update_outputs(codec
);
930 static const struct snd_kcontrol_new alc_automute_mode_enum
= {
931 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
932 .name
= "Auto-Mute Mode",
933 .info
= alc_automute_mode_info
,
934 .get
= alc_automute_mode_get
,
935 .put
= alc_automute_mode_put
,
938 static struct snd_kcontrol_new
*alc_kcontrol_new(struct alc_spec
*spec
)
940 snd_array_init(&spec
->kctls
, sizeof(struct snd_kcontrol_new
), 32);
941 return snd_array_new(&spec
->kctls
);
944 static int alc_add_automute_mode_enum(struct hda_codec
*codec
)
946 struct alc_spec
*spec
= codec
->spec
;
947 struct snd_kcontrol_new
*knew
;
949 knew
= alc_kcontrol_new(spec
);
952 *knew
= alc_automute_mode_enum
;
953 knew
->name
= kstrdup("Auto-Mute Mode", GFP_KERNEL
);
960 * Check the availability of HP/line-out auto-mute;
961 * Set up appropriately if really supported
963 static void alc_init_automute(struct hda_codec
*codec
)
965 struct alc_spec
*spec
= codec
->spec
;
966 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
972 if (cfg
->line_out_pins
[0])
974 if (cfg
->speaker_pins
[0])
976 if (present
< 2) /* need two different output types */
979 if (!cfg
->speaker_pins
[0] &&
980 cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
981 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
982 sizeof(cfg
->speaker_pins
));
983 cfg
->speaker_outs
= cfg
->line_outs
;
986 if (!cfg
->hp_pins
[0] &&
987 cfg
->line_out_type
== AUTO_PIN_HP_OUT
) {
988 memcpy(cfg
->hp_pins
, cfg
->line_out_pins
,
989 sizeof(cfg
->hp_pins
));
990 cfg
->hp_outs
= cfg
->line_outs
;
993 spec
->automute_mode
= ALC_AUTOMUTE_PIN
;
995 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
996 hda_nid_t nid
= cfg
->hp_pins
[i
];
997 if (!is_jack_detectable(codec
, nid
))
999 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1001 snd_hda_jack_detect_enable(codec
, nid
, ALC_HP_EVENT
);
1002 spec
->detect_hp
= 1;
1005 if (cfg
->line_out_type
== AUTO_PIN_LINE_OUT
&& cfg
->line_outs
) {
1006 if (cfg
->speaker_outs
)
1007 for (i
= 0; i
< cfg
->line_outs
; i
++) {
1008 hda_nid_t nid
= cfg
->line_out_pins
[i
];
1009 if (!is_jack_detectable(codec
, nid
))
1011 snd_printdd("realtek: Enable Line-Out "
1012 "auto-muting on NID 0x%x\n", nid
);
1013 snd_hda_jack_detect_enable(codec
, nid
,
1015 spec
->detect_lo
= 1;
1017 spec
->automute_lo_possible
= spec
->detect_hp
;
1020 spec
->automute_speaker_possible
= cfg
->speaker_outs
&&
1021 (spec
->detect_hp
|| spec
->detect_lo
);
1023 spec
->automute_lo
= spec
->automute_lo_possible
;
1024 spec
->automute_speaker
= spec
->automute_speaker_possible
;
1026 if (spec
->automute_speaker_possible
|| spec
->automute_lo_possible
)
1027 /* create a control for automute mode */
1028 alc_add_automute_mode_enum(codec
);
1031 /* return the position of NID in the list, or -1 if not found */
1032 static int find_idx_in_nid_list(hda_nid_t nid
, const hda_nid_t
*list
, int nums
)
1035 for (i
= 0; i
< nums
; i
++)
1041 /* check whether dynamic ADC-switching is available */
1042 static bool alc_check_dyn_adc_switch(struct hda_codec
*codec
)
1044 struct alc_spec
*spec
= codec
->spec
;
1045 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
1049 if (imux
!= spec
->input_mux
) /* no dynamic imux? */
1052 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
1053 cap
= spec
->private_capsrc_nids
[n
];
1054 for (i
= 0; i
< imux
->num_items
; i
++) {
1055 pin
= spec
->imux_pins
[i
];
1058 if (get_connection_index(codec
, cap
, pin
) < 0)
1061 if (i
>= imux
->num_items
)
1062 return true; /* no ADC-switch is needed */
1065 for (i
= 0; i
< imux
->num_items
; i
++) {
1066 pin
= spec
->imux_pins
[i
];
1067 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
1068 cap
= spec
->private_capsrc_nids
[n
];
1069 idx
= get_connection_index(codec
, cap
, pin
);
1071 imux
->items
[i
].index
= idx
;
1072 spec
->dyn_adc_idx
[i
] = n
;
1078 snd_printdd("realtek: enabling ADC switching\n");
1079 spec
->dyn_adc_switch
= 1;
1083 /* check whether all auto-mic pins are valid; setup indices if OK */
1084 static bool alc_auto_mic_check_imux(struct hda_codec
*codec
)
1086 struct alc_spec
*spec
= codec
->spec
;
1087 const struct hda_input_mux
*imux
;
1089 if (!spec
->auto_mic
)
1091 if (spec
->auto_mic_valid_imux
)
1092 return true; /* already checked */
1094 /* fill up imux indices */
1095 if (!alc_check_dyn_adc_switch(codec
)) {
1100 imux
= spec
->input_mux
;
1101 spec
->ext_mic_idx
= find_idx_in_nid_list(spec
->ext_mic_pin
,
1102 spec
->imux_pins
, imux
->num_items
);
1103 spec
->int_mic_idx
= find_idx_in_nid_list(spec
->int_mic_pin
,
1104 spec
->imux_pins
, imux
->num_items
);
1105 spec
->dock_mic_idx
= find_idx_in_nid_list(spec
->dock_mic_pin
,
1106 spec
->imux_pins
, imux
->num_items
);
1107 if (spec
->ext_mic_idx
< 0 || spec
->int_mic_idx
< 0) {
1109 return false; /* no corresponding imux */
1112 snd_hda_jack_detect_enable(codec
, spec
->ext_mic_pin
, ALC_MIC_EVENT
);
1113 if (spec
->dock_mic_pin
)
1114 snd_hda_jack_detect_enable(codec
, spec
->dock_mic_pin
,
1117 spec
->auto_mic_valid_imux
= 1;
1123 * Check the availability of auto-mic switch;
1124 * Set up if really supported
1126 static void alc_init_auto_mic(struct hda_codec
*codec
)
1128 struct alc_spec
*spec
= codec
->spec
;
1129 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1130 hda_nid_t fixed
, ext
, dock
;
1133 if (spec
->shared_mic_hp
)
1134 return; /* no auto-mic for the shared I/O */
1136 spec
->ext_mic_idx
= spec
->int_mic_idx
= spec
->dock_mic_idx
= -1;
1138 fixed
= ext
= dock
= 0;
1139 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
1140 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
1141 unsigned int defcfg
;
1142 defcfg
= snd_hda_codec_get_pincfg(codec
, nid
);
1143 switch (snd_hda_get_input_pin_attr(defcfg
)) {
1144 case INPUT_PIN_ATTR_INT
:
1146 return; /* already occupied */
1147 if (cfg
->inputs
[i
].type
!= AUTO_PIN_MIC
)
1148 return; /* invalid type */
1151 case INPUT_PIN_ATTR_UNUSED
:
1152 return; /* invalid entry */
1153 case INPUT_PIN_ATTR_DOCK
:
1155 return; /* already occupied */
1156 if (cfg
->inputs
[i
].type
> AUTO_PIN_LINE_IN
)
1157 return; /* invalid type */
1162 return; /* already occupied */
1163 if (cfg
->inputs
[i
].type
!= AUTO_PIN_MIC
)
1164 return; /* invalid type */
1175 if (!is_jack_detectable(codec
, ext
))
1176 return; /* no unsol support */
1177 if (dock
&& !is_jack_detectable(codec
, dock
))
1178 return; /* no unsol support */
1180 /* check imux indices */
1181 spec
->ext_mic_pin
= ext
;
1182 spec
->int_mic_pin
= fixed
;
1183 spec
->dock_mic_pin
= dock
;
1186 if (!alc_auto_mic_check_imux(codec
))
1189 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
1193 /* check the availabilities of auto-mute and auto-mic switches */
1194 static void alc_auto_check_switches(struct hda_codec
*codec
)
1196 alc_init_automute(codec
);
1197 alc_init_auto_mic(codec
);
1201 * Realtek SSID verification
1204 /* Could be any non-zero and even value. When used as fixup, tells
1205 * the driver to ignore any present sku defines.
1207 #define ALC_FIXUP_SKU_IGNORE (2)
1209 static void alc_fixup_sku_ignore(struct hda_codec
*codec
,
1210 const struct hda_fixup
*fix
, int action
)
1212 struct alc_spec
*spec
= codec
->spec
;
1213 if (action
== HDA_FIXUP_ACT_PRE_PROBE
) {
1214 spec
->cdefine
.fixup
= 1;
1215 spec
->cdefine
.sku_cfg
= ALC_FIXUP_SKU_IGNORE
;
1219 static int alc_auto_parse_customize_define(struct hda_codec
*codec
)
1221 unsigned int ass
, tmp
, i
;
1223 struct alc_spec
*spec
= codec
->spec
;
1225 spec
->cdefine
.enable_pcbeep
= 1; /* assume always enabled */
1227 if (spec
->cdefine
.fixup
) {
1228 ass
= spec
->cdefine
.sku_cfg
;
1229 if (ass
== ALC_FIXUP_SKU_IGNORE
)
1234 ass
= codec
->subsystem_id
& 0xffff;
1235 if (ass
!= codec
->bus
->pci
->subsystem_device
&& (ass
& 1))
1239 if (codec
->vendor_id
== 0x10ec0260)
1241 ass
= snd_hda_codec_get_pincfg(codec
, nid
);
1244 printk(KERN_INFO
"hda_codec: %s: SKU not ready 0x%08x\n",
1245 codec
->chip_name
, ass
);
1251 for (i
= 1; i
< 16; i
++) {
1255 if (((ass
>> 16) & 0xf) != tmp
)
1258 spec
->cdefine
.port_connectivity
= ass
>> 30;
1259 spec
->cdefine
.enable_pcbeep
= (ass
& 0x100000) >> 20;
1260 spec
->cdefine
.check_sum
= (ass
>> 16) & 0xf;
1261 spec
->cdefine
.customization
= ass
>> 8;
1263 spec
->cdefine
.sku_cfg
= ass
;
1264 spec
->cdefine
.external_amp
= (ass
& 0x38) >> 3;
1265 spec
->cdefine
.platform_type
= (ass
& 0x4) >> 2;
1266 spec
->cdefine
.swap
= (ass
& 0x2) >> 1;
1267 spec
->cdefine
.override
= ass
& 0x1;
1269 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1270 nid
, spec
->cdefine
.sku_cfg
);
1271 snd_printd("SKU: port_connectivity=0x%x\n",
1272 spec
->cdefine
.port_connectivity
);
1273 snd_printd("SKU: enable_pcbeep=0x%x\n", spec
->cdefine
.enable_pcbeep
);
1274 snd_printd("SKU: check_sum=0x%08x\n", spec
->cdefine
.check_sum
);
1275 snd_printd("SKU: customization=0x%08x\n", spec
->cdefine
.customization
);
1276 snd_printd("SKU: external_amp=0x%x\n", spec
->cdefine
.external_amp
);
1277 snd_printd("SKU: platform_type=0x%x\n", spec
->cdefine
.platform_type
);
1278 snd_printd("SKU: swap=0x%x\n", spec
->cdefine
.swap
);
1279 snd_printd("SKU: override=0x%x\n", spec
->cdefine
.override
);
1284 /* return true if the given NID is found in the list */
1285 static bool found_in_nid_list(hda_nid_t nid
, const hda_nid_t
*list
, int nums
)
1287 return find_idx_in_nid_list(nid
, list
, nums
) >= 0;
1290 /* check subsystem ID and set up device-specific initialization;
1291 * return 1 if initialized, 0 if invalid SSID
1293 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1294 * 31 ~ 16 : Manufacture ID
1296 * 7 ~ 0 : Assembly ID
1297 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1299 static int alc_subsystem_id(struct hda_codec
*codec
,
1300 hda_nid_t porta
, hda_nid_t porte
,
1301 hda_nid_t portd
, hda_nid_t porti
)
1303 unsigned int ass
, tmp
, i
;
1305 struct alc_spec
*spec
= codec
->spec
;
1307 if (spec
->cdefine
.fixup
) {
1308 ass
= spec
->cdefine
.sku_cfg
;
1309 if (ass
== ALC_FIXUP_SKU_IGNORE
)
1314 ass
= codec
->subsystem_id
& 0xffff;
1315 if ((ass
!= codec
->bus
->pci
->subsystem_device
) && (ass
& 1))
1318 /* invalid SSID, check the special NID pin defcfg instead */
1320 * 31~30 : port connectivity
1323 * 19~16 : Check sum (15:1)
1328 if (codec
->vendor_id
== 0x10ec0260)
1330 ass
= snd_hda_codec_get_pincfg(codec
, nid
);
1331 snd_printd("realtek: No valid SSID, "
1332 "checking pincfg 0x%08x for NID 0x%x\n",
1336 if ((ass
>> 30) != 1) /* no physical connection */
1341 for (i
= 1; i
< 16; i
++) {
1345 if (((ass
>> 16) & 0xf) != tmp
)
1348 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1349 ass
& 0xffff, codec
->vendor_id
);
1353 * 2 : 0 --> Desktop, 1 --> Laptop
1354 * 3~5 : External Amplifier control
1357 tmp
= (ass
& 0x38) >> 3; /* external Amp control */
1360 spec
->init_amp
= ALC_INIT_GPIO1
;
1363 spec
->init_amp
= ALC_INIT_GPIO2
;
1366 spec
->init_amp
= ALC_INIT_GPIO3
;
1370 spec
->init_amp
= ALC_INIT_DEFAULT
;
1374 /* is laptop or Desktop and enable the function "Mute internal speaker
1375 * when the external headphone out jack is plugged"
1377 if (!(ass
& 0x8000))
1380 * 10~8 : Jack location
1381 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1383 * 15 : 1 --> enable the function "Mute internal speaker
1384 * when the external headphone out jack is plugged"
1386 if (!spec
->autocfg
.hp_pins
[0] &&
1387 !(spec
->autocfg
.line_out_pins
[0] &&
1388 spec
->autocfg
.line_out_type
== AUTO_PIN_HP_OUT
)) {
1390 tmp
= (ass
>> 11) & 0x3; /* HP to chassis */
1401 if (found_in_nid_list(nid
, spec
->autocfg
.line_out_pins
,
1402 spec
->autocfg
.line_outs
))
1404 spec
->autocfg
.hp_pins
[0] = nid
;
1409 /* Check the validity of ALC subsystem-id
1410 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
1411 static void alc_ssid_check(struct hda_codec
*codec
, const hda_nid_t
*ports
)
1413 if (!alc_subsystem_id(codec
, ports
[0], ports
[1], ports
[2], ports
[3])) {
1414 struct alc_spec
*spec
= codec
->spec
;
1415 snd_printd("realtek: "
1416 "Enable default setup for auto mode as fallback\n");
1417 spec
->init_amp
= ALC_INIT_DEFAULT
;
1422 * COEF access helper functions
1424 static int alc_read_coef_idx(struct hda_codec
*codec
,
1425 unsigned int coef_idx
)
1428 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
,
1430 val
= snd_hda_codec_read(codec
, 0x20, 0,
1431 AC_VERB_GET_PROC_COEF
, 0);
1435 static void alc_write_coef_idx(struct hda_codec
*codec
, unsigned int coef_idx
,
1436 unsigned int coef_val
)
1438 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
,
1440 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_PROC_COEF
,
1444 /* a special bypass for COEF 0; read the cached value at the second time */
1445 static unsigned int alc_get_coef0(struct hda_codec
*codec
)
1447 struct alc_spec
*spec
= codec
->spec
;
1449 spec
->coef0
= alc_read_coef_idx(codec
, 0);
1454 * Digital I/O handling
1457 /* set right pin controls for digital I/O */
1458 static void alc_auto_init_digital(struct hda_codec
*codec
)
1460 struct alc_spec
*spec
= codec
->spec
;
1464 for (i
= 0; i
< spec
->autocfg
.dig_outs
; i
++) {
1465 pin
= spec
->autocfg
.dig_out_pins
[i
];
1468 snd_hda_set_pin_ctl(codec
, pin
, PIN_OUT
);
1470 dac
= spec
->multiout
.dig_out_nid
;
1472 dac
= spec
->slave_dig_outs
[i
- 1];
1473 if (!dac
|| !(get_wcaps(codec
, dac
) & AC_WCAP_OUT_AMP
))
1475 snd_hda_codec_write(codec
, dac
, 0,
1476 AC_VERB_SET_AMP_GAIN_MUTE
,
1479 pin
= spec
->autocfg
.dig_in_pin
;
1481 snd_hda_set_pin_ctl(codec
, pin
, PIN_IN
);
1484 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1485 static void alc_auto_parse_digital(struct hda_codec
*codec
)
1487 struct alc_spec
*spec
= codec
->spec
;
1491 /* support multiple SPDIFs; the secondary is set up as a slave */
1493 for (i
= 0; i
< spec
->autocfg
.dig_outs
; i
++) {
1495 err
= snd_hda_get_connections(codec
,
1496 spec
->autocfg
.dig_out_pins
[i
],
1497 conn
, ARRAY_SIZE(conn
));
1500 dig_nid
= conn
[0]; /* assume the first element is audio-out */
1502 spec
->multiout
.dig_out_nid
= dig_nid
;
1503 spec
->dig_out_type
= spec
->autocfg
.dig_out_type
[0];
1505 spec
->multiout
.slave_dig_outs
= spec
->slave_dig_outs
;
1506 if (nums
>= ARRAY_SIZE(spec
->slave_dig_outs
) - 1)
1508 spec
->slave_dig_outs
[nums
- 1] = dig_nid
;
1513 if (spec
->autocfg
.dig_in_pin
) {
1514 dig_nid
= codec
->start_nid
;
1515 for (i
= 0; i
< codec
->num_nodes
; i
++, dig_nid
++) {
1516 unsigned int wcaps
= get_wcaps(codec
, dig_nid
);
1517 if (get_wcaps_type(wcaps
) != AC_WID_AUD_IN
)
1519 if (!(wcaps
& AC_WCAP_DIGITAL
))
1521 if (!(wcaps
& AC_WCAP_CONN_LIST
))
1523 err
= get_connection_index(codec
, dig_nid
,
1524 spec
->autocfg
.dig_in_pin
);
1526 spec
->dig_in_nid
= dig_nid
;
1534 * capture mixer elements
1536 static int alc_cap_vol_info(struct snd_kcontrol
*kcontrol
,
1537 struct snd_ctl_elem_info
*uinfo
)
1539 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1540 struct alc_spec
*spec
= codec
->spec
;
1544 mutex_lock(&codec
->control_mutex
);
1545 if (spec
->vol_in_capsrc
)
1546 val
= HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[0], 3, 0, HDA_OUTPUT
);
1548 val
= HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[0], 3, 0, HDA_INPUT
);
1549 kcontrol
->private_value
= val
;
1550 err
= snd_hda_mixer_amp_volume_info(kcontrol
, uinfo
);
1551 mutex_unlock(&codec
->control_mutex
);
1555 static int alc_cap_vol_tlv(struct snd_kcontrol
*kcontrol
, int op_flag
,
1556 unsigned int size
, unsigned int __user
*tlv
)
1558 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1559 struct alc_spec
*spec
= codec
->spec
;
1563 mutex_lock(&codec
->control_mutex
);
1564 if (spec
->vol_in_capsrc
)
1565 val
= HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[0], 3, 0, HDA_OUTPUT
);
1567 val
= HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[0], 3, 0, HDA_INPUT
);
1568 kcontrol
->private_value
= val
;
1569 err
= snd_hda_mixer_amp_tlv(kcontrol
, op_flag
, size
, tlv
);
1570 mutex_unlock(&codec
->control_mutex
);
1574 typedef int (*getput_call_t
)(struct snd_kcontrol
*kcontrol
,
1575 struct snd_ctl_elem_value
*ucontrol
);
1577 static int alc_cap_getput_caller(struct snd_kcontrol
*kcontrol
,
1578 struct snd_ctl_elem_value
*ucontrol
,
1579 getput_call_t func
, bool is_put
)
1581 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1582 struct alc_spec
*spec
= codec
->spec
;
1585 mutex_lock(&codec
->control_mutex
);
1586 if (is_put
&& spec
->dyn_adc_switch
) {
1587 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
1588 kcontrol
->private_value
=
1589 HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[i
],
1591 err
= func(kcontrol
, ucontrol
);
1596 i
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
1597 if (spec
->vol_in_capsrc
)
1598 kcontrol
->private_value
=
1599 HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[i
],
1602 kcontrol
->private_value
=
1603 HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[i
],
1605 err
= func(kcontrol
, ucontrol
);
1607 if (err
>= 0 && is_put
)
1608 alc_inv_dmic_sync(codec
, false);
1610 mutex_unlock(&codec
->control_mutex
);
1614 static int alc_cap_vol_get(struct snd_kcontrol
*kcontrol
,
1615 struct snd_ctl_elem_value
*ucontrol
)
1617 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1618 snd_hda_mixer_amp_volume_get
, false);
1621 static int alc_cap_vol_put(struct snd_kcontrol
*kcontrol
,
1622 struct snd_ctl_elem_value
*ucontrol
)
1624 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1625 snd_hda_mixer_amp_volume_put
, true);
1628 /* capture mixer elements */
1629 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1631 static int alc_cap_sw_get(struct snd_kcontrol
*kcontrol
,
1632 struct snd_ctl_elem_value
*ucontrol
)
1634 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1635 snd_hda_mixer_amp_switch_get
, false);
1638 static int alc_cap_sw_put(struct snd_kcontrol
*kcontrol
,
1639 struct snd_ctl_elem_value
*ucontrol
)
1641 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1642 snd_hda_mixer_amp_switch_put
, true);
1645 #define _DEFINE_CAPMIX(num) \
1647 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1648 .name = "Capture Switch", \
1649 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1651 .info = alc_cap_sw_info, \
1652 .get = alc_cap_sw_get, \
1653 .put = alc_cap_sw_put, \
1656 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1657 .name = "Capture Volume", \
1658 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1659 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1660 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1662 .info = alc_cap_vol_info, \
1663 .get = alc_cap_vol_get, \
1664 .put = alc_cap_vol_put, \
1665 .tlv = { .c = alc_cap_vol_tlv }, \
1668 #define _DEFINE_CAPSRC(num) \
1670 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1671 /* .name = "Capture Source", */ \
1672 .name = "Input Source", \
1674 .info = alc_mux_enum_info, \
1675 .get = alc_mux_enum_get, \
1676 .put = alc_mux_enum_put, \
1679 #define DEFINE_CAPMIX(num) \
1680 static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1681 _DEFINE_CAPMIX(num), \
1682 _DEFINE_CAPSRC(num), \
1686 #define DEFINE_CAPMIX_NOSRC(num) \
1687 static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1688 _DEFINE_CAPMIX(num), \
1692 /* up to three ADCs */
1696 DEFINE_CAPMIX_NOSRC(1);
1697 DEFINE_CAPMIX_NOSRC(2);
1698 DEFINE_CAPMIX_NOSRC(3);
1701 * Inverted digital-mic handling
1703 * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch"
1704 * gives the additional mute only to the right channel of the digital mic
1705 * capture stream. This is a workaround for avoiding the almost silence
1706 * by summing the stereo stream from some (known to be ForteMedia)
1709 * The logic is to call alc_inv_dmic_sync() after each action (possibly)
1710 * modifying ADC amp. When the mute flag is set, it mutes the R-channel
1711 * without caching so that the cache can still keep the original value.
1712 * The cached value is then restored when the flag is set off or any other
1713 * than d-mic is used as the current input source.
1715 static void alc_inv_dmic_sync(struct hda_codec
*codec
, bool force
)
1717 struct alc_spec
*spec
= codec
->spec
;
1720 if (!spec
->inv_dmic_fixup
)
1722 if (!spec
->inv_dmic_muted
&& !force
)
1724 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
1725 int src
= spec
->dyn_adc_switch
? 0 : i
;
1726 bool dmic_fixup
= false;
1730 if (spec
->inv_dmic_muted
&&
1731 spec
->imux_pins
[spec
->cur_mux
[src
]] == spec
->inv_dmic_pin
)
1733 if (!dmic_fixup
&& !force
)
1735 if (spec
->vol_in_capsrc
) {
1736 nid
= spec
->capsrc_nids
[i
];
1737 parm
= AC_AMP_SET_RIGHT
| AC_AMP_SET_OUTPUT
;
1740 nid
= spec
->adc_nids
[i
];
1741 parm
= AC_AMP_SET_RIGHT
| AC_AMP_SET_INPUT
;
1744 /* we care only right channel */
1745 v
= snd_hda_codec_amp_read(codec
, nid
, 1, dir
, 0);
1746 if (v
& 0x80) /* if already muted, we don't need to touch */
1748 if (dmic_fixup
) /* add mute for d-mic */
1750 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
1755 static int alc_inv_dmic_sw_get(struct snd_kcontrol
*kcontrol
,
1756 struct snd_ctl_elem_value
*ucontrol
)
1758 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1759 struct alc_spec
*spec
= codec
->spec
;
1761 ucontrol
->value
.integer
.value
[0] = !spec
->inv_dmic_muted
;
1765 static int alc_inv_dmic_sw_put(struct snd_kcontrol
*kcontrol
,
1766 struct snd_ctl_elem_value
*ucontrol
)
1768 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1769 struct alc_spec
*spec
= codec
->spec
;
1770 unsigned int val
= !ucontrol
->value
.integer
.value
[0];
1772 if (val
== spec
->inv_dmic_muted
)
1774 spec
->inv_dmic_muted
= val
;
1775 alc_inv_dmic_sync(codec
, true);
1779 static const struct snd_kcontrol_new alc_inv_dmic_sw
= {
1780 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1781 .info
= snd_ctl_boolean_mono_info
,
1782 .get
= alc_inv_dmic_sw_get
,
1783 .put
= alc_inv_dmic_sw_put
,
1786 static int alc_add_inv_dmic_mixer(struct hda_codec
*codec
, hda_nid_t nid
)
1788 struct alc_spec
*spec
= codec
->spec
;
1789 struct snd_kcontrol_new
*knew
= alc_kcontrol_new(spec
);
1792 *knew
= alc_inv_dmic_sw
;
1793 knew
->name
= kstrdup("Inverted Internal Mic Capture Switch", GFP_KERNEL
);
1796 spec
->inv_dmic_fixup
= 1;
1797 spec
->inv_dmic_muted
= 0;
1798 spec
->inv_dmic_pin
= nid
;
1802 /* typically the digital mic is put at node 0x12 */
1803 static void alc_fixup_inv_dmic_0x12(struct hda_codec
*codec
,
1804 const struct alc_fixup
*fix
, int action
)
1806 if (action
== ALC_FIXUP_ACT_PROBE
)
1807 alc_add_inv_dmic_mixer(codec
, 0x12);
1811 * virtual master controls
1815 * slave controls for virtual master
1817 static const char * const alc_slave_pfxs
[] = {
1818 "Front", "Surround", "Center", "LFE", "Side",
1819 "Headphone", "Speaker", "Mono", "Line Out",
1820 "CLFE", "Bass Speaker", "PCM",
1825 * build control elements
1828 #define NID_MAPPING (-1)
1830 #define SUBDEV_SPEAKER_ (0 << 6)
1831 #define SUBDEV_HP_ (1 << 6)
1832 #define SUBDEV_LINE_ (2 << 6)
1833 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
1834 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
1835 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
1837 static void alc_free_kctls(struct hda_codec
*codec
);
1839 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1840 /* additional beep mixers; the actual parameters are overwritten at build */
1841 static const struct snd_kcontrol_new alc_beep_mixer
[] = {
1842 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT
),
1843 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT
),
1848 static int __alc_build_controls(struct hda_codec
*codec
)
1850 struct alc_spec
*spec
= codec
->spec
;
1851 struct snd_kcontrol
*kctl
= NULL
;
1852 const struct snd_kcontrol_new
*knew
;
1857 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1858 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
1862 if (spec
->cap_mixer
) {
1863 err
= snd_hda_add_new_ctls(codec
, spec
->cap_mixer
);
1867 if (spec
->multiout
.dig_out_nid
) {
1868 err
= snd_hda_create_spdif_out_ctls(codec
,
1869 spec
->multiout
.dig_out_nid
,
1870 spec
->multiout
.dig_out_nid
);
1873 if (!spec
->no_analog
) {
1874 err
= snd_hda_create_spdif_share_sw(codec
,
1878 spec
->multiout
.share_spdif
= 1;
1881 if (spec
->dig_in_nid
) {
1882 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
1887 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1888 /* create beep controls if needed */
1889 if (spec
->beep_amp
) {
1890 const struct snd_kcontrol_new
*knew
;
1891 for (knew
= alc_beep_mixer
; knew
->name
; knew
++) {
1892 struct snd_kcontrol
*kctl
;
1893 kctl
= snd_ctl_new1(knew
, codec
);
1896 kctl
->private_value
= spec
->beep_amp
;
1897 err
= snd_hda_ctl_add(codec
, 0, kctl
);
1904 /* if we have no master control, let's create it */
1905 if (!spec
->no_analog
&&
1906 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
1907 unsigned int vmaster_tlv
[4];
1908 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
1909 HDA_OUTPUT
, vmaster_tlv
);
1910 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
1911 vmaster_tlv
, alc_slave_pfxs
,
1916 if (!spec
->no_analog
&&
1917 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
1918 err
= __snd_hda_add_vmaster(codec
, "Master Playback Switch",
1919 NULL
, alc_slave_pfxs
,
1921 true, &spec
->vmaster_mute
.sw_kctl
);
1926 /* assign Capture Source enums to NID */
1927 if (spec
->capsrc_nids
|| spec
->adc_nids
) {
1928 kctl
= snd_hda_find_mixer_ctl(codec
, "Capture Source");
1930 kctl
= snd_hda_find_mixer_ctl(codec
, "Input Source");
1931 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
1932 err
= snd_hda_add_nid(codec
, kctl
, i
,
1933 get_capsrc(spec
, i
));
1938 if (spec
->cap_mixer
&& spec
->adc_nids
) {
1939 const char *kname
= kctl
? kctl
->id
.name
: NULL
;
1940 for (knew
= spec
->cap_mixer
; knew
->name
; knew
++) {
1941 if (kname
&& strcmp(knew
->name
, kname
) == 0)
1943 kctl
= snd_hda_find_mixer_ctl(codec
, knew
->name
);
1944 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
1945 err
= snd_hda_add_nid(codec
, kctl
, i
,
1953 /* other nid->control mapping */
1954 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1955 for (knew
= spec
->mixers
[i
]; knew
->name
; knew
++) {
1956 if (knew
->iface
!= NID_MAPPING
)
1958 kctl
= snd_hda_find_mixer_ctl(codec
, knew
->name
);
1961 u
= knew
->subdevice
;
1962 for (j
= 0; j
< 4; j
++, u
>>= 8) {
1967 case SUBDEV_SPEAKER_
:
1968 nid
= spec
->autocfg
.speaker_pins
[nid
];
1971 nid
= spec
->autocfg
.line_out_pins
[nid
];
1974 nid
= spec
->autocfg
.hp_pins
[nid
];
1979 err
= snd_hda_add_nid(codec
, kctl
, 0, nid
);
1983 u
= knew
->private_value
;
1984 for (j
= 0; j
< 4; j
++, u
>>= 8) {
1988 err
= snd_hda_add_nid(codec
, kctl
, 0, nid
);
1995 alc_free_kctls(codec
); /* no longer needed */
2000 static int alc_build_jacks(struct hda_codec
*codec
)
2002 struct alc_spec
*spec
= codec
->spec
;
2004 if (spec
->shared_mic_hp
) {
2006 int nid
= spec
->autocfg
.inputs
[1].pin
;
2007 err
= snd_hda_jack_add_kctl(codec
, nid
, "Headphone Mic", 0);
2010 err
= snd_hda_jack_detect_enable(codec
, nid
, 0);
2015 return snd_hda_jack_add_kctls(codec
, &spec
->autocfg
);
2018 static int alc_build_controls(struct hda_codec
*codec
)
2020 int err
= __alc_build_controls(codec
);
2024 err
= alc_build_jacks(codec
);
2027 alc_apply_fixup(codec
, ALC_FIXUP_ACT_BUILD
);
2036 static void alc_init_special_input_src(struct hda_codec
*codec
);
2037 static void alc_auto_init_std(struct hda_codec
*codec
);
2039 static int alc_init(struct hda_codec
*codec
)
2041 struct alc_spec
*spec
= codec
->spec
;
2043 if (spec
->init_hook
)
2044 spec
->init_hook(codec
);
2047 alc_auto_init_amp(codec
, spec
->init_amp
);
2049 snd_hda_gen_apply_verbs(codec
);
2050 alc_init_special_input_src(codec
);
2051 alc_auto_init_std(codec
);
2053 alc_apply_fixup(codec
, ALC_FIXUP_ACT_INIT
);
2055 snd_hda_jack_report_sync(codec
);
2057 hda_call_check_power_status(codec
, 0x01);
2061 #ifdef CONFIG_SND_HDA_POWER_SAVE
2062 static int alc_check_power_status(struct hda_codec
*codec
, hda_nid_t nid
)
2064 struct alc_spec
*spec
= codec
->spec
;
2065 return snd_hda_check_amp_list_power(codec
, &spec
->loopback
, nid
);
2070 * Analog playback callbacks
2072 static int alc_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2073 struct hda_codec
*codec
,
2074 struct snd_pcm_substream
*substream
)
2076 struct alc_spec
*spec
= codec
->spec
;
2077 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
2081 static int alc_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2082 struct hda_codec
*codec
,
2083 unsigned int stream_tag
,
2084 unsigned int format
,
2085 struct snd_pcm_substream
*substream
)
2087 struct alc_spec
*spec
= codec
->spec
;
2088 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
2089 stream_tag
, format
, substream
);
2092 static int alc_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2093 struct hda_codec
*codec
,
2094 struct snd_pcm_substream
*substream
)
2096 struct alc_spec
*spec
= codec
->spec
;
2097 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
2103 static int alc_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2104 struct hda_codec
*codec
,
2105 struct snd_pcm_substream
*substream
)
2107 struct alc_spec
*spec
= codec
->spec
;
2108 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
2111 static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2112 struct hda_codec
*codec
,
2113 unsigned int stream_tag
,
2114 unsigned int format
,
2115 struct snd_pcm_substream
*substream
)
2117 struct alc_spec
*spec
= codec
->spec
;
2118 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
2119 stream_tag
, format
, substream
);
2122 static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2123 struct hda_codec
*codec
,
2124 struct snd_pcm_substream
*substream
)
2126 struct alc_spec
*spec
= codec
->spec
;
2127 return snd_hda_multi_out_dig_cleanup(codec
, &spec
->multiout
);
2130 static int alc_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
2131 struct hda_codec
*codec
,
2132 struct snd_pcm_substream
*substream
)
2134 struct alc_spec
*spec
= codec
->spec
;
2135 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
2141 static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2142 struct hda_codec
*codec
,
2143 unsigned int stream_tag
,
2144 unsigned int format
,
2145 struct snd_pcm_substream
*substream
)
2147 struct alc_spec
*spec
= codec
->spec
;
2149 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
+ 1],
2150 stream_tag
, 0, format
);
2154 static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2155 struct hda_codec
*codec
,
2156 struct snd_pcm_substream
*substream
)
2158 struct alc_spec
*spec
= codec
->spec
;
2160 snd_hda_codec_cleanup_stream(codec
,
2161 spec
->adc_nids
[substream
->number
+ 1]);
2165 /* analog capture with dynamic dual-adc changes */
2166 static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2167 struct hda_codec
*codec
,
2168 unsigned int stream_tag
,
2169 unsigned int format
,
2170 struct snd_pcm_substream
*substream
)
2172 struct alc_spec
*spec
= codec
->spec
;
2173 spec
->cur_adc
= spec
->adc_nids
[spec
->dyn_adc_idx
[spec
->cur_mux
[0]]];
2174 spec
->cur_adc_stream_tag
= stream_tag
;
2175 spec
->cur_adc_format
= format
;
2176 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
2180 static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2181 struct hda_codec
*codec
,
2182 struct snd_pcm_substream
*substream
)
2184 struct alc_spec
*spec
= codec
->spec
;
2185 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
2190 static const struct hda_pcm_stream dyn_adc_pcm_analog_capture
= {
2194 .nid
= 0, /* fill later */
2196 .prepare
= dyn_adc_capture_pcm_prepare
,
2197 .cleanup
= dyn_adc_capture_pcm_cleanup
2203 static const struct hda_pcm_stream alc_pcm_analog_playback
= {
2207 /* NID is set in alc_build_pcms */
2209 .open
= alc_playback_pcm_open
,
2210 .prepare
= alc_playback_pcm_prepare
,
2211 .cleanup
= alc_playback_pcm_cleanup
2215 static const struct hda_pcm_stream alc_pcm_analog_capture
= {
2219 /* NID is set in alc_build_pcms */
2222 static const struct hda_pcm_stream alc_pcm_analog_alt_playback
= {
2226 /* NID is set in alc_build_pcms */
2229 static const struct hda_pcm_stream alc_pcm_analog_alt_capture
= {
2230 .substreams
= 2, /* can be overridden */
2233 /* NID is set in alc_build_pcms */
2235 .prepare
= alc_alt_capture_pcm_prepare
,
2236 .cleanup
= alc_alt_capture_pcm_cleanup
2240 static const struct hda_pcm_stream alc_pcm_digital_playback
= {
2244 /* NID is set in alc_build_pcms */
2246 .open
= alc_dig_playback_pcm_open
,
2247 .close
= alc_dig_playback_pcm_close
,
2248 .prepare
= alc_dig_playback_pcm_prepare
,
2249 .cleanup
= alc_dig_playback_pcm_cleanup
2253 static const struct hda_pcm_stream alc_pcm_digital_capture
= {
2257 /* NID is set in alc_build_pcms */
2260 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2261 static const struct hda_pcm_stream alc_pcm_null_stream
= {
2267 static int alc_build_pcms(struct hda_codec
*codec
)
2269 struct alc_spec
*spec
= codec
->spec
;
2270 struct hda_pcm
*info
= spec
->pcm_rec
;
2271 const struct hda_pcm_stream
*p
;
2272 bool have_multi_adcs
;
2275 codec
->num_pcms
= 1;
2276 codec
->pcm_info
= info
;
2278 if (spec
->no_analog
)
2281 snprintf(spec
->stream_name_analog
, sizeof(spec
->stream_name_analog
),
2282 "%s Analog", codec
->chip_name
);
2283 info
->name
= spec
->stream_name_analog
;
2285 if (spec
->multiout
.num_dacs
> 0) {
2286 p
= spec
->stream_analog_playback
;
2288 p
= &alc_pcm_analog_playback
;
2289 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2290 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dac_nids
[0];
2292 if (spec
->adc_nids
) {
2293 p
= spec
->stream_analog_capture
;
2295 if (spec
->dyn_adc_switch
)
2296 p
= &dyn_adc_pcm_analog_capture
;
2298 p
= &alc_pcm_analog_capture
;
2300 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2301 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
2304 if (spec
->channel_mode
) {
2305 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= 0;
2306 for (i
= 0; i
< spec
->num_channel_mode
; i
++) {
2307 if (spec
->channel_mode
[i
].channels
> info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
) {
2308 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= spec
->channel_mode
[i
].channels
;
2314 /* SPDIF for stream index #1 */
2315 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
2316 snprintf(spec
->stream_name_digital
,
2317 sizeof(spec
->stream_name_digital
),
2318 "%s Digital", codec
->chip_name
);
2319 codec
->num_pcms
= 2;
2320 codec
->slave_dig_outs
= spec
->multiout
.slave_dig_outs
;
2321 info
= spec
->pcm_rec
+ 1;
2322 info
->name
= spec
->stream_name_digital
;
2323 if (spec
->dig_out_type
)
2324 info
->pcm_type
= spec
->dig_out_type
;
2326 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
2327 if (spec
->multiout
.dig_out_nid
) {
2328 p
= spec
->stream_digital_playback
;
2330 p
= &alc_pcm_digital_playback
;
2331 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2332 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
2334 if (spec
->dig_in_nid
) {
2335 p
= spec
->stream_digital_capture
;
2337 p
= &alc_pcm_digital_capture
;
2338 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2339 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
2341 /* FIXME: do we need this for all Realtek codec models? */
2342 codec
->spdif_status_reset
= 1;
2345 if (spec
->no_analog
)
2348 /* If the use of more than one ADC is requested for the current
2349 * model, configure a second analog capture-only PCM.
2351 have_multi_adcs
= (spec
->num_adc_nids
> 1) &&
2352 !spec
->dyn_adc_switch
&& !spec
->auto_mic
&&
2353 (!spec
->input_mux
|| spec
->input_mux
->num_items
> 1);
2354 /* Additional Analaog capture for index #2 */
2355 if (spec
->alt_dac_nid
|| have_multi_adcs
) {
2356 codec
->num_pcms
= 3;
2357 info
= spec
->pcm_rec
+ 2;
2358 info
->name
= spec
->stream_name_analog
;
2359 if (spec
->alt_dac_nid
) {
2360 p
= spec
->stream_analog_alt_playback
;
2362 p
= &alc_pcm_analog_alt_playback
;
2363 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2364 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
2367 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
2368 alc_pcm_null_stream
;
2369 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= 0;
2371 if (have_multi_adcs
) {
2372 p
= spec
->stream_analog_alt_capture
;
2374 p
= &alc_pcm_analog_alt_capture
;
2375 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2376 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
2378 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
=
2379 spec
->num_adc_nids
- 1;
2381 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
2382 alc_pcm_null_stream
;
2383 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= 0;
2390 static inline void alc_shutup(struct hda_codec
*codec
)
2392 struct alc_spec
*spec
= codec
->spec
;
2394 if (spec
&& spec
->shutup
)
2395 spec
->shutup(codec
);
2396 snd_hda_shutup_pins(codec
);
2399 static void alc_free_kctls(struct hda_codec
*codec
)
2401 struct alc_spec
*spec
= codec
->spec
;
2403 if (spec
->kctls
.list
) {
2404 struct snd_kcontrol_new
*kctl
= spec
->kctls
.list
;
2406 for (i
= 0; i
< spec
->kctls
.used
; i
++)
2407 kfree(kctl
[i
].name
);
2409 snd_array_free(&spec
->kctls
);
2412 static void alc_free_bind_ctls(struct hda_codec
*codec
)
2414 struct alc_spec
*spec
= codec
->spec
;
2415 if (spec
->bind_ctls
.list
) {
2416 struct hda_bind_ctls
**ctl
= spec
->bind_ctls
.list
;
2418 for (i
= 0; i
< spec
->bind_ctls
.used
; i
++)
2421 snd_array_free(&spec
->bind_ctls
);
2424 static void alc_free(struct hda_codec
*codec
)
2426 struct alc_spec
*spec
= codec
->spec
;
2432 alc_free_kctls(codec
);
2433 alc_free_bind_ctls(codec
);
2434 snd_hda_gen_free(&spec
->gen
);
2436 snd_hda_detach_beep_device(codec
);
2439 #ifdef CONFIG_SND_HDA_POWER_SAVE
2440 static void alc_power_eapd(struct hda_codec
*codec
)
2442 alc_auto_setup_eapd(codec
, false);
2445 static int alc_suspend(struct hda_codec
*codec
)
2447 struct alc_spec
*spec
= codec
->spec
;
2449 if (spec
&& spec
->power_hook
)
2450 spec
->power_hook(codec
);
2456 static int alc_resume(struct hda_codec
*codec
)
2458 msleep(150); /* to avoid pop noise */
2459 codec
->patch_ops
.init(codec
);
2460 snd_hda_codec_resume_amp(codec
);
2461 snd_hda_codec_resume_cache(codec
);
2462 alc_inv_dmic_sync(codec
, true);
2463 hda_call_check_power_status(codec
, 0x01);
2470 static const struct hda_codec_ops alc_patch_ops
= {
2471 .build_controls
= alc_build_controls
,
2472 .build_pcms
= alc_build_pcms
,
2475 .unsol_event
= alc_unsol_event
,
2477 .resume
= alc_resume
,
2479 #ifdef CONFIG_SND_HDA_POWER_SAVE
2480 .suspend
= alc_suspend
,
2481 .check_power_status
= alc_check_power_status
,
2483 .reboot_notify
= alc_shutup
,
2486 /* replace the codec chip_name with the given string */
2487 static int alc_codec_rename(struct hda_codec
*codec
, const char *name
)
2489 kfree(codec
->chip_name
);
2490 codec
->chip_name
= kstrdup(name
, GFP_KERNEL
);
2491 if (!codec
->chip_name
) {
2499 * Rename codecs appropriately from COEF value
2501 struct alc_codec_rename_table
{
2502 unsigned int vendor_id
;
2503 unsigned short coef_mask
;
2504 unsigned short coef_bits
;
2508 static struct alc_codec_rename_table rename_tbl
[] = {
2509 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
2510 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
2511 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
2512 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
2513 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
2514 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
2515 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
2516 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
2517 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
2518 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
2519 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
2520 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
2521 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
2522 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
2523 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
2524 { } /* terminator */
2527 static int alc_codec_rename_from_preset(struct hda_codec
*codec
)
2529 const struct alc_codec_rename_table
*p
;
2531 for (p
= rename_tbl
; p
->vendor_id
; p
++) {
2532 if (p
->vendor_id
!= codec
->vendor_id
)
2534 if ((alc_get_coef0(codec
) & p
->coef_mask
) == p
->coef_bits
)
2535 return alc_codec_rename(codec
, p
->name
);
2541 * Automatic parse of I/O pins from the BIOS configuration
2546 ALC_CTL_WIDGET_MUTE
,
2551 static const struct snd_kcontrol_new alc_control_templates
[] = {
2552 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2553 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2554 HDA_BIND_MUTE(NULL
, 0, 0, 0),
2555 HDA_BIND_VOL(NULL
, 0),
2556 HDA_BIND_SW(NULL
, 0),
2559 /* add dynamic controls */
2560 static int add_control(struct alc_spec
*spec
, int type
, const char *name
,
2561 int cidx
, unsigned long val
)
2563 struct snd_kcontrol_new
*knew
;
2565 knew
= alc_kcontrol_new(spec
);
2568 *knew
= alc_control_templates
[type
];
2569 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2573 if (get_amp_nid_(val
))
2574 knew
->subdevice
= HDA_SUBDEV_AMP_FLAG
;
2575 knew
->private_value
= val
;
2579 static int add_control_with_pfx(struct alc_spec
*spec
, int type
,
2580 const char *pfx
, const char *dir
,
2581 const char *sfx
, int cidx
, unsigned long val
)
2584 snprintf(name
, sizeof(name
), "%s %s %s", pfx
, dir
, sfx
);
2585 return add_control(spec
, type
, name
, cidx
, val
);
2588 #define add_pb_vol_ctrl(spec, type, pfx, val) \
2589 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
2590 #define add_pb_sw_ctrl(spec, type, pfx, val) \
2591 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
2592 #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
2593 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
2594 #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
2595 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
2597 static const char * const channel_name
[4] = {
2598 "Front", "Surround", "CLFE", "Side"
2601 static const char *alc_get_line_out_pfx(struct alc_spec
*spec
, int ch
,
2602 bool can_be_master
, int *index
)
2604 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2607 if (cfg
->line_outs
== 1 && !spec
->multi_ios
&&
2608 !cfg
->hp_outs
&& !cfg
->speaker_outs
&& can_be_master
)
2611 switch (cfg
->line_out_type
) {
2612 case AUTO_PIN_SPEAKER_OUT
:
2613 if (cfg
->line_outs
== 1)
2615 if (cfg
->line_outs
== 2)
2616 return ch
? "Bass Speaker" : "Speaker";
2618 case AUTO_PIN_HP_OUT
:
2619 /* for multi-io case, only the primary out */
2620 if (ch
&& spec
->multi_ios
)
2625 if (cfg
->line_outs
== 1 && !spec
->multi_ios
)
2629 if (snd_BUG_ON(ch
>= ARRAY_SIZE(channel_name
)))
2632 return channel_name
[ch
];
2635 #ifdef CONFIG_SND_HDA_POWER_SAVE
2636 /* add the powersave loopback-list entry */
2637 static void add_loopback_list(struct alc_spec
*spec
, hda_nid_t mix
, int idx
)
2639 struct hda_amp_list
*list
;
2641 if (spec
->num_loopbacks
>= ARRAY_SIZE(spec
->loopback_list
) - 1)
2643 list
= spec
->loopback_list
+ spec
->num_loopbacks
;
2645 list
->dir
= HDA_INPUT
;
2647 spec
->num_loopbacks
++;
2648 spec
->loopback
.amplist
= spec
->loopback_list
;
2651 #define add_loopback_list(spec, mix, idx) /* NOP */
2654 /* create input playback/capture controls for the given pin */
2655 static int new_analog_input(struct alc_spec
*spec
, hda_nid_t pin
,
2656 const char *ctlname
, int ctlidx
,
2657 int idx
, hda_nid_t mix_nid
)
2661 err
= __add_pb_vol_ctrl(spec
, ALC_CTL_WIDGET_VOL
, ctlname
, ctlidx
,
2662 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
));
2665 err
= __add_pb_sw_ctrl(spec
, ALC_CTL_WIDGET_MUTE
, ctlname
, ctlidx
,
2666 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
));
2669 add_loopback_list(spec
, mix_nid
, idx
);
2673 static int alc_is_input_pin(struct hda_codec
*codec
, hda_nid_t nid
)
2675 unsigned int pincap
= snd_hda_query_pin_caps(codec
, nid
);
2676 return (pincap
& AC_PINCAP_IN
) != 0;
2679 /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */
2680 static int alc_auto_fill_adc_caps(struct hda_codec
*codec
)
2682 struct alc_spec
*spec
= codec
->spec
;
2684 hda_nid_t
*adc_nids
= spec
->private_adc_nids
;
2685 hda_nid_t
*cap_nids
= spec
->private_capsrc_nids
;
2686 int max_nums
= ARRAY_SIZE(spec
->private_adc_nids
);
2689 nid
= codec
->start_nid
;
2690 for (i
= 0; i
< codec
->num_nodes
; i
++, nid
++) {
2692 unsigned int caps
= get_wcaps(codec
, nid
);
2693 int type
= get_wcaps_type(caps
);
2695 if (type
!= AC_WID_AUD_IN
|| (caps
& AC_WCAP_DIGITAL
))
2697 adc_nids
[nums
] = nid
;
2698 cap_nids
[nums
] = nid
;
2702 type
= get_wcaps_type(get_wcaps(codec
, src
));
2703 if (type
== AC_WID_PIN
)
2705 if (type
== AC_WID_AUD_SEL
) {
2706 cap_nids
[nums
] = src
;
2709 n
= snd_hda_get_num_conns(codec
, src
);
2711 cap_nids
[nums
] = src
;
2715 if (snd_hda_get_connections(codec
, src
, &src
, 1) != 1)
2718 if (++nums
>= max_nums
)
2721 spec
->adc_nids
= spec
->private_adc_nids
;
2722 spec
->capsrc_nids
= spec
->private_capsrc_nids
;
2723 spec
->num_adc_nids
= nums
;
2727 /* create playback/capture controls for input pins */
2728 static int alc_auto_create_input_ctls(struct hda_codec
*codec
)
2730 struct alc_spec
*spec
= codec
->spec
;
2731 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2732 hda_nid_t mixer
= spec
->mixer_nid
;
2733 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
2735 int i
, c
, err
, idx
, type_idx
= 0;
2736 const char *prev_label
= NULL
;
2738 num_adcs
= alc_auto_fill_adc_caps(codec
);
2742 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2746 pin
= cfg
->inputs
[i
].pin
;
2747 if (!alc_is_input_pin(codec
, pin
))
2750 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
2751 if (spec
->shared_mic_hp
&& !strcmp(label
, "Misc"))
2752 label
= "Headphone Mic";
2753 if (prev_label
&& !strcmp(label
, prev_label
))
2760 idx
= get_connection_index(codec
, mixer
, pin
);
2762 err
= new_analog_input(spec
, pin
,
2770 for (c
= 0; c
< num_adcs
; c
++) {
2771 hda_nid_t cap
= get_capsrc(spec
, c
);
2772 idx
= get_connection_index(codec
, cap
, pin
);
2774 spec
->imux_pins
[imux
->num_items
] = pin
;
2775 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
2781 spec
->num_mux_defs
= 1;
2782 spec
->input_mux
= imux
;
2787 /* create a shared input with the headphone out */
2788 static int alc_auto_create_shared_input(struct hda_codec
*codec
)
2790 struct alc_spec
*spec
= codec
->spec
;
2791 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2792 unsigned int defcfg
;
2795 /* only one internal input pin? */
2796 if (cfg
->num_inputs
!= 1)
2798 defcfg
= snd_hda_codec_get_pincfg(codec
, cfg
->inputs
[0].pin
);
2799 if (snd_hda_get_input_pin_attr(defcfg
) != INPUT_PIN_ATTR_INT
)
2802 if (cfg
->hp_outs
== 1 && cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
)
2803 nid
= cfg
->hp_pins
[0]; /* OK, we have a single HP-out */
2804 else if (cfg
->line_outs
== 1 && cfg
->line_out_type
== AUTO_PIN_HP_OUT
)
2805 nid
= cfg
->line_out_pins
[0]; /* OK, we have a single line-out */
2807 return 0; /* both not available */
2809 if (!(snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_IN
))
2810 return 0; /* no input */
2812 cfg
->inputs
[1].pin
= nid
;
2813 cfg
->inputs
[1].type
= AUTO_PIN_MIC
;
2814 cfg
->num_inputs
= 2;
2815 spec
->shared_mic_hp
= 1;
2816 snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid
);
2820 static void alc_set_pin_output(struct hda_codec
*codec
, hda_nid_t nid
,
2821 unsigned int pin_type
)
2823 snd_hda_set_pin_ctl(codec
, nid
, pin_type
);
2825 if (nid_has_mute(codec
, nid
, HDA_OUTPUT
))
2826 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
2830 static int get_pin_type(int line_out_type
)
2832 if (line_out_type
== AUTO_PIN_HP_OUT
)
2838 static void alc_auto_init_analog_input(struct hda_codec
*codec
)
2840 struct alc_spec
*spec
= codec
->spec
;
2841 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2844 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2845 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
2846 if (alc_is_input_pin(codec
, nid
)) {
2847 alc_set_input_pin(codec
, nid
, cfg
->inputs
[i
].type
);
2848 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
2849 snd_hda_codec_write(codec
, nid
, 0,
2850 AC_VERB_SET_AMP_GAIN_MUTE
,
2855 /* mute all loopback inputs */
2856 if (spec
->mixer_nid
) {
2857 int nums
= snd_hda_get_num_conns(codec
, spec
->mixer_nid
);
2858 for (i
= 0; i
< nums
; i
++)
2859 snd_hda_codec_write(codec
, spec
->mixer_nid
, 0,
2860 AC_VERB_SET_AMP_GAIN_MUTE
,
2865 /* convert from MIX nid to DAC */
2866 static hda_nid_t
alc_auto_mix_to_dac(struct hda_codec
*codec
, hda_nid_t nid
)
2871 if (get_wcaps_type(get_wcaps(codec
, nid
)) == AC_WID_AUD_OUT
)
2873 num
= snd_hda_get_connections(codec
, nid
, list
, ARRAY_SIZE(list
));
2874 for (i
= 0; i
< num
; i
++) {
2875 if (get_wcaps_type(get_wcaps(codec
, list
[i
])) == AC_WID_AUD_OUT
)
2881 /* go down to the selector widget before the mixer */
2882 static hda_nid_t
alc_go_down_to_selector(struct hda_codec
*codec
, hda_nid_t pin
)
2885 int num
= snd_hda_get_connections(codec
, pin
, srcs
,
2888 get_wcaps_type(get_wcaps(codec
, srcs
[0])) != AC_WID_AUD_SEL
)
2893 /* get MIX nid connected to the given pin targeted to DAC */
2894 static hda_nid_t
alc_auto_dac_to_mix(struct hda_codec
*codec
, hda_nid_t pin
,
2900 pin
= alc_go_down_to_selector(codec
, pin
);
2901 num
= snd_hda_get_connections(codec
, pin
, mix
, ARRAY_SIZE(mix
));
2902 for (i
= 0; i
< num
; i
++) {
2903 if (alc_auto_mix_to_dac(codec
, mix
[i
]) == dac
)
2909 /* select the connection from pin to DAC if needed */
2910 static int alc_auto_select_dac(struct hda_codec
*codec
, hda_nid_t pin
,
2916 pin
= alc_go_down_to_selector(codec
, pin
);
2917 num
= snd_hda_get_connections(codec
, pin
, mix
, ARRAY_SIZE(mix
));
2920 for (i
= 0; i
< num
; i
++) {
2921 if (alc_auto_mix_to_dac(codec
, mix
[i
]) == dac
) {
2922 snd_hda_codec_update_cache(codec
, pin
, 0,
2923 AC_VERB_SET_CONNECT_SEL
, i
);
2930 static bool alc_is_dac_already_used(struct hda_codec
*codec
, hda_nid_t nid
)
2932 struct alc_spec
*spec
= codec
->spec
;
2934 if (found_in_nid_list(nid
, spec
->multiout
.dac_nids
,
2935 ARRAY_SIZE(spec
->private_dac_nids
)) ||
2936 found_in_nid_list(nid
, spec
->multiout
.hp_out_nid
,
2937 ARRAY_SIZE(spec
->multiout
.hp_out_nid
)) ||
2938 found_in_nid_list(nid
, spec
->multiout
.extra_out_nid
,
2939 ARRAY_SIZE(spec
->multiout
.extra_out_nid
)))
2941 for (i
= 0; i
< spec
->multi_ios
; i
++) {
2942 if (spec
->multi_io
[i
].dac
== nid
)
2948 /* look for an empty DAC slot */
2949 static hda_nid_t
alc_auto_look_for_dac(struct hda_codec
*codec
, hda_nid_t pin
)
2954 pin
= alc_go_down_to_selector(codec
, pin
);
2955 num
= snd_hda_get_connections(codec
, pin
, srcs
, ARRAY_SIZE(srcs
));
2956 for (i
= 0; i
< num
; i
++) {
2957 hda_nid_t nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
2960 if (!alc_is_dac_already_used(codec
, nid
))
2966 /* check whether the DAC is reachable from the pin */
2967 static bool alc_auto_is_dac_reachable(struct hda_codec
*codec
,
2968 hda_nid_t pin
, hda_nid_t dac
)
2975 pin
= alc_go_down_to_selector(codec
, pin
);
2976 num
= snd_hda_get_connections(codec
, pin
, srcs
, ARRAY_SIZE(srcs
));
2977 for (i
= 0; i
< num
; i
++) {
2978 hda_nid_t nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
2985 static hda_nid_t
get_dac_if_single(struct hda_codec
*codec
, hda_nid_t pin
)
2987 struct alc_spec
*spec
= codec
->spec
;
2988 hda_nid_t sel
= alc_go_down_to_selector(codec
, pin
);
2989 hda_nid_t nid
, nid_found
, srcs
[5];
2990 int i
, num
= snd_hda_get_connections(codec
, sel
, srcs
,
2993 return alc_auto_look_for_dac(codec
, pin
);
2995 for (i
= 0; i
< num
; i
++) {
2996 if (srcs
[i
] == spec
->mixer_nid
)
2998 nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
2999 if (nid
&& !alc_is_dac_already_used(codec
, nid
)) {
3008 /* mark up volume and mute control NIDs: used during badness parsing and
3009 * at creating actual controls
3011 static inline unsigned int get_ctl_pos(unsigned int data
)
3013 hda_nid_t nid
= get_amp_nid_(data
);
3015 if (snd_BUG_ON(nid
>= MAX_VOL_NIDS
))
3017 dir
= get_amp_direction_(data
);
3018 return (nid
<< 1) | dir
;
3021 #define is_ctl_used(bits, data) \
3022 test_bit(get_ctl_pos(data), bits)
3023 #define mark_ctl_usage(bits, data) \
3024 set_bit(get_ctl_pos(data), bits)
3026 static void clear_vol_marks(struct hda_codec
*codec
)
3028 struct alc_spec
*spec
= codec
->spec
;
3029 memset(spec
->vol_ctls
, 0, sizeof(spec
->vol_ctls
));
3030 memset(spec
->sw_ctls
, 0, sizeof(spec
->sw_ctls
));
3033 /* badness definition */
3035 /* No primary DAC is found for the main output */
3036 BAD_NO_PRIMARY_DAC
= 0x10000,
3037 /* No DAC is found for the extra output */
3038 BAD_NO_DAC
= 0x4000,
3039 /* No possible multi-ios */
3040 BAD_MULTI_IO
= 0x103,
3041 /* No individual DAC for extra output */
3042 BAD_NO_EXTRA_DAC
= 0x102,
3043 /* No individual DAC for extra surrounds */
3044 BAD_NO_EXTRA_SURR_DAC
= 0x101,
3045 /* Primary DAC shared with main surrounds */
3046 BAD_SHARED_SURROUND
= 0x100,
3047 /* Primary DAC shared with main CLFE */
3048 BAD_SHARED_CLFE
= 0x10,
3049 /* Primary DAC shared with extra surrounds */
3050 BAD_SHARED_EXTRA_SURROUND
= 0x10,
3051 /* Volume widget is shared */
3052 BAD_SHARED_VOL
= 0x10,
3055 static hda_nid_t
alc_look_for_out_mute_nid(struct hda_codec
*codec
,
3056 hda_nid_t pin
, hda_nid_t dac
);
3057 static hda_nid_t
alc_look_for_out_vol_nid(struct hda_codec
*codec
,
3058 hda_nid_t pin
, hda_nid_t dac
);
3060 static int eval_shared_vol_badness(struct hda_codec
*codec
, hda_nid_t pin
,
3063 struct alc_spec
*spec
= codec
->spec
;
3068 nid
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3070 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
3071 if (is_ctl_used(spec
->vol_ctls
, nid
))
3072 badness
+= BAD_SHARED_VOL
;
3074 mark_ctl_usage(spec
->vol_ctls
, val
);
3076 badness
+= BAD_SHARED_VOL
;
3077 nid
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3079 unsigned int wid_type
= get_wcaps_type(get_wcaps(codec
, nid
));
3080 if (wid_type
== AC_WID_PIN
|| wid_type
== AC_WID_AUD_OUT
)
3081 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
3083 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_INPUT
);
3084 if (is_ctl_used(spec
->sw_ctls
, val
))
3085 badness
+= BAD_SHARED_VOL
;
3087 mark_ctl_usage(spec
->sw_ctls
, val
);
3089 badness
+= BAD_SHARED_VOL
;
3093 struct badness_table
{
3094 int no_primary_dac
; /* no primary DAC */
3095 int no_dac
; /* no secondary DACs */
3096 int shared_primary
; /* primary DAC is shared with main output */
3097 int shared_surr
; /* secondary DAC shared with main or primary */
3098 int shared_clfe
; /* third DAC shared with main or primary */
3099 int shared_surr_main
; /* secondary DAC sahred with main/DAC0 */
3102 static struct badness_table main_out_badness
= {
3103 .no_primary_dac
= BAD_NO_PRIMARY_DAC
,
3104 .no_dac
= BAD_NO_DAC
,
3105 .shared_primary
= BAD_NO_PRIMARY_DAC
,
3106 .shared_surr
= BAD_SHARED_SURROUND
,
3107 .shared_clfe
= BAD_SHARED_CLFE
,
3108 .shared_surr_main
= BAD_SHARED_SURROUND
,
3111 static struct badness_table extra_out_badness
= {
3112 .no_primary_dac
= BAD_NO_DAC
,
3113 .no_dac
= BAD_NO_DAC
,
3114 .shared_primary
= BAD_NO_EXTRA_DAC
,
3115 .shared_surr
= BAD_SHARED_EXTRA_SURROUND
,
3116 .shared_clfe
= BAD_SHARED_EXTRA_SURROUND
,
3117 .shared_surr_main
= BAD_NO_EXTRA_SURR_DAC
,
3120 /* try to assign DACs to pins and return the resultant badness */
3121 static int alc_auto_fill_dacs(struct hda_codec
*codec
, int num_outs
,
3122 const hda_nid_t
*pins
, hda_nid_t
*dacs
,
3123 const struct badness_table
*bad
)
3125 struct alc_spec
*spec
= codec
->spec
;
3126 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3134 for (i
= 0; i
< num_outs
; i
++) {
3135 hda_nid_t pin
= pins
[i
];
3137 dacs
[i
] = alc_auto_look_for_dac(codec
, pin
);
3138 if (!dacs
[i
] && !i
) {
3139 for (j
= 1; j
< num_outs
; j
++) {
3140 if (alc_auto_is_dac_reachable(codec
, pin
, dacs
[j
])) {
3149 if (alc_auto_is_dac_reachable(codec
, pin
, dacs
[0]))
3151 else if (cfg
->line_outs
> i
&&
3152 alc_auto_is_dac_reachable(codec
, pin
,
3153 spec
->private_dac_nids
[i
]))
3154 dac
= spec
->private_dac_nids
[i
];
3157 badness
+= bad
->shared_primary
;
3159 badness
+= bad
->shared_surr
;
3161 badness
+= bad
->shared_clfe
;
3162 } else if (alc_auto_is_dac_reachable(codec
, pin
,
3163 spec
->private_dac_nids
[0])) {
3164 dac
= spec
->private_dac_nids
[0];
3165 badness
+= bad
->shared_surr_main
;
3167 badness
+= bad
->no_primary_dac
;
3169 badness
+= bad
->no_dac
;
3172 badness
+= eval_shared_vol_badness(codec
, pin
, dac
);
3178 static int alc_auto_fill_multi_ios(struct hda_codec
*codec
,
3179 hda_nid_t reference_pin
,
3180 bool hardwired
, int offset
);
3182 static bool alc_map_singles(struct hda_codec
*codec
, int outs
,
3183 const hda_nid_t
*pins
, hda_nid_t
*dacs
)
3187 for (i
= 0; i
< outs
; i
++) {
3190 dacs
[i
] = get_dac_if_single(codec
, pins
[i
]);
3197 /* fill in the dac_nids table from the parsed pin configuration */
3198 static int fill_and_eval_dacs(struct hda_codec
*codec
,
3199 bool fill_hardwired
,
3200 bool fill_mio_first
)
3202 struct alc_spec
*spec
= codec
->spec
;
3203 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3204 int i
, err
, badness
;
3206 /* set num_dacs once to full for alc_auto_look_for_dac() */
3207 spec
->multiout
.num_dacs
= cfg
->line_outs
;
3208 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3209 memset(spec
->private_dac_nids
, 0, sizeof(spec
->private_dac_nids
));
3210 memset(spec
->multiout
.hp_out_nid
, 0, sizeof(spec
->multiout
.hp_out_nid
));
3211 memset(spec
->multiout
.extra_out_nid
, 0, sizeof(spec
->multiout
.extra_out_nid
));
3212 spec
->multi_ios
= 0;
3213 clear_vol_marks(codec
);
3216 /* fill hard-wired DACs first */
3217 if (fill_hardwired
) {
3220 mapped
= alc_map_singles(codec
, cfg
->line_outs
,
3222 spec
->private_dac_nids
);
3223 mapped
|= alc_map_singles(codec
, cfg
->hp_outs
,
3225 spec
->multiout
.hp_out_nid
);
3226 mapped
|= alc_map_singles(codec
, cfg
->speaker_outs
,
3228 spec
->multiout
.extra_out_nid
);
3229 if (fill_mio_first
&& cfg
->line_outs
== 1 &&
3230 cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3231 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], true, 0);
3238 badness
+= alc_auto_fill_dacs(codec
, cfg
->line_outs
, cfg
->line_out_pins
,
3239 spec
->private_dac_nids
,
3242 /* re-count num_dacs and squash invalid entries */
3243 spec
->multiout
.num_dacs
= 0;
3244 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3245 if (spec
->private_dac_nids
[i
])
3246 spec
->multiout
.num_dacs
++;
3248 memmove(spec
->private_dac_nids
+ i
,
3249 spec
->private_dac_nids
+ i
+ 1,
3250 sizeof(hda_nid_t
) * (cfg
->line_outs
- i
- 1));
3251 spec
->private_dac_nids
[cfg
->line_outs
- 1] = 0;
3255 if (fill_mio_first
&&
3256 cfg
->line_outs
== 1 && cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3257 /* try to fill multi-io first */
3258 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], false, 0);
3261 /* we don't count badness at this stage yet */
3264 if (cfg
->line_out_type
!= AUTO_PIN_HP_OUT
) {
3265 err
= alc_auto_fill_dacs(codec
, cfg
->hp_outs
, cfg
->hp_pins
,
3266 spec
->multiout
.hp_out_nid
,
3267 &extra_out_badness
);
3272 if (cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3273 err
= alc_auto_fill_dacs(codec
, cfg
->speaker_outs
,
3275 spec
->multiout
.extra_out_nid
,
3276 &extra_out_badness
);
3281 if (cfg
->line_outs
== 1 && cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3282 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], false, 0);
3287 if (cfg
->hp_outs
&& cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
3288 /* try multi-ios with HP + inputs */
3290 if (cfg
->line_outs
>= 3)
3292 err
= alc_auto_fill_multi_ios(codec
, cfg
->hp_pins
[0], false,
3299 if (spec
->multi_ios
== 2) {
3300 for (i
= 0; i
< 2; i
++)
3301 spec
->private_dac_nids
[spec
->multiout
.num_dacs
++] =
3302 spec
->multi_io
[i
].dac
;
3303 spec
->ext_channel_count
= 2;
3304 } else if (spec
->multi_ios
) {
3305 spec
->multi_ios
= 0;
3306 badness
+= BAD_MULTI_IO
;
3312 #define DEBUG_BADNESS
3314 #ifdef DEBUG_BADNESS
3315 #define debug_badness snd_printdd
3317 #define debug_badness(...)
3320 static void debug_show_configs(struct alc_spec
*spec
, struct auto_pin_cfg
*cfg
)
3322 debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3323 cfg
->line_out_pins
[0], cfg
->line_out_pins
[1],
3324 cfg
->line_out_pins
[2], cfg
->line_out_pins
[2],
3325 spec
->multiout
.dac_nids
[0],
3326 spec
->multiout
.dac_nids
[1],
3327 spec
->multiout
.dac_nids
[2],
3328 spec
->multiout
.dac_nids
[3]);
3329 if (spec
->multi_ios
> 0)
3330 debug_badness("multi_ios(%d) = %x/%x : %x/%x\n",
3332 spec
->multi_io
[0].pin
, spec
->multi_io
[1].pin
,
3333 spec
->multi_io
[0].dac
, spec
->multi_io
[1].dac
);
3334 debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3335 cfg
->hp_pins
[0], cfg
->hp_pins
[1],
3336 cfg
->hp_pins
[2], cfg
->hp_pins
[2],
3337 spec
->multiout
.hp_out_nid
[0],
3338 spec
->multiout
.hp_out_nid
[1],
3339 spec
->multiout
.hp_out_nid
[2],
3340 spec
->multiout
.hp_out_nid
[3]);
3341 debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3342 cfg
->speaker_pins
[0], cfg
->speaker_pins
[1],
3343 cfg
->speaker_pins
[2], cfg
->speaker_pins
[3],
3344 spec
->multiout
.extra_out_nid
[0],
3345 spec
->multiout
.extra_out_nid
[1],
3346 spec
->multiout
.extra_out_nid
[2],
3347 spec
->multiout
.extra_out_nid
[3]);
3350 static int alc_auto_fill_dac_nids(struct hda_codec
*codec
)
3352 struct alc_spec
*spec
= codec
->spec
;
3353 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3354 struct auto_pin_cfg
*best_cfg
;
3355 int best_badness
= INT_MAX
;
3357 bool fill_hardwired
= true, fill_mio_first
= true;
3358 bool best_wired
= true, best_mio
= true;
3359 bool hp_spk_swapped
= false;
3361 best_cfg
= kmalloc(sizeof(*best_cfg
), GFP_KERNEL
);
3367 badness
= fill_and_eval_dacs(codec
, fill_hardwired
,
3373 debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n",
3374 cfg
->line_out_type
, fill_hardwired
, fill_mio_first
,
3376 debug_show_configs(spec
, cfg
);
3377 if (badness
< best_badness
) {
3378 best_badness
= badness
;
3380 best_wired
= fill_hardwired
;
3381 best_mio
= fill_mio_first
;
3385 fill_mio_first
= !fill_mio_first
;
3386 if (!fill_mio_first
)
3388 fill_hardwired
= !fill_hardwired
;
3389 if (!fill_hardwired
)
3393 hp_spk_swapped
= true;
3394 if (cfg
->speaker_outs
> 0 &&
3395 cfg
->line_out_type
== AUTO_PIN_HP_OUT
) {
3396 cfg
->hp_outs
= cfg
->line_outs
;
3397 memcpy(cfg
->hp_pins
, cfg
->line_out_pins
,
3398 sizeof(cfg
->hp_pins
));
3399 cfg
->line_outs
= cfg
->speaker_outs
;
3400 memcpy(cfg
->line_out_pins
, cfg
->speaker_pins
,
3401 sizeof(cfg
->speaker_pins
));
3402 cfg
->speaker_outs
= 0;
3403 memset(cfg
->speaker_pins
, 0, sizeof(cfg
->speaker_pins
));
3404 cfg
->line_out_type
= AUTO_PIN_SPEAKER_OUT
;
3405 fill_hardwired
= true;
3408 if (cfg
->hp_outs
> 0 &&
3409 cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
3410 cfg
->speaker_outs
= cfg
->line_outs
;
3411 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
3412 sizeof(cfg
->speaker_pins
));
3413 cfg
->line_outs
= cfg
->hp_outs
;
3414 memcpy(cfg
->line_out_pins
, cfg
->hp_pins
,
3415 sizeof(cfg
->hp_pins
));
3417 memset(cfg
->hp_pins
, 0, sizeof(cfg
->hp_pins
));
3418 cfg
->line_out_type
= AUTO_PIN_HP_OUT
;
3419 fill_hardwired
= true;
3427 fill_and_eval_dacs(codec
, best_wired
, best_mio
);
3429 debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n",
3430 cfg
->line_out_type
, best_wired
, best_mio
);
3431 debug_show_configs(spec
, cfg
);
3433 if (cfg
->line_out_pins
[0])
3435 alc_look_for_out_vol_nid(codec
, cfg
->line_out_pins
[0],
3436 spec
->multiout
.dac_nids
[0]);
3438 /* clear the bitmap flags for creating controls */
3439 clear_vol_marks(codec
);
3444 static int alc_auto_add_vol_ctl(struct hda_codec
*codec
,
3445 const char *pfx
, int cidx
,
3446 hda_nid_t nid
, unsigned int chs
)
3448 struct alc_spec
*spec
= codec
->spec
;
3452 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
);
3453 if (is_ctl_used(spec
->vol_ctls
, val
) && chs
!= 2) /* exclude LFE */
3455 mark_ctl_usage(spec
->vol_ctls
, val
);
3456 return __add_pb_vol_ctrl(codec
->spec
, ALC_CTL_WIDGET_VOL
, pfx
, cidx
,
3460 static int alc_auto_add_stereo_vol(struct hda_codec
*codec
,
3461 const char *pfx
, int cidx
,
3465 if (get_wcaps(codec
, nid
) & AC_WCAP_STEREO
)
3467 return alc_auto_add_vol_ctl(codec
, pfx
, cidx
, nid
, chs
);
3470 /* create a mute-switch for the given mixer widget;
3471 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
3473 static int alc_auto_add_sw_ctl(struct hda_codec
*codec
,
3474 const char *pfx
, int cidx
,
3475 hda_nid_t nid
, unsigned int chs
)
3477 struct alc_spec
*spec
= codec
->spec
;
3483 wid_type
= get_wcaps_type(get_wcaps(codec
, nid
));
3484 if (wid_type
== AC_WID_PIN
|| wid_type
== AC_WID_AUD_OUT
) {
3485 type
= ALC_CTL_WIDGET_MUTE
;
3486 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
);
3487 } else if (snd_hda_get_num_conns(codec
, nid
) == 1) {
3488 type
= ALC_CTL_WIDGET_MUTE
;
3489 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_INPUT
);
3491 type
= ALC_CTL_BIND_MUTE
;
3492 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 2, HDA_INPUT
);
3494 if (is_ctl_used(spec
->sw_ctls
, val
) && chs
!= 2) /* exclude LFE */
3496 mark_ctl_usage(spec
->sw_ctls
, val
);
3497 return __add_pb_sw_ctrl(codec
->spec
, type
, pfx
, cidx
, val
);
3500 static int alc_auto_add_stereo_sw(struct hda_codec
*codec
, const char *pfx
,
3501 int cidx
, hda_nid_t nid
)
3504 if (get_wcaps(codec
, nid
) & AC_WCAP_STEREO
)
3506 return alc_auto_add_sw_ctl(codec
, pfx
, cidx
, nid
, chs
);
3509 static hda_nid_t
alc_look_for_out_mute_nid(struct hda_codec
*codec
,
3510 hda_nid_t pin
, hda_nid_t dac
)
3512 hda_nid_t mix
= alc_auto_dac_to_mix(codec
, pin
, dac
);
3513 if (nid_has_mute(codec
, pin
, HDA_OUTPUT
))
3515 else if (mix
&& nid_has_mute(codec
, mix
, HDA_INPUT
))
3517 else if (nid_has_mute(codec
, dac
, HDA_OUTPUT
))
3522 static hda_nid_t
alc_look_for_out_vol_nid(struct hda_codec
*codec
,
3523 hda_nid_t pin
, hda_nid_t dac
)
3525 hda_nid_t mix
= alc_auto_dac_to_mix(codec
, pin
, dac
);
3526 if (nid_has_volume(codec
, dac
, HDA_OUTPUT
))
3528 else if (nid_has_volume(codec
, mix
, HDA_OUTPUT
))
3530 else if (nid_has_volume(codec
, pin
, HDA_OUTPUT
))
3535 /* add playback controls from the parsed DAC table */
3536 static int alc_auto_create_multi_out_ctls(struct hda_codec
*codec
,
3537 const struct auto_pin_cfg
*cfg
)
3539 struct alc_spec
*spec
= codec
->spec
;
3540 int i
, err
, noutputs
;
3542 noutputs
= cfg
->line_outs
;
3543 if (spec
->multi_ios
> 0 && cfg
->line_outs
< 3)
3544 noutputs
+= spec
->multi_ios
;
3546 for (i
= 0; i
< noutputs
; i
++) {
3552 dac
= spec
->multiout
.dac_nids
[i
];
3555 if (i
>= cfg
->line_outs
) {
3556 pin
= spec
->multi_io
[i
- 1].pin
;
3558 name
= channel_name
[i
];
3560 pin
= cfg
->line_out_pins
[i
];
3561 name
= alc_get_line_out_pfx(spec
, i
, true, &index
);
3564 sw
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3565 vol
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3566 if (!name
|| !strcmp(name
, "CLFE")) {
3568 err
= alc_auto_add_vol_ctl(codec
, "Center", 0, vol
, 1);
3571 err
= alc_auto_add_vol_ctl(codec
, "LFE", 0, vol
, 2);
3574 err
= alc_auto_add_sw_ctl(codec
, "Center", 0, sw
, 1);
3577 err
= alc_auto_add_sw_ctl(codec
, "LFE", 0, sw
, 2);
3581 err
= alc_auto_add_stereo_vol(codec
, name
, index
, vol
);
3584 err
= alc_auto_add_stereo_sw(codec
, name
, index
, sw
);
3592 static int alc_auto_create_extra_out(struct hda_codec
*codec
, hda_nid_t pin
,
3593 hda_nid_t dac
, const char *pfx
,
3596 struct alc_spec
*spec
= codec
->spec
;
3602 /* the corresponding DAC is already occupied */
3603 if (!(get_wcaps(codec
, pin
) & AC_WCAP_OUT_AMP
))
3604 return 0; /* no way */
3605 /* create a switch only */
3606 val
= HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
);
3607 if (is_ctl_used(spec
->sw_ctls
, val
))
3608 return 0; /* already created */
3609 mark_ctl_usage(spec
->sw_ctls
, val
);
3610 return __add_pb_sw_ctrl(spec
, ALC_CTL_WIDGET_MUTE
, pfx
, cidx
, val
);
3613 sw
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3614 vol
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3615 err
= alc_auto_add_stereo_vol(codec
, pfx
, cidx
, vol
);
3618 err
= alc_auto_add_stereo_sw(codec
, pfx
, cidx
, sw
);
3624 static struct hda_bind_ctls
*new_bind_ctl(struct hda_codec
*codec
,
3626 struct hda_ctl_ops
*ops
)
3628 struct alc_spec
*spec
= codec
->spec
;
3629 struct hda_bind_ctls
**ctlp
, *ctl
;
3630 snd_array_init(&spec
->bind_ctls
, sizeof(ctl
), 8);
3631 ctlp
= snd_array_new(&spec
->bind_ctls
);
3634 ctl
= kzalloc(sizeof(*ctl
) + sizeof(long) * (nums
+ 1), GFP_KERNEL
);
3641 /* add playback controls for speaker and HP outputs */
3642 static int alc_auto_create_extra_outs(struct hda_codec
*codec
, int num_pins
,
3643 const hda_nid_t
*pins
,
3644 const hda_nid_t
*dacs
,
3647 struct alc_spec
*spec
= codec
->spec
;
3648 struct hda_bind_ctls
*ctl
;
3652 if (!num_pins
|| !pins
[0])
3655 if (num_pins
== 1) {
3656 hda_nid_t dac
= *dacs
;
3658 dac
= spec
->multiout
.dac_nids
[0];
3659 return alc_auto_create_extra_out(codec
, *pins
, dac
, pfx
, 0);
3662 for (i
= 0; i
< num_pins
; i
++) {
3664 if (dacs
[num_pins
- 1])
3665 dac
= dacs
[i
]; /* with individual volumes */
3668 if (num_pins
== 2 && i
== 1 && !strcmp(pfx
, "Speaker")) {
3669 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3671 } else if (num_pins
>= 3) {
3672 snprintf(name
, sizeof(name
), "%s %s",
3673 pfx
, channel_name
[i
]);
3674 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3677 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3683 if (dacs
[num_pins
- 1])
3686 /* Let's create a bind-controls for volumes */
3687 ctl
= new_bind_ctl(codec
, num_pins
, &snd_hda_bind_vol
);
3691 for (i
= 0; i
< num_pins
; i
++) {
3693 if (!pins
[i
] || !dacs
[i
])
3695 vol
= alc_look_for_out_vol_nid(codec
, pins
[i
], dacs
[i
]);
3698 HDA_COMPOSE_AMP_VAL(vol
, 3, 0, HDA_OUTPUT
);
3701 snprintf(name
, sizeof(name
), "%s Playback Volume", pfx
);
3702 err
= add_control(spec
, ALC_CTL_BIND_VOL
, name
, 0, (long)ctl
);
3709 static int alc_auto_create_hp_out(struct hda_codec
*codec
)
3711 struct alc_spec
*spec
= codec
->spec
;
3712 return alc_auto_create_extra_outs(codec
, spec
->autocfg
.hp_outs
,
3713 spec
->autocfg
.hp_pins
,
3714 spec
->multiout
.hp_out_nid
,
3718 static int alc_auto_create_speaker_out(struct hda_codec
*codec
)
3720 struct alc_spec
*spec
= codec
->spec
;
3721 return alc_auto_create_extra_outs(codec
, spec
->autocfg
.speaker_outs
,
3722 spec
->autocfg
.speaker_pins
,
3723 spec
->multiout
.extra_out_nid
,
3727 static void alc_auto_set_output_and_unmute(struct hda_codec
*codec
,
3728 hda_nid_t pin
, int pin_type
,
3732 hda_nid_t nid
, mix
= 0;
3733 hda_nid_t srcs
[HDA_MAX_CONNECTIONS
];
3735 alc_set_pin_output(codec
, pin
, pin_type
);
3736 nid
= alc_go_down_to_selector(codec
, pin
);
3737 num
= snd_hda_get_connections(codec
, nid
, srcs
, ARRAY_SIZE(srcs
));
3738 for (i
= 0; i
< num
; i
++) {
3739 if (alc_auto_mix_to_dac(codec
, srcs
[i
]) != dac
)
3747 /* need the manual connection? */
3749 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_CONNECT_SEL
, i
);
3750 /* unmute mixer widget inputs */
3751 if (nid_has_mute(codec
, mix
, HDA_INPUT
)) {
3752 snd_hda_codec_write(codec
, mix
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3754 snd_hda_codec_write(codec
, mix
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3757 /* initialize volume */
3758 nid
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3760 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3763 /* unmute DAC if it's not assigned to a mixer */
3764 nid
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3765 if (nid
== mix
&& nid_has_mute(codec
, dac
, HDA_OUTPUT
))
3766 snd_hda_codec_write(codec
, dac
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3770 static void alc_auto_init_multi_out(struct hda_codec
*codec
)
3772 struct alc_spec
*spec
= codec
->spec
;
3773 int pin_type
= get_pin_type(spec
->autocfg
.line_out_type
);
3776 for (i
= 0; i
<= HDA_SIDE
; i
++) {
3777 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
3779 alc_auto_set_output_and_unmute(codec
, nid
, pin_type
,
3780 spec
->multiout
.dac_nids
[i
]);
3784 static void alc_auto_init_extra_out(struct hda_codec
*codec
)
3786 struct alc_spec
*spec
= codec
->spec
;
3790 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
3791 if (spec
->autocfg
.line_out_type
== AUTO_PIN_HP_OUT
)
3793 pin
= spec
->autocfg
.hp_pins
[i
];
3796 dac
= spec
->multiout
.hp_out_nid
[i
];
3798 if (i
> 0 && spec
->multiout
.hp_out_nid
[0])
3799 dac
= spec
->multiout
.hp_out_nid
[0];
3801 dac
= spec
->multiout
.dac_nids
[0];
3803 alc_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, dac
);
3805 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++) {
3806 if (spec
->autocfg
.line_out_type
== AUTO_PIN_SPEAKER_OUT
)
3808 pin
= spec
->autocfg
.speaker_pins
[i
];
3811 dac
= spec
->multiout
.extra_out_nid
[i
];
3813 if (i
> 0 && spec
->multiout
.extra_out_nid
[0])
3814 dac
= spec
->multiout
.extra_out_nid
[0];
3816 dac
= spec
->multiout
.dac_nids
[0];
3818 alc_auto_set_output_and_unmute(codec
, pin
, PIN_OUT
, dac
);
3822 /* check whether the given pin can be a multi-io pin */
3823 static bool can_be_multiio_pin(struct hda_codec
*codec
,
3824 unsigned int location
, hda_nid_t nid
)
3826 unsigned int defcfg
, caps
;
3828 defcfg
= snd_hda_codec_get_pincfg(codec
, nid
);
3829 if (get_defcfg_connect(defcfg
) != AC_JACK_PORT_COMPLEX
)
3831 if (location
&& get_defcfg_location(defcfg
) != location
)
3833 caps
= snd_hda_query_pin_caps(codec
, nid
);
3834 if (!(caps
& AC_PINCAP_OUT
))
3842 * When hardwired is set, try to fill ony hardwired pins, and returns
3843 * zero if any pins are filled, non-zero if nothing found.
3844 * When hardwired is off, try to fill possible input pins, and returns
3845 * the badness value.
3847 static int alc_auto_fill_multi_ios(struct hda_codec
*codec
,
3848 hda_nid_t reference_pin
,
3849 bool hardwired
, int offset
)
3851 struct alc_spec
*spec
= codec
->spec
;
3852 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3853 int type
, i
, j
, dacs
, num_pins
, old_pins
;
3854 unsigned int defcfg
= snd_hda_codec_get_pincfg(codec
, reference_pin
);
3855 unsigned int location
= get_defcfg_location(defcfg
);
3858 old_pins
= spec
->multi_ios
;
3863 for (type
= AUTO_PIN_LINE_IN
; type
>= AUTO_PIN_MIC
; type
--) {
3864 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3865 if (cfg
->inputs
[i
].type
!= type
)
3867 if (can_be_multiio_pin(codec
, location
,
3868 cfg
->inputs
[i
].pin
))
3875 dacs
= spec
->multiout
.num_dacs
;
3876 for (type
= AUTO_PIN_LINE_IN
; type
>= AUTO_PIN_MIC
; type
--) {
3877 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3878 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
3881 if (cfg
->inputs
[i
].type
!= type
)
3883 if (!can_be_multiio_pin(codec
, location
, nid
))
3885 for (j
= 0; j
< spec
->multi_ios
; j
++) {
3886 if (nid
== spec
->multi_io
[j
].pin
)
3889 if (j
< spec
->multi_ios
)
3892 if (offset
&& offset
+ spec
->multi_ios
< dacs
) {
3893 dac
= spec
->private_dac_nids
[offset
+ spec
->multi_ios
];
3894 if (!alc_auto_is_dac_reachable(codec
, nid
, dac
))
3898 dac
= get_dac_if_single(codec
, nid
);
3900 dac
= alc_auto_look_for_dac(codec
, nid
);
3905 spec
->multi_io
[spec
->multi_ios
].pin
= nid
;
3906 spec
->multi_io
[spec
->multi_ios
].dac
= dac
;
3908 if (spec
->multi_ios
>= 2)
3914 badness
= BAD_MULTI_IO
;
3915 if (old_pins
== spec
->multi_ios
) {
3917 return 1; /* nothing found */
3919 return badness
; /* no badness if nothing found */
3921 if (!hardwired
&& spec
->multi_ios
< 2) {
3922 spec
->multi_ios
= old_pins
;
3929 static int alc_auto_ch_mode_info(struct snd_kcontrol
*kcontrol
,
3930 struct snd_ctl_elem_info
*uinfo
)
3932 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3933 struct alc_spec
*spec
= codec
->spec
;
3935 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
3937 uinfo
->value
.enumerated
.items
= spec
->multi_ios
+ 1;
3938 if (uinfo
->value
.enumerated
.item
> spec
->multi_ios
)
3939 uinfo
->value
.enumerated
.item
= spec
->multi_ios
;
3940 sprintf(uinfo
->value
.enumerated
.name
, "%dch",
3941 (uinfo
->value
.enumerated
.item
+ 1) * 2);
3945 static int alc_auto_ch_mode_get(struct snd_kcontrol
*kcontrol
,
3946 struct snd_ctl_elem_value
*ucontrol
)
3948 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3949 struct alc_spec
*spec
= codec
->spec
;
3950 ucontrol
->value
.enumerated
.item
[0] = (spec
->ext_channel_count
- 1) / 2;
3954 static int alc_set_multi_io(struct hda_codec
*codec
, int idx
, bool output
)
3956 struct alc_spec
*spec
= codec
->spec
;
3957 hda_nid_t nid
= spec
->multi_io
[idx
].pin
;
3959 if (!spec
->multi_io
[idx
].ctl_in
)
3960 spec
->multi_io
[idx
].ctl_in
=
3961 snd_hda_codec_read(codec
, nid
, 0,
3962 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
3964 snd_hda_set_pin_ctl_cache(codec
, nid
, PIN_OUT
);
3965 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
3966 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
3968 alc_auto_select_dac(codec
, nid
, spec
->multi_io
[idx
].dac
);
3970 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
3971 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
3972 HDA_AMP_MUTE
, HDA_AMP_MUTE
);
3973 snd_hda_set_pin_ctl_cache(codec
, nid
,
3974 spec
->multi_io
[idx
].ctl_in
);
3979 static int alc_auto_ch_mode_put(struct snd_kcontrol
*kcontrol
,
3980 struct snd_ctl_elem_value
*ucontrol
)
3982 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3983 struct alc_spec
*spec
= codec
->spec
;
3986 ch
= ucontrol
->value
.enumerated
.item
[0];
3987 if (ch
< 0 || ch
> spec
->multi_ios
)
3989 if (ch
== (spec
->ext_channel_count
- 1) / 2)
3991 spec
->ext_channel_count
= (ch
+ 1) * 2;
3992 for (i
= 0; i
< spec
->multi_ios
; i
++)
3993 alc_set_multi_io(codec
, i
, i
< ch
);
3994 spec
->multiout
.max_channels
= spec
->ext_channel_count
;
3995 if (spec
->need_dac_fix
&& !spec
->const_channel_count
)
3996 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
4000 static const struct snd_kcontrol_new alc_auto_channel_mode_enum
= {
4001 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4002 .name
= "Channel Mode",
4003 .info
= alc_auto_ch_mode_info
,
4004 .get
= alc_auto_ch_mode_get
,
4005 .put
= alc_auto_ch_mode_put
,
4008 static int alc_auto_add_multi_channel_mode(struct hda_codec
*codec
)
4010 struct alc_spec
*spec
= codec
->spec
;
4012 if (spec
->multi_ios
> 0) {
4013 struct snd_kcontrol_new
*knew
;
4015 knew
= alc_kcontrol_new(spec
);
4018 *knew
= alc_auto_channel_mode_enum
;
4019 knew
->name
= kstrdup("Channel Mode", GFP_KERNEL
);
4026 /* filter out invalid adc_nids (and capsrc_nids) that don't give all
4029 static void alc_remove_invalid_adc_nids(struct hda_codec
*codec
)
4031 struct alc_spec
*spec
= codec
->spec
;
4032 const struct hda_input_mux
*imux
;
4033 hda_nid_t adc_nids
[ARRAY_SIZE(spec
->private_adc_nids
)];
4034 hda_nid_t capsrc_nids
[ARRAY_SIZE(spec
->private_adc_nids
)];
4037 imux
= spec
->input_mux
;
4040 if (spec
->dyn_adc_switch
)
4045 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
4046 hda_nid_t cap
= spec
->private_capsrc_nids
[n
];
4047 int num_conns
= snd_hda_get_num_conns(codec
, cap
);
4048 for (i
= 0; i
< imux
->num_items
; i
++) {
4049 hda_nid_t pin
= spec
->imux_pins
[i
];
4051 if (get_connection_index(codec
, cap
, pin
) < 0)
4053 } else if (num_conns
<= imux
->items
[i
].index
)
4056 if (i
>= imux
->num_items
) {
4057 adc_nids
[nums
] = spec
->private_adc_nids
[n
];
4058 capsrc_nids
[nums
++] = cap
;
4062 /* check whether ADC-switch is possible */
4063 if (!alc_check_dyn_adc_switch(codec
)) {
4064 if (spec
->shared_mic_hp
) {
4065 spec
->shared_mic_hp
= 0;
4066 spec
->private_imux
[0].num_items
= 1;
4069 printk(KERN_WARNING
"hda_codec: %s: no valid ADC found;"
4070 " using fallback 0x%x\n",
4071 codec
->chip_name
, spec
->private_adc_nids
[0]);
4072 spec
->num_adc_nids
= 1;
4076 } else if (nums
!= spec
->num_adc_nids
) {
4077 memcpy(spec
->private_adc_nids
, adc_nids
,
4078 nums
* sizeof(hda_nid_t
));
4079 memcpy(spec
->private_capsrc_nids
, capsrc_nids
,
4080 nums
* sizeof(hda_nid_t
));
4081 spec
->num_adc_nids
= nums
;
4085 alc_auto_mic_check_imux(codec
); /* check auto-mic setups */
4086 else if (spec
->input_mux
->num_items
== 1 || spec
->shared_mic_hp
)
4087 spec
->num_adc_nids
= 1; /* reduce to a single ADC */
4091 * initialize ADC paths
4093 static void alc_auto_init_adc(struct hda_codec
*codec
, int adc_idx
)
4095 struct alc_spec
*spec
= codec
->spec
;
4098 nid
= spec
->adc_nids
[adc_idx
];
4100 if (nid_has_mute(codec
, nid
, HDA_INPUT
)) {
4101 snd_hda_codec_write(codec
, nid
, 0,
4102 AC_VERB_SET_AMP_GAIN_MUTE
,
4106 if (!spec
->capsrc_nids
)
4108 nid
= spec
->capsrc_nids
[adc_idx
];
4109 if (nid_has_mute(codec
, nid
, HDA_OUTPUT
))
4110 snd_hda_codec_write(codec
, nid
, 0,
4111 AC_VERB_SET_AMP_GAIN_MUTE
,
4115 static void alc_auto_init_input_src(struct hda_codec
*codec
)
4117 struct alc_spec
*spec
= codec
->spec
;
4120 for (c
= 0; c
< spec
->num_adc_nids
; c
++)
4121 alc_auto_init_adc(codec
, c
);
4122 if (spec
->dyn_adc_switch
)
4125 nums
= spec
->num_adc_nids
;
4126 for (c
= 0; c
< nums
; c
++)
4127 alc_mux_select(codec
, c
, spec
->cur_mux
[c
], true);
4130 /* add mic boosts if needed */
4131 static int alc_auto_add_mic_boost(struct hda_codec
*codec
)
4133 struct alc_spec
*spec
= codec
->spec
;
4134 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4138 const char *prev_label
= NULL
;
4140 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
4141 if (cfg
->inputs
[i
].type
> AUTO_PIN_MIC
)
4143 nid
= cfg
->inputs
[i
].pin
;
4144 if (get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
) {
4146 char boost_label
[32];
4148 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
4149 if (spec
->shared_mic_hp
&& !strcmp(label
, "Misc"))
4150 label
= "Headphone Mic";
4151 if (prev_label
&& !strcmp(label
, prev_label
))
4157 snprintf(boost_label
, sizeof(boost_label
),
4158 "%s Boost Volume", label
);
4159 err
= add_control(spec
, ALC_CTL_WIDGET_VOL
,
4160 boost_label
, type_idx
,
4161 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_INPUT
));
4169 /* select or unmute the given capsrc route */
4170 static void select_or_unmute_capsrc(struct hda_codec
*codec
, hda_nid_t cap
,
4173 if (get_wcaps_type(get_wcaps(codec
, cap
)) == AC_WID_AUD_MIX
) {
4174 snd_hda_codec_amp_stereo(codec
, cap
, HDA_INPUT
, idx
,
4176 } else if (snd_hda_get_num_conns(codec
, cap
) > 1) {
4177 snd_hda_codec_write_cache(codec
, cap
, 0,
4178 AC_VERB_SET_CONNECT_SEL
, idx
);
4182 /* set the default connection to that pin */
4183 static int init_capsrc_for_pin(struct hda_codec
*codec
, hda_nid_t pin
)
4185 struct alc_spec
*spec
= codec
->spec
;
4190 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
4191 hda_nid_t cap
= get_capsrc(spec
, i
);
4194 idx
= get_connection_index(codec
, cap
, pin
);
4197 select_or_unmute_capsrc(codec
, cap
, idx
);
4198 return i
; /* return the found index */
4200 return -1; /* not found */
4203 /* initialize some special cases for input sources */
4204 static void alc_init_special_input_src(struct hda_codec
*codec
)
4206 struct alc_spec
*spec
= codec
->spec
;
4209 for (i
= 0; i
< spec
->autocfg
.num_inputs
; i
++)
4210 init_capsrc_for_pin(codec
, spec
->autocfg
.inputs
[i
].pin
);
4213 /* assign appropriate capture mixers */
4214 static void set_capture_mixer(struct hda_codec
*codec
)
4216 struct alc_spec
*spec
= codec
->spec
;
4217 static const struct snd_kcontrol_new
*caps
[2][3] = {
4218 { alc_capture_mixer_nosrc1
,
4219 alc_capture_mixer_nosrc2
,
4220 alc_capture_mixer_nosrc3
},
4221 { alc_capture_mixer1
,
4223 alc_capture_mixer3
},
4226 /* check whether either of ADC or MUX has a volume control */
4227 if (!nid_has_volume(codec
, spec
->adc_nids
[0], HDA_INPUT
)) {
4228 if (!spec
->capsrc_nids
)
4229 return; /* no volume */
4230 if (!nid_has_volume(codec
, spec
->capsrc_nids
[0], HDA_OUTPUT
))
4231 return; /* no volume in capsrc, too */
4232 spec
->vol_in_capsrc
= 1;
4235 if (spec
->num_adc_nids
> 0) {
4239 if (spec
->input_mux
&& spec
->input_mux
->num_items
> 1)
4241 if (spec
->auto_mic
) {
4244 } else if (spec
->dyn_adc_switch
)
4247 if (spec
->num_adc_nids
> 3)
4248 spec
->num_adc_nids
= 3;
4249 else if (!spec
->num_adc_nids
)
4251 num_adcs
= spec
->num_adc_nids
;
4253 spec
->cap_mixer
= caps
[mux
][num_adcs
- 1];
4258 * standard auto-parser initializations
4260 static void alc_auto_init_std(struct hda_codec
*codec
)
4262 alc_auto_init_multi_out(codec
);
4263 alc_auto_init_extra_out(codec
);
4264 alc_auto_init_analog_input(codec
);
4265 alc_auto_init_input_src(codec
);
4266 alc_auto_init_digital(codec
);
4267 alc_inithook(codec
);
4271 * Digital-beep handlers
4273 #ifdef CONFIG_SND_HDA_INPUT_BEEP
4274 #define set_beep_amp(spec, nid, idx, dir) \
4275 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4277 static const struct snd_pci_quirk beep_white_list
[] = {
4278 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
4279 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
4280 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
4281 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
4282 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
4283 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
4287 static inline int has_cdefine_beep(struct hda_codec
*codec
)
4289 struct alc_spec
*spec
= codec
->spec
;
4290 const struct snd_pci_quirk
*q
;
4291 q
= snd_pci_quirk_lookup(codec
->bus
->pci
, beep_white_list
);
4294 return spec
->cdefine
.enable_pcbeep
;
4297 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
4298 #define has_cdefine_beep(codec) 0
4301 /* parse the BIOS configuration and set up the alc_spec */
4302 /* return 1 if successful, 0 if the proper config is not found,
4303 * or a negative error code
4305 static int alc_parse_auto_config(struct hda_codec
*codec
,
4306 const hda_nid_t
*ignore_nids
,
4307 const hda_nid_t
*ssid_nids
)
4309 struct alc_spec
*spec
= codec
->spec
;
4310 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4313 err
= snd_hda_parse_pin_defcfg(codec
, cfg
, ignore_nids
,
4317 if (!cfg
->line_outs
) {
4318 if (cfg
->dig_outs
|| cfg
->dig_in_pin
) {
4319 spec
->multiout
.max_channels
= 2;
4320 spec
->no_analog
= 1;
4323 return 0; /* can't find valid BIOS pin config */
4326 if (cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
&&
4327 cfg
->line_outs
<= cfg
->hp_outs
) {
4328 /* use HP as primary out */
4329 cfg
->speaker_outs
= cfg
->line_outs
;
4330 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
4331 sizeof(cfg
->speaker_pins
));
4332 cfg
->line_outs
= cfg
->hp_outs
;
4333 memcpy(cfg
->line_out_pins
, cfg
->hp_pins
, sizeof(cfg
->hp_pins
));
4335 memset(cfg
->hp_pins
, 0, sizeof(cfg
->hp_pins
));
4336 cfg
->line_out_type
= AUTO_PIN_HP_OUT
;
4339 err
= alc_auto_fill_dac_nids(codec
);
4342 err
= alc_auto_add_multi_channel_mode(codec
);
4345 err
= alc_auto_create_multi_out_ctls(codec
, cfg
);
4348 err
= alc_auto_create_hp_out(codec
);
4351 err
= alc_auto_create_speaker_out(codec
);
4354 err
= alc_auto_create_shared_input(codec
);
4357 err
= alc_auto_create_input_ctls(codec
);
4361 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
4364 alc_auto_parse_digital(codec
);
4366 if (!spec
->no_analog
)
4367 alc_remove_invalid_adc_nids(codec
);
4370 alc_ssid_check(codec
, ssid_nids
);
4372 if (!spec
->no_analog
) {
4373 alc_auto_check_switches(codec
);
4374 err
= alc_auto_add_mic_boost(codec
);
4379 if (spec
->kctls
.list
)
4380 add_mixer(spec
, spec
->kctls
.list
);
4382 if (!spec
->no_analog
&& !spec
->cap_mixer
)
4383 set_capture_mixer(codec
);
4388 /* common preparation job for alc_spec */
4389 static int alc_alloc_spec(struct hda_codec
*codec
, hda_nid_t mixer_nid
)
4391 struct alc_spec
*spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4397 spec
->mixer_nid
= mixer_nid
;
4398 snd_hda_gen_init(&spec
->gen
);
4400 err
= alc_codec_rename_from_preset(codec
);
4408 static int alc880_parse_auto_config(struct hda_codec
*codec
)
4410 static const hda_nid_t alc880_ignore
[] = { 0x1d, 0 };
4411 static const hda_nid_t alc880_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
4412 return alc_parse_auto_config(codec
, alc880_ignore
, alc880_ssids
);
4421 ALC880_FIXUP_MEDION_RIM
,
4424 ALC880_FIXUP_EAPD_COEF
,
4425 ALC880_FIXUP_TCL_S700
,
4426 ALC880_FIXUP_VOL_KNOB
,
4427 ALC880_FIXUP_FUJITSU
,
4429 ALC880_FIXUP_UNIWILL
,
4430 ALC880_FIXUP_UNIWILL_DIG
,
4432 ALC880_FIXUP_3ST_BASE
,
4434 ALC880_FIXUP_3ST_DIG
,
4435 ALC880_FIXUP_5ST_BASE
,
4437 ALC880_FIXUP_5ST_DIG
,
4438 ALC880_FIXUP_6ST_BASE
,
4440 ALC880_FIXUP_6ST_DIG
,
4443 /* enable the volume-knob widget support on NID 0x21 */
4444 static void alc880_fixup_vol_knob(struct hda_codec
*codec
,
4445 const struct alc_fixup
*fix
, int action
)
4447 if (action
== ALC_FIXUP_ACT_PROBE
)
4448 snd_hda_jack_detect_enable(codec
, 0x21, ALC_DCVOL_EVENT
);
4451 static const struct alc_fixup alc880_fixups
[] = {
4452 [ALC880_FIXUP_GPIO1
] = {
4453 .type
= ALC_FIXUP_VERBS
,
4454 .v
.verbs
= alc_gpio1_init_verbs
,
4456 [ALC880_FIXUP_GPIO2
] = {
4457 .type
= ALC_FIXUP_VERBS
,
4458 .v
.verbs
= alc_gpio2_init_verbs
,
4460 [ALC880_FIXUP_MEDION_RIM
] = {
4461 .type
= ALC_FIXUP_VERBS
,
4462 .v
.verbs
= (const struct hda_verb
[]) {
4463 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4464 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
4468 .chain_id
= ALC880_FIXUP_GPIO2
,
4470 [ALC880_FIXUP_LG
] = {
4471 .type
= ALC_FIXUP_PINS
,
4472 .v
.pins
= (const struct alc_pincfg
[]) {
4473 /* disable bogus unused pins */
4474 { 0x16, 0x411111f0 },
4475 { 0x18, 0x411111f0 },
4476 { 0x1a, 0x411111f0 },
4480 [ALC880_FIXUP_W810
] = {
4481 .type
= ALC_FIXUP_PINS
,
4482 .v
.pins
= (const struct alc_pincfg
[]) {
4483 /* disable bogus unused pins */
4484 { 0x17, 0x411111f0 },
4488 .chain_id
= ALC880_FIXUP_GPIO2
,
4490 [ALC880_FIXUP_EAPD_COEF
] = {
4491 .type
= ALC_FIXUP_VERBS
,
4492 .v
.verbs
= (const struct hda_verb
[]) {
4493 /* change to EAPD mode */
4494 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4495 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
4499 [ALC880_FIXUP_TCL_S700
] = {
4500 .type
= ALC_FIXUP_VERBS
,
4501 .v
.verbs
= (const struct hda_verb
[]) {
4502 /* change to EAPD mode */
4503 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4504 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
4508 .chain_id
= ALC880_FIXUP_GPIO2
,
4510 [ALC880_FIXUP_VOL_KNOB
] = {
4511 .type
= ALC_FIXUP_FUNC
,
4512 .v
.func
= alc880_fixup_vol_knob
,
4514 [ALC880_FIXUP_FUJITSU
] = {
4515 /* override all pins as BIOS on old Amilo is broken */
4516 .type
= ALC_FIXUP_PINS
,
4517 .v
.pins
= (const struct alc_pincfg
[]) {
4518 { 0x14, 0x0121411f }, /* HP */
4519 { 0x15, 0x99030120 }, /* speaker */
4520 { 0x16, 0x99030130 }, /* bass speaker */
4521 { 0x17, 0x411111f0 }, /* N/A */
4522 { 0x18, 0x411111f0 }, /* N/A */
4523 { 0x19, 0x01a19950 }, /* mic-in */
4524 { 0x1a, 0x411111f0 }, /* N/A */
4525 { 0x1b, 0x411111f0 }, /* N/A */
4526 { 0x1c, 0x411111f0 }, /* N/A */
4527 { 0x1d, 0x411111f0 }, /* N/A */
4528 { 0x1e, 0x01454140 }, /* SPDIF out */
4532 .chain_id
= ALC880_FIXUP_VOL_KNOB
,
4534 [ALC880_FIXUP_F1734
] = {
4535 /* almost compatible with FUJITSU, but no bass and SPDIF */
4536 .type
= ALC_FIXUP_PINS
,
4537 .v
.pins
= (const struct alc_pincfg
[]) {
4538 { 0x14, 0x0121411f }, /* HP */
4539 { 0x15, 0x99030120 }, /* speaker */
4540 { 0x16, 0x411111f0 }, /* N/A */
4541 { 0x17, 0x411111f0 }, /* N/A */
4542 { 0x18, 0x411111f0 }, /* N/A */
4543 { 0x19, 0x01a19950 }, /* mic-in */
4544 { 0x1a, 0x411111f0 }, /* N/A */
4545 { 0x1b, 0x411111f0 }, /* N/A */
4546 { 0x1c, 0x411111f0 }, /* N/A */
4547 { 0x1d, 0x411111f0 }, /* N/A */
4548 { 0x1e, 0x411111f0 }, /* N/A */
4552 .chain_id
= ALC880_FIXUP_VOL_KNOB
,
4554 [ALC880_FIXUP_UNIWILL
] = {
4555 /* need to fix HP and speaker pins to be parsed correctly */
4556 .type
= ALC_FIXUP_PINS
,
4557 .v
.pins
= (const struct alc_pincfg
[]) {
4558 { 0x14, 0x0121411f }, /* HP */
4559 { 0x15, 0x99030120 }, /* speaker */
4560 { 0x16, 0x99030130 }, /* bass speaker */
4564 [ALC880_FIXUP_UNIWILL_DIG
] = {
4565 .type
= ALC_FIXUP_PINS
,
4566 .v
.pins
= (const struct alc_pincfg
[]) {
4567 /* disable bogus unused pins */
4568 { 0x17, 0x411111f0 },
4569 { 0x19, 0x411111f0 },
4570 { 0x1b, 0x411111f0 },
4571 { 0x1f, 0x411111f0 },
4575 [ALC880_FIXUP_Z71V
] = {
4576 .type
= ALC_FIXUP_PINS
,
4577 .v
.pins
= (const struct alc_pincfg
[]) {
4578 /* set up the whole pins as BIOS is utterly broken */
4579 { 0x14, 0x99030120 }, /* speaker */
4580 { 0x15, 0x0121411f }, /* HP */
4581 { 0x16, 0x411111f0 }, /* N/A */
4582 { 0x17, 0x411111f0 }, /* N/A */
4583 { 0x18, 0x01a19950 }, /* mic-in */
4584 { 0x19, 0x411111f0 }, /* N/A */
4585 { 0x1a, 0x01813031 }, /* line-in */
4586 { 0x1b, 0x411111f0 }, /* N/A */
4587 { 0x1c, 0x411111f0 }, /* N/A */
4588 { 0x1d, 0x411111f0 }, /* N/A */
4589 { 0x1e, 0x0144111e }, /* SPDIF */
4593 [ALC880_FIXUP_3ST_BASE
] = {
4594 .type
= ALC_FIXUP_PINS
,
4595 .v
.pins
= (const struct alc_pincfg
[]) {
4596 { 0x14, 0x01014010 }, /* line-out */
4597 { 0x15, 0x411111f0 }, /* N/A */
4598 { 0x16, 0x411111f0 }, /* N/A */
4599 { 0x17, 0x411111f0 }, /* N/A */
4600 { 0x18, 0x01a19c30 }, /* mic-in */
4601 { 0x19, 0x0121411f }, /* HP */
4602 { 0x1a, 0x01813031 }, /* line-in */
4603 { 0x1b, 0x02a19c40 }, /* front-mic */
4604 { 0x1c, 0x411111f0 }, /* N/A */
4605 { 0x1d, 0x411111f0 }, /* N/A */
4606 /* 0x1e is filled in below */
4607 { 0x1f, 0x411111f0 }, /* N/A */
4611 [ALC880_FIXUP_3ST
] = {
4612 .type
= ALC_FIXUP_PINS
,
4613 .v
.pins
= (const struct alc_pincfg
[]) {
4614 { 0x1e, 0x411111f0 }, /* N/A */
4618 .chain_id
= ALC880_FIXUP_3ST_BASE
,
4620 [ALC880_FIXUP_3ST_DIG
] = {
4621 .type
= ALC_FIXUP_PINS
,
4622 .v
.pins
= (const struct alc_pincfg
[]) {
4623 { 0x1e, 0x0144111e }, /* SPDIF */
4627 .chain_id
= ALC880_FIXUP_3ST_BASE
,
4629 [ALC880_FIXUP_5ST_BASE
] = {
4630 .type
= ALC_FIXUP_PINS
,
4631 .v
.pins
= (const struct alc_pincfg
[]) {
4632 { 0x14, 0x01014010 }, /* front */
4633 { 0x15, 0x411111f0 }, /* N/A */
4634 { 0x16, 0x01011411 }, /* CLFE */
4635 { 0x17, 0x01016412 }, /* surr */
4636 { 0x18, 0x01a19c30 }, /* mic-in */
4637 { 0x19, 0x0121411f }, /* HP */
4638 { 0x1a, 0x01813031 }, /* line-in */
4639 { 0x1b, 0x02a19c40 }, /* front-mic */
4640 { 0x1c, 0x411111f0 }, /* N/A */
4641 { 0x1d, 0x411111f0 }, /* N/A */
4642 /* 0x1e is filled in below */
4643 { 0x1f, 0x411111f0 }, /* N/A */
4647 [ALC880_FIXUP_5ST
] = {
4648 .type
= ALC_FIXUP_PINS
,
4649 .v
.pins
= (const struct alc_pincfg
[]) {
4650 { 0x1e, 0x411111f0 }, /* N/A */
4654 .chain_id
= ALC880_FIXUP_5ST_BASE
,
4656 [ALC880_FIXUP_5ST_DIG
] = {
4657 .type
= ALC_FIXUP_PINS
,
4658 .v
.pins
= (const struct alc_pincfg
[]) {
4659 { 0x1e, 0x0144111e }, /* SPDIF */
4663 .chain_id
= ALC880_FIXUP_5ST_BASE
,
4665 [ALC880_FIXUP_6ST_BASE
] = {
4666 .type
= ALC_FIXUP_PINS
,
4667 .v
.pins
= (const struct alc_pincfg
[]) {
4668 { 0x14, 0x01014010 }, /* front */
4669 { 0x15, 0x01016412 }, /* surr */
4670 { 0x16, 0x01011411 }, /* CLFE */
4671 { 0x17, 0x01012414 }, /* side */
4672 { 0x18, 0x01a19c30 }, /* mic-in */
4673 { 0x19, 0x02a19c40 }, /* front-mic */
4674 { 0x1a, 0x01813031 }, /* line-in */
4675 { 0x1b, 0x0121411f }, /* HP */
4676 { 0x1c, 0x411111f0 }, /* N/A */
4677 { 0x1d, 0x411111f0 }, /* N/A */
4678 /* 0x1e is filled in below */
4679 { 0x1f, 0x411111f0 }, /* N/A */
4683 [ALC880_FIXUP_6ST
] = {
4684 .type
= ALC_FIXUP_PINS
,
4685 .v
.pins
= (const struct alc_pincfg
[]) {
4686 { 0x1e, 0x411111f0 }, /* N/A */
4690 .chain_id
= ALC880_FIXUP_6ST_BASE
,
4692 [ALC880_FIXUP_6ST_DIG
] = {
4693 .type
= ALC_FIXUP_PINS
,
4694 .v
.pins
= (const struct alc_pincfg
[]) {
4695 { 0x1e, 0x0144111e }, /* SPDIF */
4699 .chain_id
= ALC880_FIXUP_6ST_BASE
,
4703 static const struct snd_pci_quirk alc880_fixup_tbl
[] = {
4704 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810
),
4705 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V
),
4706 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1
),
4707 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2
),
4708 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF
),
4709 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG
),
4710 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734
),
4711 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL
),
4712 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB
),
4713 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810
),
4714 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM
),
4715 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734
),
4716 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU
),
4717 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734
),
4718 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU
),
4719 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG
),
4720 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG
),
4721 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG
),
4722 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700
),
4724 /* Below is the copied entries from alc880_quirks.c.
4725 * It's not quite sure whether BIOS sets the correct pin-config table
4726 * on these machines, thus they are kept to be compatible with
4727 * the old static quirks. Once when it's confirmed to work without
4728 * these overrides, it'd be better to remove.
4730 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG
),
4731 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST
),
4732 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG
),
4733 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG
),
4734 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG
),
4735 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG
),
4736 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG
),
4737 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST
),
4738 SND_PCI_QUIRK(0x1039, 0x1234, NULL
, ALC880_FIXUP_6ST_DIG
),
4739 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST
),
4740 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST
),
4741 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST
),
4742 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST
),
4743 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST
),
4744 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG
),
4745 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG
),
4746 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG
),
4747 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG
),
4748 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG
),
4749 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG
),
4750 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG
),
4751 SND_PCI_QUIRK(0x2668, 0x8086, NULL
, ALC880_FIXUP_6ST_DIG
), /* broken BIOS */
4752 SND_PCI_QUIRK(0x8086, 0x2668, NULL
, ALC880_FIXUP_6ST_DIG
),
4753 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4754 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4755 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4756 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4757 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4758 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4759 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4760 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4761 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4762 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4764 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST
),
4765 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG
),
4766 SND_PCI_QUIRK(0xe803, 0x1019, NULL
, ALC880_FIXUP_6ST_DIG
),
4770 static const struct alc_model_fixup alc880_fixup_models
[] = {
4771 {.id
= ALC880_FIXUP_3ST
, .name
= "3stack"},
4772 {.id
= ALC880_FIXUP_3ST_DIG
, .name
= "3stack-digout"},
4773 {.id
= ALC880_FIXUP_5ST
, .name
= "5stack"},
4774 {.id
= ALC880_FIXUP_5ST_DIG
, .name
= "5stack-digout"},
4775 {.id
= ALC880_FIXUP_6ST
, .name
= "6stack"},
4776 {.id
= ALC880_FIXUP_6ST_DIG
, .name
= "6stack-digout"},
4782 * OK, here we have finally the patch for ALC880
4784 static int patch_alc880(struct hda_codec
*codec
)
4786 struct alc_spec
*spec
;
4789 err
= alc_alloc_spec(codec
, 0x0b);
4794 spec
->need_dac_fix
= 1;
4796 alc_pick_fixup(codec
, alc880_fixup_models
, alc880_fixup_tbl
,
4798 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
4800 /* automatic parse from the BIOS config */
4801 err
= alc880_parse_auto_config(codec
);
4805 if (!spec
->no_analog
) {
4806 err
= snd_hda_attach_beep_device(codec
, 0x1);
4809 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
4812 codec
->patch_ops
= alc_patch_ops
;
4814 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
4827 static int alc260_parse_auto_config(struct hda_codec
*codec
)
4829 static const hda_nid_t alc260_ignore
[] = { 0x17, 0 };
4830 static const hda_nid_t alc260_ssids
[] = { 0x10, 0x15, 0x0f, 0 };
4831 return alc_parse_auto_config(codec
, alc260_ignore
, alc260_ssids
);
4838 ALC260_FIXUP_HP_DC5750
,
4839 ALC260_FIXUP_HP_PIN_0F
,
4842 ALC260_FIXUP_GPIO1_TOGGLE
,
4843 ALC260_FIXUP_REPLACER
,
4844 ALC260_FIXUP_HP_B1900
,
4848 static void alc260_gpio1_automute(struct hda_codec
*codec
)
4850 struct alc_spec
*spec
= codec
->spec
;
4851 snd_hda_codec_write(codec
, 0x01, 0, AC_VERB_SET_GPIO_DATA
,
4852 spec
->hp_jack_present
);
4855 static void alc260_fixup_gpio1_toggle(struct hda_codec
*codec
,
4856 const struct alc_fixup
*fix
, int action
)
4858 struct alc_spec
*spec
= codec
->spec
;
4859 if (action
== ALC_FIXUP_ACT_PROBE
) {
4860 /* although the machine has only one output pin, we need to
4861 * toggle GPIO1 according to the jack state
4863 spec
->automute_hook
= alc260_gpio1_automute
;
4864 spec
->detect_hp
= 1;
4865 spec
->automute_speaker
= 1;
4866 spec
->autocfg
.hp_pins
[0] = 0x0f; /* copy it for automute */
4867 snd_hda_jack_detect_enable(codec
, 0x0f, ALC_HP_EVENT
);
4868 snd_hda_gen_add_verbs(&spec
->gen
, alc_gpio1_init_verbs
);
4872 static void alc260_fixup_kn1(struct hda_codec
*codec
,
4873 const struct alc_fixup
*fix
, int action
)
4875 struct alc_spec
*spec
= codec
->spec
;
4876 static const struct alc_pincfg pincfgs
[] = {
4877 { 0x0f, 0x02214000 }, /* HP/speaker */
4878 { 0x12, 0x90a60160 }, /* int mic */
4879 { 0x13, 0x02a19000 }, /* ext mic */
4880 { 0x18, 0x01446000 }, /* SPDIF out */
4881 /* disable bogus I/O pins */
4882 { 0x10, 0x411111f0 },
4883 { 0x11, 0x411111f0 },
4884 { 0x14, 0x411111f0 },
4885 { 0x15, 0x411111f0 },
4886 { 0x16, 0x411111f0 },
4887 { 0x17, 0x411111f0 },
4888 { 0x19, 0x411111f0 },
4893 case ALC_FIXUP_ACT_PRE_PROBE
:
4894 alc_apply_pincfgs(codec
, pincfgs
);
4896 case ALC_FIXUP_ACT_PROBE
:
4897 spec
->init_amp
= ALC_INIT_NONE
;
4902 static const struct alc_fixup alc260_fixups
[] = {
4903 [ALC260_FIXUP_HP_DC5750
] = {
4904 .type
= ALC_FIXUP_PINS
,
4905 .v
.pins
= (const struct alc_pincfg
[]) {
4906 { 0x11, 0x90130110 }, /* speaker */
4910 [ALC260_FIXUP_HP_PIN_0F
] = {
4911 .type
= ALC_FIXUP_PINS
,
4912 .v
.pins
= (const struct alc_pincfg
[]) {
4913 { 0x0f, 0x01214000 }, /* HP */
4917 [ALC260_FIXUP_COEF
] = {
4918 .type
= ALC_FIXUP_VERBS
,
4919 .v
.verbs
= (const struct hda_verb
[]) {
4920 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4921 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3040 },
4925 .chain_id
= ALC260_FIXUP_HP_PIN_0F
,
4927 [ALC260_FIXUP_GPIO1
] = {
4928 .type
= ALC_FIXUP_VERBS
,
4929 .v
.verbs
= alc_gpio1_init_verbs
,
4931 [ALC260_FIXUP_GPIO1_TOGGLE
] = {
4932 .type
= ALC_FIXUP_FUNC
,
4933 .v
.func
= alc260_fixup_gpio1_toggle
,
4935 .chain_id
= ALC260_FIXUP_HP_PIN_0F
,
4937 [ALC260_FIXUP_REPLACER
] = {
4938 .type
= ALC_FIXUP_VERBS
,
4939 .v
.verbs
= (const struct hda_verb
[]) {
4940 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4941 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
4945 .chain_id
= ALC260_FIXUP_GPIO1_TOGGLE
,
4947 [ALC260_FIXUP_HP_B1900
] = {
4948 .type
= ALC_FIXUP_FUNC
,
4949 .v
.func
= alc260_fixup_gpio1_toggle
,
4951 .chain_id
= ALC260_FIXUP_COEF
,
4953 [ALC260_FIXUP_KN1
] = {
4954 .type
= ALC_FIXUP_FUNC
,
4955 .v
.func
= alc260_fixup_kn1
,
4959 static const struct snd_pci_quirk alc260_fixup_tbl
[] = {
4960 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1
),
4961 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF
),
4962 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1
),
4963 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750
),
4964 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900
),
4965 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1
),
4966 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1
),
4967 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER
),
4968 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF
),
4974 static int patch_alc260(struct hda_codec
*codec
)
4976 struct alc_spec
*spec
;
4979 err
= alc_alloc_spec(codec
, 0x07);
4985 alc_pick_fixup(codec
, NULL
, alc260_fixup_tbl
, alc260_fixups
);
4986 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
4988 /* automatic parse from the BIOS config */
4989 err
= alc260_parse_auto_config(codec
);
4993 if (!spec
->no_analog
) {
4994 err
= snd_hda_attach_beep_device(codec
, 0x1);
4997 set_beep_amp(spec
, 0x07, 0x05, HDA_INPUT
);
5000 codec
->patch_ops
= alc_patch_ops
;
5001 spec
->shutup
= alc_eapd_shutup
;
5003 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5014 * ALC882/883/885/888/889 support
5016 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5017 * configuration. Each pin widget can choose any input DACs and a mixer.
5018 * Each ADC is connected from a mixer of all inputs. This makes possible
5019 * 6-channel independent captures.
5021 * In addition, an independent DAC for the multi-playback (not used in this
5029 ALC882_FIXUP_ABIT_AW9D_MAX
,
5030 ALC882_FIXUP_LENOVO_Y530
,
5031 ALC882_FIXUP_PB_M5210
,
5032 ALC882_FIXUP_ACER_ASPIRE_7736
,
5033 ALC882_FIXUP_ASUS_W90V
,
5035 ALC889_FIXUP_VAIO_TT
,
5036 ALC888_FIXUP_EEE1601
,
5039 ALC883_FIXUP_ACER_EAPD
,
5044 ALC882_FIXUP_ASUS_W2JC
,
5045 ALC882_FIXUP_ACER_ASPIRE_4930G
,
5046 ALC882_FIXUP_ACER_ASPIRE_8930G
,
5047 ALC882_FIXUP_ASPIRE_8930G_VERBS
,
5048 ALC885_FIXUP_MACPRO_GPIO
,
5049 ALC889_FIXUP_DAC_ROUTE
,
5050 ALC889_FIXUP_MBP_VREF
,
5051 ALC889_FIXUP_IMAC91_VREF
,
5052 ALC882_FIXUP_INV_DMIC
,
5055 static void alc889_fixup_coef(struct hda_codec
*codec
,
5056 const struct alc_fixup
*fix
, int action
)
5058 if (action
!= ALC_FIXUP_ACT_INIT
)
5060 alc889_coef_init(codec
);
5063 /* toggle speaker-output according to the hp-jack state */
5064 static void alc882_gpio_mute(struct hda_codec
*codec
, int pin
, int muted
)
5066 unsigned int gpiostate
, gpiomask
, gpiodir
;
5068 gpiostate
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5069 AC_VERB_GET_GPIO_DATA
, 0);
5072 gpiostate
|= (1 << pin
);
5074 gpiostate
&= ~(1 << pin
);
5076 gpiomask
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5077 AC_VERB_GET_GPIO_MASK
, 0);
5078 gpiomask
|= (1 << pin
);
5080 gpiodir
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5081 AC_VERB_GET_GPIO_DIRECTION
, 0);
5082 gpiodir
|= (1 << pin
);
5085 snd_hda_codec_write(codec
, codec
->afg
, 0,
5086 AC_VERB_SET_GPIO_MASK
, gpiomask
);
5087 snd_hda_codec_write(codec
, codec
->afg
, 0,
5088 AC_VERB_SET_GPIO_DIRECTION
, gpiodir
);
5092 snd_hda_codec_write(codec
, codec
->afg
, 0,
5093 AC_VERB_SET_GPIO_DATA
, gpiostate
);
5096 /* set up GPIO at initialization */
5097 static void alc885_fixup_macpro_gpio(struct hda_codec
*codec
,
5098 const struct alc_fixup
*fix
, int action
)
5100 if (action
!= ALC_FIXUP_ACT_INIT
)
5102 alc882_gpio_mute(codec
, 0, 0);
5103 alc882_gpio_mute(codec
, 1, 0);
5106 /* Fix the connection of some pins for ALC889:
5107 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
5108 * work correctly (bko#42740)
5110 static void alc889_fixup_dac_route(struct hda_codec
*codec
,
5111 const struct alc_fixup
*fix
, int action
)
5113 if (action
== ALC_FIXUP_ACT_PRE_PROBE
) {
5114 /* fake the connections during parsing the tree */
5115 hda_nid_t conn1
[2] = { 0x0c, 0x0d };
5116 hda_nid_t conn2
[2] = { 0x0e, 0x0f };
5117 snd_hda_override_conn_list(codec
, 0x14, 2, conn1
);
5118 snd_hda_override_conn_list(codec
, 0x15, 2, conn1
);
5119 snd_hda_override_conn_list(codec
, 0x18, 2, conn2
);
5120 snd_hda_override_conn_list(codec
, 0x1a, 2, conn2
);
5121 } else if (action
== ALC_FIXUP_ACT_PROBE
) {
5122 /* restore the connections */
5123 hda_nid_t conn
[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
5124 snd_hda_override_conn_list(codec
, 0x14, 5, conn
);
5125 snd_hda_override_conn_list(codec
, 0x15, 5, conn
);
5126 snd_hda_override_conn_list(codec
, 0x18, 5, conn
);
5127 snd_hda_override_conn_list(codec
, 0x1a, 5, conn
);
5131 /* Set VREF on HP pin */
5132 static void alc889_fixup_mbp_vref(struct hda_codec
*codec
,
5133 const struct alc_fixup
*fix
, int action
)
5135 struct alc_spec
*spec
= codec
->spec
;
5136 static hda_nid_t nids
[2] = { 0x14, 0x15 };
5139 if (action
!= ALC_FIXUP_ACT_INIT
)
5141 for (i
= 0; i
< ARRAY_SIZE(nids
); i
++) {
5142 unsigned int val
= snd_hda_codec_get_pincfg(codec
, nids
[i
]);
5143 if (get_defcfg_device(val
) != AC_JACK_HP_OUT
)
5145 val
= snd_hda_codec_read(codec
, nids
[i
], 0,
5146 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
5147 val
|= AC_PINCTL_VREF_80
;
5148 snd_hda_set_pin_ctl(codec
, nids
[i
], val
);
5149 spec
->keep_vref_in_automute
= 1;
5154 /* Set VREF on speaker pins on imac91 */
5155 static void alc889_fixup_imac91_vref(struct hda_codec
*codec
,
5156 const struct alc_fixup
*fix
, int action
)
5158 struct alc_spec
*spec
= codec
->spec
;
5159 static hda_nid_t nids
[2] = { 0x18, 0x1a };
5162 if (action
!= ALC_FIXUP_ACT_INIT
)
5164 for (i
= 0; i
< ARRAY_SIZE(nids
); i
++) {
5166 val
= snd_hda_codec_read(codec
, nids
[i
], 0,
5167 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
5168 val
|= AC_PINCTL_VREF_50
;
5169 snd_hda_set_pin_ctl(codec
, nids
[i
], val
);
5171 spec
->keep_vref_in_automute
= 1;
5174 static const struct alc_fixup alc882_fixups
[] = {
5175 [ALC882_FIXUP_ABIT_AW9D_MAX
] = {
5176 .type
= ALC_FIXUP_PINS
,
5177 .v
.pins
= (const struct alc_pincfg
[]) {
5178 { 0x15, 0x01080104 }, /* side */
5179 { 0x16, 0x01011012 }, /* rear */
5180 { 0x17, 0x01016011 }, /* clfe */
5184 [ALC882_FIXUP_LENOVO_Y530
] = {
5185 .type
= ALC_FIXUP_PINS
,
5186 .v
.pins
= (const struct alc_pincfg
[]) {
5187 { 0x15, 0x99130112 }, /* rear int speakers */
5188 { 0x16, 0x99130111 }, /* subwoofer */
5192 [ALC882_FIXUP_PB_M5210
] = {
5193 .type
= ALC_FIXUP_VERBS
,
5194 .v
.verbs
= (const struct hda_verb
[]) {
5195 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF50
},
5199 [ALC882_FIXUP_ACER_ASPIRE_7736
] = {
5200 .type
= ALC_FIXUP_FUNC
,
5201 .v
.func
= alc_fixup_sku_ignore
,
5203 [ALC882_FIXUP_ASUS_W90V
] = {
5204 .type
= ALC_FIXUP_PINS
,
5205 .v
.pins
= (const struct alc_pincfg
[]) {
5206 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
5210 [ALC889_FIXUP_CD
] = {
5211 .type
= ALC_FIXUP_PINS
,
5212 .v
.pins
= (const struct alc_pincfg
[]) {
5213 { 0x1c, 0x993301f0 }, /* CD */
5217 [ALC889_FIXUP_VAIO_TT
] = {
5218 .type
= ALC_FIXUP_PINS
,
5219 .v
.pins
= (const struct alc_pincfg
[]) {
5220 { 0x17, 0x90170111 }, /* hidden surround speaker */
5224 [ALC888_FIXUP_EEE1601
] = {
5225 .type
= ALC_FIXUP_VERBS
,
5226 .v
.verbs
= (const struct hda_verb
[]) {
5227 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x0b },
5228 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0838 },
5232 [ALC882_FIXUP_EAPD
] = {
5233 .type
= ALC_FIXUP_VERBS
,
5234 .v
.verbs
= (const struct hda_verb
[]) {
5235 /* change to EAPD mode */
5236 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5237 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
5241 [ALC883_FIXUP_EAPD
] = {
5242 .type
= ALC_FIXUP_VERBS
,
5243 .v
.verbs
= (const struct hda_verb
[]) {
5244 /* change to EAPD mode */
5245 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5246 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
5250 [ALC883_FIXUP_ACER_EAPD
] = {
5251 .type
= ALC_FIXUP_VERBS
,
5252 .v
.verbs
= (const struct hda_verb
[]) {
5253 /* eanable EAPD on Acer laptops */
5254 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5255 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5259 [ALC882_FIXUP_GPIO1
] = {
5260 .type
= ALC_FIXUP_VERBS
,
5261 .v
.verbs
= alc_gpio1_init_verbs
,
5263 [ALC882_FIXUP_GPIO2
] = {
5264 .type
= ALC_FIXUP_VERBS
,
5265 .v
.verbs
= alc_gpio2_init_verbs
,
5267 [ALC882_FIXUP_GPIO3
] = {
5268 .type
= ALC_FIXUP_VERBS
,
5269 .v
.verbs
= alc_gpio3_init_verbs
,
5271 [ALC882_FIXUP_ASUS_W2JC
] = {
5272 .type
= ALC_FIXUP_VERBS
,
5273 .v
.verbs
= alc_gpio1_init_verbs
,
5275 .chain_id
= ALC882_FIXUP_EAPD
,
5277 [ALC889_FIXUP_COEF
] = {
5278 .type
= ALC_FIXUP_FUNC
,
5279 .v
.func
= alc889_fixup_coef
,
5281 [ALC882_FIXUP_ACER_ASPIRE_4930G
] = {
5282 .type
= ALC_FIXUP_PINS
,
5283 .v
.pins
= (const struct alc_pincfg
[]) {
5284 { 0x16, 0x99130111 }, /* CLFE speaker */
5285 { 0x17, 0x99130112 }, /* surround speaker */
5289 .chain_id
= ALC882_FIXUP_GPIO1
,
5291 [ALC882_FIXUP_ACER_ASPIRE_8930G
] = {
5292 .type
= ALC_FIXUP_PINS
,
5293 .v
.pins
= (const struct alc_pincfg
[]) {
5294 { 0x16, 0x99130111 }, /* CLFE speaker */
5295 { 0x1b, 0x99130112 }, /* surround speaker */
5299 .chain_id
= ALC882_FIXUP_ASPIRE_8930G_VERBS
,
5301 [ALC882_FIXUP_ASPIRE_8930G_VERBS
] = {
5302 /* additional init verbs for Acer Aspire 8930G */
5303 .type
= ALC_FIXUP_VERBS
,
5304 .v
.verbs
= (const struct hda_verb
[]) {
5305 /* Enable all DACs */
5306 /* DAC DISABLE/MUTE 1? */
5307 /* setting bits 1-5 disables DAC nids 0x02-0x06
5308 * apparently. Init=0x38 */
5309 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x03 },
5310 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0000 },
5311 /* DAC DISABLE/MUTE 2? */
5312 /* some bit here disables the other DACs.
5314 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x08 },
5315 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0000 },
5317 * This laptop has a stereo digital microphone.
5318 * The mics are only 1cm apart which makes the stereo
5319 * useless. However, either the mic or the ALC889
5320 * makes the signal become a difference/sum signal
5321 * instead of standard stereo, which is annoying.
5322 * So instead we flip this bit which makes the
5323 * codec replicate the sum signal to both channels,
5324 * turning it into a normal mono mic.
5326 /* DMIC_CONTROL? Init value = 0x0001 */
5327 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x0b },
5328 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0003 },
5329 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5330 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5334 .chain_id
= ALC882_FIXUP_GPIO1
,
5336 [ALC885_FIXUP_MACPRO_GPIO
] = {
5337 .type
= ALC_FIXUP_FUNC
,
5338 .v
.func
= alc885_fixup_macpro_gpio
,
5340 [ALC889_FIXUP_DAC_ROUTE
] = {
5341 .type
= ALC_FIXUP_FUNC
,
5342 .v
.func
= alc889_fixup_dac_route
,
5344 [ALC889_FIXUP_MBP_VREF
] = {
5345 .type
= ALC_FIXUP_FUNC
,
5346 .v
.func
= alc889_fixup_mbp_vref
,
5348 .chain_id
= ALC882_FIXUP_GPIO1
,
5350 [ALC889_FIXUP_IMAC91_VREF
] = {
5351 .type
= ALC_FIXUP_FUNC
,
5352 .v
.func
= alc889_fixup_imac91_vref
,
5354 .chain_id
= ALC882_FIXUP_GPIO1
,
5356 [ALC882_FIXUP_INV_DMIC
] = {
5357 .type
= ALC_FIXUP_FUNC
,
5358 .v
.func
= alc_fixup_inv_dmic_0x12
,
5362 static const struct snd_pci_quirk alc882_fixup_tbl
[] = {
5363 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD
),
5364 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD
),
5365 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD
),
5366 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD
),
5367 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD
),
5368 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD
),
5369 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
5370 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5371 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
5372 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5373 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
5374 ALC882_FIXUP_ACER_ASPIRE_8930G
),
5375 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
5376 ALC882_FIXUP_ACER_ASPIRE_8930G
),
5377 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
5378 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5379 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
5380 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5381 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
5382 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5383 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210
),
5384 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
5385 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5386 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE
),
5387 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G
),
5388 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736
),
5389 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD
),
5390 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V
),
5391 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC
),
5392 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601
),
5393 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT
),
5395 /* All Apple entries are in codec SSIDs */
5396 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF
),
5397 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF
),
5398 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF
),
5399 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO
),
5400 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO
),
5401 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO
),
5402 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF
),
5403 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF
),
5404 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD
),
5405 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF
),
5406 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF
),
5407 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF
),
5408 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF
),
5409 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO
),
5410 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF
),
5411 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF
),
5412 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF
),
5413 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO
),
5414 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF
),
5415 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF
),
5416 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF
),
5418 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD
),
5419 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD
),
5420 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3
),
5421 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD
),
5422 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX
),
5423 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD
),
5424 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD
),
5425 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530
),
5426 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF
),
5430 static const struct alc_model_fixup alc882_fixup_models
[] = {
5431 {.id
= ALC882_FIXUP_ACER_ASPIRE_4930G
, .name
= "acer-aspire-4930g"},
5432 {.id
= ALC882_FIXUP_ACER_ASPIRE_8930G
, .name
= "acer-aspire-8930g"},
5433 {.id
= ALC883_FIXUP_ACER_EAPD
, .name
= "acer-aspire"},
5434 {.id
= ALC882_FIXUP_INV_DMIC
, .name
= "inv-dmic"},
5439 * BIOS auto configuration
5441 /* almost identical with ALC880 parser... */
5442 static int alc882_parse_auto_config(struct hda_codec
*codec
)
5444 static const hda_nid_t alc882_ignore
[] = { 0x1d, 0 };
5445 static const hda_nid_t alc882_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5446 return alc_parse_auto_config(codec
, alc882_ignore
, alc882_ssids
);
5451 static int patch_alc882(struct hda_codec
*codec
)
5453 struct alc_spec
*spec
;
5456 err
= alc_alloc_spec(codec
, 0x0b);
5462 switch (codec
->vendor_id
) {
5467 /* ALC883 and variants */
5468 alc_fix_pll_init(codec
, 0x20, 0x0a, 10);
5472 alc_pick_fixup(codec
, alc882_fixup_models
, alc882_fixup_tbl
,
5474 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5476 alc_auto_parse_customize_define(codec
);
5478 /* automatic parse from the BIOS config */
5479 err
= alc882_parse_auto_config(codec
);
5483 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
5484 err
= snd_hda_attach_beep_device(codec
, 0x1);
5487 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
5490 codec
->patch_ops
= alc_patch_ops
;
5492 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5505 static int alc262_parse_auto_config(struct hda_codec
*codec
)
5507 static const hda_nid_t alc262_ignore
[] = { 0x1d, 0 };
5508 static const hda_nid_t alc262_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5509 return alc_parse_auto_config(codec
, alc262_ignore
, alc262_ssids
);
5516 ALC262_FIXUP_FSC_H270
,
5517 ALC262_FIXUP_HP_Z200
,
5519 ALC262_FIXUP_LENOVO_3000
,
5521 ALC262_FIXUP_BENQ_T31
,
5522 ALC262_FIXUP_INV_DMIC
,
5525 static const struct alc_fixup alc262_fixups
[] = {
5526 [ALC262_FIXUP_FSC_H270
] = {
5527 .type
= ALC_FIXUP_PINS
,
5528 .v
.pins
= (const struct alc_pincfg
[]) {
5529 { 0x14, 0x99130110 }, /* speaker */
5530 { 0x15, 0x0221142f }, /* front HP */
5531 { 0x1b, 0x0121141f }, /* rear HP */
5535 [ALC262_FIXUP_HP_Z200
] = {
5536 .type
= ALC_FIXUP_PINS
,
5537 .v
.pins
= (const struct alc_pincfg
[]) {
5538 { 0x16, 0x99130120 }, /* internal speaker */
5542 [ALC262_FIXUP_TYAN
] = {
5543 .type
= ALC_FIXUP_PINS
,
5544 .v
.pins
= (const struct alc_pincfg
[]) {
5545 { 0x14, 0x1993e1f0 }, /* int AUX */
5549 [ALC262_FIXUP_LENOVO_3000
] = {
5550 .type
= ALC_FIXUP_VERBS
,
5551 .v
.verbs
= (const struct hda_verb
[]) {
5552 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF50
},
5556 .chain_id
= ALC262_FIXUP_BENQ
,
5558 [ALC262_FIXUP_BENQ
] = {
5559 .type
= ALC_FIXUP_VERBS
,
5560 .v
.verbs
= (const struct hda_verb
[]) {
5561 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5562 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
5566 [ALC262_FIXUP_BENQ_T31
] = {
5567 .type
= ALC_FIXUP_VERBS
,
5568 .v
.verbs
= (const struct hda_verb
[]) {
5569 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5570 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5574 [ALC262_FIXUP_INV_DMIC
] = {
5575 .type
= ALC_FIXUP_FUNC
,
5576 .v
.func
= alc_fixup_inv_dmic_0x12
,
5580 static const struct snd_pci_quirk alc262_fixup_tbl
[] = {
5581 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200
),
5582 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ
),
5583 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ
),
5584 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN
),
5585 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270
),
5586 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000
),
5587 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ
),
5588 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31
),
5592 static const struct alc_model_fixup alc262_fixup_models
[] = {
5593 {.id
= ALC262_FIXUP_INV_DMIC
, .name
= "inv-dmic"},
5599 static int patch_alc262(struct hda_codec
*codec
)
5601 struct alc_spec
*spec
;
5604 err
= alc_alloc_spec(codec
, 0x0b);
5611 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
5616 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
5617 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
5618 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
5619 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PROC_COEF
, tmp
| 0x80);
5622 alc_fix_pll_init(codec
, 0x20, 0x0a, 10);
5624 alc_pick_fixup(codec
, alc262_fixup_models
, alc262_fixup_tbl
,
5626 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5628 alc_auto_parse_customize_define(codec
);
5630 /* automatic parse from the BIOS config */
5631 err
= alc262_parse_auto_config(codec
);
5635 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
5636 err
= snd_hda_attach_beep_device(codec
, 0x1);
5639 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
5642 codec
->patch_ops
= alc_patch_ops
;
5643 spec
->shutup
= alc_eapd_shutup
;
5645 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5657 /* bind Beep switches of both NID 0x0f and 0x10 */
5658 static const struct hda_bind_ctls alc268_bind_beep_sw
= {
5659 .ops
= &snd_hda_bind_sw
,
5661 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT
),
5662 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT
),
5667 static const struct snd_kcontrol_new alc268_beep_mixer
[] = {
5668 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT
),
5669 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw
),
5673 /* set PCBEEP vol = 0, mute connections */
5674 static const struct hda_verb alc268_beep_init_verbs
[] = {
5675 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5676 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5677 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5682 ALC268_FIXUP_INV_DMIC
,
5685 static const struct alc_fixup alc268_fixups
[] = {
5686 [ALC268_FIXUP_INV_DMIC
] = {
5687 .type
= ALC_FIXUP_FUNC
,
5688 .v
.func
= alc_fixup_inv_dmic_0x12
,
5692 static const struct alc_model_fixup alc268_fixup_models
[] = {
5693 {.id
= ALC268_FIXUP_INV_DMIC
, .name
= "inv-dmic"},
5698 * BIOS auto configuration
5700 static int alc268_parse_auto_config(struct hda_codec
*codec
)
5702 static const hda_nid_t alc268_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5703 struct alc_spec
*spec
= codec
->spec
;
5704 int err
= alc_parse_auto_config(codec
, NULL
, alc268_ssids
);
5706 if (!spec
->no_analog
&& spec
->autocfg
.speaker_pins
[0] != 0x1d) {
5707 add_mixer(spec
, alc268_beep_mixer
);
5708 snd_hda_gen_add_verbs(&spec
->gen
, alc268_beep_init_verbs
);
5716 static int patch_alc268(struct hda_codec
*codec
)
5718 struct alc_spec
*spec
;
5719 int i
, has_beep
, err
;
5721 /* ALC268 has no aa-loopback mixer */
5722 err
= alc_alloc_spec(codec
, 0);
5728 alc_pick_fixup(codec
, alc268_fixup_models
, NULL
, alc268_fixups
);
5729 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5731 /* automatic parse from the BIOS config */
5732 err
= alc268_parse_auto_config(codec
);
5737 for (i
= 0; i
< spec
->num_mixers
; i
++) {
5738 if (spec
->mixers
[i
] == alc268_beep_mixer
) {
5745 err
= snd_hda_attach_beep_device(codec
, 0x1);
5748 if (!query_amp_caps(codec
, 0x1d, HDA_INPUT
))
5749 /* override the amp caps for beep generator */
5750 snd_hda_override_amp_caps(codec
, 0x1d, HDA_INPUT
,
5751 (0x0c << AC_AMPCAP_OFFSET_SHIFT
) |
5752 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT
) |
5753 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
5754 (0 << AC_AMPCAP_MUTE_SHIFT
));
5757 codec
->patch_ops
= alc_patch_ops
;
5758 spec
->shutup
= alc_eapd_shutup
;
5760 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5772 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback
= {
5776 .rates
= SNDRV_PCM_RATE_44100
, /* fixed rate */
5777 /* NID is set in alc_build_pcms */
5779 .open
= alc_playback_pcm_open
,
5780 .prepare
= alc_playback_pcm_prepare
,
5781 .cleanup
= alc_playback_pcm_cleanup
5785 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture
= {
5789 .rates
= SNDRV_PCM_RATE_44100
, /* fixed rate */
5790 /* NID is set in alc_build_pcms */
5793 /* different alc269-variants */
5795 ALC269_TYPE_ALC269VA
,
5796 ALC269_TYPE_ALC269VB
,
5797 ALC269_TYPE_ALC269VC
,
5798 ALC269_TYPE_ALC269VD
,
5802 * BIOS auto configuration
5804 static int alc269_parse_auto_config(struct hda_codec
*codec
)
5806 static const hda_nid_t alc269_ignore
[] = { 0x1d, 0 };
5807 static const hda_nid_t alc269_ssids
[] = { 0, 0x1b, 0x14, 0x21 };
5808 static const hda_nid_t alc269va_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5809 struct alc_spec
*spec
= codec
->spec
;
5810 const hda_nid_t
*ssids
;
5812 switch (spec
->codec_variant
) {
5813 case ALC269_TYPE_ALC269VA
:
5814 case ALC269_TYPE_ALC269VC
:
5815 ssids
= alc269va_ssids
;
5817 case ALC269_TYPE_ALC269VB
:
5818 case ALC269_TYPE_ALC269VD
:
5819 ssids
= alc269_ssids
;
5822 ssids
= alc269_ssids
;
5826 return alc_parse_auto_config(codec
, alc269_ignore
, ssids
);
5829 static void alc269_toggle_power_output(struct hda_codec
*codec
, int power_up
)
5831 int val
= alc_read_coef_idx(codec
, 0x04);
5836 alc_write_coef_idx(codec
, 0x04, val
);
5839 static void alc269_shutup(struct hda_codec
*codec
)
5841 struct alc_spec
*spec
= codec
->spec
;
5843 if (spec
->codec_variant
!= ALC269_TYPE_ALC269VB
)
5846 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017)
5847 alc269_toggle_power_output(codec
, 0);
5848 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
5849 alc269_toggle_power_output(codec
, 0);
5855 static int alc269_resume(struct hda_codec
*codec
)
5857 struct alc_spec
*spec
= codec
->spec
;
5859 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
||
5860 (alc_get_coef0(codec
) & 0x00ff) == 0x018) {
5861 alc269_toggle_power_output(codec
, 0);
5865 codec
->patch_ops
.init(codec
);
5867 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
||
5868 (alc_get_coef0(codec
) & 0x00ff) == 0x017) {
5869 alc269_toggle_power_output(codec
, 1);
5873 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
||
5874 (alc_get_coef0(codec
) & 0x00ff) == 0x018)
5875 alc269_toggle_power_output(codec
, 1);
5877 snd_hda_codec_resume_amp(codec
);
5878 snd_hda_codec_resume_cache(codec
);
5879 hda_call_check_power_status(codec
, 0x01);
5882 #endif /* CONFIG_PM */
5884 static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec
*codec
,
5885 const struct alc_fixup
*fix
, int action
)
5887 struct alc_spec
*spec
= codec
->spec
;
5889 if (action
== ALC_FIXUP_ACT_PRE_PROBE
)
5890 spec
->parse_flags
= HDA_PINCFG_NO_HP_FIXUP
;
5893 static void alc269_fixup_hweq(struct hda_codec
*codec
,
5894 const struct alc_fixup
*fix
, int action
)
5898 if (action
!= ALC_FIXUP_ACT_INIT
)
5900 coef
= alc_read_coef_idx(codec
, 0x1e);
5901 alc_write_coef_idx(codec
, 0x1e, coef
| 0x80);
5904 static void alc271_fixup_dmic(struct hda_codec
*codec
,
5905 const struct alc_fixup
*fix
, int action
)
5907 static const struct hda_verb verbs
[] = {
5908 {0x20, AC_VERB_SET_COEF_INDEX
, 0x0d},
5909 {0x20, AC_VERB_SET_PROC_COEF
, 0x4000},
5914 if (strcmp(codec
->chip_name
, "ALC271X"))
5916 cfg
= snd_hda_codec_get_pincfg(codec
, 0x12);
5917 if (get_defcfg_connect(cfg
) == AC_JACK_PORT_FIXED
)
5918 snd_hda_sequence_write(codec
, verbs
);
5921 static void alc269_fixup_pcm_44k(struct hda_codec
*codec
,
5922 const struct alc_fixup
*fix
, int action
)
5924 struct alc_spec
*spec
= codec
->spec
;
5926 if (action
!= ALC_FIXUP_ACT_PROBE
)
5929 /* Due to a hardware problem on Lenovo Ideadpad, we need to
5930 * fix the sample rate of analog I/O to 44.1kHz
5932 spec
->stream_analog_playback
= &alc269_44k_pcm_analog_playback
;
5933 spec
->stream_analog_capture
= &alc269_44k_pcm_analog_capture
;
5936 static void alc269_fixup_stereo_dmic(struct hda_codec
*codec
,
5937 const struct alc_fixup
*fix
, int action
)
5941 if (action
!= ALC_FIXUP_ACT_INIT
)
5943 /* The digital-mic unit sends PDM (differential signal) instead of
5944 * the standard PCM, thus you can't record a valid mono stream as is.
5945 * Below is a workaround specific to ALC269 to control the dmic
5946 * signal source as mono.
5948 coef
= alc_read_coef_idx(codec
, 0x07);
5949 alc_write_coef_idx(codec
, 0x07, coef
| 0x80);
5952 static void alc269_quanta_automute(struct hda_codec
*codec
)
5954 update_outputs(codec
);
5956 snd_hda_codec_write(codec
, 0x20, 0,
5957 AC_VERB_SET_COEF_INDEX
, 0x0c);
5958 snd_hda_codec_write(codec
, 0x20, 0,
5959 AC_VERB_SET_PROC_COEF
, 0x680);
5961 snd_hda_codec_write(codec
, 0x20, 0,
5962 AC_VERB_SET_COEF_INDEX
, 0x0c);
5963 snd_hda_codec_write(codec
, 0x20, 0,
5964 AC_VERB_SET_PROC_COEF
, 0x480);
5967 static void alc269_fixup_quanta_mute(struct hda_codec
*codec
,
5968 const struct alc_fixup
*fix
, int action
)
5970 struct alc_spec
*spec
= codec
->spec
;
5971 if (action
!= ALC_FIXUP_ACT_PROBE
)
5973 spec
->automute_hook
= alc269_quanta_automute
;
5976 /* update mute-LED according to the speaker mute state via mic2 VREF pin */
5977 static void alc269_fixup_mic2_mute_hook(void *private_data
, int enabled
)
5979 struct hda_codec
*codec
= private_data
;
5980 unsigned int pinval
= enabled
? 0x20 : 0x24;
5981 snd_hda_set_pin_ctl_cache(codec
, 0x19, pinval
);
5984 static void alc269_fixup_mic2_mute(struct hda_codec
*codec
,
5985 const struct alc_fixup
*fix
, int action
)
5987 struct alc_spec
*spec
= codec
->spec
;
5989 case ALC_FIXUP_ACT_BUILD
:
5990 spec
->vmaster_mute
.hook
= alc269_fixup_mic2_mute_hook
;
5991 snd_hda_add_vmaster_hook(codec
, &spec
->vmaster_mute
, true);
5993 case ALC_FIXUP_ACT_INIT
:
5994 snd_hda_sync_vmaster_hook(&spec
->vmaster_mute
);
6001 ALC269_FIXUP_SONY_VAIO
,
6002 ALC275_FIXUP_SONY_VAIO_GPIO2
,
6003 ALC269_FIXUP_DELL_M101Z
,
6004 ALC269_FIXUP_SKU_IGNORE
,
6005 ALC269_FIXUP_ASUS_G73JW
,
6006 ALC269_FIXUP_LENOVO_EAPD
,
6007 ALC275_FIXUP_SONY_HWEQ
,
6009 ALC269_FIXUP_PCM_44K
,
6010 ALC269_FIXUP_STEREO_DMIC
,
6011 ALC269_FIXUP_QUANTA_MUTE
,
6012 ALC269_FIXUP_LIFEBOOK
,
6015 ALC269VB_FIXUP_AMIC
,
6016 ALC269VB_FIXUP_DMIC
,
6017 ALC269_FIXUP_MIC2_MUTE_LED
,
6018 ALC269_FIXUP_INV_DMIC
,
6019 ALC269_FIXUP_LENOVO_DOCK
,
6020 ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
,
6023 static const struct alc_fixup alc269_fixups
[] = {
6024 [ALC269_FIXUP_SONY_VAIO
] = {
6025 .type
= ALC_FIXUP_VERBS
,
6026 .v
.verbs
= (const struct hda_verb
[]) {
6027 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREFGRD
},
6031 [ALC275_FIXUP_SONY_VAIO_GPIO2
] = {
6032 .type
= ALC_FIXUP_VERBS
,
6033 .v
.verbs
= (const struct hda_verb
[]) {
6034 {0x01, AC_VERB_SET_GPIO_MASK
, 0x04},
6035 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x04},
6036 {0x01, AC_VERB_SET_GPIO_DATA
, 0x00},
6040 .chain_id
= ALC269_FIXUP_SONY_VAIO
6042 [ALC269_FIXUP_DELL_M101Z
] = {
6043 .type
= ALC_FIXUP_VERBS
,
6044 .v
.verbs
= (const struct hda_verb
[]) {
6045 /* Enables internal speaker */
6046 {0x20, AC_VERB_SET_COEF_INDEX
, 13},
6047 {0x20, AC_VERB_SET_PROC_COEF
, 0x4040},
6051 [ALC269_FIXUP_SKU_IGNORE
] = {
6052 .type
= ALC_FIXUP_FUNC
,
6053 .v
.func
= alc_fixup_sku_ignore
,
6055 [ALC269_FIXUP_ASUS_G73JW
] = {
6056 .type
= ALC_FIXUP_PINS
,
6057 .v
.pins
= (const struct alc_pincfg
[]) {
6058 { 0x17, 0x99130111 }, /* subwoofer */
6062 [ALC269_FIXUP_LENOVO_EAPD
] = {
6063 .type
= ALC_FIXUP_VERBS
,
6064 .v
.verbs
= (const struct hda_verb
[]) {
6065 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 0},
6069 [ALC275_FIXUP_SONY_HWEQ
] = {
6070 .type
= ALC_FIXUP_FUNC
,
6071 .v
.func
= alc269_fixup_hweq
,
6073 .chain_id
= ALC275_FIXUP_SONY_VAIO_GPIO2
6075 [ALC271_FIXUP_DMIC
] = {
6076 .type
= ALC_FIXUP_FUNC
,
6077 .v
.func
= alc271_fixup_dmic
,
6079 [ALC269_FIXUP_PCM_44K
] = {
6080 .type
= ALC_FIXUP_FUNC
,
6081 .v
.func
= alc269_fixup_pcm_44k
,
6083 [ALC269_FIXUP_STEREO_DMIC
] = {
6084 .type
= ALC_FIXUP_FUNC
,
6085 .v
.func
= alc269_fixup_stereo_dmic
,
6087 [ALC269_FIXUP_QUANTA_MUTE
] = {
6088 .type
= ALC_FIXUP_FUNC
,
6089 .v
.func
= alc269_fixup_quanta_mute
,
6091 [ALC269_FIXUP_LIFEBOOK
] = {
6092 .type
= ALC_FIXUP_PINS
,
6093 .v
.pins
= (const struct alc_pincfg
[]) {
6094 { 0x1a, 0x2101103f }, /* dock line-out */
6095 { 0x1b, 0x23a11040 }, /* dock mic-in */
6099 .chain_id
= ALC269_FIXUP_QUANTA_MUTE
6101 [ALC269_FIXUP_AMIC
] = {
6102 .type
= ALC_FIXUP_PINS
,
6103 .v
.pins
= (const struct alc_pincfg
[]) {
6104 { 0x14, 0x99130110 }, /* speaker */
6105 { 0x15, 0x0121401f }, /* HP out */
6106 { 0x18, 0x01a19c20 }, /* mic */
6107 { 0x19, 0x99a3092f }, /* int-mic */
6111 [ALC269_FIXUP_DMIC
] = {
6112 .type
= ALC_FIXUP_PINS
,
6113 .v
.pins
= (const struct alc_pincfg
[]) {
6114 { 0x12, 0x99a3092f }, /* int-mic */
6115 { 0x14, 0x99130110 }, /* speaker */
6116 { 0x15, 0x0121401f }, /* HP out */
6117 { 0x18, 0x01a19c20 }, /* mic */
6121 [ALC269VB_FIXUP_AMIC
] = {
6122 .type
= ALC_FIXUP_PINS
,
6123 .v
.pins
= (const struct alc_pincfg
[]) {
6124 { 0x14, 0x99130110 }, /* speaker */
6125 { 0x18, 0x01a19c20 }, /* mic */
6126 { 0x19, 0x99a3092f }, /* int-mic */
6127 { 0x21, 0x0121401f }, /* HP out */
6131 [ALC269VB_FIXUP_DMIC
] = {
6132 .type
= ALC_FIXUP_PINS
,
6133 .v
.pins
= (const struct alc_pincfg
[]) {
6134 { 0x12, 0x99a3092f }, /* int-mic */
6135 { 0x14, 0x99130110 }, /* speaker */
6136 { 0x18, 0x01a19c20 }, /* mic */
6137 { 0x21, 0x0121401f }, /* HP out */
6141 [ALC269_FIXUP_MIC2_MUTE_LED
] = {
6142 .type
= ALC_FIXUP_FUNC
,
6143 .v
.func
= alc269_fixup_mic2_mute
,
6145 [ALC269_FIXUP_INV_DMIC
] = {
6146 .type
= ALC_FIXUP_FUNC
,
6147 .v
.func
= alc_fixup_inv_dmic_0x12
,
6149 [ALC269_FIXUP_LENOVO_DOCK
] = {
6150 .type
= ALC_FIXUP_PINS
,
6151 .v
.pins
= (const struct alc_pincfg
[]) {
6152 { 0x19, 0x23a11040 }, /* dock mic */
6153 { 0x1b, 0x2121103f }, /* dock headphone */
6157 .chain_id
= ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
6159 [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
] = {
6160 .type
= ALC_FIXUP_FUNC
,
6161 .v
.func
= alc269_fixup_pincfg_no_hp_to_lineout
,
6165 static const struct snd_pci_quirk alc269_fixup_tbl
[] = {
6166 SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC
),
6167 SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC
),
6168 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED
),
6169 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC
),
6170 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW
),
6171 SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC
),
6172 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC
),
6173 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC
),
6174 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC
),
6175 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC
),
6176 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC
),
6177 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2
),
6178 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ
),
6179 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ
),
6180 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO
),
6181 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z
),
6182 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC
),
6183 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK
),
6184 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE
),
6185 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE
),
6186 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE
),
6187 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE
),
6188 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE
),
6189 SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK
),
6190 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE
),
6191 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K
),
6192 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD
),
6195 /* Below is a quirk table taken from the old code.
6196 * Basically the device should work as is without the fixup table.
6197 * If BIOS doesn't give a proper info, enable the corresponding
6200 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
6202 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC
),
6203 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC
),
6204 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC
),
6205 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC
),
6206 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC
),
6207 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC
),
6208 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC
),
6209 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC
),
6210 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC
),
6211 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC
),
6212 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC
),
6213 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC
),
6214 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC
),
6215 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC
),
6216 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC
),
6217 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC
),
6218 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC
),
6219 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC
),
6220 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC
),
6221 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC
),
6222 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC
),
6223 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC
),
6224 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC
),
6225 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC
),
6226 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC
),
6227 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC
),
6228 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC
),
6229 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC
),
6230 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC
),
6231 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC
),
6232 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC
),
6233 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC
),
6234 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC
),
6235 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC
),
6236 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC
),
6237 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC
),
6238 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC
),
6239 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC
),
6240 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC
),
6245 static const struct alc_model_fixup alc269_fixup_models
[] = {
6246 {.id
= ALC269_FIXUP_AMIC
, .name
= "laptop-amic"},
6247 {.id
= ALC269_FIXUP_DMIC
, .name
= "laptop-dmic"},
6248 {.id
= ALC269_FIXUP_STEREO_DMIC
, .name
= "alc269-dmic"},
6249 {.id
= ALC271_FIXUP_DMIC
, .name
= "alc271-dmic"},
6250 {.id
= ALC269_FIXUP_INV_DMIC
, .name
= "inv-dmic"},
6251 {.id
= ALC269_FIXUP_LENOVO_DOCK
, .name
= "lenovo-dock"},
6256 static void alc269_fill_coef(struct hda_codec
*codec
)
6258 struct alc_spec
*spec
= codec
->spec
;
6261 if (spec
->codec_variant
!= ALC269_TYPE_ALC269VB
)
6264 if ((alc_get_coef0(codec
) & 0x00ff) < 0x015) {
6265 alc_write_coef_idx(codec
, 0xf, 0x960b);
6266 alc_write_coef_idx(codec
, 0xe, 0x8817);
6269 if ((alc_get_coef0(codec
) & 0x00ff) == 0x016) {
6270 alc_write_coef_idx(codec
, 0xf, 0x960b);
6271 alc_write_coef_idx(codec
, 0xe, 0x8814);
6274 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017) {
6275 val
= alc_read_coef_idx(codec
, 0x04);
6276 /* Power up output pin */
6277 alc_write_coef_idx(codec
, 0x04, val
| (1<<11));
6280 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
6281 val
= alc_read_coef_idx(codec
, 0xd);
6282 if ((val
& 0x0c00) >> 10 != 0x1) {
6283 /* Capless ramp up clock control */
6284 alc_write_coef_idx(codec
, 0xd, val
| (1<<10));
6286 val
= alc_read_coef_idx(codec
, 0x17);
6287 if ((val
& 0x01c0) >> 6 != 0x4) {
6288 /* Class D power on reset */
6289 alc_write_coef_idx(codec
, 0x17, val
| (1<<7));
6293 val
= alc_read_coef_idx(codec
, 0xd); /* Class D */
6294 alc_write_coef_idx(codec
, 0xd, val
| (1<<14));
6296 val
= alc_read_coef_idx(codec
, 0x4); /* HP */
6297 alc_write_coef_idx(codec
, 0x4, val
| (1<<11));
6302 static int patch_alc269(struct hda_codec
*codec
)
6304 struct alc_spec
*spec
;
6307 err
= alc_alloc_spec(codec
, 0x0b);
6313 if (codec
->vendor_id
== 0x10ec0269) {
6314 spec
->codec_variant
= ALC269_TYPE_ALC269VA
;
6315 switch (alc_get_coef0(codec
) & 0x00f0) {
6317 if (codec
->bus
->pci
->subsystem_vendor
== 0x1025 &&
6318 spec
->cdefine
.platform_type
== 1)
6319 err
= alc_codec_rename(codec
, "ALC271X");
6320 spec
->codec_variant
= ALC269_TYPE_ALC269VB
;
6323 if (codec
->bus
->pci
->subsystem_vendor
== 0x17aa &&
6324 codec
->bus
->pci
->subsystem_device
== 0x21f3)
6325 err
= alc_codec_rename(codec
, "ALC3202");
6326 spec
->codec_variant
= ALC269_TYPE_ALC269VC
;
6329 spec
->codec_variant
= ALC269_TYPE_ALC269VD
;
6332 alc_fix_pll_init(codec
, 0x20, 0x04, 15);
6336 spec
->init_hook
= alc269_fill_coef
;
6337 alc269_fill_coef(codec
);
6340 alc_pick_fixup(codec
, alc269_fixup_models
,
6341 alc269_fixup_tbl
, alc269_fixups
);
6342 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6344 alc_auto_parse_customize_define(codec
);
6346 /* automatic parse from the BIOS config */
6347 err
= alc269_parse_auto_config(codec
);
6351 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
6352 err
= snd_hda_attach_beep_device(codec
, 0x1);
6355 set_beep_amp(spec
, 0x0b, 0x04, HDA_INPUT
);
6358 codec
->patch_ops
= alc_patch_ops
;
6360 codec
->patch_ops
.resume
= alc269_resume
;
6362 spec
->shutup
= alc269_shutup
;
6364 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6377 static int alc861_parse_auto_config(struct hda_codec
*codec
)
6379 static const hda_nid_t alc861_ignore
[] = { 0x1d, 0 };
6380 static const hda_nid_t alc861_ssids
[] = { 0x0e, 0x0f, 0x0b, 0 };
6381 return alc_parse_auto_config(codec
, alc861_ignore
, alc861_ssids
);
6384 /* Pin config fixes */
6386 ALC861_FIXUP_FSC_AMILO_PI1505
,
6387 ALC861_FIXUP_AMP_VREF_0F
,
6388 ALC861_FIXUP_NO_JACK_DETECT
,
6389 ALC861_FIXUP_ASUS_A6RP
,
6392 /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
6393 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec
*codec
,
6394 const struct alc_fixup
*fix
, int action
)
6396 struct alc_spec
*spec
= codec
->spec
;
6399 if (action
!= ALC_FIXUP_ACT_INIT
)
6401 val
= snd_hda_codec_read(codec
, 0x0f, 0,
6402 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
6403 if (!(val
& (AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
)))
6404 val
|= AC_PINCTL_IN_EN
;
6405 val
|= AC_PINCTL_VREF_50
;
6406 snd_hda_set_pin_ctl(codec
, 0x0f, val
);
6407 spec
->keep_vref_in_automute
= 1;
6410 /* suppress the jack-detection */
6411 static void alc_fixup_no_jack_detect(struct hda_codec
*codec
,
6412 const struct alc_fixup
*fix
, int action
)
6414 if (action
== ALC_FIXUP_ACT_PRE_PROBE
)
6415 codec
->no_jack_detect
= 1;
6418 static const struct alc_fixup alc861_fixups
[] = {
6419 [ALC861_FIXUP_FSC_AMILO_PI1505
] = {
6420 .type
= ALC_FIXUP_PINS
,
6421 .v
.pins
= (const struct alc_pincfg
[]) {
6422 { 0x0b, 0x0221101f }, /* HP */
6423 { 0x0f, 0x90170310 }, /* speaker */
6427 [ALC861_FIXUP_AMP_VREF_0F
] = {
6428 .type
= ALC_FIXUP_FUNC
,
6429 .v
.func
= alc861_fixup_asus_amp_vref_0f
,
6431 [ALC861_FIXUP_NO_JACK_DETECT
] = {
6432 .type
= ALC_FIXUP_FUNC
,
6433 .v
.func
= alc_fixup_no_jack_detect
,
6435 [ALC861_FIXUP_ASUS_A6RP
] = {
6436 .type
= ALC_FIXUP_FUNC
,
6437 .v
.func
= alc861_fixup_asus_amp_vref_0f
,
6439 .chain_id
= ALC861_FIXUP_NO_JACK_DETECT
,
6443 static const struct snd_pci_quirk alc861_fixup_tbl
[] = {
6444 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP
),
6445 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F
),
6446 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT
),
6447 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F
),
6448 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F
),
6449 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505
),
6455 static int patch_alc861(struct hda_codec
*codec
)
6457 struct alc_spec
*spec
;
6460 err
= alc_alloc_spec(codec
, 0x15);
6466 alc_pick_fixup(codec
, NULL
, alc861_fixup_tbl
, alc861_fixups
);
6467 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6469 /* automatic parse from the BIOS config */
6470 err
= alc861_parse_auto_config(codec
);
6474 if (!spec
->no_analog
) {
6475 err
= snd_hda_attach_beep_device(codec
, 0x23);
6478 set_beep_amp(spec
, 0x23, 0, HDA_OUTPUT
);
6481 codec
->patch_ops
= alc_patch_ops
;
6482 #ifdef CONFIG_SND_HDA_POWER_SAVE
6483 spec
->power_hook
= alc_power_eapd
;
6486 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6500 * In addition, an independent DAC
6502 static int alc861vd_parse_auto_config(struct hda_codec
*codec
)
6504 static const hda_nid_t alc861vd_ignore
[] = { 0x1d, 0 };
6505 static const hda_nid_t alc861vd_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
6506 return alc_parse_auto_config(codec
, alc861vd_ignore
, alc861vd_ssids
);
6510 ALC660VD_FIX_ASUS_GPIO1
,
6511 ALC861VD_FIX_DALLAS
,
6514 /* exclude VREF80 */
6515 static void alc861vd_fixup_dallas(struct hda_codec
*codec
,
6516 const struct alc_fixup
*fix
, int action
)
6518 if (action
== ALC_FIXUP_ACT_PRE_PROBE
) {
6519 snd_hda_override_pin_caps(codec
, 0x18, 0x00001714);
6520 snd_hda_override_pin_caps(codec
, 0x19, 0x0000171c);
6524 static const struct alc_fixup alc861vd_fixups
[] = {
6525 [ALC660VD_FIX_ASUS_GPIO1
] = {
6526 .type
= ALC_FIXUP_VERBS
,
6527 .v
.verbs
= (const struct hda_verb
[]) {
6529 {0x01, AC_VERB_SET_GPIO_MASK
, 0x03},
6530 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
6531 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
6535 [ALC861VD_FIX_DALLAS
] = {
6536 .type
= ALC_FIXUP_FUNC
,
6537 .v
.func
= alc861vd_fixup_dallas
,
6541 static const struct snd_pci_quirk alc861vd_fixup_tbl
[] = {
6542 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS
),
6543 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1
),
6544 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS
),
6550 static int patch_alc861vd(struct hda_codec
*codec
)
6552 struct alc_spec
*spec
;
6555 err
= alc_alloc_spec(codec
, 0x0b);
6561 alc_pick_fixup(codec
, NULL
, alc861vd_fixup_tbl
, alc861vd_fixups
);
6562 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6564 /* automatic parse from the BIOS config */
6565 err
= alc861vd_parse_auto_config(codec
);
6569 if (!spec
->no_analog
) {
6570 err
= snd_hda_attach_beep_device(codec
, 0x23);
6573 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
6576 codec
->patch_ops
= alc_patch_ops
;
6578 spec
->shutup
= alc_eapd_shutup
;
6580 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6592 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
6593 * configuration. Each pin widget can choose any input DACs and a mixer.
6594 * Each ADC is connected from a mixer of all inputs. This makes possible
6595 * 6-channel independent captures.
6597 * In addition, an independent DAC for the multi-playback (not used in this
6602 * BIOS auto configuration
6605 static int alc662_parse_auto_config(struct hda_codec
*codec
)
6607 static const hda_nid_t alc662_ignore
[] = { 0x1d, 0 };
6608 static const hda_nid_t alc663_ssids
[] = { 0x15, 0x1b, 0x14, 0x21 };
6609 static const hda_nid_t alc662_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
6610 const hda_nid_t
*ssids
;
6612 if (codec
->vendor_id
== 0x10ec0272 || codec
->vendor_id
== 0x10ec0663 ||
6613 codec
->vendor_id
== 0x10ec0665 || codec
->vendor_id
== 0x10ec0670)
6614 ssids
= alc663_ssids
;
6616 ssids
= alc662_ssids
;
6617 return alc_parse_auto_config(codec
, alc662_ignore
, ssids
);
6620 static void alc272_fixup_mario(struct hda_codec
*codec
,
6621 const struct alc_fixup
*fix
, int action
)
6623 if (action
!= ALC_FIXUP_ACT_PROBE
)
6625 if (snd_hda_override_amp_caps(codec
, 0x2, HDA_OUTPUT
,
6626 (0x3b << AC_AMPCAP_OFFSET_SHIFT
) |
6627 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT
) |
6628 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
6629 (0 << AC_AMPCAP_MUTE_SHIFT
)))
6631 "hda_codec: failed to override amp caps for NID 0x2\n");
6635 ALC662_FIXUP_ASPIRE
,
6636 ALC662_FIXUP_IDEAPAD
,
6638 ALC662_FIXUP_CZC_P10T
,
6639 ALC662_FIXUP_SKU_IGNORE
,
6640 ALC662_FIXUP_HP_RP5800
,
6641 ALC662_FIXUP_ASUS_MODE1
,
6642 ALC662_FIXUP_ASUS_MODE2
,
6643 ALC662_FIXUP_ASUS_MODE3
,
6644 ALC662_FIXUP_ASUS_MODE4
,
6645 ALC662_FIXUP_ASUS_MODE5
,
6646 ALC662_FIXUP_ASUS_MODE6
,
6647 ALC662_FIXUP_ASUS_MODE7
,
6648 ALC662_FIXUP_ASUS_MODE8
,
6649 ALC662_FIXUP_NO_JACK_DETECT
,
6650 ALC662_FIXUP_ZOTAC_Z68
,
6651 ALC662_FIXUP_INV_DMIC
,
6654 static const struct alc_fixup alc662_fixups
[] = {
6655 [ALC662_FIXUP_ASPIRE
] = {
6656 .type
= ALC_FIXUP_PINS
,
6657 .v
.pins
= (const struct alc_pincfg
[]) {
6658 { 0x15, 0x99130112 }, /* subwoofer */
6662 [ALC662_FIXUP_IDEAPAD
] = {
6663 .type
= ALC_FIXUP_PINS
,
6664 .v
.pins
= (const struct alc_pincfg
[]) {
6665 { 0x17, 0x99130112 }, /* subwoofer */
6669 [ALC272_FIXUP_MARIO
] = {
6670 .type
= ALC_FIXUP_FUNC
,
6671 .v
.func
= alc272_fixup_mario
,
6673 [ALC662_FIXUP_CZC_P10T
] = {
6674 .type
= ALC_FIXUP_VERBS
,
6675 .v
.verbs
= (const struct hda_verb
[]) {
6676 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 0},
6680 [ALC662_FIXUP_SKU_IGNORE
] = {
6681 .type
= ALC_FIXUP_FUNC
,
6682 .v
.func
= alc_fixup_sku_ignore
,
6684 [ALC662_FIXUP_HP_RP5800
] = {
6685 .type
= ALC_FIXUP_PINS
,
6686 .v
.pins
= (const struct alc_pincfg
[]) {
6687 { 0x14, 0x0221201f }, /* HP out */
6691 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6693 [ALC662_FIXUP_ASUS_MODE1
] = {
6694 .type
= ALC_FIXUP_PINS
,
6695 .v
.pins
= (const struct alc_pincfg
[]) {
6696 { 0x14, 0x99130110 }, /* speaker */
6697 { 0x18, 0x01a19c20 }, /* mic */
6698 { 0x19, 0x99a3092f }, /* int-mic */
6699 { 0x21, 0x0121401f }, /* HP out */
6703 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6705 [ALC662_FIXUP_ASUS_MODE2
] = {
6706 .type
= ALC_FIXUP_PINS
,
6707 .v
.pins
= (const struct alc_pincfg
[]) {
6708 { 0x14, 0x99130110 }, /* speaker */
6709 { 0x18, 0x01a19820 }, /* mic */
6710 { 0x19, 0x99a3092f }, /* int-mic */
6711 { 0x1b, 0x0121401f }, /* HP out */
6715 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6717 [ALC662_FIXUP_ASUS_MODE3
] = {
6718 .type
= ALC_FIXUP_PINS
,
6719 .v
.pins
= (const struct alc_pincfg
[]) {
6720 { 0x14, 0x99130110 }, /* speaker */
6721 { 0x15, 0x0121441f }, /* HP */
6722 { 0x18, 0x01a19840 }, /* mic */
6723 { 0x19, 0x99a3094f }, /* int-mic */
6724 { 0x21, 0x01211420 }, /* HP2 */
6728 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6730 [ALC662_FIXUP_ASUS_MODE4
] = {
6731 .type
= ALC_FIXUP_PINS
,
6732 .v
.pins
= (const struct alc_pincfg
[]) {
6733 { 0x14, 0x99130110 }, /* speaker */
6734 { 0x16, 0x99130111 }, /* speaker */
6735 { 0x18, 0x01a19840 }, /* mic */
6736 { 0x19, 0x99a3094f }, /* int-mic */
6737 { 0x21, 0x0121441f }, /* HP */
6741 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6743 [ALC662_FIXUP_ASUS_MODE5
] = {
6744 .type
= ALC_FIXUP_PINS
,
6745 .v
.pins
= (const struct alc_pincfg
[]) {
6746 { 0x14, 0x99130110 }, /* speaker */
6747 { 0x15, 0x0121441f }, /* HP */
6748 { 0x16, 0x99130111 }, /* speaker */
6749 { 0x18, 0x01a19840 }, /* mic */
6750 { 0x19, 0x99a3094f }, /* int-mic */
6754 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6756 [ALC662_FIXUP_ASUS_MODE6
] = {
6757 .type
= ALC_FIXUP_PINS
,
6758 .v
.pins
= (const struct alc_pincfg
[]) {
6759 { 0x14, 0x99130110 }, /* speaker */
6760 { 0x15, 0x01211420 }, /* HP2 */
6761 { 0x18, 0x01a19840 }, /* mic */
6762 { 0x19, 0x99a3094f }, /* int-mic */
6763 { 0x1b, 0x0121441f }, /* HP */
6767 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6769 [ALC662_FIXUP_ASUS_MODE7
] = {
6770 .type
= ALC_FIXUP_PINS
,
6771 .v
.pins
= (const struct alc_pincfg
[]) {
6772 { 0x14, 0x99130110 }, /* speaker */
6773 { 0x17, 0x99130111 }, /* speaker */
6774 { 0x18, 0x01a19840 }, /* mic */
6775 { 0x19, 0x99a3094f }, /* int-mic */
6776 { 0x1b, 0x01214020 }, /* HP */
6777 { 0x21, 0x0121401f }, /* HP */
6781 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6783 [ALC662_FIXUP_ASUS_MODE8
] = {
6784 .type
= ALC_FIXUP_PINS
,
6785 .v
.pins
= (const struct alc_pincfg
[]) {
6786 { 0x14, 0x99130110 }, /* speaker */
6787 { 0x12, 0x99a30970 }, /* int-mic */
6788 { 0x15, 0x01214020 }, /* HP */
6789 { 0x17, 0x99130111 }, /* speaker */
6790 { 0x18, 0x01a19840 }, /* mic */
6791 { 0x21, 0x0121401f }, /* HP */
6795 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6797 [ALC662_FIXUP_NO_JACK_DETECT
] = {
6798 .type
= ALC_FIXUP_FUNC
,
6799 .v
.func
= alc_fixup_no_jack_detect
,
6801 [ALC662_FIXUP_ZOTAC_Z68
] = {
6802 .type
= ALC_FIXUP_PINS
,
6803 .v
.pins
= (const struct alc_pincfg
[]) {
6804 { 0x1b, 0x02214020 }, /* Front HP */
6808 [ALC662_FIXUP_INV_DMIC
] = {
6809 .type
= ALC_FIXUP_FUNC
,
6810 .v
.func
= alc_fixup_inv_dmic_0x12
,
6814 static const struct snd_pci_quirk alc662_fixup_tbl
[] = {
6815 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2
),
6816 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE
),
6817 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE
),
6818 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC
),
6819 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE
),
6820 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800
),
6821 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT
),
6822 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2
),
6823 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD
),
6824 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD
),
6825 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD
),
6826 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68
),
6827 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T
),
6830 /* Below is a quirk table taken from the old code.
6831 * Basically the device should work as is without the fixup table.
6832 * If BIOS doesn't give a proper info, enable the corresponding
6835 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1
),
6836 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3
),
6837 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1
),
6838 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3
),
6839 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6840 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6841 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6842 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1
),
6843 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1
),
6844 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6845 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7
),
6846 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7
),
6847 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8
),
6848 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3
),
6849 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1
),
6850 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6851 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2
),
6852 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1
),
6853 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6854 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6855 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6856 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6857 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1
),
6858 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3
),
6859 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2
),
6860 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6861 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5
),
6862 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6863 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6864 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1
),
6865 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6866 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6867 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3
),
6868 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3
),
6869 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1
),
6870 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1
),
6871 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1
),
6872 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1
),
6873 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1
),
6874 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6875 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2
),
6876 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1
),
6877 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6878 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3
),
6879 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1
),
6880 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1
),
6881 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1
),
6882 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2
),
6883 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6884 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4
),
6889 static const struct alc_model_fixup alc662_fixup_models
[] = {
6890 {.id
= ALC272_FIXUP_MARIO
, .name
= "mario"},
6891 {.id
= ALC662_FIXUP_ASUS_MODE1
, .name
= "asus-mode1"},
6892 {.id
= ALC662_FIXUP_ASUS_MODE2
, .name
= "asus-mode2"},
6893 {.id
= ALC662_FIXUP_ASUS_MODE3
, .name
= "asus-mode3"},
6894 {.id
= ALC662_FIXUP_ASUS_MODE4
, .name
= "asus-mode4"},
6895 {.id
= ALC662_FIXUP_ASUS_MODE5
, .name
= "asus-mode5"},
6896 {.id
= ALC662_FIXUP_ASUS_MODE6
, .name
= "asus-mode6"},
6897 {.id
= ALC662_FIXUP_ASUS_MODE7
, .name
= "asus-mode7"},
6898 {.id
= ALC662_FIXUP_ASUS_MODE8
, .name
= "asus-mode8"},
6899 {.id
= ALC662_FIXUP_INV_DMIC
, .name
= "inv-dmic"},
6903 static void alc662_fill_coef(struct hda_codec
*codec
)
6907 coef
= alc_get_coef0(codec
);
6909 switch (codec
->vendor_id
) {
6911 if ((coef
& 0x00f0) == 0x0030) {
6912 val
= alc_read_coef_idx(codec
, 0x4); /* EAPD Ctrl */
6913 alc_write_coef_idx(codec
, 0x4, val
& ~(1<<10));
6923 val
= alc_read_coef_idx(codec
, 0xd); /* EAPD Ctrl */
6924 alc_write_coef_idx(codec
, 0xd, val
| (1<<14));
6931 static int patch_alc662(struct hda_codec
*codec
)
6933 struct alc_spec
*spec
;
6936 err
= alc_alloc_spec(codec
, 0x0b);
6942 /* handle multiple HPs as is */
6943 spec
->parse_flags
= HDA_PINCFG_NO_HP_FIXUP
;
6945 alc_fix_pll_init(codec
, 0x20, 0x04, 15);
6947 spec
->init_hook
= alc662_fill_coef
;
6948 alc662_fill_coef(codec
);
6950 alc_pick_fixup(codec
, alc662_fixup_models
,
6951 alc662_fixup_tbl
, alc662_fixups
);
6952 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6954 alc_auto_parse_customize_define(codec
);
6956 if ((alc_get_coef0(codec
) & (1 << 14)) &&
6957 codec
->bus
->pci
->subsystem_vendor
== 0x1025 &&
6958 spec
->cdefine
.platform_type
== 1) {
6959 if (alc_codec_rename(codec
, "ALC272X") < 0)
6963 /* automatic parse from the BIOS config */
6964 err
= alc662_parse_auto_config(codec
);
6968 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
6969 err
= snd_hda_attach_beep_device(codec
, 0x1);
6972 switch (codec
->vendor_id
) {
6974 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
6979 set_beep_amp(spec
, 0x0b, 0x04, HDA_INPUT
);
6982 set_beep_amp(spec
, 0x0b, 0x03, HDA_INPUT
);
6987 codec
->patch_ops
= alc_patch_ops
;
6988 spec
->shutup
= alc_eapd_shutup
;
6990 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
7003 static int alc680_parse_auto_config(struct hda_codec
*codec
)
7005 return alc_parse_auto_config(codec
, NULL
, NULL
);
7010 static int patch_alc680(struct hda_codec
*codec
)
7014 /* ALC680 has no aa-loopback mixer */
7015 err
= alc_alloc_spec(codec
, 0);
7019 /* automatic parse from the BIOS config */
7020 err
= alc680_parse_auto_config(codec
);
7026 codec
->patch_ops
= alc_patch_ops
;
7034 static const struct hda_codec_preset snd_hda_preset_realtek
[] = {
7035 { .id
= 0x10ec0221, .name
= "ALC221", .patch
= patch_alc269
},
7036 { .id
= 0x10ec0260, .name
= "ALC260", .patch
= patch_alc260
},
7037 { .id
= 0x10ec0262, .name
= "ALC262", .patch
= patch_alc262
},
7038 { .id
= 0x10ec0267, .name
= "ALC267", .patch
= patch_alc268
},
7039 { .id
= 0x10ec0268, .name
= "ALC268", .patch
= patch_alc268
},
7040 { .id
= 0x10ec0269, .name
= "ALC269", .patch
= patch_alc269
},
7041 { .id
= 0x10ec0270, .name
= "ALC270", .patch
= patch_alc269
},
7042 { .id
= 0x10ec0272, .name
= "ALC272", .patch
= patch_alc662
},
7043 { .id
= 0x10ec0275, .name
= "ALC275", .patch
= patch_alc269
},
7044 { .id
= 0x10ec0276, .name
= "ALC276", .patch
= patch_alc269
},
7045 { .id
= 0x10ec0280, .name
= "ALC280", .patch
= patch_alc269
},
7046 { .id
= 0x10ec0282, .name
= "ALC282", .patch
= patch_alc269
},
7047 { .id
= 0x10ec0861, .rev
= 0x100340, .name
= "ALC660",
7048 .patch
= patch_alc861
},
7049 { .id
= 0x10ec0660, .name
= "ALC660-VD", .patch
= patch_alc861vd
},
7050 { .id
= 0x10ec0861, .name
= "ALC861", .patch
= patch_alc861
},
7051 { .id
= 0x10ec0862, .name
= "ALC861-VD", .patch
= patch_alc861vd
},
7052 { .id
= 0x10ec0662, .rev
= 0x100002, .name
= "ALC662 rev2",
7053 .patch
= patch_alc882
},
7054 { .id
= 0x10ec0662, .rev
= 0x100101, .name
= "ALC662 rev1",
7055 .patch
= patch_alc662
},
7056 { .id
= 0x10ec0662, .rev
= 0x100300, .name
= "ALC662 rev3",
7057 .patch
= patch_alc662
},
7058 { .id
= 0x10ec0663, .name
= "ALC663", .patch
= patch_alc662
},
7059 { .id
= 0x10ec0665, .name
= "ALC665", .patch
= patch_alc662
},
7060 { .id
= 0x10ec0670, .name
= "ALC670", .patch
= patch_alc662
},
7061 { .id
= 0x10ec0680, .name
= "ALC680", .patch
= patch_alc680
},
7062 { .id
= 0x10ec0880, .name
= "ALC880", .patch
= patch_alc880
},
7063 { .id
= 0x10ec0882, .name
= "ALC882", .patch
= patch_alc882
},
7064 { .id
= 0x10ec0883, .name
= "ALC883", .patch
= patch_alc882
},
7065 { .id
= 0x10ec0885, .rev
= 0x100101, .name
= "ALC889A",
7066 .patch
= patch_alc882
},
7067 { .id
= 0x10ec0885, .rev
= 0x100103, .name
= "ALC889A",
7068 .patch
= patch_alc882
},
7069 { .id
= 0x10ec0885, .name
= "ALC885", .patch
= patch_alc882
},
7070 { .id
= 0x10ec0887, .name
= "ALC887", .patch
= patch_alc882
},
7071 { .id
= 0x10ec0888, .rev
= 0x100101, .name
= "ALC1200",
7072 .patch
= patch_alc882
},
7073 { .id
= 0x10ec0888, .name
= "ALC888", .patch
= patch_alc882
},
7074 { .id
= 0x10ec0889, .name
= "ALC889", .patch
= patch_alc882
},
7075 { .id
= 0x10ec0892, .name
= "ALC892", .patch
= patch_alc662
},
7076 { .id
= 0x10ec0899, .name
= "ALC898", .patch
= patch_alc882
},
7080 MODULE_ALIAS("snd-hda-codec-id:10ec*");
7082 MODULE_LICENSE("GPL");
7083 MODULE_DESCRIPTION("Realtek HD-audio codec");
7085 static struct hda_codec_preset_list realtek_list
= {
7086 .preset
= snd_hda_preset_realtek
,
7087 .owner
= THIS_MODULE
,
7090 static int __init
patch_realtek_init(void)
7092 return snd_hda_add_codec_preset(&realtek_list
);
7095 static void __exit
patch_realtek_exit(void)
7097 snd_hda_delete_codec_preset(&realtek_list
);
7100 module_init(patch_realtek_init
)
7101 module_exit(patch_realtek_exit
)