2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for Realtek ALC codecs
6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
8 * Takashi Iwai <tiwai@suse.de>
9 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <linux/module.h>
31 #include <sound/core.h>
32 #include <sound/jack.h>
33 #include "hda_codec.h"
34 #include "hda_local.h"
38 /* unsol event tags */
39 #define ALC_FRONT_EVENT 0x01
40 #define ALC_DCVOL_EVENT 0x02
41 #define ALC_HP_EVENT 0x04
42 #define ALC_MIC_EVENT 0x08
45 #define GPIO_MASK 0x03
47 /* extra amp-initialization sequence types */
56 struct alc_customize_define
{
58 unsigned char port_connectivity
;
59 unsigned char check_sum
;
60 unsigned char customization
;
61 unsigned char external_amp
;
62 unsigned int enable_pcbeep
:1;
63 unsigned int platform_type
:1;
65 unsigned int override
:1;
66 unsigned int fixup
:1; /* Means that this sku is set by driver, not read from hw */
72 hda_nid_t pin
; /* multi-io widget pin NID */
73 hda_nid_t dac
; /* DAC to be connected */
74 unsigned int ctl_in
; /* cached input-pin control value */
78 ALC_AUTOMUTE_PIN
, /* change the pin control */
79 ALC_AUTOMUTE_AMP
, /* mute/unmute the pin AMP */
80 ALC_AUTOMUTE_MIXER
, /* mute/unmute mixer widget AMP */
83 #define MAX_VOL_NIDS 0x40
86 /* codec parameterization */
87 const struct snd_kcontrol_new
*mixers
[5]; /* mixer arrays */
88 unsigned int num_mixers
;
89 const struct snd_kcontrol_new
*cap_mixer
; /* capture mixer */
90 unsigned int beep_amp
; /* beep amp value, set via set_beep_amp() */
92 const struct hda_verb
*init_verbs
[10]; /* initialization verbs
96 unsigned int num_init_verbs
;
98 char stream_name_analog
[32]; /* analog PCM stream */
99 const struct hda_pcm_stream
*stream_analog_playback
;
100 const struct hda_pcm_stream
*stream_analog_capture
;
101 const struct hda_pcm_stream
*stream_analog_alt_playback
;
102 const struct hda_pcm_stream
*stream_analog_alt_capture
;
104 char stream_name_digital
[32]; /* digital PCM stream */
105 const struct hda_pcm_stream
*stream_digital_playback
;
106 const struct hda_pcm_stream
*stream_digital_capture
;
109 struct hda_multi_out multiout
; /* playback set-up
110 * max_channels, dacs must be set
111 * dig_out_nid and hp_nid are optional
113 hda_nid_t alt_dac_nid
;
114 hda_nid_t slave_dig_outs
[3]; /* optional - for auto-parsing */
118 unsigned int num_adc_nids
;
119 const hda_nid_t
*adc_nids
;
120 const hda_nid_t
*capsrc_nids
;
121 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
122 hda_nid_t mixer_nid
; /* analog-mixer NID */
123 DECLARE_BITMAP(vol_ctls
, MAX_VOL_NIDS
<< 1);
124 DECLARE_BITMAP(sw_ctls
, MAX_VOL_NIDS
<< 1);
126 /* capture setup for dynamic dual-adc switch */
128 unsigned int cur_adc_stream_tag
;
129 unsigned int cur_adc_format
;
132 unsigned int num_mux_defs
;
133 const struct hda_input_mux
*input_mux
;
134 unsigned int cur_mux
[3];
135 hda_nid_t ext_mic_pin
;
136 hda_nid_t dock_mic_pin
;
137 hda_nid_t int_mic_pin
;
140 const struct hda_channel_mode
*channel_mode
;
141 int num_channel_mode
;
143 int const_channel_count
;
144 int ext_channel_count
;
146 /* PCM information */
147 struct hda_pcm pcm_rec
[3]; /* used in alc_build_pcms() */
149 /* dynamic controls, init_verbs and input_mux */
150 struct auto_pin_cfg autocfg
;
151 struct alc_customize_define cdefine
;
152 struct snd_array kctls
;
153 struct hda_input_mux private_imux
[3];
154 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
155 hda_nid_t private_adc_nids
[AUTO_CFG_MAX_OUTS
];
156 hda_nid_t private_capsrc_nids
[AUTO_CFG_MAX_OUTS
];
157 hda_nid_t imux_pins
[HDA_MAX_NUM_INPUTS
];
158 unsigned int dyn_adc_idx
[HDA_MAX_NUM_INPUTS
];
159 int int_mic_idx
, ext_mic_idx
, dock_mic_idx
; /* for auto-mic */
162 void (*init_hook
)(struct hda_codec
*codec
);
163 void (*unsol_event
)(struct hda_codec
*codec
, unsigned int res
);
164 #ifdef CONFIG_SND_HDA_POWER_SAVE
165 void (*power_hook
)(struct hda_codec
*codec
);
167 void (*shutup
)(struct hda_codec
*codec
);
168 void (*automute_hook
)(struct hda_codec
*codec
);
170 /* for pin sensing */
171 unsigned int hp_jack_present
:1;
172 unsigned int line_jack_present
:1;
173 unsigned int master_mute
:1;
174 unsigned int auto_mic
:1;
175 unsigned int auto_mic_valid_imux
:1; /* valid imux for auto-mic */
176 unsigned int automute_speaker
:1; /* automute speaker outputs */
177 unsigned int automute_lo
:1; /* automute LO outputs */
178 unsigned int detect_hp
:1; /* Headphone detection enabled */
179 unsigned int detect_lo
:1; /* Line-out detection enabled */
180 unsigned int automute_speaker_possible
:1; /* there are speakers and either LO or HP */
181 unsigned int automute_lo_possible
:1; /* there are line outs and HP */
182 unsigned int keep_vref_in_automute
:1; /* Don't clear VREF in automute */
185 unsigned int no_analog
:1; /* digital I/O only */
186 unsigned int dyn_adc_switch
:1; /* switch ADCs (for ALC275) */
187 unsigned int single_input_src
:1;
188 unsigned int vol_in_capsrc
:1; /* use capsrc volume (ADC has no vol) */
189 unsigned int parse_flags
; /* passed to snd_hda_parse_pin_defcfg() */
190 unsigned int shared_mic_hp
:1; /* HP/Mic-in sharing */
192 /* auto-mute control */
194 hda_nid_t automute_mixer_nid
[AUTO_CFG_MAX_OUTS
];
197 int codec_variant
; /* flag for other variants */
199 /* for virtual master */
200 hda_nid_t vmaster_nid
;
201 #ifdef CONFIG_SND_HDA_POWER_SAVE
202 struct hda_loopback_check loopback
;
207 unsigned int pll_coef_idx
, pll_coef_bit
;
212 const struct alc_fixup
*fixup_list
;
213 const char *fixup_name
;
217 struct alc_multi_io multi_io
[4];
220 struct snd_array bind_ctls
;
223 #define ALC_MODEL_AUTO 0 /* common for all chips */
225 static bool check_amp_caps(struct hda_codec
*codec
, hda_nid_t nid
,
226 int dir
, unsigned int bits
)
230 if (get_wcaps(codec
, nid
) & (1 << (dir
+ 1)))
231 if (query_amp_caps(codec
, nid
, dir
) & bits
)
236 #define nid_has_mute(codec, nid, dir) \
237 check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE)
238 #define nid_has_volume(codec, nid, dir) \
239 check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS)
244 static int alc_mux_enum_info(struct snd_kcontrol
*kcontrol
,
245 struct snd_ctl_elem_info
*uinfo
)
247 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
248 struct alc_spec
*spec
= codec
->spec
;
249 unsigned int mux_idx
= snd_ctl_get_ioffidx(kcontrol
, &uinfo
->id
);
250 if (mux_idx
>= spec
->num_mux_defs
)
252 if (!spec
->input_mux
[mux_idx
].num_items
&& mux_idx
> 0)
254 return snd_hda_input_mux_info(&spec
->input_mux
[mux_idx
], uinfo
);
257 static int alc_mux_enum_get(struct snd_kcontrol
*kcontrol
,
258 struct snd_ctl_elem_value
*ucontrol
)
260 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
261 struct alc_spec
*spec
= codec
->spec
;
262 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
264 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
268 static bool alc_dyn_adc_pcm_resetup(struct hda_codec
*codec
, int cur
)
270 struct alc_spec
*spec
= codec
->spec
;
271 hda_nid_t new_adc
= spec
->adc_nids
[spec
->dyn_adc_idx
[cur
]];
273 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
274 /* stream is running, let's swap the current ADC */
275 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
276 spec
->cur_adc
= new_adc
;
277 snd_hda_codec_setup_stream(codec
, new_adc
,
278 spec
->cur_adc_stream_tag
, 0,
279 spec
->cur_adc_format
);
285 static inline hda_nid_t
get_capsrc(struct alc_spec
*spec
, int idx
)
287 return spec
->capsrc_nids
?
288 spec
->capsrc_nids
[idx
] : spec
->adc_nids
[idx
];
291 static void call_update_outputs(struct hda_codec
*codec
);
293 /* select the given imux item; either unmute exclusively or select the route */
294 static int alc_mux_select(struct hda_codec
*codec
, unsigned int adc_idx
,
295 unsigned int idx
, bool force
)
297 struct alc_spec
*spec
= codec
->spec
;
298 const struct hda_input_mux
*imux
;
299 unsigned int mux_idx
;
300 int i
, type
, num_conns
;
303 mux_idx
= adc_idx
>= spec
->num_mux_defs
? 0 : adc_idx
;
304 imux
= &spec
->input_mux
[mux_idx
];
305 if (!imux
->num_items
&& mux_idx
> 0)
306 imux
= &spec
->input_mux
[0];
307 if (!imux
->num_items
)
310 if (idx
>= imux
->num_items
)
311 idx
= imux
->num_items
- 1;
312 if (spec
->cur_mux
[adc_idx
] == idx
&& !force
)
314 spec
->cur_mux
[adc_idx
] = idx
;
316 /* for shared I/O, change the pin-control accordingly */
317 if (spec
->shared_mic_hp
) {
318 /* NOTE: this assumes that there are only two inputs, the
319 * first is the real internal mic and the second is HP jack.
321 snd_hda_codec_write(codec
, spec
->autocfg
.inputs
[1].pin
, 0,
322 AC_VERB_SET_PIN_WIDGET_CONTROL
,
323 spec
->cur_mux
[adc_idx
] ?
324 PIN_VREF80
: PIN_HP
);
325 spec
->automute_speaker
= !spec
->cur_mux
[adc_idx
];
326 call_update_outputs(codec
);
329 if (spec
->dyn_adc_switch
) {
330 alc_dyn_adc_pcm_resetup(codec
, idx
);
331 adc_idx
= spec
->dyn_adc_idx
[idx
];
334 nid
= get_capsrc(spec
, adc_idx
);
337 num_conns
= snd_hda_get_conn_list(codec
, nid
, NULL
);
341 type
= get_wcaps_type(get_wcaps(codec
, nid
));
342 if (type
== AC_WID_AUD_MIX
) {
343 /* Matrix-mixer style (e.g. ALC882) */
344 int active
= imux
->items
[idx
].index
;
345 for (i
= 0; i
< num_conns
; i
++) {
346 unsigned int v
= (i
== active
) ? 0 : HDA_AMP_MUTE
;
347 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, i
,
351 /* MUX style (e.g. ALC880) */
352 snd_hda_codec_write_cache(codec
, nid
, 0,
353 AC_VERB_SET_CONNECT_SEL
,
354 imux
->items
[idx
].index
);
359 static int alc_mux_enum_put(struct snd_kcontrol
*kcontrol
,
360 struct snd_ctl_elem_value
*ucontrol
)
362 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
363 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
364 return alc_mux_select(codec
, adc_idx
,
365 ucontrol
->value
.enumerated
.item
[0], false);
369 * set up the input pin config (depending on the given auto-pin type)
371 static void alc_set_input_pin(struct hda_codec
*codec
, hda_nid_t nid
,
374 unsigned int val
= PIN_IN
;
376 if (auto_pin_type
== AUTO_PIN_MIC
) {
379 oldval
= snd_hda_codec_read(codec
, nid
, 0,
380 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
381 pincap
= snd_hda_query_pin_caps(codec
, nid
);
382 pincap
= (pincap
& AC_PINCAP_VREF
) >> AC_PINCAP_VREF_SHIFT
;
383 /* if the default pin setup is vref50, we give it priority */
384 if ((pincap
& AC_PINCAP_VREF_80
) && oldval
!= PIN_VREF50
)
386 else if (pincap
& AC_PINCAP_VREF_50
)
388 else if (pincap
& AC_PINCAP_VREF_100
)
390 else if (pincap
& AC_PINCAP_VREF_GRD
)
393 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, val
);
397 * Append the given mixer and verb elements for the later use
398 * The mixer array is referred in build_controls(), and init_verbs are
401 static void add_mixer(struct alc_spec
*spec
, const struct snd_kcontrol_new
*mix
)
403 if (snd_BUG_ON(spec
->num_mixers
>= ARRAY_SIZE(spec
->mixers
)))
405 spec
->mixers
[spec
->num_mixers
++] = mix
;
408 static void add_verb(struct alc_spec
*spec
, const struct hda_verb
*verb
)
410 if (snd_BUG_ON(spec
->num_init_verbs
>= ARRAY_SIZE(spec
->init_verbs
)))
412 spec
->init_verbs
[spec
->num_init_verbs
++] = verb
;
416 * GPIO setup tables, used in initialization
418 /* Enable GPIO mask and set output */
419 static const struct hda_verb alc_gpio1_init_verbs
[] = {
420 {0x01, AC_VERB_SET_GPIO_MASK
, 0x01},
421 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
422 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
426 static const struct hda_verb alc_gpio2_init_verbs
[] = {
427 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
428 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
429 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02},
433 static const struct hda_verb alc_gpio3_init_verbs
[] = {
434 {0x01, AC_VERB_SET_GPIO_MASK
, 0x03},
435 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x03},
436 {0x01, AC_VERB_SET_GPIO_DATA
, 0x03},
441 * Fix hardware PLL issue
442 * On some codecs, the analog PLL gating control must be off while
443 * the default value is 1.
445 static void alc_fix_pll(struct hda_codec
*codec
)
447 struct alc_spec
*spec
= codec
->spec
;
452 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_COEF_INDEX
,
454 val
= snd_hda_codec_read(codec
, spec
->pll_nid
, 0,
455 AC_VERB_GET_PROC_COEF
, 0);
456 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_COEF_INDEX
,
458 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_PROC_COEF
,
459 val
& ~(1 << spec
->pll_coef_bit
));
462 static void alc_fix_pll_init(struct hda_codec
*codec
, hda_nid_t nid
,
463 unsigned int coef_idx
, unsigned int coef_bit
)
465 struct alc_spec
*spec
= codec
->spec
;
467 spec
->pll_coef_idx
= coef_idx
;
468 spec
->pll_coef_bit
= coef_bit
;
473 * Jack detections for HP auto-mute and mic-switch
476 /* check each pin in the given array; returns true if any of them is plugged */
477 static bool detect_jacks(struct hda_codec
*codec
, int num_pins
, hda_nid_t
*pins
)
481 for (i
= 0; i
< num_pins
; i
++) {
482 hda_nid_t nid
= pins
[i
];
485 present
|= snd_hda_jack_detect(codec
, nid
);
490 /* standard HP/line-out auto-mute helper */
491 static void do_automute(struct hda_codec
*codec
, int num_pins
, hda_nid_t
*pins
,
492 bool mute
, bool hp_out
)
494 struct alc_spec
*spec
= codec
->spec
;
495 unsigned int mute_bits
= mute
? HDA_AMP_MUTE
: 0;
496 unsigned int pin_bits
= mute
? 0 : (hp_out
? PIN_HP
: PIN_OUT
);
499 for (i
= 0; i
< num_pins
; i
++) {
500 hda_nid_t nid
= pins
[i
];
504 switch (spec
->automute_mode
) {
505 case ALC_AUTOMUTE_PIN
:
506 /* don't reset VREF value in case it's controlling
507 * the amp (see alc861_fixup_asus_amp_vref_0f())
509 if (spec
->keep_vref_in_automute
) {
510 val
= snd_hda_codec_read(codec
, nid
, 0,
511 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
516 snd_hda_codec_write(codec
, nid
, 0,
517 AC_VERB_SET_PIN_WIDGET_CONTROL
,
520 case ALC_AUTOMUTE_AMP
:
521 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
522 HDA_AMP_MUTE
, mute_bits
);
524 case ALC_AUTOMUTE_MIXER
:
525 nid
= spec
->automute_mixer_nid
[i
];
528 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, 0,
529 HDA_AMP_MUTE
, mute_bits
);
530 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, 1,
531 HDA_AMP_MUTE
, mute_bits
);
537 /* Toggle outputs muting */
538 static void update_outputs(struct hda_codec
*codec
)
540 struct alc_spec
*spec
= codec
->spec
;
543 /* Control HP pins/amps depending on master_mute state;
544 * in general, HP pins/amps control should be enabled in all cases,
545 * but currently set only for master_mute, just to be safe
547 if (!spec
->shared_mic_hp
) /* don't change HP-pin when shared with mic */
548 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.hp_pins
),
549 spec
->autocfg
.hp_pins
, spec
->master_mute
, true);
551 if (!spec
->automute_speaker
)
554 on
= spec
->hp_jack_present
| spec
->line_jack_present
;
555 on
|= spec
->master_mute
;
556 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.speaker_pins
),
557 spec
->autocfg
.speaker_pins
, on
, false);
559 /* toggle line-out mutes if needed, too */
560 /* if LO is a copy of either HP or Speaker, don't need to handle it */
561 if (spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.hp_pins
[0] ||
562 spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.speaker_pins
[0])
564 if (!spec
->automute_lo
)
567 on
= spec
->hp_jack_present
;
568 on
|= spec
->master_mute
;
569 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.line_out_pins
),
570 spec
->autocfg
.line_out_pins
, on
, false);
573 static void call_update_outputs(struct hda_codec
*codec
)
575 struct alc_spec
*spec
= codec
->spec
;
576 if (spec
->automute_hook
)
577 spec
->automute_hook(codec
);
579 update_outputs(codec
);
582 /* standard HP-automute helper */
583 static void alc_hp_automute(struct hda_codec
*codec
)
585 struct alc_spec
*spec
= codec
->spec
;
587 spec
->hp_jack_present
=
588 detect_jacks(codec
, ARRAY_SIZE(spec
->autocfg
.hp_pins
),
589 spec
->autocfg
.hp_pins
);
590 if (!spec
->detect_hp
|| (!spec
->automute_speaker
&& !spec
->automute_lo
))
592 call_update_outputs(codec
);
595 /* standard line-out-automute helper */
596 static void alc_line_automute(struct hda_codec
*codec
)
598 struct alc_spec
*spec
= codec
->spec
;
600 /* check LO jack only when it's different from HP */
601 if (spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.hp_pins
[0])
604 spec
->line_jack_present
=
605 detect_jacks(codec
, ARRAY_SIZE(spec
->autocfg
.line_out_pins
),
606 spec
->autocfg
.line_out_pins
);
607 if (!spec
->automute_speaker
|| !spec
->detect_lo
)
609 call_update_outputs(codec
);
612 #define get_connection_index(codec, mux, nid) \
613 snd_hda_get_conn_index(codec, mux, nid, 0)
615 /* standard mic auto-switch helper */
616 static void alc_mic_automute(struct hda_codec
*codec
)
618 struct alc_spec
*spec
= codec
->spec
;
619 hda_nid_t
*pins
= spec
->imux_pins
;
621 if (!spec
->auto_mic
|| !spec
->auto_mic_valid_imux
)
623 if (snd_BUG_ON(!spec
->adc_nids
))
625 if (snd_BUG_ON(spec
->int_mic_idx
< 0 || spec
->ext_mic_idx
< 0))
628 if (snd_hda_jack_detect(codec
, pins
[spec
->ext_mic_idx
]))
629 alc_mux_select(codec
, 0, spec
->ext_mic_idx
, false);
630 else if (spec
->dock_mic_idx
>= 0 &&
631 snd_hda_jack_detect(codec
, pins
[spec
->dock_mic_idx
]))
632 alc_mux_select(codec
, 0, spec
->dock_mic_idx
, false);
634 alc_mux_select(codec
, 0, spec
->int_mic_idx
, false);
637 /* handle the specified unsol action (ALC_XXX_EVENT) */
638 static void alc_exec_unsol_event(struct hda_codec
*codec
, int action
)
642 alc_hp_automute(codec
);
644 case ALC_FRONT_EVENT
:
645 alc_line_automute(codec
);
648 alc_mic_automute(codec
);
651 snd_hda_jack_report_sync(codec
);
654 /* update the master volume per volume-knob's unsol event */
655 static void alc_update_knob_master(struct hda_codec
*codec
, hda_nid_t nid
)
658 struct snd_kcontrol
*kctl
;
659 struct snd_ctl_elem_value
*uctl
;
661 kctl
= snd_hda_find_mixer_ctl(codec
, "Master Playback Volume");
664 uctl
= kzalloc(sizeof(*uctl
), GFP_KERNEL
);
667 val
= snd_hda_codec_read(codec
, nid
, 0,
668 AC_VERB_GET_VOLUME_KNOB_CONTROL
, 0);
669 val
&= HDA_AMP_VOLMASK
;
670 uctl
->value
.integer
.value
[0] = val
;
671 uctl
->value
.integer
.value
[1] = val
;
672 kctl
->put(kctl
, uctl
);
676 /* unsolicited event for HP jack sensing */
677 static void alc_sku_unsol_event(struct hda_codec
*codec
, unsigned int res
)
681 if (codec
->vendor_id
== 0x10ec0880)
685 action
= snd_hda_jack_get_action(codec
, res
);
686 if (res
== ALC_DCVOL_EVENT
) {
687 /* Execute the dc-vol event here as it requires the NID
688 * but we don't pass NID to alc_exec_unsol_event().
689 * Once when we convert all static quirks to the auto-parser,
690 * this can be integerated into there.
692 struct hda_jack_tbl
*jack
;
693 jack
= snd_hda_jack_tbl_get_from_tag(codec
, res
);
695 alc_update_knob_master(codec
, jack
->nid
);
698 alc_exec_unsol_event(codec
, action
);
701 /* call init functions of standard auto-mute helpers */
702 static void alc_inithook(struct hda_codec
*codec
)
704 alc_hp_automute(codec
);
705 alc_line_automute(codec
);
706 alc_mic_automute(codec
);
709 /* additional initialization for ALC888 variants */
710 static void alc888_coef_init(struct hda_codec
*codec
)
714 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 0);
715 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
716 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
717 if ((tmp
& 0xf0) == 0x20)
719 snd_hda_codec_read(codec
, 0x20, 0,
720 AC_VERB_SET_PROC_COEF
, 0x830);
723 snd_hda_codec_read(codec
, 0x20, 0,
724 AC_VERB_SET_PROC_COEF
, 0x3030);
727 /* additional initialization for ALC889 variants */
728 static void alc889_coef_init(struct hda_codec
*codec
)
732 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
733 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
734 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
735 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_PROC_COEF
, tmp
|0x2010);
738 /* turn on/off EAPD control (only if available) */
739 static void set_eapd(struct hda_codec
*codec
, hda_nid_t nid
, int on
)
741 if (get_wcaps_type(get_wcaps(codec
, nid
)) != AC_WID_PIN
)
743 if (snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_EAPD
)
744 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_EAPD_BTLENABLE
,
748 /* turn on/off EAPD controls of the codec */
749 static void alc_auto_setup_eapd(struct hda_codec
*codec
, bool on
)
751 /* We currently only handle front, HP */
752 static hda_nid_t pins
[] = {
753 0x0f, 0x10, 0x14, 0x15, 0
756 for (p
= pins
; *p
; p
++)
757 set_eapd(codec
, *p
, on
);
760 /* generic shutup callback;
761 * just turning off EPAD and a little pause for avoiding pop-noise
763 static void alc_eapd_shutup(struct hda_codec
*codec
)
765 alc_auto_setup_eapd(codec
, false);
769 /* generic EAPD initialization */
770 static void alc_auto_init_amp(struct hda_codec
*codec
, int type
)
774 alc_auto_setup_eapd(codec
, true);
777 snd_hda_sequence_write(codec
, alc_gpio1_init_verbs
);
780 snd_hda_sequence_write(codec
, alc_gpio2_init_verbs
);
783 snd_hda_sequence_write(codec
, alc_gpio3_init_verbs
);
785 case ALC_INIT_DEFAULT
:
786 switch (codec
->vendor_id
) {
788 snd_hda_codec_write(codec
, 0x1a, 0,
789 AC_VERB_SET_COEF_INDEX
, 7);
790 tmp
= snd_hda_codec_read(codec
, 0x1a, 0,
791 AC_VERB_GET_PROC_COEF
, 0);
792 snd_hda_codec_write(codec
, 0x1a, 0,
793 AC_VERB_SET_COEF_INDEX
, 7);
794 snd_hda_codec_write(codec
, 0x1a, 0,
795 AC_VERB_SET_PROC_COEF
,
804 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
805 alc889_coef_init(codec
);
808 alc888_coef_init(codec
);
810 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
813 snd_hda_codec_write(codec
, 0x20, 0,
814 AC_VERB_SET_COEF_INDEX
, 7);
815 tmp
= snd_hda_codec_read(codec
, 0x20, 0,
816 AC_VERB_GET_PROC_COEF
, 0);
817 snd_hda_codec_write(codec
, 0x20, 0,
818 AC_VERB_SET_COEF_INDEX
, 7);
819 snd_hda_codec_write(codec
, 0x20, 0,
820 AC_VERB_SET_PROC_COEF
,
830 * Auto-Mute mode mixer enum support
832 static int alc_automute_mode_info(struct snd_kcontrol
*kcontrol
,
833 struct snd_ctl_elem_info
*uinfo
)
835 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
836 struct alc_spec
*spec
= codec
->spec
;
837 static const char * const texts2
[] = {
838 "Disabled", "Enabled"
840 static const char * const texts3
[] = {
841 "Disabled", "Speaker Only", "Line-Out+Speaker"
843 const char * const *texts
;
845 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
847 if (spec
->automute_speaker_possible
&& spec
->automute_lo_possible
) {
848 uinfo
->value
.enumerated
.items
= 3;
851 uinfo
->value
.enumerated
.items
= 2;
854 if (uinfo
->value
.enumerated
.item
>= uinfo
->value
.enumerated
.items
)
855 uinfo
->value
.enumerated
.item
= uinfo
->value
.enumerated
.items
- 1;
856 strcpy(uinfo
->value
.enumerated
.name
,
857 texts
[uinfo
->value
.enumerated
.item
]);
861 static int alc_automute_mode_get(struct snd_kcontrol
*kcontrol
,
862 struct snd_ctl_elem_value
*ucontrol
)
864 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
865 struct alc_spec
*spec
= codec
->spec
;
866 unsigned int val
= 0;
867 if (spec
->automute_speaker
)
869 if (spec
->automute_lo
)
872 ucontrol
->value
.enumerated
.item
[0] = val
;
876 static int alc_automute_mode_put(struct snd_kcontrol
*kcontrol
,
877 struct snd_ctl_elem_value
*ucontrol
)
879 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
880 struct alc_spec
*spec
= codec
->spec
;
882 switch (ucontrol
->value
.enumerated
.item
[0]) {
884 if (!spec
->automute_speaker
&& !spec
->automute_lo
)
886 spec
->automute_speaker
= 0;
887 spec
->automute_lo
= 0;
890 if (spec
->automute_speaker_possible
) {
891 if (!spec
->automute_lo
&& spec
->automute_speaker
)
893 spec
->automute_speaker
= 1;
894 spec
->automute_lo
= 0;
895 } else if (spec
->automute_lo_possible
) {
896 if (spec
->automute_lo
)
898 spec
->automute_lo
= 1;
903 if (!spec
->automute_lo_possible
|| !spec
->automute_speaker_possible
)
905 if (spec
->automute_speaker
&& spec
->automute_lo
)
907 spec
->automute_speaker
= 1;
908 spec
->automute_lo
= 1;
913 call_update_outputs(codec
);
917 static const struct snd_kcontrol_new alc_automute_mode_enum
= {
918 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
919 .name
= "Auto-Mute Mode",
920 .info
= alc_automute_mode_info
,
921 .get
= alc_automute_mode_get
,
922 .put
= alc_automute_mode_put
,
925 static struct snd_kcontrol_new
*alc_kcontrol_new(struct alc_spec
*spec
)
927 snd_array_init(&spec
->kctls
, sizeof(struct snd_kcontrol_new
), 32);
928 return snd_array_new(&spec
->kctls
);
931 static int alc_add_automute_mode_enum(struct hda_codec
*codec
)
933 struct alc_spec
*spec
= codec
->spec
;
934 struct snd_kcontrol_new
*knew
;
936 knew
= alc_kcontrol_new(spec
);
939 *knew
= alc_automute_mode_enum
;
940 knew
->name
= kstrdup("Auto-Mute Mode", GFP_KERNEL
);
947 * Check the availability of HP/line-out auto-mute;
948 * Set up appropriately if really supported
950 static void alc_init_automute(struct hda_codec
*codec
)
952 struct alc_spec
*spec
= codec
->spec
;
953 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
959 if (cfg
->line_out_pins
[0])
961 if (cfg
->speaker_pins
[0])
963 if (present
< 2) /* need two different output types */
966 if (!cfg
->speaker_pins
[0] &&
967 cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
968 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
969 sizeof(cfg
->speaker_pins
));
970 cfg
->speaker_outs
= cfg
->line_outs
;
973 if (!cfg
->hp_pins
[0] &&
974 cfg
->line_out_type
== AUTO_PIN_HP_OUT
) {
975 memcpy(cfg
->hp_pins
, cfg
->line_out_pins
,
976 sizeof(cfg
->hp_pins
));
977 cfg
->hp_outs
= cfg
->line_outs
;
980 spec
->automute_mode
= ALC_AUTOMUTE_PIN
;
982 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
983 hda_nid_t nid
= cfg
->hp_pins
[i
];
984 if (!is_jack_detectable(codec
, nid
))
986 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
988 snd_hda_jack_detect_enable(codec
, nid
, ALC_HP_EVENT
);
992 if (cfg
->line_out_type
== AUTO_PIN_LINE_OUT
&& cfg
->line_outs
) {
993 if (cfg
->speaker_outs
)
994 for (i
= 0; i
< cfg
->line_outs
; i
++) {
995 hda_nid_t nid
= cfg
->line_out_pins
[i
];
996 if (!is_jack_detectable(codec
, nid
))
998 snd_printdd("realtek: Enable Line-Out "
999 "auto-muting on NID 0x%x\n", nid
);
1000 snd_hda_jack_detect_enable(codec
, nid
,
1002 spec
->detect_lo
= 1;
1004 spec
->automute_lo_possible
= spec
->detect_hp
;
1007 spec
->automute_speaker_possible
= cfg
->speaker_outs
&&
1008 (spec
->detect_hp
|| spec
->detect_lo
);
1010 spec
->automute_lo
= spec
->automute_lo_possible
;
1011 spec
->automute_speaker
= spec
->automute_speaker_possible
;
1013 if (spec
->automute_speaker_possible
|| spec
->automute_lo_possible
) {
1014 /* create a control for automute mode */
1015 alc_add_automute_mode_enum(codec
);
1016 spec
->unsol_event
= alc_sku_unsol_event
;
1020 /* return the position of NID in the list, or -1 if not found */
1021 static int find_idx_in_nid_list(hda_nid_t nid
, const hda_nid_t
*list
, int nums
)
1024 for (i
= 0; i
< nums
; i
++)
1030 /* check whether dynamic ADC-switching is available */
1031 static bool alc_check_dyn_adc_switch(struct hda_codec
*codec
)
1033 struct alc_spec
*spec
= codec
->spec
;
1034 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
1038 if (imux
!= spec
->input_mux
) /* no dynamic imux? */
1041 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
1042 cap
= spec
->private_capsrc_nids
[n
];
1043 for (i
= 0; i
< imux
->num_items
; i
++) {
1044 pin
= spec
->imux_pins
[i
];
1047 if (get_connection_index(codec
, cap
, pin
) < 0)
1050 if (i
>= imux
->num_items
)
1051 return true; /* no ADC-switch is needed */
1054 for (i
= 0; i
< imux
->num_items
; i
++) {
1055 pin
= spec
->imux_pins
[i
];
1056 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
1057 cap
= spec
->private_capsrc_nids
[n
];
1058 idx
= get_connection_index(codec
, cap
, pin
);
1060 imux
->items
[i
].index
= idx
;
1061 spec
->dyn_adc_idx
[i
] = n
;
1067 snd_printdd("realtek: enabling ADC switching\n");
1068 spec
->dyn_adc_switch
= 1;
1072 /* rebuild imux for matching with the given auto-mic pins (if not yet) */
1073 static bool alc_rebuild_imux_for_auto_mic(struct hda_codec
*codec
)
1075 struct alc_spec
*spec
= codec
->spec
;
1076 struct hda_input_mux
*imux
;
1077 static char * const texts
[3] = {
1078 "Mic", "Internal Mic", "Dock Mic"
1082 if (!spec
->auto_mic
)
1084 imux
= &spec
->private_imux
[0];
1085 if (spec
->input_mux
== imux
)
1087 spec
->imux_pins
[0] = spec
->ext_mic_pin
;
1088 spec
->imux_pins
[1] = spec
->int_mic_pin
;
1089 spec
->imux_pins
[2] = spec
->dock_mic_pin
;
1090 for (i
= 0; i
< 3; i
++) {
1091 strcpy(imux
->items
[i
].label
, texts
[i
]);
1092 if (spec
->imux_pins
[i
]) {
1093 hda_nid_t pin
= spec
->imux_pins
[i
];
1095 for (c
= 0; c
< spec
->num_adc_nids
; c
++) {
1096 hda_nid_t cap
= get_capsrc(spec
, c
);
1097 int idx
= get_connection_index(codec
, cap
, pin
);
1099 imux
->items
[i
].index
= idx
;
1103 imux
->num_items
= i
+ 1;
1106 spec
->num_mux_defs
= 1;
1107 spec
->input_mux
= imux
;
1111 /* check whether all auto-mic pins are valid; setup indices if OK */
1112 static bool alc_auto_mic_check_imux(struct hda_codec
*codec
)
1114 struct alc_spec
*spec
= codec
->spec
;
1115 const struct hda_input_mux
*imux
;
1117 if (!spec
->auto_mic
)
1119 if (spec
->auto_mic_valid_imux
)
1120 return true; /* already checked */
1122 /* fill up imux indices */
1123 if (!alc_check_dyn_adc_switch(codec
)) {
1128 imux
= spec
->input_mux
;
1129 spec
->ext_mic_idx
= find_idx_in_nid_list(spec
->ext_mic_pin
,
1130 spec
->imux_pins
, imux
->num_items
);
1131 spec
->int_mic_idx
= find_idx_in_nid_list(spec
->int_mic_pin
,
1132 spec
->imux_pins
, imux
->num_items
);
1133 spec
->dock_mic_idx
= find_idx_in_nid_list(spec
->dock_mic_pin
,
1134 spec
->imux_pins
, imux
->num_items
);
1135 if (spec
->ext_mic_idx
< 0 || spec
->int_mic_idx
< 0) {
1137 return false; /* no corresponding imux */
1140 snd_hda_jack_detect_enable(codec
, spec
->ext_mic_pin
, ALC_MIC_EVENT
);
1141 if (spec
->dock_mic_pin
)
1142 snd_hda_jack_detect_enable(codec
, spec
->dock_mic_pin
,
1145 spec
->auto_mic_valid_imux
= 1;
1151 * Check the availability of auto-mic switch;
1152 * Set up if really supported
1154 static void alc_init_auto_mic(struct hda_codec
*codec
)
1156 struct alc_spec
*spec
= codec
->spec
;
1157 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1158 hda_nid_t fixed
, ext
, dock
;
1161 if (spec
->shared_mic_hp
)
1162 return; /* no auto-mic for the shared I/O */
1164 spec
->ext_mic_idx
= spec
->int_mic_idx
= spec
->dock_mic_idx
= -1;
1166 fixed
= ext
= dock
= 0;
1167 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
1168 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
1169 unsigned int defcfg
;
1170 defcfg
= snd_hda_codec_get_pincfg(codec
, nid
);
1171 switch (snd_hda_get_input_pin_attr(defcfg
)) {
1172 case INPUT_PIN_ATTR_INT
:
1174 return; /* already occupied */
1175 if (cfg
->inputs
[i
].type
!= AUTO_PIN_MIC
)
1176 return; /* invalid type */
1179 case INPUT_PIN_ATTR_UNUSED
:
1180 return; /* invalid entry */
1181 case INPUT_PIN_ATTR_DOCK
:
1183 return; /* already occupied */
1184 if (cfg
->inputs
[i
].type
> AUTO_PIN_LINE_IN
)
1185 return; /* invalid type */
1190 return; /* already occupied */
1191 if (cfg
->inputs
[i
].type
!= AUTO_PIN_MIC
)
1192 return; /* invalid type */
1203 if (!is_jack_detectable(codec
, ext
))
1204 return; /* no unsol support */
1205 if (dock
&& !is_jack_detectable(codec
, dock
))
1206 return; /* no unsol support */
1208 /* check imux indices */
1209 spec
->ext_mic_pin
= ext
;
1210 spec
->int_mic_pin
= fixed
;
1211 spec
->dock_mic_pin
= dock
;
1214 if (!alc_auto_mic_check_imux(codec
))
1217 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
1219 spec
->unsol_event
= alc_sku_unsol_event
;
1222 /* check the availabilities of auto-mute and auto-mic switches */
1223 static void alc_auto_check_switches(struct hda_codec
*codec
)
1225 alc_init_automute(codec
);
1226 alc_init_auto_mic(codec
);
1230 * Realtek SSID verification
1233 /* Could be any non-zero and even value. When used as fixup, tells
1234 * the driver to ignore any present sku defines.
1236 #define ALC_FIXUP_SKU_IGNORE (2)
1238 static int alc_auto_parse_customize_define(struct hda_codec
*codec
)
1240 unsigned int ass
, tmp
, i
;
1242 struct alc_spec
*spec
= codec
->spec
;
1244 spec
->cdefine
.enable_pcbeep
= 1; /* assume always enabled */
1246 if (spec
->cdefine
.fixup
) {
1247 ass
= spec
->cdefine
.sku_cfg
;
1248 if (ass
== ALC_FIXUP_SKU_IGNORE
)
1253 ass
= codec
->subsystem_id
& 0xffff;
1254 if (ass
!= codec
->bus
->pci
->subsystem_device
&& (ass
& 1))
1258 if (codec
->vendor_id
== 0x10ec0260)
1260 ass
= snd_hda_codec_get_pincfg(codec
, nid
);
1263 printk(KERN_INFO
"hda_codec: %s: SKU not ready 0x%08x\n",
1264 codec
->chip_name
, ass
);
1270 for (i
= 1; i
< 16; i
++) {
1274 if (((ass
>> 16) & 0xf) != tmp
)
1277 spec
->cdefine
.port_connectivity
= ass
>> 30;
1278 spec
->cdefine
.enable_pcbeep
= (ass
& 0x100000) >> 20;
1279 spec
->cdefine
.check_sum
= (ass
>> 16) & 0xf;
1280 spec
->cdefine
.customization
= ass
>> 8;
1282 spec
->cdefine
.sku_cfg
= ass
;
1283 spec
->cdefine
.external_amp
= (ass
& 0x38) >> 3;
1284 spec
->cdefine
.platform_type
= (ass
& 0x4) >> 2;
1285 spec
->cdefine
.swap
= (ass
& 0x2) >> 1;
1286 spec
->cdefine
.override
= ass
& 0x1;
1288 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1289 nid
, spec
->cdefine
.sku_cfg
);
1290 snd_printd("SKU: port_connectivity=0x%x\n",
1291 spec
->cdefine
.port_connectivity
);
1292 snd_printd("SKU: enable_pcbeep=0x%x\n", spec
->cdefine
.enable_pcbeep
);
1293 snd_printd("SKU: check_sum=0x%08x\n", spec
->cdefine
.check_sum
);
1294 snd_printd("SKU: customization=0x%08x\n", spec
->cdefine
.customization
);
1295 snd_printd("SKU: external_amp=0x%x\n", spec
->cdefine
.external_amp
);
1296 snd_printd("SKU: platform_type=0x%x\n", spec
->cdefine
.platform_type
);
1297 snd_printd("SKU: swap=0x%x\n", spec
->cdefine
.swap
);
1298 snd_printd("SKU: override=0x%x\n", spec
->cdefine
.override
);
1303 /* return true if the given NID is found in the list */
1304 static bool found_in_nid_list(hda_nid_t nid
, const hda_nid_t
*list
, int nums
)
1306 return find_idx_in_nid_list(nid
, list
, nums
) >= 0;
1309 /* check subsystem ID and set up device-specific initialization;
1310 * return 1 if initialized, 0 if invalid SSID
1312 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1313 * 31 ~ 16 : Manufacture ID
1315 * 7 ~ 0 : Assembly ID
1316 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1318 static int alc_subsystem_id(struct hda_codec
*codec
,
1319 hda_nid_t porta
, hda_nid_t porte
,
1320 hda_nid_t portd
, hda_nid_t porti
)
1322 unsigned int ass
, tmp
, i
;
1324 struct alc_spec
*spec
= codec
->spec
;
1326 if (spec
->cdefine
.fixup
) {
1327 ass
= spec
->cdefine
.sku_cfg
;
1328 if (ass
== ALC_FIXUP_SKU_IGNORE
)
1333 ass
= codec
->subsystem_id
& 0xffff;
1334 if ((ass
!= codec
->bus
->pci
->subsystem_device
) && (ass
& 1))
1337 /* invalid SSID, check the special NID pin defcfg instead */
1339 * 31~30 : port connectivity
1342 * 19~16 : Check sum (15:1)
1347 if (codec
->vendor_id
== 0x10ec0260)
1349 ass
= snd_hda_codec_get_pincfg(codec
, nid
);
1350 snd_printd("realtek: No valid SSID, "
1351 "checking pincfg 0x%08x for NID 0x%x\n",
1355 if ((ass
>> 30) != 1) /* no physical connection */
1360 for (i
= 1; i
< 16; i
++) {
1364 if (((ass
>> 16) & 0xf) != tmp
)
1367 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1368 ass
& 0xffff, codec
->vendor_id
);
1372 * 2 : 0 --> Desktop, 1 --> Laptop
1373 * 3~5 : External Amplifier control
1376 tmp
= (ass
& 0x38) >> 3; /* external Amp control */
1379 spec
->init_amp
= ALC_INIT_GPIO1
;
1382 spec
->init_amp
= ALC_INIT_GPIO2
;
1385 spec
->init_amp
= ALC_INIT_GPIO3
;
1389 spec
->init_amp
= ALC_INIT_DEFAULT
;
1393 /* is laptop or Desktop and enable the function "Mute internal speaker
1394 * when the external headphone out jack is plugged"
1396 if (!(ass
& 0x8000))
1399 * 10~8 : Jack location
1400 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1402 * 15 : 1 --> enable the function "Mute internal speaker
1403 * when the external headphone out jack is plugged"
1405 if (!spec
->autocfg
.hp_pins
[0] &&
1406 !(spec
->autocfg
.line_out_pins
[0] &&
1407 spec
->autocfg
.line_out_type
== AUTO_PIN_HP_OUT
)) {
1409 tmp
= (ass
>> 11) & 0x3; /* HP to chassis */
1420 if (found_in_nid_list(nid
, spec
->autocfg
.line_out_pins
,
1421 spec
->autocfg
.line_outs
))
1423 spec
->autocfg
.hp_pins
[0] = nid
;
1428 /* Check the validity of ALC subsystem-id
1429 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
1430 static void alc_ssid_check(struct hda_codec
*codec
, const hda_nid_t
*ports
)
1432 if (!alc_subsystem_id(codec
, ports
[0], ports
[1], ports
[2], ports
[3])) {
1433 struct alc_spec
*spec
= codec
->spec
;
1434 snd_printd("realtek: "
1435 "Enable default setup for auto mode as fallback\n");
1436 spec
->init_amp
= ALC_INIT_DEFAULT
;
1441 * Fix-up pin default configurations and add default verbs
1449 struct alc_model_fixup
{
1460 const struct alc_pincfg
*pins
;
1461 const struct hda_verb
*verbs
;
1462 void (*func
)(struct hda_codec
*codec
,
1463 const struct alc_fixup
*fix
,
1477 ALC_FIXUP_ACT_PRE_PROBE
,
1478 ALC_FIXUP_ACT_PROBE
,
1482 static void alc_apply_fixup(struct hda_codec
*codec
, int action
)
1484 struct alc_spec
*spec
= codec
->spec
;
1485 int id
= spec
->fixup_id
;
1486 #ifdef CONFIG_SND_DEBUG_VERBOSE
1487 const char *modelname
= spec
->fixup_name
;
1491 if (!spec
->fixup_list
)
1495 const struct alc_fixup
*fix
= spec
->fixup_list
+ id
;
1496 const struct alc_pincfg
*cfg
;
1498 switch (fix
->type
) {
1500 if (action
!= ALC_FIXUP_ACT_PRE_PROBE
|| !fix
->v
.sku
)
1502 snd_printdd(KERN_INFO
"hda_codec: %s: "
1503 "Apply sku override for %s\n",
1504 codec
->chip_name
, modelname
);
1505 spec
->cdefine
.sku_cfg
= fix
->v
.sku
;
1506 spec
->cdefine
.fixup
= 1;
1508 case ALC_FIXUP_PINS
:
1510 if (action
!= ALC_FIXUP_ACT_PRE_PROBE
|| !cfg
)
1512 snd_printdd(KERN_INFO
"hda_codec: %s: "
1513 "Apply pincfg for %s\n",
1514 codec
->chip_name
, modelname
);
1515 for (; cfg
->nid
; cfg
++)
1516 snd_hda_codec_set_pincfg(codec
, cfg
->nid
,
1519 case ALC_FIXUP_VERBS
:
1520 if (action
!= ALC_FIXUP_ACT_PROBE
|| !fix
->v
.verbs
)
1522 snd_printdd(KERN_INFO
"hda_codec: %s: "
1523 "Apply fix-verbs for %s\n",
1524 codec
->chip_name
, modelname
);
1525 add_verb(codec
->spec
, fix
->v
.verbs
);
1527 case ALC_FIXUP_FUNC
:
1530 snd_printdd(KERN_INFO
"hda_codec: %s: "
1531 "Apply fix-func for %s\n",
1532 codec
->chip_name
, modelname
);
1533 fix
->v
.func(codec
, fix
, action
);
1536 snd_printk(KERN_ERR
"hda_codec: %s: "
1537 "Invalid fixup type %d\n",
1538 codec
->chip_name
, fix
->type
);
1549 static void alc_pick_fixup(struct hda_codec
*codec
,
1550 const struct alc_model_fixup
*models
,
1551 const struct snd_pci_quirk
*quirk
,
1552 const struct alc_fixup
*fixlist
)
1554 struct alc_spec
*spec
= codec
->spec
;
1555 const struct snd_pci_quirk
*q
;
1557 const char *name
= NULL
;
1559 /* when model=nofixup is given, don't pick up any fixups */
1560 if (codec
->modelname
&& !strcmp(codec
->modelname
, "nofixup")) {
1561 spec
->fixup_list
= NULL
;
1562 spec
->fixup_id
= -1;
1566 if (codec
->modelname
&& models
) {
1567 while (models
->name
) {
1568 if (!strcmp(codec
->modelname
, models
->name
)) {
1570 name
= models
->name
;
1577 q
= snd_pci_quirk_lookup(codec
->bus
->pci
, quirk
);
1580 #ifdef CONFIG_SND_DEBUG_VERBOSE
1586 for (q
= quirk
; q
->subvendor
; q
++) {
1587 unsigned int vendorid
=
1588 q
->subdevice
| (q
->subvendor
<< 16);
1589 if (vendorid
== codec
->subsystem_id
) {
1591 #ifdef CONFIG_SND_DEBUG_VERBOSE
1599 spec
->fixup_id
= id
;
1601 spec
->fixup_list
= fixlist
;
1602 spec
->fixup_name
= name
;
1607 * COEF access helper functions
1609 static int alc_read_coef_idx(struct hda_codec
*codec
,
1610 unsigned int coef_idx
)
1613 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
,
1615 val
= snd_hda_codec_read(codec
, 0x20, 0,
1616 AC_VERB_GET_PROC_COEF
, 0);
1620 static void alc_write_coef_idx(struct hda_codec
*codec
, unsigned int coef_idx
,
1621 unsigned int coef_val
)
1623 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
,
1625 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_PROC_COEF
,
1629 /* a special bypass for COEF 0; read the cached value at the second time */
1630 static unsigned int alc_get_coef0(struct hda_codec
*codec
)
1632 struct alc_spec
*spec
= codec
->spec
;
1634 spec
->coef0
= alc_read_coef_idx(codec
, 0);
1639 * Digital I/O handling
1642 /* set right pin controls for digital I/O */
1643 static void alc_auto_init_digital(struct hda_codec
*codec
)
1645 struct alc_spec
*spec
= codec
->spec
;
1649 for (i
= 0; i
< spec
->autocfg
.dig_outs
; i
++) {
1650 pin
= spec
->autocfg
.dig_out_pins
[i
];
1653 snd_hda_codec_write(codec
, pin
, 0,
1654 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
1656 dac
= spec
->multiout
.dig_out_nid
;
1658 dac
= spec
->slave_dig_outs
[i
- 1];
1659 if (!dac
|| !(get_wcaps(codec
, dac
) & AC_WCAP_OUT_AMP
))
1661 snd_hda_codec_write(codec
, dac
, 0,
1662 AC_VERB_SET_AMP_GAIN_MUTE
,
1665 pin
= spec
->autocfg
.dig_in_pin
;
1667 snd_hda_codec_write(codec
, pin
, 0,
1668 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1672 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1673 static void alc_auto_parse_digital(struct hda_codec
*codec
)
1675 struct alc_spec
*spec
= codec
->spec
;
1679 /* support multiple SPDIFs; the secondary is set up as a slave */
1681 for (i
= 0; i
< spec
->autocfg
.dig_outs
; i
++) {
1683 err
= snd_hda_get_connections(codec
,
1684 spec
->autocfg
.dig_out_pins
[i
],
1685 conn
, ARRAY_SIZE(conn
));
1688 dig_nid
= conn
[0]; /* assume the first element is audio-out */
1690 spec
->multiout
.dig_out_nid
= dig_nid
;
1691 spec
->dig_out_type
= spec
->autocfg
.dig_out_type
[0];
1693 spec
->multiout
.slave_dig_outs
= spec
->slave_dig_outs
;
1694 if (nums
>= ARRAY_SIZE(spec
->slave_dig_outs
) - 1)
1696 spec
->slave_dig_outs
[nums
- 1] = dig_nid
;
1701 if (spec
->autocfg
.dig_in_pin
) {
1702 dig_nid
= codec
->start_nid
;
1703 for (i
= 0; i
< codec
->num_nodes
; i
++, dig_nid
++) {
1704 unsigned int wcaps
= get_wcaps(codec
, dig_nid
);
1705 if (get_wcaps_type(wcaps
) != AC_WID_AUD_IN
)
1707 if (!(wcaps
& AC_WCAP_DIGITAL
))
1709 if (!(wcaps
& AC_WCAP_CONN_LIST
))
1711 err
= get_connection_index(codec
, dig_nid
,
1712 spec
->autocfg
.dig_in_pin
);
1714 spec
->dig_in_nid
= dig_nid
;
1722 * capture mixer elements
1724 static int alc_cap_vol_info(struct snd_kcontrol
*kcontrol
,
1725 struct snd_ctl_elem_info
*uinfo
)
1727 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1728 struct alc_spec
*spec
= codec
->spec
;
1732 mutex_lock(&codec
->control_mutex
);
1733 if (spec
->vol_in_capsrc
)
1734 val
= HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[0], 3, 0, HDA_OUTPUT
);
1736 val
= HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[0], 3, 0, HDA_INPUT
);
1737 kcontrol
->private_value
= val
;
1738 err
= snd_hda_mixer_amp_volume_info(kcontrol
, uinfo
);
1739 mutex_unlock(&codec
->control_mutex
);
1743 static int alc_cap_vol_tlv(struct snd_kcontrol
*kcontrol
, int op_flag
,
1744 unsigned int size
, unsigned int __user
*tlv
)
1746 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1747 struct alc_spec
*spec
= codec
->spec
;
1751 mutex_lock(&codec
->control_mutex
);
1752 if (spec
->vol_in_capsrc
)
1753 val
= HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[0], 3, 0, HDA_OUTPUT
);
1755 val
= HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[0], 3, 0, HDA_INPUT
);
1756 kcontrol
->private_value
= val
;
1757 err
= snd_hda_mixer_amp_tlv(kcontrol
, op_flag
, size
, tlv
);
1758 mutex_unlock(&codec
->control_mutex
);
1762 typedef int (*getput_call_t
)(struct snd_kcontrol
*kcontrol
,
1763 struct snd_ctl_elem_value
*ucontrol
);
1765 static int alc_cap_getput_caller(struct snd_kcontrol
*kcontrol
,
1766 struct snd_ctl_elem_value
*ucontrol
,
1767 getput_call_t func
, bool check_adc_switch
)
1769 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1770 struct alc_spec
*spec
= codec
->spec
;
1773 mutex_lock(&codec
->control_mutex
);
1774 if (check_adc_switch
&& spec
->dyn_adc_switch
) {
1775 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
1776 kcontrol
->private_value
=
1777 HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[i
],
1779 err
= func(kcontrol
, ucontrol
);
1784 i
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
1785 if (spec
->vol_in_capsrc
)
1786 kcontrol
->private_value
=
1787 HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[i
],
1790 kcontrol
->private_value
=
1791 HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[i
],
1793 err
= func(kcontrol
, ucontrol
);
1796 mutex_unlock(&codec
->control_mutex
);
1800 static int alc_cap_vol_get(struct snd_kcontrol
*kcontrol
,
1801 struct snd_ctl_elem_value
*ucontrol
)
1803 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1804 snd_hda_mixer_amp_volume_get
, false);
1807 static int alc_cap_vol_put(struct snd_kcontrol
*kcontrol
,
1808 struct snd_ctl_elem_value
*ucontrol
)
1810 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1811 snd_hda_mixer_amp_volume_put
, true);
1814 /* capture mixer elements */
1815 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1817 static int alc_cap_sw_get(struct snd_kcontrol
*kcontrol
,
1818 struct snd_ctl_elem_value
*ucontrol
)
1820 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1821 snd_hda_mixer_amp_switch_get
, false);
1824 static int alc_cap_sw_put(struct snd_kcontrol
*kcontrol
,
1825 struct snd_ctl_elem_value
*ucontrol
)
1827 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1828 snd_hda_mixer_amp_switch_put
, true);
1831 #define _DEFINE_CAPMIX(num) \
1833 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1834 .name = "Capture Switch", \
1835 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1837 .info = alc_cap_sw_info, \
1838 .get = alc_cap_sw_get, \
1839 .put = alc_cap_sw_put, \
1842 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1843 .name = "Capture Volume", \
1844 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1845 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1846 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1848 .info = alc_cap_vol_info, \
1849 .get = alc_cap_vol_get, \
1850 .put = alc_cap_vol_put, \
1851 .tlv = { .c = alc_cap_vol_tlv }, \
1854 #define _DEFINE_CAPSRC(num) \
1856 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1857 /* .name = "Capture Source", */ \
1858 .name = "Input Source", \
1860 .info = alc_mux_enum_info, \
1861 .get = alc_mux_enum_get, \
1862 .put = alc_mux_enum_put, \
1865 #define DEFINE_CAPMIX(num) \
1866 static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1867 _DEFINE_CAPMIX(num), \
1868 _DEFINE_CAPSRC(num), \
1872 #define DEFINE_CAPMIX_NOSRC(num) \
1873 static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1874 _DEFINE_CAPMIX(num), \
1878 /* up to three ADCs */
1882 DEFINE_CAPMIX_NOSRC(1);
1883 DEFINE_CAPMIX_NOSRC(2);
1884 DEFINE_CAPMIX_NOSRC(3);
1887 * virtual master controls
1891 * slave controls for virtual master
1893 static const char * const alc_slave_pfxs
[] = {
1894 "Front", "Surround", "Center", "LFE", "Side",
1895 "Headphone", "Speaker", "Mono", "Line-Out",
1896 "CLFE", "Bass Speaker", "PCM",
1901 * build control elements
1904 #define NID_MAPPING (-1)
1906 #define SUBDEV_SPEAKER_ (0 << 6)
1907 #define SUBDEV_HP_ (1 << 6)
1908 #define SUBDEV_LINE_ (2 << 6)
1909 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
1910 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
1911 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
1913 static void alc_free_kctls(struct hda_codec
*codec
);
1915 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1916 /* additional beep mixers; the actual parameters are overwritten at build */
1917 static const struct snd_kcontrol_new alc_beep_mixer
[] = {
1918 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT
),
1919 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT
),
1924 static int __alc_build_controls(struct hda_codec
*codec
)
1926 struct alc_spec
*spec
= codec
->spec
;
1927 struct snd_kcontrol
*kctl
= NULL
;
1928 const struct snd_kcontrol_new
*knew
;
1933 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1934 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
1938 if (spec
->cap_mixer
) {
1939 err
= snd_hda_add_new_ctls(codec
, spec
->cap_mixer
);
1943 if (spec
->multiout
.dig_out_nid
) {
1944 err
= snd_hda_create_spdif_out_ctls(codec
,
1945 spec
->multiout
.dig_out_nid
,
1946 spec
->multiout
.dig_out_nid
);
1949 if (!spec
->no_analog
) {
1950 err
= snd_hda_create_spdif_share_sw(codec
,
1954 spec
->multiout
.share_spdif
= 1;
1957 if (spec
->dig_in_nid
) {
1958 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
1963 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1964 /* create beep controls if needed */
1965 if (spec
->beep_amp
) {
1966 const struct snd_kcontrol_new
*knew
;
1967 for (knew
= alc_beep_mixer
; knew
->name
; knew
++) {
1968 struct snd_kcontrol
*kctl
;
1969 kctl
= snd_ctl_new1(knew
, codec
);
1972 kctl
->private_value
= spec
->beep_amp
;
1973 err
= snd_hda_ctl_add(codec
, 0, kctl
);
1980 /* if we have no master control, let's create it */
1981 if (!spec
->no_analog
&&
1982 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
1983 unsigned int vmaster_tlv
[4];
1984 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
1985 HDA_OUTPUT
, vmaster_tlv
);
1986 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
1987 vmaster_tlv
, alc_slave_pfxs
,
1992 if (!spec
->no_analog
&&
1993 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
1994 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
1995 NULL
, alc_slave_pfxs
,
2001 /* assign Capture Source enums to NID */
2002 if (spec
->capsrc_nids
|| spec
->adc_nids
) {
2003 kctl
= snd_hda_find_mixer_ctl(codec
, "Capture Source");
2005 kctl
= snd_hda_find_mixer_ctl(codec
, "Input Source");
2006 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
2007 err
= snd_hda_add_nid(codec
, kctl
, i
,
2008 get_capsrc(spec
, i
));
2013 if (spec
->cap_mixer
&& spec
->adc_nids
) {
2014 const char *kname
= kctl
? kctl
->id
.name
: NULL
;
2015 for (knew
= spec
->cap_mixer
; knew
->name
; knew
++) {
2016 if (kname
&& strcmp(knew
->name
, kname
) == 0)
2018 kctl
= snd_hda_find_mixer_ctl(codec
, knew
->name
);
2019 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
2020 err
= snd_hda_add_nid(codec
, kctl
, i
,
2028 /* other nid->control mapping */
2029 for (i
= 0; i
< spec
->num_mixers
; i
++) {
2030 for (knew
= spec
->mixers
[i
]; knew
->name
; knew
++) {
2031 if (knew
->iface
!= NID_MAPPING
)
2033 kctl
= snd_hda_find_mixer_ctl(codec
, knew
->name
);
2036 u
= knew
->subdevice
;
2037 for (j
= 0; j
< 4; j
++, u
>>= 8) {
2042 case SUBDEV_SPEAKER_
:
2043 nid
= spec
->autocfg
.speaker_pins
[nid
];
2046 nid
= spec
->autocfg
.line_out_pins
[nid
];
2049 nid
= spec
->autocfg
.hp_pins
[nid
];
2054 err
= snd_hda_add_nid(codec
, kctl
, 0, nid
);
2058 u
= knew
->private_value
;
2059 for (j
= 0; j
< 4; j
++, u
>>= 8) {
2063 err
= snd_hda_add_nid(codec
, kctl
, 0, nid
);
2070 alc_free_kctls(codec
); /* no longer needed */
2075 static int alc_build_controls(struct hda_codec
*codec
)
2077 struct alc_spec
*spec
= codec
->spec
;
2078 int err
= __alc_build_controls(codec
);
2081 return snd_hda_jack_add_kctls(codec
, &spec
->autocfg
);
2089 static void alc_init_special_input_src(struct hda_codec
*codec
);
2091 static int alc_init(struct hda_codec
*codec
)
2093 struct alc_spec
*spec
= codec
->spec
;
2097 alc_auto_init_amp(codec
, spec
->init_amp
);
2099 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
2100 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
2101 alc_init_special_input_src(codec
);
2103 if (spec
->init_hook
)
2104 spec
->init_hook(codec
);
2106 alc_apply_fixup(codec
, ALC_FIXUP_ACT_INIT
);
2108 snd_hda_jack_report_sync(codec
);
2110 hda_call_check_power_status(codec
, 0x01);
2114 static void alc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2116 struct alc_spec
*spec
= codec
->spec
;
2118 if (spec
->unsol_event
)
2119 spec
->unsol_event(codec
, res
);
2122 #ifdef CONFIG_SND_HDA_POWER_SAVE
2123 static int alc_check_power_status(struct hda_codec
*codec
, hda_nid_t nid
)
2125 struct alc_spec
*spec
= codec
->spec
;
2126 return snd_hda_check_amp_list_power(codec
, &spec
->loopback
, nid
);
2131 * Analog playback callbacks
2133 static int alc_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2134 struct hda_codec
*codec
,
2135 struct snd_pcm_substream
*substream
)
2137 struct alc_spec
*spec
= codec
->spec
;
2138 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
2142 static int alc_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2143 struct hda_codec
*codec
,
2144 unsigned int stream_tag
,
2145 unsigned int format
,
2146 struct snd_pcm_substream
*substream
)
2148 struct alc_spec
*spec
= codec
->spec
;
2149 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
2150 stream_tag
, format
, substream
);
2153 static int alc_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2154 struct hda_codec
*codec
,
2155 struct snd_pcm_substream
*substream
)
2157 struct alc_spec
*spec
= codec
->spec
;
2158 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
2164 static int alc_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2165 struct hda_codec
*codec
,
2166 struct snd_pcm_substream
*substream
)
2168 struct alc_spec
*spec
= codec
->spec
;
2169 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
2172 static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2173 struct hda_codec
*codec
,
2174 unsigned int stream_tag
,
2175 unsigned int format
,
2176 struct snd_pcm_substream
*substream
)
2178 struct alc_spec
*spec
= codec
->spec
;
2179 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
2180 stream_tag
, format
, substream
);
2183 static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2184 struct hda_codec
*codec
,
2185 struct snd_pcm_substream
*substream
)
2187 struct alc_spec
*spec
= codec
->spec
;
2188 return snd_hda_multi_out_dig_cleanup(codec
, &spec
->multiout
);
2191 static int alc_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
2192 struct hda_codec
*codec
,
2193 struct snd_pcm_substream
*substream
)
2195 struct alc_spec
*spec
= codec
->spec
;
2196 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
2202 static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2203 struct hda_codec
*codec
,
2204 unsigned int stream_tag
,
2205 unsigned int format
,
2206 struct snd_pcm_substream
*substream
)
2208 struct alc_spec
*spec
= codec
->spec
;
2210 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
+ 1],
2211 stream_tag
, 0, format
);
2215 static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2216 struct hda_codec
*codec
,
2217 struct snd_pcm_substream
*substream
)
2219 struct alc_spec
*spec
= codec
->spec
;
2221 snd_hda_codec_cleanup_stream(codec
,
2222 spec
->adc_nids
[substream
->number
+ 1]);
2226 /* analog capture with dynamic dual-adc changes */
2227 static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2228 struct hda_codec
*codec
,
2229 unsigned int stream_tag
,
2230 unsigned int format
,
2231 struct snd_pcm_substream
*substream
)
2233 struct alc_spec
*spec
= codec
->spec
;
2234 spec
->cur_adc
= spec
->adc_nids
[spec
->dyn_adc_idx
[spec
->cur_mux
[0]]];
2235 spec
->cur_adc_stream_tag
= stream_tag
;
2236 spec
->cur_adc_format
= format
;
2237 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
2241 static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2242 struct hda_codec
*codec
,
2243 struct snd_pcm_substream
*substream
)
2245 struct alc_spec
*spec
= codec
->spec
;
2246 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
2251 static const struct hda_pcm_stream dyn_adc_pcm_analog_capture
= {
2255 .nid
= 0, /* fill later */
2257 .prepare
= dyn_adc_capture_pcm_prepare
,
2258 .cleanup
= dyn_adc_capture_pcm_cleanup
2264 static const struct hda_pcm_stream alc_pcm_analog_playback
= {
2268 /* NID is set in alc_build_pcms */
2270 .open
= alc_playback_pcm_open
,
2271 .prepare
= alc_playback_pcm_prepare
,
2272 .cleanup
= alc_playback_pcm_cleanup
2276 static const struct hda_pcm_stream alc_pcm_analog_capture
= {
2280 /* NID is set in alc_build_pcms */
2283 static const struct hda_pcm_stream alc_pcm_analog_alt_playback
= {
2287 /* NID is set in alc_build_pcms */
2290 static const struct hda_pcm_stream alc_pcm_analog_alt_capture
= {
2291 .substreams
= 2, /* can be overridden */
2294 /* NID is set in alc_build_pcms */
2296 .prepare
= alc_alt_capture_pcm_prepare
,
2297 .cleanup
= alc_alt_capture_pcm_cleanup
2301 static const struct hda_pcm_stream alc_pcm_digital_playback
= {
2305 /* NID is set in alc_build_pcms */
2307 .open
= alc_dig_playback_pcm_open
,
2308 .close
= alc_dig_playback_pcm_close
,
2309 .prepare
= alc_dig_playback_pcm_prepare
,
2310 .cleanup
= alc_dig_playback_pcm_cleanup
2314 static const struct hda_pcm_stream alc_pcm_digital_capture
= {
2318 /* NID is set in alc_build_pcms */
2321 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2322 static const struct hda_pcm_stream alc_pcm_null_stream
= {
2328 static int alc_build_pcms(struct hda_codec
*codec
)
2330 struct alc_spec
*spec
= codec
->spec
;
2331 struct hda_pcm
*info
= spec
->pcm_rec
;
2332 const struct hda_pcm_stream
*p
;
2333 bool have_multi_adcs
;
2336 codec
->num_pcms
= 1;
2337 codec
->pcm_info
= info
;
2339 if (spec
->no_analog
)
2342 snprintf(spec
->stream_name_analog
, sizeof(spec
->stream_name_analog
),
2343 "%s Analog", codec
->chip_name
);
2344 info
->name
= spec
->stream_name_analog
;
2346 if (spec
->multiout
.num_dacs
> 0) {
2347 p
= spec
->stream_analog_playback
;
2349 p
= &alc_pcm_analog_playback
;
2350 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2351 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dac_nids
[0];
2353 if (spec
->adc_nids
) {
2354 p
= spec
->stream_analog_capture
;
2356 if (spec
->dyn_adc_switch
)
2357 p
= &dyn_adc_pcm_analog_capture
;
2359 p
= &alc_pcm_analog_capture
;
2361 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2362 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
2365 if (spec
->channel_mode
) {
2366 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= 0;
2367 for (i
= 0; i
< spec
->num_channel_mode
; i
++) {
2368 if (spec
->channel_mode
[i
].channels
> info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
) {
2369 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= spec
->channel_mode
[i
].channels
;
2375 /* SPDIF for stream index #1 */
2376 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
2377 snprintf(spec
->stream_name_digital
,
2378 sizeof(spec
->stream_name_digital
),
2379 "%s Digital", codec
->chip_name
);
2380 codec
->num_pcms
= 2;
2381 codec
->slave_dig_outs
= spec
->multiout
.slave_dig_outs
;
2382 info
= spec
->pcm_rec
+ 1;
2383 info
->name
= spec
->stream_name_digital
;
2384 if (spec
->dig_out_type
)
2385 info
->pcm_type
= spec
->dig_out_type
;
2387 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
2388 if (spec
->multiout
.dig_out_nid
) {
2389 p
= spec
->stream_digital_playback
;
2391 p
= &alc_pcm_digital_playback
;
2392 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2393 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
2395 if (spec
->dig_in_nid
) {
2396 p
= spec
->stream_digital_capture
;
2398 p
= &alc_pcm_digital_capture
;
2399 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2400 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
2402 /* FIXME: do we need this for all Realtek codec models? */
2403 codec
->spdif_status_reset
= 1;
2406 if (spec
->no_analog
)
2409 /* If the use of more than one ADC is requested for the current
2410 * model, configure a second analog capture-only PCM.
2412 have_multi_adcs
= (spec
->num_adc_nids
> 1) &&
2413 !spec
->dyn_adc_switch
&& !spec
->auto_mic
&&
2414 (!spec
->input_mux
|| spec
->input_mux
->num_items
> 1);
2415 /* Additional Analaog capture for index #2 */
2416 if (spec
->alt_dac_nid
|| have_multi_adcs
) {
2417 codec
->num_pcms
= 3;
2418 info
= spec
->pcm_rec
+ 2;
2419 info
->name
= spec
->stream_name_analog
;
2420 if (spec
->alt_dac_nid
) {
2421 p
= spec
->stream_analog_alt_playback
;
2423 p
= &alc_pcm_analog_alt_playback
;
2424 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2425 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
2428 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
2429 alc_pcm_null_stream
;
2430 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= 0;
2432 if (have_multi_adcs
) {
2433 p
= spec
->stream_analog_alt_capture
;
2435 p
= &alc_pcm_analog_alt_capture
;
2436 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2437 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
2439 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
=
2440 spec
->num_adc_nids
- 1;
2442 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
2443 alc_pcm_null_stream
;
2444 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= 0;
2451 static inline void alc_shutup(struct hda_codec
*codec
)
2453 struct alc_spec
*spec
= codec
->spec
;
2455 if (spec
&& spec
->shutup
)
2456 spec
->shutup(codec
);
2457 snd_hda_shutup_pins(codec
);
2460 static void alc_free_kctls(struct hda_codec
*codec
)
2462 struct alc_spec
*spec
= codec
->spec
;
2464 if (spec
->kctls
.list
) {
2465 struct snd_kcontrol_new
*kctl
= spec
->kctls
.list
;
2467 for (i
= 0; i
< spec
->kctls
.used
; i
++)
2468 kfree(kctl
[i
].name
);
2470 snd_array_free(&spec
->kctls
);
2473 static void alc_free_bind_ctls(struct hda_codec
*codec
)
2475 struct alc_spec
*spec
= codec
->spec
;
2476 if (spec
->bind_ctls
.list
) {
2477 struct hda_bind_ctls
**ctl
= spec
->bind_ctls
.list
;
2479 for (i
= 0; i
< spec
->bind_ctls
.used
; i
++)
2482 snd_array_free(&spec
->bind_ctls
);
2485 static void alc_free(struct hda_codec
*codec
)
2487 struct alc_spec
*spec
= codec
->spec
;
2493 alc_free_kctls(codec
);
2494 alc_free_bind_ctls(codec
);
2496 snd_hda_detach_beep_device(codec
);
2499 #ifdef CONFIG_SND_HDA_POWER_SAVE
2500 static void alc_power_eapd(struct hda_codec
*codec
)
2502 alc_auto_setup_eapd(codec
, false);
2505 static int alc_suspend(struct hda_codec
*codec
, pm_message_t state
)
2507 struct alc_spec
*spec
= codec
->spec
;
2509 if (spec
&& spec
->power_hook
)
2510 spec
->power_hook(codec
);
2516 static int alc_resume(struct hda_codec
*codec
)
2518 msleep(150); /* to avoid pop noise */
2519 codec
->patch_ops
.init(codec
);
2520 snd_hda_codec_resume_amp(codec
);
2521 snd_hda_codec_resume_cache(codec
);
2522 hda_call_check_power_status(codec
, 0x01);
2529 static const struct hda_codec_ops alc_patch_ops
= {
2530 .build_controls
= alc_build_controls
,
2531 .build_pcms
= alc_build_pcms
,
2534 .unsol_event
= alc_unsol_event
,
2536 .resume
= alc_resume
,
2538 #ifdef CONFIG_SND_HDA_POWER_SAVE
2539 .suspend
= alc_suspend
,
2540 .check_power_status
= alc_check_power_status
,
2542 .reboot_notify
= alc_shutup
,
2545 /* replace the codec chip_name with the given string */
2546 static int alc_codec_rename(struct hda_codec
*codec
, const char *name
)
2548 kfree(codec
->chip_name
);
2549 codec
->chip_name
= kstrdup(name
, GFP_KERNEL
);
2550 if (!codec
->chip_name
) {
2558 * Rename codecs appropriately from COEF value
2560 struct alc_codec_rename_table
{
2561 unsigned int vendor_id
;
2562 unsigned short coef_mask
;
2563 unsigned short coef_bits
;
2567 static struct alc_codec_rename_table rename_tbl
[] = {
2568 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
2569 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
2570 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
2571 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
2572 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
2573 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
2574 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
2575 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
2576 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
2577 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
2578 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
2579 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
2580 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
2581 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
2582 { } /* terminator */
2585 static int alc_codec_rename_from_preset(struct hda_codec
*codec
)
2587 const struct alc_codec_rename_table
*p
;
2589 for (p
= rename_tbl
; p
->vendor_id
; p
++) {
2590 if (p
->vendor_id
!= codec
->vendor_id
)
2592 if ((alc_get_coef0(codec
) & p
->coef_mask
) == p
->coef_bits
)
2593 return alc_codec_rename(codec
, p
->name
);
2599 * Automatic parse of I/O pins from the BIOS configuration
2604 ALC_CTL_WIDGET_MUTE
,
2609 static const struct snd_kcontrol_new alc_control_templates
[] = {
2610 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2611 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2612 HDA_BIND_MUTE(NULL
, 0, 0, 0),
2613 HDA_BIND_VOL(NULL
, 0),
2614 HDA_BIND_SW(NULL
, 0),
2617 /* add dynamic controls */
2618 static int add_control(struct alc_spec
*spec
, int type
, const char *name
,
2619 int cidx
, unsigned long val
)
2621 struct snd_kcontrol_new
*knew
;
2623 knew
= alc_kcontrol_new(spec
);
2626 *knew
= alc_control_templates
[type
];
2627 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2631 if (get_amp_nid_(val
))
2632 knew
->subdevice
= HDA_SUBDEV_AMP_FLAG
;
2633 knew
->private_value
= val
;
2637 static int add_control_with_pfx(struct alc_spec
*spec
, int type
,
2638 const char *pfx
, const char *dir
,
2639 const char *sfx
, int cidx
, unsigned long val
)
2642 snprintf(name
, sizeof(name
), "%s %s %s", pfx
, dir
, sfx
);
2643 return add_control(spec
, type
, name
, cidx
, val
);
2646 #define add_pb_vol_ctrl(spec, type, pfx, val) \
2647 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
2648 #define add_pb_sw_ctrl(spec, type, pfx, val) \
2649 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
2650 #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
2651 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
2652 #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
2653 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
2655 static const char * const channel_name
[4] = {
2656 "Front", "Surround", "CLFE", "Side"
2659 static const char *alc_get_line_out_pfx(struct alc_spec
*spec
, int ch
,
2660 bool can_be_master
, int *index
)
2662 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2665 if (cfg
->line_outs
== 1 && !spec
->multi_ios
&&
2666 !cfg
->hp_outs
&& !cfg
->speaker_outs
&& can_be_master
)
2669 switch (cfg
->line_out_type
) {
2670 case AUTO_PIN_SPEAKER_OUT
:
2671 if (cfg
->line_outs
== 1)
2673 if (cfg
->line_outs
== 2)
2674 return ch
? "Bass Speaker" : "Speaker";
2676 case AUTO_PIN_HP_OUT
:
2677 /* for multi-io case, only the primary out */
2678 if (ch
&& spec
->multi_ios
)
2683 if (cfg
->line_outs
== 1 && !spec
->multi_ios
)
2687 if (snd_BUG_ON(ch
>= ARRAY_SIZE(channel_name
)))
2690 return channel_name
[ch
];
2693 /* create input playback/capture controls for the given pin */
2694 static int new_analog_input(struct alc_spec
*spec
, hda_nid_t pin
,
2695 const char *ctlname
, int ctlidx
,
2696 int idx
, hda_nid_t mix_nid
)
2700 err
= __add_pb_vol_ctrl(spec
, ALC_CTL_WIDGET_VOL
, ctlname
, ctlidx
,
2701 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
));
2704 err
= __add_pb_sw_ctrl(spec
, ALC_CTL_WIDGET_MUTE
, ctlname
, ctlidx
,
2705 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
));
2711 static int alc_is_input_pin(struct hda_codec
*codec
, hda_nid_t nid
)
2713 unsigned int pincap
= snd_hda_query_pin_caps(codec
, nid
);
2714 return (pincap
& AC_PINCAP_IN
) != 0;
2717 /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */
2718 static int alc_auto_fill_adc_caps(struct hda_codec
*codec
)
2720 struct alc_spec
*spec
= codec
->spec
;
2722 hda_nid_t
*adc_nids
= spec
->private_adc_nids
;
2723 hda_nid_t
*cap_nids
= spec
->private_capsrc_nids
;
2724 int max_nums
= ARRAY_SIZE(spec
->private_adc_nids
);
2727 if (spec
->shared_mic_hp
)
2728 max_nums
= 1; /* no multi streams with the shared HP/mic */
2730 nid
= codec
->start_nid
;
2731 for (i
= 0; i
< codec
->num_nodes
; i
++, nid
++) {
2733 const hda_nid_t
*list
;
2734 unsigned int caps
= get_wcaps(codec
, nid
);
2735 int type
= get_wcaps_type(caps
);
2737 if (type
!= AC_WID_AUD_IN
|| (caps
& AC_WCAP_DIGITAL
))
2739 adc_nids
[nums
] = nid
;
2740 cap_nids
[nums
] = nid
;
2744 type
= get_wcaps_type(get_wcaps(codec
, src
));
2745 if (type
== AC_WID_PIN
)
2747 if (type
== AC_WID_AUD_SEL
) {
2748 cap_nids
[nums
] = src
;
2751 n
= snd_hda_get_conn_list(codec
, src
, &list
);
2753 cap_nids
[nums
] = src
;
2759 if (++nums
>= max_nums
)
2762 spec
->adc_nids
= spec
->private_adc_nids
;
2763 spec
->capsrc_nids
= spec
->private_capsrc_nids
;
2764 spec
->num_adc_nids
= nums
;
2768 /* create playback/capture controls for input pins */
2769 static int alc_auto_create_input_ctls(struct hda_codec
*codec
)
2771 struct alc_spec
*spec
= codec
->spec
;
2772 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2773 hda_nid_t mixer
= spec
->mixer_nid
;
2774 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
2776 int i
, c
, err
, idx
, type_idx
= 0;
2777 const char *prev_label
= NULL
;
2779 num_adcs
= alc_auto_fill_adc_caps(codec
);
2783 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2787 pin
= cfg
->inputs
[i
].pin
;
2788 if (!alc_is_input_pin(codec
, pin
))
2791 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
2792 if (spec
->shared_mic_hp
&& !strcmp(label
, "Misc"))
2793 label
= "Headphone Mic";
2794 if (prev_label
&& !strcmp(label
, prev_label
))
2801 idx
= get_connection_index(codec
, mixer
, pin
);
2803 err
= new_analog_input(spec
, pin
,
2811 for (c
= 0; c
< num_adcs
; c
++) {
2812 hda_nid_t cap
= get_capsrc(spec
, c
);
2813 idx
= get_connection_index(codec
, cap
, pin
);
2815 spec
->imux_pins
[imux
->num_items
] = pin
;
2816 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
2822 spec
->num_mux_defs
= 1;
2823 spec
->input_mux
= imux
;
2828 /* create a shared input with the headphone out */
2829 static int alc_auto_create_shared_input(struct hda_codec
*codec
)
2831 struct alc_spec
*spec
= codec
->spec
;
2832 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2833 unsigned int defcfg
;
2836 /* only one internal input pin? */
2837 if (cfg
->num_inputs
!= 1)
2839 defcfg
= snd_hda_codec_get_pincfg(codec
, cfg
->inputs
[0].pin
);
2840 if (snd_hda_get_input_pin_attr(defcfg
) != INPUT_PIN_ATTR_INT
)
2843 if (cfg
->hp_outs
== 1 && cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
)
2844 nid
= cfg
->hp_pins
[0]; /* OK, we have a single HP-out */
2845 else if (cfg
->line_outs
== 1 && cfg
->line_out_type
== AUTO_PIN_HP_OUT
)
2846 nid
= cfg
->line_out_pins
[0]; /* OK, we have a single line-out */
2848 return 0; /* both not available */
2850 if (!(snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_IN
))
2851 return 0; /* no input */
2853 cfg
->inputs
[1].pin
= nid
;
2854 cfg
->inputs
[1].type
= AUTO_PIN_MIC
;
2855 cfg
->num_inputs
= 2;
2856 spec
->shared_mic_hp
= 1;
2857 snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid
);
2861 static void alc_set_pin_output(struct hda_codec
*codec
, hda_nid_t nid
,
2862 unsigned int pin_type
)
2864 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2867 if (nid_has_mute(codec
, nid
, HDA_OUTPUT
))
2868 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
2872 static int get_pin_type(int line_out_type
)
2874 if (line_out_type
== AUTO_PIN_HP_OUT
)
2880 static void alc_auto_init_analog_input(struct hda_codec
*codec
)
2882 struct alc_spec
*spec
= codec
->spec
;
2883 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2886 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2887 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
2888 if (alc_is_input_pin(codec
, nid
)) {
2889 alc_set_input_pin(codec
, nid
, cfg
->inputs
[i
].type
);
2890 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
2891 snd_hda_codec_write(codec
, nid
, 0,
2892 AC_VERB_SET_AMP_GAIN_MUTE
,
2897 /* mute all loopback inputs */
2898 if (spec
->mixer_nid
) {
2899 int nums
= snd_hda_get_conn_list(codec
, spec
->mixer_nid
, NULL
);
2900 for (i
= 0; i
< nums
; i
++)
2901 snd_hda_codec_write(codec
, spec
->mixer_nid
, 0,
2902 AC_VERB_SET_AMP_GAIN_MUTE
,
2907 /* convert from MIX nid to DAC */
2908 static hda_nid_t
alc_auto_mix_to_dac(struct hda_codec
*codec
, hda_nid_t nid
)
2913 if (get_wcaps_type(get_wcaps(codec
, nid
)) == AC_WID_AUD_OUT
)
2915 num
= snd_hda_get_connections(codec
, nid
, list
, ARRAY_SIZE(list
));
2916 for (i
= 0; i
< num
; i
++) {
2917 if (get_wcaps_type(get_wcaps(codec
, list
[i
])) == AC_WID_AUD_OUT
)
2923 /* go down to the selector widget before the mixer */
2924 static hda_nid_t
alc_go_down_to_selector(struct hda_codec
*codec
, hda_nid_t pin
)
2927 int num
= snd_hda_get_connections(codec
, pin
, srcs
,
2930 get_wcaps_type(get_wcaps(codec
, srcs
[0])) != AC_WID_AUD_SEL
)
2935 /* get MIX nid connected to the given pin targeted to DAC */
2936 static hda_nid_t
alc_auto_dac_to_mix(struct hda_codec
*codec
, hda_nid_t pin
,
2942 pin
= alc_go_down_to_selector(codec
, pin
);
2943 num
= snd_hda_get_connections(codec
, pin
, mix
, ARRAY_SIZE(mix
));
2944 for (i
= 0; i
< num
; i
++) {
2945 if (alc_auto_mix_to_dac(codec
, mix
[i
]) == dac
)
2951 /* select the connection from pin to DAC if needed */
2952 static int alc_auto_select_dac(struct hda_codec
*codec
, hda_nid_t pin
,
2958 pin
= alc_go_down_to_selector(codec
, pin
);
2959 num
= snd_hda_get_connections(codec
, pin
, mix
, ARRAY_SIZE(mix
));
2962 for (i
= 0; i
< num
; i
++) {
2963 if (alc_auto_mix_to_dac(codec
, mix
[i
]) == dac
) {
2964 snd_hda_codec_update_cache(codec
, pin
, 0,
2965 AC_VERB_SET_CONNECT_SEL
, i
);
2972 static bool alc_is_dac_already_used(struct hda_codec
*codec
, hda_nid_t nid
)
2974 struct alc_spec
*spec
= codec
->spec
;
2976 if (found_in_nid_list(nid
, spec
->multiout
.dac_nids
,
2977 ARRAY_SIZE(spec
->private_dac_nids
)) ||
2978 found_in_nid_list(nid
, spec
->multiout
.hp_out_nid
,
2979 ARRAY_SIZE(spec
->multiout
.hp_out_nid
)) ||
2980 found_in_nid_list(nid
, spec
->multiout
.extra_out_nid
,
2981 ARRAY_SIZE(spec
->multiout
.extra_out_nid
)))
2983 for (i
= 0; i
< spec
->multi_ios
; i
++) {
2984 if (spec
->multi_io
[i
].dac
== nid
)
2990 /* look for an empty DAC slot */
2991 static hda_nid_t
alc_auto_look_for_dac(struct hda_codec
*codec
, hda_nid_t pin
)
2996 pin
= alc_go_down_to_selector(codec
, pin
);
2997 num
= snd_hda_get_connections(codec
, pin
, srcs
, ARRAY_SIZE(srcs
));
2998 for (i
= 0; i
< num
; i
++) {
2999 hda_nid_t nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
3002 if (!alc_is_dac_already_used(codec
, nid
))
3008 /* check whether the DAC is reachable from the pin */
3009 static bool alc_auto_is_dac_reachable(struct hda_codec
*codec
,
3010 hda_nid_t pin
, hda_nid_t dac
)
3017 pin
= alc_go_down_to_selector(codec
, pin
);
3018 num
= snd_hda_get_connections(codec
, pin
, srcs
, ARRAY_SIZE(srcs
));
3019 for (i
= 0; i
< num
; i
++) {
3020 hda_nid_t nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
3027 static hda_nid_t
get_dac_if_single(struct hda_codec
*codec
, hda_nid_t pin
)
3029 struct alc_spec
*spec
= codec
->spec
;
3030 hda_nid_t sel
= alc_go_down_to_selector(codec
, pin
);
3031 hda_nid_t nid
, nid_found
, srcs
[5];
3032 int i
, num
= snd_hda_get_connections(codec
, sel
, srcs
,
3035 return alc_auto_look_for_dac(codec
, pin
);
3037 for (i
= 0; i
< num
; i
++) {
3038 if (srcs
[i
] == spec
->mixer_nid
)
3040 nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
3041 if (nid
&& !alc_is_dac_already_used(codec
, nid
)) {
3050 /* mark up volume and mute control NIDs: used during badness parsing and
3051 * at creating actual controls
3053 static inline unsigned int get_ctl_pos(unsigned int data
)
3055 hda_nid_t nid
= get_amp_nid_(data
);
3057 if (snd_BUG_ON(nid
>= MAX_VOL_NIDS
))
3059 dir
= get_amp_direction_(data
);
3060 return (nid
<< 1) | dir
;
3063 #define is_ctl_used(bits, data) \
3064 test_bit(get_ctl_pos(data), bits)
3065 #define mark_ctl_usage(bits, data) \
3066 set_bit(get_ctl_pos(data), bits)
3068 static void clear_vol_marks(struct hda_codec
*codec
)
3070 struct alc_spec
*spec
= codec
->spec
;
3071 memset(spec
->vol_ctls
, 0, sizeof(spec
->vol_ctls
));
3072 memset(spec
->sw_ctls
, 0, sizeof(spec
->sw_ctls
));
3075 /* badness definition */
3077 /* No primary DAC is found for the main output */
3078 BAD_NO_PRIMARY_DAC
= 0x10000,
3079 /* No DAC is found for the extra output */
3080 BAD_NO_DAC
= 0x4000,
3081 /* No possible multi-ios */
3082 BAD_MULTI_IO
= 0x103,
3083 /* No individual DAC for extra output */
3084 BAD_NO_EXTRA_DAC
= 0x102,
3085 /* No individual DAC for extra surrounds */
3086 BAD_NO_EXTRA_SURR_DAC
= 0x101,
3087 /* Primary DAC shared with main surrounds */
3088 BAD_SHARED_SURROUND
= 0x100,
3089 /* Primary DAC shared with main CLFE */
3090 BAD_SHARED_CLFE
= 0x10,
3091 /* Primary DAC shared with extra surrounds */
3092 BAD_SHARED_EXTRA_SURROUND
= 0x10,
3093 /* Volume widget is shared */
3094 BAD_SHARED_VOL
= 0x10,
3097 static hda_nid_t
alc_look_for_out_mute_nid(struct hda_codec
*codec
,
3098 hda_nid_t pin
, hda_nid_t dac
);
3099 static hda_nid_t
alc_look_for_out_vol_nid(struct hda_codec
*codec
,
3100 hda_nid_t pin
, hda_nid_t dac
);
3102 static int eval_shared_vol_badness(struct hda_codec
*codec
, hda_nid_t pin
,
3105 struct alc_spec
*spec
= codec
->spec
;
3110 nid
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3112 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
3113 if (is_ctl_used(spec
->vol_ctls
, nid
))
3114 badness
+= BAD_SHARED_VOL
;
3116 mark_ctl_usage(spec
->vol_ctls
, val
);
3118 badness
+= BAD_SHARED_VOL
;
3119 nid
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3121 unsigned int wid_type
= get_wcaps_type(get_wcaps(codec
, nid
));
3122 if (wid_type
== AC_WID_PIN
|| wid_type
== AC_WID_AUD_OUT
)
3123 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
3125 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_INPUT
);
3126 if (is_ctl_used(spec
->sw_ctls
, val
))
3127 badness
+= BAD_SHARED_VOL
;
3129 mark_ctl_usage(spec
->sw_ctls
, val
);
3131 badness
+= BAD_SHARED_VOL
;
3135 struct badness_table
{
3136 int no_primary_dac
; /* no primary DAC */
3137 int no_dac
; /* no secondary DACs */
3138 int shared_primary
; /* primary DAC is shared with main output */
3139 int shared_surr
; /* secondary DAC shared with main or primary */
3140 int shared_clfe
; /* third DAC shared with main or primary */
3141 int shared_surr_main
; /* secondary DAC sahred with main/DAC0 */
3144 static struct badness_table main_out_badness
= {
3145 .no_primary_dac
= BAD_NO_PRIMARY_DAC
,
3146 .no_dac
= BAD_NO_DAC
,
3147 .shared_primary
= BAD_NO_PRIMARY_DAC
,
3148 .shared_surr
= BAD_SHARED_SURROUND
,
3149 .shared_clfe
= BAD_SHARED_CLFE
,
3150 .shared_surr_main
= BAD_SHARED_SURROUND
,
3153 static struct badness_table extra_out_badness
= {
3154 .no_primary_dac
= BAD_NO_DAC
,
3155 .no_dac
= BAD_NO_DAC
,
3156 .shared_primary
= BAD_NO_EXTRA_DAC
,
3157 .shared_surr
= BAD_SHARED_EXTRA_SURROUND
,
3158 .shared_clfe
= BAD_SHARED_EXTRA_SURROUND
,
3159 .shared_surr_main
= BAD_NO_EXTRA_SURR_DAC
,
3162 /* try to assign DACs to pins and return the resultant badness */
3163 static int alc_auto_fill_dacs(struct hda_codec
*codec
, int num_outs
,
3164 const hda_nid_t
*pins
, hda_nid_t
*dacs
,
3165 const struct badness_table
*bad
)
3167 struct alc_spec
*spec
= codec
->spec
;
3168 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3176 for (i
= 0; i
< num_outs
; i
++) {
3177 hda_nid_t pin
= pins
[i
];
3179 dacs
[i
] = alc_auto_look_for_dac(codec
, pin
);
3180 if (!dacs
[i
] && !i
) {
3181 for (j
= 1; j
< num_outs
; j
++) {
3182 if (alc_auto_is_dac_reachable(codec
, pin
, dacs
[j
])) {
3191 if (alc_auto_is_dac_reachable(codec
, pin
, dacs
[0]))
3193 else if (cfg
->line_outs
> i
&&
3194 alc_auto_is_dac_reachable(codec
, pin
,
3195 spec
->private_dac_nids
[i
]))
3196 dac
= spec
->private_dac_nids
[i
];
3199 badness
+= bad
->shared_primary
;
3201 badness
+= bad
->shared_surr
;
3203 badness
+= bad
->shared_clfe
;
3204 } else if (alc_auto_is_dac_reachable(codec
, pin
,
3205 spec
->private_dac_nids
[0])) {
3206 dac
= spec
->private_dac_nids
[0];
3207 badness
+= bad
->shared_surr_main
;
3209 badness
+= bad
->no_primary_dac
;
3211 badness
+= bad
->no_dac
;
3214 badness
+= eval_shared_vol_badness(codec
, pin
, dac
);
3220 static int alc_auto_fill_multi_ios(struct hda_codec
*codec
,
3221 hda_nid_t reference_pin
,
3222 bool hardwired
, int offset
);
3224 static bool alc_map_singles(struct hda_codec
*codec
, int outs
,
3225 const hda_nid_t
*pins
, hda_nid_t
*dacs
)
3229 for (i
= 0; i
< outs
; i
++) {
3232 dacs
[i
] = get_dac_if_single(codec
, pins
[i
]);
3239 /* fill in the dac_nids table from the parsed pin configuration */
3240 static int fill_and_eval_dacs(struct hda_codec
*codec
,
3241 bool fill_hardwired
,
3242 bool fill_mio_first
)
3244 struct alc_spec
*spec
= codec
->spec
;
3245 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3246 int i
, err
, badness
;
3248 /* set num_dacs once to full for alc_auto_look_for_dac() */
3249 spec
->multiout
.num_dacs
= cfg
->line_outs
;
3250 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3251 memset(spec
->private_dac_nids
, 0, sizeof(spec
->private_dac_nids
));
3252 memset(spec
->multiout
.hp_out_nid
, 0, sizeof(spec
->multiout
.hp_out_nid
));
3253 memset(spec
->multiout
.extra_out_nid
, 0, sizeof(spec
->multiout
.extra_out_nid
));
3254 spec
->multi_ios
= 0;
3255 clear_vol_marks(codec
);
3258 /* fill hard-wired DACs first */
3259 if (fill_hardwired
) {
3262 mapped
= alc_map_singles(codec
, cfg
->line_outs
,
3264 spec
->private_dac_nids
);
3265 mapped
|= alc_map_singles(codec
, cfg
->hp_outs
,
3267 spec
->multiout
.hp_out_nid
);
3268 mapped
|= alc_map_singles(codec
, cfg
->speaker_outs
,
3270 spec
->multiout
.extra_out_nid
);
3271 if (fill_mio_first
&& cfg
->line_outs
== 1 &&
3272 cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3273 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], true, 0);
3280 badness
+= alc_auto_fill_dacs(codec
, cfg
->line_outs
, cfg
->line_out_pins
,
3281 spec
->private_dac_nids
,
3284 /* re-count num_dacs and squash invalid entries */
3285 spec
->multiout
.num_dacs
= 0;
3286 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3287 if (spec
->private_dac_nids
[i
])
3288 spec
->multiout
.num_dacs
++;
3290 memmove(spec
->private_dac_nids
+ i
,
3291 spec
->private_dac_nids
+ i
+ 1,
3292 sizeof(hda_nid_t
) * (cfg
->line_outs
- i
- 1));
3293 spec
->private_dac_nids
[cfg
->line_outs
- 1] = 0;
3297 if (fill_mio_first
&&
3298 cfg
->line_outs
== 1 && cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3299 /* try to fill multi-io first */
3300 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], false, 0);
3303 /* we don't count badness at this stage yet */
3306 if (cfg
->line_out_type
!= AUTO_PIN_HP_OUT
) {
3307 err
= alc_auto_fill_dacs(codec
, cfg
->hp_outs
, cfg
->hp_pins
,
3308 spec
->multiout
.hp_out_nid
,
3309 &extra_out_badness
);
3314 if (cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3315 err
= alc_auto_fill_dacs(codec
, cfg
->speaker_outs
,
3317 spec
->multiout
.extra_out_nid
,
3318 &extra_out_badness
);
3323 if (cfg
->line_outs
== 1 && cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3324 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], false, 0);
3329 if (cfg
->hp_outs
&& cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
3330 /* try multi-ios with HP + inputs */
3331 err
= alc_auto_fill_multi_ios(codec
, cfg
->hp_pins
[0], false, 1);
3337 if (spec
->multi_ios
== 2) {
3338 for (i
= 0; i
< 2; i
++)
3339 spec
->private_dac_nids
[spec
->multiout
.num_dacs
++] =
3340 spec
->multi_io
[i
].dac
;
3341 spec
->ext_channel_count
= 2;
3342 } else if (spec
->multi_ios
) {
3343 spec
->multi_ios
= 0;
3344 badness
+= BAD_MULTI_IO
;
3350 #define DEBUG_BADNESS
3352 #ifdef DEBUG_BADNESS
3353 #define debug_badness snd_printdd
3355 #define debug_badness(...)
3358 static void debug_show_configs(struct alc_spec
*spec
, struct auto_pin_cfg
*cfg
)
3360 debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3361 cfg
->line_out_pins
[0], cfg
->line_out_pins
[1],
3362 cfg
->line_out_pins
[2], cfg
->line_out_pins
[2],
3363 spec
->multiout
.dac_nids
[0],
3364 spec
->multiout
.dac_nids
[1],
3365 spec
->multiout
.dac_nids
[2],
3366 spec
->multiout
.dac_nids
[3]);
3367 if (spec
->multi_ios
> 0)
3368 debug_badness("multi_ios(%d) = %x/%x : %x/%x\n",
3370 spec
->multi_io
[0].pin
, spec
->multi_io
[1].pin
,
3371 spec
->multi_io
[0].dac
, spec
->multi_io
[1].dac
);
3372 debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3373 cfg
->hp_pins
[0], cfg
->hp_pins
[1],
3374 cfg
->hp_pins
[2], cfg
->hp_pins
[2],
3375 spec
->multiout
.hp_out_nid
[0],
3376 spec
->multiout
.hp_out_nid
[1],
3377 spec
->multiout
.hp_out_nid
[2],
3378 spec
->multiout
.hp_out_nid
[3]);
3379 debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3380 cfg
->speaker_pins
[0], cfg
->speaker_pins
[1],
3381 cfg
->speaker_pins
[2], cfg
->speaker_pins
[3],
3382 spec
->multiout
.extra_out_nid
[0],
3383 spec
->multiout
.extra_out_nid
[1],
3384 spec
->multiout
.extra_out_nid
[2],
3385 spec
->multiout
.extra_out_nid
[3]);
3388 static int alc_auto_fill_dac_nids(struct hda_codec
*codec
)
3390 struct alc_spec
*spec
= codec
->spec
;
3391 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3392 struct auto_pin_cfg
*best_cfg
;
3393 int best_badness
= INT_MAX
;
3395 bool fill_hardwired
= true, fill_mio_first
= true;
3396 bool best_wired
= true, best_mio
= true;
3397 bool hp_spk_swapped
= false;
3399 best_cfg
= kmalloc(sizeof(*best_cfg
), GFP_KERNEL
);
3405 badness
= fill_and_eval_dacs(codec
, fill_hardwired
,
3409 debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n",
3410 cfg
->line_out_type
, fill_hardwired
, fill_mio_first
,
3412 debug_show_configs(spec
, cfg
);
3413 if (badness
< best_badness
) {
3414 best_badness
= badness
;
3416 best_wired
= fill_hardwired
;
3417 best_mio
= fill_mio_first
;
3421 fill_mio_first
= !fill_mio_first
;
3422 if (!fill_mio_first
)
3424 fill_hardwired
= !fill_hardwired
;
3425 if (!fill_hardwired
)
3429 hp_spk_swapped
= true;
3430 if (cfg
->speaker_outs
> 0 &&
3431 cfg
->line_out_type
== AUTO_PIN_HP_OUT
) {
3432 cfg
->hp_outs
= cfg
->line_outs
;
3433 memcpy(cfg
->hp_pins
, cfg
->line_out_pins
,
3434 sizeof(cfg
->hp_pins
));
3435 cfg
->line_outs
= cfg
->speaker_outs
;
3436 memcpy(cfg
->line_out_pins
, cfg
->speaker_pins
,
3437 sizeof(cfg
->speaker_pins
));
3438 cfg
->speaker_outs
= 0;
3439 memset(cfg
->speaker_pins
, 0, sizeof(cfg
->speaker_pins
));
3440 cfg
->line_out_type
= AUTO_PIN_SPEAKER_OUT
;
3441 fill_hardwired
= true;
3444 if (cfg
->hp_outs
> 0 &&
3445 cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
3446 cfg
->speaker_outs
= cfg
->line_outs
;
3447 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
3448 sizeof(cfg
->speaker_pins
));
3449 cfg
->line_outs
= cfg
->hp_outs
;
3450 memcpy(cfg
->line_out_pins
, cfg
->hp_pins
,
3451 sizeof(cfg
->hp_pins
));
3453 memset(cfg
->hp_pins
, 0, sizeof(cfg
->hp_pins
));
3454 cfg
->line_out_type
= AUTO_PIN_HP_OUT
;
3455 fill_hardwired
= true;
3463 fill_and_eval_dacs(codec
, best_wired
, best_mio
);
3465 debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n",
3466 cfg
->line_out_type
, best_wired
, best_mio
);
3467 debug_show_configs(spec
, cfg
);
3469 if (cfg
->line_out_pins
[0])
3471 alc_look_for_out_vol_nid(codec
, cfg
->line_out_pins
[0],
3472 spec
->multiout
.dac_nids
[0]);
3474 /* clear the bitmap flags for creating controls */
3475 clear_vol_marks(codec
);
3480 static int alc_auto_add_vol_ctl(struct hda_codec
*codec
,
3481 const char *pfx
, int cidx
,
3482 hda_nid_t nid
, unsigned int chs
)
3484 struct alc_spec
*spec
= codec
->spec
;
3488 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
);
3489 if (is_ctl_used(spec
->vol_ctls
, val
) && chs
!= 2) /* exclude LFE */
3491 mark_ctl_usage(spec
->vol_ctls
, val
);
3492 return __add_pb_vol_ctrl(codec
->spec
, ALC_CTL_WIDGET_VOL
, pfx
, cidx
,
3496 static int alc_auto_add_stereo_vol(struct hda_codec
*codec
,
3497 const char *pfx
, int cidx
,
3501 if (get_wcaps(codec
, nid
) & AC_WCAP_STEREO
)
3503 return alc_auto_add_vol_ctl(codec
, pfx
, cidx
, nid
, chs
);
3506 /* create a mute-switch for the given mixer widget;
3507 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
3509 static int alc_auto_add_sw_ctl(struct hda_codec
*codec
,
3510 const char *pfx
, int cidx
,
3511 hda_nid_t nid
, unsigned int chs
)
3513 struct alc_spec
*spec
= codec
->spec
;
3519 wid_type
= get_wcaps_type(get_wcaps(codec
, nid
));
3520 if (wid_type
== AC_WID_PIN
|| wid_type
== AC_WID_AUD_OUT
) {
3521 type
= ALC_CTL_WIDGET_MUTE
;
3522 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
);
3523 } else if (snd_hda_get_conn_list(codec
, nid
, NULL
) == 1) {
3524 type
= ALC_CTL_WIDGET_MUTE
;
3525 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_INPUT
);
3527 type
= ALC_CTL_BIND_MUTE
;
3528 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 2, HDA_INPUT
);
3530 if (is_ctl_used(spec
->sw_ctls
, val
) && chs
!= 2) /* exclude LFE */
3532 mark_ctl_usage(spec
->sw_ctls
, val
);
3533 return __add_pb_sw_ctrl(codec
->spec
, type
, pfx
, cidx
, val
);
3536 static int alc_auto_add_stereo_sw(struct hda_codec
*codec
, const char *pfx
,
3537 int cidx
, hda_nid_t nid
)
3540 if (get_wcaps(codec
, nid
) & AC_WCAP_STEREO
)
3542 return alc_auto_add_sw_ctl(codec
, pfx
, cidx
, nid
, chs
);
3545 static hda_nid_t
alc_look_for_out_mute_nid(struct hda_codec
*codec
,
3546 hda_nid_t pin
, hda_nid_t dac
)
3548 hda_nid_t mix
= alc_auto_dac_to_mix(codec
, pin
, dac
);
3549 if (nid_has_mute(codec
, pin
, HDA_OUTPUT
))
3551 else if (mix
&& nid_has_mute(codec
, mix
, HDA_INPUT
))
3553 else if (nid_has_mute(codec
, dac
, HDA_OUTPUT
))
3558 static hda_nid_t
alc_look_for_out_vol_nid(struct hda_codec
*codec
,
3559 hda_nid_t pin
, hda_nid_t dac
)
3561 hda_nid_t mix
= alc_auto_dac_to_mix(codec
, pin
, dac
);
3562 if (nid_has_volume(codec
, dac
, HDA_OUTPUT
))
3564 else if (nid_has_volume(codec
, mix
, HDA_OUTPUT
))
3566 else if (nid_has_volume(codec
, pin
, HDA_OUTPUT
))
3571 /* add playback controls from the parsed DAC table */
3572 static int alc_auto_create_multi_out_ctls(struct hda_codec
*codec
,
3573 const struct auto_pin_cfg
*cfg
)
3575 struct alc_spec
*spec
= codec
->spec
;
3576 int i
, err
, noutputs
;
3578 noutputs
= cfg
->line_outs
;
3579 if (spec
->multi_ios
> 0 && cfg
->line_outs
< 3)
3580 noutputs
+= spec
->multi_ios
;
3582 for (i
= 0; i
< noutputs
; i
++) {
3588 dac
= spec
->multiout
.dac_nids
[i
];
3591 if (i
>= cfg
->line_outs
)
3592 pin
= spec
->multi_io
[i
- 1].pin
;
3594 pin
= cfg
->line_out_pins
[i
];
3596 sw
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3597 vol
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3598 name
= alc_get_line_out_pfx(spec
, i
, true, &index
);
3599 if (!name
|| !strcmp(name
, "CLFE")) {
3601 err
= alc_auto_add_vol_ctl(codec
, "Center", 0, vol
, 1);
3604 err
= alc_auto_add_vol_ctl(codec
, "LFE", 0, vol
, 2);
3607 err
= alc_auto_add_sw_ctl(codec
, "Center", 0, sw
, 1);
3610 err
= alc_auto_add_sw_ctl(codec
, "LFE", 0, sw
, 2);
3614 err
= alc_auto_add_stereo_vol(codec
, name
, index
, vol
);
3617 err
= alc_auto_add_stereo_sw(codec
, name
, index
, sw
);
3625 static int alc_auto_create_extra_out(struct hda_codec
*codec
, hda_nid_t pin
,
3626 hda_nid_t dac
, const char *pfx
,
3629 struct alc_spec
*spec
= codec
->spec
;
3635 /* the corresponding DAC is already occupied */
3636 if (!(get_wcaps(codec
, pin
) & AC_WCAP_OUT_AMP
))
3637 return 0; /* no way */
3638 /* create a switch only */
3639 val
= HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
);
3640 if (is_ctl_used(spec
->sw_ctls
, val
))
3641 return 0; /* already created */
3642 mark_ctl_usage(spec
->sw_ctls
, val
);
3643 return __add_pb_sw_ctrl(spec
, ALC_CTL_WIDGET_MUTE
, pfx
, cidx
, val
);
3646 sw
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3647 vol
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3648 err
= alc_auto_add_stereo_vol(codec
, pfx
, cidx
, vol
);
3651 err
= alc_auto_add_stereo_sw(codec
, pfx
, cidx
, sw
);
3657 static struct hda_bind_ctls
*new_bind_ctl(struct hda_codec
*codec
,
3659 struct hda_ctl_ops
*ops
)
3661 struct alc_spec
*spec
= codec
->spec
;
3662 struct hda_bind_ctls
**ctlp
, *ctl
;
3663 snd_array_init(&spec
->bind_ctls
, sizeof(ctl
), 8);
3664 ctlp
= snd_array_new(&spec
->bind_ctls
);
3667 ctl
= kzalloc(sizeof(*ctl
) + sizeof(long) * (nums
+ 1), GFP_KERNEL
);
3674 /* add playback controls for speaker and HP outputs */
3675 static int alc_auto_create_extra_outs(struct hda_codec
*codec
, int num_pins
,
3676 const hda_nid_t
*pins
,
3677 const hda_nid_t
*dacs
,
3680 struct alc_spec
*spec
= codec
->spec
;
3681 struct hda_bind_ctls
*ctl
;
3685 if (!num_pins
|| !pins
[0])
3688 if (num_pins
== 1) {
3689 hda_nid_t dac
= *dacs
;
3691 dac
= spec
->multiout
.dac_nids
[0];
3692 return alc_auto_create_extra_out(codec
, *pins
, dac
, pfx
, 0);
3695 if (dacs
[num_pins
- 1]) {
3696 /* OK, we have a multi-output system with individual volumes */
3697 for (i
= 0; i
< num_pins
; i
++) {
3698 if (num_pins
>= 3) {
3699 snprintf(name
, sizeof(name
), "%s %s",
3700 pfx
, channel_name
[i
]);
3701 err
= alc_auto_create_extra_out(codec
, pins
[i
], dacs
[i
],
3704 err
= alc_auto_create_extra_out(codec
, pins
[i
], dacs
[i
],
3713 /* Let's create a bind-controls */
3714 ctl
= new_bind_ctl(codec
, num_pins
, &snd_hda_bind_sw
);
3718 for (i
= 0; i
< num_pins
; i
++) {
3719 if (get_wcaps(codec
, pins
[i
]) & AC_WCAP_OUT_AMP
)
3721 HDA_COMPOSE_AMP_VAL(pins
[i
], 3, 0, HDA_OUTPUT
);
3724 snprintf(name
, sizeof(name
), "%s Playback Switch", pfx
);
3725 err
= add_control(spec
, ALC_CTL_BIND_SW
, name
, 0, (long)ctl
);
3730 ctl
= new_bind_ctl(codec
, num_pins
, &snd_hda_bind_vol
);
3734 for (i
= 0; i
< num_pins
; i
++) {
3736 if (!pins
[i
] || !dacs
[i
])
3738 vol
= alc_look_for_out_vol_nid(codec
, pins
[i
], dacs
[i
]);
3741 HDA_COMPOSE_AMP_VAL(vol
, 3, 0, HDA_OUTPUT
);
3744 snprintf(name
, sizeof(name
), "%s Playback Volume", pfx
);
3745 err
= add_control(spec
, ALC_CTL_BIND_VOL
, name
, 0, (long)ctl
);
3752 static int alc_auto_create_hp_out(struct hda_codec
*codec
)
3754 struct alc_spec
*spec
= codec
->spec
;
3755 return alc_auto_create_extra_outs(codec
, spec
->autocfg
.hp_outs
,
3756 spec
->autocfg
.hp_pins
,
3757 spec
->multiout
.hp_out_nid
,
3761 static int alc_auto_create_speaker_out(struct hda_codec
*codec
)
3763 struct alc_spec
*spec
= codec
->spec
;
3764 return alc_auto_create_extra_outs(codec
, spec
->autocfg
.speaker_outs
,
3765 spec
->autocfg
.speaker_pins
,
3766 spec
->multiout
.extra_out_nid
,
3770 static void alc_auto_set_output_and_unmute(struct hda_codec
*codec
,
3771 hda_nid_t pin
, int pin_type
,
3775 hda_nid_t nid
, mix
= 0;
3776 hda_nid_t srcs
[HDA_MAX_CONNECTIONS
];
3778 alc_set_pin_output(codec
, pin
, pin_type
);
3779 nid
= alc_go_down_to_selector(codec
, pin
);
3780 num
= snd_hda_get_connections(codec
, nid
, srcs
, ARRAY_SIZE(srcs
));
3781 for (i
= 0; i
< num
; i
++) {
3782 if (alc_auto_mix_to_dac(codec
, srcs
[i
]) != dac
)
3790 /* need the manual connection? */
3792 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_CONNECT_SEL
, i
);
3793 /* unmute mixer widget inputs */
3794 if (nid_has_mute(codec
, mix
, HDA_INPUT
)) {
3795 snd_hda_codec_write(codec
, mix
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3797 snd_hda_codec_write(codec
, mix
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3800 /* initialize volume */
3801 nid
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3803 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3806 /* unmute DAC if it's not assigned to a mixer */
3807 nid
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3808 if (nid
== mix
&& nid_has_mute(codec
, dac
, HDA_OUTPUT
))
3809 snd_hda_codec_write(codec
, dac
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3813 static void alc_auto_init_multi_out(struct hda_codec
*codec
)
3815 struct alc_spec
*spec
= codec
->spec
;
3816 int pin_type
= get_pin_type(spec
->autocfg
.line_out_type
);
3819 for (i
= 0; i
<= HDA_SIDE
; i
++) {
3820 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
3822 alc_auto_set_output_and_unmute(codec
, nid
, pin_type
,
3823 spec
->multiout
.dac_nids
[i
]);
3827 static void alc_auto_init_extra_out(struct hda_codec
*codec
)
3829 struct alc_spec
*spec
= codec
->spec
;
3833 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
3834 if (spec
->autocfg
.line_out_type
== AUTO_PIN_HP_OUT
)
3836 pin
= spec
->autocfg
.hp_pins
[i
];
3839 dac
= spec
->multiout
.hp_out_nid
[i
];
3841 if (i
> 0 && spec
->multiout
.hp_out_nid
[0])
3842 dac
= spec
->multiout
.hp_out_nid
[0];
3844 dac
= spec
->multiout
.dac_nids
[0];
3846 alc_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, dac
);
3848 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++) {
3849 if (spec
->autocfg
.line_out_type
== AUTO_PIN_SPEAKER_OUT
)
3851 pin
= spec
->autocfg
.speaker_pins
[i
];
3854 dac
= spec
->multiout
.extra_out_nid
[i
];
3856 if (i
> 0 && spec
->multiout
.extra_out_nid
[0])
3857 dac
= spec
->multiout
.extra_out_nid
[0];
3859 dac
= spec
->multiout
.dac_nids
[0];
3861 alc_auto_set_output_and_unmute(codec
, pin
, PIN_OUT
, dac
);
3865 /* check whether the given pin can be a multi-io pin */
3866 static bool can_be_multiio_pin(struct hda_codec
*codec
,
3867 unsigned int location
, hda_nid_t nid
)
3869 unsigned int defcfg
, caps
;
3871 defcfg
= snd_hda_codec_get_pincfg(codec
, nid
);
3872 if (get_defcfg_connect(defcfg
) != AC_JACK_PORT_COMPLEX
)
3874 if (location
&& get_defcfg_location(defcfg
) != location
)
3876 caps
= snd_hda_query_pin_caps(codec
, nid
);
3877 if (!(caps
& AC_PINCAP_OUT
))
3885 * When hardwired is set, try to fill ony hardwired pins, and returns
3886 * zero if any pins are filled, non-zero if nothing found.
3887 * When hardwired is off, try to fill possible input pins, and returns
3888 * the badness value.
3890 static int alc_auto_fill_multi_ios(struct hda_codec
*codec
,
3891 hda_nid_t reference_pin
,
3892 bool hardwired
, int offset
)
3894 struct alc_spec
*spec
= codec
->spec
;
3895 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3896 int type
, i
, j
, dacs
, num_pins
, old_pins
;
3897 unsigned int defcfg
= snd_hda_codec_get_pincfg(codec
, reference_pin
);
3898 unsigned int location
= get_defcfg_location(defcfg
);
3901 old_pins
= spec
->multi_ios
;
3906 for (type
= AUTO_PIN_LINE_IN
; type
>= AUTO_PIN_MIC
; type
--) {
3907 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3908 if (cfg
->inputs
[i
].type
!= type
)
3910 if (can_be_multiio_pin(codec
, location
,
3911 cfg
->inputs
[i
].pin
))
3918 dacs
= spec
->multiout
.num_dacs
;
3919 for (type
= AUTO_PIN_LINE_IN
; type
>= AUTO_PIN_MIC
; type
--) {
3920 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3921 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
3924 if (cfg
->inputs
[i
].type
!= type
)
3926 if (!can_be_multiio_pin(codec
, location
, nid
))
3928 for (j
= 0; j
< spec
->multi_ios
; j
++) {
3929 if (nid
== spec
->multi_io
[j
].pin
)
3932 if (j
< spec
->multi_ios
)
3935 if (offset
&& offset
+ spec
->multi_ios
< dacs
) {
3936 dac
= spec
->private_dac_nids
[offset
+ spec
->multi_ios
];
3937 if (!alc_auto_is_dac_reachable(codec
, nid
, dac
))
3941 dac
= get_dac_if_single(codec
, nid
);
3943 dac
= alc_auto_look_for_dac(codec
, nid
);
3948 spec
->multi_io
[spec
->multi_ios
].pin
= nid
;
3949 spec
->multi_io
[spec
->multi_ios
].dac
= dac
;
3951 if (spec
->multi_ios
>= 2)
3957 badness
= BAD_MULTI_IO
;
3958 if (old_pins
== spec
->multi_ios
) {
3960 return 1; /* nothing found */
3962 return badness
; /* no badness if nothing found */
3964 if (!hardwired
&& spec
->multi_ios
< 2) {
3965 spec
->multi_ios
= old_pins
;
3972 static int alc_auto_ch_mode_info(struct snd_kcontrol
*kcontrol
,
3973 struct snd_ctl_elem_info
*uinfo
)
3975 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3976 struct alc_spec
*spec
= codec
->spec
;
3978 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
3980 uinfo
->value
.enumerated
.items
= spec
->multi_ios
+ 1;
3981 if (uinfo
->value
.enumerated
.item
> spec
->multi_ios
)
3982 uinfo
->value
.enumerated
.item
= spec
->multi_ios
;
3983 sprintf(uinfo
->value
.enumerated
.name
, "%dch",
3984 (uinfo
->value
.enumerated
.item
+ 1) * 2);
3988 static int alc_auto_ch_mode_get(struct snd_kcontrol
*kcontrol
,
3989 struct snd_ctl_elem_value
*ucontrol
)
3991 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3992 struct alc_spec
*spec
= codec
->spec
;
3993 ucontrol
->value
.enumerated
.item
[0] = (spec
->ext_channel_count
- 1) / 2;
3997 static int alc_set_multi_io(struct hda_codec
*codec
, int idx
, bool output
)
3999 struct alc_spec
*spec
= codec
->spec
;
4000 hda_nid_t nid
= spec
->multi_io
[idx
].pin
;
4002 if (!spec
->multi_io
[idx
].ctl_in
)
4003 spec
->multi_io
[idx
].ctl_in
=
4004 snd_hda_codec_read(codec
, nid
, 0,
4005 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
4007 snd_hda_codec_update_cache(codec
, nid
, 0,
4008 AC_VERB_SET_PIN_WIDGET_CONTROL
,
4010 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
4011 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
4013 alc_auto_select_dac(codec
, nid
, spec
->multi_io
[idx
].dac
);
4015 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
4016 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
4017 HDA_AMP_MUTE
, HDA_AMP_MUTE
);
4018 snd_hda_codec_update_cache(codec
, nid
, 0,
4019 AC_VERB_SET_PIN_WIDGET_CONTROL
,
4020 spec
->multi_io
[idx
].ctl_in
);
4025 static int alc_auto_ch_mode_put(struct snd_kcontrol
*kcontrol
,
4026 struct snd_ctl_elem_value
*ucontrol
)
4028 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
4029 struct alc_spec
*spec
= codec
->spec
;
4032 ch
= ucontrol
->value
.enumerated
.item
[0];
4033 if (ch
< 0 || ch
> spec
->multi_ios
)
4035 if (ch
== (spec
->ext_channel_count
- 1) / 2)
4037 spec
->ext_channel_count
= (ch
+ 1) * 2;
4038 for (i
= 0; i
< spec
->multi_ios
; i
++)
4039 alc_set_multi_io(codec
, i
, i
< ch
);
4040 spec
->multiout
.max_channels
= spec
->ext_channel_count
;
4041 if (spec
->need_dac_fix
&& !spec
->const_channel_count
)
4042 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
4046 static const struct snd_kcontrol_new alc_auto_channel_mode_enum
= {
4047 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4048 .name
= "Channel Mode",
4049 .info
= alc_auto_ch_mode_info
,
4050 .get
= alc_auto_ch_mode_get
,
4051 .put
= alc_auto_ch_mode_put
,
4054 static int alc_auto_add_multi_channel_mode(struct hda_codec
*codec
)
4056 struct alc_spec
*spec
= codec
->spec
;
4058 if (spec
->multi_ios
> 0) {
4059 struct snd_kcontrol_new
*knew
;
4061 knew
= alc_kcontrol_new(spec
);
4064 *knew
= alc_auto_channel_mode_enum
;
4065 knew
->name
= kstrdup("Channel Mode", GFP_KERNEL
);
4072 /* filter out invalid adc_nids (and capsrc_nids) that don't give all
4075 static void alc_remove_invalid_adc_nids(struct hda_codec
*codec
)
4077 struct alc_spec
*spec
= codec
->spec
;
4078 const struct hda_input_mux
*imux
;
4079 hda_nid_t adc_nids
[ARRAY_SIZE(spec
->private_adc_nids
)];
4080 hda_nid_t capsrc_nids
[ARRAY_SIZE(spec
->private_adc_nids
)];
4083 imux
= spec
->input_mux
;
4086 if (spec
->dyn_adc_switch
)
4090 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
4091 hda_nid_t cap
= spec
->private_capsrc_nids
[n
];
4092 int num_conns
= snd_hda_get_conn_list(codec
, cap
, NULL
);
4093 for (i
= 0; i
< imux
->num_items
; i
++) {
4094 hda_nid_t pin
= spec
->imux_pins
[i
];
4096 if (get_connection_index(codec
, cap
, pin
) < 0)
4098 } else if (num_conns
<= imux
->items
[i
].index
)
4101 if (i
>= imux
->num_items
) {
4102 adc_nids
[nums
] = spec
->private_adc_nids
[n
];
4103 capsrc_nids
[nums
++] = cap
;
4107 /* check whether ADC-switch is possible */
4108 if (!alc_check_dyn_adc_switch(codec
)) {
4109 printk(KERN_WARNING
"hda_codec: %s: no valid ADC found;"
4110 " using fallback 0x%x\n",
4111 codec
->chip_name
, spec
->private_adc_nids
[0]);
4112 spec
->num_adc_nids
= 1;
4116 } else if (nums
!= spec
->num_adc_nids
) {
4117 memcpy(spec
->private_adc_nids
, adc_nids
,
4118 nums
* sizeof(hda_nid_t
));
4119 memcpy(spec
->private_capsrc_nids
, capsrc_nids
,
4120 nums
* sizeof(hda_nid_t
));
4121 spec
->num_adc_nids
= nums
;
4125 alc_auto_mic_check_imux(codec
); /* check auto-mic setups */
4126 else if (spec
->input_mux
->num_items
== 1)
4127 spec
->num_adc_nids
= 1; /* reduce to a single ADC */
4131 * initialize ADC paths
4133 static void alc_auto_init_adc(struct hda_codec
*codec
, int adc_idx
)
4135 struct alc_spec
*spec
= codec
->spec
;
4138 nid
= spec
->adc_nids
[adc_idx
];
4140 if (nid_has_mute(codec
, nid
, HDA_INPUT
)) {
4141 snd_hda_codec_write(codec
, nid
, 0,
4142 AC_VERB_SET_AMP_GAIN_MUTE
,
4146 if (!spec
->capsrc_nids
)
4148 nid
= spec
->capsrc_nids
[adc_idx
];
4149 if (nid_has_mute(codec
, nid
, HDA_OUTPUT
))
4150 snd_hda_codec_write(codec
, nid
, 0,
4151 AC_VERB_SET_AMP_GAIN_MUTE
,
4155 static void alc_auto_init_input_src(struct hda_codec
*codec
)
4157 struct alc_spec
*spec
= codec
->spec
;
4160 for (c
= 0; c
< spec
->num_adc_nids
; c
++)
4161 alc_auto_init_adc(codec
, c
);
4162 if (spec
->dyn_adc_switch
)
4165 nums
= spec
->num_adc_nids
;
4166 for (c
= 0; c
< nums
; c
++)
4167 alc_mux_select(codec
, 0, spec
->cur_mux
[c
], true);
4170 /* add mic boosts if needed */
4171 static int alc_auto_add_mic_boost(struct hda_codec
*codec
)
4173 struct alc_spec
*spec
= codec
->spec
;
4174 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4178 const char *prev_label
= NULL
;
4180 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
4181 if (cfg
->inputs
[i
].type
> AUTO_PIN_MIC
)
4183 nid
= cfg
->inputs
[i
].pin
;
4184 if (get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
) {
4186 char boost_label
[32];
4188 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
4189 if (spec
->shared_mic_hp
&& !strcmp(label
, "Misc"))
4190 label
= "Headphone Mic";
4191 if (prev_label
&& !strcmp(label
, prev_label
))
4197 snprintf(boost_label
, sizeof(boost_label
),
4198 "%s Boost Volume", label
);
4199 err
= add_control(spec
, ALC_CTL_WIDGET_VOL
,
4200 boost_label
, type_idx
,
4201 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_INPUT
));
4209 /* select or unmute the given capsrc route */
4210 static void select_or_unmute_capsrc(struct hda_codec
*codec
, hda_nid_t cap
,
4213 if (get_wcaps_type(get_wcaps(codec
, cap
)) == AC_WID_AUD_MIX
) {
4214 snd_hda_codec_amp_stereo(codec
, cap
, HDA_INPUT
, idx
,
4216 } else if (snd_hda_get_conn_list(codec
, cap
, NULL
) > 1) {
4217 snd_hda_codec_write_cache(codec
, cap
, 0,
4218 AC_VERB_SET_CONNECT_SEL
, idx
);
4222 /* set the default connection to that pin */
4223 static int init_capsrc_for_pin(struct hda_codec
*codec
, hda_nid_t pin
)
4225 struct alc_spec
*spec
= codec
->spec
;
4230 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
4231 hda_nid_t cap
= get_capsrc(spec
, i
);
4234 idx
= get_connection_index(codec
, cap
, pin
);
4237 select_or_unmute_capsrc(codec
, cap
, idx
);
4238 return i
; /* return the found index */
4240 return -1; /* not found */
4243 /* initialize some special cases for input sources */
4244 static void alc_init_special_input_src(struct hda_codec
*codec
)
4246 struct alc_spec
*spec
= codec
->spec
;
4249 for (i
= 0; i
< spec
->autocfg
.num_inputs
; i
++)
4250 init_capsrc_for_pin(codec
, spec
->autocfg
.inputs
[i
].pin
);
4253 /* assign appropriate capture mixers */
4254 static void set_capture_mixer(struct hda_codec
*codec
)
4256 struct alc_spec
*spec
= codec
->spec
;
4257 static const struct snd_kcontrol_new
*caps
[2][3] = {
4258 { alc_capture_mixer_nosrc1
,
4259 alc_capture_mixer_nosrc2
,
4260 alc_capture_mixer_nosrc3
},
4261 { alc_capture_mixer1
,
4263 alc_capture_mixer3
},
4266 /* check whether either of ADC or MUX has a volume control */
4267 if (!nid_has_volume(codec
, spec
->adc_nids
[0], HDA_INPUT
)) {
4268 if (!spec
->capsrc_nids
)
4269 return; /* no volume */
4270 if (!nid_has_volume(codec
, spec
->capsrc_nids
[0], HDA_OUTPUT
))
4271 return; /* no volume in capsrc, too */
4272 spec
->vol_in_capsrc
= 1;
4275 if (spec
->num_adc_nids
> 0) {
4279 if (spec
->input_mux
&& spec
->input_mux
->num_items
> 1)
4281 if (spec
->auto_mic
) {
4284 } else if (spec
->dyn_adc_switch
)
4287 if (spec
->num_adc_nids
> 3)
4288 spec
->num_adc_nids
= 3;
4289 else if (!spec
->num_adc_nids
)
4291 num_adcs
= spec
->num_adc_nids
;
4293 spec
->cap_mixer
= caps
[mux
][num_adcs
- 1];
4298 * standard auto-parser initializations
4300 static void alc_auto_init_std(struct hda_codec
*codec
)
4302 struct alc_spec
*spec
= codec
->spec
;
4303 alc_auto_init_multi_out(codec
);
4304 alc_auto_init_extra_out(codec
);
4305 alc_auto_init_analog_input(codec
);
4306 alc_auto_init_input_src(codec
);
4307 alc_auto_init_digital(codec
);
4308 if (spec
->unsol_event
)
4309 alc_inithook(codec
);
4313 * Digital-beep handlers
4315 #ifdef CONFIG_SND_HDA_INPUT_BEEP
4316 #define set_beep_amp(spec, nid, idx, dir) \
4317 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4319 static const struct snd_pci_quirk beep_white_list
[] = {
4320 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
4321 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
4322 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
4323 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
4324 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
4328 static inline int has_cdefine_beep(struct hda_codec
*codec
)
4330 struct alc_spec
*spec
= codec
->spec
;
4331 const struct snd_pci_quirk
*q
;
4332 q
= snd_pci_quirk_lookup(codec
->bus
->pci
, beep_white_list
);
4335 return spec
->cdefine
.enable_pcbeep
;
4338 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
4339 #define has_cdefine_beep(codec) 0
4342 /* parse the BIOS configuration and set up the alc_spec */
4343 /* return 1 if successful, 0 if the proper config is not found,
4344 * or a negative error code
4346 static int alc_parse_auto_config(struct hda_codec
*codec
,
4347 const hda_nid_t
*ignore_nids
,
4348 const hda_nid_t
*ssid_nids
)
4350 struct alc_spec
*spec
= codec
->spec
;
4351 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4354 err
= snd_hda_parse_pin_defcfg(codec
, cfg
, ignore_nids
,
4358 if (!cfg
->line_outs
) {
4359 if (cfg
->dig_outs
|| cfg
->dig_in_pin
) {
4360 spec
->multiout
.max_channels
= 2;
4361 spec
->no_analog
= 1;
4364 return 0; /* can't find valid BIOS pin config */
4367 if (cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
&&
4368 cfg
->line_outs
<= cfg
->hp_outs
) {
4369 /* use HP as primary out */
4370 cfg
->speaker_outs
= cfg
->line_outs
;
4371 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
4372 sizeof(cfg
->speaker_pins
));
4373 cfg
->line_outs
= cfg
->hp_outs
;
4374 memcpy(cfg
->line_out_pins
, cfg
->hp_pins
, sizeof(cfg
->hp_pins
));
4376 memset(cfg
->hp_pins
, 0, sizeof(cfg
->hp_pins
));
4377 cfg
->line_out_type
= AUTO_PIN_HP_OUT
;
4380 err
= alc_auto_fill_dac_nids(codec
);
4383 err
= alc_auto_add_multi_channel_mode(codec
);
4386 err
= alc_auto_create_multi_out_ctls(codec
, cfg
);
4389 err
= alc_auto_create_hp_out(codec
);
4392 err
= alc_auto_create_speaker_out(codec
);
4395 err
= alc_auto_create_shared_input(codec
);
4398 err
= alc_auto_create_input_ctls(codec
);
4402 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
4405 alc_auto_parse_digital(codec
);
4407 if (!spec
->no_analog
)
4408 alc_remove_invalid_adc_nids(codec
);
4411 alc_ssid_check(codec
, ssid_nids
);
4413 if (!spec
->no_analog
) {
4414 alc_auto_check_switches(codec
);
4415 err
= alc_auto_add_mic_boost(codec
);
4420 if (spec
->kctls
.list
)
4421 add_mixer(spec
, spec
->kctls
.list
);
4426 static int alc880_parse_auto_config(struct hda_codec
*codec
)
4428 static const hda_nid_t alc880_ignore
[] = { 0x1d, 0 };
4429 static const hda_nid_t alc880_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
4430 return alc_parse_auto_config(codec
, alc880_ignore
, alc880_ssids
);
4433 #ifdef CONFIG_SND_HDA_POWER_SAVE
4434 static const struct hda_amp_list alc880_loopbacks
[] = {
4435 { 0x0b, HDA_INPUT
, 0 },
4436 { 0x0b, HDA_INPUT
, 1 },
4437 { 0x0b, HDA_INPUT
, 2 },
4438 { 0x0b, HDA_INPUT
, 3 },
4439 { 0x0b, HDA_INPUT
, 4 },
4450 ALC880_FIXUP_MEDION_RIM
,
4453 ALC880_FIXUP_EAPD_COEF
,
4454 ALC880_FIXUP_TCL_S700
,
4455 ALC880_FIXUP_VOL_KNOB
,
4456 ALC880_FIXUP_FUJITSU
,
4458 ALC880_FIXUP_UNIWILL
,
4459 ALC880_FIXUP_UNIWILL_DIG
,
4461 ALC880_FIXUP_3ST_BASE
,
4463 ALC880_FIXUP_3ST_DIG
,
4464 ALC880_FIXUP_5ST_BASE
,
4466 ALC880_FIXUP_5ST_DIG
,
4467 ALC880_FIXUP_6ST_BASE
,
4469 ALC880_FIXUP_6ST_DIG
,
4472 /* enable the volume-knob widget support on NID 0x21 */
4473 static void alc880_fixup_vol_knob(struct hda_codec
*codec
,
4474 const struct alc_fixup
*fix
, int action
)
4476 if (action
== ALC_FIXUP_ACT_PROBE
)
4477 snd_hda_jack_detect_enable(codec
, 0x21, ALC_DCVOL_EVENT
);
4480 static const struct alc_fixup alc880_fixups
[] = {
4481 [ALC880_FIXUP_GPIO1
] = {
4482 .type
= ALC_FIXUP_VERBS
,
4483 .v
.verbs
= alc_gpio1_init_verbs
,
4485 [ALC880_FIXUP_GPIO2
] = {
4486 .type
= ALC_FIXUP_VERBS
,
4487 .v
.verbs
= alc_gpio2_init_verbs
,
4489 [ALC880_FIXUP_MEDION_RIM
] = {
4490 .type
= ALC_FIXUP_VERBS
,
4491 .v
.verbs
= (const struct hda_verb
[]) {
4492 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4493 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
4497 .chain_id
= ALC880_FIXUP_GPIO2
,
4499 [ALC880_FIXUP_LG
] = {
4500 .type
= ALC_FIXUP_PINS
,
4501 .v
.pins
= (const struct alc_pincfg
[]) {
4502 /* disable bogus unused pins */
4503 { 0x16, 0x411111f0 },
4504 { 0x18, 0x411111f0 },
4505 { 0x1a, 0x411111f0 },
4509 [ALC880_FIXUP_W810
] = {
4510 .type
= ALC_FIXUP_PINS
,
4511 .v
.pins
= (const struct alc_pincfg
[]) {
4512 /* disable bogus unused pins */
4513 { 0x17, 0x411111f0 },
4517 .chain_id
= ALC880_FIXUP_GPIO2
,
4519 [ALC880_FIXUP_EAPD_COEF
] = {
4520 .type
= ALC_FIXUP_VERBS
,
4521 .v
.verbs
= (const struct hda_verb
[]) {
4522 /* change to EAPD mode */
4523 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4524 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
4528 [ALC880_FIXUP_TCL_S700
] = {
4529 .type
= ALC_FIXUP_VERBS
,
4530 .v
.verbs
= (const struct hda_verb
[]) {
4531 /* change to EAPD mode */
4532 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4533 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
4537 .chain_id
= ALC880_FIXUP_GPIO2
,
4539 [ALC880_FIXUP_VOL_KNOB
] = {
4540 .type
= ALC_FIXUP_FUNC
,
4541 .v
.func
= alc880_fixup_vol_knob
,
4543 [ALC880_FIXUP_FUJITSU
] = {
4544 /* override all pins as BIOS on old Amilo is broken */
4545 .type
= ALC_FIXUP_PINS
,
4546 .v
.pins
= (const struct alc_pincfg
[]) {
4547 { 0x14, 0x0121411f }, /* HP */
4548 { 0x15, 0x99030120 }, /* speaker */
4549 { 0x16, 0x99030130 }, /* bass speaker */
4550 { 0x17, 0x411111f0 }, /* N/A */
4551 { 0x18, 0x411111f0 }, /* N/A */
4552 { 0x19, 0x01a19950 }, /* mic-in */
4553 { 0x1a, 0x411111f0 }, /* N/A */
4554 { 0x1b, 0x411111f0 }, /* N/A */
4555 { 0x1c, 0x411111f0 }, /* N/A */
4556 { 0x1d, 0x411111f0 }, /* N/A */
4557 { 0x1e, 0x01454140 }, /* SPDIF out */
4561 .chain_id
= ALC880_FIXUP_VOL_KNOB
,
4563 [ALC880_FIXUP_F1734
] = {
4564 /* almost compatible with FUJITSU, but no bass and SPDIF */
4565 .type
= ALC_FIXUP_PINS
,
4566 .v
.pins
= (const struct alc_pincfg
[]) {
4567 { 0x14, 0x0121411f }, /* HP */
4568 { 0x15, 0x99030120 }, /* speaker */
4569 { 0x16, 0x411111f0 }, /* N/A */
4570 { 0x17, 0x411111f0 }, /* N/A */
4571 { 0x18, 0x411111f0 }, /* N/A */
4572 { 0x19, 0x01a19950 }, /* mic-in */
4573 { 0x1a, 0x411111f0 }, /* N/A */
4574 { 0x1b, 0x411111f0 }, /* N/A */
4575 { 0x1c, 0x411111f0 }, /* N/A */
4576 { 0x1d, 0x411111f0 }, /* N/A */
4577 { 0x1e, 0x411111f0 }, /* N/A */
4581 .chain_id
= ALC880_FIXUP_VOL_KNOB
,
4583 [ALC880_FIXUP_UNIWILL
] = {
4584 /* need to fix HP and speaker pins to be parsed correctly */
4585 .type
= ALC_FIXUP_PINS
,
4586 .v
.pins
= (const struct alc_pincfg
[]) {
4587 { 0x14, 0x0121411f }, /* HP */
4588 { 0x15, 0x99030120 }, /* speaker */
4589 { 0x16, 0x99030130 }, /* bass speaker */
4593 [ALC880_FIXUP_UNIWILL_DIG
] = {
4594 .type
= ALC_FIXUP_PINS
,
4595 .v
.pins
= (const struct alc_pincfg
[]) {
4596 /* disable bogus unused pins */
4597 { 0x17, 0x411111f0 },
4598 { 0x19, 0x411111f0 },
4599 { 0x1b, 0x411111f0 },
4600 { 0x1f, 0x411111f0 },
4604 [ALC880_FIXUP_Z71V
] = {
4605 .type
= ALC_FIXUP_PINS
,
4606 .v
.pins
= (const struct alc_pincfg
[]) {
4607 /* set up the whole pins as BIOS is utterly broken */
4608 { 0x14, 0x99030120 }, /* speaker */
4609 { 0x15, 0x0121411f }, /* HP */
4610 { 0x16, 0x411111f0 }, /* N/A */
4611 { 0x17, 0x411111f0 }, /* N/A */
4612 { 0x18, 0x01a19950 }, /* mic-in */
4613 { 0x19, 0x411111f0 }, /* N/A */
4614 { 0x1a, 0x01813031 }, /* line-in */
4615 { 0x1b, 0x411111f0 }, /* N/A */
4616 { 0x1c, 0x411111f0 }, /* N/A */
4617 { 0x1d, 0x411111f0 }, /* N/A */
4618 { 0x1e, 0x0144111e }, /* SPDIF */
4622 [ALC880_FIXUP_3ST_BASE
] = {
4623 .type
= ALC_FIXUP_PINS
,
4624 .v
.pins
= (const struct alc_pincfg
[]) {
4625 { 0x14, 0x01014010 }, /* line-out */
4626 { 0x15, 0x411111f0 }, /* N/A */
4627 { 0x16, 0x411111f0 }, /* N/A */
4628 { 0x17, 0x411111f0 }, /* N/A */
4629 { 0x18, 0x01a19c30 }, /* mic-in */
4630 { 0x19, 0x0121411f }, /* HP */
4631 { 0x1a, 0x01813031 }, /* line-in */
4632 { 0x1b, 0x02a19c40 }, /* front-mic */
4633 { 0x1c, 0x411111f0 }, /* N/A */
4634 { 0x1d, 0x411111f0 }, /* N/A */
4635 /* 0x1e is filled in below */
4636 { 0x1f, 0x411111f0 }, /* N/A */
4640 [ALC880_FIXUP_3ST
] = {
4641 .type
= ALC_FIXUP_PINS
,
4642 .v
.pins
= (const struct alc_pincfg
[]) {
4643 { 0x1e, 0x411111f0 }, /* N/A */
4647 .chain_id
= ALC880_FIXUP_3ST_BASE
,
4649 [ALC880_FIXUP_3ST_DIG
] = {
4650 .type
= ALC_FIXUP_PINS
,
4651 .v
.pins
= (const struct alc_pincfg
[]) {
4652 { 0x1e, 0x0144111e }, /* SPDIF */
4656 .chain_id
= ALC880_FIXUP_3ST_BASE
,
4658 [ALC880_FIXUP_5ST_BASE
] = {
4659 .type
= ALC_FIXUP_PINS
,
4660 .v
.pins
= (const struct alc_pincfg
[]) {
4661 { 0x14, 0x01014010 }, /* front */
4662 { 0x15, 0x411111f0 }, /* N/A */
4663 { 0x16, 0x01011411 }, /* CLFE */
4664 { 0x17, 0x01016412 }, /* surr */
4665 { 0x18, 0x01a19c30 }, /* mic-in */
4666 { 0x19, 0x0121411f }, /* HP */
4667 { 0x1a, 0x01813031 }, /* line-in */
4668 { 0x1b, 0x02a19c40 }, /* front-mic */
4669 { 0x1c, 0x411111f0 }, /* N/A */
4670 { 0x1d, 0x411111f0 }, /* N/A */
4671 /* 0x1e is filled in below */
4672 { 0x1f, 0x411111f0 }, /* N/A */
4676 [ALC880_FIXUP_5ST
] = {
4677 .type
= ALC_FIXUP_PINS
,
4678 .v
.pins
= (const struct alc_pincfg
[]) {
4679 { 0x1e, 0x411111f0 }, /* N/A */
4683 .chain_id
= ALC880_FIXUP_5ST_BASE
,
4685 [ALC880_FIXUP_5ST_DIG
] = {
4686 .type
= ALC_FIXUP_PINS
,
4687 .v
.pins
= (const struct alc_pincfg
[]) {
4688 { 0x1e, 0x0144111e }, /* SPDIF */
4692 .chain_id
= ALC880_FIXUP_5ST_BASE
,
4694 [ALC880_FIXUP_6ST_BASE
] = {
4695 .type
= ALC_FIXUP_PINS
,
4696 .v
.pins
= (const struct alc_pincfg
[]) {
4697 { 0x14, 0x01014010 }, /* front */
4698 { 0x15, 0x01016412 }, /* surr */
4699 { 0x16, 0x01011411 }, /* CLFE */
4700 { 0x17, 0x01012414 }, /* side */
4701 { 0x18, 0x01a19c30 }, /* mic-in */
4702 { 0x19, 0x02a19c40 }, /* front-mic */
4703 { 0x1a, 0x01813031 }, /* line-in */
4704 { 0x1b, 0x0121411f }, /* HP */
4705 { 0x1c, 0x411111f0 }, /* N/A */
4706 { 0x1d, 0x411111f0 }, /* N/A */
4707 /* 0x1e is filled in below */
4708 { 0x1f, 0x411111f0 }, /* N/A */
4712 [ALC880_FIXUP_6ST
] = {
4713 .type
= ALC_FIXUP_PINS
,
4714 .v
.pins
= (const struct alc_pincfg
[]) {
4715 { 0x1e, 0x411111f0 }, /* N/A */
4719 .chain_id
= ALC880_FIXUP_6ST_BASE
,
4721 [ALC880_FIXUP_6ST_DIG
] = {
4722 .type
= ALC_FIXUP_PINS
,
4723 .v
.pins
= (const struct alc_pincfg
[]) {
4724 { 0x1e, 0x0144111e }, /* SPDIF */
4728 .chain_id
= ALC880_FIXUP_6ST_BASE
,
4732 static const struct snd_pci_quirk alc880_fixup_tbl
[] = {
4733 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810
),
4734 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V
),
4735 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1
),
4736 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2
),
4737 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF
),
4738 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG
),
4739 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734
),
4740 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL
),
4741 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB
),
4742 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810
),
4743 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM
),
4744 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734
),
4745 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU
),
4746 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734
),
4747 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU
),
4748 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG
),
4749 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG
),
4750 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG
),
4751 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700
),
4753 /* Below is the copied entries from alc880_quirks.c.
4754 * It's not quite sure whether BIOS sets the correct pin-config table
4755 * on these machines, thus they are kept to be compatible with
4756 * the old static quirks. Once when it's confirmed to work without
4757 * these overrides, it'd be better to remove.
4759 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG
),
4760 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST
),
4761 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG
),
4762 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG
),
4763 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG
),
4764 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG
),
4765 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG
),
4766 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST
),
4767 SND_PCI_QUIRK(0x1039, 0x1234, NULL
, ALC880_FIXUP_6ST_DIG
),
4768 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST
),
4769 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST
),
4770 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST
),
4771 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST
),
4772 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST
),
4773 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG
),
4774 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG
),
4775 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG
),
4776 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG
),
4777 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG
),
4778 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG
),
4779 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG
),
4780 SND_PCI_QUIRK(0x2668, 0x8086, NULL
, ALC880_FIXUP_6ST_DIG
), /* broken BIOS */
4781 SND_PCI_QUIRK(0x8086, 0x2668, NULL
, ALC880_FIXUP_6ST_DIG
),
4782 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4783 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4784 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4785 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4786 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4787 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4788 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4789 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4790 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4791 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4793 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST
),
4794 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG
),
4795 SND_PCI_QUIRK(0xe803, 0x1019, NULL
, ALC880_FIXUP_6ST_DIG
),
4799 static const struct alc_model_fixup alc880_fixup_models
[] = {
4800 {.id
= ALC880_FIXUP_3ST
, .name
= "3stack"},
4801 {.id
= ALC880_FIXUP_3ST_DIG
, .name
= "3stack-digout"},
4802 {.id
= ALC880_FIXUP_5ST
, .name
= "5stack"},
4803 {.id
= ALC880_FIXUP_5ST_DIG
, .name
= "5stack-digout"},
4804 {.id
= ALC880_FIXUP_6ST
, .name
= "6stack"},
4805 {.id
= ALC880_FIXUP_6ST_DIG
, .name
= "6stack-digout"},
4813 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4814 #define alc_board_config \
4815 snd_hda_check_board_config
4816 #define alc_board_codec_sid_config \
4817 snd_hda_check_board_codec_sid_config
4818 #include "alc_quirks.c"
4820 #define alc_board_config(codec, nums, models, tbl) -1
4821 #define alc_board_codec_sid_config(codec, nums, models, tbl) -1
4822 #define setup_preset(codec, x) /* NOP */
4826 * OK, here we have finally the patch for ALC880
4828 static int patch_alc880(struct hda_codec
*codec
)
4830 struct alc_spec
*spec
;
4833 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4839 spec
->mixer_nid
= 0x0b;
4840 spec
->need_dac_fix
= 1;
4842 alc_pick_fixup(codec
, alc880_fixup_models
, alc880_fixup_tbl
,
4844 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
4846 /* automatic parse from the BIOS config */
4847 err
= alc880_parse_auto_config(codec
);
4851 if (!spec
->no_analog
&& !spec
->adc_nids
) {
4852 alc_auto_fill_adc_caps(codec
);
4853 alc_rebuild_imux_for_auto_mic(codec
);
4854 alc_remove_invalid_adc_nids(codec
);
4857 if (!spec
->no_analog
&& !spec
->cap_mixer
)
4858 set_capture_mixer(codec
);
4860 if (!spec
->no_analog
) {
4861 err
= snd_hda_attach_beep_device(codec
, 0x1);
4864 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
4867 codec
->patch_ops
= alc_patch_ops
;
4868 spec
->init_hook
= alc_auto_init_std
;
4869 #ifdef CONFIG_SND_HDA_POWER_SAVE
4870 if (!spec
->loopback
.amplist
)
4871 spec
->loopback
.amplist
= alc880_loopbacks
;
4874 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
4887 static int alc260_parse_auto_config(struct hda_codec
*codec
)
4889 static const hda_nid_t alc260_ignore
[] = { 0x17, 0 };
4890 static const hda_nid_t alc260_ssids
[] = { 0x10, 0x15, 0x0f, 0 };
4891 return alc_parse_auto_config(codec
, alc260_ignore
, alc260_ssids
);
4894 #ifdef CONFIG_SND_HDA_POWER_SAVE
4895 static const struct hda_amp_list alc260_loopbacks
[] = {
4896 { 0x07, HDA_INPUT
, 0 },
4897 { 0x07, HDA_INPUT
, 1 },
4898 { 0x07, HDA_INPUT
, 2 },
4899 { 0x07, HDA_INPUT
, 3 },
4900 { 0x07, HDA_INPUT
, 4 },
4909 ALC260_FIXUP_HP_DC5750
,
4910 ALC260_FIXUP_HP_PIN_0F
,
4913 ALC260_FIXUP_GPIO1_TOGGLE
,
4914 ALC260_FIXUP_REPLACER
,
4915 ALC260_FIXUP_HP_B1900
,
4918 static void alc260_gpio1_automute(struct hda_codec
*codec
)
4920 struct alc_spec
*spec
= codec
->spec
;
4921 snd_hda_codec_write(codec
, 0x01, 0, AC_VERB_SET_GPIO_DATA
,
4922 spec
->hp_jack_present
);
4925 static void alc260_fixup_gpio1_toggle(struct hda_codec
*codec
,
4926 const struct alc_fixup
*fix
, int action
)
4928 struct alc_spec
*spec
= codec
->spec
;
4929 if (action
== ALC_FIXUP_ACT_PROBE
) {
4930 /* although the machine has only one output pin, we need to
4931 * toggle GPIO1 according to the jack state
4933 spec
->automute_hook
= alc260_gpio1_automute
;
4934 spec
->detect_hp
= 1;
4935 spec
->automute_speaker
= 1;
4936 spec
->autocfg
.hp_pins
[0] = 0x0f; /* copy it for automute */
4937 snd_hda_jack_detect_enable(codec
, 0x0f, ALC_HP_EVENT
);
4938 spec
->unsol_event
= alc_sku_unsol_event
;
4939 add_verb(codec
->spec
, alc_gpio1_init_verbs
);
4943 static const struct alc_fixup alc260_fixups
[] = {
4944 [ALC260_FIXUP_HP_DC5750
] = {
4945 .type
= ALC_FIXUP_PINS
,
4946 .v
.pins
= (const struct alc_pincfg
[]) {
4947 { 0x11, 0x90130110 }, /* speaker */
4951 [ALC260_FIXUP_HP_PIN_0F
] = {
4952 .type
= ALC_FIXUP_PINS
,
4953 .v
.pins
= (const struct alc_pincfg
[]) {
4954 { 0x0f, 0x01214000 }, /* HP */
4958 [ALC260_FIXUP_COEF
] = {
4959 .type
= ALC_FIXUP_VERBS
,
4960 .v
.verbs
= (const struct hda_verb
[]) {
4961 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4962 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3040 },
4966 .chain_id
= ALC260_FIXUP_HP_PIN_0F
,
4968 [ALC260_FIXUP_GPIO1
] = {
4969 .type
= ALC_FIXUP_VERBS
,
4970 .v
.verbs
= alc_gpio1_init_verbs
,
4972 [ALC260_FIXUP_GPIO1_TOGGLE
] = {
4973 .type
= ALC_FIXUP_FUNC
,
4974 .v
.func
= alc260_fixup_gpio1_toggle
,
4976 .chain_id
= ALC260_FIXUP_HP_PIN_0F
,
4978 [ALC260_FIXUP_REPLACER
] = {
4979 .type
= ALC_FIXUP_VERBS
,
4980 .v
.verbs
= (const struct hda_verb
[]) {
4981 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4982 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
4986 .chain_id
= ALC260_FIXUP_GPIO1_TOGGLE
,
4988 [ALC260_FIXUP_HP_B1900
] = {
4989 .type
= ALC_FIXUP_FUNC
,
4990 .v
.func
= alc260_fixup_gpio1_toggle
,
4992 .chain_id
= ALC260_FIXUP_COEF
,
4996 static const struct snd_pci_quirk alc260_fixup_tbl
[] = {
4997 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1
),
4998 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF
),
4999 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1
),
5000 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750
),
5001 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900
),
5002 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1
),
5003 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER
),
5004 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF
),
5010 static int patch_alc260(struct hda_codec
*codec
)
5012 struct alc_spec
*spec
;
5015 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5021 spec
->mixer_nid
= 0x07;
5023 alc_pick_fixup(codec
, NULL
, alc260_fixup_tbl
, alc260_fixups
);
5024 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5026 /* automatic parse from the BIOS config */
5027 err
= alc260_parse_auto_config(codec
);
5031 if (!spec
->no_analog
&& !spec
->adc_nids
) {
5032 alc_auto_fill_adc_caps(codec
);
5033 alc_rebuild_imux_for_auto_mic(codec
);
5034 alc_remove_invalid_adc_nids(codec
);
5037 if (!spec
->no_analog
&& !spec
->cap_mixer
)
5038 set_capture_mixer(codec
);
5040 if (!spec
->no_analog
) {
5041 err
= snd_hda_attach_beep_device(codec
, 0x1);
5044 set_beep_amp(spec
, 0x07, 0x05, HDA_INPUT
);
5047 codec
->patch_ops
= alc_patch_ops
;
5048 spec
->init_hook
= alc_auto_init_std
;
5049 spec
->shutup
= alc_eapd_shutup
;
5050 #ifdef CONFIG_SND_HDA_POWER_SAVE
5051 if (!spec
->loopback
.amplist
)
5052 spec
->loopback
.amplist
= alc260_loopbacks
;
5055 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5066 * ALC882/883/885/888/889 support
5068 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5069 * configuration. Each pin widget can choose any input DACs and a mixer.
5070 * Each ADC is connected from a mixer of all inputs. This makes possible
5071 * 6-channel independent captures.
5073 * In addition, an independent DAC for the multi-playback (not used in this
5076 #ifdef CONFIG_SND_HDA_POWER_SAVE
5077 #define alc882_loopbacks alc880_loopbacks
5084 ALC882_FIXUP_ABIT_AW9D_MAX
,
5085 ALC882_FIXUP_LENOVO_Y530
,
5086 ALC882_FIXUP_PB_M5210
,
5087 ALC882_FIXUP_ACER_ASPIRE_7736
,
5088 ALC882_FIXUP_ASUS_W90V
,
5089 ALC889_FIXUP_VAIO_TT
,
5090 ALC888_FIXUP_EEE1601
,
5093 ALC883_FIXUP_ACER_EAPD
,
5096 ALC882_FIXUP_ASUS_W2JC
,
5097 ALC882_FIXUP_ACER_ASPIRE_4930G
,
5098 ALC882_FIXUP_ACER_ASPIRE_8930G
,
5099 ALC882_FIXUP_ASPIRE_8930G_VERBS
,
5100 ALC885_FIXUP_MACPRO_GPIO
,
5101 ALC889_FIXUP_DAC_ROUTE
,
5104 static void alc889_fixup_coef(struct hda_codec
*codec
,
5105 const struct alc_fixup
*fix
, int action
)
5107 if (action
!= ALC_FIXUP_ACT_INIT
)
5109 alc889_coef_init(codec
);
5112 /* toggle speaker-output according to the hp-jack state */
5113 static void alc882_gpio_mute(struct hda_codec
*codec
, int pin
, int muted
)
5115 unsigned int gpiostate
, gpiomask
, gpiodir
;
5117 gpiostate
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5118 AC_VERB_GET_GPIO_DATA
, 0);
5121 gpiostate
|= (1 << pin
);
5123 gpiostate
&= ~(1 << pin
);
5125 gpiomask
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5126 AC_VERB_GET_GPIO_MASK
, 0);
5127 gpiomask
|= (1 << pin
);
5129 gpiodir
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5130 AC_VERB_GET_GPIO_DIRECTION
, 0);
5131 gpiodir
|= (1 << pin
);
5134 snd_hda_codec_write(codec
, codec
->afg
, 0,
5135 AC_VERB_SET_GPIO_MASK
, gpiomask
);
5136 snd_hda_codec_write(codec
, codec
->afg
, 0,
5137 AC_VERB_SET_GPIO_DIRECTION
, gpiodir
);
5141 snd_hda_codec_write(codec
, codec
->afg
, 0,
5142 AC_VERB_SET_GPIO_DATA
, gpiostate
);
5145 /* set up GPIO at initialization */
5146 static void alc885_fixup_macpro_gpio(struct hda_codec
*codec
,
5147 const struct alc_fixup
*fix
, int action
)
5149 if (action
!= ALC_FIXUP_ACT_INIT
)
5151 alc882_gpio_mute(codec
, 0, 0);
5152 alc882_gpio_mute(codec
, 1, 0);
5155 /* Fix the connection of some pins for ALC889:
5156 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
5157 * work correctly (bko#42740)
5159 static void alc889_fixup_dac_route(struct hda_codec
*codec
,
5160 const struct alc_fixup
*fix
, int action
)
5162 if (action
== ALC_FIXUP_ACT_PRE_PROBE
) {
5163 hda_nid_t conn1
[2] = { 0x0c, 0x0d };
5164 hda_nid_t conn2
[2] = { 0x0e, 0x0f };
5165 snd_hda_override_conn_list(codec
, 0x14, 2, conn1
);
5166 snd_hda_override_conn_list(codec
, 0x15, 2, conn1
);
5167 snd_hda_override_conn_list(codec
, 0x18, 2, conn2
);
5168 snd_hda_override_conn_list(codec
, 0x1a, 2, conn2
);
5172 static const struct alc_fixup alc882_fixups
[] = {
5173 [ALC882_FIXUP_ABIT_AW9D_MAX
] = {
5174 .type
= ALC_FIXUP_PINS
,
5175 .v
.pins
= (const struct alc_pincfg
[]) {
5176 { 0x15, 0x01080104 }, /* side */
5177 { 0x16, 0x01011012 }, /* rear */
5178 { 0x17, 0x01016011 }, /* clfe */
5182 [ALC882_FIXUP_LENOVO_Y530
] = {
5183 .type
= ALC_FIXUP_PINS
,
5184 .v
.pins
= (const struct alc_pincfg
[]) {
5185 { 0x15, 0x99130112 }, /* rear int speakers */
5186 { 0x16, 0x99130111 }, /* subwoofer */
5190 [ALC882_FIXUP_PB_M5210
] = {
5191 .type
= ALC_FIXUP_VERBS
,
5192 .v
.verbs
= (const struct hda_verb
[]) {
5193 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF50
},
5197 [ALC882_FIXUP_ACER_ASPIRE_7736
] = {
5198 .type
= ALC_FIXUP_SKU
,
5199 .v
.sku
= ALC_FIXUP_SKU_IGNORE
,
5201 [ALC882_FIXUP_ASUS_W90V
] = {
5202 .type
= ALC_FIXUP_PINS
,
5203 .v
.pins
= (const struct alc_pincfg
[]) {
5204 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
5208 [ALC889_FIXUP_VAIO_TT
] = {
5209 .type
= ALC_FIXUP_PINS
,
5210 .v
.pins
= (const struct alc_pincfg
[]) {
5211 { 0x17, 0x90170111 }, /* hidden surround speaker */
5215 [ALC888_FIXUP_EEE1601
] = {
5216 .type
= ALC_FIXUP_VERBS
,
5217 .v
.verbs
= (const struct hda_verb
[]) {
5218 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x0b },
5219 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0838 },
5223 [ALC882_FIXUP_EAPD
] = {
5224 .type
= ALC_FIXUP_VERBS
,
5225 .v
.verbs
= (const struct hda_verb
[]) {
5226 /* change to EAPD mode */
5227 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5228 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
5232 [ALC883_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
, 0x3070 },
5241 [ALC883_FIXUP_ACER_EAPD
] = {
5242 .type
= ALC_FIXUP_VERBS
,
5243 .v
.verbs
= (const struct hda_verb
[]) {
5244 /* eanable EAPD on Acer laptops */
5245 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5246 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5250 [ALC882_FIXUP_GPIO3
] = {
5251 .type
= ALC_FIXUP_VERBS
,
5252 .v
.verbs
= alc_gpio3_init_verbs
,
5254 [ALC882_FIXUP_ASUS_W2JC
] = {
5255 .type
= ALC_FIXUP_VERBS
,
5256 .v
.verbs
= alc_gpio1_init_verbs
,
5258 .chain_id
= ALC882_FIXUP_EAPD
,
5260 [ALC889_FIXUP_COEF
] = {
5261 .type
= ALC_FIXUP_FUNC
,
5262 .v
.func
= alc889_fixup_coef
,
5264 [ALC882_FIXUP_ACER_ASPIRE_4930G
] = {
5265 .type
= ALC_FIXUP_PINS
,
5266 .v
.pins
= (const struct alc_pincfg
[]) {
5267 { 0x16, 0x99130111 }, /* CLFE speaker */
5268 { 0x17, 0x99130112 }, /* surround speaker */
5272 [ALC882_FIXUP_ACER_ASPIRE_8930G
] = {
5273 .type
= ALC_FIXUP_PINS
,
5274 .v
.pins
= (const struct alc_pincfg
[]) {
5275 { 0x16, 0x99130111 }, /* CLFE speaker */
5276 { 0x1b, 0x99130112 }, /* surround speaker */
5280 .chain_id
= ALC882_FIXUP_ASPIRE_8930G_VERBS
,
5282 [ALC882_FIXUP_ASPIRE_8930G_VERBS
] = {
5283 /* additional init verbs for Acer Aspire 8930G */
5284 .type
= ALC_FIXUP_VERBS
,
5285 .v
.verbs
= (const struct hda_verb
[]) {
5286 /* Enable all DACs */
5287 /* DAC DISABLE/MUTE 1? */
5288 /* setting bits 1-5 disables DAC nids 0x02-0x06
5289 * apparently. Init=0x38 */
5290 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x03 },
5291 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0000 },
5292 /* DAC DISABLE/MUTE 2? */
5293 /* some bit here disables the other DACs.
5295 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x08 },
5296 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0000 },
5298 * This laptop has a stereo digital microphone.
5299 * The mics are only 1cm apart which makes the stereo
5300 * useless. However, either the mic or the ALC889
5301 * makes the signal become a difference/sum signal
5302 * instead of standard stereo, which is annoying.
5303 * So instead we flip this bit which makes the
5304 * codec replicate the sum signal to both channels,
5305 * turning it into a normal mono mic.
5307 /* DMIC_CONTROL? Init value = 0x0001 */
5308 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x0b },
5309 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0003 },
5310 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5311 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5315 [ALC885_FIXUP_MACPRO_GPIO
] = {
5316 .type
= ALC_FIXUP_FUNC
,
5317 .v
.func
= alc885_fixup_macpro_gpio
,
5319 [ALC889_FIXUP_DAC_ROUTE
] = {
5320 .type
= ALC_FIXUP_FUNC
,
5321 .v
.func
= alc889_fixup_dac_route
,
5325 static const struct snd_pci_quirk alc882_fixup_tbl
[] = {
5326 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD
),
5327 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD
),
5328 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD
),
5329 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD
),
5330 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD
),
5331 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD
),
5332 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
5333 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5334 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
5335 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5336 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
5337 ALC882_FIXUP_ACER_ASPIRE_8930G
),
5338 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
5339 ALC882_FIXUP_ACER_ASPIRE_8930G
),
5340 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
5341 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5342 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
5343 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5344 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
5345 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5346 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210
),
5347 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE
),
5348 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736
),
5349 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD
),
5350 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V
),
5351 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC
),
5352 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601
),
5353 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT
),
5355 /* All Apple entries are in codec SSIDs */
5356 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO
),
5357 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO
),
5358 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO
),
5359 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD
),
5360 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO
),
5362 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD
),
5363 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3
),
5364 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX
),
5365 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD
),
5366 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD
),
5367 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530
),
5368 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF
),
5373 * BIOS auto configuration
5375 /* almost identical with ALC880 parser... */
5376 static int alc882_parse_auto_config(struct hda_codec
*codec
)
5378 static const hda_nid_t alc882_ignore
[] = { 0x1d, 0 };
5379 static const hda_nid_t alc882_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5380 return alc_parse_auto_config(codec
, alc882_ignore
, alc882_ssids
);
5385 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
5386 #include "alc882_quirks.c"
5389 static int patch_alc882(struct hda_codec
*codec
)
5391 struct alc_spec
*spec
;
5392 int err
, board_config
;
5394 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5400 spec
->mixer_nid
= 0x0b;
5402 switch (codec
->vendor_id
) {
5407 /* ALC883 and variants */
5408 alc_fix_pll_init(codec
, 0x20, 0x0a, 10);
5412 err
= alc_codec_rename_from_preset(codec
);
5416 board_config
= alc_board_config(codec
, ALC882_MODEL_LAST
,
5417 alc882_models
, NULL
);
5418 if (board_config
< 0)
5419 board_config
= alc_board_codec_sid_config(codec
,
5420 ALC882_MODEL_LAST
, alc882_models
, alc882_ssid_cfg_tbl
);
5422 if (board_config
< 0) {
5423 printk(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
5425 board_config
= ALC_MODEL_AUTO
;
5428 if (board_config
== ALC_MODEL_AUTO
) {
5429 alc_pick_fixup(codec
, NULL
, alc882_fixup_tbl
, alc882_fixups
);
5430 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5433 alc_auto_parse_customize_define(codec
);
5435 if (board_config
== ALC_MODEL_AUTO
) {
5436 /* automatic parse from the BIOS config */
5437 err
= alc882_parse_auto_config(codec
);
5442 if (board_config
!= ALC_MODEL_AUTO
) {
5443 setup_preset(codec
, &alc882_presets
[board_config
]);
5444 spec
->vmaster_nid
= 0x0c;
5447 if (!spec
->no_analog
&& !spec
->adc_nids
) {
5448 alc_auto_fill_adc_caps(codec
);
5449 alc_rebuild_imux_for_auto_mic(codec
);
5450 alc_remove_invalid_adc_nids(codec
);
5453 if (!spec
->no_analog
&& !spec
->cap_mixer
)
5454 set_capture_mixer(codec
);
5456 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
5457 err
= snd_hda_attach_beep_device(codec
, 0x1);
5460 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
5463 codec
->patch_ops
= alc_patch_ops
;
5464 if (board_config
== ALC_MODEL_AUTO
)
5465 spec
->init_hook
= alc_auto_init_std
;
5467 codec
->patch_ops
.build_controls
= __alc_build_controls
;
5469 #ifdef CONFIG_SND_HDA_POWER_SAVE
5470 if (!spec
->loopback
.amplist
)
5471 spec
->loopback
.amplist
= alc882_loopbacks
;
5474 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5487 static int alc262_parse_auto_config(struct hda_codec
*codec
)
5489 static const hda_nid_t alc262_ignore
[] = { 0x1d, 0 };
5490 static const hda_nid_t alc262_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5491 return alc_parse_auto_config(codec
, alc262_ignore
, alc262_ssids
);
5498 ALC262_FIXUP_FSC_H270
,
5499 ALC262_FIXUP_HP_Z200
,
5501 ALC262_FIXUP_LENOVO_3000
,
5503 ALC262_FIXUP_BENQ_T31
,
5506 static const struct alc_fixup alc262_fixups
[] = {
5507 [ALC262_FIXUP_FSC_H270
] = {
5508 .type
= ALC_FIXUP_PINS
,
5509 .v
.pins
= (const struct alc_pincfg
[]) {
5510 { 0x14, 0x99130110 }, /* speaker */
5511 { 0x15, 0x0221142f }, /* front HP */
5512 { 0x1b, 0x0121141f }, /* rear HP */
5516 [ALC262_FIXUP_HP_Z200
] = {
5517 .type
= ALC_FIXUP_PINS
,
5518 .v
.pins
= (const struct alc_pincfg
[]) {
5519 { 0x16, 0x99130120 }, /* internal speaker */
5523 [ALC262_FIXUP_TYAN
] = {
5524 .type
= ALC_FIXUP_PINS
,
5525 .v
.pins
= (const struct alc_pincfg
[]) {
5526 { 0x14, 0x1993e1f0 }, /* int AUX */
5530 [ALC262_FIXUP_LENOVO_3000
] = {
5531 .type
= ALC_FIXUP_VERBS
,
5532 .v
.verbs
= (const struct hda_verb
[]) {
5533 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF50
},
5537 .chain_id
= ALC262_FIXUP_BENQ
,
5539 [ALC262_FIXUP_BENQ
] = {
5540 .type
= ALC_FIXUP_VERBS
,
5541 .v
.verbs
= (const struct hda_verb
[]) {
5542 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5543 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
5547 [ALC262_FIXUP_BENQ_T31
] = {
5548 .type
= ALC_FIXUP_VERBS
,
5549 .v
.verbs
= (const struct hda_verb
[]) {
5550 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5551 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5557 static const struct snd_pci_quirk alc262_fixup_tbl
[] = {
5558 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200
),
5559 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ
),
5560 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ
),
5561 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN
),
5562 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270
),
5563 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000
),
5564 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ
),
5565 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31
),
5570 #ifdef CONFIG_SND_HDA_POWER_SAVE
5571 #define alc262_loopbacks alc880_loopbacks
5576 static int patch_alc262(struct hda_codec
*codec
)
5578 struct alc_spec
*spec
;
5581 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5587 spec
->mixer_nid
= 0x0b;
5590 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
5595 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
5596 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
5597 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
5598 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PROC_COEF
, tmp
| 0x80);
5601 alc_auto_parse_customize_define(codec
);
5603 alc_fix_pll_init(codec
, 0x20, 0x0a, 10);
5605 alc_pick_fixup(codec
, NULL
, alc262_fixup_tbl
, alc262_fixups
);
5606 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5608 /* automatic parse from the BIOS config */
5609 err
= alc262_parse_auto_config(codec
);
5613 if (!spec
->no_analog
&& !spec
->adc_nids
) {
5614 alc_auto_fill_adc_caps(codec
);
5615 alc_rebuild_imux_for_auto_mic(codec
);
5616 alc_remove_invalid_adc_nids(codec
);
5619 if (!spec
->no_analog
&& !spec
->cap_mixer
)
5620 set_capture_mixer(codec
);
5622 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
5623 err
= snd_hda_attach_beep_device(codec
, 0x1);
5626 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
5629 codec
->patch_ops
= alc_patch_ops
;
5630 spec
->init_hook
= alc_auto_init_std
;
5631 spec
->shutup
= alc_eapd_shutup
;
5633 #ifdef CONFIG_SND_HDA_POWER_SAVE
5634 if (!spec
->loopback
.amplist
)
5635 spec
->loopback
.amplist
= alc262_loopbacks
;
5638 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5650 /* bind Beep switches of both NID 0x0f and 0x10 */
5651 static const struct hda_bind_ctls alc268_bind_beep_sw
= {
5652 .ops
= &snd_hda_bind_sw
,
5654 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT
),
5655 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT
),
5660 static const struct snd_kcontrol_new alc268_beep_mixer
[] = {
5661 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT
),
5662 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw
),
5666 /* set PCBEEP vol = 0, mute connections */
5667 static const struct hda_verb alc268_beep_init_verbs
[] = {
5668 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5669 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5670 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5675 * BIOS auto configuration
5677 static int alc268_parse_auto_config(struct hda_codec
*codec
)
5679 static const hda_nid_t alc268_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5680 struct alc_spec
*spec
= codec
->spec
;
5681 int err
= alc_parse_auto_config(codec
, NULL
, alc268_ssids
);
5683 if (!spec
->no_analog
&& spec
->autocfg
.speaker_pins
[0] != 0x1d) {
5684 add_mixer(spec
, alc268_beep_mixer
);
5685 add_verb(spec
, alc268_beep_init_verbs
);
5693 static int patch_alc268(struct hda_codec
*codec
)
5695 struct alc_spec
*spec
;
5696 int i
, has_beep
, err
;
5698 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5704 /* ALC268 has no aa-loopback mixer */
5706 /* automatic parse from the BIOS config */
5707 err
= alc268_parse_auto_config(codec
);
5712 for (i
= 0; i
< spec
->num_mixers
; i
++) {
5713 if (spec
->mixers
[i
] == alc268_beep_mixer
) {
5720 err
= snd_hda_attach_beep_device(codec
, 0x1);
5723 if (!query_amp_caps(codec
, 0x1d, HDA_INPUT
))
5724 /* override the amp caps for beep generator */
5725 snd_hda_override_amp_caps(codec
, 0x1d, HDA_INPUT
,
5726 (0x0c << AC_AMPCAP_OFFSET_SHIFT
) |
5727 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT
) |
5728 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
5729 (0 << AC_AMPCAP_MUTE_SHIFT
));
5732 if (!spec
->no_analog
&& !spec
->adc_nids
) {
5733 alc_auto_fill_adc_caps(codec
);
5734 alc_rebuild_imux_for_auto_mic(codec
);
5735 alc_remove_invalid_adc_nids(codec
);
5738 if (!spec
->no_analog
&& !spec
->cap_mixer
)
5739 set_capture_mixer(codec
);
5741 codec
->patch_ops
= alc_patch_ops
;
5742 spec
->init_hook
= alc_auto_init_std
;
5743 spec
->shutup
= alc_eapd_shutup
;
5755 #ifdef CONFIG_SND_HDA_POWER_SAVE
5756 #define alc269_loopbacks alc880_loopbacks
5759 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback
= {
5763 .rates
= SNDRV_PCM_RATE_44100
, /* fixed rate */
5764 /* NID is set in alc_build_pcms */
5766 .open
= alc_playback_pcm_open
,
5767 .prepare
= alc_playback_pcm_prepare
,
5768 .cleanup
= alc_playback_pcm_cleanup
5772 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture
= {
5776 .rates
= SNDRV_PCM_RATE_44100
, /* fixed rate */
5777 /* NID is set in alc_build_pcms */
5780 #ifdef CONFIG_SND_HDA_POWER_SAVE
5781 static int alc269_mic2_for_mute_led(struct hda_codec
*codec
)
5783 switch (codec
->subsystem_id
) {
5790 static int alc269_mic2_mute_check_ps(struct hda_codec
*codec
, hda_nid_t nid
)
5792 /* update mute-LED according to the speaker mute state */
5793 if (nid
== 0x01 || nid
== 0x14) {
5795 if (snd_hda_codec_amp_read(codec
, 0x14, 0, HDA_OUTPUT
, 0) &
5800 /* mic2 vref pin is used for mute LED control */
5801 snd_hda_codec_update_cache(codec
, 0x19, 0,
5802 AC_VERB_SET_PIN_WIDGET_CONTROL
,
5805 return alc_check_power_status(codec
, nid
);
5807 #endif /* CONFIG_SND_HDA_POWER_SAVE */
5809 /* different alc269-variants */
5811 ALC269_TYPE_ALC269VA
,
5812 ALC269_TYPE_ALC269VB
,
5813 ALC269_TYPE_ALC269VC
,
5817 * BIOS auto configuration
5819 static int alc269_parse_auto_config(struct hda_codec
*codec
)
5821 static const hda_nid_t alc269_ignore
[] = { 0x1d, 0 };
5822 static const hda_nid_t alc269_ssids
[] = { 0, 0x1b, 0x14, 0x21 };
5823 static const hda_nid_t alc269va_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5824 struct alc_spec
*spec
= codec
->spec
;
5825 const hda_nid_t
*ssids
= spec
->codec_variant
== ALC269_TYPE_ALC269VA
?
5826 alc269va_ssids
: alc269_ssids
;
5828 return alc_parse_auto_config(codec
, alc269_ignore
, ssids
);
5831 static void alc269_toggle_power_output(struct hda_codec
*codec
, int power_up
)
5833 int val
= alc_read_coef_idx(codec
, 0x04);
5838 alc_write_coef_idx(codec
, 0x04, val
);
5841 static void alc269_shutup(struct hda_codec
*codec
)
5843 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017)
5844 alc269_toggle_power_output(codec
, 0);
5845 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
5846 alc269_toggle_power_output(codec
, 0);
5852 static int alc269_resume(struct hda_codec
*codec
)
5854 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
5855 alc269_toggle_power_output(codec
, 0);
5859 codec
->patch_ops
.init(codec
);
5861 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017) {
5862 alc269_toggle_power_output(codec
, 1);
5866 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018)
5867 alc269_toggle_power_output(codec
, 1);
5869 snd_hda_codec_resume_amp(codec
);
5870 snd_hda_codec_resume_cache(codec
);
5871 hda_call_check_power_status(codec
, 0x01);
5874 #endif /* CONFIG_PM */
5876 static void alc269_fixup_hweq(struct hda_codec
*codec
,
5877 const struct alc_fixup
*fix
, int action
)
5881 if (action
!= ALC_FIXUP_ACT_INIT
)
5883 coef
= alc_read_coef_idx(codec
, 0x1e);
5884 alc_write_coef_idx(codec
, 0x1e, coef
| 0x80);
5887 static void alc271_fixup_dmic(struct hda_codec
*codec
,
5888 const struct alc_fixup
*fix
, int action
)
5890 static const struct hda_verb verbs
[] = {
5891 {0x20, AC_VERB_SET_COEF_INDEX
, 0x0d},
5892 {0x20, AC_VERB_SET_PROC_COEF
, 0x4000},
5897 if (strcmp(codec
->chip_name
, "ALC271X"))
5899 cfg
= snd_hda_codec_get_pincfg(codec
, 0x12);
5900 if (get_defcfg_connect(cfg
) == AC_JACK_PORT_FIXED
)
5901 snd_hda_sequence_write(codec
, verbs
);
5904 static void alc269_fixup_pcm_44k(struct hda_codec
*codec
,
5905 const struct alc_fixup
*fix
, int action
)
5907 struct alc_spec
*spec
= codec
->spec
;
5909 if (action
!= ALC_FIXUP_ACT_PROBE
)
5912 /* Due to a hardware problem on Lenovo Ideadpad, we need to
5913 * fix the sample rate of analog I/O to 44.1kHz
5915 spec
->stream_analog_playback
= &alc269_44k_pcm_analog_playback
;
5916 spec
->stream_analog_capture
= &alc269_44k_pcm_analog_capture
;
5919 static void alc269_fixup_stereo_dmic(struct hda_codec
*codec
,
5920 const struct alc_fixup
*fix
, int action
)
5924 if (action
!= ALC_FIXUP_ACT_INIT
)
5926 /* The digital-mic unit sends PDM (differential signal) instead of
5927 * the standard PCM, thus you can't record a valid mono stream as is.
5928 * Below is a workaround specific to ALC269 to control the dmic
5929 * signal source as mono.
5931 coef
= alc_read_coef_idx(codec
, 0x07);
5932 alc_write_coef_idx(codec
, 0x07, coef
| 0x80);
5935 static void alc269_quanta_automute(struct hda_codec
*codec
)
5937 update_outputs(codec
);
5939 snd_hda_codec_write(codec
, 0x20, 0,
5940 AC_VERB_SET_COEF_INDEX
, 0x0c);
5941 snd_hda_codec_write(codec
, 0x20, 0,
5942 AC_VERB_SET_PROC_COEF
, 0x680);
5944 snd_hda_codec_write(codec
, 0x20, 0,
5945 AC_VERB_SET_COEF_INDEX
, 0x0c);
5946 snd_hda_codec_write(codec
, 0x20, 0,
5947 AC_VERB_SET_PROC_COEF
, 0x480);
5950 static void alc269_fixup_quanta_mute(struct hda_codec
*codec
,
5951 const struct alc_fixup
*fix
, int action
)
5953 struct alc_spec
*spec
= codec
->spec
;
5954 if (action
!= ALC_FIXUP_ACT_PROBE
)
5956 spec
->automute_hook
= alc269_quanta_automute
;
5960 ALC269_FIXUP_SONY_VAIO
,
5961 ALC275_FIXUP_SONY_VAIO_GPIO2
,
5962 ALC269_FIXUP_DELL_M101Z
,
5963 ALC269_FIXUP_SKU_IGNORE
,
5964 ALC269_FIXUP_ASUS_G73JW
,
5965 ALC269_FIXUP_LENOVO_EAPD
,
5966 ALC275_FIXUP_SONY_HWEQ
,
5968 ALC269_FIXUP_PCM_44K
,
5969 ALC269_FIXUP_STEREO_DMIC
,
5970 ALC269_FIXUP_QUANTA_MUTE
,
5971 ALC269_FIXUP_LIFEBOOK
,
5974 ALC269VB_FIXUP_AMIC
,
5975 ALC269VB_FIXUP_DMIC
,
5978 static const struct alc_fixup alc269_fixups
[] = {
5979 [ALC269_FIXUP_SONY_VAIO
] = {
5980 .type
= ALC_FIXUP_VERBS
,
5981 .v
.verbs
= (const struct hda_verb
[]) {
5982 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREFGRD
},
5986 [ALC275_FIXUP_SONY_VAIO_GPIO2
] = {
5987 .type
= ALC_FIXUP_VERBS
,
5988 .v
.verbs
= (const struct hda_verb
[]) {
5989 {0x01, AC_VERB_SET_GPIO_MASK
, 0x04},
5990 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x04},
5991 {0x01, AC_VERB_SET_GPIO_DATA
, 0x00},
5995 .chain_id
= ALC269_FIXUP_SONY_VAIO
5997 [ALC269_FIXUP_DELL_M101Z
] = {
5998 .type
= ALC_FIXUP_VERBS
,
5999 .v
.verbs
= (const struct hda_verb
[]) {
6000 /* Enables internal speaker */
6001 {0x20, AC_VERB_SET_COEF_INDEX
, 13},
6002 {0x20, AC_VERB_SET_PROC_COEF
, 0x4040},
6006 [ALC269_FIXUP_SKU_IGNORE
] = {
6007 .type
= ALC_FIXUP_SKU
,
6008 .v
.sku
= ALC_FIXUP_SKU_IGNORE
,
6010 [ALC269_FIXUP_ASUS_G73JW
] = {
6011 .type
= ALC_FIXUP_PINS
,
6012 .v
.pins
= (const struct alc_pincfg
[]) {
6013 { 0x17, 0x99130111 }, /* subwoofer */
6017 [ALC269_FIXUP_LENOVO_EAPD
] = {
6018 .type
= ALC_FIXUP_VERBS
,
6019 .v
.verbs
= (const struct hda_verb
[]) {
6020 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 0},
6024 [ALC275_FIXUP_SONY_HWEQ
] = {
6025 .type
= ALC_FIXUP_FUNC
,
6026 .v
.func
= alc269_fixup_hweq
,
6028 .chain_id
= ALC275_FIXUP_SONY_VAIO_GPIO2
6030 [ALC271_FIXUP_DMIC
] = {
6031 .type
= ALC_FIXUP_FUNC
,
6032 .v
.func
= alc271_fixup_dmic
,
6034 [ALC269_FIXUP_PCM_44K
] = {
6035 .type
= ALC_FIXUP_FUNC
,
6036 .v
.func
= alc269_fixup_pcm_44k
,
6038 [ALC269_FIXUP_STEREO_DMIC
] = {
6039 .type
= ALC_FIXUP_FUNC
,
6040 .v
.func
= alc269_fixup_stereo_dmic
,
6042 [ALC269_FIXUP_QUANTA_MUTE
] = {
6043 .type
= ALC_FIXUP_FUNC
,
6044 .v
.func
= alc269_fixup_quanta_mute
,
6046 [ALC269_FIXUP_LIFEBOOK
] = {
6047 .type
= ALC_FIXUP_PINS
,
6048 .v
.pins
= (const struct alc_pincfg
[]) {
6049 { 0x1a, 0x2101103f }, /* dock line-out */
6050 { 0x1b, 0x23a11040 }, /* dock mic-in */
6054 .chain_id
= ALC269_FIXUP_QUANTA_MUTE
6056 [ALC269_FIXUP_AMIC
] = {
6057 .type
= ALC_FIXUP_PINS
,
6058 .v
.pins
= (const struct alc_pincfg
[]) {
6059 { 0x14, 0x99130110 }, /* speaker */
6060 { 0x15, 0x0121401f }, /* HP out */
6061 { 0x18, 0x01a19c20 }, /* mic */
6062 { 0x19, 0x99a3092f }, /* int-mic */
6066 [ALC269_FIXUP_DMIC
] = {
6067 .type
= ALC_FIXUP_PINS
,
6068 .v
.pins
= (const struct alc_pincfg
[]) {
6069 { 0x12, 0x99a3092f }, /* int-mic */
6070 { 0x14, 0x99130110 }, /* speaker */
6071 { 0x15, 0x0121401f }, /* HP out */
6072 { 0x18, 0x01a19c20 }, /* mic */
6076 [ALC269VB_FIXUP_AMIC
] = {
6077 .type
= ALC_FIXUP_PINS
,
6078 .v
.pins
= (const struct alc_pincfg
[]) {
6079 { 0x14, 0x99130110 }, /* speaker */
6080 { 0x18, 0x01a19c20 }, /* mic */
6081 { 0x19, 0x99a3092f }, /* int-mic */
6082 { 0x21, 0x0121401f }, /* HP out */
6086 [ALC269VB_FIXUP_DMIC
] = {
6087 .type
= ALC_FIXUP_PINS
,
6088 .v
.pins
= (const struct alc_pincfg
[]) {
6089 { 0x12, 0x99a3092f }, /* int-mic */
6090 { 0x14, 0x99130110 }, /* speaker */
6091 { 0x18, 0x01a19c20 }, /* mic */
6092 { 0x21, 0x0121401f }, /* HP out */
6098 static const struct snd_pci_quirk alc269_fixup_tbl
[] = {
6099 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW
),
6100 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC
),
6101 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC
),
6102 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC
),
6103 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC
),
6104 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC
),
6105 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2
),
6106 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ
),
6107 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ
),
6108 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO
),
6109 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z
),
6110 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC
),
6111 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK
),
6112 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE
),
6113 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE
),
6114 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE
),
6115 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE
),
6116 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE
),
6117 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE
),
6118 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K
),
6119 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD
),
6122 /* Below is a quirk table taken from the old code.
6123 * Basically the device should work as is without the fixup table.
6124 * If BIOS doesn't give a proper info, enable the corresponding
6127 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
6129 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC
),
6130 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC
),
6131 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC
),
6132 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC
),
6133 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC
),
6134 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC
),
6135 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC
),
6136 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC
),
6137 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC
),
6138 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC
),
6139 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC
),
6140 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC
),
6141 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC
),
6142 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC
),
6143 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC
),
6144 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC
),
6145 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC
),
6146 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC
),
6147 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC
),
6148 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC
),
6149 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC
),
6150 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC
),
6151 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC
),
6152 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC
),
6153 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC
),
6154 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC
),
6155 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC
),
6156 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC
),
6157 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC
),
6158 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC
),
6159 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC
),
6160 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC
),
6161 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC
),
6162 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC
),
6163 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC
),
6164 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC
),
6165 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC
),
6166 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC
),
6167 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC
),
6172 static const struct alc_model_fixup alc269_fixup_models
[] = {
6173 {.id
= ALC269_FIXUP_AMIC
, .name
= "laptop-amic"},
6174 {.id
= ALC269_FIXUP_DMIC
, .name
= "laptop-dmic"},
6179 static int alc269_fill_coef(struct hda_codec
*codec
)
6183 if ((alc_get_coef0(codec
) & 0x00ff) < 0x015) {
6184 alc_write_coef_idx(codec
, 0xf, 0x960b);
6185 alc_write_coef_idx(codec
, 0xe, 0x8817);
6188 if ((alc_get_coef0(codec
) & 0x00ff) == 0x016) {
6189 alc_write_coef_idx(codec
, 0xf, 0x960b);
6190 alc_write_coef_idx(codec
, 0xe, 0x8814);
6193 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017) {
6194 val
= alc_read_coef_idx(codec
, 0x04);
6195 /* Power up output pin */
6196 alc_write_coef_idx(codec
, 0x04, val
| (1<<11));
6199 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
6200 val
= alc_read_coef_idx(codec
, 0xd);
6201 if ((val
& 0x0c00) >> 10 != 0x1) {
6202 /* Capless ramp up clock control */
6203 alc_write_coef_idx(codec
, 0xd, val
| (1<<10));
6205 val
= alc_read_coef_idx(codec
, 0x17);
6206 if ((val
& 0x01c0) >> 6 != 0x4) {
6207 /* Class D power on reset */
6208 alc_write_coef_idx(codec
, 0x17, val
| (1<<7));
6212 val
= alc_read_coef_idx(codec
, 0xd); /* Class D */
6213 alc_write_coef_idx(codec
, 0xd, val
| (1<<14));
6215 val
= alc_read_coef_idx(codec
, 0x4); /* HP */
6216 alc_write_coef_idx(codec
, 0x4, val
| (1<<11));
6223 static int patch_alc269(struct hda_codec
*codec
)
6225 struct alc_spec
*spec
;
6228 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
6234 spec
->mixer_nid
= 0x0b;
6236 alc_auto_parse_customize_define(codec
);
6238 err
= alc_codec_rename_from_preset(codec
);
6242 if (codec
->vendor_id
== 0x10ec0269) {
6243 spec
->codec_variant
= ALC269_TYPE_ALC269VA
;
6244 switch (alc_get_coef0(codec
) & 0x00f0) {
6246 if (codec
->bus
->pci
->subsystem_vendor
== 0x1025 &&
6247 spec
->cdefine
.platform_type
== 1)
6248 err
= alc_codec_rename(codec
, "ALC271X");
6249 spec
->codec_variant
= ALC269_TYPE_ALC269VB
;
6252 if (codec
->bus
->pci
->subsystem_vendor
== 0x17aa &&
6253 codec
->bus
->pci
->subsystem_device
== 0x21f3)
6254 err
= alc_codec_rename(codec
, "ALC3202");
6255 spec
->codec_variant
= ALC269_TYPE_ALC269VC
;
6258 alc_fix_pll_init(codec
, 0x20, 0x04, 15);
6262 alc269_fill_coef(codec
);
6265 alc_pick_fixup(codec
, alc269_fixup_models
,
6266 alc269_fixup_tbl
, alc269_fixups
);
6267 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6269 /* automatic parse from the BIOS config */
6270 err
= alc269_parse_auto_config(codec
);
6274 if (!spec
->no_analog
&& !spec
->adc_nids
) {
6275 alc_auto_fill_adc_caps(codec
);
6276 alc_rebuild_imux_for_auto_mic(codec
);
6277 alc_remove_invalid_adc_nids(codec
);
6280 if (!spec
->no_analog
&& !spec
->cap_mixer
)
6281 set_capture_mixer(codec
);
6283 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
6284 err
= snd_hda_attach_beep_device(codec
, 0x1);
6287 set_beep_amp(spec
, 0x0b, 0x04, HDA_INPUT
);
6290 codec
->patch_ops
= alc_patch_ops
;
6292 codec
->patch_ops
.resume
= alc269_resume
;
6294 spec
->init_hook
= alc_auto_init_std
;
6295 spec
->shutup
= alc269_shutup
;
6297 #ifdef CONFIG_SND_HDA_POWER_SAVE
6298 if (!spec
->loopback
.amplist
)
6299 spec
->loopback
.amplist
= alc269_loopbacks
;
6300 if (alc269_mic2_for_mute_led(codec
))
6301 codec
->patch_ops
.check_power_status
= alc269_mic2_mute_check_ps
;
6304 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6317 static int alc861_parse_auto_config(struct hda_codec
*codec
)
6319 static const hda_nid_t alc861_ignore
[] = { 0x1d, 0 };
6320 static const hda_nid_t alc861_ssids
[] = { 0x0e, 0x0f, 0x0b, 0 };
6321 return alc_parse_auto_config(codec
, alc861_ignore
, alc861_ssids
);
6324 #ifdef CONFIG_SND_HDA_POWER_SAVE
6325 static const struct hda_amp_list alc861_loopbacks
[] = {
6326 { 0x15, HDA_INPUT
, 0 },
6327 { 0x15, HDA_INPUT
, 1 },
6328 { 0x15, HDA_INPUT
, 2 },
6329 { 0x15, HDA_INPUT
, 3 },
6335 /* Pin config fixes */
6337 ALC861_FIXUP_FSC_AMILO_PI1505
,
6338 ALC861_FIXUP_AMP_VREF_0F
,
6339 ALC861_FIXUP_NO_JACK_DETECT
,
6340 ALC861_FIXUP_ASUS_A6RP
,
6343 /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
6344 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec
*codec
,
6345 const struct alc_fixup
*fix
, int action
)
6347 struct alc_spec
*spec
= codec
->spec
;
6350 if (action
!= ALC_FIXUP_ACT_INIT
)
6352 val
= snd_hda_codec_read(codec
, 0x0f, 0,
6353 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
6354 if (!(val
& (AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
)))
6355 val
|= AC_PINCTL_IN_EN
;
6356 val
|= AC_PINCTL_VREF_50
;
6357 snd_hda_codec_write(codec
, 0x0f, 0,
6358 AC_VERB_SET_PIN_WIDGET_CONTROL
, val
);
6359 spec
->keep_vref_in_automute
= 1;
6362 /* suppress the jack-detection */
6363 static void alc_fixup_no_jack_detect(struct hda_codec
*codec
,
6364 const struct alc_fixup
*fix
, int action
)
6366 if (action
== ALC_FIXUP_ACT_PRE_PROBE
)
6367 codec
->no_jack_detect
= 1;
6370 static const struct alc_fixup alc861_fixups
[] = {
6371 [ALC861_FIXUP_FSC_AMILO_PI1505
] = {
6372 .type
= ALC_FIXUP_PINS
,
6373 .v
.pins
= (const struct alc_pincfg
[]) {
6374 { 0x0b, 0x0221101f }, /* HP */
6375 { 0x0f, 0x90170310 }, /* speaker */
6379 [ALC861_FIXUP_AMP_VREF_0F
] = {
6380 .type
= ALC_FIXUP_FUNC
,
6381 .v
.func
= alc861_fixup_asus_amp_vref_0f
,
6383 [ALC861_FIXUP_NO_JACK_DETECT
] = {
6384 .type
= ALC_FIXUP_FUNC
,
6385 .v
.func
= alc_fixup_no_jack_detect
,
6387 [ALC861_FIXUP_ASUS_A6RP
] = {
6388 .type
= ALC_FIXUP_FUNC
,
6389 .v
.func
= alc861_fixup_asus_amp_vref_0f
,
6391 .chain_id
= ALC861_FIXUP_NO_JACK_DETECT
,
6395 static const struct snd_pci_quirk alc861_fixup_tbl
[] = {
6396 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP
),
6397 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F
),
6398 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT
),
6399 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F
),
6400 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F
),
6401 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505
),
6407 static int patch_alc861(struct hda_codec
*codec
)
6409 struct alc_spec
*spec
;
6412 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
6418 spec
->mixer_nid
= 0x15;
6420 alc_pick_fixup(codec
, NULL
, alc861_fixup_tbl
, alc861_fixups
);
6421 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6423 /* automatic parse from the BIOS config */
6424 err
= alc861_parse_auto_config(codec
);
6428 if (!spec
->no_analog
&& !spec
->adc_nids
) {
6429 alc_auto_fill_adc_caps(codec
);
6430 alc_rebuild_imux_for_auto_mic(codec
);
6431 alc_remove_invalid_adc_nids(codec
);
6434 if (!spec
->no_analog
&& !spec
->cap_mixer
)
6435 set_capture_mixer(codec
);
6437 if (!spec
->no_analog
) {
6438 err
= snd_hda_attach_beep_device(codec
, 0x23);
6441 set_beep_amp(spec
, 0x23, 0, HDA_OUTPUT
);
6444 codec
->patch_ops
= alc_patch_ops
;
6445 spec
->init_hook
= alc_auto_init_std
;
6446 #ifdef CONFIG_SND_HDA_POWER_SAVE
6447 spec
->power_hook
= alc_power_eapd
;
6448 if (!spec
->loopback
.amplist
)
6449 spec
->loopback
.amplist
= alc861_loopbacks
;
6452 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6466 * In addition, an independent DAC
6468 #ifdef CONFIG_SND_HDA_POWER_SAVE
6469 #define alc861vd_loopbacks alc880_loopbacks
6472 static int alc861vd_parse_auto_config(struct hda_codec
*codec
)
6474 static const hda_nid_t alc861vd_ignore
[] = { 0x1d, 0 };
6475 static const hda_nid_t alc861vd_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
6476 return alc_parse_auto_config(codec
, alc861vd_ignore
, alc861vd_ssids
);
6480 ALC660VD_FIX_ASUS_GPIO1
,
6481 ALC861VD_FIX_DALLAS
,
6484 /* exclude VREF80 */
6485 static void alc861vd_fixup_dallas(struct hda_codec
*codec
,
6486 const struct alc_fixup
*fix
, int action
)
6488 if (action
== ALC_FIXUP_ACT_PRE_PROBE
) {
6489 snd_hda_override_pin_caps(codec
, 0x18, 0x00001714);
6490 snd_hda_override_pin_caps(codec
, 0x19, 0x0000171c);
6494 static const struct alc_fixup alc861vd_fixups
[] = {
6495 [ALC660VD_FIX_ASUS_GPIO1
] = {
6496 .type
= ALC_FIXUP_VERBS
,
6497 .v
.verbs
= (const struct hda_verb
[]) {
6499 {0x01, AC_VERB_SET_GPIO_MASK
, 0x03},
6500 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
6501 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
6505 [ALC861VD_FIX_DALLAS
] = {
6506 .type
= ALC_FIXUP_FUNC
,
6507 .v
.func
= alc861vd_fixup_dallas
,
6511 static const struct snd_pci_quirk alc861vd_fixup_tbl
[] = {
6512 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS
),
6513 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1
),
6514 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS
),
6518 static const struct hda_verb alc660vd_eapd_verbs
[] = {
6519 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 2},
6520 {0x15, AC_VERB_SET_EAPD_BTLENABLE
, 2},
6526 static int patch_alc861vd(struct hda_codec
*codec
)
6528 struct alc_spec
*spec
;
6531 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
6537 spec
->mixer_nid
= 0x0b;
6539 alc_pick_fixup(codec
, NULL
, alc861vd_fixup_tbl
, alc861vd_fixups
);
6540 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6542 /* automatic parse from the BIOS config */
6543 err
= alc861vd_parse_auto_config(codec
);
6547 if (codec
->vendor_id
== 0x10ec0660) {
6548 /* always turn on EAPD */
6549 add_verb(spec
, alc660vd_eapd_verbs
);
6552 if (!spec
->no_analog
&& !spec
->adc_nids
) {
6553 alc_auto_fill_adc_caps(codec
);
6554 alc_rebuild_imux_for_auto_mic(codec
);
6555 alc_remove_invalid_adc_nids(codec
);
6558 if (!spec
->no_analog
&& !spec
->cap_mixer
)
6559 set_capture_mixer(codec
);
6561 if (!spec
->no_analog
) {
6562 err
= snd_hda_attach_beep_device(codec
, 0x23);
6565 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
6568 codec
->patch_ops
= alc_patch_ops
;
6570 spec
->init_hook
= alc_auto_init_std
;
6571 spec
->shutup
= alc_eapd_shutup
;
6572 #ifdef CONFIG_SND_HDA_POWER_SAVE
6573 if (!spec
->loopback
.amplist
)
6574 spec
->loopback
.amplist
= alc861vd_loopbacks
;
6577 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6589 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
6590 * configuration. Each pin widget can choose any input DACs and a mixer.
6591 * Each ADC is connected from a mixer of all inputs. This makes possible
6592 * 6-channel independent captures.
6594 * In addition, an independent DAC for the multi-playback (not used in this
6597 #ifdef CONFIG_SND_HDA_POWER_SAVE
6598 #define alc662_loopbacks alc880_loopbacks
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
,
6652 static const struct alc_fixup alc662_fixups
[] = {
6653 [ALC662_FIXUP_ASPIRE
] = {
6654 .type
= ALC_FIXUP_PINS
,
6655 .v
.pins
= (const struct alc_pincfg
[]) {
6656 { 0x15, 0x99130112 }, /* subwoofer */
6660 [ALC662_FIXUP_IDEAPAD
] = {
6661 .type
= ALC_FIXUP_PINS
,
6662 .v
.pins
= (const struct alc_pincfg
[]) {
6663 { 0x17, 0x99130112 }, /* subwoofer */
6667 [ALC272_FIXUP_MARIO
] = {
6668 .type
= ALC_FIXUP_FUNC
,
6669 .v
.func
= alc272_fixup_mario
,
6671 [ALC662_FIXUP_CZC_P10T
] = {
6672 .type
= ALC_FIXUP_VERBS
,
6673 .v
.verbs
= (const struct hda_verb
[]) {
6674 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 0},
6678 [ALC662_FIXUP_SKU_IGNORE
] = {
6679 .type
= ALC_FIXUP_SKU
,
6680 .v
.sku
= ALC_FIXUP_SKU_IGNORE
,
6682 [ALC662_FIXUP_HP_RP5800
] = {
6683 .type
= ALC_FIXUP_PINS
,
6684 .v
.pins
= (const struct alc_pincfg
[]) {
6685 { 0x14, 0x0221201f }, /* HP out */
6689 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6691 [ALC662_FIXUP_ASUS_MODE1
] = {
6692 .type
= ALC_FIXUP_PINS
,
6693 .v
.pins
= (const struct alc_pincfg
[]) {
6694 { 0x14, 0x99130110 }, /* speaker */
6695 { 0x18, 0x01a19c20 }, /* mic */
6696 { 0x19, 0x99a3092f }, /* int-mic */
6697 { 0x21, 0x0121401f }, /* HP out */
6701 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6703 [ALC662_FIXUP_ASUS_MODE2
] = {
6704 .type
= ALC_FIXUP_PINS
,
6705 .v
.pins
= (const struct alc_pincfg
[]) {
6706 { 0x14, 0x99130110 }, /* speaker */
6707 { 0x18, 0x01a19820 }, /* mic */
6708 { 0x19, 0x99a3092f }, /* int-mic */
6709 { 0x1b, 0x0121401f }, /* HP out */
6713 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6715 [ALC662_FIXUP_ASUS_MODE3
] = {
6716 .type
= ALC_FIXUP_PINS
,
6717 .v
.pins
= (const struct alc_pincfg
[]) {
6718 { 0x14, 0x99130110 }, /* speaker */
6719 { 0x15, 0x0121441f }, /* HP */
6720 { 0x18, 0x01a19840 }, /* mic */
6721 { 0x19, 0x99a3094f }, /* int-mic */
6722 { 0x21, 0x01211420 }, /* HP2 */
6726 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6728 [ALC662_FIXUP_ASUS_MODE4
] = {
6729 .type
= ALC_FIXUP_PINS
,
6730 .v
.pins
= (const struct alc_pincfg
[]) {
6731 { 0x14, 0x99130110 }, /* speaker */
6732 { 0x16, 0x99130111 }, /* speaker */
6733 { 0x18, 0x01a19840 }, /* mic */
6734 { 0x19, 0x99a3094f }, /* int-mic */
6735 { 0x21, 0x0121441f }, /* HP */
6739 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6741 [ALC662_FIXUP_ASUS_MODE5
] = {
6742 .type
= ALC_FIXUP_PINS
,
6743 .v
.pins
= (const struct alc_pincfg
[]) {
6744 { 0x14, 0x99130110 }, /* speaker */
6745 { 0x15, 0x0121441f }, /* HP */
6746 { 0x16, 0x99130111 }, /* speaker */
6747 { 0x18, 0x01a19840 }, /* mic */
6748 { 0x19, 0x99a3094f }, /* int-mic */
6752 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6754 [ALC662_FIXUP_ASUS_MODE6
] = {
6755 .type
= ALC_FIXUP_PINS
,
6756 .v
.pins
= (const struct alc_pincfg
[]) {
6757 { 0x14, 0x99130110 }, /* speaker */
6758 { 0x15, 0x01211420 }, /* HP2 */
6759 { 0x18, 0x01a19840 }, /* mic */
6760 { 0x19, 0x99a3094f }, /* int-mic */
6761 { 0x1b, 0x0121441f }, /* HP */
6765 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6767 [ALC662_FIXUP_ASUS_MODE7
] = {
6768 .type
= ALC_FIXUP_PINS
,
6769 .v
.pins
= (const struct alc_pincfg
[]) {
6770 { 0x14, 0x99130110 }, /* speaker */
6771 { 0x17, 0x99130111 }, /* speaker */
6772 { 0x18, 0x01a19840 }, /* mic */
6773 { 0x19, 0x99a3094f }, /* int-mic */
6774 { 0x1b, 0x01214020 }, /* HP */
6775 { 0x21, 0x0121401f }, /* HP */
6779 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6781 [ALC662_FIXUP_ASUS_MODE8
] = {
6782 .type
= ALC_FIXUP_PINS
,
6783 .v
.pins
= (const struct alc_pincfg
[]) {
6784 { 0x14, 0x99130110 }, /* speaker */
6785 { 0x12, 0x99a30970 }, /* int-mic */
6786 { 0x15, 0x01214020 }, /* HP */
6787 { 0x17, 0x99130111 }, /* speaker */
6788 { 0x18, 0x01a19840 }, /* mic */
6789 { 0x21, 0x0121401f }, /* HP */
6793 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6795 [ALC662_FIXUP_NO_JACK_DETECT
] = {
6796 .type
= ALC_FIXUP_FUNC
,
6797 .v
.func
= alc_fixup_no_jack_detect
,
6801 static const struct snd_pci_quirk alc662_fixup_tbl
[] = {
6802 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2
),
6803 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE
),
6804 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE
),
6805 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE
),
6806 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800
),
6807 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT
),
6808 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2
),
6809 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD
),
6810 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD
),
6811 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD
),
6812 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T
),
6815 /* Below is a quirk table taken from the old code.
6816 * Basically the device should work as is without the fixup table.
6817 * If BIOS doesn't give a proper info, enable the corresponding
6820 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1
),
6821 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3
),
6822 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1
),
6823 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3
),
6824 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6825 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6826 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6827 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1
),
6828 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1
),
6829 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6830 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7
),
6831 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7
),
6832 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8
),
6833 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3
),
6834 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1
),
6835 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6836 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2
),
6837 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1
),
6838 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6839 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6840 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6841 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6842 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1
),
6843 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3
),
6844 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2
),
6845 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6846 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5
),
6847 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6848 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6849 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1
),
6850 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6851 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6852 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3
),
6853 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3
),
6854 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1
),
6855 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1
),
6856 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1
),
6857 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1
),
6858 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1
),
6859 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6860 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2
),
6861 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1
),
6862 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6863 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3
),
6864 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1
),
6865 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1
),
6866 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1
),
6867 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2
),
6868 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6869 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4
),
6874 static const struct alc_model_fixup alc662_fixup_models
[] = {
6875 {.id
= ALC272_FIXUP_MARIO
, .name
= "mario"},
6876 {.id
= ALC662_FIXUP_ASUS_MODE1
, .name
= "asus-mode1"},
6877 {.id
= ALC662_FIXUP_ASUS_MODE2
, .name
= "asus-mode2"},
6878 {.id
= ALC662_FIXUP_ASUS_MODE3
, .name
= "asus-mode3"},
6879 {.id
= ALC662_FIXUP_ASUS_MODE4
, .name
= "asus-mode4"},
6880 {.id
= ALC662_FIXUP_ASUS_MODE5
, .name
= "asus-mode5"},
6881 {.id
= ALC662_FIXUP_ASUS_MODE6
, .name
= "asus-mode6"},
6882 {.id
= ALC662_FIXUP_ASUS_MODE7
, .name
= "asus-mode7"},
6883 {.id
= ALC662_FIXUP_ASUS_MODE8
, .name
= "asus-mode8"},
6890 static int patch_alc662(struct hda_codec
*codec
)
6892 struct alc_spec
*spec
;
6895 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
6901 spec
->mixer_nid
= 0x0b;
6903 /* handle multiple HPs as is */
6904 spec
->parse_flags
= HDA_PINCFG_NO_HP_FIXUP
;
6906 alc_auto_parse_customize_define(codec
);
6908 alc_fix_pll_init(codec
, 0x20, 0x04, 15);
6910 err
= alc_codec_rename_from_preset(codec
);
6914 if ((alc_get_coef0(codec
) & (1 << 14)) &&
6915 codec
->bus
->pci
->subsystem_vendor
== 0x1025 &&
6916 spec
->cdefine
.platform_type
== 1) {
6917 if (alc_codec_rename(codec
, "ALC272X") < 0)
6921 alc_pick_fixup(codec
, alc662_fixup_models
,
6922 alc662_fixup_tbl
, alc662_fixups
);
6923 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6924 /* automatic parse from the BIOS config */
6925 err
= alc662_parse_auto_config(codec
);
6929 if (!spec
->no_analog
&& !spec
->adc_nids
) {
6930 alc_auto_fill_adc_caps(codec
);
6931 alc_rebuild_imux_for_auto_mic(codec
);
6932 alc_remove_invalid_adc_nids(codec
);
6935 if (!spec
->no_analog
&& !spec
->cap_mixer
)
6936 set_capture_mixer(codec
);
6938 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
6939 err
= snd_hda_attach_beep_device(codec
, 0x1);
6942 switch (codec
->vendor_id
) {
6944 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
6949 set_beep_amp(spec
, 0x0b, 0x04, HDA_INPUT
);
6952 set_beep_amp(spec
, 0x0b, 0x03, HDA_INPUT
);
6957 codec
->patch_ops
= alc_patch_ops
;
6958 spec
->init_hook
= alc_auto_init_std
;
6959 spec
->shutup
= alc_eapd_shutup
;
6961 #ifdef CONFIG_SND_HDA_POWER_SAVE
6962 if (!spec
->loopback
.amplist
)
6963 spec
->loopback
.amplist
= alc662_loopbacks
;
6966 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6979 static int alc680_parse_auto_config(struct hda_codec
*codec
)
6981 return alc_parse_auto_config(codec
, NULL
, NULL
);
6986 static int patch_alc680(struct hda_codec
*codec
)
6988 struct alc_spec
*spec
;
6991 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
6997 /* ALC680 has no aa-loopback mixer */
6999 /* automatic parse from the BIOS config */
7000 err
= alc680_parse_auto_config(codec
);
7006 if (!spec
->no_analog
&& !spec
->cap_mixer
)
7007 set_capture_mixer(codec
);
7009 codec
->patch_ops
= alc_patch_ops
;
7010 spec
->init_hook
= alc_auto_init_std
;
7018 static const struct hda_codec_preset snd_hda_preset_realtek
[] = {
7019 { .id
= 0x10ec0221, .name
= "ALC221", .patch
= patch_alc269
},
7020 { .id
= 0x10ec0260, .name
= "ALC260", .patch
= patch_alc260
},
7021 { .id
= 0x10ec0262, .name
= "ALC262", .patch
= patch_alc262
},
7022 { .id
= 0x10ec0267, .name
= "ALC267", .patch
= patch_alc268
},
7023 { .id
= 0x10ec0268, .name
= "ALC268", .patch
= patch_alc268
},
7024 { .id
= 0x10ec0269, .name
= "ALC269", .patch
= patch_alc269
},
7025 { .id
= 0x10ec0270, .name
= "ALC270", .patch
= patch_alc269
},
7026 { .id
= 0x10ec0272, .name
= "ALC272", .patch
= patch_alc662
},
7027 { .id
= 0x10ec0275, .name
= "ALC275", .patch
= patch_alc269
},
7028 { .id
= 0x10ec0276, .name
= "ALC276", .patch
= patch_alc269
},
7029 { .id
= 0x10ec0861, .rev
= 0x100340, .name
= "ALC660",
7030 .patch
= patch_alc861
},
7031 { .id
= 0x10ec0660, .name
= "ALC660-VD", .patch
= patch_alc861vd
},
7032 { .id
= 0x10ec0861, .name
= "ALC861", .patch
= patch_alc861
},
7033 { .id
= 0x10ec0862, .name
= "ALC861-VD", .patch
= patch_alc861vd
},
7034 { .id
= 0x10ec0662, .rev
= 0x100002, .name
= "ALC662 rev2",
7035 .patch
= patch_alc882
},
7036 { .id
= 0x10ec0662, .rev
= 0x100101, .name
= "ALC662 rev1",
7037 .patch
= patch_alc662
},
7038 { .id
= 0x10ec0662, .rev
= 0x100300, .name
= "ALC662 rev3",
7039 .patch
= patch_alc662
},
7040 { .id
= 0x10ec0663, .name
= "ALC663", .patch
= patch_alc662
},
7041 { .id
= 0x10ec0665, .name
= "ALC665", .patch
= patch_alc662
},
7042 { .id
= 0x10ec0670, .name
= "ALC670", .patch
= patch_alc662
},
7043 { .id
= 0x10ec0680, .name
= "ALC680", .patch
= patch_alc680
},
7044 { .id
= 0x10ec0880, .name
= "ALC880", .patch
= patch_alc880
},
7045 { .id
= 0x10ec0882, .name
= "ALC882", .patch
= patch_alc882
},
7046 { .id
= 0x10ec0883, .name
= "ALC883", .patch
= patch_alc882
},
7047 { .id
= 0x10ec0885, .rev
= 0x100101, .name
= "ALC889A",
7048 .patch
= patch_alc882
},
7049 { .id
= 0x10ec0885, .rev
= 0x100103, .name
= "ALC889A",
7050 .patch
= patch_alc882
},
7051 { .id
= 0x10ec0885, .name
= "ALC885", .patch
= patch_alc882
},
7052 { .id
= 0x10ec0887, .name
= "ALC887", .patch
= patch_alc882
},
7053 { .id
= 0x10ec0888, .rev
= 0x100101, .name
= "ALC1200",
7054 .patch
= patch_alc882
},
7055 { .id
= 0x10ec0888, .name
= "ALC888", .patch
= patch_alc882
},
7056 { .id
= 0x10ec0889, .name
= "ALC889", .patch
= patch_alc882
},
7057 { .id
= 0x10ec0892, .name
= "ALC892", .patch
= patch_alc662
},
7058 { .id
= 0x10ec0899, .name
= "ALC898", .patch
= patch_alc882
},
7062 MODULE_ALIAS("snd-hda-codec-id:10ec*");
7064 MODULE_LICENSE("GPL");
7065 MODULE_DESCRIPTION("Realtek HD-audio codec");
7067 static struct hda_codec_preset_list realtek_list
= {
7068 .preset
= snd_hda_preset_realtek
,
7069 .owner
= THIS_MODULE
,
7072 static int __init
patch_realtek_init(void)
7074 return snd_hda_add_codec_preset(&realtek_list
);
7077 static void __exit
patch_realtek_exit(void)
7079 snd_hda_delete_codec_preset(&realtek_list
);
7082 module_init(patch_realtek_init
)
7083 module_exit(patch_realtek_exit
)