2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for Realtek ALC codecs
6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
8 * Takashi Iwai <tiwai@suse.de>
9 * Jonathan Woithe <jwoithe@just42.net>
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <linux/module.h>
31 #include <sound/core.h>
32 #include <sound/jack.h>
33 #include "hda_codec.h"
34 #include "hda_local.h"
35 #include "hda_auto_parser.h"
39 /* unsol event tags */
40 #define ALC_FRONT_EVENT 0x01
41 #define ALC_DCVOL_EVENT 0x02
42 #define ALC_HP_EVENT 0x04
43 #define ALC_MIC_EVENT 0x08
46 #define GPIO_MASK 0x03
48 /* extra amp-initialization sequence types */
57 struct alc_customize_define
{
59 unsigned char port_connectivity
;
60 unsigned char check_sum
;
61 unsigned char customization
;
62 unsigned char external_amp
;
63 unsigned int enable_pcbeep
:1;
64 unsigned int platform_type
:1;
66 unsigned int override
:1;
67 unsigned int fixup
:1; /* Means that this sku is set by driver, not read from hw */
71 hda_nid_t pin
; /* multi-io widget pin NID */
72 hda_nid_t dac
; /* DAC to be connected */
73 unsigned int ctl_in
; /* cached input-pin control value */
77 ALC_AUTOMUTE_PIN
, /* change the pin control */
78 ALC_AUTOMUTE_AMP
, /* mute/unmute the pin AMP */
79 ALC_AUTOMUTE_MIXER
, /* mute/unmute mixer widget AMP */
82 #define MAX_VOL_NIDS 0x40
84 /* make compatible with old code */
85 #define alc_apply_pincfgs snd_hda_apply_pincfgs
86 #define alc_apply_fixup snd_hda_apply_fixup
87 #define alc_pick_fixup snd_hda_pick_fixup
88 #define alc_fixup hda_fixup
89 #define alc_pincfg hda_pintbl
90 #define alc_model_fixup hda_model_fixup
92 #define ALC_FIXUP_PINS HDA_FIXUP_PINS
93 #define ALC_FIXUP_VERBS HDA_FIXUP_VERBS
94 #define ALC_FIXUP_FUNC HDA_FIXUP_FUNC
96 #define ALC_FIXUP_ACT_PRE_PROBE HDA_FIXUP_ACT_PRE_PROBE
97 #define ALC_FIXUP_ACT_PROBE HDA_FIXUP_ACT_PROBE
98 #define ALC_FIXUP_ACT_INIT HDA_FIXUP_ACT_INIT
99 #define ALC_FIXUP_ACT_BUILD HDA_FIXUP_ACT_BUILD
103 struct hda_gen_spec gen
;
105 /* codec parameterization */
106 const struct snd_kcontrol_new
*mixers
[5]; /* mixer arrays */
107 unsigned int num_mixers
;
108 const struct snd_kcontrol_new
*cap_mixer
; /* capture mixer */
109 unsigned int beep_amp
; /* beep amp value, set via set_beep_amp() */
111 char stream_name_analog
[32]; /* analog PCM stream */
112 const struct hda_pcm_stream
*stream_analog_playback
;
113 const struct hda_pcm_stream
*stream_analog_capture
;
114 const struct hda_pcm_stream
*stream_analog_alt_playback
;
115 const struct hda_pcm_stream
*stream_analog_alt_capture
;
117 char stream_name_digital
[32]; /* digital PCM stream */
118 const struct hda_pcm_stream
*stream_digital_playback
;
119 const struct hda_pcm_stream
*stream_digital_capture
;
122 struct hda_multi_out multiout
; /* playback set-up
123 * max_channels, dacs must be set
124 * dig_out_nid and hp_nid are optional
126 hda_nid_t alt_dac_nid
;
127 hda_nid_t slave_dig_outs
[3]; /* optional - for auto-parsing */
131 unsigned int num_adc_nids
;
132 const hda_nid_t
*adc_nids
;
133 const hda_nid_t
*capsrc_nids
;
134 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
135 hda_nid_t mixer_nid
; /* analog-mixer NID */
136 DECLARE_BITMAP(vol_ctls
, MAX_VOL_NIDS
<< 1);
137 DECLARE_BITMAP(sw_ctls
, MAX_VOL_NIDS
<< 1);
139 /* capture setup for dynamic dual-adc switch */
141 unsigned int cur_adc_stream_tag
;
142 unsigned int cur_adc_format
;
145 unsigned int num_mux_defs
;
146 const struct hda_input_mux
*input_mux
;
147 unsigned int cur_mux
[3];
148 hda_nid_t ext_mic_pin
;
149 hda_nid_t dock_mic_pin
;
150 hda_nid_t int_mic_pin
;
153 const struct hda_channel_mode
*channel_mode
;
154 int num_channel_mode
;
156 int const_channel_count
;
157 int ext_channel_count
;
159 /* PCM information */
160 struct hda_pcm pcm_rec
[3]; /* used in alc_build_pcms() */
162 /* dynamic controls, init_verbs and input_mux */
163 struct auto_pin_cfg autocfg
;
164 struct alc_customize_define cdefine
;
165 struct snd_array kctls
;
166 struct hda_input_mux private_imux
[3];
167 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
168 hda_nid_t private_adc_nids
[AUTO_CFG_MAX_OUTS
];
169 hda_nid_t private_capsrc_nids
[AUTO_CFG_MAX_OUTS
];
170 hda_nid_t imux_pins
[HDA_MAX_NUM_INPUTS
];
171 unsigned int dyn_adc_idx
[HDA_MAX_NUM_INPUTS
];
172 int int_mic_idx
, ext_mic_idx
, dock_mic_idx
; /* for auto-mic */
175 void (*init_hook
)(struct hda_codec
*codec
);
176 void (*unsol_event
)(struct hda_codec
*codec
, unsigned int res
);
177 #ifdef CONFIG_SND_HDA_POWER_SAVE
178 void (*power_hook
)(struct hda_codec
*codec
);
180 void (*shutup
)(struct hda_codec
*codec
);
181 void (*automute_hook
)(struct hda_codec
*codec
);
183 /* for pin sensing */
184 unsigned int hp_jack_present
:1;
185 unsigned int line_jack_present
:1;
186 unsigned int master_mute
:1;
187 unsigned int auto_mic
:1;
188 unsigned int auto_mic_valid_imux
:1; /* valid imux for auto-mic */
189 unsigned int automute_speaker
:1; /* automute speaker outputs */
190 unsigned int automute_lo
:1; /* automute LO outputs */
191 unsigned int detect_hp
:1; /* Headphone detection enabled */
192 unsigned int detect_lo
:1; /* Line-out detection enabled */
193 unsigned int automute_speaker_possible
:1; /* there are speakers and either LO or HP */
194 unsigned int automute_lo_possible
:1; /* there are line outs and HP */
195 unsigned int keep_vref_in_automute
:1; /* Don't clear VREF in automute */
198 unsigned int no_analog
:1; /* digital I/O only */
199 unsigned int dyn_adc_switch
:1; /* switch ADCs (for ALC275) */
200 unsigned int single_input_src
:1;
201 unsigned int vol_in_capsrc
:1; /* use capsrc volume (ADC has no vol) */
202 unsigned int parse_flags
; /* passed to snd_hda_parse_pin_defcfg() */
203 unsigned int shared_mic_hp
:1; /* HP/Mic-in sharing */
205 /* auto-mute control */
207 hda_nid_t automute_mixer_nid
[AUTO_CFG_MAX_OUTS
];
210 int codec_variant
; /* flag for other variants */
212 /* for virtual master */
213 hda_nid_t vmaster_nid
;
214 struct hda_vmaster_mute_hook vmaster_mute
;
215 #ifdef CONFIG_SND_HDA_POWER_SAVE
216 struct hda_loopback_check loopback
;
218 struct hda_amp_list loopback_list
[8];
223 unsigned int pll_coef_idx
, pll_coef_bit
;
228 struct alc_multi_io multi_io
[4];
231 struct snd_array bind_ctls
;
234 static bool check_amp_caps(struct hda_codec
*codec
, hda_nid_t nid
,
235 int dir
, unsigned int bits
)
239 if (get_wcaps(codec
, nid
) & (1 << (dir
+ 1)))
240 if (query_amp_caps(codec
, nid
, dir
) & bits
)
245 #define nid_has_mute(codec, nid, dir) \
246 check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE)
247 #define nid_has_volume(codec, nid, dir) \
248 check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS)
253 static int alc_mux_enum_info(struct snd_kcontrol
*kcontrol
,
254 struct snd_ctl_elem_info
*uinfo
)
256 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
257 struct alc_spec
*spec
= codec
->spec
;
258 unsigned int mux_idx
= snd_ctl_get_ioffidx(kcontrol
, &uinfo
->id
);
259 if (mux_idx
>= spec
->num_mux_defs
)
261 if (!spec
->input_mux
[mux_idx
].num_items
&& mux_idx
> 0)
263 return snd_hda_input_mux_info(&spec
->input_mux
[mux_idx
], uinfo
);
266 static int alc_mux_enum_get(struct snd_kcontrol
*kcontrol
,
267 struct snd_ctl_elem_value
*ucontrol
)
269 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
270 struct alc_spec
*spec
= codec
->spec
;
271 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
273 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
277 static bool alc_dyn_adc_pcm_resetup(struct hda_codec
*codec
, int cur
)
279 struct alc_spec
*spec
= codec
->spec
;
280 hda_nid_t new_adc
= spec
->adc_nids
[spec
->dyn_adc_idx
[cur
]];
282 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
283 /* stream is running, let's swap the current ADC */
284 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
285 spec
->cur_adc
= new_adc
;
286 snd_hda_codec_setup_stream(codec
, new_adc
,
287 spec
->cur_adc_stream_tag
, 0,
288 spec
->cur_adc_format
);
294 static inline hda_nid_t
get_capsrc(struct alc_spec
*spec
, int idx
)
296 return spec
->capsrc_nids
?
297 spec
->capsrc_nids
[idx
] : spec
->adc_nids
[idx
];
300 static void call_update_outputs(struct hda_codec
*codec
);
302 /* select the given imux item; either unmute exclusively or select the route */
303 static int alc_mux_select(struct hda_codec
*codec
, unsigned int adc_idx
,
304 unsigned int idx
, bool force
)
306 struct alc_spec
*spec
= codec
->spec
;
307 const struct hda_input_mux
*imux
;
308 unsigned int mux_idx
;
309 int i
, type
, num_conns
;
312 if (!spec
->input_mux
)
315 mux_idx
= adc_idx
>= spec
->num_mux_defs
? 0 : adc_idx
;
316 imux
= &spec
->input_mux
[mux_idx
];
317 if (!imux
->num_items
&& mux_idx
> 0)
318 imux
= &spec
->input_mux
[0];
319 if (!imux
->num_items
)
322 if (idx
>= imux
->num_items
)
323 idx
= imux
->num_items
- 1;
324 if (spec
->cur_mux
[adc_idx
] == idx
&& !force
)
326 spec
->cur_mux
[adc_idx
] = idx
;
328 /* for shared I/O, change the pin-control accordingly */
329 if (spec
->shared_mic_hp
) {
331 hda_nid_t pin
= spec
->autocfg
.inputs
[1].pin
;
332 /* NOTE: this assumes that there are only two inputs, the
333 * first is the real internal mic and the second is HP jack.
335 if (spec
->cur_mux
[adc_idx
])
336 val
= snd_hda_get_default_vref(codec
, pin
) | PIN_IN
;
339 snd_hda_set_pin_ctl(codec
, pin
, val
);
340 spec
->automute_speaker
= !spec
->cur_mux
[adc_idx
];
341 call_update_outputs(codec
);
344 if (spec
->dyn_adc_switch
) {
345 alc_dyn_adc_pcm_resetup(codec
, idx
);
346 adc_idx
= spec
->dyn_adc_idx
[idx
];
349 nid
= get_capsrc(spec
, adc_idx
);
352 num_conns
= snd_hda_get_num_conns(codec
, nid
);
356 type
= get_wcaps_type(get_wcaps(codec
, nid
));
357 if (type
== AC_WID_AUD_MIX
) {
358 /* Matrix-mixer style (e.g. ALC882) */
359 int active
= imux
->items
[idx
].index
;
360 for (i
= 0; i
< num_conns
; i
++) {
361 unsigned int v
= (i
== active
) ? 0 : HDA_AMP_MUTE
;
362 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, i
,
366 /* MUX style (e.g. ALC880) */
367 snd_hda_codec_write_cache(codec
, nid
, 0,
368 AC_VERB_SET_CONNECT_SEL
,
369 imux
->items
[idx
].index
);
374 static int alc_mux_enum_put(struct snd_kcontrol
*kcontrol
,
375 struct snd_ctl_elem_value
*ucontrol
)
377 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
378 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
379 return alc_mux_select(codec
, adc_idx
,
380 ucontrol
->value
.enumerated
.item
[0], false);
384 * set up the input pin config (depending on the given auto-pin type)
386 static void alc_set_input_pin(struct hda_codec
*codec
, hda_nid_t nid
,
389 unsigned int val
= PIN_IN
;
390 if (auto_pin_type
== AUTO_PIN_MIC
)
391 val
|= snd_hda_get_default_vref(codec
, nid
);
392 snd_hda_set_pin_ctl(codec
, nid
, val
);
396 * Append the given mixer and verb elements for the later use
397 * The mixer array is referred in build_controls(), and init_verbs are
400 static void add_mixer(struct alc_spec
*spec
, const struct snd_kcontrol_new
*mix
)
402 if (snd_BUG_ON(spec
->num_mixers
>= ARRAY_SIZE(spec
->mixers
)))
404 spec
->mixers
[spec
->num_mixers
++] = mix
;
408 * GPIO setup tables, used in initialization
410 /* Enable GPIO mask and set output */
411 static const struct hda_verb alc_gpio1_init_verbs
[] = {
412 {0x01, AC_VERB_SET_GPIO_MASK
, 0x01},
413 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
414 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
418 static const struct hda_verb alc_gpio2_init_verbs
[] = {
419 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
420 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
421 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02},
425 static const struct hda_verb alc_gpio3_init_verbs
[] = {
426 {0x01, AC_VERB_SET_GPIO_MASK
, 0x03},
427 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x03},
428 {0x01, AC_VERB_SET_GPIO_DATA
, 0x03},
433 * Fix hardware PLL issue
434 * On some codecs, the analog PLL gating control must be off while
435 * the default value is 1.
437 static void alc_fix_pll(struct hda_codec
*codec
)
439 struct alc_spec
*spec
= codec
->spec
;
444 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_COEF_INDEX
,
446 val
= snd_hda_codec_read(codec
, spec
->pll_nid
, 0,
447 AC_VERB_GET_PROC_COEF
, 0);
448 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_COEF_INDEX
,
450 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_PROC_COEF
,
451 val
& ~(1 << spec
->pll_coef_bit
));
454 static void alc_fix_pll_init(struct hda_codec
*codec
, hda_nid_t nid
,
455 unsigned int coef_idx
, unsigned int coef_bit
)
457 struct alc_spec
*spec
= codec
->spec
;
459 spec
->pll_coef_idx
= coef_idx
;
460 spec
->pll_coef_bit
= coef_bit
;
465 * Jack detections for HP auto-mute and mic-switch
468 /* check each pin in the given array; returns true if any of them is plugged */
469 static bool detect_jacks(struct hda_codec
*codec
, int num_pins
, hda_nid_t
*pins
)
473 for (i
= 0; i
< num_pins
; i
++) {
474 hda_nid_t nid
= pins
[i
];
477 present
|= snd_hda_jack_detect(codec
, nid
);
482 /* standard HP/line-out auto-mute helper */
483 static void do_automute(struct hda_codec
*codec
, int num_pins
, hda_nid_t
*pins
,
484 bool mute
, bool hp_out
)
486 struct alc_spec
*spec
= codec
->spec
;
487 unsigned int mute_bits
= mute
? HDA_AMP_MUTE
: 0;
488 unsigned int pin_bits
= mute
? 0 : (hp_out
? PIN_HP
: PIN_OUT
);
491 for (i
= 0; i
< num_pins
; i
++) {
492 hda_nid_t nid
= pins
[i
];
496 switch (spec
->automute_mode
) {
497 case ALC_AUTOMUTE_PIN
:
498 /* don't reset VREF value in case it's controlling
499 * the amp (see alc861_fixup_asus_amp_vref_0f())
501 if (spec
->keep_vref_in_automute
) {
502 val
= snd_hda_codec_read(codec
, nid
, 0,
503 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
508 snd_hda_set_pin_ctl(codec
, nid
, val
);
510 case ALC_AUTOMUTE_AMP
:
511 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
512 HDA_AMP_MUTE
, mute_bits
);
514 case ALC_AUTOMUTE_MIXER
:
515 nid
= spec
->automute_mixer_nid
[i
];
518 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, 0,
519 HDA_AMP_MUTE
, mute_bits
);
520 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, 1,
521 HDA_AMP_MUTE
, mute_bits
);
527 /* Toggle outputs muting */
528 static void update_outputs(struct hda_codec
*codec
)
530 struct alc_spec
*spec
= codec
->spec
;
533 /* Control HP pins/amps depending on master_mute state;
534 * in general, HP pins/amps control should be enabled in all cases,
535 * but currently set only for master_mute, just to be safe
537 if (!spec
->shared_mic_hp
) /* don't change HP-pin when shared with mic */
538 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.hp_pins
),
539 spec
->autocfg
.hp_pins
, spec
->master_mute
, true);
541 if (!spec
->automute_speaker
)
544 on
= spec
->hp_jack_present
| spec
->line_jack_present
;
545 on
|= spec
->master_mute
;
546 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.speaker_pins
),
547 spec
->autocfg
.speaker_pins
, on
, false);
549 /* toggle line-out mutes if needed, too */
550 /* if LO is a copy of either HP or Speaker, don't need to handle it */
551 if (spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.hp_pins
[0] ||
552 spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.speaker_pins
[0])
554 if (!spec
->automute_lo
)
557 on
= spec
->hp_jack_present
;
558 on
|= spec
->master_mute
;
559 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.line_out_pins
),
560 spec
->autocfg
.line_out_pins
, on
, false);
563 static void call_update_outputs(struct hda_codec
*codec
)
565 struct alc_spec
*spec
= codec
->spec
;
566 if (spec
->automute_hook
)
567 spec
->automute_hook(codec
);
569 update_outputs(codec
);
572 /* standard HP-automute helper */
573 static void alc_hp_automute(struct hda_codec
*codec
)
575 struct alc_spec
*spec
= codec
->spec
;
577 spec
->hp_jack_present
=
578 detect_jacks(codec
, ARRAY_SIZE(spec
->autocfg
.hp_pins
),
579 spec
->autocfg
.hp_pins
);
580 if (!spec
->detect_hp
|| (!spec
->automute_speaker
&& !spec
->automute_lo
))
582 call_update_outputs(codec
);
585 /* standard line-out-automute helper */
586 static void alc_line_automute(struct hda_codec
*codec
)
588 struct alc_spec
*spec
= codec
->spec
;
590 /* check LO jack only when it's different from HP */
591 if (spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.hp_pins
[0])
594 spec
->line_jack_present
=
595 detect_jacks(codec
, ARRAY_SIZE(spec
->autocfg
.line_out_pins
),
596 spec
->autocfg
.line_out_pins
);
597 if (!spec
->automute_speaker
|| !spec
->detect_lo
)
599 call_update_outputs(codec
);
602 #define get_connection_index(codec, mux, nid) \
603 snd_hda_get_conn_index(codec, mux, nid, 0)
605 /* standard mic auto-switch helper */
606 static void alc_mic_automute(struct hda_codec
*codec
)
608 struct alc_spec
*spec
= codec
->spec
;
609 hda_nid_t
*pins
= spec
->imux_pins
;
611 if (!spec
->auto_mic
|| !spec
->auto_mic_valid_imux
)
613 if (snd_BUG_ON(!spec
->adc_nids
))
615 if (snd_BUG_ON(spec
->int_mic_idx
< 0 || spec
->ext_mic_idx
< 0))
618 if (snd_hda_jack_detect(codec
, pins
[spec
->ext_mic_idx
]))
619 alc_mux_select(codec
, 0, spec
->ext_mic_idx
, false);
620 else if (spec
->dock_mic_idx
>= 0 &&
621 snd_hda_jack_detect(codec
, pins
[spec
->dock_mic_idx
]))
622 alc_mux_select(codec
, 0, spec
->dock_mic_idx
, false);
624 alc_mux_select(codec
, 0, spec
->int_mic_idx
, false);
627 /* handle the specified unsol action (ALC_XXX_EVENT) */
628 static void alc_exec_unsol_event(struct hda_codec
*codec
, int action
)
632 alc_hp_automute(codec
);
634 case ALC_FRONT_EVENT
:
635 alc_line_automute(codec
);
638 alc_mic_automute(codec
);
641 snd_hda_jack_report_sync(codec
);
644 /* update the master volume per volume-knob's unsol event */
645 static void alc_update_knob_master(struct hda_codec
*codec
, hda_nid_t nid
)
648 struct snd_kcontrol
*kctl
;
649 struct snd_ctl_elem_value
*uctl
;
651 kctl
= snd_hda_find_mixer_ctl(codec
, "Master Playback Volume");
654 uctl
= kzalloc(sizeof(*uctl
), GFP_KERNEL
);
657 val
= snd_hda_codec_read(codec
, nid
, 0,
658 AC_VERB_GET_VOLUME_KNOB_CONTROL
, 0);
659 val
&= HDA_AMP_VOLMASK
;
660 uctl
->value
.integer
.value
[0] = val
;
661 uctl
->value
.integer
.value
[1] = val
;
662 kctl
->put(kctl
, uctl
);
666 /* unsolicited event for HP jack sensing */
667 static void alc_sku_unsol_event(struct hda_codec
*codec
, unsigned int res
)
671 if (codec
->vendor_id
== 0x10ec0880)
675 action
= snd_hda_jack_get_action(codec
, res
);
676 if (action
== ALC_DCVOL_EVENT
) {
677 /* Execute the dc-vol event here as it requires the NID
678 * but we don't pass NID to alc_exec_unsol_event().
679 * Once when we convert all static quirks to the auto-parser,
680 * this can be integerated into there.
682 struct hda_jack_tbl
*jack
;
683 jack
= snd_hda_jack_tbl_get_from_tag(codec
, res
);
685 alc_update_knob_master(codec
, jack
->nid
);
688 alc_exec_unsol_event(codec
, action
);
691 /* call init functions of standard auto-mute helpers */
692 static void alc_inithook(struct hda_codec
*codec
)
694 alc_hp_automute(codec
);
695 alc_line_automute(codec
);
696 alc_mic_automute(codec
);
699 /* additional initialization for ALC888 variants */
700 static void alc888_coef_init(struct hda_codec
*codec
)
704 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 0);
705 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
706 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
707 if ((tmp
& 0xf0) == 0x20)
709 snd_hda_codec_read(codec
, 0x20, 0,
710 AC_VERB_SET_PROC_COEF
, 0x830);
713 snd_hda_codec_read(codec
, 0x20, 0,
714 AC_VERB_SET_PROC_COEF
, 0x3030);
717 /* additional initialization for ALC889 variants */
718 static void alc889_coef_init(struct hda_codec
*codec
)
722 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
723 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
724 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
725 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_PROC_COEF
, tmp
|0x2010);
728 /* turn on/off EAPD control (only if available) */
729 static void set_eapd(struct hda_codec
*codec
, hda_nid_t nid
, int on
)
731 if (get_wcaps_type(get_wcaps(codec
, nid
)) != AC_WID_PIN
)
733 if (snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_EAPD
)
734 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_EAPD_BTLENABLE
,
738 /* turn on/off EAPD controls of the codec */
739 static void alc_auto_setup_eapd(struct hda_codec
*codec
, bool on
)
741 /* We currently only handle front, HP */
742 static hda_nid_t pins
[] = {
743 0x0f, 0x10, 0x14, 0x15, 0
746 for (p
= pins
; *p
; p
++)
747 set_eapd(codec
, *p
, on
);
750 /* generic shutup callback;
751 * just turning off EPAD and a little pause for avoiding pop-noise
753 static void alc_eapd_shutup(struct hda_codec
*codec
)
755 alc_auto_setup_eapd(codec
, false);
759 /* generic EAPD initialization */
760 static void alc_auto_init_amp(struct hda_codec
*codec
, int type
)
764 alc_auto_setup_eapd(codec
, true);
767 snd_hda_sequence_write(codec
, alc_gpio1_init_verbs
);
770 snd_hda_sequence_write(codec
, alc_gpio2_init_verbs
);
773 snd_hda_sequence_write(codec
, alc_gpio3_init_verbs
);
775 case ALC_INIT_DEFAULT
:
776 switch (codec
->vendor_id
) {
778 snd_hda_codec_write(codec
, 0x1a, 0,
779 AC_VERB_SET_COEF_INDEX
, 7);
780 tmp
= snd_hda_codec_read(codec
, 0x1a, 0,
781 AC_VERB_GET_PROC_COEF
, 0);
782 snd_hda_codec_write(codec
, 0x1a, 0,
783 AC_VERB_SET_COEF_INDEX
, 7);
784 snd_hda_codec_write(codec
, 0x1a, 0,
785 AC_VERB_SET_PROC_COEF
,
794 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
795 alc889_coef_init(codec
);
798 alc888_coef_init(codec
);
800 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
803 snd_hda_codec_write(codec
, 0x20, 0,
804 AC_VERB_SET_COEF_INDEX
, 7);
805 tmp
= snd_hda_codec_read(codec
, 0x20, 0,
806 AC_VERB_GET_PROC_COEF
, 0);
807 snd_hda_codec_write(codec
, 0x20, 0,
808 AC_VERB_SET_COEF_INDEX
, 7);
809 snd_hda_codec_write(codec
, 0x20, 0,
810 AC_VERB_SET_PROC_COEF
,
820 * Auto-Mute mode mixer enum support
822 static int alc_automute_mode_info(struct snd_kcontrol
*kcontrol
,
823 struct snd_ctl_elem_info
*uinfo
)
825 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
826 struct alc_spec
*spec
= codec
->spec
;
827 static const char * const texts2
[] = {
828 "Disabled", "Enabled"
830 static const char * const texts3
[] = {
831 "Disabled", "Speaker Only", "Line Out+Speaker"
833 const char * const *texts
;
835 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
837 if (spec
->automute_speaker_possible
&& spec
->automute_lo_possible
) {
838 uinfo
->value
.enumerated
.items
= 3;
841 uinfo
->value
.enumerated
.items
= 2;
844 if (uinfo
->value
.enumerated
.item
>= uinfo
->value
.enumerated
.items
)
845 uinfo
->value
.enumerated
.item
= uinfo
->value
.enumerated
.items
- 1;
846 strcpy(uinfo
->value
.enumerated
.name
,
847 texts
[uinfo
->value
.enumerated
.item
]);
851 static int alc_automute_mode_get(struct snd_kcontrol
*kcontrol
,
852 struct snd_ctl_elem_value
*ucontrol
)
854 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
855 struct alc_spec
*spec
= codec
->spec
;
856 unsigned int val
= 0;
857 if (spec
->automute_speaker
)
859 if (spec
->automute_lo
)
862 ucontrol
->value
.enumerated
.item
[0] = val
;
866 static int alc_automute_mode_put(struct snd_kcontrol
*kcontrol
,
867 struct snd_ctl_elem_value
*ucontrol
)
869 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
870 struct alc_spec
*spec
= codec
->spec
;
872 switch (ucontrol
->value
.enumerated
.item
[0]) {
874 if (!spec
->automute_speaker
&& !spec
->automute_lo
)
876 spec
->automute_speaker
= 0;
877 spec
->automute_lo
= 0;
880 if (spec
->automute_speaker_possible
) {
881 if (!spec
->automute_lo
&& spec
->automute_speaker
)
883 spec
->automute_speaker
= 1;
884 spec
->automute_lo
= 0;
885 } else if (spec
->automute_lo_possible
) {
886 if (spec
->automute_lo
)
888 spec
->automute_lo
= 1;
893 if (!spec
->automute_lo_possible
|| !spec
->automute_speaker_possible
)
895 if (spec
->automute_speaker
&& spec
->automute_lo
)
897 spec
->automute_speaker
= 1;
898 spec
->automute_lo
= 1;
903 call_update_outputs(codec
);
907 static const struct snd_kcontrol_new alc_automute_mode_enum
= {
908 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
909 .name
= "Auto-Mute Mode",
910 .info
= alc_automute_mode_info
,
911 .get
= alc_automute_mode_get
,
912 .put
= alc_automute_mode_put
,
915 static struct snd_kcontrol_new
*alc_kcontrol_new(struct alc_spec
*spec
)
917 snd_array_init(&spec
->kctls
, sizeof(struct snd_kcontrol_new
), 32);
918 return snd_array_new(&spec
->kctls
);
921 static int alc_add_automute_mode_enum(struct hda_codec
*codec
)
923 struct alc_spec
*spec
= codec
->spec
;
924 struct snd_kcontrol_new
*knew
;
926 knew
= alc_kcontrol_new(spec
);
929 *knew
= alc_automute_mode_enum
;
930 knew
->name
= kstrdup("Auto-Mute Mode", GFP_KERNEL
);
937 * Check the availability of HP/line-out auto-mute;
938 * Set up appropriately if really supported
940 static void alc_init_automute(struct hda_codec
*codec
)
942 struct alc_spec
*spec
= codec
->spec
;
943 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
949 if (cfg
->line_out_pins
[0])
951 if (cfg
->speaker_pins
[0])
953 if (present
< 2) /* need two different output types */
956 if (!cfg
->speaker_pins
[0] &&
957 cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
958 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
959 sizeof(cfg
->speaker_pins
));
960 cfg
->speaker_outs
= cfg
->line_outs
;
963 if (!cfg
->hp_pins
[0] &&
964 cfg
->line_out_type
== AUTO_PIN_HP_OUT
) {
965 memcpy(cfg
->hp_pins
, cfg
->line_out_pins
,
966 sizeof(cfg
->hp_pins
));
967 cfg
->hp_outs
= cfg
->line_outs
;
970 spec
->automute_mode
= ALC_AUTOMUTE_PIN
;
972 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
973 hda_nid_t nid
= cfg
->hp_pins
[i
];
974 if (!is_jack_detectable(codec
, nid
))
976 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
978 snd_hda_jack_detect_enable(codec
, nid
, ALC_HP_EVENT
);
982 if (cfg
->line_out_type
== AUTO_PIN_LINE_OUT
&& cfg
->line_outs
) {
983 if (cfg
->speaker_outs
)
984 for (i
= 0; i
< cfg
->line_outs
; i
++) {
985 hda_nid_t nid
= cfg
->line_out_pins
[i
];
986 if (!is_jack_detectable(codec
, nid
))
988 snd_printdd("realtek: Enable Line-Out "
989 "auto-muting on NID 0x%x\n", nid
);
990 snd_hda_jack_detect_enable(codec
, nid
,
994 spec
->automute_lo_possible
= spec
->detect_hp
;
997 spec
->automute_speaker_possible
= cfg
->speaker_outs
&&
998 (spec
->detect_hp
|| spec
->detect_lo
);
1000 spec
->automute_lo
= spec
->automute_lo_possible
;
1001 spec
->automute_speaker
= spec
->automute_speaker_possible
;
1003 if (spec
->automute_speaker_possible
|| spec
->automute_lo_possible
) {
1004 /* create a control for automute mode */
1005 alc_add_automute_mode_enum(codec
);
1006 spec
->unsol_event
= alc_sku_unsol_event
;
1010 /* return the position of NID in the list, or -1 if not found */
1011 static int find_idx_in_nid_list(hda_nid_t nid
, const hda_nid_t
*list
, int nums
)
1014 for (i
= 0; i
< nums
; i
++)
1020 /* check whether dynamic ADC-switching is available */
1021 static bool alc_check_dyn_adc_switch(struct hda_codec
*codec
)
1023 struct alc_spec
*spec
= codec
->spec
;
1024 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
1028 if (imux
!= spec
->input_mux
) /* no dynamic imux? */
1031 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
1032 cap
= spec
->private_capsrc_nids
[n
];
1033 for (i
= 0; i
< imux
->num_items
; i
++) {
1034 pin
= spec
->imux_pins
[i
];
1037 if (get_connection_index(codec
, cap
, pin
) < 0)
1040 if (i
>= imux
->num_items
)
1041 return true; /* no ADC-switch is needed */
1044 for (i
= 0; i
< imux
->num_items
; i
++) {
1045 pin
= spec
->imux_pins
[i
];
1046 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
1047 cap
= spec
->private_capsrc_nids
[n
];
1048 idx
= get_connection_index(codec
, cap
, pin
);
1050 imux
->items
[i
].index
= idx
;
1051 spec
->dyn_adc_idx
[i
] = n
;
1057 snd_printdd("realtek: enabling ADC switching\n");
1058 spec
->dyn_adc_switch
= 1;
1062 /* check whether all auto-mic pins are valid; setup indices if OK */
1063 static bool alc_auto_mic_check_imux(struct hda_codec
*codec
)
1065 struct alc_spec
*spec
= codec
->spec
;
1066 const struct hda_input_mux
*imux
;
1068 if (!spec
->auto_mic
)
1070 if (spec
->auto_mic_valid_imux
)
1071 return true; /* already checked */
1073 /* fill up imux indices */
1074 if (!alc_check_dyn_adc_switch(codec
)) {
1079 imux
= spec
->input_mux
;
1080 spec
->ext_mic_idx
= find_idx_in_nid_list(spec
->ext_mic_pin
,
1081 spec
->imux_pins
, imux
->num_items
);
1082 spec
->int_mic_idx
= find_idx_in_nid_list(spec
->int_mic_pin
,
1083 spec
->imux_pins
, imux
->num_items
);
1084 spec
->dock_mic_idx
= find_idx_in_nid_list(spec
->dock_mic_pin
,
1085 spec
->imux_pins
, imux
->num_items
);
1086 if (spec
->ext_mic_idx
< 0 || spec
->int_mic_idx
< 0) {
1088 return false; /* no corresponding imux */
1091 snd_hda_jack_detect_enable(codec
, spec
->ext_mic_pin
, ALC_MIC_EVENT
);
1092 if (spec
->dock_mic_pin
)
1093 snd_hda_jack_detect_enable(codec
, spec
->dock_mic_pin
,
1096 spec
->auto_mic_valid_imux
= 1;
1102 * Check the availability of auto-mic switch;
1103 * Set up if really supported
1105 static void alc_init_auto_mic(struct hda_codec
*codec
)
1107 struct alc_spec
*spec
= codec
->spec
;
1108 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1109 hda_nid_t fixed
, ext
, dock
;
1112 if (spec
->shared_mic_hp
)
1113 return; /* no auto-mic for the shared I/O */
1115 spec
->ext_mic_idx
= spec
->int_mic_idx
= spec
->dock_mic_idx
= -1;
1117 fixed
= ext
= dock
= 0;
1118 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
1119 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
1120 unsigned int defcfg
;
1121 defcfg
= snd_hda_codec_get_pincfg(codec
, nid
);
1122 switch (snd_hda_get_input_pin_attr(defcfg
)) {
1123 case INPUT_PIN_ATTR_INT
:
1125 return; /* already occupied */
1126 if (cfg
->inputs
[i
].type
!= AUTO_PIN_MIC
)
1127 return; /* invalid type */
1130 case INPUT_PIN_ATTR_UNUSED
:
1131 return; /* invalid entry */
1132 case INPUT_PIN_ATTR_DOCK
:
1134 return; /* already occupied */
1135 if (cfg
->inputs
[i
].type
> AUTO_PIN_LINE_IN
)
1136 return; /* invalid type */
1141 return; /* already occupied */
1142 if (cfg
->inputs
[i
].type
!= AUTO_PIN_MIC
)
1143 return; /* invalid type */
1154 if (!is_jack_detectable(codec
, ext
))
1155 return; /* no unsol support */
1156 if (dock
&& !is_jack_detectable(codec
, dock
))
1157 return; /* no unsol support */
1159 /* check imux indices */
1160 spec
->ext_mic_pin
= ext
;
1161 spec
->int_mic_pin
= fixed
;
1162 spec
->dock_mic_pin
= dock
;
1165 if (!alc_auto_mic_check_imux(codec
))
1168 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
1170 spec
->unsol_event
= alc_sku_unsol_event
;
1173 /* check the availabilities of auto-mute and auto-mic switches */
1174 static void alc_auto_check_switches(struct hda_codec
*codec
)
1176 alc_init_automute(codec
);
1177 alc_init_auto_mic(codec
);
1181 * Realtek SSID verification
1184 /* Could be any non-zero and even value. When used as fixup, tells
1185 * the driver to ignore any present sku defines.
1187 #define ALC_FIXUP_SKU_IGNORE (2)
1189 static void alc_fixup_sku_ignore(struct hda_codec
*codec
,
1190 const struct hda_fixup
*fix
, int action
)
1192 struct alc_spec
*spec
= codec
->spec
;
1193 if (action
== HDA_FIXUP_ACT_PRE_PROBE
) {
1194 spec
->cdefine
.fixup
= 1;
1195 spec
->cdefine
.sku_cfg
= ALC_FIXUP_SKU_IGNORE
;
1199 static int alc_auto_parse_customize_define(struct hda_codec
*codec
)
1201 unsigned int ass
, tmp
, i
;
1203 struct alc_spec
*spec
= codec
->spec
;
1205 spec
->cdefine
.enable_pcbeep
= 1; /* assume always enabled */
1207 if (spec
->cdefine
.fixup
) {
1208 ass
= spec
->cdefine
.sku_cfg
;
1209 if (ass
== ALC_FIXUP_SKU_IGNORE
)
1214 ass
= codec
->subsystem_id
& 0xffff;
1215 if (ass
!= codec
->bus
->pci
->subsystem_device
&& (ass
& 1))
1219 if (codec
->vendor_id
== 0x10ec0260)
1221 ass
= snd_hda_codec_get_pincfg(codec
, nid
);
1224 printk(KERN_INFO
"hda_codec: %s: SKU not ready 0x%08x\n",
1225 codec
->chip_name
, ass
);
1231 for (i
= 1; i
< 16; i
++) {
1235 if (((ass
>> 16) & 0xf) != tmp
)
1238 spec
->cdefine
.port_connectivity
= ass
>> 30;
1239 spec
->cdefine
.enable_pcbeep
= (ass
& 0x100000) >> 20;
1240 spec
->cdefine
.check_sum
= (ass
>> 16) & 0xf;
1241 spec
->cdefine
.customization
= ass
>> 8;
1243 spec
->cdefine
.sku_cfg
= ass
;
1244 spec
->cdefine
.external_amp
= (ass
& 0x38) >> 3;
1245 spec
->cdefine
.platform_type
= (ass
& 0x4) >> 2;
1246 spec
->cdefine
.swap
= (ass
& 0x2) >> 1;
1247 spec
->cdefine
.override
= ass
& 0x1;
1249 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1250 nid
, spec
->cdefine
.sku_cfg
);
1251 snd_printd("SKU: port_connectivity=0x%x\n",
1252 spec
->cdefine
.port_connectivity
);
1253 snd_printd("SKU: enable_pcbeep=0x%x\n", spec
->cdefine
.enable_pcbeep
);
1254 snd_printd("SKU: check_sum=0x%08x\n", spec
->cdefine
.check_sum
);
1255 snd_printd("SKU: customization=0x%08x\n", spec
->cdefine
.customization
);
1256 snd_printd("SKU: external_amp=0x%x\n", spec
->cdefine
.external_amp
);
1257 snd_printd("SKU: platform_type=0x%x\n", spec
->cdefine
.platform_type
);
1258 snd_printd("SKU: swap=0x%x\n", spec
->cdefine
.swap
);
1259 snd_printd("SKU: override=0x%x\n", spec
->cdefine
.override
);
1264 /* return true if the given NID is found in the list */
1265 static bool found_in_nid_list(hda_nid_t nid
, const hda_nid_t
*list
, int nums
)
1267 return find_idx_in_nid_list(nid
, list
, nums
) >= 0;
1270 /* check subsystem ID and set up device-specific initialization;
1271 * return 1 if initialized, 0 if invalid SSID
1273 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1274 * 31 ~ 16 : Manufacture ID
1276 * 7 ~ 0 : Assembly ID
1277 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1279 static int alc_subsystem_id(struct hda_codec
*codec
,
1280 hda_nid_t porta
, hda_nid_t porte
,
1281 hda_nid_t portd
, hda_nid_t porti
)
1283 unsigned int ass
, tmp
, i
;
1285 struct alc_spec
*spec
= codec
->spec
;
1287 if (spec
->cdefine
.fixup
) {
1288 ass
= spec
->cdefine
.sku_cfg
;
1289 if (ass
== ALC_FIXUP_SKU_IGNORE
)
1294 ass
= codec
->subsystem_id
& 0xffff;
1295 if ((ass
!= codec
->bus
->pci
->subsystem_device
) && (ass
& 1))
1298 /* invalid SSID, check the special NID pin defcfg instead */
1300 * 31~30 : port connectivity
1303 * 19~16 : Check sum (15:1)
1308 if (codec
->vendor_id
== 0x10ec0260)
1310 ass
= snd_hda_codec_get_pincfg(codec
, nid
);
1311 snd_printd("realtek: No valid SSID, "
1312 "checking pincfg 0x%08x for NID 0x%x\n",
1316 if ((ass
>> 30) != 1) /* no physical connection */
1321 for (i
= 1; i
< 16; i
++) {
1325 if (((ass
>> 16) & 0xf) != tmp
)
1328 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1329 ass
& 0xffff, codec
->vendor_id
);
1333 * 2 : 0 --> Desktop, 1 --> Laptop
1334 * 3~5 : External Amplifier control
1337 tmp
= (ass
& 0x38) >> 3; /* external Amp control */
1340 spec
->init_amp
= ALC_INIT_GPIO1
;
1343 spec
->init_amp
= ALC_INIT_GPIO2
;
1346 spec
->init_amp
= ALC_INIT_GPIO3
;
1350 spec
->init_amp
= ALC_INIT_DEFAULT
;
1354 /* is laptop or Desktop and enable the function "Mute internal speaker
1355 * when the external headphone out jack is plugged"
1357 if (!(ass
& 0x8000))
1360 * 10~8 : Jack location
1361 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1363 * 15 : 1 --> enable the function "Mute internal speaker
1364 * when the external headphone out jack is plugged"
1366 if (!spec
->autocfg
.hp_pins
[0] &&
1367 !(spec
->autocfg
.line_out_pins
[0] &&
1368 spec
->autocfg
.line_out_type
== AUTO_PIN_HP_OUT
)) {
1370 tmp
= (ass
>> 11) & 0x3; /* HP to chassis */
1381 if (found_in_nid_list(nid
, spec
->autocfg
.line_out_pins
,
1382 spec
->autocfg
.line_outs
))
1384 spec
->autocfg
.hp_pins
[0] = nid
;
1389 /* Check the validity of ALC subsystem-id
1390 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
1391 static void alc_ssid_check(struct hda_codec
*codec
, const hda_nid_t
*ports
)
1393 if (!alc_subsystem_id(codec
, ports
[0], ports
[1], ports
[2], ports
[3])) {
1394 struct alc_spec
*spec
= codec
->spec
;
1395 snd_printd("realtek: "
1396 "Enable default setup for auto mode as fallback\n");
1397 spec
->init_amp
= ALC_INIT_DEFAULT
;
1402 * COEF access helper functions
1404 static int alc_read_coef_idx(struct hda_codec
*codec
,
1405 unsigned int coef_idx
)
1408 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
,
1410 val
= snd_hda_codec_read(codec
, 0x20, 0,
1411 AC_VERB_GET_PROC_COEF
, 0);
1415 static void alc_write_coef_idx(struct hda_codec
*codec
, unsigned int coef_idx
,
1416 unsigned int coef_val
)
1418 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
,
1420 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_PROC_COEF
,
1424 /* a special bypass for COEF 0; read the cached value at the second time */
1425 static unsigned int alc_get_coef0(struct hda_codec
*codec
)
1427 struct alc_spec
*spec
= codec
->spec
;
1429 spec
->coef0
= alc_read_coef_idx(codec
, 0);
1434 * Digital I/O handling
1437 /* set right pin controls for digital I/O */
1438 static void alc_auto_init_digital(struct hda_codec
*codec
)
1440 struct alc_spec
*spec
= codec
->spec
;
1444 for (i
= 0; i
< spec
->autocfg
.dig_outs
; i
++) {
1445 pin
= spec
->autocfg
.dig_out_pins
[i
];
1448 snd_hda_set_pin_ctl(codec
, pin
, PIN_OUT
);
1450 dac
= spec
->multiout
.dig_out_nid
;
1452 dac
= spec
->slave_dig_outs
[i
- 1];
1453 if (!dac
|| !(get_wcaps(codec
, dac
) & AC_WCAP_OUT_AMP
))
1455 snd_hda_codec_write(codec
, dac
, 0,
1456 AC_VERB_SET_AMP_GAIN_MUTE
,
1459 pin
= spec
->autocfg
.dig_in_pin
;
1461 snd_hda_set_pin_ctl(codec
, pin
, PIN_IN
);
1464 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1465 static void alc_auto_parse_digital(struct hda_codec
*codec
)
1467 struct alc_spec
*spec
= codec
->spec
;
1471 /* support multiple SPDIFs; the secondary is set up as a slave */
1473 for (i
= 0; i
< spec
->autocfg
.dig_outs
; i
++) {
1475 err
= snd_hda_get_connections(codec
,
1476 spec
->autocfg
.dig_out_pins
[i
],
1477 conn
, ARRAY_SIZE(conn
));
1480 dig_nid
= conn
[0]; /* assume the first element is audio-out */
1482 spec
->multiout
.dig_out_nid
= dig_nid
;
1483 spec
->dig_out_type
= spec
->autocfg
.dig_out_type
[0];
1485 spec
->multiout
.slave_dig_outs
= spec
->slave_dig_outs
;
1486 if (nums
>= ARRAY_SIZE(spec
->slave_dig_outs
) - 1)
1488 spec
->slave_dig_outs
[nums
- 1] = dig_nid
;
1493 if (spec
->autocfg
.dig_in_pin
) {
1494 dig_nid
= codec
->start_nid
;
1495 for (i
= 0; i
< codec
->num_nodes
; i
++, dig_nid
++) {
1496 unsigned int wcaps
= get_wcaps(codec
, dig_nid
);
1497 if (get_wcaps_type(wcaps
) != AC_WID_AUD_IN
)
1499 if (!(wcaps
& AC_WCAP_DIGITAL
))
1501 if (!(wcaps
& AC_WCAP_CONN_LIST
))
1503 err
= get_connection_index(codec
, dig_nid
,
1504 spec
->autocfg
.dig_in_pin
);
1506 spec
->dig_in_nid
= dig_nid
;
1514 * capture mixer elements
1516 static int alc_cap_vol_info(struct snd_kcontrol
*kcontrol
,
1517 struct snd_ctl_elem_info
*uinfo
)
1519 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1520 struct alc_spec
*spec
= codec
->spec
;
1524 mutex_lock(&codec
->control_mutex
);
1525 if (spec
->vol_in_capsrc
)
1526 val
= HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[0], 3, 0, HDA_OUTPUT
);
1528 val
= HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[0], 3, 0, HDA_INPUT
);
1529 kcontrol
->private_value
= val
;
1530 err
= snd_hda_mixer_amp_volume_info(kcontrol
, uinfo
);
1531 mutex_unlock(&codec
->control_mutex
);
1535 static int alc_cap_vol_tlv(struct snd_kcontrol
*kcontrol
, int op_flag
,
1536 unsigned int size
, unsigned int __user
*tlv
)
1538 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1539 struct alc_spec
*spec
= codec
->spec
;
1543 mutex_lock(&codec
->control_mutex
);
1544 if (spec
->vol_in_capsrc
)
1545 val
= HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[0], 3, 0, HDA_OUTPUT
);
1547 val
= HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[0], 3, 0, HDA_INPUT
);
1548 kcontrol
->private_value
= val
;
1549 err
= snd_hda_mixer_amp_tlv(kcontrol
, op_flag
, size
, tlv
);
1550 mutex_unlock(&codec
->control_mutex
);
1554 typedef int (*getput_call_t
)(struct snd_kcontrol
*kcontrol
,
1555 struct snd_ctl_elem_value
*ucontrol
);
1557 static int alc_cap_getput_caller(struct snd_kcontrol
*kcontrol
,
1558 struct snd_ctl_elem_value
*ucontrol
,
1559 getput_call_t func
, bool check_adc_switch
)
1561 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1562 struct alc_spec
*spec
= codec
->spec
;
1565 mutex_lock(&codec
->control_mutex
);
1566 if (check_adc_switch
&& spec
->dyn_adc_switch
) {
1567 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
1568 kcontrol
->private_value
=
1569 HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[i
],
1571 err
= func(kcontrol
, ucontrol
);
1576 i
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
1577 if (spec
->vol_in_capsrc
)
1578 kcontrol
->private_value
=
1579 HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[i
],
1582 kcontrol
->private_value
=
1583 HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[i
],
1585 err
= func(kcontrol
, ucontrol
);
1588 mutex_unlock(&codec
->control_mutex
);
1592 static int alc_cap_vol_get(struct snd_kcontrol
*kcontrol
,
1593 struct snd_ctl_elem_value
*ucontrol
)
1595 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1596 snd_hda_mixer_amp_volume_get
, false);
1599 static int alc_cap_vol_put(struct snd_kcontrol
*kcontrol
,
1600 struct snd_ctl_elem_value
*ucontrol
)
1602 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1603 snd_hda_mixer_amp_volume_put
, true);
1606 /* capture mixer elements */
1607 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1609 static int alc_cap_sw_get(struct snd_kcontrol
*kcontrol
,
1610 struct snd_ctl_elem_value
*ucontrol
)
1612 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1613 snd_hda_mixer_amp_switch_get
, false);
1616 static int alc_cap_sw_put(struct snd_kcontrol
*kcontrol
,
1617 struct snd_ctl_elem_value
*ucontrol
)
1619 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1620 snd_hda_mixer_amp_switch_put
, true);
1623 #define _DEFINE_CAPMIX(num) \
1625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1626 .name = "Capture Switch", \
1627 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1629 .info = alc_cap_sw_info, \
1630 .get = alc_cap_sw_get, \
1631 .put = alc_cap_sw_put, \
1634 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1635 .name = "Capture Volume", \
1636 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1637 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1638 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1640 .info = alc_cap_vol_info, \
1641 .get = alc_cap_vol_get, \
1642 .put = alc_cap_vol_put, \
1643 .tlv = { .c = alc_cap_vol_tlv }, \
1646 #define _DEFINE_CAPSRC(num) \
1648 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1649 /* .name = "Capture Source", */ \
1650 .name = "Input Source", \
1652 .info = alc_mux_enum_info, \
1653 .get = alc_mux_enum_get, \
1654 .put = alc_mux_enum_put, \
1657 #define DEFINE_CAPMIX(num) \
1658 static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1659 _DEFINE_CAPMIX(num), \
1660 _DEFINE_CAPSRC(num), \
1664 #define DEFINE_CAPMIX_NOSRC(num) \
1665 static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1666 _DEFINE_CAPMIX(num), \
1670 /* up to three ADCs */
1674 DEFINE_CAPMIX_NOSRC(1);
1675 DEFINE_CAPMIX_NOSRC(2);
1676 DEFINE_CAPMIX_NOSRC(3);
1679 * virtual master controls
1683 * slave controls for virtual master
1685 static const char * const alc_slave_pfxs
[] = {
1686 "Front", "Surround", "Center", "LFE", "Side",
1687 "Headphone", "Speaker", "Mono", "Line Out",
1688 "CLFE", "Bass Speaker", "PCM",
1693 * build control elements
1696 #define NID_MAPPING (-1)
1698 #define SUBDEV_SPEAKER_ (0 << 6)
1699 #define SUBDEV_HP_ (1 << 6)
1700 #define SUBDEV_LINE_ (2 << 6)
1701 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
1702 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
1703 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
1705 static void alc_free_kctls(struct hda_codec
*codec
);
1707 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1708 /* additional beep mixers; the actual parameters are overwritten at build */
1709 static const struct snd_kcontrol_new alc_beep_mixer
[] = {
1710 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT
),
1711 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT
),
1716 static int __alc_build_controls(struct hda_codec
*codec
)
1718 struct alc_spec
*spec
= codec
->spec
;
1719 struct snd_kcontrol
*kctl
= NULL
;
1720 const struct snd_kcontrol_new
*knew
;
1725 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1726 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
1730 if (spec
->cap_mixer
) {
1731 err
= snd_hda_add_new_ctls(codec
, spec
->cap_mixer
);
1735 if (spec
->multiout
.dig_out_nid
) {
1736 err
= snd_hda_create_spdif_out_ctls(codec
,
1737 spec
->multiout
.dig_out_nid
,
1738 spec
->multiout
.dig_out_nid
);
1741 if (!spec
->no_analog
) {
1742 err
= snd_hda_create_spdif_share_sw(codec
,
1746 spec
->multiout
.share_spdif
= 1;
1749 if (spec
->dig_in_nid
) {
1750 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
1755 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1756 /* create beep controls if needed */
1757 if (spec
->beep_amp
) {
1758 const struct snd_kcontrol_new
*knew
;
1759 for (knew
= alc_beep_mixer
; knew
->name
; knew
++) {
1760 struct snd_kcontrol
*kctl
;
1761 kctl
= snd_ctl_new1(knew
, codec
);
1764 kctl
->private_value
= spec
->beep_amp
;
1765 err
= snd_hda_ctl_add(codec
, 0, kctl
);
1772 /* if we have no master control, let's create it */
1773 if (!spec
->no_analog
&&
1774 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
1775 unsigned int vmaster_tlv
[4];
1776 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
1777 HDA_OUTPUT
, vmaster_tlv
);
1778 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
1779 vmaster_tlv
, alc_slave_pfxs
,
1784 if (!spec
->no_analog
&&
1785 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
1786 err
= __snd_hda_add_vmaster(codec
, "Master Playback Switch",
1787 NULL
, alc_slave_pfxs
,
1789 true, &spec
->vmaster_mute
.sw_kctl
);
1794 /* assign Capture Source enums to NID */
1795 if (spec
->capsrc_nids
|| spec
->adc_nids
) {
1796 kctl
= snd_hda_find_mixer_ctl(codec
, "Capture Source");
1798 kctl
= snd_hda_find_mixer_ctl(codec
, "Input Source");
1799 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
1800 err
= snd_hda_add_nid(codec
, kctl
, i
,
1801 get_capsrc(spec
, i
));
1806 if (spec
->cap_mixer
&& spec
->adc_nids
) {
1807 const char *kname
= kctl
? kctl
->id
.name
: NULL
;
1808 for (knew
= spec
->cap_mixer
; knew
->name
; knew
++) {
1809 if (kname
&& strcmp(knew
->name
, kname
) == 0)
1811 kctl
= snd_hda_find_mixer_ctl(codec
, knew
->name
);
1812 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
1813 err
= snd_hda_add_nid(codec
, kctl
, i
,
1821 /* other nid->control mapping */
1822 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1823 for (knew
= spec
->mixers
[i
]; knew
->name
; knew
++) {
1824 if (knew
->iface
!= NID_MAPPING
)
1826 kctl
= snd_hda_find_mixer_ctl(codec
, knew
->name
);
1829 u
= knew
->subdevice
;
1830 for (j
= 0; j
< 4; j
++, u
>>= 8) {
1835 case SUBDEV_SPEAKER_
:
1836 nid
= spec
->autocfg
.speaker_pins
[nid
];
1839 nid
= spec
->autocfg
.line_out_pins
[nid
];
1842 nid
= spec
->autocfg
.hp_pins
[nid
];
1847 err
= snd_hda_add_nid(codec
, kctl
, 0, nid
);
1851 u
= knew
->private_value
;
1852 for (j
= 0; j
< 4; j
++, u
>>= 8) {
1856 err
= snd_hda_add_nid(codec
, kctl
, 0, nid
);
1863 alc_free_kctls(codec
); /* no longer needed */
1868 static int alc_build_controls(struct hda_codec
*codec
)
1870 struct alc_spec
*spec
= codec
->spec
;
1871 int err
= __alc_build_controls(codec
);
1874 err
= snd_hda_jack_add_kctls(codec
, &spec
->autocfg
);
1877 alc_apply_fixup(codec
, ALC_FIXUP_ACT_BUILD
);
1886 static void alc_init_special_input_src(struct hda_codec
*codec
);
1887 static void alc_auto_init_std(struct hda_codec
*codec
);
1889 static int alc_init(struct hda_codec
*codec
)
1891 struct alc_spec
*spec
= codec
->spec
;
1893 if (spec
->init_hook
)
1894 spec
->init_hook(codec
);
1897 alc_auto_init_amp(codec
, spec
->init_amp
);
1899 alc_init_special_input_src(codec
);
1900 alc_auto_init_std(codec
);
1902 alc_apply_fixup(codec
, ALC_FIXUP_ACT_INIT
);
1904 snd_hda_jack_report_sync(codec
);
1906 hda_call_check_power_status(codec
, 0x01);
1910 static void alc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
1912 struct alc_spec
*spec
= codec
->spec
;
1914 if (spec
->unsol_event
)
1915 spec
->unsol_event(codec
, res
);
1918 #ifdef CONFIG_SND_HDA_POWER_SAVE
1919 static int alc_check_power_status(struct hda_codec
*codec
, hda_nid_t nid
)
1921 struct alc_spec
*spec
= codec
->spec
;
1922 return snd_hda_check_amp_list_power(codec
, &spec
->loopback
, nid
);
1927 * Analog playback callbacks
1929 static int alc_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
1930 struct hda_codec
*codec
,
1931 struct snd_pcm_substream
*substream
)
1933 struct alc_spec
*spec
= codec
->spec
;
1934 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
1938 static int alc_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
1939 struct hda_codec
*codec
,
1940 unsigned int stream_tag
,
1941 unsigned int format
,
1942 struct snd_pcm_substream
*substream
)
1944 struct alc_spec
*spec
= codec
->spec
;
1945 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
1946 stream_tag
, format
, substream
);
1949 static int alc_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
1950 struct hda_codec
*codec
,
1951 struct snd_pcm_substream
*substream
)
1953 struct alc_spec
*spec
= codec
->spec
;
1954 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
1960 static int alc_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
1961 struct hda_codec
*codec
,
1962 struct snd_pcm_substream
*substream
)
1964 struct alc_spec
*spec
= codec
->spec
;
1965 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
1968 static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
1969 struct hda_codec
*codec
,
1970 unsigned int stream_tag
,
1971 unsigned int format
,
1972 struct snd_pcm_substream
*substream
)
1974 struct alc_spec
*spec
= codec
->spec
;
1975 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
1976 stream_tag
, format
, substream
);
1979 static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
1980 struct hda_codec
*codec
,
1981 struct snd_pcm_substream
*substream
)
1983 struct alc_spec
*spec
= codec
->spec
;
1984 return snd_hda_multi_out_dig_cleanup(codec
, &spec
->multiout
);
1987 static int alc_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
1988 struct hda_codec
*codec
,
1989 struct snd_pcm_substream
*substream
)
1991 struct alc_spec
*spec
= codec
->spec
;
1992 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
1998 static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
1999 struct hda_codec
*codec
,
2000 unsigned int stream_tag
,
2001 unsigned int format
,
2002 struct snd_pcm_substream
*substream
)
2004 struct alc_spec
*spec
= codec
->spec
;
2006 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
+ 1],
2007 stream_tag
, 0, format
);
2011 static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2012 struct hda_codec
*codec
,
2013 struct snd_pcm_substream
*substream
)
2015 struct alc_spec
*spec
= codec
->spec
;
2017 snd_hda_codec_cleanup_stream(codec
,
2018 spec
->adc_nids
[substream
->number
+ 1]);
2022 /* analog capture with dynamic dual-adc changes */
2023 static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2024 struct hda_codec
*codec
,
2025 unsigned int stream_tag
,
2026 unsigned int format
,
2027 struct snd_pcm_substream
*substream
)
2029 struct alc_spec
*spec
= codec
->spec
;
2030 spec
->cur_adc
= spec
->adc_nids
[spec
->dyn_adc_idx
[spec
->cur_mux
[0]]];
2031 spec
->cur_adc_stream_tag
= stream_tag
;
2032 spec
->cur_adc_format
= format
;
2033 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
2037 static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2038 struct hda_codec
*codec
,
2039 struct snd_pcm_substream
*substream
)
2041 struct alc_spec
*spec
= codec
->spec
;
2042 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
2047 static const struct hda_pcm_stream dyn_adc_pcm_analog_capture
= {
2051 .nid
= 0, /* fill later */
2053 .prepare
= dyn_adc_capture_pcm_prepare
,
2054 .cleanup
= dyn_adc_capture_pcm_cleanup
2060 static const struct hda_pcm_stream alc_pcm_analog_playback
= {
2064 /* NID is set in alc_build_pcms */
2066 .open
= alc_playback_pcm_open
,
2067 .prepare
= alc_playback_pcm_prepare
,
2068 .cleanup
= alc_playback_pcm_cleanup
2072 static const struct hda_pcm_stream alc_pcm_analog_capture
= {
2076 /* NID is set in alc_build_pcms */
2079 static const struct hda_pcm_stream alc_pcm_analog_alt_playback
= {
2083 /* NID is set in alc_build_pcms */
2086 static const struct hda_pcm_stream alc_pcm_analog_alt_capture
= {
2087 .substreams
= 2, /* can be overridden */
2090 /* NID is set in alc_build_pcms */
2092 .prepare
= alc_alt_capture_pcm_prepare
,
2093 .cleanup
= alc_alt_capture_pcm_cleanup
2097 static const struct hda_pcm_stream alc_pcm_digital_playback
= {
2101 /* NID is set in alc_build_pcms */
2103 .open
= alc_dig_playback_pcm_open
,
2104 .close
= alc_dig_playback_pcm_close
,
2105 .prepare
= alc_dig_playback_pcm_prepare
,
2106 .cleanup
= alc_dig_playback_pcm_cleanup
2110 static const struct hda_pcm_stream alc_pcm_digital_capture
= {
2114 /* NID is set in alc_build_pcms */
2117 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2118 static const struct hda_pcm_stream alc_pcm_null_stream
= {
2124 static int alc_build_pcms(struct hda_codec
*codec
)
2126 struct alc_spec
*spec
= codec
->spec
;
2127 struct hda_pcm
*info
= spec
->pcm_rec
;
2128 const struct hda_pcm_stream
*p
;
2129 bool have_multi_adcs
;
2132 codec
->num_pcms
= 1;
2133 codec
->pcm_info
= info
;
2135 if (spec
->no_analog
)
2138 snprintf(spec
->stream_name_analog
, sizeof(spec
->stream_name_analog
),
2139 "%s Analog", codec
->chip_name
);
2140 info
->name
= spec
->stream_name_analog
;
2142 if (spec
->multiout
.num_dacs
> 0) {
2143 p
= spec
->stream_analog_playback
;
2145 p
= &alc_pcm_analog_playback
;
2146 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2147 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dac_nids
[0];
2149 if (spec
->adc_nids
) {
2150 p
= spec
->stream_analog_capture
;
2152 if (spec
->dyn_adc_switch
)
2153 p
= &dyn_adc_pcm_analog_capture
;
2155 p
= &alc_pcm_analog_capture
;
2157 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2158 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
2161 if (spec
->channel_mode
) {
2162 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= 0;
2163 for (i
= 0; i
< spec
->num_channel_mode
; i
++) {
2164 if (spec
->channel_mode
[i
].channels
> info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
) {
2165 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= spec
->channel_mode
[i
].channels
;
2171 /* SPDIF for stream index #1 */
2172 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
2173 snprintf(spec
->stream_name_digital
,
2174 sizeof(spec
->stream_name_digital
),
2175 "%s Digital", codec
->chip_name
);
2176 codec
->num_pcms
= 2;
2177 codec
->slave_dig_outs
= spec
->multiout
.slave_dig_outs
;
2178 info
= spec
->pcm_rec
+ 1;
2179 info
->name
= spec
->stream_name_digital
;
2180 if (spec
->dig_out_type
)
2181 info
->pcm_type
= spec
->dig_out_type
;
2183 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
2184 if (spec
->multiout
.dig_out_nid
) {
2185 p
= spec
->stream_digital_playback
;
2187 p
= &alc_pcm_digital_playback
;
2188 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2189 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
2191 if (spec
->dig_in_nid
) {
2192 p
= spec
->stream_digital_capture
;
2194 p
= &alc_pcm_digital_capture
;
2195 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2196 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
2198 /* FIXME: do we need this for all Realtek codec models? */
2199 codec
->spdif_status_reset
= 1;
2202 if (spec
->no_analog
)
2205 /* If the use of more than one ADC is requested for the current
2206 * model, configure a second analog capture-only PCM.
2208 have_multi_adcs
= (spec
->num_adc_nids
> 1) &&
2209 !spec
->dyn_adc_switch
&& !spec
->auto_mic
&&
2210 (!spec
->input_mux
|| spec
->input_mux
->num_items
> 1);
2211 /* Additional Analaog capture for index #2 */
2212 if (spec
->alt_dac_nid
|| have_multi_adcs
) {
2213 codec
->num_pcms
= 3;
2214 info
= spec
->pcm_rec
+ 2;
2215 info
->name
= spec
->stream_name_analog
;
2216 if (spec
->alt_dac_nid
) {
2217 p
= spec
->stream_analog_alt_playback
;
2219 p
= &alc_pcm_analog_alt_playback
;
2220 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2221 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
2224 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
2225 alc_pcm_null_stream
;
2226 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= 0;
2228 if (have_multi_adcs
) {
2229 p
= spec
->stream_analog_alt_capture
;
2231 p
= &alc_pcm_analog_alt_capture
;
2232 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2233 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
2235 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
=
2236 spec
->num_adc_nids
- 1;
2238 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
2239 alc_pcm_null_stream
;
2240 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= 0;
2247 static inline void alc_shutup(struct hda_codec
*codec
)
2249 struct alc_spec
*spec
= codec
->spec
;
2251 if (spec
&& spec
->shutup
)
2252 spec
->shutup(codec
);
2253 snd_hda_shutup_pins(codec
);
2256 static void alc_free_kctls(struct hda_codec
*codec
)
2258 struct alc_spec
*spec
= codec
->spec
;
2260 if (spec
->kctls
.list
) {
2261 struct snd_kcontrol_new
*kctl
= spec
->kctls
.list
;
2263 for (i
= 0; i
< spec
->kctls
.used
; i
++)
2264 kfree(kctl
[i
].name
);
2266 snd_array_free(&spec
->kctls
);
2269 static void alc_free_bind_ctls(struct hda_codec
*codec
)
2271 struct alc_spec
*spec
= codec
->spec
;
2272 if (spec
->bind_ctls
.list
) {
2273 struct hda_bind_ctls
**ctl
= spec
->bind_ctls
.list
;
2275 for (i
= 0; i
< spec
->bind_ctls
.used
; i
++)
2278 snd_array_free(&spec
->bind_ctls
);
2281 static void alc_free(struct hda_codec
*codec
)
2283 struct alc_spec
*spec
= codec
->spec
;
2289 alc_free_kctls(codec
);
2290 alc_free_bind_ctls(codec
);
2292 snd_hda_detach_beep_device(codec
);
2295 #ifdef CONFIG_SND_HDA_POWER_SAVE
2296 static void alc_power_eapd(struct hda_codec
*codec
)
2298 alc_auto_setup_eapd(codec
, false);
2301 static int alc_suspend(struct hda_codec
*codec
, pm_message_t state
)
2303 struct alc_spec
*spec
= codec
->spec
;
2305 if (spec
&& spec
->power_hook
)
2306 spec
->power_hook(codec
);
2312 static int alc_resume(struct hda_codec
*codec
)
2314 msleep(150); /* to avoid pop noise */
2315 codec
->patch_ops
.init(codec
);
2316 snd_hda_codec_resume_amp(codec
);
2317 snd_hda_codec_resume_cache(codec
);
2318 hda_call_check_power_status(codec
, 0x01);
2325 static const struct hda_codec_ops alc_patch_ops
= {
2326 .build_controls
= alc_build_controls
,
2327 .build_pcms
= alc_build_pcms
,
2330 .unsol_event
= alc_unsol_event
,
2332 .resume
= alc_resume
,
2334 #ifdef CONFIG_SND_HDA_POWER_SAVE
2335 .suspend
= alc_suspend
,
2336 .check_power_status
= alc_check_power_status
,
2338 .reboot_notify
= alc_shutup
,
2341 /* replace the codec chip_name with the given string */
2342 static int alc_codec_rename(struct hda_codec
*codec
, const char *name
)
2344 kfree(codec
->chip_name
);
2345 codec
->chip_name
= kstrdup(name
, GFP_KERNEL
);
2346 if (!codec
->chip_name
) {
2354 * Rename codecs appropriately from COEF value
2356 struct alc_codec_rename_table
{
2357 unsigned int vendor_id
;
2358 unsigned short coef_mask
;
2359 unsigned short coef_bits
;
2363 static struct alc_codec_rename_table rename_tbl
[] = {
2364 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
2365 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
2366 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
2367 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
2368 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
2369 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
2370 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
2371 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
2372 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
2373 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
2374 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
2375 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
2376 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
2377 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
2378 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
2379 { } /* terminator */
2382 static int alc_codec_rename_from_preset(struct hda_codec
*codec
)
2384 const struct alc_codec_rename_table
*p
;
2386 for (p
= rename_tbl
; p
->vendor_id
; p
++) {
2387 if (p
->vendor_id
!= codec
->vendor_id
)
2389 if ((alc_get_coef0(codec
) & p
->coef_mask
) == p
->coef_bits
)
2390 return alc_codec_rename(codec
, p
->name
);
2396 * Automatic parse of I/O pins from the BIOS configuration
2401 ALC_CTL_WIDGET_MUTE
,
2406 static const struct snd_kcontrol_new alc_control_templates
[] = {
2407 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2408 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2409 HDA_BIND_MUTE(NULL
, 0, 0, 0),
2410 HDA_BIND_VOL(NULL
, 0),
2411 HDA_BIND_SW(NULL
, 0),
2414 /* add dynamic controls */
2415 static int add_control(struct alc_spec
*spec
, int type
, const char *name
,
2416 int cidx
, unsigned long val
)
2418 struct snd_kcontrol_new
*knew
;
2420 knew
= alc_kcontrol_new(spec
);
2423 *knew
= alc_control_templates
[type
];
2424 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2428 if (get_amp_nid_(val
))
2429 knew
->subdevice
= HDA_SUBDEV_AMP_FLAG
;
2430 knew
->private_value
= val
;
2434 static int add_control_with_pfx(struct alc_spec
*spec
, int type
,
2435 const char *pfx
, const char *dir
,
2436 const char *sfx
, int cidx
, unsigned long val
)
2439 snprintf(name
, sizeof(name
), "%s %s %s", pfx
, dir
, sfx
);
2440 return add_control(spec
, type
, name
, cidx
, val
);
2443 #define add_pb_vol_ctrl(spec, type, pfx, val) \
2444 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
2445 #define add_pb_sw_ctrl(spec, type, pfx, val) \
2446 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
2447 #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
2448 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
2449 #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
2450 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
2452 static const char * const channel_name
[4] = {
2453 "Front", "Surround", "CLFE", "Side"
2456 static const char *alc_get_line_out_pfx(struct alc_spec
*spec
, int ch
,
2457 bool can_be_master
, int *index
)
2459 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2462 if (cfg
->line_outs
== 1 && !spec
->multi_ios
&&
2463 !cfg
->hp_outs
&& !cfg
->speaker_outs
&& can_be_master
)
2466 switch (cfg
->line_out_type
) {
2467 case AUTO_PIN_SPEAKER_OUT
:
2468 if (cfg
->line_outs
== 1)
2470 if (cfg
->line_outs
== 2)
2471 return ch
? "Bass Speaker" : "Speaker";
2473 case AUTO_PIN_HP_OUT
:
2474 /* for multi-io case, only the primary out */
2475 if (ch
&& spec
->multi_ios
)
2480 if (cfg
->line_outs
== 1 && !spec
->multi_ios
)
2484 if (snd_BUG_ON(ch
>= ARRAY_SIZE(channel_name
)))
2487 return channel_name
[ch
];
2490 #ifdef CONFIG_SND_HDA_POWER_SAVE
2491 /* add the powersave loopback-list entry */
2492 static void add_loopback_list(struct alc_spec
*spec
, hda_nid_t mix
, int idx
)
2494 struct hda_amp_list
*list
;
2496 if (spec
->num_loopbacks
>= ARRAY_SIZE(spec
->loopback_list
) - 1)
2498 list
= spec
->loopback_list
+ spec
->num_loopbacks
;
2500 list
->dir
= HDA_INPUT
;
2502 spec
->num_loopbacks
++;
2503 spec
->loopback
.amplist
= spec
->loopback_list
;
2506 #define add_loopback_list(spec, mix, idx) /* NOP */
2509 /* create input playback/capture controls for the given pin */
2510 static int new_analog_input(struct alc_spec
*spec
, hda_nid_t pin
,
2511 const char *ctlname
, int ctlidx
,
2512 int idx
, hda_nid_t mix_nid
)
2516 err
= __add_pb_vol_ctrl(spec
, ALC_CTL_WIDGET_VOL
, ctlname
, ctlidx
,
2517 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
));
2520 err
= __add_pb_sw_ctrl(spec
, ALC_CTL_WIDGET_MUTE
, ctlname
, ctlidx
,
2521 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
));
2524 add_loopback_list(spec
, mix_nid
, idx
);
2528 static int alc_is_input_pin(struct hda_codec
*codec
, hda_nid_t nid
)
2530 unsigned int pincap
= snd_hda_query_pin_caps(codec
, nid
);
2531 return (pincap
& AC_PINCAP_IN
) != 0;
2534 /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */
2535 static int alc_auto_fill_adc_caps(struct hda_codec
*codec
)
2537 struct alc_spec
*spec
= codec
->spec
;
2539 hda_nid_t
*adc_nids
= spec
->private_adc_nids
;
2540 hda_nid_t
*cap_nids
= spec
->private_capsrc_nids
;
2541 int max_nums
= ARRAY_SIZE(spec
->private_adc_nids
);
2544 nid
= codec
->start_nid
;
2545 for (i
= 0; i
< codec
->num_nodes
; i
++, nid
++) {
2547 unsigned int caps
= get_wcaps(codec
, nid
);
2548 int type
= get_wcaps_type(caps
);
2550 if (type
!= AC_WID_AUD_IN
|| (caps
& AC_WCAP_DIGITAL
))
2552 adc_nids
[nums
] = nid
;
2553 cap_nids
[nums
] = nid
;
2557 type
= get_wcaps_type(get_wcaps(codec
, src
));
2558 if (type
== AC_WID_PIN
)
2560 if (type
== AC_WID_AUD_SEL
) {
2561 cap_nids
[nums
] = src
;
2564 n
= snd_hda_get_num_conns(codec
, src
);
2566 cap_nids
[nums
] = src
;
2570 if (snd_hda_get_connections(codec
, src
, &src
, 1) != 1)
2573 if (++nums
>= max_nums
)
2576 spec
->adc_nids
= spec
->private_adc_nids
;
2577 spec
->capsrc_nids
= spec
->private_capsrc_nids
;
2578 spec
->num_adc_nids
= nums
;
2582 /* create playback/capture controls for input pins */
2583 static int alc_auto_create_input_ctls(struct hda_codec
*codec
)
2585 struct alc_spec
*spec
= codec
->spec
;
2586 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2587 hda_nid_t mixer
= spec
->mixer_nid
;
2588 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
2590 int i
, c
, err
, idx
, type_idx
= 0;
2591 const char *prev_label
= NULL
;
2593 num_adcs
= alc_auto_fill_adc_caps(codec
);
2597 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2601 pin
= cfg
->inputs
[i
].pin
;
2602 if (!alc_is_input_pin(codec
, pin
))
2605 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
2606 if (spec
->shared_mic_hp
&& !strcmp(label
, "Misc"))
2607 label
= "Headphone Mic";
2608 if (prev_label
&& !strcmp(label
, prev_label
))
2615 idx
= get_connection_index(codec
, mixer
, pin
);
2617 err
= new_analog_input(spec
, pin
,
2625 for (c
= 0; c
< num_adcs
; c
++) {
2626 hda_nid_t cap
= get_capsrc(spec
, c
);
2627 idx
= get_connection_index(codec
, cap
, pin
);
2629 spec
->imux_pins
[imux
->num_items
] = pin
;
2630 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
2636 spec
->num_mux_defs
= 1;
2637 spec
->input_mux
= imux
;
2642 /* create a shared input with the headphone out */
2643 static int alc_auto_create_shared_input(struct hda_codec
*codec
)
2645 struct alc_spec
*spec
= codec
->spec
;
2646 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2647 unsigned int defcfg
;
2650 /* only one internal input pin? */
2651 if (cfg
->num_inputs
!= 1)
2653 defcfg
= snd_hda_codec_get_pincfg(codec
, cfg
->inputs
[0].pin
);
2654 if (snd_hda_get_input_pin_attr(defcfg
) != INPUT_PIN_ATTR_INT
)
2657 if (cfg
->hp_outs
== 1 && cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
)
2658 nid
= cfg
->hp_pins
[0]; /* OK, we have a single HP-out */
2659 else if (cfg
->line_outs
== 1 && cfg
->line_out_type
== AUTO_PIN_HP_OUT
)
2660 nid
= cfg
->line_out_pins
[0]; /* OK, we have a single line-out */
2662 return 0; /* both not available */
2664 if (!(snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_IN
))
2665 return 0; /* no input */
2667 cfg
->inputs
[1].pin
= nid
;
2668 cfg
->inputs
[1].type
= AUTO_PIN_MIC
;
2669 cfg
->num_inputs
= 2;
2670 spec
->shared_mic_hp
= 1;
2671 snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid
);
2675 static void alc_set_pin_output(struct hda_codec
*codec
, hda_nid_t nid
,
2676 unsigned int pin_type
)
2678 snd_hda_set_pin_ctl(codec
, nid
, pin_type
);
2680 if (nid_has_mute(codec
, nid
, HDA_OUTPUT
))
2681 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
2685 static int get_pin_type(int line_out_type
)
2687 if (line_out_type
== AUTO_PIN_HP_OUT
)
2693 static void alc_auto_init_analog_input(struct hda_codec
*codec
)
2695 struct alc_spec
*spec
= codec
->spec
;
2696 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2699 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2700 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
2701 if (alc_is_input_pin(codec
, nid
)) {
2702 alc_set_input_pin(codec
, nid
, cfg
->inputs
[i
].type
);
2703 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
2704 snd_hda_codec_write(codec
, nid
, 0,
2705 AC_VERB_SET_AMP_GAIN_MUTE
,
2710 /* mute all loopback inputs */
2711 if (spec
->mixer_nid
) {
2712 int nums
= snd_hda_get_num_conns(codec
, spec
->mixer_nid
);
2713 for (i
= 0; i
< nums
; i
++)
2714 snd_hda_codec_write(codec
, spec
->mixer_nid
, 0,
2715 AC_VERB_SET_AMP_GAIN_MUTE
,
2720 /* convert from MIX nid to DAC */
2721 static hda_nid_t
alc_auto_mix_to_dac(struct hda_codec
*codec
, hda_nid_t nid
)
2726 if (get_wcaps_type(get_wcaps(codec
, nid
)) == AC_WID_AUD_OUT
)
2728 num
= snd_hda_get_connections(codec
, nid
, list
, ARRAY_SIZE(list
));
2729 for (i
= 0; i
< num
; i
++) {
2730 if (get_wcaps_type(get_wcaps(codec
, list
[i
])) == AC_WID_AUD_OUT
)
2736 /* go down to the selector widget before the mixer */
2737 static hda_nid_t
alc_go_down_to_selector(struct hda_codec
*codec
, hda_nid_t pin
)
2740 int num
= snd_hda_get_connections(codec
, pin
, srcs
,
2743 get_wcaps_type(get_wcaps(codec
, srcs
[0])) != AC_WID_AUD_SEL
)
2748 /* get MIX nid connected to the given pin targeted to DAC */
2749 static hda_nid_t
alc_auto_dac_to_mix(struct hda_codec
*codec
, hda_nid_t pin
,
2755 pin
= alc_go_down_to_selector(codec
, pin
);
2756 num
= snd_hda_get_connections(codec
, pin
, mix
, ARRAY_SIZE(mix
));
2757 for (i
= 0; i
< num
; i
++) {
2758 if (alc_auto_mix_to_dac(codec
, mix
[i
]) == dac
)
2764 /* select the connection from pin to DAC if needed */
2765 static int alc_auto_select_dac(struct hda_codec
*codec
, hda_nid_t pin
,
2771 pin
= alc_go_down_to_selector(codec
, pin
);
2772 num
= snd_hda_get_connections(codec
, pin
, mix
, ARRAY_SIZE(mix
));
2775 for (i
= 0; i
< num
; i
++) {
2776 if (alc_auto_mix_to_dac(codec
, mix
[i
]) == dac
) {
2777 snd_hda_codec_update_cache(codec
, pin
, 0,
2778 AC_VERB_SET_CONNECT_SEL
, i
);
2785 static bool alc_is_dac_already_used(struct hda_codec
*codec
, hda_nid_t nid
)
2787 struct alc_spec
*spec
= codec
->spec
;
2789 if (found_in_nid_list(nid
, spec
->multiout
.dac_nids
,
2790 ARRAY_SIZE(spec
->private_dac_nids
)) ||
2791 found_in_nid_list(nid
, spec
->multiout
.hp_out_nid
,
2792 ARRAY_SIZE(spec
->multiout
.hp_out_nid
)) ||
2793 found_in_nid_list(nid
, spec
->multiout
.extra_out_nid
,
2794 ARRAY_SIZE(spec
->multiout
.extra_out_nid
)))
2796 for (i
= 0; i
< spec
->multi_ios
; i
++) {
2797 if (spec
->multi_io
[i
].dac
== nid
)
2803 /* look for an empty DAC slot */
2804 static hda_nid_t
alc_auto_look_for_dac(struct hda_codec
*codec
, hda_nid_t pin
)
2809 pin
= alc_go_down_to_selector(codec
, pin
);
2810 num
= snd_hda_get_connections(codec
, pin
, srcs
, ARRAY_SIZE(srcs
));
2811 for (i
= 0; i
< num
; i
++) {
2812 hda_nid_t nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
2815 if (!alc_is_dac_already_used(codec
, nid
))
2821 /* check whether the DAC is reachable from the pin */
2822 static bool alc_auto_is_dac_reachable(struct hda_codec
*codec
,
2823 hda_nid_t pin
, hda_nid_t dac
)
2830 pin
= alc_go_down_to_selector(codec
, pin
);
2831 num
= snd_hda_get_connections(codec
, pin
, srcs
, ARRAY_SIZE(srcs
));
2832 for (i
= 0; i
< num
; i
++) {
2833 hda_nid_t nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
2840 static hda_nid_t
get_dac_if_single(struct hda_codec
*codec
, hda_nid_t pin
)
2842 struct alc_spec
*spec
= codec
->spec
;
2843 hda_nid_t sel
= alc_go_down_to_selector(codec
, pin
);
2844 hda_nid_t nid
, nid_found
, srcs
[5];
2845 int i
, num
= snd_hda_get_connections(codec
, sel
, srcs
,
2848 return alc_auto_look_for_dac(codec
, pin
);
2850 for (i
= 0; i
< num
; i
++) {
2851 if (srcs
[i
] == spec
->mixer_nid
)
2853 nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
2854 if (nid
&& !alc_is_dac_already_used(codec
, nid
)) {
2863 /* mark up volume and mute control NIDs: used during badness parsing and
2864 * at creating actual controls
2866 static inline unsigned int get_ctl_pos(unsigned int data
)
2868 hda_nid_t nid
= get_amp_nid_(data
);
2870 if (snd_BUG_ON(nid
>= MAX_VOL_NIDS
))
2872 dir
= get_amp_direction_(data
);
2873 return (nid
<< 1) | dir
;
2876 #define is_ctl_used(bits, data) \
2877 test_bit(get_ctl_pos(data), bits)
2878 #define mark_ctl_usage(bits, data) \
2879 set_bit(get_ctl_pos(data), bits)
2881 static void clear_vol_marks(struct hda_codec
*codec
)
2883 struct alc_spec
*spec
= codec
->spec
;
2884 memset(spec
->vol_ctls
, 0, sizeof(spec
->vol_ctls
));
2885 memset(spec
->sw_ctls
, 0, sizeof(spec
->sw_ctls
));
2888 /* badness definition */
2890 /* No primary DAC is found for the main output */
2891 BAD_NO_PRIMARY_DAC
= 0x10000,
2892 /* No DAC is found for the extra output */
2893 BAD_NO_DAC
= 0x4000,
2894 /* No possible multi-ios */
2895 BAD_MULTI_IO
= 0x103,
2896 /* No individual DAC for extra output */
2897 BAD_NO_EXTRA_DAC
= 0x102,
2898 /* No individual DAC for extra surrounds */
2899 BAD_NO_EXTRA_SURR_DAC
= 0x101,
2900 /* Primary DAC shared with main surrounds */
2901 BAD_SHARED_SURROUND
= 0x100,
2902 /* Primary DAC shared with main CLFE */
2903 BAD_SHARED_CLFE
= 0x10,
2904 /* Primary DAC shared with extra surrounds */
2905 BAD_SHARED_EXTRA_SURROUND
= 0x10,
2906 /* Volume widget is shared */
2907 BAD_SHARED_VOL
= 0x10,
2910 static hda_nid_t
alc_look_for_out_mute_nid(struct hda_codec
*codec
,
2911 hda_nid_t pin
, hda_nid_t dac
);
2912 static hda_nid_t
alc_look_for_out_vol_nid(struct hda_codec
*codec
,
2913 hda_nid_t pin
, hda_nid_t dac
);
2915 static int eval_shared_vol_badness(struct hda_codec
*codec
, hda_nid_t pin
,
2918 struct alc_spec
*spec
= codec
->spec
;
2923 nid
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
2925 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
2926 if (is_ctl_used(spec
->vol_ctls
, nid
))
2927 badness
+= BAD_SHARED_VOL
;
2929 mark_ctl_usage(spec
->vol_ctls
, val
);
2931 badness
+= BAD_SHARED_VOL
;
2932 nid
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
2934 unsigned int wid_type
= get_wcaps_type(get_wcaps(codec
, nid
));
2935 if (wid_type
== AC_WID_PIN
|| wid_type
== AC_WID_AUD_OUT
)
2936 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
2938 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_INPUT
);
2939 if (is_ctl_used(spec
->sw_ctls
, val
))
2940 badness
+= BAD_SHARED_VOL
;
2942 mark_ctl_usage(spec
->sw_ctls
, val
);
2944 badness
+= BAD_SHARED_VOL
;
2948 struct badness_table
{
2949 int no_primary_dac
; /* no primary DAC */
2950 int no_dac
; /* no secondary DACs */
2951 int shared_primary
; /* primary DAC is shared with main output */
2952 int shared_surr
; /* secondary DAC shared with main or primary */
2953 int shared_clfe
; /* third DAC shared with main or primary */
2954 int shared_surr_main
; /* secondary DAC sahred with main/DAC0 */
2957 static struct badness_table main_out_badness
= {
2958 .no_primary_dac
= BAD_NO_PRIMARY_DAC
,
2959 .no_dac
= BAD_NO_DAC
,
2960 .shared_primary
= BAD_NO_PRIMARY_DAC
,
2961 .shared_surr
= BAD_SHARED_SURROUND
,
2962 .shared_clfe
= BAD_SHARED_CLFE
,
2963 .shared_surr_main
= BAD_SHARED_SURROUND
,
2966 static struct badness_table extra_out_badness
= {
2967 .no_primary_dac
= BAD_NO_DAC
,
2968 .no_dac
= BAD_NO_DAC
,
2969 .shared_primary
= BAD_NO_EXTRA_DAC
,
2970 .shared_surr
= BAD_SHARED_EXTRA_SURROUND
,
2971 .shared_clfe
= BAD_SHARED_EXTRA_SURROUND
,
2972 .shared_surr_main
= BAD_NO_EXTRA_SURR_DAC
,
2975 /* try to assign DACs to pins and return the resultant badness */
2976 static int alc_auto_fill_dacs(struct hda_codec
*codec
, int num_outs
,
2977 const hda_nid_t
*pins
, hda_nid_t
*dacs
,
2978 const struct badness_table
*bad
)
2980 struct alc_spec
*spec
= codec
->spec
;
2981 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2989 for (i
= 0; i
< num_outs
; i
++) {
2990 hda_nid_t pin
= pins
[i
];
2992 dacs
[i
] = alc_auto_look_for_dac(codec
, pin
);
2993 if (!dacs
[i
] && !i
) {
2994 for (j
= 1; j
< num_outs
; j
++) {
2995 if (alc_auto_is_dac_reachable(codec
, pin
, dacs
[j
])) {
3004 if (alc_auto_is_dac_reachable(codec
, pin
, dacs
[0]))
3006 else if (cfg
->line_outs
> i
&&
3007 alc_auto_is_dac_reachable(codec
, pin
,
3008 spec
->private_dac_nids
[i
]))
3009 dac
= spec
->private_dac_nids
[i
];
3012 badness
+= bad
->shared_primary
;
3014 badness
+= bad
->shared_surr
;
3016 badness
+= bad
->shared_clfe
;
3017 } else if (alc_auto_is_dac_reachable(codec
, pin
,
3018 spec
->private_dac_nids
[0])) {
3019 dac
= spec
->private_dac_nids
[0];
3020 badness
+= bad
->shared_surr_main
;
3022 badness
+= bad
->no_primary_dac
;
3024 badness
+= bad
->no_dac
;
3027 badness
+= eval_shared_vol_badness(codec
, pin
, dac
);
3033 static int alc_auto_fill_multi_ios(struct hda_codec
*codec
,
3034 hda_nid_t reference_pin
,
3035 bool hardwired
, int offset
);
3037 static bool alc_map_singles(struct hda_codec
*codec
, int outs
,
3038 const hda_nid_t
*pins
, hda_nid_t
*dacs
)
3042 for (i
= 0; i
< outs
; i
++) {
3045 dacs
[i
] = get_dac_if_single(codec
, pins
[i
]);
3052 /* fill in the dac_nids table from the parsed pin configuration */
3053 static int fill_and_eval_dacs(struct hda_codec
*codec
,
3054 bool fill_hardwired
,
3055 bool fill_mio_first
)
3057 struct alc_spec
*spec
= codec
->spec
;
3058 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3059 int i
, err
, badness
;
3061 /* set num_dacs once to full for alc_auto_look_for_dac() */
3062 spec
->multiout
.num_dacs
= cfg
->line_outs
;
3063 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3064 memset(spec
->private_dac_nids
, 0, sizeof(spec
->private_dac_nids
));
3065 memset(spec
->multiout
.hp_out_nid
, 0, sizeof(spec
->multiout
.hp_out_nid
));
3066 memset(spec
->multiout
.extra_out_nid
, 0, sizeof(spec
->multiout
.extra_out_nid
));
3067 spec
->multi_ios
= 0;
3068 clear_vol_marks(codec
);
3071 /* fill hard-wired DACs first */
3072 if (fill_hardwired
) {
3075 mapped
= alc_map_singles(codec
, cfg
->line_outs
,
3077 spec
->private_dac_nids
);
3078 mapped
|= alc_map_singles(codec
, cfg
->hp_outs
,
3080 spec
->multiout
.hp_out_nid
);
3081 mapped
|= alc_map_singles(codec
, cfg
->speaker_outs
,
3083 spec
->multiout
.extra_out_nid
);
3084 if (fill_mio_first
&& cfg
->line_outs
== 1 &&
3085 cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3086 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], true, 0);
3093 badness
+= alc_auto_fill_dacs(codec
, cfg
->line_outs
, cfg
->line_out_pins
,
3094 spec
->private_dac_nids
,
3097 /* re-count num_dacs and squash invalid entries */
3098 spec
->multiout
.num_dacs
= 0;
3099 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3100 if (spec
->private_dac_nids
[i
])
3101 spec
->multiout
.num_dacs
++;
3103 memmove(spec
->private_dac_nids
+ i
,
3104 spec
->private_dac_nids
+ i
+ 1,
3105 sizeof(hda_nid_t
) * (cfg
->line_outs
- i
- 1));
3106 spec
->private_dac_nids
[cfg
->line_outs
- 1] = 0;
3110 if (fill_mio_first
&&
3111 cfg
->line_outs
== 1 && cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3112 /* try to fill multi-io first */
3113 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], false, 0);
3116 /* we don't count badness at this stage yet */
3119 if (cfg
->line_out_type
!= AUTO_PIN_HP_OUT
) {
3120 err
= alc_auto_fill_dacs(codec
, cfg
->hp_outs
, cfg
->hp_pins
,
3121 spec
->multiout
.hp_out_nid
,
3122 &extra_out_badness
);
3127 if (cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3128 err
= alc_auto_fill_dacs(codec
, cfg
->speaker_outs
,
3130 spec
->multiout
.extra_out_nid
,
3131 &extra_out_badness
);
3136 if (cfg
->line_outs
== 1 && cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3137 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], false, 0);
3142 if (cfg
->hp_outs
&& cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
3143 /* try multi-ios with HP + inputs */
3145 if (cfg
->line_outs
>= 3)
3147 err
= alc_auto_fill_multi_ios(codec
, cfg
->hp_pins
[0], false,
3154 if (spec
->multi_ios
== 2) {
3155 for (i
= 0; i
< 2; i
++)
3156 spec
->private_dac_nids
[spec
->multiout
.num_dacs
++] =
3157 spec
->multi_io
[i
].dac
;
3158 spec
->ext_channel_count
= 2;
3159 } else if (spec
->multi_ios
) {
3160 spec
->multi_ios
= 0;
3161 badness
+= BAD_MULTI_IO
;
3167 #define DEBUG_BADNESS
3169 #ifdef DEBUG_BADNESS
3170 #define debug_badness snd_printdd
3172 #define debug_badness(...)
3175 static void debug_show_configs(struct alc_spec
*spec
, struct auto_pin_cfg
*cfg
)
3177 debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3178 cfg
->line_out_pins
[0], cfg
->line_out_pins
[1],
3179 cfg
->line_out_pins
[2], cfg
->line_out_pins
[2],
3180 spec
->multiout
.dac_nids
[0],
3181 spec
->multiout
.dac_nids
[1],
3182 spec
->multiout
.dac_nids
[2],
3183 spec
->multiout
.dac_nids
[3]);
3184 if (spec
->multi_ios
> 0)
3185 debug_badness("multi_ios(%d) = %x/%x : %x/%x\n",
3187 spec
->multi_io
[0].pin
, spec
->multi_io
[1].pin
,
3188 spec
->multi_io
[0].dac
, spec
->multi_io
[1].dac
);
3189 debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3190 cfg
->hp_pins
[0], cfg
->hp_pins
[1],
3191 cfg
->hp_pins
[2], cfg
->hp_pins
[2],
3192 spec
->multiout
.hp_out_nid
[0],
3193 spec
->multiout
.hp_out_nid
[1],
3194 spec
->multiout
.hp_out_nid
[2],
3195 spec
->multiout
.hp_out_nid
[3]);
3196 debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3197 cfg
->speaker_pins
[0], cfg
->speaker_pins
[1],
3198 cfg
->speaker_pins
[2], cfg
->speaker_pins
[3],
3199 spec
->multiout
.extra_out_nid
[0],
3200 spec
->multiout
.extra_out_nid
[1],
3201 spec
->multiout
.extra_out_nid
[2],
3202 spec
->multiout
.extra_out_nid
[3]);
3205 static int alc_auto_fill_dac_nids(struct hda_codec
*codec
)
3207 struct alc_spec
*spec
= codec
->spec
;
3208 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3209 struct auto_pin_cfg
*best_cfg
;
3210 int best_badness
= INT_MAX
;
3212 bool fill_hardwired
= true, fill_mio_first
= true;
3213 bool best_wired
= true, best_mio
= true;
3214 bool hp_spk_swapped
= false;
3216 best_cfg
= kmalloc(sizeof(*best_cfg
), GFP_KERNEL
);
3222 badness
= fill_and_eval_dacs(codec
, fill_hardwired
,
3228 debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n",
3229 cfg
->line_out_type
, fill_hardwired
, fill_mio_first
,
3231 debug_show_configs(spec
, cfg
);
3232 if (badness
< best_badness
) {
3233 best_badness
= badness
;
3235 best_wired
= fill_hardwired
;
3236 best_mio
= fill_mio_first
;
3240 fill_mio_first
= !fill_mio_first
;
3241 if (!fill_mio_first
)
3243 fill_hardwired
= !fill_hardwired
;
3244 if (!fill_hardwired
)
3248 hp_spk_swapped
= true;
3249 if (cfg
->speaker_outs
> 0 &&
3250 cfg
->line_out_type
== AUTO_PIN_HP_OUT
) {
3251 cfg
->hp_outs
= cfg
->line_outs
;
3252 memcpy(cfg
->hp_pins
, cfg
->line_out_pins
,
3253 sizeof(cfg
->hp_pins
));
3254 cfg
->line_outs
= cfg
->speaker_outs
;
3255 memcpy(cfg
->line_out_pins
, cfg
->speaker_pins
,
3256 sizeof(cfg
->speaker_pins
));
3257 cfg
->speaker_outs
= 0;
3258 memset(cfg
->speaker_pins
, 0, sizeof(cfg
->speaker_pins
));
3259 cfg
->line_out_type
= AUTO_PIN_SPEAKER_OUT
;
3260 fill_hardwired
= true;
3263 if (cfg
->hp_outs
> 0 &&
3264 cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
3265 cfg
->speaker_outs
= cfg
->line_outs
;
3266 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
3267 sizeof(cfg
->speaker_pins
));
3268 cfg
->line_outs
= cfg
->hp_outs
;
3269 memcpy(cfg
->line_out_pins
, cfg
->hp_pins
,
3270 sizeof(cfg
->hp_pins
));
3272 memset(cfg
->hp_pins
, 0, sizeof(cfg
->hp_pins
));
3273 cfg
->line_out_type
= AUTO_PIN_HP_OUT
;
3274 fill_hardwired
= true;
3282 fill_and_eval_dacs(codec
, best_wired
, best_mio
);
3284 debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n",
3285 cfg
->line_out_type
, best_wired
, best_mio
);
3286 debug_show_configs(spec
, cfg
);
3288 if (cfg
->line_out_pins
[0])
3290 alc_look_for_out_vol_nid(codec
, cfg
->line_out_pins
[0],
3291 spec
->multiout
.dac_nids
[0]);
3293 /* clear the bitmap flags for creating controls */
3294 clear_vol_marks(codec
);
3299 static int alc_auto_add_vol_ctl(struct hda_codec
*codec
,
3300 const char *pfx
, int cidx
,
3301 hda_nid_t nid
, unsigned int chs
)
3303 struct alc_spec
*spec
= codec
->spec
;
3307 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
);
3308 if (is_ctl_used(spec
->vol_ctls
, val
) && chs
!= 2) /* exclude LFE */
3310 mark_ctl_usage(spec
->vol_ctls
, val
);
3311 return __add_pb_vol_ctrl(codec
->spec
, ALC_CTL_WIDGET_VOL
, pfx
, cidx
,
3315 static int alc_auto_add_stereo_vol(struct hda_codec
*codec
,
3316 const char *pfx
, int cidx
,
3320 if (get_wcaps(codec
, nid
) & AC_WCAP_STEREO
)
3322 return alc_auto_add_vol_ctl(codec
, pfx
, cidx
, nid
, chs
);
3325 /* create a mute-switch for the given mixer widget;
3326 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
3328 static int alc_auto_add_sw_ctl(struct hda_codec
*codec
,
3329 const char *pfx
, int cidx
,
3330 hda_nid_t nid
, unsigned int chs
)
3332 struct alc_spec
*spec
= codec
->spec
;
3338 wid_type
= get_wcaps_type(get_wcaps(codec
, nid
));
3339 if (wid_type
== AC_WID_PIN
|| wid_type
== AC_WID_AUD_OUT
) {
3340 type
= ALC_CTL_WIDGET_MUTE
;
3341 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
);
3342 } else if (snd_hda_get_num_conns(codec
, nid
) == 1) {
3343 type
= ALC_CTL_WIDGET_MUTE
;
3344 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_INPUT
);
3346 type
= ALC_CTL_BIND_MUTE
;
3347 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 2, HDA_INPUT
);
3349 if (is_ctl_used(spec
->sw_ctls
, val
) && chs
!= 2) /* exclude LFE */
3351 mark_ctl_usage(spec
->sw_ctls
, val
);
3352 return __add_pb_sw_ctrl(codec
->spec
, type
, pfx
, cidx
, val
);
3355 static int alc_auto_add_stereo_sw(struct hda_codec
*codec
, const char *pfx
,
3356 int cidx
, hda_nid_t nid
)
3359 if (get_wcaps(codec
, nid
) & AC_WCAP_STEREO
)
3361 return alc_auto_add_sw_ctl(codec
, pfx
, cidx
, nid
, chs
);
3364 static hda_nid_t
alc_look_for_out_mute_nid(struct hda_codec
*codec
,
3365 hda_nid_t pin
, hda_nid_t dac
)
3367 hda_nid_t mix
= alc_auto_dac_to_mix(codec
, pin
, dac
);
3368 if (nid_has_mute(codec
, pin
, HDA_OUTPUT
))
3370 else if (mix
&& nid_has_mute(codec
, mix
, HDA_INPUT
))
3372 else if (nid_has_mute(codec
, dac
, HDA_OUTPUT
))
3377 static hda_nid_t
alc_look_for_out_vol_nid(struct hda_codec
*codec
,
3378 hda_nid_t pin
, hda_nid_t dac
)
3380 hda_nid_t mix
= alc_auto_dac_to_mix(codec
, pin
, dac
);
3381 if (nid_has_volume(codec
, dac
, HDA_OUTPUT
))
3383 else if (nid_has_volume(codec
, mix
, HDA_OUTPUT
))
3385 else if (nid_has_volume(codec
, pin
, HDA_OUTPUT
))
3390 /* add playback controls from the parsed DAC table */
3391 static int alc_auto_create_multi_out_ctls(struct hda_codec
*codec
,
3392 const struct auto_pin_cfg
*cfg
)
3394 struct alc_spec
*spec
= codec
->spec
;
3395 int i
, err
, noutputs
;
3397 noutputs
= cfg
->line_outs
;
3398 if (spec
->multi_ios
> 0 && cfg
->line_outs
< 3)
3399 noutputs
+= spec
->multi_ios
;
3401 for (i
= 0; i
< noutputs
; i
++) {
3407 dac
= spec
->multiout
.dac_nids
[i
];
3410 if (i
>= cfg
->line_outs
) {
3411 pin
= spec
->multi_io
[i
- 1].pin
;
3413 name
= channel_name
[i
];
3415 pin
= cfg
->line_out_pins
[i
];
3416 name
= alc_get_line_out_pfx(spec
, i
, true, &index
);
3419 sw
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3420 vol
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3421 if (!name
|| !strcmp(name
, "CLFE")) {
3423 err
= alc_auto_add_vol_ctl(codec
, "Center", 0, vol
, 1);
3426 err
= alc_auto_add_vol_ctl(codec
, "LFE", 0, vol
, 2);
3429 err
= alc_auto_add_sw_ctl(codec
, "Center", 0, sw
, 1);
3432 err
= alc_auto_add_sw_ctl(codec
, "LFE", 0, sw
, 2);
3436 err
= alc_auto_add_stereo_vol(codec
, name
, index
, vol
);
3439 err
= alc_auto_add_stereo_sw(codec
, name
, index
, sw
);
3447 static int alc_auto_create_extra_out(struct hda_codec
*codec
, hda_nid_t pin
,
3448 hda_nid_t dac
, const char *pfx
,
3451 struct alc_spec
*spec
= codec
->spec
;
3457 /* the corresponding DAC is already occupied */
3458 if (!(get_wcaps(codec
, pin
) & AC_WCAP_OUT_AMP
))
3459 return 0; /* no way */
3460 /* create a switch only */
3461 val
= HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
);
3462 if (is_ctl_used(spec
->sw_ctls
, val
))
3463 return 0; /* already created */
3464 mark_ctl_usage(spec
->sw_ctls
, val
);
3465 return __add_pb_sw_ctrl(spec
, ALC_CTL_WIDGET_MUTE
, pfx
, cidx
, val
);
3468 sw
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3469 vol
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3470 err
= alc_auto_add_stereo_vol(codec
, pfx
, cidx
, vol
);
3473 err
= alc_auto_add_stereo_sw(codec
, pfx
, cidx
, sw
);
3479 static struct hda_bind_ctls
*new_bind_ctl(struct hda_codec
*codec
,
3481 struct hda_ctl_ops
*ops
)
3483 struct alc_spec
*spec
= codec
->spec
;
3484 struct hda_bind_ctls
**ctlp
, *ctl
;
3485 snd_array_init(&spec
->bind_ctls
, sizeof(ctl
), 8);
3486 ctlp
= snd_array_new(&spec
->bind_ctls
);
3489 ctl
= kzalloc(sizeof(*ctl
) + sizeof(long) * (nums
+ 1), GFP_KERNEL
);
3496 /* add playback controls for speaker and HP outputs */
3497 static int alc_auto_create_extra_outs(struct hda_codec
*codec
, int num_pins
,
3498 const hda_nid_t
*pins
,
3499 const hda_nid_t
*dacs
,
3502 struct alc_spec
*spec
= codec
->spec
;
3503 struct hda_bind_ctls
*ctl
;
3507 if (!num_pins
|| !pins
[0])
3510 if (num_pins
== 1) {
3511 hda_nid_t dac
= *dacs
;
3513 dac
= spec
->multiout
.dac_nids
[0];
3514 return alc_auto_create_extra_out(codec
, *pins
, dac
, pfx
, 0);
3517 for (i
= 0; i
< num_pins
; i
++) {
3519 if (dacs
[num_pins
- 1])
3520 dac
= dacs
[i
]; /* with individual volumes */
3523 if (num_pins
== 2 && i
== 1 && !strcmp(pfx
, "Speaker")) {
3524 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3526 } else if (num_pins
>= 3) {
3527 snprintf(name
, sizeof(name
), "%s %s",
3528 pfx
, channel_name
[i
]);
3529 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3532 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3538 if (dacs
[num_pins
- 1])
3541 /* Let's create a bind-controls for volumes */
3542 ctl
= new_bind_ctl(codec
, num_pins
, &snd_hda_bind_vol
);
3546 for (i
= 0; i
< num_pins
; i
++) {
3548 if (!pins
[i
] || !dacs
[i
])
3550 vol
= alc_look_for_out_vol_nid(codec
, pins
[i
], dacs
[i
]);
3553 HDA_COMPOSE_AMP_VAL(vol
, 3, 0, HDA_OUTPUT
);
3556 snprintf(name
, sizeof(name
), "%s Playback Volume", pfx
);
3557 err
= add_control(spec
, ALC_CTL_BIND_VOL
, name
, 0, (long)ctl
);
3564 static int alc_auto_create_hp_out(struct hda_codec
*codec
)
3566 struct alc_spec
*spec
= codec
->spec
;
3567 return alc_auto_create_extra_outs(codec
, spec
->autocfg
.hp_outs
,
3568 spec
->autocfg
.hp_pins
,
3569 spec
->multiout
.hp_out_nid
,
3573 static int alc_auto_create_speaker_out(struct hda_codec
*codec
)
3575 struct alc_spec
*spec
= codec
->spec
;
3576 return alc_auto_create_extra_outs(codec
, spec
->autocfg
.speaker_outs
,
3577 spec
->autocfg
.speaker_pins
,
3578 spec
->multiout
.extra_out_nid
,
3582 static void alc_auto_set_output_and_unmute(struct hda_codec
*codec
,
3583 hda_nid_t pin
, int pin_type
,
3587 hda_nid_t nid
, mix
= 0;
3588 hda_nid_t srcs
[HDA_MAX_CONNECTIONS
];
3590 alc_set_pin_output(codec
, pin
, pin_type
);
3591 nid
= alc_go_down_to_selector(codec
, pin
);
3592 num
= snd_hda_get_connections(codec
, nid
, srcs
, ARRAY_SIZE(srcs
));
3593 for (i
= 0; i
< num
; i
++) {
3594 if (alc_auto_mix_to_dac(codec
, srcs
[i
]) != dac
)
3602 /* need the manual connection? */
3604 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_CONNECT_SEL
, i
);
3605 /* unmute mixer widget inputs */
3606 if (nid_has_mute(codec
, mix
, HDA_INPUT
)) {
3607 snd_hda_codec_write(codec
, mix
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3609 snd_hda_codec_write(codec
, mix
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3612 /* initialize volume */
3613 nid
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3615 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3618 /* unmute DAC if it's not assigned to a mixer */
3619 nid
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3620 if (nid
== mix
&& nid_has_mute(codec
, dac
, HDA_OUTPUT
))
3621 snd_hda_codec_write(codec
, dac
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3625 static void alc_auto_init_multi_out(struct hda_codec
*codec
)
3627 struct alc_spec
*spec
= codec
->spec
;
3628 int pin_type
= get_pin_type(spec
->autocfg
.line_out_type
);
3631 for (i
= 0; i
<= HDA_SIDE
; i
++) {
3632 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
3634 alc_auto_set_output_and_unmute(codec
, nid
, pin_type
,
3635 spec
->multiout
.dac_nids
[i
]);
3639 static void alc_auto_init_extra_out(struct hda_codec
*codec
)
3641 struct alc_spec
*spec
= codec
->spec
;
3645 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
3646 if (spec
->autocfg
.line_out_type
== AUTO_PIN_HP_OUT
)
3648 pin
= spec
->autocfg
.hp_pins
[i
];
3651 dac
= spec
->multiout
.hp_out_nid
[i
];
3653 if (i
> 0 && spec
->multiout
.hp_out_nid
[0])
3654 dac
= spec
->multiout
.hp_out_nid
[0];
3656 dac
= spec
->multiout
.dac_nids
[0];
3658 alc_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, dac
);
3660 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++) {
3661 if (spec
->autocfg
.line_out_type
== AUTO_PIN_SPEAKER_OUT
)
3663 pin
= spec
->autocfg
.speaker_pins
[i
];
3666 dac
= spec
->multiout
.extra_out_nid
[i
];
3668 if (i
> 0 && spec
->multiout
.extra_out_nid
[0])
3669 dac
= spec
->multiout
.extra_out_nid
[0];
3671 dac
= spec
->multiout
.dac_nids
[0];
3673 alc_auto_set_output_and_unmute(codec
, pin
, PIN_OUT
, dac
);
3677 /* check whether the given pin can be a multi-io pin */
3678 static bool can_be_multiio_pin(struct hda_codec
*codec
,
3679 unsigned int location
, hda_nid_t nid
)
3681 unsigned int defcfg
, caps
;
3683 defcfg
= snd_hda_codec_get_pincfg(codec
, nid
);
3684 if (get_defcfg_connect(defcfg
) != AC_JACK_PORT_COMPLEX
)
3686 if (location
&& get_defcfg_location(defcfg
) != location
)
3688 caps
= snd_hda_query_pin_caps(codec
, nid
);
3689 if (!(caps
& AC_PINCAP_OUT
))
3697 * When hardwired is set, try to fill ony hardwired pins, and returns
3698 * zero if any pins are filled, non-zero if nothing found.
3699 * When hardwired is off, try to fill possible input pins, and returns
3700 * the badness value.
3702 static int alc_auto_fill_multi_ios(struct hda_codec
*codec
,
3703 hda_nid_t reference_pin
,
3704 bool hardwired
, int offset
)
3706 struct alc_spec
*spec
= codec
->spec
;
3707 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3708 int type
, i
, j
, dacs
, num_pins
, old_pins
;
3709 unsigned int defcfg
= snd_hda_codec_get_pincfg(codec
, reference_pin
);
3710 unsigned int location
= get_defcfg_location(defcfg
);
3713 old_pins
= spec
->multi_ios
;
3718 for (type
= AUTO_PIN_LINE_IN
; type
>= AUTO_PIN_MIC
; type
--) {
3719 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3720 if (cfg
->inputs
[i
].type
!= type
)
3722 if (can_be_multiio_pin(codec
, location
,
3723 cfg
->inputs
[i
].pin
))
3730 dacs
= spec
->multiout
.num_dacs
;
3731 for (type
= AUTO_PIN_LINE_IN
; type
>= AUTO_PIN_MIC
; type
--) {
3732 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3733 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
3736 if (cfg
->inputs
[i
].type
!= type
)
3738 if (!can_be_multiio_pin(codec
, location
, nid
))
3740 for (j
= 0; j
< spec
->multi_ios
; j
++) {
3741 if (nid
== spec
->multi_io
[j
].pin
)
3744 if (j
< spec
->multi_ios
)
3747 if (offset
&& offset
+ spec
->multi_ios
< dacs
) {
3748 dac
= spec
->private_dac_nids
[offset
+ spec
->multi_ios
];
3749 if (!alc_auto_is_dac_reachable(codec
, nid
, dac
))
3753 dac
= get_dac_if_single(codec
, nid
);
3755 dac
= alc_auto_look_for_dac(codec
, nid
);
3760 spec
->multi_io
[spec
->multi_ios
].pin
= nid
;
3761 spec
->multi_io
[spec
->multi_ios
].dac
= dac
;
3763 if (spec
->multi_ios
>= 2)
3769 badness
= BAD_MULTI_IO
;
3770 if (old_pins
== spec
->multi_ios
) {
3772 return 1; /* nothing found */
3774 return badness
; /* no badness if nothing found */
3776 if (!hardwired
&& spec
->multi_ios
< 2) {
3777 spec
->multi_ios
= old_pins
;
3784 static int alc_auto_ch_mode_info(struct snd_kcontrol
*kcontrol
,
3785 struct snd_ctl_elem_info
*uinfo
)
3787 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3788 struct alc_spec
*spec
= codec
->spec
;
3790 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
3792 uinfo
->value
.enumerated
.items
= spec
->multi_ios
+ 1;
3793 if (uinfo
->value
.enumerated
.item
> spec
->multi_ios
)
3794 uinfo
->value
.enumerated
.item
= spec
->multi_ios
;
3795 sprintf(uinfo
->value
.enumerated
.name
, "%dch",
3796 (uinfo
->value
.enumerated
.item
+ 1) * 2);
3800 static int alc_auto_ch_mode_get(struct snd_kcontrol
*kcontrol
,
3801 struct snd_ctl_elem_value
*ucontrol
)
3803 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3804 struct alc_spec
*spec
= codec
->spec
;
3805 ucontrol
->value
.enumerated
.item
[0] = (spec
->ext_channel_count
- 1) / 2;
3809 static int alc_set_multi_io(struct hda_codec
*codec
, int idx
, bool output
)
3811 struct alc_spec
*spec
= codec
->spec
;
3812 hda_nid_t nid
= spec
->multi_io
[idx
].pin
;
3814 if (!spec
->multi_io
[idx
].ctl_in
)
3815 spec
->multi_io
[idx
].ctl_in
=
3816 snd_hda_codec_read(codec
, nid
, 0,
3817 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
3819 snd_hda_set_pin_ctl_cache(codec
, nid
, PIN_OUT
);
3820 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
3821 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
3823 alc_auto_select_dac(codec
, nid
, spec
->multi_io
[idx
].dac
);
3825 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
3826 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
3827 HDA_AMP_MUTE
, HDA_AMP_MUTE
);
3828 snd_hda_set_pin_ctl_cache(codec
, nid
,
3829 spec
->multi_io
[idx
].ctl_in
);
3834 static int alc_auto_ch_mode_put(struct snd_kcontrol
*kcontrol
,
3835 struct snd_ctl_elem_value
*ucontrol
)
3837 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3838 struct alc_spec
*spec
= codec
->spec
;
3841 ch
= ucontrol
->value
.enumerated
.item
[0];
3842 if (ch
< 0 || ch
> spec
->multi_ios
)
3844 if (ch
== (spec
->ext_channel_count
- 1) / 2)
3846 spec
->ext_channel_count
= (ch
+ 1) * 2;
3847 for (i
= 0; i
< spec
->multi_ios
; i
++)
3848 alc_set_multi_io(codec
, i
, i
< ch
);
3849 spec
->multiout
.max_channels
= spec
->ext_channel_count
;
3850 if (spec
->need_dac_fix
&& !spec
->const_channel_count
)
3851 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
3855 static const struct snd_kcontrol_new alc_auto_channel_mode_enum
= {
3856 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3857 .name
= "Channel Mode",
3858 .info
= alc_auto_ch_mode_info
,
3859 .get
= alc_auto_ch_mode_get
,
3860 .put
= alc_auto_ch_mode_put
,
3863 static int alc_auto_add_multi_channel_mode(struct hda_codec
*codec
)
3865 struct alc_spec
*spec
= codec
->spec
;
3867 if (spec
->multi_ios
> 0) {
3868 struct snd_kcontrol_new
*knew
;
3870 knew
= alc_kcontrol_new(spec
);
3873 *knew
= alc_auto_channel_mode_enum
;
3874 knew
->name
= kstrdup("Channel Mode", GFP_KERNEL
);
3881 /* filter out invalid adc_nids (and capsrc_nids) that don't give all
3884 static void alc_remove_invalid_adc_nids(struct hda_codec
*codec
)
3886 struct alc_spec
*spec
= codec
->spec
;
3887 const struct hda_input_mux
*imux
;
3888 hda_nid_t adc_nids
[ARRAY_SIZE(spec
->private_adc_nids
)];
3889 hda_nid_t capsrc_nids
[ARRAY_SIZE(spec
->private_adc_nids
)];
3892 imux
= spec
->input_mux
;
3895 if (spec
->dyn_adc_switch
)
3900 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
3901 hda_nid_t cap
= spec
->private_capsrc_nids
[n
];
3902 int num_conns
= snd_hda_get_num_conns(codec
, cap
);
3903 for (i
= 0; i
< imux
->num_items
; i
++) {
3904 hda_nid_t pin
= spec
->imux_pins
[i
];
3906 if (get_connection_index(codec
, cap
, pin
) < 0)
3908 } else if (num_conns
<= imux
->items
[i
].index
)
3911 if (i
>= imux
->num_items
) {
3912 adc_nids
[nums
] = spec
->private_adc_nids
[n
];
3913 capsrc_nids
[nums
++] = cap
;
3917 /* check whether ADC-switch is possible */
3918 if (!alc_check_dyn_adc_switch(codec
)) {
3919 if (spec
->shared_mic_hp
) {
3920 spec
->shared_mic_hp
= 0;
3921 spec
->private_imux
[0].num_items
= 1;
3924 printk(KERN_WARNING
"hda_codec: %s: no valid ADC found;"
3925 " using fallback 0x%x\n",
3926 codec
->chip_name
, spec
->private_adc_nids
[0]);
3927 spec
->num_adc_nids
= 1;
3931 } else if (nums
!= spec
->num_adc_nids
) {
3932 memcpy(spec
->private_adc_nids
, adc_nids
,
3933 nums
* sizeof(hda_nid_t
));
3934 memcpy(spec
->private_capsrc_nids
, capsrc_nids
,
3935 nums
* sizeof(hda_nid_t
));
3936 spec
->num_adc_nids
= nums
;
3940 alc_auto_mic_check_imux(codec
); /* check auto-mic setups */
3941 else if (spec
->input_mux
->num_items
== 1 || spec
->shared_mic_hp
)
3942 spec
->num_adc_nids
= 1; /* reduce to a single ADC */
3946 * initialize ADC paths
3948 static void alc_auto_init_adc(struct hda_codec
*codec
, int adc_idx
)
3950 struct alc_spec
*spec
= codec
->spec
;
3953 nid
= spec
->adc_nids
[adc_idx
];
3955 if (nid_has_mute(codec
, nid
, HDA_INPUT
)) {
3956 snd_hda_codec_write(codec
, nid
, 0,
3957 AC_VERB_SET_AMP_GAIN_MUTE
,
3961 if (!spec
->capsrc_nids
)
3963 nid
= spec
->capsrc_nids
[adc_idx
];
3964 if (nid_has_mute(codec
, nid
, HDA_OUTPUT
))
3965 snd_hda_codec_write(codec
, nid
, 0,
3966 AC_VERB_SET_AMP_GAIN_MUTE
,
3970 static void alc_auto_init_input_src(struct hda_codec
*codec
)
3972 struct alc_spec
*spec
= codec
->spec
;
3975 for (c
= 0; c
< spec
->num_adc_nids
; c
++)
3976 alc_auto_init_adc(codec
, c
);
3977 if (spec
->dyn_adc_switch
)
3980 nums
= spec
->num_adc_nids
;
3981 for (c
= 0; c
< nums
; c
++)
3982 alc_mux_select(codec
, c
, spec
->cur_mux
[c
], true);
3985 /* add mic boosts if needed */
3986 static int alc_auto_add_mic_boost(struct hda_codec
*codec
)
3988 struct alc_spec
*spec
= codec
->spec
;
3989 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3993 const char *prev_label
= NULL
;
3995 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3996 if (cfg
->inputs
[i
].type
> AUTO_PIN_MIC
)
3998 nid
= cfg
->inputs
[i
].pin
;
3999 if (get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
) {
4001 char boost_label
[32];
4003 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
4004 if (spec
->shared_mic_hp
&& !strcmp(label
, "Misc"))
4005 label
= "Headphone Mic";
4006 if (prev_label
&& !strcmp(label
, prev_label
))
4012 snprintf(boost_label
, sizeof(boost_label
),
4013 "%s Boost Volume", label
);
4014 err
= add_control(spec
, ALC_CTL_WIDGET_VOL
,
4015 boost_label
, type_idx
,
4016 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_INPUT
));
4024 /* select or unmute the given capsrc route */
4025 static void select_or_unmute_capsrc(struct hda_codec
*codec
, hda_nid_t cap
,
4028 if (get_wcaps_type(get_wcaps(codec
, cap
)) == AC_WID_AUD_MIX
) {
4029 snd_hda_codec_amp_stereo(codec
, cap
, HDA_INPUT
, idx
,
4031 } else if (snd_hda_get_num_conns(codec
, cap
) > 1) {
4032 snd_hda_codec_write_cache(codec
, cap
, 0,
4033 AC_VERB_SET_CONNECT_SEL
, idx
);
4037 /* set the default connection to that pin */
4038 static int init_capsrc_for_pin(struct hda_codec
*codec
, hda_nid_t pin
)
4040 struct alc_spec
*spec
= codec
->spec
;
4045 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
4046 hda_nid_t cap
= get_capsrc(spec
, i
);
4049 idx
= get_connection_index(codec
, cap
, pin
);
4052 select_or_unmute_capsrc(codec
, cap
, idx
);
4053 return i
; /* return the found index */
4055 return -1; /* not found */
4058 /* initialize some special cases for input sources */
4059 static void alc_init_special_input_src(struct hda_codec
*codec
)
4061 struct alc_spec
*spec
= codec
->spec
;
4064 for (i
= 0; i
< spec
->autocfg
.num_inputs
; i
++)
4065 init_capsrc_for_pin(codec
, spec
->autocfg
.inputs
[i
].pin
);
4068 /* assign appropriate capture mixers */
4069 static void set_capture_mixer(struct hda_codec
*codec
)
4071 struct alc_spec
*spec
= codec
->spec
;
4072 static const struct snd_kcontrol_new
*caps
[2][3] = {
4073 { alc_capture_mixer_nosrc1
,
4074 alc_capture_mixer_nosrc2
,
4075 alc_capture_mixer_nosrc3
},
4076 { alc_capture_mixer1
,
4078 alc_capture_mixer3
},
4081 /* check whether either of ADC or MUX has a volume control */
4082 if (!nid_has_volume(codec
, spec
->adc_nids
[0], HDA_INPUT
)) {
4083 if (!spec
->capsrc_nids
)
4084 return; /* no volume */
4085 if (!nid_has_volume(codec
, spec
->capsrc_nids
[0], HDA_OUTPUT
))
4086 return; /* no volume in capsrc, too */
4087 spec
->vol_in_capsrc
= 1;
4090 if (spec
->num_adc_nids
> 0) {
4094 if (spec
->input_mux
&& spec
->input_mux
->num_items
> 1)
4096 if (spec
->auto_mic
) {
4099 } else if (spec
->dyn_adc_switch
)
4102 if (spec
->num_adc_nids
> 3)
4103 spec
->num_adc_nids
= 3;
4104 else if (!spec
->num_adc_nids
)
4106 num_adcs
= spec
->num_adc_nids
;
4108 spec
->cap_mixer
= caps
[mux
][num_adcs
- 1];
4113 * standard auto-parser initializations
4115 static void alc_auto_init_std(struct hda_codec
*codec
)
4117 struct alc_spec
*spec
= codec
->spec
;
4118 alc_auto_init_multi_out(codec
);
4119 alc_auto_init_extra_out(codec
);
4120 alc_auto_init_analog_input(codec
);
4121 alc_auto_init_input_src(codec
);
4122 alc_auto_init_digital(codec
);
4123 if (spec
->unsol_event
)
4124 alc_inithook(codec
);
4128 * Digital-beep handlers
4130 #ifdef CONFIG_SND_HDA_INPUT_BEEP
4131 #define set_beep_amp(spec, nid, idx, dir) \
4132 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4134 static const struct snd_pci_quirk beep_white_list
[] = {
4135 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
4136 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
4137 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
4138 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
4139 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
4140 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
4144 static inline int has_cdefine_beep(struct hda_codec
*codec
)
4146 struct alc_spec
*spec
= codec
->spec
;
4147 const struct snd_pci_quirk
*q
;
4148 q
= snd_pci_quirk_lookup(codec
->bus
->pci
, beep_white_list
);
4151 return spec
->cdefine
.enable_pcbeep
;
4154 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
4155 #define has_cdefine_beep(codec) 0
4158 /* parse the BIOS configuration and set up the alc_spec */
4159 /* return 1 if successful, 0 if the proper config is not found,
4160 * or a negative error code
4162 static int alc_parse_auto_config(struct hda_codec
*codec
,
4163 const hda_nid_t
*ignore_nids
,
4164 const hda_nid_t
*ssid_nids
)
4166 struct alc_spec
*spec
= codec
->spec
;
4167 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4170 err
= snd_hda_parse_pin_defcfg(codec
, cfg
, ignore_nids
,
4174 if (!cfg
->line_outs
) {
4175 if (cfg
->dig_outs
|| cfg
->dig_in_pin
) {
4176 spec
->multiout
.max_channels
= 2;
4177 spec
->no_analog
= 1;
4180 return 0; /* can't find valid BIOS pin config */
4183 if (cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
&&
4184 cfg
->line_outs
<= cfg
->hp_outs
) {
4185 /* use HP as primary out */
4186 cfg
->speaker_outs
= cfg
->line_outs
;
4187 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
4188 sizeof(cfg
->speaker_pins
));
4189 cfg
->line_outs
= cfg
->hp_outs
;
4190 memcpy(cfg
->line_out_pins
, cfg
->hp_pins
, sizeof(cfg
->hp_pins
));
4192 memset(cfg
->hp_pins
, 0, sizeof(cfg
->hp_pins
));
4193 cfg
->line_out_type
= AUTO_PIN_HP_OUT
;
4196 err
= alc_auto_fill_dac_nids(codec
);
4199 err
= alc_auto_add_multi_channel_mode(codec
);
4202 err
= alc_auto_create_multi_out_ctls(codec
, cfg
);
4205 err
= alc_auto_create_hp_out(codec
);
4208 err
= alc_auto_create_speaker_out(codec
);
4211 err
= alc_auto_create_shared_input(codec
);
4214 err
= alc_auto_create_input_ctls(codec
);
4218 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
4221 alc_auto_parse_digital(codec
);
4223 if (!spec
->no_analog
)
4224 alc_remove_invalid_adc_nids(codec
);
4227 alc_ssid_check(codec
, ssid_nids
);
4229 if (!spec
->no_analog
) {
4230 alc_auto_check_switches(codec
);
4231 err
= alc_auto_add_mic_boost(codec
);
4236 if (spec
->kctls
.list
)
4237 add_mixer(spec
, spec
->kctls
.list
);
4239 if (!spec
->no_analog
&& !spec
->cap_mixer
)
4240 set_capture_mixer(codec
);
4245 /* common preparation job for alc_spec */
4246 static int alc_alloc_spec(struct hda_codec
*codec
, hda_nid_t mixer_nid
)
4248 struct alc_spec
*spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4254 spec
->mixer_nid
= mixer_nid
;
4256 err
= alc_codec_rename_from_preset(codec
);
4264 static int alc880_parse_auto_config(struct hda_codec
*codec
)
4266 static const hda_nid_t alc880_ignore
[] = { 0x1d, 0 };
4267 static const hda_nid_t alc880_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
4268 return alc_parse_auto_config(codec
, alc880_ignore
, alc880_ssids
);
4277 ALC880_FIXUP_MEDION_RIM
,
4280 ALC880_FIXUP_EAPD_COEF
,
4281 ALC880_FIXUP_TCL_S700
,
4282 ALC880_FIXUP_VOL_KNOB
,
4283 ALC880_FIXUP_FUJITSU
,
4285 ALC880_FIXUP_UNIWILL
,
4286 ALC880_FIXUP_UNIWILL_DIG
,
4288 ALC880_FIXUP_3ST_BASE
,
4290 ALC880_FIXUP_3ST_DIG
,
4291 ALC880_FIXUP_5ST_BASE
,
4293 ALC880_FIXUP_5ST_DIG
,
4294 ALC880_FIXUP_6ST_BASE
,
4296 ALC880_FIXUP_6ST_DIG
,
4299 /* enable the volume-knob widget support on NID 0x21 */
4300 static void alc880_fixup_vol_knob(struct hda_codec
*codec
,
4301 const struct alc_fixup
*fix
, int action
)
4303 if (action
== ALC_FIXUP_ACT_PROBE
)
4304 snd_hda_jack_detect_enable(codec
, 0x21, ALC_DCVOL_EVENT
);
4307 static const struct alc_fixup alc880_fixups
[] = {
4308 [ALC880_FIXUP_GPIO1
] = {
4309 .type
= ALC_FIXUP_VERBS
,
4310 .v
.verbs
= alc_gpio1_init_verbs
,
4312 [ALC880_FIXUP_GPIO2
] = {
4313 .type
= ALC_FIXUP_VERBS
,
4314 .v
.verbs
= alc_gpio2_init_verbs
,
4316 [ALC880_FIXUP_MEDION_RIM
] = {
4317 .type
= ALC_FIXUP_VERBS
,
4318 .v
.verbs
= (const struct hda_verb
[]) {
4319 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4320 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
4324 .chain_id
= ALC880_FIXUP_GPIO2
,
4326 [ALC880_FIXUP_LG
] = {
4327 .type
= ALC_FIXUP_PINS
,
4328 .v
.pins
= (const struct alc_pincfg
[]) {
4329 /* disable bogus unused pins */
4330 { 0x16, 0x411111f0 },
4331 { 0x18, 0x411111f0 },
4332 { 0x1a, 0x411111f0 },
4336 [ALC880_FIXUP_W810
] = {
4337 .type
= ALC_FIXUP_PINS
,
4338 .v
.pins
= (const struct alc_pincfg
[]) {
4339 /* disable bogus unused pins */
4340 { 0x17, 0x411111f0 },
4344 .chain_id
= ALC880_FIXUP_GPIO2
,
4346 [ALC880_FIXUP_EAPD_COEF
] = {
4347 .type
= ALC_FIXUP_VERBS
,
4348 .v
.verbs
= (const struct hda_verb
[]) {
4349 /* change to EAPD mode */
4350 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4351 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
4355 [ALC880_FIXUP_TCL_S700
] = {
4356 .type
= ALC_FIXUP_VERBS
,
4357 .v
.verbs
= (const struct hda_verb
[]) {
4358 /* change to EAPD mode */
4359 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4360 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
4364 .chain_id
= ALC880_FIXUP_GPIO2
,
4366 [ALC880_FIXUP_VOL_KNOB
] = {
4367 .type
= ALC_FIXUP_FUNC
,
4368 .v
.func
= alc880_fixup_vol_knob
,
4370 [ALC880_FIXUP_FUJITSU
] = {
4371 /* override all pins as BIOS on old Amilo is broken */
4372 .type
= ALC_FIXUP_PINS
,
4373 .v
.pins
= (const struct alc_pincfg
[]) {
4374 { 0x14, 0x0121411f }, /* HP */
4375 { 0x15, 0x99030120 }, /* speaker */
4376 { 0x16, 0x99030130 }, /* bass speaker */
4377 { 0x17, 0x411111f0 }, /* N/A */
4378 { 0x18, 0x411111f0 }, /* N/A */
4379 { 0x19, 0x01a19950 }, /* mic-in */
4380 { 0x1a, 0x411111f0 }, /* N/A */
4381 { 0x1b, 0x411111f0 }, /* N/A */
4382 { 0x1c, 0x411111f0 }, /* N/A */
4383 { 0x1d, 0x411111f0 }, /* N/A */
4384 { 0x1e, 0x01454140 }, /* SPDIF out */
4388 .chain_id
= ALC880_FIXUP_VOL_KNOB
,
4390 [ALC880_FIXUP_F1734
] = {
4391 /* almost compatible with FUJITSU, but no bass and SPDIF */
4392 .type
= ALC_FIXUP_PINS
,
4393 .v
.pins
= (const struct alc_pincfg
[]) {
4394 { 0x14, 0x0121411f }, /* HP */
4395 { 0x15, 0x99030120 }, /* speaker */
4396 { 0x16, 0x411111f0 }, /* N/A */
4397 { 0x17, 0x411111f0 }, /* N/A */
4398 { 0x18, 0x411111f0 }, /* N/A */
4399 { 0x19, 0x01a19950 }, /* mic-in */
4400 { 0x1a, 0x411111f0 }, /* N/A */
4401 { 0x1b, 0x411111f0 }, /* N/A */
4402 { 0x1c, 0x411111f0 }, /* N/A */
4403 { 0x1d, 0x411111f0 }, /* N/A */
4404 { 0x1e, 0x411111f0 }, /* N/A */
4408 .chain_id
= ALC880_FIXUP_VOL_KNOB
,
4410 [ALC880_FIXUP_UNIWILL
] = {
4411 /* need to fix HP and speaker pins to be parsed correctly */
4412 .type
= ALC_FIXUP_PINS
,
4413 .v
.pins
= (const struct alc_pincfg
[]) {
4414 { 0x14, 0x0121411f }, /* HP */
4415 { 0x15, 0x99030120 }, /* speaker */
4416 { 0x16, 0x99030130 }, /* bass speaker */
4420 [ALC880_FIXUP_UNIWILL_DIG
] = {
4421 .type
= ALC_FIXUP_PINS
,
4422 .v
.pins
= (const struct alc_pincfg
[]) {
4423 /* disable bogus unused pins */
4424 { 0x17, 0x411111f0 },
4425 { 0x19, 0x411111f0 },
4426 { 0x1b, 0x411111f0 },
4427 { 0x1f, 0x411111f0 },
4431 [ALC880_FIXUP_Z71V
] = {
4432 .type
= ALC_FIXUP_PINS
,
4433 .v
.pins
= (const struct alc_pincfg
[]) {
4434 /* set up the whole pins as BIOS is utterly broken */
4435 { 0x14, 0x99030120 }, /* speaker */
4436 { 0x15, 0x0121411f }, /* HP */
4437 { 0x16, 0x411111f0 }, /* N/A */
4438 { 0x17, 0x411111f0 }, /* N/A */
4439 { 0x18, 0x01a19950 }, /* mic-in */
4440 { 0x19, 0x411111f0 }, /* N/A */
4441 { 0x1a, 0x01813031 }, /* line-in */
4442 { 0x1b, 0x411111f0 }, /* N/A */
4443 { 0x1c, 0x411111f0 }, /* N/A */
4444 { 0x1d, 0x411111f0 }, /* N/A */
4445 { 0x1e, 0x0144111e }, /* SPDIF */
4449 [ALC880_FIXUP_3ST_BASE
] = {
4450 .type
= ALC_FIXUP_PINS
,
4451 .v
.pins
= (const struct alc_pincfg
[]) {
4452 { 0x14, 0x01014010 }, /* line-out */
4453 { 0x15, 0x411111f0 }, /* N/A */
4454 { 0x16, 0x411111f0 }, /* N/A */
4455 { 0x17, 0x411111f0 }, /* N/A */
4456 { 0x18, 0x01a19c30 }, /* mic-in */
4457 { 0x19, 0x0121411f }, /* HP */
4458 { 0x1a, 0x01813031 }, /* line-in */
4459 { 0x1b, 0x02a19c40 }, /* front-mic */
4460 { 0x1c, 0x411111f0 }, /* N/A */
4461 { 0x1d, 0x411111f0 }, /* N/A */
4462 /* 0x1e is filled in below */
4463 { 0x1f, 0x411111f0 }, /* N/A */
4467 [ALC880_FIXUP_3ST
] = {
4468 .type
= ALC_FIXUP_PINS
,
4469 .v
.pins
= (const struct alc_pincfg
[]) {
4470 { 0x1e, 0x411111f0 }, /* N/A */
4474 .chain_id
= ALC880_FIXUP_3ST_BASE
,
4476 [ALC880_FIXUP_3ST_DIG
] = {
4477 .type
= ALC_FIXUP_PINS
,
4478 .v
.pins
= (const struct alc_pincfg
[]) {
4479 { 0x1e, 0x0144111e }, /* SPDIF */
4483 .chain_id
= ALC880_FIXUP_3ST_BASE
,
4485 [ALC880_FIXUP_5ST_BASE
] = {
4486 .type
= ALC_FIXUP_PINS
,
4487 .v
.pins
= (const struct alc_pincfg
[]) {
4488 { 0x14, 0x01014010 }, /* front */
4489 { 0x15, 0x411111f0 }, /* N/A */
4490 { 0x16, 0x01011411 }, /* CLFE */
4491 { 0x17, 0x01016412 }, /* surr */
4492 { 0x18, 0x01a19c30 }, /* mic-in */
4493 { 0x19, 0x0121411f }, /* HP */
4494 { 0x1a, 0x01813031 }, /* line-in */
4495 { 0x1b, 0x02a19c40 }, /* front-mic */
4496 { 0x1c, 0x411111f0 }, /* N/A */
4497 { 0x1d, 0x411111f0 }, /* N/A */
4498 /* 0x1e is filled in below */
4499 { 0x1f, 0x411111f0 }, /* N/A */
4503 [ALC880_FIXUP_5ST
] = {
4504 .type
= ALC_FIXUP_PINS
,
4505 .v
.pins
= (const struct alc_pincfg
[]) {
4506 { 0x1e, 0x411111f0 }, /* N/A */
4510 .chain_id
= ALC880_FIXUP_5ST_BASE
,
4512 [ALC880_FIXUP_5ST_DIG
] = {
4513 .type
= ALC_FIXUP_PINS
,
4514 .v
.pins
= (const struct alc_pincfg
[]) {
4515 { 0x1e, 0x0144111e }, /* SPDIF */
4519 .chain_id
= ALC880_FIXUP_5ST_BASE
,
4521 [ALC880_FIXUP_6ST_BASE
] = {
4522 .type
= ALC_FIXUP_PINS
,
4523 .v
.pins
= (const struct alc_pincfg
[]) {
4524 { 0x14, 0x01014010 }, /* front */
4525 { 0x15, 0x01016412 }, /* surr */
4526 { 0x16, 0x01011411 }, /* CLFE */
4527 { 0x17, 0x01012414 }, /* side */
4528 { 0x18, 0x01a19c30 }, /* mic-in */
4529 { 0x19, 0x02a19c40 }, /* front-mic */
4530 { 0x1a, 0x01813031 }, /* line-in */
4531 { 0x1b, 0x0121411f }, /* HP */
4532 { 0x1c, 0x411111f0 }, /* N/A */
4533 { 0x1d, 0x411111f0 }, /* N/A */
4534 /* 0x1e is filled in below */
4535 { 0x1f, 0x411111f0 }, /* N/A */
4539 [ALC880_FIXUP_6ST
] = {
4540 .type
= ALC_FIXUP_PINS
,
4541 .v
.pins
= (const struct alc_pincfg
[]) {
4542 { 0x1e, 0x411111f0 }, /* N/A */
4546 .chain_id
= ALC880_FIXUP_6ST_BASE
,
4548 [ALC880_FIXUP_6ST_DIG
] = {
4549 .type
= ALC_FIXUP_PINS
,
4550 .v
.pins
= (const struct alc_pincfg
[]) {
4551 { 0x1e, 0x0144111e }, /* SPDIF */
4555 .chain_id
= ALC880_FIXUP_6ST_BASE
,
4559 static const struct snd_pci_quirk alc880_fixup_tbl
[] = {
4560 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810
),
4561 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V
),
4562 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1
),
4563 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2
),
4564 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF
),
4565 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG
),
4566 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734
),
4567 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL
),
4568 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB
),
4569 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810
),
4570 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM
),
4571 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734
),
4572 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU
),
4573 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734
),
4574 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU
),
4575 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG
),
4576 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG
),
4577 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG
),
4578 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700
),
4580 /* Below is the copied entries from alc880_quirks.c.
4581 * It's not quite sure whether BIOS sets the correct pin-config table
4582 * on these machines, thus they are kept to be compatible with
4583 * the old static quirks. Once when it's confirmed to work without
4584 * these overrides, it'd be better to remove.
4586 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG
),
4587 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST
),
4588 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG
),
4589 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG
),
4590 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG
),
4591 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG
),
4592 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG
),
4593 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST
),
4594 SND_PCI_QUIRK(0x1039, 0x1234, NULL
, ALC880_FIXUP_6ST_DIG
),
4595 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST
),
4596 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST
),
4597 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST
),
4598 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST
),
4599 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST
),
4600 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG
),
4601 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG
),
4602 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG
),
4603 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG
),
4604 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG
),
4605 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG
),
4606 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG
),
4607 SND_PCI_QUIRK(0x2668, 0x8086, NULL
, ALC880_FIXUP_6ST_DIG
), /* broken BIOS */
4608 SND_PCI_QUIRK(0x8086, 0x2668, NULL
, ALC880_FIXUP_6ST_DIG
),
4609 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4610 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4611 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4612 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4613 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4614 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4615 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4616 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4617 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4618 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4620 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST
),
4621 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG
),
4622 SND_PCI_QUIRK(0xe803, 0x1019, NULL
, ALC880_FIXUP_6ST_DIG
),
4626 static const struct alc_model_fixup alc880_fixup_models
[] = {
4627 {.id
= ALC880_FIXUP_3ST
, .name
= "3stack"},
4628 {.id
= ALC880_FIXUP_3ST_DIG
, .name
= "3stack-digout"},
4629 {.id
= ALC880_FIXUP_5ST
, .name
= "5stack"},
4630 {.id
= ALC880_FIXUP_5ST_DIG
, .name
= "5stack-digout"},
4631 {.id
= ALC880_FIXUP_6ST
, .name
= "6stack"},
4632 {.id
= ALC880_FIXUP_6ST_DIG
, .name
= "6stack-digout"},
4638 * OK, here we have finally the patch for ALC880
4640 static int patch_alc880(struct hda_codec
*codec
)
4642 struct alc_spec
*spec
;
4645 err
= alc_alloc_spec(codec
, 0x0b);
4650 spec
->need_dac_fix
= 1;
4652 alc_pick_fixup(codec
, alc880_fixup_models
, alc880_fixup_tbl
,
4654 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
4656 /* automatic parse from the BIOS config */
4657 err
= alc880_parse_auto_config(codec
);
4661 if (!spec
->no_analog
) {
4662 err
= snd_hda_attach_beep_device(codec
, 0x1);
4665 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
4668 codec
->patch_ops
= alc_patch_ops
;
4670 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
4683 static int alc260_parse_auto_config(struct hda_codec
*codec
)
4685 static const hda_nid_t alc260_ignore
[] = { 0x17, 0 };
4686 static const hda_nid_t alc260_ssids
[] = { 0x10, 0x15, 0x0f, 0 };
4687 return alc_parse_auto_config(codec
, alc260_ignore
, alc260_ssids
);
4694 ALC260_FIXUP_HP_DC5750
,
4695 ALC260_FIXUP_HP_PIN_0F
,
4698 ALC260_FIXUP_GPIO1_TOGGLE
,
4699 ALC260_FIXUP_REPLACER
,
4700 ALC260_FIXUP_HP_B1900
,
4704 static void alc260_gpio1_automute(struct hda_codec
*codec
)
4706 struct alc_spec
*spec
= codec
->spec
;
4707 snd_hda_codec_write(codec
, 0x01, 0, AC_VERB_SET_GPIO_DATA
,
4708 spec
->hp_jack_present
);
4711 static void alc260_fixup_gpio1_toggle(struct hda_codec
*codec
,
4712 const struct alc_fixup
*fix
, int action
)
4714 struct alc_spec
*spec
= codec
->spec
;
4715 if (action
== ALC_FIXUP_ACT_PROBE
) {
4716 /* although the machine has only one output pin, we need to
4717 * toggle GPIO1 according to the jack state
4719 spec
->automute_hook
= alc260_gpio1_automute
;
4720 spec
->detect_hp
= 1;
4721 spec
->automute_speaker
= 1;
4722 spec
->autocfg
.hp_pins
[0] = 0x0f; /* copy it for automute */
4723 snd_hda_jack_detect_enable(codec
, 0x0f, ALC_HP_EVENT
);
4724 spec
->unsol_event
= alc_sku_unsol_event
;
4725 snd_hda_gen_add_verbs(&spec
->gen
, alc_gpio1_init_verbs
);
4729 static void alc260_fixup_kn1(struct hda_codec
*codec
,
4730 const struct alc_fixup
*fix
, int action
)
4732 struct alc_spec
*spec
= codec
->spec
;
4733 static const struct alc_pincfg pincfgs
[] = {
4734 { 0x0f, 0x02214000 }, /* HP/speaker */
4735 { 0x12, 0x90a60160 }, /* int mic */
4736 { 0x13, 0x02a19000 }, /* ext mic */
4737 { 0x18, 0x01446000 }, /* SPDIF out */
4738 /* disable bogus I/O pins */
4739 { 0x10, 0x411111f0 },
4740 { 0x11, 0x411111f0 },
4741 { 0x14, 0x411111f0 },
4742 { 0x15, 0x411111f0 },
4743 { 0x16, 0x411111f0 },
4744 { 0x17, 0x411111f0 },
4745 { 0x19, 0x411111f0 },
4750 case ALC_FIXUP_ACT_PRE_PROBE
:
4751 alc_apply_pincfgs(codec
, pincfgs
);
4753 case ALC_FIXUP_ACT_PROBE
:
4754 spec
->init_amp
= ALC_INIT_NONE
;
4759 static const struct alc_fixup alc260_fixups
[] = {
4760 [ALC260_FIXUP_HP_DC5750
] = {
4761 .type
= ALC_FIXUP_PINS
,
4762 .v
.pins
= (const struct alc_pincfg
[]) {
4763 { 0x11, 0x90130110 }, /* speaker */
4767 [ALC260_FIXUP_HP_PIN_0F
] = {
4768 .type
= ALC_FIXUP_PINS
,
4769 .v
.pins
= (const struct alc_pincfg
[]) {
4770 { 0x0f, 0x01214000 }, /* HP */
4774 [ALC260_FIXUP_COEF
] = {
4775 .type
= ALC_FIXUP_VERBS
,
4776 .v
.verbs
= (const struct hda_verb
[]) {
4777 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4778 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3040 },
4782 .chain_id
= ALC260_FIXUP_HP_PIN_0F
,
4784 [ALC260_FIXUP_GPIO1
] = {
4785 .type
= ALC_FIXUP_VERBS
,
4786 .v
.verbs
= alc_gpio1_init_verbs
,
4788 [ALC260_FIXUP_GPIO1_TOGGLE
] = {
4789 .type
= ALC_FIXUP_FUNC
,
4790 .v
.func
= alc260_fixup_gpio1_toggle
,
4792 .chain_id
= ALC260_FIXUP_HP_PIN_0F
,
4794 [ALC260_FIXUP_REPLACER
] = {
4795 .type
= ALC_FIXUP_VERBS
,
4796 .v
.verbs
= (const struct hda_verb
[]) {
4797 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4798 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
4802 .chain_id
= ALC260_FIXUP_GPIO1_TOGGLE
,
4804 [ALC260_FIXUP_HP_B1900
] = {
4805 .type
= ALC_FIXUP_FUNC
,
4806 .v
.func
= alc260_fixup_gpio1_toggle
,
4808 .chain_id
= ALC260_FIXUP_COEF
,
4810 [ALC260_FIXUP_KN1
] = {
4811 .type
= ALC_FIXUP_FUNC
,
4812 .v
.func
= alc260_fixup_kn1
,
4816 static const struct snd_pci_quirk alc260_fixup_tbl
[] = {
4817 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1
),
4818 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF
),
4819 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1
),
4820 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750
),
4821 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900
),
4822 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1
),
4823 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1
),
4824 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER
),
4825 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF
),
4831 static int patch_alc260(struct hda_codec
*codec
)
4833 struct alc_spec
*spec
;
4836 err
= alc_alloc_spec(codec
, 0x07);
4842 alc_pick_fixup(codec
, NULL
, alc260_fixup_tbl
, alc260_fixups
);
4843 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
4845 /* automatic parse from the BIOS config */
4846 err
= alc260_parse_auto_config(codec
);
4850 if (!spec
->no_analog
) {
4851 err
= snd_hda_attach_beep_device(codec
, 0x1);
4854 set_beep_amp(spec
, 0x07, 0x05, HDA_INPUT
);
4857 codec
->patch_ops
= alc_patch_ops
;
4858 spec
->shutup
= alc_eapd_shutup
;
4860 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
4871 * ALC882/883/885/888/889 support
4873 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4874 * configuration. Each pin widget can choose any input DACs and a mixer.
4875 * Each ADC is connected from a mixer of all inputs. This makes possible
4876 * 6-channel independent captures.
4878 * In addition, an independent DAC for the multi-playback (not used in this
4886 ALC882_FIXUP_ABIT_AW9D_MAX
,
4887 ALC882_FIXUP_LENOVO_Y530
,
4888 ALC882_FIXUP_PB_M5210
,
4889 ALC882_FIXUP_ACER_ASPIRE_7736
,
4890 ALC882_FIXUP_ASUS_W90V
,
4892 ALC889_FIXUP_VAIO_TT
,
4893 ALC888_FIXUP_EEE1601
,
4896 ALC883_FIXUP_ACER_EAPD
,
4901 ALC882_FIXUP_ASUS_W2JC
,
4902 ALC882_FIXUP_ACER_ASPIRE_4930G
,
4903 ALC882_FIXUP_ACER_ASPIRE_8930G
,
4904 ALC882_FIXUP_ASPIRE_8930G_VERBS
,
4905 ALC885_FIXUP_MACPRO_GPIO
,
4906 ALC889_FIXUP_DAC_ROUTE
,
4907 ALC889_FIXUP_MBP_VREF
,
4908 ALC889_FIXUP_IMAC91_VREF
,
4911 static void alc889_fixup_coef(struct hda_codec
*codec
,
4912 const struct alc_fixup
*fix
, int action
)
4914 if (action
!= ALC_FIXUP_ACT_INIT
)
4916 alc889_coef_init(codec
);
4919 /* toggle speaker-output according to the hp-jack state */
4920 static void alc882_gpio_mute(struct hda_codec
*codec
, int pin
, int muted
)
4922 unsigned int gpiostate
, gpiomask
, gpiodir
;
4924 gpiostate
= snd_hda_codec_read(codec
, codec
->afg
, 0,
4925 AC_VERB_GET_GPIO_DATA
, 0);
4928 gpiostate
|= (1 << pin
);
4930 gpiostate
&= ~(1 << pin
);
4932 gpiomask
= snd_hda_codec_read(codec
, codec
->afg
, 0,
4933 AC_VERB_GET_GPIO_MASK
, 0);
4934 gpiomask
|= (1 << pin
);
4936 gpiodir
= snd_hda_codec_read(codec
, codec
->afg
, 0,
4937 AC_VERB_GET_GPIO_DIRECTION
, 0);
4938 gpiodir
|= (1 << pin
);
4941 snd_hda_codec_write(codec
, codec
->afg
, 0,
4942 AC_VERB_SET_GPIO_MASK
, gpiomask
);
4943 snd_hda_codec_write(codec
, codec
->afg
, 0,
4944 AC_VERB_SET_GPIO_DIRECTION
, gpiodir
);
4948 snd_hda_codec_write(codec
, codec
->afg
, 0,
4949 AC_VERB_SET_GPIO_DATA
, gpiostate
);
4952 /* set up GPIO at initialization */
4953 static void alc885_fixup_macpro_gpio(struct hda_codec
*codec
,
4954 const struct alc_fixup
*fix
, int action
)
4956 if (action
!= ALC_FIXUP_ACT_INIT
)
4958 alc882_gpio_mute(codec
, 0, 0);
4959 alc882_gpio_mute(codec
, 1, 0);
4962 /* Fix the connection of some pins for ALC889:
4963 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
4964 * work correctly (bko#42740)
4966 static void alc889_fixup_dac_route(struct hda_codec
*codec
,
4967 const struct alc_fixup
*fix
, int action
)
4969 if (action
== ALC_FIXUP_ACT_PRE_PROBE
) {
4970 /* fake the connections during parsing the tree */
4971 hda_nid_t conn1
[2] = { 0x0c, 0x0d };
4972 hda_nid_t conn2
[2] = { 0x0e, 0x0f };
4973 snd_hda_override_conn_list(codec
, 0x14, 2, conn1
);
4974 snd_hda_override_conn_list(codec
, 0x15, 2, conn1
);
4975 snd_hda_override_conn_list(codec
, 0x18, 2, conn2
);
4976 snd_hda_override_conn_list(codec
, 0x1a, 2, conn2
);
4977 } else if (action
== ALC_FIXUP_ACT_PROBE
) {
4978 /* restore the connections */
4979 hda_nid_t conn
[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
4980 snd_hda_override_conn_list(codec
, 0x14, 5, conn
);
4981 snd_hda_override_conn_list(codec
, 0x15, 5, conn
);
4982 snd_hda_override_conn_list(codec
, 0x18, 5, conn
);
4983 snd_hda_override_conn_list(codec
, 0x1a, 5, conn
);
4987 /* Set VREF on HP pin */
4988 static void alc889_fixup_mbp_vref(struct hda_codec
*codec
,
4989 const struct alc_fixup
*fix
, int action
)
4991 struct alc_spec
*spec
= codec
->spec
;
4992 static hda_nid_t nids
[2] = { 0x14, 0x15 };
4995 if (action
!= ALC_FIXUP_ACT_INIT
)
4997 for (i
= 0; i
< ARRAY_SIZE(nids
); i
++) {
4998 unsigned int val
= snd_hda_codec_get_pincfg(codec
, nids
[i
]);
4999 if (get_defcfg_device(val
) != AC_JACK_HP_OUT
)
5001 val
= snd_hda_codec_read(codec
, nids
[i
], 0,
5002 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
5003 val
|= AC_PINCTL_VREF_80
;
5004 snd_hda_set_pin_ctl(codec
, nids
[i
], val
);
5005 spec
->keep_vref_in_automute
= 1;
5010 /* Set VREF on speaker pins on imac91 */
5011 static void alc889_fixup_imac91_vref(struct hda_codec
*codec
,
5012 const struct alc_fixup
*fix
, int action
)
5014 struct alc_spec
*spec
= codec
->spec
;
5015 static hda_nid_t nids
[2] = { 0x18, 0x1a };
5018 if (action
!= ALC_FIXUP_ACT_INIT
)
5020 for (i
= 0; i
< ARRAY_SIZE(nids
); i
++) {
5022 val
= snd_hda_codec_read(codec
, nids
[i
], 0,
5023 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
5024 val
|= AC_PINCTL_VREF_50
;
5025 snd_hda_set_pin_ctl(codec
, nids
[i
], val
);
5027 spec
->keep_vref_in_automute
= 1;
5030 static const struct alc_fixup alc882_fixups
[] = {
5031 [ALC882_FIXUP_ABIT_AW9D_MAX
] = {
5032 .type
= ALC_FIXUP_PINS
,
5033 .v
.pins
= (const struct alc_pincfg
[]) {
5034 { 0x15, 0x01080104 }, /* side */
5035 { 0x16, 0x01011012 }, /* rear */
5036 { 0x17, 0x01016011 }, /* clfe */
5040 [ALC882_FIXUP_LENOVO_Y530
] = {
5041 .type
= ALC_FIXUP_PINS
,
5042 .v
.pins
= (const struct alc_pincfg
[]) {
5043 { 0x15, 0x99130112 }, /* rear int speakers */
5044 { 0x16, 0x99130111 }, /* subwoofer */
5048 [ALC882_FIXUP_PB_M5210
] = {
5049 .type
= ALC_FIXUP_VERBS
,
5050 .v
.verbs
= (const struct hda_verb
[]) {
5051 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF50
},
5055 [ALC882_FIXUP_ACER_ASPIRE_7736
] = {
5056 .type
= ALC_FIXUP_FUNC
,
5057 .v
.func
= alc_fixup_sku_ignore
,
5059 [ALC882_FIXUP_ASUS_W90V
] = {
5060 .type
= ALC_FIXUP_PINS
,
5061 .v
.pins
= (const struct alc_pincfg
[]) {
5062 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
5066 [ALC889_FIXUP_CD
] = {
5067 .type
= ALC_FIXUP_PINS
,
5068 .v
.pins
= (const struct alc_pincfg
[]) {
5069 { 0x1c, 0x993301f0 }, /* CD */
5073 [ALC889_FIXUP_VAIO_TT
] = {
5074 .type
= ALC_FIXUP_PINS
,
5075 .v
.pins
= (const struct alc_pincfg
[]) {
5076 { 0x17, 0x90170111 }, /* hidden surround speaker */
5080 [ALC888_FIXUP_EEE1601
] = {
5081 .type
= ALC_FIXUP_VERBS
,
5082 .v
.verbs
= (const struct hda_verb
[]) {
5083 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x0b },
5084 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0838 },
5088 [ALC882_FIXUP_EAPD
] = {
5089 .type
= ALC_FIXUP_VERBS
,
5090 .v
.verbs
= (const struct hda_verb
[]) {
5091 /* change to EAPD mode */
5092 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5093 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
5097 [ALC883_FIXUP_EAPD
] = {
5098 .type
= ALC_FIXUP_VERBS
,
5099 .v
.verbs
= (const struct hda_verb
[]) {
5100 /* change to EAPD mode */
5101 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5102 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
5106 [ALC883_FIXUP_ACER_EAPD
] = {
5107 .type
= ALC_FIXUP_VERBS
,
5108 .v
.verbs
= (const struct hda_verb
[]) {
5109 /* eanable EAPD on Acer laptops */
5110 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5111 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5115 [ALC882_FIXUP_GPIO1
] = {
5116 .type
= ALC_FIXUP_VERBS
,
5117 .v
.verbs
= alc_gpio1_init_verbs
,
5119 [ALC882_FIXUP_GPIO2
] = {
5120 .type
= ALC_FIXUP_VERBS
,
5121 .v
.verbs
= alc_gpio2_init_verbs
,
5123 [ALC882_FIXUP_GPIO3
] = {
5124 .type
= ALC_FIXUP_VERBS
,
5125 .v
.verbs
= alc_gpio3_init_verbs
,
5127 [ALC882_FIXUP_ASUS_W2JC
] = {
5128 .type
= ALC_FIXUP_VERBS
,
5129 .v
.verbs
= alc_gpio1_init_verbs
,
5131 .chain_id
= ALC882_FIXUP_EAPD
,
5133 [ALC889_FIXUP_COEF
] = {
5134 .type
= ALC_FIXUP_FUNC
,
5135 .v
.func
= alc889_fixup_coef
,
5137 [ALC882_FIXUP_ACER_ASPIRE_4930G
] = {
5138 .type
= ALC_FIXUP_PINS
,
5139 .v
.pins
= (const struct alc_pincfg
[]) {
5140 { 0x16, 0x99130111 }, /* CLFE speaker */
5141 { 0x17, 0x99130112 }, /* surround speaker */
5145 .chain_id
= ALC882_FIXUP_GPIO1
,
5147 [ALC882_FIXUP_ACER_ASPIRE_8930G
] = {
5148 .type
= ALC_FIXUP_PINS
,
5149 .v
.pins
= (const struct alc_pincfg
[]) {
5150 { 0x16, 0x99130111 }, /* CLFE speaker */
5151 { 0x1b, 0x99130112 }, /* surround speaker */
5155 .chain_id
= ALC882_FIXUP_ASPIRE_8930G_VERBS
,
5157 [ALC882_FIXUP_ASPIRE_8930G_VERBS
] = {
5158 /* additional init verbs for Acer Aspire 8930G */
5159 .type
= ALC_FIXUP_VERBS
,
5160 .v
.verbs
= (const struct hda_verb
[]) {
5161 /* Enable all DACs */
5162 /* DAC DISABLE/MUTE 1? */
5163 /* setting bits 1-5 disables DAC nids 0x02-0x06
5164 * apparently. Init=0x38 */
5165 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x03 },
5166 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0000 },
5167 /* DAC DISABLE/MUTE 2? */
5168 /* some bit here disables the other DACs.
5170 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x08 },
5171 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0000 },
5173 * This laptop has a stereo digital microphone.
5174 * The mics are only 1cm apart which makes the stereo
5175 * useless. However, either the mic or the ALC889
5176 * makes the signal become a difference/sum signal
5177 * instead of standard stereo, which is annoying.
5178 * So instead we flip this bit which makes the
5179 * codec replicate the sum signal to both channels,
5180 * turning it into a normal mono mic.
5182 /* DMIC_CONTROL? Init value = 0x0001 */
5183 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x0b },
5184 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0003 },
5185 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5186 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5190 .chain_id
= ALC882_FIXUP_GPIO1
,
5192 [ALC885_FIXUP_MACPRO_GPIO
] = {
5193 .type
= ALC_FIXUP_FUNC
,
5194 .v
.func
= alc885_fixup_macpro_gpio
,
5196 [ALC889_FIXUP_DAC_ROUTE
] = {
5197 .type
= ALC_FIXUP_FUNC
,
5198 .v
.func
= alc889_fixup_dac_route
,
5200 [ALC889_FIXUP_MBP_VREF
] = {
5201 .type
= ALC_FIXUP_FUNC
,
5202 .v
.func
= alc889_fixup_mbp_vref
,
5204 .chain_id
= ALC882_FIXUP_GPIO1
,
5206 [ALC889_FIXUP_IMAC91_VREF
] = {
5207 .type
= ALC_FIXUP_FUNC
,
5208 .v
.func
= alc889_fixup_imac91_vref
,
5210 .chain_id
= ALC882_FIXUP_GPIO1
,
5214 static const struct snd_pci_quirk alc882_fixup_tbl
[] = {
5215 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD
),
5216 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD
),
5217 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD
),
5218 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD
),
5219 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD
),
5220 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD
),
5221 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
5222 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5223 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
5224 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5225 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
5226 ALC882_FIXUP_ACER_ASPIRE_8930G
),
5227 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
5228 ALC882_FIXUP_ACER_ASPIRE_8930G
),
5229 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
5230 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5231 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
5232 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5233 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
5234 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5235 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210
),
5236 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
5237 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5238 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE
),
5239 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G
),
5240 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736
),
5241 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD
),
5242 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V
),
5243 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC
),
5244 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601
),
5245 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT
),
5247 /* All Apple entries are in codec SSIDs */
5248 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF
),
5249 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF
),
5250 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF
),
5251 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO
),
5252 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO
),
5253 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO
),
5254 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF
),
5255 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF
),
5256 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD
),
5257 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF
),
5258 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF
),
5259 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF
),
5260 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF
),
5261 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO
),
5262 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF
),
5263 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF
),
5264 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF
),
5265 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO
),
5266 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF
),
5267 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF
),
5268 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF
),
5270 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD
),
5271 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD
),
5272 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3
),
5273 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD
),
5274 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX
),
5275 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD
),
5276 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD
),
5277 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530
),
5278 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF
),
5282 static const struct alc_model_fixup alc882_fixup_models
[] = {
5283 {.id
= ALC882_FIXUP_ACER_ASPIRE_4930G
, .name
= "acer-aspire-4930g"},
5284 {.id
= ALC882_FIXUP_ACER_ASPIRE_8930G
, .name
= "acer-aspire-8930g"},
5285 {.id
= ALC883_FIXUP_ACER_EAPD
, .name
= "acer-aspire"},
5290 * BIOS auto configuration
5292 /* almost identical with ALC880 parser... */
5293 static int alc882_parse_auto_config(struct hda_codec
*codec
)
5295 static const hda_nid_t alc882_ignore
[] = { 0x1d, 0 };
5296 static const hda_nid_t alc882_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5297 return alc_parse_auto_config(codec
, alc882_ignore
, alc882_ssids
);
5302 static int patch_alc882(struct hda_codec
*codec
)
5304 struct alc_spec
*spec
;
5307 err
= alc_alloc_spec(codec
, 0x0b);
5313 switch (codec
->vendor_id
) {
5318 /* ALC883 and variants */
5319 alc_fix_pll_init(codec
, 0x20, 0x0a, 10);
5323 alc_pick_fixup(codec
, alc882_fixup_models
, alc882_fixup_tbl
,
5325 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5327 alc_auto_parse_customize_define(codec
);
5329 /* automatic parse from the BIOS config */
5330 err
= alc882_parse_auto_config(codec
);
5334 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
5335 err
= snd_hda_attach_beep_device(codec
, 0x1);
5338 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
5341 codec
->patch_ops
= alc_patch_ops
;
5343 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5356 static int alc262_parse_auto_config(struct hda_codec
*codec
)
5358 static const hda_nid_t alc262_ignore
[] = { 0x1d, 0 };
5359 static const hda_nid_t alc262_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5360 return alc_parse_auto_config(codec
, alc262_ignore
, alc262_ssids
);
5367 ALC262_FIXUP_FSC_H270
,
5368 ALC262_FIXUP_HP_Z200
,
5370 ALC262_FIXUP_LENOVO_3000
,
5372 ALC262_FIXUP_BENQ_T31
,
5375 static const struct alc_fixup alc262_fixups
[] = {
5376 [ALC262_FIXUP_FSC_H270
] = {
5377 .type
= ALC_FIXUP_PINS
,
5378 .v
.pins
= (const struct alc_pincfg
[]) {
5379 { 0x14, 0x99130110 }, /* speaker */
5380 { 0x15, 0x0221142f }, /* front HP */
5381 { 0x1b, 0x0121141f }, /* rear HP */
5385 [ALC262_FIXUP_HP_Z200
] = {
5386 .type
= ALC_FIXUP_PINS
,
5387 .v
.pins
= (const struct alc_pincfg
[]) {
5388 { 0x16, 0x99130120 }, /* internal speaker */
5392 [ALC262_FIXUP_TYAN
] = {
5393 .type
= ALC_FIXUP_PINS
,
5394 .v
.pins
= (const struct alc_pincfg
[]) {
5395 { 0x14, 0x1993e1f0 }, /* int AUX */
5399 [ALC262_FIXUP_LENOVO_3000
] = {
5400 .type
= ALC_FIXUP_VERBS
,
5401 .v
.verbs
= (const struct hda_verb
[]) {
5402 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF50
},
5406 .chain_id
= ALC262_FIXUP_BENQ
,
5408 [ALC262_FIXUP_BENQ
] = {
5409 .type
= ALC_FIXUP_VERBS
,
5410 .v
.verbs
= (const struct hda_verb
[]) {
5411 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5412 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
5416 [ALC262_FIXUP_BENQ_T31
] = {
5417 .type
= ALC_FIXUP_VERBS
,
5418 .v
.verbs
= (const struct hda_verb
[]) {
5419 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5420 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5426 static const struct snd_pci_quirk alc262_fixup_tbl
[] = {
5427 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200
),
5428 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ
),
5429 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ
),
5430 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN
),
5431 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270
),
5432 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000
),
5433 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ
),
5434 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31
),
5441 static int patch_alc262(struct hda_codec
*codec
)
5443 struct alc_spec
*spec
;
5446 err
= alc_alloc_spec(codec
, 0x0b);
5453 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
5458 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
5459 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
5460 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
5461 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PROC_COEF
, tmp
| 0x80);
5464 alc_fix_pll_init(codec
, 0x20, 0x0a, 10);
5466 alc_pick_fixup(codec
, NULL
, alc262_fixup_tbl
, alc262_fixups
);
5467 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5469 alc_auto_parse_customize_define(codec
);
5471 /* automatic parse from the BIOS config */
5472 err
= alc262_parse_auto_config(codec
);
5476 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
5477 err
= snd_hda_attach_beep_device(codec
, 0x1);
5480 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
5483 codec
->patch_ops
= alc_patch_ops
;
5484 spec
->shutup
= alc_eapd_shutup
;
5486 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5498 /* bind Beep switches of both NID 0x0f and 0x10 */
5499 static const struct hda_bind_ctls alc268_bind_beep_sw
= {
5500 .ops
= &snd_hda_bind_sw
,
5502 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT
),
5503 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT
),
5508 static const struct snd_kcontrol_new alc268_beep_mixer
[] = {
5509 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT
),
5510 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw
),
5514 /* set PCBEEP vol = 0, mute connections */
5515 static const struct hda_verb alc268_beep_init_verbs
[] = {
5516 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5517 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5518 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5523 * BIOS auto configuration
5525 static int alc268_parse_auto_config(struct hda_codec
*codec
)
5527 static const hda_nid_t alc268_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5528 struct alc_spec
*spec
= codec
->spec
;
5529 int err
= alc_parse_auto_config(codec
, NULL
, alc268_ssids
);
5531 if (!spec
->no_analog
&& spec
->autocfg
.speaker_pins
[0] != 0x1d) {
5532 add_mixer(spec
, alc268_beep_mixer
);
5533 snd_hda_gen_add_verbs(&spec
->gen
, alc268_beep_init_verbs
);
5541 static int patch_alc268(struct hda_codec
*codec
)
5543 struct alc_spec
*spec
;
5544 int i
, has_beep
, err
;
5546 /* ALC268 has no aa-loopback mixer */
5547 err
= alc_alloc_spec(codec
, 0);
5553 /* automatic parse from the BIOS config */
5554 err
= alc268_parse_auto_config(codec
);
5559 for (i
= 0; i
< spec
->num_mixers
; i
++) {
5560 if (spec
->mixers
[i
] == alc268_beep_mixer
) {
5567 err
= snd_hda_attach_beep_device(codec
, 0x1);
5570 if (!query_amp_caps(codec
, 0x1d, HDA_INPUT
))
5571 /* override the amp caps for beep generator */
5572 snd_hda_override_amp_caps(codec
, 0x1d, HDA_INPUT
,
5573 (0x0c << AC_AMPCAP_OFFSET_SHIFT
) |
5574 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT
) |
5575 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
5576 (0 << AC_AMPCAP_MUTE_SHIFT
));
5579 codec
->patch_ops
= alc_patch_ops
;
5580 spec
->shutup
= alc_eapd_shutup
;
5592 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback
= {
5596 .rates
= SNDRV_PCM_RATE_44100
, /* fixed rate */
5597 /* NID is set in alc_build_pcms */
5599 .open
= alc_playback_pcm_open
,
5600 .prepare
= alc_playback_pcm_prepare
,
5601 .cleanup
= alc_playback_pcm_cleanup
5605 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture
= {
5609 .rates
= SNDRV_PCM_RATE_44100
, /* fixed rate */
5610 /* NID is set in alc_build_pcms */
5613 /* different alc269-variants */
5615 ALC269_TYPE_ALC269VA
,
5616 ALC269_TYPE_ALC269VB
,
5617 ALC269_TYPE_ALC269VC
,
5618 ALC269_TYPE_ALC269VD
,
5622 * BIOS auto configuration
5624 static int alc269_parse_auto_config(struct hda_codec
*codec
)
5626 static const hda_nid_t alc269_ignore
[] = { 0x1d, 0 };
5627 static const hda_nid_t alc269_ssids
[] = { 0, 0x1b, 0x14, 0x21 };
5628 static const hda_nid_t alc269va_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5629 struct alc_spec
*spec
= codec
->spec
;
5630 const hda_nid_t
*ssids
;
5632 switch (spec
->codec_variant
) {
5633 case ALC269_TYPE_ALC269VA
:
5634 case ALC269_TYPE_ALC269VC
:
5635 ssids
= alc269va_ssids
;
5637 case ALC269_TYPE_ALC269VB
:
5638 case ALC269_TYPE_ALC269VD
:
5639 ssids
= alc269_ssids
;
5642 ssids
= alc269_ssids
;
5646 return alc_parse_auto_config(codec
, alc269_ignore
, ssids
);
5649 static void alc269_toggle_power_output(struct hda_codec
*codec
, int power_up
)
5651 int val
= alc_read_coef_idx(codec
, 0x04);
5656 alc_write_coef_idx(codec
, 0x04, val
);
5659 static void alc269_shutup(struct hda_codec
*codec
)
5661 struct alc_spec
*spec
= codec
->spec
;
5663 if (spec
->codec_variant
!= ALC269_TYPE_ALC269VB
)
5666 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017)
5667 alc269_toggle_power_output(codec
, 0);
5668 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
5669 alc269_toggle_power_output(codec
, 0);
5675 static int alc269_resume(struct hda_codec
*codec
)
5677 struct alc_spec
*spec
= codec
->spec
;
5679 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
||
5680 (alc_get_coef0(codec
) & 0x00ff) == 0x018) {
5681 alc269_toggle_power_output(codec
, 0);
5685 codec
->patch_ops
.init(codec
);
5687 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
||
5688 (alc_get_coef0(codec
) & 0x00ff) == 0x017) {
5689 alc269_toggle_power_output(codec
, 1);
5693 if (spec
->codec_variant
== ALC269_TYPE_ALC269VB
||
5694 (alc_get_coef0(codec
) & 0x00ff) == 0x018)
5695 alc269_toggle_power_output(codec
, 1);
5697 snd_hda_codec_resume_amp(codec
);
5698 snd_hda_codec_resume_cache(codec
);
5699 hda_call_check_power_status(codec
, 0x01);
5702 #endif /* CONFIG_PM */
5704 static void alc269_fixup_hweq(struct hda_codec
*codec
,
5705 const struct alc_fixup
*fix
, int action
)
5709 if (action
!= ALC_FIXUP_ACT_INIT
)
5711 coef
= alc_read_coef_idx(codec
, 0x1e);
5712 alc_write_coef_idx(codec
, 0x1e, coef
| 0x80);
5715 static void alc271_fixup_dmic(struct hda_codec
*codec
,
5716 const struct alc_fixup
*fix
, int action
)
5718 static const struct hda_verb verbs
[] = {
5719 {0x20, AC_VERB_SET_COEF_INDEX
, 0x0d},
5720 {0x20, AC_VERB_SET_PROC_COEF
, 0x4000},
5725 if (strcmp(codec
->chip_name
, "ALC271X"))
5727 cfg
= snd_hda_codec_get_pincfg(codec
, 0x12);
5728 if (get_defcfg_connect(cfg
) == AC_JACK_PORT_FIXED
)
5729 snd_hda_sequence_write(codec
, verbs
);
5732 static void alc269_fixup_pcm_44k(struct hda_codec
*codec
,
5733 const struct alc_fixup
*fix
, int action
)
5735 struct alc_spec
*spec
= codec
->spec
;
5737 if (action
!= ALC_FIXUP_ACT_PROBE
)
5740 /* Due to a hardware problem on Lenovo Ideadpad, we need to
5741 * fix the sample rate of analog I/O to 44.1kHz
5743 spec
->stream_analog_playback
= &alc269_44k_pcm_analog_playback
;
5744 spec
->stream_analog_capture
= &alc269_44k_pcm_analog_capture
;
5747 static void alc269_fixup_stereo_dmic(struct hda_codec
*codec
,
5748 const struct alc_fixup
*fix
, int action
)
5752 if (action
!= ALC_FIXUP_ACT_INIT
)
5754 /* The digital-mic unit sends PDM (differential signal) instead of
5755 * the standard PCM, thus you can't record a valid mono stream as is.
5756 * Below is a workaround specific to ALC269 to control the dmic
5757 * signal source as mono.
5759 coef
= alc_read_coef_idx(codec
, 0x07);
5760 alc_write_coef_idx(codec
, 0x07, coef
| 0x80);
5763 static void alc269_quanta_automute(struct hda_codec
*codec
)
5765 update_outputs(codec
);
5767 snd_hda_codec_write(codec
, 0x20, 0,
5768 AC_VERB_SET_COEF_INDEX
, 0x0c);
5769 snd_hda_codec_write(codec
, 0x20, 0,
5770 AC_VERB_SET_PROC_COEF
, 0x680);
5772 snd_hda_codec_write(codec
, 0x20, 0,
5773 AC_VERB_SET_COEF_INDEX
, 0x0c);
5774 snd_hda_codec_write(codec
, 0x20, 0,
5775 AC_VERB_SET_PROC_COEF
, 0x480);
5778 static void alc269_fixup_quanta_mute(struct hda_codec
*codec
,
5779 const struct alc_fixup
*fix
, int action
)
5781 struct alc_spec
*spec
= codec
->spec
;
5782 if (action
!= ALC_FIXUP_ACT_PROBE
)
5784 spec
->automute_hook
= alc269_quanta_automute
;
5787 /* update mute-LED according to the speaker mute state via mic2 VREF pin */
5788 static void alc269_fixup_mic2_mute_hook(void *private_data
, int enabled
)
5790 struct hda_codec
*codec
= private_data
;
5791 unsigned int pinval
= enabled
? 0x20 : 0x24;
5792 snd_hda_set_pin_ctl_cache(codec
, 0x19, pinval
);
5795 static void alc269_fixup_mic2_mute(struct hda_codec
*codec
,
5796 const struct alc_fixup
*fix
, int action
)
5798 struct alc_spec
*spec
= codec
->spec
;
5800 case ALC_FIXUP_ACT_BUILD
:
5801 spec
->vmaster_mute
.hook
= alc269_fixup_mic2_mute_hook
;
5802 snd_hda_add_vmaster_hook(codec
, &spec
->vmaster_mute
, true);
5804 case ALC_FIXUP_ACT_INIT
:
5805 snd_hda_sync_vmaster_hook(&spec
->vmaster_mute
);
5811 ALC269_FIXUP_SONY_VAIO
,
5812 ALC275_FIXUP_SONY_VAIO_GPIO2
,
5813 ALC269_FIXUP_DELL_M101Z
,
5814 ALC269_FIXUP_SKU_IGNORE
,
5815 ALC269_FIXUP_ASUS_G73JW
,
5816 ALC269_FIXUP_LENOVO_EAPD
,
5817 ALC275_FIXUP_SONY_HWEQ
,
5819 ALC269_FIXUP_PCM_44K
,
5820 ALC269_FIXUP_STEREO_DMIC
,
5821 ALC269_FIXUP_QUANTA_MUTE
,
5822 ALC269_FIXUP_LIFEBOOK
,
5825 ALC269VB_FIXUP_AMIC
,
5826 ALC269VB_FIXUP_DMIC
,
5827 ALC269_FIXUP_MIC2_MUTE_LED
,
5830 static const struct alc_fixup alc269_fixups
[] = {
5831 [ALC269_FIXUP_SONY_VAIO
] = {
5832 .type
= ALC_FIXUP_VERBS
,
5833 .v
.verbs
= (const struct hda_verb
[]) {
5834 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREFGRD
},
5838 [ALC275_FIXUP_SONY_VAIO_GPIO2
] = {
5839 .type
= ALC_FIXUP_VERBS
,
5840 .v
.verbs
= (const struct hda_verb
[]) {
5841 {0x01, AC_VERB_SET_GPIO_MASK
, 0x04},
5842 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x04},
5843 {0x01, AC_VERB_SET_GPIO_DATA
, 0x00},
5847 .chain_id
= ALC269_FIXUP_SONY_VAIO
5849 [ALC269_FIXUP_DELL_M101Z
] = {
5850 .type
= ALC_FIXUP_VERBS
,
5851 .v
.verbs
= (const struct hda_verb
[]) {
5852 /* Enables internal speaker */
5853 {0x20, AC_VERB_SET_COEF_INDEX
, 13},
5854 {0x20, AC_VERB_SET_PROC_COEF
, 0x4040},
5858 [ALC269_FIXUP_SKU_IGNORE
] = {
5859 .type
= ALC_FIXUP_FUNC
,
5860 .v
.func
= alc_fixup_sku_ignore
,
5862 [ALC269_FIXUP_ASUS_G73JW
] = {
5863 .type
= ALC_FIXUP_PINS
,
5864 .v
.pins
= (const struct alc_pincfg
[]) {
5865 { 0x17, 0x99130111 }, /* subwoofer */
5869 [ALC269_FIXUP_LENOVO_EAPD
] = {
5870 .type
= ALC_FIXUP_VERBS
,
5871 .v
.verbs
= (const struct hda_verb
[]) {
5872 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 0},
5876 [ALC275_FIXUP_SONY_HWEQ
] = {
5877 .type
= ALC_FIXUP_FUNC
,
5878 .v
.func
= alc269_fixup_hweq
,
5880 .chain_id
= ALC275_FIXUP_SONY_VAIO_GPIO2
5882 [ALC271_FIXUP_DMIC
] = {
5883 .type
= ALC_FIXUP_FUNC
,
5884 .v
.func
= alc271_fixup_dmic
,
5886 [ALC269_FIXUP_PCM_44K
] = {
5887 .type
= ALC_FIXUP_FUNC
,
5888 .v
.func
= alc269_fixup_pcm_44k
,
5890 [ALC269_FIXUP_STEREO_DMIC
] = {
5891 .type
= ALC_FIXUP_FUNC
,
5892 .v
.func
= alc269_fixup_stereo_dmic
,
5894 [ALC269_FIXUP_QUANTA_MUTE
] = {
5895 .type
= ALC_FIXUP_FUNC
,
5896 .v
.func
= alc269_fixup_quanta_mute
,
5898 [ALC269_FIXUP_LIFEBOOK
] = {
5899 .type
= ALC_FIXUP_PINS
,
5900 .v
.pins
= (const struct alc_pincfg
[]) {
5901 { 0x1a, 0x2101103f }, /* dock line-out */
5902 { 0x1b, 0x23a11040 }, /* dock mic-in */
5906 .chain_id
= ALC269_FIXUP_QUANTA_MUTE
5908 [ALC269_FIXUP_AMIC
] = {
5909 .type
= ALC_FIXUP_PINS
,
5910 .v
.pins
= (const struct alc_pincfg
[]) {
5911 { 0x14, 0x99130110 }, /* speaker */
5912 { 0x15, 0x0121401f }, /* HP out */
5913 { 0x18, 0x01a19c20 }, /* mic */
5914 { 0x19, 0x99a3092f }, /* int-mic */
5918 [ALC269_FIXUP_DMIC
] = {
5919 .type
= ALC_FIXUP_PINS
,
5920 .v
.pins
= (const struct alc_pincfg
[]) {
5921 { 0x12, 0x99a3092f }, /* int-mic */
5922 { 0x14, 0x99130110 }, /* speaker */
5923 { 0x15, 0x0121401f }, /* HP out */
5924 { 0x18, 0x01a19c20 }, /* mic */
5928 [ALC269VB_FIXUP_AMIC
] = {
5929 .type
= ALC_FIXUP_PINS
,
5930 .v
.pins
= (const struct alc_pincfg
[]) {
5931 { 0x14, 0x99130110 }, /* speaker */
5932 { 0x18, 0x01a19c20 }, /* mic */
5933 { 0x19, 0x99a3092f }, /* int-mic */
5934 { 0x21, 0x0121401f }, /* HP out */
5938 [ALC269VB_FIXUP_DMIC
] = {
5939 .type
= ALC_FIXUP_PINS
,
5940 .v
.pins
= (const struct alc_pincfg
[]) {
5941 { 0x12, 0x99a3092f }, /* int-mic */
5942 { 0x14, 0x99130110 }, /* speaker */
5943 { 0x18, 0x01a19c20 }, /* mic */
5944 { 0x21, 0x0121401f }, /* HP out */
5948 [ALC269_FIXUP_MIC2_MUTE_LED
] = {
5949 .type
= ALC_FIXUP_FUNC
,
5950 .v
.func
= alc269_fixup_mic2_mute
,
5954 static const struct snd_pci_quirk alc269_fixup_tbl
[] = {
5955 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED
),
5956 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC
),
5957 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW
),
5958 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC
),
5959 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC
),
5960 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC
),
5961 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC
),
5962 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC
),
5963 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2
),
5964 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ
),
5965 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ
),
5966 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO
),
5967 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z
),
5968 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC
),
5969 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK
),
5970 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE
),
5971 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE
),
5972 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE
),
5973 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE
),
5974 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE
),
5975 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE
),
5976 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K
),
5977 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD
),
5980 /* Below is a quirk table taken from the old code.
5981 * Basically the device should work as is without the fixup table.
5982 * If BIOS doesn't give a proper info, enable the corresponding
5985 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
5987 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC
),
5988 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC
),
5989 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC
),
5990 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC
),
5991 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC
),
5992 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC
),
5993 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC
),
5994 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC
),
5995 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC
),
5996 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC
),
5997 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC
),
5998 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC
),
5999 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC
),
6000 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC
),
6001 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC
),
6002 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC
),
6003 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC
),
6004 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC
),
6005 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC
),
6006 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC
),
6007 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC
),
6008 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC
),
6009 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC
),
6010 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC
),
6011 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC
),
6012 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC
),
6013 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC
),
6014 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC
),
6015 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC
),
6016 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC
),
6017 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC
),
6018 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC
),
6019 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC
),
6020 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC
),
6021 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC
),
6022 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC
),
6023 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC
),
6024 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC
),
6025 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC
),
6030 static const struct alc_model_fixup alc269_fixup_models
[] = {
6031 {.id
= ALC269_FIXUP_AMIC
, .name
= "laptop-amic"},
6032 {.id
= ALC269_FIXUP_DMIC
, .name
= "laptop-dmic"},
6037 static void alc269_fill_coef(struct hda_codec
*codec
)
6039 struct alc_spec
*spec
= codec
->spec
;
6042 if (spec
->codec_variant
!= ALC269_TYPE_ALC269VB
)
6045 if ((alc_get_coef0(codec
) & 0x00ff) < 0x015) {
6046 alc_write_coef_idx(codec
, 0xf, 0x960b);
6047 alc_write_coef_idx(codec
, 0xe, 0x8817);
6050 if ((alc_get_coef0(codec
) & 0x00ff) == 0x016) {
6051 alc_write_coef_idx(codec
, 0xf, 0x960b);
6052 alc_write_coef_idx(codec
, 0xe, 0x8814);
6055 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017) {
6056 val
= alc_read_coef_idx(codec
, 0x04);
6057 /* Power up output pin */
6058 alc_write_coef_idx(codec
, 0x04, val
| (1<<11));
6061 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
6062 val
= alc_read_coef_idx(codec
, 0xd);
6063 if ((val
& 0x0c00) >> 10 != 0x1) {
6064 /* Capless ramp up clock control */
6065 alc_write_coef_idx(codec
, 0xd, val
| (1<<10));
6067 val
= alc_read_coef_idx(codec
, 0x17);
6068 if ((val
& 0x01c0) >> 6 != 0x4) {
6069 /* Class D power on reset */
6070 alc_write_coef_idx(codec
, 0x17, val
| (1<<7));
6074 val
= alc_read_coef_idx(codec
, 0xd); /* Class D */
6075 alc_write_coef_idx(codec
, 0xd, val
| (1<<14));
6077 val
= alc_read_coef_idx(codec
, 0x4); /* HP */
6078 alc_write_coef_idx(codec
, 0x4, val
| (1<<11));
6083 static int patch_alc269(struct hda_codec
*codec
)
6085 struct alc_spec
*spec
;
6088 err
= alc_alloc_spec(codec
, 0x0b);
6094 if (codec
->vendor_id
== 0x10ec0269) {
6095 spec
->codec_variant
= ALC269_TYPE_ALC269VA
;
6096 switch (alc_get_coef0(codec
) & 0x00f0) {
6098 if (codec
->bus
->pci
->subsystem_vendor
== 0x1025 &&
6099 spec
->cdefine
.platform_type
== 1)
6100 err
= alc_codec_rename(codec
, "ALC271X");
6101 spec
->codec_variant
= ALC269_TYPE_ALC269VB
;
6104 if (codec
->bus
->pci
->subsystem_vendor
== 0x17aa &&
6105 codec
->bus
->pci
->subsystem_device
== 0x21f3)
6106 err
= alc_codec_rename(codec
, "ALC3202");
6107 spec
->codec_variant
= ALC269_TYPE_ALC269VC
;
6110 spec
->codec_variant
= ALC269_TYPE_ALC269VD
;
6113 alc_fix_pll_init(codec
, 0x20, 0x04, 15);
6117 spec
->init_hook
= alc269_fill_coef
;
6118 alc269_fill_coef(codec
);
6121 alc_pick_fixup(codec
, alc269_fixup_models
,
6122 alc269_fixup_tbl
, alc269_fixups
);
6123 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6125 alc_auto_parse_customize_define(codec
);
6127 /* automatic parse from the BIOS config */
6128 err
= alc269_parse_auto_config(codec
);
6132 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
6133 err
= snd_hda_attach_beep_device(codec
, 0x1);
6136 set_beep_amp(spec
, 0x0b, 0x04, HDA_INPUT
);
6139 codec
->patch_ops
= alc_patch_ops
;
6141 codec
->patch_ops
.resume
= alc269_resume
;
6143 spec
->shutup
= alc269_shutup
;
6145 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6158 static int alc861_parse_auto_config(struct hda_codec
*codec
)
6160 static const hda_nid_t alc861_ignore
[] = { 0x1d, 0 };
6161 static const hda_nid_t alc861_ssids
[] = { 0x0e, 0x0f, 0x0b, 0 };
6162 return alc_parse_auto_config(codec
, alc861_ignore
, alc861_ssids
);
6165 /* Pin config fixes */
6167 ALC861_FIXUP_FSC_AMILO_PI1505
,
6168 ALC861_FIXUP_AMP_VREF_0F
,
6169 ALC861_FIXUP_NO_JACK_DETECT
,
6170 ALC861_FIXUP_ASUS_A6RP
,
6173 /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
6174 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec
*codec
,
6175 const struct alc_fixup
*fix
, int action
)
6177 struct alc_spec
*spec
= codec
->spec
;
6180 if (action
!= ALC_FIXUP_ACT_INIT
)
6182 val
= snd_hda_codec_read(codec
, 0x0f, 0,
6183 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
6184 if (!(val
& (AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
)))
6185 val
|= AC_PINCTL_IN_EN
;
6186 val
|= AC_PINCTL_VREF_50
;
6187 snd_hda_set_pin_ctl(codec
, 0x0f, val
);
6188 spec
->keep_vref_in_automute
= 1;
6191 /* suppress the jack-detection */
6192 static void alc_fixup_no_jack_detect(struct hda_codec
*codec
,
6193 const struct alc_fixup
*fix
, int action
)
6195 if (action
== ALC_FIXUP_ACT_PRE_PROBE
)
6196 codec
->no_jack_detect
= 1;
6199 static const struct alc_fixup alc861_fixups
[] = {
6200 [ALC861_FIXUP_FSC_AMILO_PI1505
] = {
6201 .type
= ALC_FIXUP_PINS
,
6202 .v
.pins
= (const struct alc_pincfg
[]) {
6203 { 0x0b, 0x0221101f }, /* HP */
6204 { 0x0f, 0x90170310 }, /* speaker */
6208 [ALC861_FIXUP_AMP_VREF_0F
] = {
6209 .type
= ALC_FIXUP_FUNC
,
6210 .v
.func
= alc861_fixup_asus_amp_vref_0f
,
6212 [ALC861_FIXUP_NO_JACK_DETECT
] = {
6213 .type
= ALC_FIXUP_FUNC
,
6214 .v
.func
= alc_fixup_no_jack_detect
,
6216 [ALC861_FIXUP_ASUS_A6RP
] = {
6217 .type
= ALC_FIXUP_FUNC
,
6218 .v
.func
= alc861_fixup_asus_amp_vref_0f
,
6220 .chain_id
= ALC861_FIXUP_NO_JACK_DETECT
,
6224 static const struct snd_pci_quirk alc861_fixup_tbl
[] = {
6225 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP
),
6226 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F
),
6227 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT
),
6228 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F
),
6229 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F
),
6230 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505
),
6236 static int patch_alc861(struct hda_codec
*codec
)
6238 struct alc_spec
*spec
;
6241 err
= alc_alloc_spec(codec
, 0x15);
6247 alc_pick_fixup(codec
, NULL
, alc861_fixup_tbl
, alc861_fixups
);
6248 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6250 /* automatic parse from the BIOS config */
6251 err
= alc861_parse_auto_config(codec
);
6255 if (!spec
->no_analog
) {
6256 err
= snd_hda_attach_beep_device(codec
, 0x23);
6259 set_beep_amp(spec
, 0x23, 0, HDA_OUTPUT
);
6262 codec
->patch_ops
= alc_patch_ops
;
6263 #ifdef CONFIG_SND_HDA_POWER_SAVE
6264 spec
->power_hook
= alc_power_eapd
;
6267 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6281 * In addition, an independent DAC
6283 static int alc861vd_parse_auto_config(struct hda_codec
*codec
)
6285 static const hda_nid_t alc861vd_ignore
[] = { 0x1d, 0 };
6286 static const hda_nid_t alc861vd_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
6287 return alc_parse_auto_config(codec
, alc861vd_ignore
, alc861vd_ssids
);
6291 ALC660VD_FIX_ASUS_GPIO1
,
6292 ALC861VD_FIX_DALLAS
,
6295 /* exclude VREF80 */
6296 static void alc861vd_fixup_dallas(struct hda_codec
*codec
,
6297 const struct alc_fixup
*fix
, int action
)
6299 if (action
== ALC_FIXUP_ACT_PRE_PROBE
) {
6300 snd_hda_override_pin_caps(codec
, 0x18, 0x00001714);
6301 snd_hda_override_pin_caps(codec
, 0x19, 0x0000171c);
6305 static const struct alc_fixup alc861vd_fixups
[] = {
6306 [ALC660VD_FIX_ASUS_GPIO1
] = {
6307 .type
= ALC_FIXUP_VERBS
,
6308 .v
.verbs
= (const struct hda_verb
[]) {
6310 {0x01, AC_VERB_SET_GPIO_MASK
, 0x03},
6311 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
6312 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
6316 [ALC861VD_FIX_DALLAS
] = {
6317 .type
= ALC_FIXUP_FUNC
,
6318 .v
.func
= alc861vd_fixup_dallas
,
6322 static const struct snd_pci_quirk alc861vd_fixup_tbl
[] = {
6323 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS
),
6324 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1
),
6325 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS
),
6329 static const struct hda_verb alc660vd_eapd_verbs
[] = {
6330 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 2},
6331 {0x15, AC_VERB_SET_EAPD_BTLENABLE
, 2},
6337 static int patch_alc861vd(struct hda_codec
*codec
)
6339 struct alc_spec
*spec
;
6342 err
= alc_alloc_spec(codec
, 0x0b);
6348 alc_pick_fixup(codec
, NULL
, alc861vd_fixup_tbl
, alc861vd_fixups
);
6349 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6351 /* automatic parse from the BIOS config */
6352 err
= alc861vd_parse_auto_config(codec
);
6356 if (codec
->vendor_id
== 0x10ec0660) {
6357 /* always turn on EAPD */
6358 snd_hda_gen_add_verbs(&spec
->gen
, alc660vd_eapd_verbs
);
6361 if (!spec
->no_analog
) {
6362 err
= snd_hda_attach_beep_device(codec
, 0x23);
6365 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
6368 codec
->patch_ops
= alc_patch_ops
;
6370 spec
->shutup
= alc_eapd_shutup
;
6372 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6384 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
6385 * configuration. Each pin widget can choose any input DACs and a mixer.
6386 * Each ADC is connected from a mixer of all inputs. This makes possible
6387 * 6-channel independent captures.
6389 * In addition, an independent DAC for the multi-playback (not used in this
6394 * BIOS auto configuration
6397 static int alc662_parse_auto_config(struct hda_codec
*codec
)
6399 static const hda_nid_t alc662_ignore
[] = { 0x1d, 0 };
6400 static const hda_nid_t alc663_ssids
[] = { 0x15, 0x1b, 0x14, 0x21 };
6401 static const hda_nid_t alc662_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
6402 const hda_nid_t
*ssids
;
6404 if (codec
->vendor_id
== 0x10ec0272 || codec
->vendor_id
== 0x10ec0663 ||
6405 codec
->vendor_id
== 0x10ec0665 || codec
->vendor_id
== 0x10ec0670)
6406 ssids
= alc663_ssids
;
6408 ssids
= alc662_ssids
;
6409 return alc_parse_auto_config(codec
, alc662_ignore
, ssids
);
6412 static void alc272_fixup_mario(struct hda_codec
*codec
,
6413 const struct alc_fixup
*fix
, int action
)
6415 if (action
!= ALC_FIXUP_ACT_PROBE
)
6417 if (snd_hda_override_amp_caps(codec
, 0x2, HDA_OUTPUT
,
6418 (0x3b << AC_AMPCAP_OFFSET_SHIFT
) |
6419 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT
) |
6420 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
6421 (0 << AC_AMPCAP_MUTE_SHIFT
)))
6423 "hda_codec: failed to override amp caps for NID 0x2\n");
6427 ALC662_FIXUP_ASPIRE
,
6428 ALC662_FIXUP_IDEAPAD
,
6430 ALC662_FIXUP_CZC_P10T
,
6431 ALC662_FIXUP_SKU_IGNORE
,
6432 ALC662_FIXUP_HP_RP5800
,
6433 ALC662_FIXUP_ASUS_MODE1
,
6434 ALC662_FIXUP_ASUS_MODE2
,
6435 ALC662_FIXUP_ASUS_MODE3
,
6436 ALC662_FIXUP_ASUS_MODE4
,
6437 ALC662_FIXUP_ASUS_MODE5
,
6438 ALC662_FIXUP_ASUS_MODE6
,
6439 ALC662_FIXUP_ASUS_MODE7
,
6440 ALC662_FIXUP_ASUS_MODE8
,
6441 ALC662_FIXUP_NO_JACK_DETECT
,
6444 static const struct alc_fixup alc662_fixups
[] = {
6445 [ALC662_FIXUP_ASPIRE
] = {
6446 .type
= ALC_FIXUP_PINS
,
6447 .v
.pins
= (const struct alc_pincfg
[]) {
6448 { 0x15, 0x99130112 }, /* subwoofer */
6452 [ALC662_FIXUP_IDEAPAD
] = {
6453 .type
= ALC_FIXUP_PINS
,
6454 .v
.pins
= (const struct alc_pincfg
[]) {
6455 { 0x17, 0x99130112 }, /* subwoofer */
6459 [ALC272_FIXUP_MARIO
] = {
6460 .type
= ALC_FIXUP_FUNC
,
6461 .v
.func
= alc272_fixup_mario
,
6463 [ALC662_FIXUP_CZC_P10T
] = {
6464 .type
= ALC_FIXUP_VERBS
,
6465 .v
.verbs
= (const struct hda_verb
[]) {
6466 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 0},
6470 [ALC662_FIXUP_SKU_IGNORE
] = {
6471 .type
= ALC_FIXUP_FUNC
,
6472 .v
.func
= alc_fixup_sku_ignore
,
6474 [ALC662_FIXUP_HP_RP5800
] = {
6475 .type
= ALC_FIXUP_PINS
,
6476 .v
.pins
= (const struct alc_pincfg
[]) {
6477 { 0x14, 0x0221201f }, /* HP out */
6481 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6483 [ALC662_FIXUP_ASUS_MODE1
] = {
6484 .type
= ALC_FIXUP_PINS
,
6485 .v
.pins
= (const struct alc_pincfg
[]) {
6486 { 0x14, 0x99130110 }, /* speaker */
6487 { 0x18, 0x01a19c20 }, /* mic */
6488 { 0x19, 0x99a3092f }, /* int-mic */
6489 { 0x21, 0x0121401f }, /* HP out */
6493 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6495 [ALC662_FIXUP_ASUS_MODE2
] = {
6496 .type
= ALC_FIXUP_PINS
,
6497 .v
.pins
= (const struct alc_pincfg
[]) {
6498 { 0x14, 0x99130110 }, /* speaker */
6499 { 0x18, 0x01a19820 }, /* mic */
6500 { 0x19, 0x99a3092f }, /* int-mic */
6501 { 0x1b, 0x0121401f }, /* HP out */
6505 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6507 [ALC662_FIXUP_ASUS_MODE3
] = {
6508 .type
= ALC_FIXUP_PINS
,
6509 .v
.pins
= (const struct alc_pincfg
[]) {
6510 { 0x14, 0x99130110 }, /* speaker */
6511 { 0x15, 0x0121441f }, /* HP */
6512 { 0x18, 0x01a19840 }, /* mic */
6513 { 0x19, 0x99a3094f }, /* int-mic */
6514 { 0x21, 0x01211420 }, /* HP2 */
6518 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6520 [ALC662_FIXUP_ASUS_MODE4
] = {
6521 .type
= ALC_FIXUP_PINS
,
6522 .v
.pins
= (const struct alc_pincfg
[]) {
6523 { 0x14, 0x99130110 }, /* speaker */
6524 { 0x16, 0x99130111 }, /* speaker */
6525 { 0x18, 0x01a19840 }, /* mic */
6526 { 0x19, 0x99a3094f }, /* int-mic */
6527 { 0x21, 0x0121441f }, /* HP */
6531 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6533 [ALC662_FIXUP_ASUS_MODE5
] = {
6534 .type
= ALC_FIXUP_PINS
,
6535 .v
.pins
= (const struct alc_pincfg
[]) {
6536 { 0x14, 0x99130110 }, /* speaker */
6537 { 0x15, 0x0121441f }, /* HP */
6538 { 0x16, 0x99130111 }, /* speaker */
6539 { 0x18, 0x01a19840 }, /* mic */
6540 { 0x19, 0x99a3094f }, /* int-mic */
6544 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6546 [ALC662_FIXUP_ASUS_MODE6
] = {
6547 .type
= ALC_FIXUP_PINS
,
6548 .v
.pins
= (const struct alc_pincfg
[]) {
6549 { 0x14, 0x99130110 }, /* speaker */
6550 { 0x15, 0x01211420 }, /* HP2 */
6551 { 0x18, 0x01a19840 }, /* mic */
6552 { 0x19, 0x99a3094f }, /* int-mic */
6553 { 0x1b, 0x0121441f }, /* HP */
6557 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6559 [ALC662_FIXUP_ASUS_MODE7
] = {
6560 .type
= ALC_FIXUP_PINS
,
6561 .v
.pins
= (const struct alc_pincfg
[]) {
6562 { 0x14, 0x99130110 }, /* speaker */
6563 { 0x17, 0x99130111 }, /* speaker */
6564 { 0x18, 0x01a19840 }, /* mic */
6565 { 0x19, 0x99a3094f }, /* int-mic */
6566 { 0x1b, 0x01214020 }, /* HP */
6567 { 0x21, 0x0121401f }, /* HP */
6571 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6573 [ALC662_FIXUP_ASUS_MODE8
] = {
6574 .type
= ALC_FIXUP_PINS
,
6575 .v
.pins
= (const struct alc_pincfg
[]) {
6576 { 0x14, 0x99130110 }, /* speaker */
6577 { 0x12, 0x99a30970 }, /* int-mic */
6578 { 0x15, 0x01214020 }, /* HP */
6579 { 0x17, 0x99130111 }, /* speaker */
6580 { 0x18, 0x01a19840 }, /* mic */
6581 { 0x21, 0x0121401f }, /* HP */
6585 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6587 [ALC662_FIXUP_NO_JACK_DETECT
] = {
6588 .type
= ALC_FIXUP_FUNC
,
6589 .v
.func
= alc_fixup_no_jack_detect
,
6593 static const struct snd_pci_quirk alc662_fixup_tbl
[] = {
6594 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2
),
6595 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE
),
6596 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE
),
6597 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE
),
6598 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800
),
6599 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT
),
6600 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2
),
6601 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD
),
6602 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD
),
6603 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD
),
6604 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T
),
6607 /* Below is a quirk table taken from the old code.
6608 * Basically the device should work as is without the fixup table.
6609 * If BIOS doesn't give a proper info, enable the corresponding
6612 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1
),
6613 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3
),
6614 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1
),
6615 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3
),
6616 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6617 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6618 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6619 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1
),
6620 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1
),
6621 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6622 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7
),
6623 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7
),
6624 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8
),
6625 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3
),
6626 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1
),
6627 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6628 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2
),
6629 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1
),
6630 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6631 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6632 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6633 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6634 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1
),
6635 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3
),
6636 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2
),
6637 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6638 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5
),
6639 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6640 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6641 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1
),
6642 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6643 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6644 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3
),
6645 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3
),
6646 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1
),
6647 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1
),
6648 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1
),
6649 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1
),
6650 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1
),
6651 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6652 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2
),
6653 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1
),
6654 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6655 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3
),
6656 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1
),
6657 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1
),
6658 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1
),
6659 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2
),
6660 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6661 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4
),
6666 static const struct alc_model_fixup alc662_fixup_models
[] = {
6667 {.id
= ALC272_FIXUP_MARIO
, .name
= "mario"},
6668 {.id
= ALC662_FIXUP_ASUS_MODE1
, .name
= "asus-mode1"},
6669 {.id
= ALC662_FIXUP_ASUS_MODE2
, .name
= "asus-mode2"},
6670 {.id
= ALC662_FIXUP_ASUS_MODE3
, .name
= "asus-mode3"},
6671 {.id
= ALC662_FIXUP_ASUS_MODE4
, .name
= "asus-mode4"},
6672 {.id
= ALC662_FIXUP_ASUS_MODE5
, .name
= "asus-mode5"},
6673 {.id
= ALC662_FIXUP_ASUS_MODE6
, .name
= "asus-mode6"},
6674 {.id
= ALC662_FIXUP_ASUS_MODE7
, .name
= "asus-mode7"},
6675 {.id
= ALC662_FIXUP_ASUS_MODE8
, .name
= "asus-mode8"},
6682 static int patch_alc662(struct hda_codec
*codec
)
6684 struct alc_spec
*spec
;
6687 err
= alc_alloc_spec(codec
, 0x0b);
6693 /* handle multiple HPs as is */
6694 spec
->parse_flags
= HDA_PINCFG_NO_HP_FIXUP
;
6696 alc_fix_pll_init(codec
, 0x20, 0x04, 15);
6698 if ((alc_get_coef0(codec
) & (1 << 14)) &&
6699 codec
->bus
->pci
->subsystem_vendor
== 0x1025 &&
6700 spec
->cdefine
.platform_type
== 1) {
6701 if (alc_codec_rename(codec
, "ALC272X") < 0)
6705 alc_pick_fixup(codec
, alc662_fixup_models
,
6706 alc662_fixup_tbl
, alc662_fixups
);
6707 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6709 alc_auto_parse_customize_define(codec
);
6711 /* automatic parse from the BIOS config */
6712 err
= alc662_parse_auto_config(codec
);
6716 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
6717 err
= snd_hda_attach_beep_device(codec
, 0x1);
6720 switch (codec
->vendor_id
) {
6722 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
6727 set_beep_amp(spec
, 0x0b, 0x04, HDA_INPUT
);
6730 set_beep_amp(spec
, 0x0b, 0x03, HDA_INPUT
);
6735 codec
->patch_ops
= alc_patch_ops
;
6736 spec
->shutup
= alc_eapd_shutup
;
6738 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6751 static int alc680_parse_auto_config(struct hda_codec
*codec
)
6753 return alc_parse_auto_config(codec
, NULL
, NULL
);
6758 static int patch_alc680(struct hda_codec
*codec
)
6762 /* ALC680 has no aa-loopback mixer */
6763 err
= alc_alloc_spec(codec
, 0);
6767 /* automatic parse from the BIOS config */
6768 err
= alc680_parse_auto_config(codec
);
6774 codec
->patch_ops
= alc_patch_ops
;
6782 static const struct hda_codec_preset snd_hda_preset_realtek
[] = {
6783 { .id
= 0x10ec0221, .name
= "ALC221", .patch
= patch_alc269
},
6784 { .id
= 0x10ec0260, .name
= "ALC260", .patch
= patch_alc260
},
6785 { .id
= 0x10ec0262, .name
= "ALC262", .patch
= patch_alc262
},
6786 { .id
= 0x10ec0267, .name
= "ALC267", .patch
= patch_alc268
},
6787 { .id
= 0x10ec0268, .name
= "ALC268", .patch
= patch_alc268
},
6788 { .id
= 0x10ec0269, .name
= "ALC269", .patch
= patch_alc269
},
6789 { .id
= 0x10ec0270, .name
= "ALC270", .patch
= patch_alc269
},
6790 { .id
= 0x10ec0272, .name
= "ALC272", .patch
= patch_alc662
},
6791 { .id
= 0x10ec0275, .name
= "ALC275", .patch
= patch_alc269
},
6792 { .id
= 0x10ec0276, .name
= "ALC276", .patch
= patch_alc269
},
6793 { .id
= 0x10ec0861, .rev
= 0x100340, .name
= "ALC660",
6794 .patch
= patch_alc861
},
6795 { .id
= 0x10ec0660, .name
= "ALC660-VD", .patch
= patch_alc861vd
},
6796 { .id
= 0x10ec0861, .name
= "ALC861", .patch
= patch_alc861
},
6797 { .id
= 0x10ec0862, .name
= "ALC861-VD", .patch
= patch_alc861vd
},
6798 { .id
= 0x10ec0662, .rev
= 0x100002, .name
= "ALC662 rev2",
6799 .patch
= patch_alc882
},
6800 { .id
= 0x10ec0662, .rev
= 0x100101, .name
= "ALC662 rev1",
6801 .patch
= patch_alc662
},
6802 { .id
= 0x10ec0662, .rev
= 0x100300, .name
= "ALC662 rev3",
6803 .patch
= patch_alc662
},
6804 { .id
= 0x10ec0663, .name
= "ALC663", .patch
= patch_alc662
},
6805 { .id
= 0x10ec0665, .name
= "ALC665", .patch
= patch_alc662
},
6806 { .id
= 0x10ec0670, .name
= "ALC670", .patch
= patch_alc662
},
6807 { .id
= 0x10ec0680, .name
= "ALC680", .patch
= patch_alc680
},
6808 { .id
= 0x10ec0880, .name
= "ALC880", .patch
= patch_alc880
},
6809 { .id
= 0x10ec0882, .name
= "ALC882", .patch
= patch_alc882
},
6810 { .id
= 0x10ec0883, .name
= "ALC883", .patch
= patch_alc882
},
6811 { .id
= 0x10ec0885, .rev
= 0x100101, .name
= "ALC889A",
6812 .patch
= patch_alc882
},
6813 { .id
= 0x10ec0885, .rev
= 0x100103, .name
= "ALC889A",
6814 .patch
= patch_alc882
},
6815 { .id
= 0x10ec0885, .name
= "ALC885", .patch
= patch_alc882
},
6816 { .id
= 0x10ec0887, .name
= "ALC887", .patch
= patch_alc882
},
6817 { .id
= 0x10ec0888, .rev
= 0x100101, .name
= "ALC1200",
6818 .patch
= patch_alc882
},
6819 { .id
= 0x10ec0888, .name
= "ALC888", .patch
= patch_alc882
},
6820 { .id
= 0x10ec0889, .name
= "ALC889", .patch
= patch_alc882
},
6821 { .id
= 0x10ec0892, .name
= "ALC892", .patch
= patch_alc662
},
6822 { .id
= 0x10ec0899, .name
= "ALC898", .patch
= patch_alc882
},
6826 MODULE_ALIAS("snd-hda-codec-id:10ec*");
6828 MODULE_LICENSE("GPL");
6829 MODULE_DESCRIPTION("Realtek HD-audio codec");
6831 static struct hda_codec_preset_list realtek_list
= {
6832 .preset
= snd_hda_preset_realtek
,
6833 .owner
= THIS_MODULE
,
6836 static int __init
patch_realtek_init(void)
6838 return snd_hda_add_codec_preset(&realtek_list
);
6841 static void __exit
patch_realtek_exit(void)
6843 snd_hda_delete_codec_preset(&realtek_list
);
6846 module_init(patch_realtek_init
)
6847 module_exit(patch_realtek_exit
)