2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for Realtek ALC codecs
6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
8 * Takashi Iwai <tiwai@suse.de>
9 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <linux/module.h>
31 #include <sound/core.h>
32 #include <sound/jack.h>
33 #include "hda_codec.h"
34 #include "hda_local.h"
38 /* unsol event tags */
39 #define ALC_FRONT_EVENT 0x01
40 #define ALC_DCVOL_EVENT 0x02
41 #define ALC_HP_EVENT 0x04
42 #define ALC_MIC_EVENT 0x08
45 #define GPIO_MASK 0x03
47 /* extra amp-initialization sequence types */
56 struct alc_customize_define
{
58 unsigned char port_connectivity
;
59 unsigned char check_sum
;
60 unsigned char customization
;
61 unsigned char external_amp
;
62 unsigned int enable_pcbeep
:1;
63 unsigned int platform_type
:1;
65 unsigned int override
:1;
66 unsigned int fixup
:1; /* Means that this sku is set by driver, not read from hw */
72 hda_nid_t pin
; /* multi-io widget pin NID */
73 hda_nid_t dac
; /* DAC to be connected */
74 unsigned int ctl_in
; /* cached input-pin control value */
78 ALC_AUTOMUTE_PIN
, /* change the pin control */
79 ALC_AUTOMUTE_AMP
, /* mute/unmute the pin AMP */
80 ALC_AUTOMUTE_MIXER
, /* mute/unmute mixer widget AMP */
83 #define MAX_VOL_NIDS 0x40
86 /* codec parameterization */
87 const struct snd_kcontrol_new
*mixers
[5]; /* mixer arrays */
88 unsigned int num_mixers
;
89 const struct snd_kcontrol_new
*cap_mixer
; /* capture mixer */
90 unsigned int beep_amp
; /* beep amp value, set via set_beep_amp() */
92 const struct hda_verb
*init_verbs
[10]; /* initialization verbs
96 unsigned int num_init_verbs
;
98 char stream_name_analog
[32]; /* analog PCM stream */
99 const struct hda_pcm_stream
*stream_analog_playback
;
100 const struct hda_pcm_stream
*stream_analog_capture
;
101 const struct hda_pcm_stream
*stream_analog_alt_playback
;
102 const struct hda_pcm_stream
*stream_analog_alt_capture
;
104 char stream_name_digital
[32]; /* digital PCM stream */
105 const struct hda_pcm_stream
*stream_digital_playback
;
106 const struct hda_pcm_stream
*stream_digital_capture
;
109 struct hda_multi_out multiout
; /* playback set-up
110 * max_channels, dacs must be set
111 * dig_out_nid and hp_nid are optional
113 hda_nid_t alt_dac_nid
;
114 hda_nid_t slave_dig_outs
[3]; /* optional - for auto-parsing */
118 unsigned int num_adc_nids
;
119 const hda_nid_t
*adc_nids
;
120 const hda_nid_t
*capsrc_nids
;
121 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
122 hda_nid_t mixer_nid
; /* analog-mixer NID */
123 DECLARE_BITMAP(vol_ctls
, MAX_VOL_NIDS
<< 1);
124 DECLARE_BITMAP(sw_ctls
, MAX_VOL_NIDS
<< 1);
126 /* capture setup for dynamic dual-adc switch */
128 unsigned int cur_adc_stream_tag
;
129 unsigned int cur_adc_format
;
132 unsigned int num_mux_defs
;
133 const struct hda_input_mux
*input_mux
;
134 unsigned int cur_mux
[3];
135 hda_nid_t ext_mic_pin
;
136 hda_nid_t dock_mic_pin
;
137 hda_nid_t int_mic_pin
;
140 const struct hda_channel_mode
*channel_mode
;
141 int num_channel_mode
;
143 int const_channel_count
;
144 int ext_channel_count
;
146 /* PCM information */
147 struct hda_pcm pcm_rec
[3]; /* used in alc_build_pcms() */
149 /* dynamic controls, init_verbs and input_mux */
150 struct auto_pin_cfg autocfg
;
151 struct alc_customize_define cdefine
;
152 struct snd_array kctls
;
153 struct hda_input_mux private_imux
[3];
154 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
155 hda_nid_t private_adc_nids
[AUTO_CFG_MAX_OUTS
];
156 hda_nid_t private_capsrc_nids
[AUTO_CFG_MAX_OUTS
];
157 hda_nid_t imux_pins
[HDA_MAX_NUM_INPUTS
];
158 unsigned int dyn_adc_idx
[HDA_MAX_NUM_INPUTS
];
159 int int_mic_idx
, ext_mic_idx
, dock_mic_idx
; /* for auto-mic */
162 void (*init_hook
)(struct hda_codec
*codec
);
163 void (*unsol_event
)(struct hda_codec
*codec
, unsigned int res
);
164 #ifdef CONFIG_SND_HDA_POWER_SAVE
165 void (*power_hook
)(struct hda_codec
*codec
);
167 void (*shutup
)(struct hda_codec
*codec
);
168 void (*automute_hook
)(struct hda_codec
*codec
);
170 /* for pin sensing */
171 unsigned int hp_jack_present
:1;
172 unsigned int line_jack_present
:1;
173 unsigned int master_mute
:1;
174 unsigned int auto_mic
:1;
175 unsigned int auto_mic_valid_imux
:1; /* valid imux for auto-mic */
176 unsigned int automute_speaker
:1; /* automute speaker outputs */
177 unsigned int automute_lo
:1; /* automute LO outputs */
178 unsigned int detect_hp
:1; /* Headphone detection enabled */
179 unsigned int detect_lo
:1; /* Line-out detection enabled */
180 unsigned int automute_speaker_possible
:1; /* there are speakers and either LO or HP */
181 unsigned int automute_lo_possible
:1; /* there are line outs and HP */
182 unsigned int keep_vref_in_automute
:1; /* Don't clear VREF in automute */
185 unsigned int no_analog
:1; /* digital I/O only */
186 unsigned int dyn_adc_switch
:1; /* switch ADCs (for ALC275) */
187 unsigned int single_input_src
:1;
188 unsigned int vol_in_capsrc
:1; /* use capsrc volume (ADC has no vol) */
189 unsigned int parse_flags
; /* passed to snd_hda_parse_pin_defcfg() */
190 unsigned int shared_mic_hp
:1; /* HP/Mic-in sharing */
192 /* auto-mute control */
194 hda_nid_t automute_mixer_nid
[AUTO_CFG_MAX_OUTS
];
197 int codec_variant
; /* flag for other variants */
199 /* for virtual master */
200 hda_nid_t vmaster_nid
;
201 struct snd_kcontrol
*vmaster_sw_kctl
;
202 #ifdef CONFIG_SND_HDA_POWER_SAVE
203 struct hda_loopback_check loopback
;
205 struct hda_amp_list loopback_list
[8];
210 unsigned int pll_coef_idx
, pll_coef_bit
;
215 const struct alc_fixup
*fixup_list
;
216 const char *fixup_name
;
220 struct alc_multi_io multi_io
[4];
223 struct snd_array bind_ctls
;
226 static bool check_amp_caps(struct hda_codec
*codec
, hda_nid_t nid
,
227 int dir
, unsigned int bits
)
231 if (get_wcaps(codec
, nid
) & (1 << (dir
+ 1)))
232 if (query_amp_caps(codec
, nid
, dir
) & bits
)
237 #define nid_has_mute(codec, nid, dir) \
238 check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE)
239 #define nid_has_volume(codec, nid, dir) \
240 check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS)
245 static int alc_mux_enum_info(struct snd_kcontrol
*kcontrol
,
246 struct snd_ctl_elem_info
*uinfo
)
248 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
249 struct alc_spec
*spec
= codec
->spec
;
250 unsigned int mux_idx
= snd_ctl_get_ioffidx(kcontrol
, &uinfo
->id
);
251 if (mux_idx
>= spec
->num_mux_defs
)
253 if (!spec
->input_mux
[mux_idx
].num_items
&& mux_idx
> 0)
255 return snd_hda_input_mux_info(&spec
->input_mux
[mux_idx
], uinfo
);
258 static int alc_mux_enum_get(struct snd_kcontrol
*kcontrol
,
259 struct snd_ctl_elem_value
*ucontrol
)
261 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
262 struct alc_spec
*spec
= codec
->spec
;
263 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
265 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
269 static bool alc_dyn_adc_pcm_resetup(struct hda_codec
*codec
, int cur
)
271 struct alc_spec
*spec
= codec
->spec
;
272 hda_nid_t new_adc
= spec
->adc_nids
[spec
->dyn_adc_idx
[cur
]];
274 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
275 /* stream is running, let's swap the current ADC */
276 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
277 spec
->cur_adc
= new_adc
;
278 snd_hda_codec_setup_stream(codec
, new_adc
,
279 spec
->cur_adc_stream_tag
, 0,
280 spec
->cur_adc_format
);
286 static inline hda_nid_t
get_capsrc(struct alc_spec
*spec
, int idx
)
288 return spec
->capsrc_nids
?
289 spec
->capsrc_nids
[idx
] : spec
->adc_nids
[idx
];
292 static void call_update_outputs(struct hda_codec
*codec
);
294 /* select the given imux item; either unmute exclusively or select the route */
295 static int alc_mux_select(struct hda_codec
*codec
, unsigned int adc_idx
,
296 unsigned int idx
, bool force
)
298 struct alc_spec
*spec
= codec
->spec
;
299 const struct hda_input_mux
*imux
;
300 unsigned int mux_idx
;
301 int i
, type
, num_conns
;
304 if (!spec
->input_mux
)
307 mux_idx
= adc_idx
>= spec
->num_mux_defs
? 0 : adc_idx
;
308 imux
= &spec
->input_mux
[mux_idx
];
309 if (!imux
->num_items
&& mux_idx
> 0)
310 imux
= &spec
->input_mux
[0];
311 if (!imux
->num_items
)
314 if (idx
>= imux
->num_items
)
315 idx
= imux
->num_items
- 1;
316 if (spec
->cur_mux
[adc_idx
] == idx
&& !force
)
318 spec
->cur_mux
[adc_idx
] = idx
;
320 /* for shared I/O, change the pin-control accordingly */
321 if (spec
->shared_mic_hp
) {
322 /* NOTE: this assumes that there are only two inputs, the
323 * first is the real internal mic and the second is HP jack.
325 snd_hda_codec_write(codec
, spec
->autocfg
.inputs
[1].pin
, 0,
326 AC_VERB_SET_PIN_WIDGET_CONTROL
,
327 spec
->cur_mux
[adc_idx
] ?
328 PIN_VREF80
: PIN_HP
);
329 spec
->automute_speaker
= !spec
->cur_mux
[adc_idx
];
330 call_update_outputs(codec
);
333 if (spec
->dyn_adc_switch
) {
334 alc_dyn_adc_pcm_resetup(codec
, idx
);
335 adc_idx
= spec
->dyn_adc_idx
[idx
];
338 nid
= get_capsrc(spec
, adc_idx
);
341 num_conns
= snd_hda_get_conn_list(codec
, nid
, NULL
);
345 type
= get_wcaps_type(get_wcaps(codec
, nid
));
346 if (type
== AC_WID_AUD_MIX
) {
347 /* Matrix-mixer style (e.g. ALC882) */
348 int active
= imux
->items
[idx
].index
;
349 for (i
= 0; i
< num_conns
; i
++) {
350 unsigned int v
= (i
== active
) ? 0 : HDA_AMP_MUTE
;
351 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, i
,
355 /* MUX style (e.g. ALC880) */
356 snd_hda_codec_write_cache(codec
, nid
, 0,
357 AC_VERB_SET_CONNECT_SEL
,
358 imux
->items
[idx
].index
);
363 static int alc_mux_enum_put(struct snd_kcontrol
*kcontrol
,
364 struct snd_ctl_elem_value
*ucontrol
)
366 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
367 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
368 return alc_mux_select(codec
, adc_idx
,
369 ucontrol
->value
.enumerated
.item
[0], false);
373 * set up the input pin config (depending on the given auto-pin type)
375 static void alc_set_input_pin(struct hda_codec
*codec
, hda_nid_t nid
,
378 unsigned int val
= PIN_IN
;
380 if (auto_pin_type
== AUTO_PIN_MIC
) {
383 oldval
= snd_hda_codec_read(codec
, nid
, 0,
384 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
385 pincap
= snd_hda_query_pin_caps(codec
, nid
);
386 pincap
= (pincap
& AC_PINCAP_VREF
) >> AC_PINCAP_VREF_SHIFT
;
387 /* if the default pin setup is vref50, we give it priority */
388 if ((pincap
& AC_PINCAP_VREF_80
) && oldval
!= PIN_VREF50
)
390 else if (pincap
& AC_PINCAP_VREF_50
)
392 else if (pincap
& AC_PINCAP_VREF_100
)
394 else if (pincap
& AC_PINCAP_VREF_GRD
)
397 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, val
);
401 * Append the given mixer and verb elements for the later use
402 * The mixer array is referred in build_controls(), and init_verbs are
405 static void add_mixer(struct alc_spec
*spec
, const struct snd_kcontrol_new
*mix
)
407 if (snd_BUG_ON(spec
->num_mixers
>= ARRAY_SIZE(spec
->mixers
)))
409 spec
->mixers
[spec
->num_mixers
++] = mix
;
412 static void add_verb(struct alc_spec
*spec
, const struct hda_verb
*verb
)
414 if (snd_BUG_ON(spec
->num_init_verbs
>= ARRAY_SIZE(spec
->init_verbs
)))
416 spec
->init_verbs
[spec
->num_init_verbs
++] = verb
;
420 * GPIO setup tables, used in initialization
422 /* Enable GPIO mask and set output */
423 static const struct hda_verb alc_gpio1_init_verbs
[] = {
424 {0x01, AC_VERB_SET_GPIO_MASK
, 0x01},
425 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
426 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
430 static const struct hda_verb alc_gpio2_init_verbs
[] = {
431 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
432 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
433 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02},
437 static const struct hda_verb alc_gpio3_init_verbs
[] = {
438 {0x01, AC_VERB_SET_GPIO_MASK
, 0x03},
439 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x03},
440 {0x01, AC_VERB_SET_GPIO_DATA
, 0x03},
445 * Fix hardware PLL issue
446 * On some codecs, the analog PLL gating control must be off while
447 * the default value is 1.
449 static void alc_fix_pll(struct hda_codec
*codec
)
451 struct alc_spec
*spec
= codec
->spec
;
456 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_COEF_INDEX
,
458 val
= snd_hda_codec_read(codec
, spec
->pll_nid
, 0,
459 AC_VERB_GET_PROC_COEF
, 0);
460 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_COEF_INDEX
,
462 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_PROC_COEF
,
463 val
& ~(1 << spec
->pll_coef_bit
));
466 static void alc_fix_pll_init(struct hda_codec
*codec
, hda_nid_t nid
,
467 unsigned int coef_idx
, unsigned int coef_bit
)
469 struct alc_spec
*spec
= codec
->spec
;
471 spec
->pll_coef_idx
= coef_idx
;
472 spec
->pll_coef_bit
= coef_bit
;
477 * Jack detections for HP auto-mute and mic-switch
480 /* check each pin in the given array; returns true if any of them is plugged */
481 static bool detect_jacks(struct hda_codec
*codec
, int num_pins
, hda_nid_t
*pins
)
485 for (i
= 0; i
< num_pins
; i
++) {
486 hda_nid_t nid
= pins
[i
];
489 present
|= snd_hda_jack_detect(codec
, nid
);
494 /* standard HP/line-out auto-mute helper */
495 static void do_automute(struct hda_codec
*codec
, int num_pins
, hda_nid_t
*pins
,
496 bool mute
, bool hp_out
)
498 struct alc_spec
*spec
= codec
->spec
;
499 unsigned int mute_bits
= mute
? HDA_AMP_MUTE
: 0;
500 unsigned int pin_bits
= mute
? 0 : (hp_out
? PIN_HP
: PIN_OUT
);
503 for (i
= 0; i
< num_pins
; i
++) {
504 hda_nid_t nid
= pins
[i
];
508 switch (spec
->automute_mode
) {
509 case ALC_AUTOMUTE_PIN
:
510 /* don't reset VREF value in case it's controlling
511 * the amp (see alc861_fixup_asus_amp_vref_0f())
513 if (spec
->keep_vref_in_automute
) {
514 val
= snd_hda_codec_read(codec
, nid
, 0,
515 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
520 snd_hda_codec_write(codec
, nid
, 0,
521 AC_VERB_SET_PIN_WIDGET_CONTROL
,
524 case ALC_AUTOMUTE_AMP
:
525 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
526 HDA_AMP_MUTE
, mute_bits
);
528 case ALC_AUTOMUTE_MIXER
:
529 nid
= spec
->automute_mixer_nid
[i
];
532 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, 0,
533 HDA_AMP_MUTE
, mute_bits
);
534 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, 1,
535 HDA_AMP_MUTE
, mute_bits
);
541 /* Toggle outputs muting */
542 static void update_outputs(struct hda_codec
*codec
)
544 struct alc_spec
*spec
= codec
->spec
;
547 /* Control HP pins/amps depending on master_mute state;
548 * in general, HP pins/amps control should be enabled in all cases,
549 * but currently set only for master_mute, just to be safe
551 if (!spec
->shared_mic_hp
) /* don't change HP-pin when shared with mic */
552 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.hp_pins
),
553 spec
->autocfg
.hp_pins
, spec
->master_mute
, true);
555 if (!spec
->automute_speaker
)
558 on
= spec
->hp_jack_present
| spec
->line_jack_present
;
559 on
|= spec
->master_mute
;
560 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.speaker_pins
),
561 spec
->autocfg
.speaker_pins
, on
, false);
563 /* toggle line-out mutes if needed, too */
564 /* if LO is a copy of either HP or Speaker, don't need to handle it */
565 if (spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.hp_pins
[0] ||
566 spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.speaker_pins
[0])
568 if (!spec
->automute_lo
)
571 on
= spec
->hp_jack_present
;
572 on
|= spec
->master_mute
;
573 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.line_out_pins
),
574 spec
->autocfg
.line_out_pins
, on
, false);
577 static void call_update_outputs(struct hda_codec
*codec
)
579 struct alc_spec
*spec
= codec
->spec
;
580 if (spec
->automute_hook
)
581 spec
->automute_hook(codec
);
583 update_outputs(codec
);
586 /* standard HP-automute helper */
587 static void alc_hp_automute(struct hda_codec
*codec
)
589 struct alc_spec
*spec
= codec
->spec
;
591 spec
->hp_jack_present
=
592 detect_jacks(codec
, ARRAY_SIZE(spec
->autocfg
.hp_pins
),
593 spec
->autocfg
.hp_pins
);
594 if (!spec
->detect_hp
|| (!spec
->automute_speaker
&& !spec
->automute_lo
))
596 call_update_outputs(codec
);
599 /* standard line-out-automute helper */
600 static void alc_line_automute(struct hda_codec
*codec
)
602 struct alc_spec
*spec
= codec
->spec
;
604 /* check LO jack only when it's different from HP */
605 if (spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.hp_pins
[0])
608 spec
->line_jack_present
=
609 detect_jacks(codec
, ARRAY_SIZE(spec
->autocfg
.line_out_pins
),
610 spec
->autocfg
.line_out_pins
);
611 if (!spec
->automute_speaker
|| !spec
->detect_lo
)
613 call_update_outputs(codec
);
616 #define get_connection_index(codec, mux, nid) \
617 snd_hda_get_conn_index(codec, mux, nid, 0)
619 /* standard mic auto-switch helper */
620 static void alc_mic_automute(struct hda_codec
*codec
)
622 struct alc_spec
*spec
= codec
->spec
;
623 hda_nid_t
*pins
= spec
->imux_pins
;
625 if (!spec
->auto_mic
|| !spec
->auto_mic_valid_imux
)
627 if (snd_BUG_ON(!spec
->adc_nids
))
629 if (snd_BUG_ON(spec
->int_mic_idx
< 0 || spec
->ext_mic_idx
< 0))
632 if (snd_hda_jack_detect(codec
, pins
[spec
->ext_mic_idx
]))
633 alc_mux_select(codec
, 0, spec
->ext_mic_idx
, false);
634 else if (spec
->dock_mic_idx
>= 0 &&
635 snd_hda_jack_detect(codec
, pins
[spec
->dock_mic_idx
]))
636 alc_mux_select(codec
, 0, spec
->dock_mic_idx
, false);
638 alc_mux_select(codec
, 0, spec
->int_mic_idx
, false);
641 /* handle the specified unsol action (ALC_XXX_EVENT) */
642 static void alc_exec_unsol_event(struct hda_codec
*codec
, int action
)
646 alc_hp_automute(codec
);
648 case ALC_FRONT_EVENT
:
649 alc_line_automute(codec
);
652 alc_mic_automute(codec
);
655 snd_hda_jack_report_sync(codec
);
658 /* update the master volume per volume-knob's unsol event */
659 static void alc_update_knob_master(struct hda_codec
*codec
, hda_nid_t nid
)
662 struct snd_kcontrol
*kctl
;
663 struct snd_ctl_elem_value
*uctl
;
665 kctl
= snd_hda_find_mixer_ctl(codec
, "Master Playback Volume");
668 uctl
= kzalloc(sizeof(*uctl
), GFP_KERNEL
);
671 val
= snd_hda_codec_read(codec
, nid
, 0,
672 AC_VERB_GET_VOLUME_KNOB_CONTROL
, 0);
673 val
&= HDA_AMP_VOLMASK
;
674 uctl
->value
.integer
.value
[0] = val
;
675 uctl
->value
.integer
.value
[1] = val
;
676 kctl
->put(kctl
, uctl
);
680 /* unsolicited event for HP jack sensing */
681 static void alc_sku_unsol_event(struct hda_codec
*codec
, unsigned int res
)
685 if (codec
->vendor_id
== 0x10ec0880)
689 action
= snd_hda_jack_get_action(codec
, res
);
690 if (action
== ALC_DCVOL_EVENT
) {
691 /* Execute the dc-vol event here as it requires the NID
692 * but we don't pass NID to alc_exec_unsol_event().
693 * Once when we convert all static quirks to the auto-parser,
694 * this can be integerated into there.
696 struct hda_jack_tbl
*jack
;
697 jack
= snd_hda_jack_tbl_get_from_tag(codec
, res
);
699 alc_update_knob_master(codec
, jack
->nid
);
702 alc_exec_unsol_event(codec
, action
);
705 /* call init functions of standard auto-mute helpers */
706 static void alc_inithook(struct hda_codec
*codec
)
708 alc_hp_automute(codec
);
709 alc_line_automute(codec
);
710 alc_mic_automute(codec
);
713 /* additional initialization for ALC888 variants */
714 static void alc888_coef_init(struct hda_codec
*codec
)
718 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 0);
719 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
720 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
721 if ((tmp
& 0xf0) == 0x20)
723 snd_hda_codec_read(codec
, 0x20, 0,
724 AC_VERB_SET_PROC_COEF
, 0x830);
727 snd_hda_codec_read(codec
, 0x20, 0,
728 AC_VERB_SET_PROC_COEF
, 0x3030);
731 /* additional initialization for ALC889 variants */
732 static void alc889_coef_init(struct hda_codec
*codec
)
736 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
737 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
738 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
739 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_PROC_COEF
, tmp
|0x2010);
742 /* turn on/off EAPD control (only if available) */
743 static void set_eapd(struct hda_codec
*codec
, hda_nid_t nid
, int on
)
745 if (get_wcaps_type(get_wcaps(codec
, nid
)) != AC_WID_PIN
)
747 if (snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_EAPD
)
748 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_EAPD_BTLENABLE
,
752 /* turn on/off EAPD controls of the codec */
753 static void alc_auto_setup_eapd(struct hda_codec
*codec
, bool on
)
755 /* We currently only handle front, HP */
756 static hda_nid_t pins
[] = {
757 0x0f, 0x10, 0x14, 0x15, 0
760 for (p
= pins
; *p
; p
++)
761 set_eapd(codec
, *p
, on
);
764 /* generic shutup callback;
765 * just turning off EPAD and a little pause for avoiding pop-noise
767 static void alc_eapd_shutup(struct hda_codec
*codec
)
769 alc_auto_setup_eapd(codec
, false);
773 /* generic EAPD initialization */
774 static void alc_auto_init_amp(struct hda_codec
*codec
, int type
)
778 alc_auto_setup_eapd(codec
, true);
781 snd_hda_sequence_write(codec
, alc_gpio1_init_verbs
);
784 snd_hda_sequence_write(codec
, alc_gpio2_init_verbs
);
787 snd_hda_sequence_write(codec
, alc_gpio3_init_verbs
);
789 case ALC_INIT_DEFAULT
:
790 switch (codec
->vendor_id
) {
792 snd_hda_codec_write(codec
, 0x1a, 0,
793 AC_VERB_SET_COEF_INDEX
, 7);
794 tmp
= snd_hda_codec_read(codec
, 0x1a, 0,
795 AC_VERB_GET_PROC_COEF
, 0);
796 snd_hda_codec_write(codec
, 0x1a, 0,
797 AC_VERB_SET_COEF_INDEX
, 7);
798 snd_hda_codec_write(codec
, 0x1a, 0,
799 AC_VERB_SET_PROC_COEF
,
808 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
809 alc889_coef_init(codec
);
812 alc888_coef_init(codec
);
814 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
817 snd_hda_codec_write(codec
, 0x20, 0,
818 AC_VERB_SET_COEF_INDEX
, 7);
819 tmp
= snd_hda_codec_read(codec
, 0x20, 0,
820 AC_VERB_GET_PROC_COEF
, 0);
821 snd_hda_codec_write(codec
, 0x20, 0,
822 AC_VERB_SET_COEF_INDEX
, 7);
823 snd_hda_codec_write(codec
, 0x20, 0,
824 AC_VERB_SET_PROC_COEF
,
834 * Auto-Mute mode mixer enum support
836 static int alc_automute_mode_info(struct snd_kcontrol
*kcontrol
,
837 struct snd_ctl_elem_info
*uinfo
)
839 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
840 struct alc_spec
*spec
= codec
->spec
;
841 static const char * const texts2
[] = {
842 "Disabled", "Enabled"
844 static const char * const texts3
[] = {
845 "Disabled", "Speaker Only", "Line Out+Speaker"
847 const char * const *texts
;
849 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
851 if (spec
->automute_speaker_possible
&& spec
->automute_lo_possible
) {
852 uinfo
->value
.enumerated
.items
= 3;
855 uinfo
->value
.enumerated
.items
= 2;
858 if (uinfo
->value
.enumerated
.item
>= uinfo
->value
.enumerated
.items
)
859 uinfo
->value
.enumerated
.item
= uinfo
->value
.enumerated
.items
- 1;
860 strcpy(uinfo
->value
.enumerated
.name
,
861 texts
[uinfo
->value
.enumerated
.item
]);
865 static int alc_automute_mode_get(struct snd_kcontrol
*kcontrol
,
866 struct snd_ctl_elem_value
*ucontrol
)
868 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
869 struct alc_spec
*spec
= codec
->spec
;
870 unsigned int val
= 0;
871 if (spec
->automute_speaker
)
873 if (spec
->automute_lo
)
876 ucontrol
->value
.enumerated
.item
[0] = val
;
880 static int alc_automute_mode_put(struct snd_kcontrol
*kcontrol
,
881 struct snd_ctl_elem_value
*ucontrol
)
883 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
884 struct alc_spec
*spec
= codec
->spec
;
886 switch (ucontrol
->value
.enumerated
.item
[0]) {
888 if (!spec
->automute_speaker
&& !spec
->automute_lo
)
890 spec
->automute_speaker
= 0;
891 spec
->automute_lo
= 0;
894 if (spec
->automute_speaker_possible
) {
895 if (!spec
->automute_lo
&& spec
->automute_speaker
)
897 spec
->automute_speaker
= 1;
898 spec
->automute_lo
= 0;
899 } else if (spec
->automute_lo_possible
) {
900 if (spec
->automute_lo
)
902 spec
->automute_lo
= 1;
907 if (!spec
->automute_lo_possible
|| !spec
->automute_speaker_possible
)
909 if (spec
->automute_speaker
&& spec
->automute_lo
)
911 spec
->automute_speaker
= 1;
912 spec
->automute_lo
= 1;
917 call_update_outputs(codec
);
921 static const struct snd_kcontrol_new alc_automute_mode_enum
= {
922 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
923 .name
= "Auto-Mute Mode",
924 .info
= alc_automute_mode_info
,
925 .get
= alc_automute_mode_get
,
926 .put
= alc_automute_mode_put
,
929 static struct snd_kcontrol_new
*alc_kcontrol_new(struct alc_spec
*spec
)
931 snd_array_init(&spec
->kctls
, sizeof(struct snd_kcontrol_new
), 32);
932 return snd_array_new(&spec
->kctls
);
935 static int alc_add_automute_mode_enum(struct hda_codec
*codec
)
937 struct alc_spec
*spec
= codec
->spec
;
938 struct snd_kcontrol_new
*knew
;
940 knew
= alc_kcontrol_new(spec
);
943 *knew
= alc_automute_mode_enum
;
944 knew
->name
= kstrdup("Auto-Mute Mode", GFP_KERNEL
);
951 * Check the availability of HP/line-out auto-mute;
952 * Set up appropriately if really supported
954 static void alc_init_automute(struct hda_codec
*codec
)
956 struct alc_spec
*spec
= codec
->spec
;
957 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
963 if (cfg
->line_out_pins
[0])
965 if (cfg
->speaker_pins
[0])
967 if (present
< 2) /* need two different output types */
970 if (!cfg
->speaker_pins
[0] &&
971 cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
972 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
973 sizeof(cfg
->speaker_pins
));
974 cfg
->speaker_outs
= cfg
->line_outs
;
977 if (!cfg
->hp_pins
[0] &&
978 cfg
->line_out_type
== AUTO_PIN_HP_OUT
) {
979 memcpy(cfg
->hp_pins
, cfg
->line_out_pins
,
980 sizeof(cfg
->hp_pins
));
981 cfg
->hp_outs
= cfg
->line_outs
;
984 spec
->automute_mode
= ALC_AUTOMUTE_PIN
;
986 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
987 hda_nid_t nid
= cfg
->hp_pins
[i
];
988 if (!is_jack_detectable(codec
, nid
))
990 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
992 snd_hda_jack_detect_enable(codec
, nid
, ALC_HP_EVENT
);
996 if (cfg
->line_out_type
== AUTO_PIN_LINE_OUT
&& cfg
->line_outs
) {
997 if (cfg
->speaker_outs
)
998 for (i
= 0; i
< cfg
->line_outs
; i
++) {
999 hda_nid_t nid
= cfg
->line_out_pins
[i
];
1000 if (!is_jack_detectable(codec
, nid
))
1002 snd_printdd("realtek: Enable Line-Out "
1003 "auto-muting on NID 0x%x\n", nid
);
1004 snd_hda_jack_detect_enable(codec
, nid
,
1006 spec
->detect_lo
= 1;
1008 spec
->automute_lo_possible
= spec
->detect_hp
;
1011 spec
->automute_speaker_possible
= cfg
->speaker_outs
&&
1012 (spec
->detect_hp
|| spec
->detect_lo
);
1014 spec
->automute_lo
= spec
->automute_lo_possible
;
1015 spec
->automute_speaker
= spec
->automute_speaker_possible
;
1017 if (spec
->automute_speaker_possible
|| spec
->automute_lo_possible
) {
1018 /* create a control for automute mode */
1019 alc_add_automute_mode_enum(codec
);
1020 spec
->unsol_event
= alc_sku_unsol_event
;
1024 /* return the position of NID in the list, or -1 if not found */
1025 static int find_idx_in_nid_list(hda_nid_t nid
, const hda_nid_t
*list
, int nums
)
1028 for (i
= 0; i
< nums
; i
++)
1034 /* check whether dynamic ADC-switching is available */
1035 static bool alc_check_dyn_adc_switch(struct hda_codec
*codec
)
1037 struct alc_spec
*spec
= codec
->spec
;
1038 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
1042 if (imux
!= spec
->input_mux
) /* no dynamic imux? */
1045 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
1046 cap
= spec
->private_capsrc_nids
[n
];
1047 for (i
= 0; i
< imux
->num_items
; i
++) {
1048 pin
= spec
->imux_pins
[i
];
1051 if (get_connection_index(codec
, cap
, pin
) < 0)
1054 if (i
>= imux
->num_items
)
1055 return true; /* no ADC-switch is needed */
1058 for (i
= 0; i
< imux
->num_items
; i
++) {
1059 pin
= spec
->imux_pins
[i
];
1060 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
1061 cap
= spec
->private_capsrc_nids
[n
];
1062 idx
= get_connection_index(codec
, cap
, pin
);
1064 imux
->items
[i
].index
= idx
;
1065 spec
->dyn_adc_idx
[i
] = n
;
1071 snd_printdd("realtek: enabling ADC switching\n");
1072 spec
->dyn_adc_switch
= 1;
1076 /* check whether all auto-mic pins are valid; setup indices if OK */
1077 static bool alc_auto_mic_check_imux(struct hda_codec
*codec
)
1079 struct alc_spec
*spec
= codec
->spec
;
1080 const struct hda_input_mux
*imux
;
1082 if (!spec
->auto_mic
)
1084 if (spec
->auto_mic_valid_imux
)
1085 return true; /* already checked */
1087 /* fill up imux indices */
1088 if (!alc_check_dyn_adc_switch(codec
)) {
1093 imux
= spec
->input_mux
;
1094 spec
->ext_mic_idx
= find_idx_in_nid_list(spec
->ext_mic_pin
,
1095 spec
->imux_pins
, imux
->num_items
);
1096 spec
->int_mic_idx
= find_idx_in_nid_list(spec
->int_mic_pin
,
1097 spec
->imux_pins
, imux
->num_items
);
1098 spec
->dock_mic_idx
= find_idx_in_nid_list(spec
->dock_mic_pin
,
1099 spec
->imux_pins
, imux
->num_items
);
1100 if (spec
->ext_mic_idx
< 0 || spec
->int_mic_idx
< 0) {
1102 return false; /* no corresponding imux */
1105 snd_hda_jack_detect_enable(codec
, spec
->ext_mic_pin
, ALC_MIC_EVENT
);
1106 if (spec
->dock_mic_pin
)
1107 snd_hda_jack_detect_enable(codec
, spec
->dock_mic_pin
,
1110 spec
->auto_mic_valid_imux
= 1;
1116 * Check the availability of auto-mic switch;
1117 * Set up if really supported
1119 static void alc_init_auto_mic(struct hda_codec
*codec
)
1121 struct alc_spec
*spec
= codec
->spec
;
1122 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1123 hda_nid_t fixed
, ext
, dock
;
1126 if (spec
->shared_mic_hp
)
1127 return; /* no auto-mic for the shared I/O */
1129 spec
->ext_mic_idx
= spec
->int_mic_idx
= spec
->dock_mic_idx
= -1;
1131 fixed
= ext
= dock
= 0;
1132 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
1133 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
1134 unsigned int defcfg
;
1135 defcfg
= snd_hda_codec_get_pincfg(codec
, nid
);
1136 switch (snd_hda_get_input_pin_attr(defcfg
)) {
1137 case INPUT_PIN_ATTR_INT
:
1139 return; /* already occupied */
1140 if (cfg
->inputs
[i
].type
!= AUTO_PIN_MIC
)
1141 return; /* invalid type */
1144 case INPUT_PIN_ATTR_UNUSED
:
1145 return; /* invalid entry */
1146 case INPUT_PIN_ATTR_DOCK
:
1148 return; /* already occupied */
1149 if (cfg
->inputs
[i
].type
> AUTO_PIN_LINE_IN
)
1150 return; /* invalid type */
1155 return; /* already occupied */
1156 if (cfg
->inputs
[i
].type
!= AUTO_PIN_MIC
)
1157 return; /* invalid type */
1168 if (!is_jack_detectable(codec
, ext
))
1169 return; /* no unsol support */
1170 if (dock
&& !is_jack_detectable(codec
, dock
))
1171 return; /* no unsol support */
1173 /* check imux indices */
1174 spec
->ext_mic_pin
= ext
;
1175 spec
->int_mic_pin
= fixed
;
1176 spec
->dock_mic_pin
= dock
;
1179 if (!alc_auto_mic_check_imux(codec
))
1182 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
1184 spec
->unsol_event
= alc_sku_unsol_event
;
1187 /* check the availabilities of auto-mute and auto-mic switches */
1188 static void alc_auto_check_switches(struct hda_codec
*codec
)
1190 alc_init_automute(codec
);
1191 alc_init_auto_mic(codec
);
1195 * Realtek SSID verification
1198 /* Could be any non-zero and even value. When used as fixup, tells
1199 * the driver to ignore any present sku defines.
1201 #define ALC_FIXUP_SKU_IGNORE (2)
1203 static int alc_auto_parse_customize_define(struct hda_codec
*codec
)
1205 unsigned int ass
, tmp
, i
;
1207 struct alc_spec
*spec
= codec
->spec
;
1209 spec
->cdefine
.enable_pcbeep
= 1; /* assume always enabled */
1211 if (spec
->cdefine
.fixup
) {
1212 ass
= spec
->cdefine
.sku_cfg
;
1213 if (ass
== ALC_FIXUP_SKU_IGNORE
)
1218 ass
= codec
->subsystem_id
& 0xffff;
1219 if (ass
!= codec
->bus
->pci
->subsystem_device
&& (ass
& 1))
1223 if (codec
->vendor_id
== 0x10ec0260)
1225 ass
= snd_hda_codec_get_pincfg(codec
, nid
);
1228 printk(KERN_INFO
"hda_codec: %s: SKU not ready 0x%08x\n",
1229 codec
->chip_name
, ass
);
1235 for (i
= 1; i
< 16; i
++) {
1239 if (((ass
>> 16) & 0xf) != tmp
)
1242 spec
->cdefine
.port_connectivity
= ass
>> 30;
1243 spec
->cdefine
.enable_pcbeep
= (ass
& 0x100000) >> 20;
1244 spec
->cdefine
.check_sum
= (ass
>> 16) & 0xf;
1245 spec
->cdefine
.customization
= ass
>> 8;
1247 spec
->cdefine
.sku_cfg
= ass
;
1248 spec
->cdefine
.external_amp
= (ass
& 0x38) >> 3;
1249 spec
->cdefine
.platform_type
= (ass
& 0x4) >> 2;
1250 spec
->cdefine
.swap
= (ass
& 0x2) >> 1;
1251 spec
->cdefine
.override
= ass
& 0x1;
1253 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1254 nid
, spec
->cdefine
.sku_cfg
);
1255 snd_printd("SKU: port_connectivity=0x%x\n",
1256 spec
->cdefine
.port_connectivity
);
1257 snd_printd("SKU: enable_pcbeep=0x%x\n", spec
->cdefine
.enable_pcbeep
);
1258 snd_printd("SKU: check_sum=0x%08x\n", spec
->cdefine
.check_sum
);
1259 snd_printd("SKU: customization=0x%08x\n", spec
->cdefine
.customization
);
1260 snd_printd("SKU: external_amp=0x%x\n", spec
->cdefine
.external_amp
);
1261 snd_printd("SKU: platform_type=0x%x\n", spec
->cdefine
.platform_type
);
1262 snd_printd("SKU: swap=0x%x\n", spec
->cdefine
.swap
);
1263 snd_printd("SKU: override=0x%x\n", spec
->cdefine
.override
);
1268 /* return true if the given NID is found in the list */
1269 static bool found_in_nid_list(hda_nid_t nid
, const hda_nid_t
*list
, int nums
)
1271 return find_idx_in_nid_list(nid
, list
, nums
) >= 0;
1274 /* check subsystem ID and set up device-specific initialization;
1275 * return 1 if initialized, 0 if invalid SSID
1277 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1278 * 31 ~ 16 : Manufacture ID
1280 * 7 ~ 0 : Assembly ID
1281 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1283 static int alc_subsystem_id(struct hda_codec
*codec
,
1284 hda_nid_t porta
, hda_nid_t porte
,
1285 hda_nid_t portd
, hda_nid_t porti
)
1287 unsigned int ass
, tmp
, i
;
1289 struct alc_spec
*spec
= codec
->spec
;
1291 if (spec
->cdefine
.fixup
) {
1292 ass
= spec
->cdefine
.sku_cfg
;
1293 if (ass
== ALC_FIXUP_SKU_IGNORE
)
1298 ass
= codec
->subsystem_id
& 0xffff;
1299 if ((ass
!= codec
->bus
->pci
->subsystem_device
) && (ass
& 1))
1302 /* invalid SSID, check the special NID pin defcfg instead */
1304 * 31~30 : port connectivity
1307 * 19~16 : Check sum (15:1)
1312 if (codec
->vendor_id
== 0x10ec0260)
1314 ass
= snd_hda_codec_get_pincfg(codec
, nid
);
1315 snd_printd("realtek: No valid SSID, "
1316 "checking pincfg 0x%08x for NID 0x%x\n",
1320 if ((ass
>> 30) != 1) /* no physical connection */
1325 for (i
= 1; i
< 16; i
++) {
1329 if (((ass
>> 16) & 0xf) != tmp
)
1332 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1333 ass
& 0xffff, codec
->vendor_id
);
1337 * 2 : 0 --> Desktop, 1 --> Laptop
1338 * 3~5 : External Amplifier control
1341 tmp
= (ass
& 0x38) >> 3; /* external Amp control */
1344 spec
->init_amp
= ALC_INIT_GPIO1
;
1347 spec
->init_amp
= ALC_INIT_GPIO2
;
1350 spec
->init_amp
= ALC_INIT_GPIO3
;
1354 spec
->init_amp
= ALC_INIT_DEFAULT
;
1358 /* is laptop or Desktop and enable the function "Mute internal speaker
1359 * when the external headphone out jack is plugged"
1361 if (!(ass
& 0x8000))
1364 * 10~8 : Jack location
1365 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1367 * 15 : 1 --> enable the function "Mute internal speaker
1368 * when the external headphone out jack is plugged"
1370 if (!spec
->autocfg
.hp_pins
[0] &&
1371 !(spec
->autocfg
.line_out_pins
[0] &&
1372 spec
->autocfg
.line_out_type
== AUTO_PIN_HP_OUT
)) {
1374 tmp
= (ass
>> 11) & 0x3; /* HP to chassis */
1385 if (found_in_nid_list(nid
, spec
->autocfg
.line_out_pins
,
1386 spec
->autocfg
.line_outs
))
1388 spec
->autocfg
.hp_pins
[0] = nid
;
1393 /* Check the validity of ALC subsystem-id
1394 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
1395 static void alc_ssid_check(struct hda_codec
*codec
, const hda_nid_t
*ports
)
1397 if (!alc_subsystem_id(codec
, ports
[0], ports
[1], ports
[2], ports
[3])) {
1398 struct alc_spec
*spec
= codec
->spec
;
1399 snd_printd("realtek: "
1400 "Enable default setup for auto mode as fallback\n");
1401 spec
->init_amp
= ALC_INIT_DEFAULT
;
1406 * Fix-up pin default configurations and add default verbs
1414 struct alc_model_fixup
{
1425 const struct alc_pincfg
*pins
;
1426 const struct hda_verb
*verbs
;
1427 void (*func
)(struct hda_codec
*codec
,
1428 const struct alc_fixup
*fix
,
1442 ALC_FIXUP_ACT_PRE_PROBE
,
1443 ALC_FIXUP_ACT_PROBE
,
1445 ALC_FIXUP_ACT_BUILD
,
1448 static void alc_apply_fixup(struct hda_codec
*codec
, int action
)
1450 struct alc_spec
*spec
= codec
->spec
;
1451 int id
= spec
->fixup_id
;
1452 #ifdef CONFIG_SND_DEBUG_VERBOSE
1453 const char *modelname
= spec
->fixup_name
;
1457 if (!spec
->fixup_list
)
1461 const struct alc_fixup
*fix
= spec
->fixup_list
+ id
;
1462 const struct alc_pincfg
*cfg
;
1464 switch (fix
->type
) {
1466 if (action
!= ALC_FIXUP_ACT_PRE_PROBE
|| !fix
->v
.sku
)
1468 snd_printdd(KERN_INFO
"hda_codec: %s: "
1469 "Apply sku override for %s\n",
1470 codec
->chip_name
, modelname
);
1471 spec
->cdefine
.sku_cfg
= fix
->v
.sku
;
1472 spec
->cdefine
.fixup
= 1;
1474 case ALC_FIXUP_PINS
:
1476 if (action
!= ALC_FIXUP_ACT_PRE_PROBE
|| !cfg
)
1478 snd_printdd(KERN_INFO
"hda_codec: %s: "
1479 "Apply pincfg for %s\n",
1480 codec
->chip_name
, modelname
);
1481 for (; cfg
->nid
; cfg
++)
1482 snd_hda_codec_set_pincfg(codec
, cfg
->nid
,
1485 case ALC_FIXUP_VERBS
:
1486 if (action
!= ALC_FIXUP_ACT_PROBE
|| !fix
->v
.verbs
)
1488 snd_printdd(KERN_INFO
"hda_codec: %s: "
1489 "Apply fix-verbs for %s\n",
1490 codec
->chip_name
, modelname
);
1491 add_verb(codec
->spec
, fix
->v
.verbs
);
1493 case ALC_FIXUP_FUNC
:
1496 snd_printdd(KERN_INFO
"hda_codec: %s: "
1497 "Apply fix-func for %s\n",
1498 codec
->chip_name
, modelname
);
1499 fix
->v
.func(codec
, fix
, action
);
1502 snd_printk(KERN_ERR
"hda_codec: %s: "
1503 "Invalid fixup type %d\n",
1504 codec
->chip_name
, fix
->type
);
1515 static void alc_pick_fixup(struct hda_codec
*codec
,
1516 const struct alc_model_fixup
*models
,
1517 const struct snd_pci_quirk
*quirk
,
1518 const struct alc_fixup
*fixlist
)
1520 struct alc_spec
*spec
= codec
->spec
;
1521 const struct snd_pci_quirk
*q
;
1523 const char *name
= NULL
;
1525 /* when model=nofixup is given, don't pick up any fixups */
1526 if (codec
->modelname
&& !strcmp(codec
->modelname
, "nofixup")) {
1527 spec
->fixup_list
= NULL
;
1528 spec
->fixup_id
= -1;
1532 if (codec
->modelname
&& models
) {
1533 while (models
->name
) {
1534 if (!strcmp(codec
->modelname
, models
->name
)) {
1536 name
= models
->name
;
1543 q
= snd_pci_quirk_lookup(codec
->bus
->pci
, quirk
);
1546 #ifdef CONFIG_SND_DEBUG_VERBOSE
1552 for (q
= quirk
; q
->subvendor
; q
++) {
1553 unsigned int vendorid
=
1554 q
->subdevice
| (q
->subvendor
<< 16);
1555 if (vendorid
== codec
->subsystem_id
) {
1557 #ifdef CONFIG_SND_DEBUG_VERBOSE
1565 spec
->fixup_id
= id
;
1567 spec
->fixup_list
= fixlist
;
1568 spec
->fixup_name
= name
;
1573 * COEF access helper functions
1575 static int alc_read_coef_idx(struct hda_codec
*codec
,
1576 unsigned int coef_idx
)
1579 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
,
1581 val
= snd_hda_codec_read(codec
, 0x20, 0,
1582 AC_VERB_GET_PROC_COEF
, 0);
1586 static void alc_write_coef_idx(struct hda_codec
*codec
, unsigned int coef_idx
,
1587 unsigned int coef_val
)
1589 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
,
1591 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_PROC_COEF
,
1595 /* a special bypass for COEF 0; read the cached value at the second time */
1596 static unsigned int alc_get_coef0(struct hda_codec
*codec
)
1598 struct alc_spec
*spec
= codec
->spec
;
1600 spec
->coef0
= alc_read_coef_idx(codec
, 0);
1605 * Digital I/O handling
1608 /* set right pin controls for digital I/O */
1609 static void alc_auto_init_digital(struct hda_codec
*codec
)
1611 struct alc_spec
*spec
= codec
->spec
;
1615 for (i
= 0; i
< spec
->autocfg
.dig_outs
; i
++) {
1616 pin
= spec
->autocfg
.dig_out_pins
[i
];
1619 snd_hda_codec_write(codec
, pin
, 0,
1620 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
1622 dac
= spec
->multiout
.dig_out_nid
;
1624 dac
= spec
->slave_dig_outs
[i
- 1];
1625 if (!dac
|| !(get_wcaps(codec
, dac
) & AC_WCAP_OUT_AMP
))
1627 snd_hda_codec_write(codec
, dac
, 0,
1628 AC_VERB_SET_AMP_GAIN_MUTE
,
1631 pin
= spec
->autocfg
.dig_in_pin
;
1633 snd_hda_codec_write(codec
, pin
, 0,
1634 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1638 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1639 static void alc_auto_parse_digital(struct hda_codec
*codec
)
1641 struct alc_spec
*spec
= codec
->spec
;
1645 /* support multiple SPDIFs; the secondary is set up as a slave */
1647 for (i
= 0; i
< spec
->autocfg
.dig_outs
; i
++) {
1649 err
= snd_hda_get_connections(codec
,
1650 spec
->autocfg
.dig_out_pins
[i
],
1651 conn
, ARRAY_SIZE(conn
));
1654 dig_nid
= conn
[0]; /* assume the first element is audio-out */
1656 spec
->multiout
.dig_out_nid
= dig_nid
;
1657 spec
->dig_out_type
= spec
->autocfg
.dig_out_type
[0];
1659 spec
->multiout
.slave_dig_outs
= spec
->slave_dig_outs
;
1660 if (nums
>= ARRAY_SIZE(spec
->slave_dig_outs
) - 1)
1662 spec
->slave_dig_outs
[nums
- 1] = dig_nid
;
1667 if (spec
->autocfg
.dig_in_pin
) {
1668 dig_nid
= codec
->start_nid
;
1669 for (i
= 0; i
< codec
->num_nodes
; i
++, dig_nid
++) {
1670 unsigned int wcaps
= get_wcaps(codec
, dig_nid
);
1671 if (get_wcaps_type(wcaps
) != AC_WID_AUD_IN
)
1673 if (!(wcaps
& AC_WCAP_DIGITAL
))
1675 if (!(wcaps
& AC_WCAP_CONN_LIST
))
1677 err
= get_connection_index(codec
, dig_nid
,
1678 spec
->autocfg
.dig_in_pin
);
1680 spec
->dig_in_nid
= dig_nid
;
1688 * capture mixer elements
1690 static int alc_cap_vol_info(struct snd_kcontrol
*kcontrol
,
1691 struct snd_ctl_elem_info
*uinfo
)
1693 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1694 struct alc_spec
*spec
= codec
->spec
;
1698 mutex_lock(&codec
->control_mutex
);
1699 if (spec
->vol_in_capsrc
)
1700 val
= HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[0], 3, 0, HDA_OUTPUT
);
1702 val
= HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[0], 3, 0, HDA_INPUT
);
1703 kcontrol
->private_value
= val
;
1704 err
= snd_hda_mixer_amp_volume_info(kcontrol
, uinfo
);
1705 mutex_unlock(&codec
->control_mutex
);
1709 static int alc_cap_vol_tlv(struct snd_kcontrol
*kcontrol
, int op_flag
,
1710 unsigned int size
, unsigned int __user
*tlv
)
1712 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1713 struct alc_spec
*spec
= codec
->spec
;
1717 mutex_lock(&codec
->control_mutex
);
1718 if (spec
->vol_in_capsrc
)
1719 val
= HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[0], 3, 0, HDA_OUTPUT
);
1721 val
= HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[0], 3, 0, HDA_INPUT
);
1722 kcontrol
->private_value
= val
;
1723 err
= snd_hda_mixer_amp_tlv(kcontrol
, op_flag
, size
, tlv
);
1724 mutex_unlock(&codec
->control_mutex
);
1728 typedef int (*getput_call_t
)(struct snd_kcontrol
*kcontrol
,
1729 struct snd_ctl_elem_value
*ucontrol
);
1731 static int alc_cap_getput_caller(struct snd_kcontrol
*kcontrol
,
1732 struct snd_ctl_elem_value
*ucontrol
,
1733 getput_call_t func
, bool check_adc_switch
)
1735 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1736 struct alc_spec
*spec
= codec
->spec
;
1739 mutex_lock(&codec
->control_mutex
);
1740 if (check_adc_switch
&& spec
->dyn_adc_switch
) {
1741 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
1742 kcontrol
->private_value
=
1743 HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[i
],
1745 err
= func(kcontrol
, ucontrol
);
1750 i
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
1751 if (spec
->vol_in_capsrc
)
1752 kcontrol
->private_value
=
1753 HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[i
],
1756 kcontrol
->private_value
=
1757 HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[i
],
1759 err
= func(kcontrol
, ucontrol
);
1762 mutex_unlock(&codec
->control_mutex
);
1766 static int alc_cap_vol_get(struct snd_kcontrol
*kcontrol
,
1767 struct snd_ctl_elem_value
*ucontrol
)
1769 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1770 snd_hda_mixer_amp_volume_get
, false);
1773 static int alc_cap_vol_put(struct snd_kcontrol
*kcontrol
,
1774 struct snd_ctl_elem_value
*ucontrol
)
1776 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1777 snd_hda_mixer_amp_volume_put
, true);
1780 /* capture mixer elements */
1781 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1783 static int alc_cap_sw_get(struct snd_kcontrol
*kcontrol
,
1784 struct snd_ctl_elem_value
*ucontrol
)
1786 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1787 snd_hda_mixer_amp_switch_get
, false);
1790 static int alc_cap_sw_put(struct snd_kcontrol
*kcontrol
,
1791 struct snd_ctl_elem_value
*ucontrol
)
1793 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1794 snd_hda_mixer_amp_switch_put
, true);
1797 #define _DEFINE_CAPMIX(num) \
1799 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1800 .name = "Capture Switch", \
1801 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1803 .info = alc_cap_sw_info, \
1804 .get = alc_cap_sw_get, \
1805 .put = alc_cap_sw_put, \
1808 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1809 .name = "Capture Volume", \
1810 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1811 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1812 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1814 .info = alc_cap_vol_info, \
1815 .get = alc_cap_vol_get, \
1816 .put = alc_cap_vol_put, \
1817 .tlv = { .c = alc_cap_vol_tlv }, \
1820 #define _DEFINE_CAPSRC(num) \
1822 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1823 /* .name = "Capture Source", */ \
1824 .name = "Input Source", \
1826 .info = alc_mux_enum_info, \
1827 .get = alc_mux_enum_get, \
1828 .put = alc_mux_enum_put, \
1831 #define DEFINE_CAPMIX(num) \
1832 static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1833 _DEFINE_CAPMIX(num), \
1834 _DEFINE_CAPSRC(num), \
1838 #define DEFINE_CAPMIX_NOSRC(num) \
1839 static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1840 _DEFINE_CAPMIX(num), \
1844 /* up to three ADCs */
1848 DEFINE_CAPMIX_NOSRC(1);
1849 DEFINE_CAPMIX_NOSRC(2);
1850 DEFINE_CAPMIX_NOSRC(3);
1853 * virtual master controls
1857 * slave controls for virtual master
1859 static const char * const alc_slave_pfxs
[] = {
1860 "Front", "Surround", "Center", "LFE", "Side",
1861 "Headphone", "Speaker", "Mono", "Line Out",
1862 "CLFE", "Bass Speaker", "PCM",
1867 * build control elements
1870 #define NID_MAPPING (-1)
1872 #define SUBDEV_SPEAKER_ (0 << 6)
1873 #define SUBDEV_HP_ (1 << 6)
1874 #define SUBDEV_LINE_ (2 << 6)
1875 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
1876 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
1877 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
1879 static void alc_free_kctls(struct hda_codec
*codec
);
1881 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1882 /* additional beep mixers; the actual parameters are overwritten at build */
1883 static const struct snd_kcontrol_new alc_beep_mixer
[] = {
1884 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT
),
1885 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT
),
1890 static int __alc_build_controls(struct hda_codec
*codec
)
1892 struct alc_spec
*spec
= codec
->spec
;
1893 struct snd_kcontrol
*kctl
= NULL
;
1894 const struct snd_kcontrol_new
*knew
;
1899 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1900 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
1904 if (spec
->cap_mixer
) {
1905 err
= snd_hda_add_new_ctls(codec
, spec
->cap_mixer
);
1909 if (spec
->multiout
.dig_out_nid
) {
1910 err
= snd_hda_create_spdif_out_ctls(codec
,
1911 spec
->multiout
.dig_out_nid
,
1912 spec
->multiout
.dig_out_nid
);
1915 if (!spec
->no_analog
) {
1916 err
= snd_hda_create_spdif_share_sw(codec
,
1920 spec
->multiout
.share_spdif
= 1;
1923 if (spec
->dig_in_nid
) {
1924 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
1929 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1930 /* create beep controls if needed */
1931 if (spec
->beep_amp
) {
1932 const struct snd_kcontrol_new
*knew
;
1933 for (knew
= alc_beep_mixer
; knew
->name
; knew
++) {
1934 struct snd_kcontrol
*kctl
;
1935 kctl
= snd_ctl_new1(knew
, codec
);
1938 kctl
->private_value
= spec
->beep_amp
;
1939 err
= snd_hda_ctl_add(codec
, 0, kctl
);
1946 /* if we have no master control, let's create it */
1947 if (!spec
->no_analog
&&
1948 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
1949 unsigned int vmaster_tlv
[4];
1950 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
1951 HDA_OUTPUT
, vmaster_tlv
);
1952 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
1953 vmaster_tlv
, alc_slave_pfxs
,
1958 if (!spec
->no_analog
&&
1959 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
1960 err
= __snd_hda_add_vmaster(codec
, "Master Playback Switch",
1961 NULL
, alc_slave_pfxs
,
1963 true, &spec
->vmaster_sw_kctl
);
1968 /* assign Capture Source enums to NID */
1969 if (spec
->capsrc_nids
|| spec
->adc_nids
) {
1970 kctl
= snd_hda_find_mixer_ctl(codec
, "Capture Source");
1972 kctl
= snd_hda_find_mixer_ctl(codec
, "Input Source");
1973 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
1974 err
= snd_hda_add_nid(codec
, kctl
, i
,
1975 get_capsrc(spec
, i
));
1980 if (spec
->cap_mixer
&& spec
->adc_nids
) {
1981 const char *kname
= kctl
? kctl
->id
.name
: NULL
;
1982 for (knew
= spec
->cap_mixer
; knew
->name
; knew
++) {
1983 if (kname
&& strcmp(knew
->name
, kname
) == 0)
1985 kctl
= snd_hda_find_mixer_ctl(codec
, knew
->name
);
1986 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
1987 err
= snd_hda_add_nid(codec
, kctl
, i
,
1995 /* other nid->control mapping */
1996 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1997 for (knew
= spec
->mixers
[i
]; knew
->name
; knew
++) {
1998 if (knew
->iface
!= NID_MAPPING
)
2000 kctl
= snd_hda_find_mixer_ctl(codec
, knew
->name
);
2003 u
= knew
->subdevice
;
2004 for (j
= 0; j
< 4; j
++, u
>>= 8) {
2009 case SUBDEV_SPEAKER_
:
2010 nid
= spec
->autocfg
.speaker_pins
[nid
];
2013 nid
= spec
->autocfg
.line_out_pins
[nid
];
2016 nid
= spec
->autocfg
.hp_pins
[nid
];
2021 err
= snd_hda_add_nid(codec
, kctl
, 0, nid
);
2025 u
= knew
->private_value
;
2026 for (j
= 0; j
< 4; j
++, u
>>= 8) {
2030 err
= snd_hda_add_nid(codec
, kctl
, 0, nid
);
2037 alc_free_kctls(codec
); /* no longer needed */
2042 static int alc_build_controls(struct hda_codec
*codec
)
2044 struct alc_spec
*spec
= codec
->spec
;
2045 int err
= __alc_build_controls(codec
);
2048 err
= snd_hda_jack_add_kctls(codec
, &spec
->autocfg
);
2051 alc_apply_fixup(codec
, ALC_FIXUP_ACT_BUILD
);
2060 static void alc_init_special_input_src(struct hda_codec
*codec
);
2061 static void alc_auto_init_std(struct hda_codec
*codec
);
2063 static int alc_init(struct hda_codec
*codec
)
2065 struct alc_spec
*spec
= codec
->spec
;
2068 if (spec
->init_hook
)
2069 spec
->init_hook(codec
);
2072 alc_auto_init_amp(codec
, spec
->init_amp
);
2074 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
2075 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
2076 alc_init_special_input_src(codec
);
2077 alc_auto_init_std(codec
);
2079 alc_apply_fixup(codec
, ALC_FIXUP_ACT_INIT
);
2081 snd_hda_jack_report_sync(codec
);
2083 hda_call_check_power_status(codec
, 0x01);
2087 static void alc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2089 struct alc_spec
*spec
= codec
->spec
;
2091 if (spec
->unsol_event
)
2092 spec
->unsol_event(codec
, res
);
2095 #ifdef CONFIG_SND_HDA_POWER_SAVE
2096 static int alc_check_power_status(struct hda_codec
*codec
, hda_nid_t nid
)
2098 struct alc_spec
*spec
= codec
->spec
;
2099 return snd_hda_check_amp_list_power(codec
, &spec
->loopback
, nid
);
2104 * Analog playback callbacks
2106 static int alc_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2107 struct hda_codec
*codec
,
2108 struct snd_pcm_substream
*substream
)
2110 struct alc_spec
*spec
= codec
->spec
;
2111 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
2115 static int alc_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2116 struct hda_codec
*codec
,
2117 unsigned int stream_tag
,
2118 unsigned int format
,
2119 struct snd_pcm_substream
*substream
)
2121 struct alc_spec
*spec
= codec
->spec
;
2122 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
2123 stream_tag
, format
, substream
);
2126 static int alc_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2127 struct hda_codec
*codec
,
2128 struct snd_pcm_substream
*substream
)
2130 struct alc_spec
*spec
= codec
->spec
;
2131 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
2137 static int alc_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2138 struct hda_codec
*codec
,
2139 struct snd_pcm_substream
*substream
)
2141 struct alc_spec
*spec
= codec
->spec
;
2142 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
2145 static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2146 struct hda_codec
*codec
,
2147 unsigned int stream_tag
,
2148 unsigned int format
,
2149 struct snd_pcm_substream
*substream
)
2151 struct alc_spec
*spec
= codec
->spec
;
2152 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
2153 stream_tag
, format
, substream
);
2156 static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2157 struct hda_codec
*codec
,
2158 struct snd_pcm_substream
*substream
)
2160 struct alc_spec
*spec
= codec
->spec
;
2161 return snd_hda_multi_out_dig_cleanup(codec
, &spec
->multiout
);
2164 static int alc_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
2165 struct hda_codec
*codec
,
2166 struct snd_pcm_substream
*substream
)
2168 struct alc_spec
*spec
= codec
->spec
;
2169 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
2175 static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2176 struct hda_codec
*codec
,
2177 unsigned int stream_tag
,
2178 unsigned int format
,
2179 struct snd_pcm_substream
*substream
)
2181 struct alc_spec
*spec
= codec
->spec
;
2183 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
+ 1],
2184 stream_tag
, 0, format
);
2188 static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2189 struct hda_codec
*codec
,
2190 struct snd_pcm_substream
*substream
)
2192 struct alc_spec
*spec
= codec
->spec
;
2194 snd_hda_codec_cleanup_stream(codec
,
2195 spec
->adc_nids
[substream
->number
+ 1]);
2199 /* analog capture with dynamic dual-adc changes */
2200 static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2201 struct hda_codec
*codec
,
2202 unsigned int stream_tag
,
2203 unsigned int format
,
2204 struct snd_pcm_substream
*substream
)
2206 struct alc_spec
*spec
= codec
->spec
;
2207 spec
->cur_adc
= spec
->adc_nids
[spec
->dyn_adc_idx
[spec
->cur_mux
[0]]];
2208 spec
->cur_adc_stream_tag
= stream_tag
;
2209 spec
->cur_adc_format
= format
;
2210 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
2214 static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2215 struct hda_codec
*codec
,
2216 struct snd_pcm_substream
*substream
)
2218 struct alc_spec
*spec
= codec
->spec
;
2219 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
2224 static const struct hda_pcm_stream dyn_adc_pcm_analog_capture
= {
2228 .nid
= 0, /* fill later */
2230 .prepare
= dyn_adc_capture_pcm_prepare
,
2231 .cleanup
= dyn_adc_capture_pcm_cleanup
2237 static const struct hda_pcm_stream alc_pcm_analog_playback
= {
2241 /* NID is set in alc_build_pcms */
2243 .open
= alc_playback_pcm_open
,
2244 .prepare
= alc_playback_pcm_prepare
,
2245 .cleanup
= alc_playback_pcm_cleanup
2249 static const struct hda_pcm_stream alc_pcm_analog_capture
= {
2253 /* NID is set in alc_build_pcms */
2256 static const struct hda_pcm_stream alc_pcm_analog_alt_playback
= {
2260 /* NID is set in alc_build_pcms */
2263 static const struct hda_pcm_stream alc_pcm_analog_alt_capture
= {
2264 .substreams
= 2, /* can be overridden */
2267 /* NID is set in alc_build_pcms */
2269 .prepare
= alc_alt_capture_pcm_prepare
,
2270 .cleanup
= alc_alt_capture_pcm_cleanup
2274 static const struct hda_pcm_stream alc_pcm_digital_playback
= {
2278 /* NID is set in alc_build_pcms */
2280 .open
= alc_dig_playback_pcm_open
,
2281 .close
= alc_dig_playback_pcm_close
,
2282 .prepare
= alc_dig_playback_pcm_prepare
,
2283 .cleanup
= alc_dig_playback_pcm_cleanup
2287 static const struct hda_pcm_stream alc_pcm_digital_capture
= {
2291 /* NID is set in alc_build_pcms */
2294 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2295 static const struct hda_pcm_stream alc_pcm_null_stream
= {
2301 static int alc_build_pcms(struct hda_codec
*codec
)
2303 struct alc_spec
*spec
= codec
->spec
;
2304 struct hda_pcm
*info
= spec
->pcm_rec
;
2305 const struct hda_pcm_stream
*p
;
2306 bool have_multi_adcs
;
2309 codec
->num_pcms
= 1;
2310 codec
->pcm_info
= info
;
2312 if (spec
->no_analog
)
2315 snprintf(spec
->stream_name_analog
, sizeof(spec
->stream_name_analog
),
2316 "%s Analog", codec
->chip_name
);
2317 info
->name
= spec
->stream_name_analog
;
2319 if (spec
->multiout
.num_dacs
> 0) {
2320 p
= spec
->stream_analog_playback
;
2322 p
= &alc_pcm_analog_playback
;
2323 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2324 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dac_nids
[0];
2326 if (spec
->adc_nids
) {
2327 p
= spec
->stream_analog_capture
;
2329 if (spec
->dyn_adc_switch
)
2330 p
= &dyn_adc_pcm_analog_capture
;
2332 p
= &alc_pcm_analog_capture
;
2334 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2335 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
2338 if (spec
->channel_mode
) {
2339 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= 0;
2340 for (i
= 0; i
< spec
->num_channel_mode
; i
++) {
2341 if (spec
->channel_mode
[i
].channels
> info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
) {
2342 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= spec
->channel_mode
[i
].channels
;
2348 /* SPDIF for stream index #1 */
2349 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
2350 snprintf(spec
->stream_name_digital
,
2351 sizeof(spec
->stream_name_digital
),
2352 "%s Digital", codec
->chip_name
);
2353 codec
->num_pcms
= 2;
2354 codec
->slave_dig_outs
= spec
->multiout
.slave_dig_outs
;
2355 info
= spec
->pcm_rec
+ 1;
2356 info
->name
= spec
->stream_name_digital
;
2357 if (spec
->dig_out_type
)
2358 info
->pcm_type
= spec
->dig_out_type
;
2360 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
2361 if (spec
->multiout
.dig_out_nid
) {
2362 p
= spec
->stream_digital_playback
;
2364 p
= &alc_pcm_digital_playback
;
2365 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2366 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
2368 if (spec
->dig_in_nid
) {
2369 p
= spec
->stream_digital_capture
;
2371 p
= &alc_pcm_digital_capture
;
2372 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2373 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
2375 /* FIXME: do we need this for all Realtek codec models? */
2376 codec
->spdif_status_reset
= 1;
2379 if (spec
->no_analog
)
2382 /* If the use of more than one ADC is requested for the current
2383 * model, configure a second analog capture-only PCM.
2385 have_multi_adcs
= (spec
->num_adc_nids
> 1) &&
2386 !spec
->dyn_adc_switch
&& !spec
->auto_mic
&&
2387 (!spec
->input_mux
|| spec
->input_mux
->num_items
> 1);
2388 /* Additional Analaog capture for index #2 */
2389 if (spec
->alt_dac_nid
|| have_multi_adcs
) {
2390 codec
->num_pcms
= 3;
2391 info
= spec
->pcm_rec
+ 2;
2392 info
->name
= spec
->stream_name_analog
;
2393 if (spec
->alt_dac_nid
) {
2394 p
= spec
->stream_analog_alt_playback
;
2396 p
= &alc_pcm_analog_alt_playback
;
2397 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2398 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
2401 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
2402 alc_pcm_null_stream
;
2403 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= 0;
2405 if (have_multi_adcs
) {
2406 p
= spec
->stream_analog_alt_capture
;
2408 p
= &alc_pcm_analog_alt_capture
;
2409 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2410 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
2412 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
=
2413 spec
->num_adc_nids
- 1;
2415 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
2416 alc_pcm_null_stream
;
2417 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= 0;
2424 static inline void alc_shutup(struct hda_codec
*codec
)
2426 struct alc_spec
*spec
= codec
->spec
;
2428 if (spec
&& spec
->shutup
)
2429 spec
->shutup(codec
);
2430 snd_hda_shutup_pins(codec
);
2433 static void alc_free_kctls(struct hda_codec
*codec
)
2435 struct alc_spec
*spec
= codec
->spec
;
2437 if (spec
->kctls
.list
) {
2438 struct snd_kcontrol_new
*kctl
= spec
->kctls
.list
;
2440 for (i
= 0; i
< spec
->kctls
.used
; i
++)
2441 kfree(kctl
[i
].name
);
2443 snd_array_free(&spec
->kctls
);
2446 static void alc_free_bind_ctls(struct hda_codec
*codec
)
2448 struct alc_spec
*spec
= codec
->spec
;
2449 if (spec
->bind_ctls
.list
) {
2450 struct hda_bind_ctls
**ctl
= spec
->bind_ctls
.list
;
2452 for (i
= 0; i
< spec
->bind_ctls
.used
; i
++)
2455 snd_array_free(&spec
->bind_ctls
);
2458 static void alc_free(struct hda_codec
*codec
)
2460 struct alc_spec
*spec
= codec
->spec
;
2466 alc_free_kctls(codec
);
2467 alc_free_bind_ctls(codec
);
2469 snd_hda_detach_beep_device(codec
);
2472 #ifdef CONFIG_SND_HDA_POWER_SAVE
2473 static void alc_power_eapd(struct hda_codec
*codec
)
2475 alc_auto_setup_eapd(codec
, false);
2478 static int alc_suspend(struct hda_codec
*codec
, pm_message_t state
)
2480 struct alc_spec
*spec
= codec
->spec
;
2482 if (spec
&& spec
->power_hook
)
2483 spec
->power_hook(codec
);
2489 static int alc_resume(struct hda_codec
*codec
)
2491 msleep(150); /* to avoid pop noise */
2492 codec
->patch_ops
.init(codec
);
2493 snd_hda_codec_resume_amp(codec
);
2494 snd_hda_codec_resume_cache(codec
);
2495 hda_call_check_power_status(codec
, 0x01);
2502 static const struct hda_codec_ops alc_patch_ops
= {
2503 .build_controls
= alc_build_controls
,
2504 .build_pcms
= alc_build_pcms
,
2507 .unsol_event
= alc_unsol_event
,
2509 .resume
= alc_resume
,
2511 #ifdef CONFIG_SND_HDA_POWER_SAVE
2512 .suspend
= alc_suspend
,
2513 .check_power_status
= alc_check_power_status
,
2515 .reboot_notify
= alc_shutup
,
2518 /* replace the codec chip_name with the given string */
2519 static int alc_codec_rename(struct hda_codec
*codec
, const char *name
)
2521 kfree(codec
->chip_name
);
2522 codec
->chip_name
= kstrdup(name
, GFP_KERNEL
);
2523 if (!codec
->chip_name
) {
2531 * Rename codecs appropriately from COEF value
2533 struct alc_codec_rename_table
{
2534 unsigned int vendor_id
;
2535 unsigned short coef_mask
;
2536 unsigned short coef_bits
;
2540 static struct alc_codec_rename_table rename_tbl
[] = {
2541 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
2542 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
2543 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
2544 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
2545 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
2546 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
2547 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
2548 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
2549 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
2550 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
2551 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
2552 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
2553 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
2554 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
2555 { } /* terminator */
2558 static int alc_codec_rename_from_preset(struct hda_codec
*codec
)
2560 const struct alc_codec_rename_table
*p
;
2562 for (p
= rename_tbl
; p
->vendor_id
; p
++) {
2563 if (p
->vendor_id
!= codec
->vendor_id
)
2565 if ((alc_get_coef0(codec
) & p
->coef_mask
) == p
->coef_bits
)
2566 return alc_codec_rename(codec
, p
->name
);
2572 * Automatic parse of I/O pins from the BIOS configuration
2577 ALC_CTL_WIDGET_MUTE
,
2582 static const struct snd_kcontrol_new alc_control_templates
[] = {
2583 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2584 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2585 HDA_BIND_MUTE(NULL
, 0, 0, 0),
2586 HDA_BIND_VOL(NULL
, 0),
2587 HDA_BIND_SW(NULL
, 0),
2590 /* add dynamic controls */
2591 static int add_control(struct alc_spec
*spec
, int type
, const char *name
,
2592 int cidx
, unsigned long val
)
2594 struct snd_kcontrol_new
*knew
;
2596 knew
= alc_kcontrol_new(spec
);
2599 *knew
= alc_control_templates
[type
];
2600 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2604 if (get_amp_nid_(val
))
2605 knew
->subdevice
= HDA_SUBDEV_AMP_FLAG
;
2606 knew
->private_value
= val
;
2610 static int add_control_with_pfx(struct alc_spec
*spec
, int type
,
2611 const char *pfx
, const char *dir
,
2612 const char *sfx
, int cidx
, unsigned long val
)
2615 snprintf(name
, sizeof(name
), "%s %s %s", pfx
, dir
, sfx
);
2616 return add_control(spec
, type
, name
, cidx
, val
);
2619 #define add_pb_vol_ctrl(spec, type, pfx, val) \
2620 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
2621 #define add_pb_sw_ctrl(spec, type, pfx, val) \
2622 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
2623 #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
2624 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
2625 #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
2626 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
2628 static const char * const channel_name
[4] = {
2629 "Front", "Surround", "CLFE", "Side"
2632 static const char *alc_get_line_out_pfx(struct alc_spec
*spec
, int ch
,
2633 bool can_be_master
, int *index
)
2635 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2638 if (cfg
->line_outs
== 1 && !spec
->multi_ios
&&
2639 !cfg
->hp_outs
&& !cfg
->speaker_outs
&& can_be_master
)
2642 switch (cfg
->line_out_type
) {
2643 case AUTO_PIN_SPEAKER_OUT
:
2644 if (cfg
->line_outs
== 1)
2646 if (cfg
->line_outs
== 2)
2647 return ch
? "Bass Speaker" : "Speaker";
2649 case AUTO_PIN_HP_OUT
:
2650 /* for multi-io case, only the primary out */
2651 if (ch
&& spec
->multi_ios
)
2656 if (cfg
->line_outs
== 1 && !spec
->multi_ios
)
2660 if (snd_BUG_ON(ch
>= ARRAY_SIZE(channel_name
)))
2663 return channel_name
[ch
];
2666 #ifdef CONFIG_SND_HDA_POWER_SAVE
2667 /* add the powersave loopback-list entry */
2668 static void add_loopback_list(struct alc_spec
*spec
, hda_nid_t mix
, int idx
)
2670 struct hda_amp_list
*list
;
2672 if (spec
->num_loopbacks
>= ARRAY_SIZE(spec
->loopback_list
) - 1)
2674 list
= spec
->loopback_list
+ spec
->num_loopbacks
;
2676 list
->dir
= HDA_INPUT
;
2678 spec
->num_loopbacks
++;
2679 spec
->loopback
.amplist
= spec
->loopback_list
;
2682 #define add_loopback_list(spec, mix, idx) /* NOP */
2685 /* create input playback/capture controls for the given pin */
2686 static int new_analog_input(struct alc_spec
*spec
, hda_nid_t pin
,
2687 const char *ctlname
, int ctlidx
,
2688 int idx
, hda_nid_t mix_nid
)
2692 err
= __add_pb_vol_ctrl(spec
, ALC_CTL_WIDGET_VOL
, ctlname
, ctlidx
,
2693 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
));
2696 err
= __add_pb_sw_ctrl(spec
, ALC_CTL_WIDGET_MUTE
, ctlname
, ctlidx
,
2697 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
));
2700 add_loopback_list(spec
, mix_nid
, idx
);
2704 static int alc_is_input_pin(struct hda_codec
*codec
, hda_nid_t nid
)
2706 unsigned int pincap
= snd_hda_query_pin_caps(codec
, nid
);
2707 return (pincap
& AC_PINCAP_IN
) != 0;
2710 /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */
2711 static int alc_auto_fill_adc_caps(struct hda_codec
*codec
)
2713 struct alc_spec
*spec
= codec
->spec
;
2715 hda_nid_t
*adc_nids
= spec
->private_adc_nids
;
2716 hda_nid_t
*cap_nids
= spec
->private_capsrc_nids
;
2717 int max_nums
= ARRAY_SIZE(spec
->private_adc_nids
);
2720 if (spec
->shared_mic_hp
)
2721 max_nums
= 1; /* no multi streams with the shared HP/mic */
2723 nid
= codec
->start_nid
;
2724 for (i
= 0; i
< codec
->num_nodes
; i
++, nid
++) {
2726 const hda_nid_t
*list
;
2727 unsigned int caps
= get_wcaps(codec
, nid
);
2728 int type
= get_wcaps_type(caps
);
2730 if (type
!= AC_WID_AUD_IN
|| (caps
& AC_WCAP_DIGITAL
))
2732 adc_nids
[nums
] = nid
;
2733 cap_nids
[nums
] = nid
;
2737 type
= get_wcaps_type(get_wcaps(codec
, src
));
2738 if (type
== AC_WID_PIN
)
2740 if (type
== AC_WID_AUD_SEL
) {
2741 cap_nids
[nums
] = src
;
2744 n
= snd_hda_get_conn_list(codec
, src
, &list
);
2746 cap_nids
[nums
] = src
;
2752 if (++nums
>= max_nums
)
2755 spec
->adc_nids
= spec
->private_adc_nids
;
2756 spec
->capsrc_nids
= spec
->private_capsrc_nids
;
2757 spec
->num_adc_nids
= nums
;
2761 /* create playback/capture controls for input pins */
2762 static int alc_auto_create_input_ctls(struct hda_codec
*codec
)
2764 struct alc_spec
*spec
= codec
->spec
;
2765 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2766 hda_nid_t mixer
= spec
->mixer_nid
;
2767 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
2769 int i
, c
, err
, idx
, type_idx
= 0;
2770 const char *prev_label
= NULL
;
2772 num_adcs
= alc_auto_fill_adc_caps(codec
);
2776 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2780 pin
= cfg
->inputs
[i
].pin
;
2781 if (!alc_is_input_pin(codec
, pin
))
2784 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
2785 if (spec
->shared_mic_hp
&& !strcmp(label
, "Misc"))
2786 label
= "Headphone Mic";
2787 if (prev_label
&& !strcmp(label
, prev_label
))
2794 idx
= get_connection_index(codec
, mixer
, pin
);
2796 err
= new_analog_input(spec
, pin
,
2804 for (c
= 0; c
< num_adcs
; c
++) {
2805 hda_nid_t cap
= get_capsrc(spec
, c
);
2806 idx
= get_connection_index(codec
, cap
, pin
);
2808 spec
->imux_pins
[imux
->num_items
] = pin
;
2809 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
2815 spec
->num_mux_defs
= 1;
2816 spec
->input_mux
= imux
;
2821 /* create a shared input with the headphone out */
2822 static int alc_auto_create_shared_input(struct hda_codec
*codec
)
2824 struct alc_spec
*spec
= codec
->spec
;
2825 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2826 unsigned int defcfg
;
2829 /* only one internal input pin? */
2830 if (cfg
->num_inputs
!= 1)
2832 defcfg
= snd_hda_codec_get_pincfg(codec
, cfg
->inputs
[0].pin
);
2833 if (snd_hda_get_input_pin_attr(defcfg
) != INPUT_PIN_ATTR_INT
)
2836 if (cfg
->hp_outs
== 1 && cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
)
2837 nid
= cfg
->hp_pins
[0]; /* OK, we have a single HP-out */
2838 else if (cfg
->line_outs
== 1 && cfg
->line_out_type
== AUTO_PIN_HP_OUT
)
2839 nid
= cfg
->line_out_pins
[0]; /* OK, we have a single line-out */
2841 return 0; /* both not available */
2843 if (!(snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_IN
))
2844 return 0; /* no input */
2846 cfg
->inputs
[1].pin
= nid
;
2847 cfg
->inputs
[1].type
= AUTO_PIN_MIC
;
2848 cfg
->num_inputs
= 2;
2849 spec
->shared_mic_hp
= 1;
2850 snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid
);
2854 static void alc_set_pin_output(struct hda_codec
*codec
, hda_nid_t nid
,
2855 unsigned int pin_type
)
2857 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2860 if (nid_has_mute(codec
, nid
, HDA_OUTPUT
))
2861 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
2865 static int get_pin_type(int line_out_type
)
2867 if (line_out_type
== AUTO_PIN_HP_OUT
)
2873 static void alc_auto_init_analog_input(struct hda_codec
*codec
)
2875 struct alc_spec
*spec
= codec
->spec
;
2876 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2879 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2880 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
2881 if (alc_is_input_pin(codec
, nid
)) {
2882 alc_set_input_pin(codec
, nid
, cfg
->inputs
[i
].type
);
2883 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
2884 snd_hda_codec_write(codec
, nid
, 0,
2885 AC_VERB_SET_AMP_GAIN_MUTE
,
2890 /* mute all loopback inputs */
2891 if (spec
->mixer_nid
) {
2892 int nums
= snd_hda_get_conn_list(codec
, spec
->mixer_nid
, NULL
);
2893 for (i
= 0; i
< nums
; i
++)
2894 snd_hda_codec_write(codec
, spec
->mixer_nid
, 0,
2895 AC_VERB_SET_AMP_GAIN_MUTE
,
2900 /* convert from MIX nid to DAC */
2901 static hda_nid_t
alc_auto_mix_to_dac(struct hda_codec
*codec
, hda_nid_t nid
)
2906 if (get_wcaps_type(get_wcaps(codec
, nid
)) == AC_WID_AUD_OUT
)
2908 num
= snd_hda_get_connections(codec
, nid
, list
, ARRAY_SIZE(list
));
2909 for (i
= 0; i
< num
; i
++) {
2910 if (get_wcaps_type(get_wcaps(codec
, list
[i
])) == AC_WID_AUD_OUT
)
2916 /* go down to the selector widget before the mixer */
2917 static hda_nid_t
alc_go_down_to_selector(struct hda_codec
*codec
, hda_nid_t pin
)
2920 int num
= snd_hda_get_connections(codec
, pin
, srcs
,
2923 get_wcaps_type(get_wcaps(codec
, srcs
[0])) != AC_WID_AUD_SEL
)
2928 /* get MIX nid connected to the given pin targeted to DAC */
2929 static hda_nid_t
alc_auto_dac_to_mix(struct hda_codec
*codec
, hda_nid_t pin
,
2935 pin
= alc_go_down_to_selector(codec
, pin
);
2936 num
= snd_hda_get_connections(codec
, pin
, mix
, ARRAY_SIZE(mix
));
2937 for (i
= 0; i
< num
; i
++) {
2938 if (alc_auto_mix_to_dac(codec
, mix
[i
]) == dac
)
2944 /* select the connection from pin to DAC if needed */
2945 static int alc_auto_select_dac(struct hda_codec
*codec
, hda_nid_t pin
,
2951 pin
= alc_go_down_to_selector(codec
, pin
);
2952 num
= snd_hda_get_connections(codec
, pin
, mix
, ARRAY_SIZE(mix
));
2955 for (i
= 0; i
< num
; i
++) {
2956 if (alc_auto_mix_to_dac(codec
, mix
[i
]) == dac
) {
2957 snd_hda_codec_update_cache(codec
, pin
, 0,
2958 AC_VERB_SET_CONNECT_SEL
, i
);
2965 static bool alc_is_dac_already_used(struct hda_codec
*codec
, hda_nid_t nid
)
2967 struct alc_spec
*spec
= codec
->spec
;
2969 if (found_in_nid_list(nid
, spec
->multiout
.dac_nids
,
2970 ARRAY_SIZE(spec
->private_dac_nids
)) ||
2971 found_in_nid_list(nid
, spec
->multiout
.hp_out_nid
,
2972 ARRAY_SIZE(spec
->multiout
.hp_out_nid
)) ||
2973 found_in_nid_list(nid
, spec
->multiout
.extra_out_nid
,
2974 ARRAY_SIZE(spec
->multiout
.extra_out_nid
)))
2976 for (i
= 0; i
< spec
->multi_ios
; i
++) {
2977 if (spec
->multi_io
[i
].dac
== nid
)
2983 /* look for an empty DAC slot */
2984 static hda_nid_t
alc_auto_look_for_dac(struct hda_codec
*codec
, hda_nid_t pin
)
2989 pin
= alc_go_down_to_selector(codec
, pin
);
2990 num
= snd_hda_get_connections(codec
, pin
, srcs
, ARRAY_SIZE(srcs
));
2991 for (i
= 0; i
< num
; i
++) {
2992 hda_nid_t nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
2995 if (!alc_is_dac_already_used(codec
, nid
))
3001 /* check whether the DAC is reachable from the pin */
3002 static bool alc_auto_is_dac_reachable(struct hda_codec
*codec
,
3003 hda_nid_t pin
, hda_nid_t dac
)
3010 pin
= alc_go_down_to_selector(codec
, pin
);
3011 num
= snd_hda_get_connections(codec
, pin
, srcs
, ARRAY_SIZE(srcs
));
3012 for (i
= 0; i
< num
; i
++) {
3013 hda_nid_t nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
3020 static hda_nid_t
get_dac_if_single(struct hda_codec
*codec
, hda_nid_t pin
)
3022 struct alc_spec
*spec
= codec
->spec
;
3023 hda_nid_t sel
= alc_go_down_to_selector(codec
, pin
);
3024 hda_nid_t nid
, nid_found
, srcs
[5];
3025 int i
, num
= snd_hda_get_connections(codec
, sel
, srcs
,
3028 return alc_auto_look_for_dac(codec
, pin
);
3030 for (i
= 0; i
< num
; i
++) {
3031 if (srcs
[i
] == spec
->mixer_nid
)
3033 nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
3034 if (nid
&& !alc_is_dac_already_used(codec
, nid
)) {
3043 /* mark up volume and mute control NIDs: used during badness parsing and
3044 * at creating actual controls
3046 static inline unsigned int get_ctl_pos(unsigned int data
)
3048 hda_nid_t nid
= get_amp_nid_(data
);
3050 if (snd_BUG_ON(nid
>= MAX_VOL_NIDS
))
3052 dir
= get_amp_direction_(data
);
3053 return (nid
<< 1) | dir
;
3056 #define is_ctl_used(bits, data) \
3057 test_bit(get_ctl_pos(data), bits)
3058 #define mark_ctl_usage(bits, data) \
3059 set_bit(get_ctl_pos(data), bits)
3061 static void clear_vol_marks(struct hda_codec
*codec
)
3063 struct alc_spec
*spec
= codec
->spec
;
3064 memset(spec
->vol_ctls
, 0, sizeof(spec
->vol_ctls
));
3065 memset(spec
->sw_ctls
, 0, sizeof(spec
->sw_ctls
));
3068 /* badness definition */
3070 /* No primary DAC is found for the main output */
3071 BAD_NO_PRIMARY_DAC
= 0x10000,
3072 /* No DAC is found for the extra output */
3073 BAD_NO_DAC
= 0x4000,
3074 /* No possible multi-ios */
3075 BAD_MULTI_IO
= 0x103,
3076 /* No individual DAC for extra output */
3077 BAD_NO_EXTRA_DAC
= 0x102,
3078 /* No individual DAC for extra surrounds */
3079 BAD_NO_EXTRA_SURR_DAC
= 0x101,
3080 /* Primary DAC shared with main surrounds */
3081 BAD_SHARED_SURROUND
= 0x100,
3082 /* Primary DAC shared with main CLFE */
3083 BAD_SHARED_CLFE
= 0x10,
3084 /* Primary DAC shared with extra surrounds */
3085 BAD_SHARED_EXTRA_SURROUND
= 0x10,
3086 /* Volume widget is shared */
3087 BAD_SHARED_VOL
= 0x10,
3090 static hda_nid_t
alc_look_for_out_mute_nid(struct hda_codec
*codec
,
3091 hda_nid_t pin
, hda_nid_t dac
);
3092 static hda_nid_t
alc_look_for_out_vol_nid(struct hda_codec
*codec
,
3093 hda_nid_t pin
, hda_nid_t dac
);
3095 static int eval_shared_vol_badness(struct hda_codec
*codec
, hda_nid_t pin
,
3098 struct alc_spec
*spec
= codec
->spec
;
3103 nid
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3105 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
3106 if (is_ctl_used(spec
->vol_ctls
, nid
))
3107 badness
+= BAD_SHARED_VOL
;
3109 mark_ctl_usage(spec
->vol_ctls
, val
);
3111 badness
+= BAD_SHARED_VOL
;
3112 nid
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3114 unsigned int wid_type
= get_wcaps_type(get_wcaps(codec
, nid
));
3115 if (wid_type
== AC_WID_PIN
|| wid_type
== AC_WID_AUD_OUT
)
3116 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
3118 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_INPUT
);
3119 if (is_ctl_used(spec
->sw_ctls
, val
))
3120 badness
+= BAD_SHARED_VOL
;
3122 mark_ctl_usage(spec
->sw_ctls
, val
);
3124 badness
+= BAD_SHARED_VOL
;
3128 struct badness_table
{
3129 int no_primary_dac
; /* no primary DAC */
3130 int no_dac
; /* no secondary DACs */
3131 int shared_primary
; /* primary DAC is shared with main output */
3132 int shared_surr
; /* secondary DAC shared with main or primary */
3133 int shared_clfe
; /* third DAC shared with main or primary */
3134 int shared_surr_main
; /* secondary DAC sahred with main/DAC0 */
3137 static struct badness_table main_out_badness
= {
3138 .no_primary_dac
= BAD_NO_PRIMARY_DAC
,
3139 .no_dac
= BAD_NO_DAC
,
3140 .shared_primary
= BAD_NO_PRIMARY_DAC
,
3141 .shared_surr
= BAD_SHARED_SURROUND
,
3142 .shared_clfe
= BAD_SHARED_CLFE
,
3143 .shared_surr_main
= BAD_SHARED_SURROUND
,
3146 static struct badness_table extra_out_badness
= {
3147 .no_primary_dac
= BAD_NO_DAC
,
3148 .no_dac
= BAD_NO_DAC
,
3149 .shared_primary
= BAD_NO_EXTRA_DAC
,
3150 .shared_surr
= BAD_SHARED_EXTRA_SURROUND
,
3151 .shared_clfe
= BAD_SHARED_EXTRA_SURROUND
,
3152 .shared_surr_main
= BAD_NO_EXTRA_SURR_DAC
,
3155 /* try to assign DACs to pins and return the resultant badness */
3156 static int alc_auto_fill_dacs(struct hda_codec
*codec
, int num_outs
,
3157 const hda_nid_t
*pins
, hda_nid_t
*dacs
,
3158 const struct badness_table
*bad
)
3160 struct alc_spec
*spec
= codec
->spec
;
3161 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3169 for (i
= 0; i
< num_outs
; i
++) {
3170 hda_nid_t pin
= pins
[i
];
3172 dacs
[i
] = alc_auto_look_for_dac(codec
, pin
);
3173 if (!dacs
[i
] && !i
) {
3174 for (j
= 1; j
< num_outs
; j
++) {
3175 if (alc_auto_is_dac_reachable(codec
, pin
, dacs
[j
])) {
3184 if (alc_auto_is_dac_reachable(codec
, pin
, dacs
[0]))
3186 else if (cfg
->line_outs
> i
&&
3187 alc_auto_is_dac_reachable(codec
, pin
,
3188 spec
->private_dac_nids
[i
]))
3189 dac
= spec
->private_dac_nids
[i
];
3192 badness
+= bad
->shared_primary
;
3194 badness
+= bad
->shared_surr
;
3196 badness
+= bad
->shared_clfe
;
3197 } else if (alc_auto_is_dac_reachable(codec
, pin
,
3198 spec
->private_dac_nids
[0])) {
3199 dac
= spec
->private_dac_nids
[0];
3200 badness
+= bad
->shared_surr_main
;
3202 badness
+= bad
->no_primary_dac
;
3204 badness
+= bad
->no_dac
;
3207 badness
+= eval_shared_vol_badness(codec
, pin
, dac
);
3213 static int alc_auto_fill_multi_ios(struct hda_codec
*codec
,
3214 hda_nid_t reference_pin
,
3215 bool hardwired
, int offset
);
3217 static bool alc_map_singles(struct hda_codec
*codec
, int outs
,
3218 const hda_nid_t
*pins
, hda_nid_t
*dacs
)
3222 for (i
= 0; i
< outs
; i
++) {
3225 dacs
[i
] = get_dac_if_single(codec
, pins
[i
]);
3232 /* fill in the dac_nids table from the parsed pin configuration */
3233 static int fill_and_eval_dacs(struct hda_codec
*codec
,
3234 bool fill_hardwired
,
3235 bool fill_mio_first
)
3237 struct alc_spec
*spec
= codec
->spec
;
3238 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3239 int i
, err
, badness
;
3241 /* set num_dacs once to full for alc_auto_look_for_dac() */
3242 spec
->multiout
.num_dacs
= cfg
->line_outs
;
3243 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3244 memset(spec
->private_dac_nids
, 0, sizeof(spec
->private_dac_nids
));
3245 memset(spec
->multiout
.hp_out_nid
, 0, sizeof(spec
->multiout
.hp_out_nid
));
3246 memset(spec
->multiout
.extra_out_nid
, 0, sizeof(spec
->multiout
.extra_out_nid
));
3247 spec
->multi_ios
= 0;
3248 clear_vol_marks(codec
);
3251 /* fill hard-wired DACs first */
3252 if (fill_hardwired
) {
3255 mapped
= alc_map_singles(codec
, cfg
->line_outs
,
3257 spec
->private_dac_nids
);
3258 mapped
|= alc_map_singles(codec
, cfg
->hp_outs
,
3260 spec
->multiout
.hp_out_nid
);
3261 mapped
|= alc_map_singles(codec
, cfg
->speaker_outs
,
3263 spec
->multiout
.extra_out_nid
);
3264 if (fill_mio_first
&& cfg
->line_outs
== 1 &&
3265 cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3266 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], true, 0);
3273 badness
+= alc_auto_fill_dacs(codec
, cfg
->line_outs
, cfg
->line_out_pins
,
3274 spec
->private_dac_nids
,
3277 /* re-count num_dacs and squash invalid entries */
3278 spec
->multiout
.num_dacs
= 0;
3279 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3280 if (spec
->private_dac_nids
[i
])
3281 spec
->multiout
.num_dacs
++;
3283 memmove(spec
->private_dac_nids
+ i
,
3284 spec
->private_dac_nids
+ i
+ 1,
3285 sizeof(hda_nid_t
) * (cfg
->line_outs
- i
- 1));
3286 spec
->private_dac_nids
[cfg
->line_outs
- 1] = 0;
3290 if (fill_mio_first
&&
3291 cfg
->line_outs
== 1 && cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3292 /* try to fill multi-io first */
3293 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], false, 0);
3296 /* we don't count badness at this stage yet */
3299 if (cfg
->line_out_type
!= AUTO_PIN_HP_OUT
) {
3300 err
= alc_auto_fill_dacs(codec
, cfg
->hp_outs
, cfg
->hp_pins
,
3301 spec
->multiout
.hp_out_nid
,
3302 &extra_out_badness
);
3307 if (cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3308 err
= alc_auto_fill_dacs(codec
, cfg
->speaker_outs
,
3310 spec
->multiout
.extra_out_nid
,
3311 &extra_out_badness
);
3316 if (cfg
->line_outs
== 1 && cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3317 err
= alc_auto_fill_multi_ios(codec
, cfg
->line_out_pins
[0], false, 0);
3322 if (cfg
->hp_outs
&& cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
3323 /* try multi-ios with HP + inputs */
3325 if (cfg
->line_outs
>= 3)
3327 err
= alc_auto_fill_multi_ios(codec
, cfg
->hp_pins
[0], false,
3334 if (spec
->multi_ios
== 2) {
3335 for (i
= 0; i
< 2; i
++)
3336 spec
->private_dac_nids
[spec
->multiout
.num_dacs
++] =
3337 spec
->multi_io
[i
].dac
;
3338 spec
->ext_channel_count
= 2;
3339 } else if (spec
->multi_ios
) {
3340 spec
->multi_ios
= 0;
3341 badness
+= BAD_MULTI_IO
;
3347 #define DEBUG_BADNESS
3349 #ifdef DEBUG_BADNESS
3350 #define debug_badness snd_printdd
3352 #define debug_badness(...)
3355 static void debug_show_configs(struct alc_spec
*spec
, struct auto_pin_cfg
*cfg
)
3357 debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3358 cfg
->line_out_pins
[0], cfg
->line_out_pins
[1],
3359 cfg
->line_out_pins
[2], cfg
->line_out_pins
[2],
3360 spec
->multiout
.dac_nids
[0],
3361 spec
->multiout
.dac_nids
[1],
3362 spec
->multiout
.dac_nids
[2],
3363 spec
->multiout
.dac_nids
[3]);
3364 if (spec
->multi_ios
> 0)
3365 debug_badness("multi_ios(%d) = %x/%x : %x/%x\n",
3367 spec
->multi_io
[0].pin
, spec
->multi_io
[1].pin
,
3368 spec
->multi_io
[0].dac
, spec
->multi_io
[1].dac
);
3369 debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3370 cfg
->hp_pins
[0], cfg
->hp_pins
[1],
3371 cfg
->hp_pins
[2], cfg
->hp_pins
[2],
3372 spec
->multiout
.hp_out_nid
[0],
3373 spec
->multiout
.hp_out_nid
[1],
3374 spec
->multiout
.hp_out_nid
[2],
3375 spec
->multiout
.hp_out_nid
[3]);
3376 debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3377 cfg
->speaker_pins
[0], cfg
->speaker_pins
[1],
3378 cfg
->speaker_pins
[2], cfg
->speaker_pins
[3],
3379 spec
->multiout
.extra_out_nid
[0],
3380 spec
->multiout
.extra_out_nid
[1],
3381 spec
->multiout
.extra_out_nid
[2],
3382 spec
->multiout
.extra_out_nid
[3]);
3385 static int alc_auto_fill_dac_nids(struct hda_codec
*codec
)
3387 struct alc_spec
*spec
= codec
->spec
;
3388 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3389 struct auto_pin_cfg
*best_cfg
;
3390 int best_badness
= INT_MAX
;
3392 bool fill_hardwired
= true, fill_mio_first
= true;
3393 bool best_wired
= true, best_mio
= true;
3394 bool hp_spk_swapped
= false;
3396 best_cfg
= kmalloc(sizeof(*best_cfg
), GFP_KERNEL
);
3402 badness
= fill_and_eval_dacs(codec
, fill_hardwired
,
3406 debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n",
3407 cfg
->line_out_type
, fill_hardwired
, fill_mio_first
,
3409 debug_show_configs(spec
, cfg
);
3410 if (badness
< best_badness
) {
3411 best_badness
= badness
;
3413 best_wired
= fill_hardwired
;
3414 best_mio
= fill_mio_first
;
3418 fill_mio_first
= !fill_mio_first
;
3419 if (!fill_mio_first
)
3421 fill_hardwired
= !fill_hardwired
;
3422 if (!fill_hardwired
)
3426 hp_spk_swapped
= true;
3427 if (cfg
->speaker_outs
> 0 &&
3428 cfg
->line_out_type
== AUTO_PIN_HP_OUT
) {
3429 cfg
->hp_outs
= cfg
->line_outs
;
3430 memcpy(cfg
->hp_pins
, cfg
->line_out_pins
,
3431 sizeof(cfg
->hp_pins
));
3432 cfg
->line_outs
= cfg
->speaker_outs
;
3433 memcpy(cfg
->line_out_pins
, cfg
->speaker_pins
,
3434 sizeof(cfg
->speaker_pins
));
3435 cfg
->speaker_outs
= 0;
3436 memset(cfg
->speaker_pins
, 0, sizeof(cfg
->speaker_pins
));
3437 cfg
->line_out_type
= AUTO_PIN_SPEAKER_OUT
;
3438 fill_hardwired
= true;
3441 if (cfg
->hp_outs
> 0 &&
3442 cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
3443 cfg
->speaker_outs
= cfg
->line_outs
;
3444 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
3445 sizeof(cfg
->speaker_pins
));
3446 cfg
->line_outs
= cfg
->hp_outs
;
3447 memcpy(cfg
->line_out_pins
, cfg
->hp_pins
,
3448 sizeof(cfg
->hp_pins
));
3450 memset(cfg
->hp_pins
, 0, sizeof(cfg
->hp_pins
));
3451 cfg
->line_out_type
= AUTO_PIN_HP_OUT
;
3452 fill_hardwired
= true;
3460 fill_and_eval_dacs(codec
, best_wired
, best_mio
);
3462 debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n",
3463 cfg
->line_out_type
, best_wired
, best_mio
);
3464 debug_show_configs(spec
, cfg
);
3466 if (cfg
->line_out_pins
[0])
3468 alc_look_for_out_vol_nid(codec
, cfg
->line_out_pins
[0],
3469 spec
->multiout
.dac_nids
[0]);
3471 /* clear the bitmap flags for creating controls */
3472 clear_vol_marks(codec
);
3477 static int alc_auto_add_vol_ctl(struct hda_codec
*codec
,
3478 const char *pfx
, int cidx
,
3479 hda_nid_t nid
, unsigned int chs
)
3481 struct alc_spec
*spec
= codec
->spec
;
3485 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
);
3486 if (is_ctl_used(spec
->vol_ctls
, val
) && chs
!= 2) /* exclude LFE */
3488 mark_ctl_usage(spec
->vol_ctls
, val
);
3489 return __add_pb_vol_ctrl(codec
->spec
, ALC_CTL_WIDGET_VOL
, pfx
, cidx
,
3493 static int alc_auto_add_stereo_vol(struct hda_codec
*codec
,
3494 const char *pfx
, int cidx
,
3498 if (get_wcaps(codec
, nid
) & AC_WCAP_STEREO
)
3500 return alc_auto_add_vol_ctl(codec
, pfx
, cidx
, nid
, chs
);
3503 /* create a mute-switch for the given mixer widget;
3504 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
3506 static int alc_auto_add_sw_ctl(struct hda_codec
*codec
,
3507 const char *pfx
, int cidx
,
3508 hda_nid_t nid
, unsigned int chs
)
3510 struct alc_spec
*spec
= codec
->spec
;
3516 wid_type
= get_wcaps_type(get_wcaps(codec
, nid
));
3517 if (wid_type
== AC_WID_PIN
|| wid_type
== AC_WID_AUD_OUT
) {
3518 type
= ALC_CTL_WIDGET_MUTE
;
3519 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
);
3520 } else if (snd_hda_get_conn_list(codec
, nid
, NULL
) == 1) {
3521 type
= ALC_CTL_WIDGET_MUTE
;
3522 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_INPUT
);
3524 type
= ALC_CTL_BIND_MUTE
;
3525 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 2, HDA_INPUT
);
3527 if (is_ctl_used(spec
->sw_ctls
, val
) && chs
!= 2) /* exclude LFE */
3529 mark_ctl_usage(spec
->sw_ctls
, val
);
3530 return __add_pb_sw_ctrl(codec
->spec
, type
, pfx
, cidx
, val
);
3533 static int alc_auto_add_stereo_sw(struct hda_codec
*codec
, const char *pfx
,
3534 int cidx
, hda_nid_t nid
)
3537 if (get_wcaps(codec
, nid
) & AC_WCAP_STEREO
)
3539 return alc_auto_add_sw_ctl(codec
, pfx
, cidx
, nid
, chs
);
3542 static hda_nid_t
alc_look_for_out_mute_nid(struct hda_codec
*codec
,
3543 hda_nid_t pin
, hda_nid_t dac
)
3545 hda_nid_t mix
= alc_auto_dac_to_mix(codec
, pin
, dac
);
3546 if (nid_has_mute(codec
, pin
, HDA_OUTPUT
))
3548 else if (mix
&& nid_has_mute(codec
, mix
, HDA_INPUT
))
3550 else if (nid_has_mute(codec
, dac
, HDA_OUTPUT
))
3555 static hda_nid_t
alc_look_for_out_vol_nid(struct hda_codec
*codec
,
3556 hda_nid_t pin
, hda_nid_t dac
)
3558 hda_nid_t mix
= alc_auto_dac_to_mix(codec
, pin
, dac
);
3559 if (nid_has_volume(codec
, dac
, HDA_OUTPUT
))
3561 else if (nid_has_volume(codec
, mix
, HDA_OUTPUT
))
3563 else if (nid_has_volume(codec
, pin
, HDA_OUTPUT
))
3568 /* add playback controls from the parsed DAC table */
3569 static int alc_auto_create_multi_out_ctls(struct hda_codec
*codec
,
3570 const struct auto_pin_cfg
*cfg
)
3572 struct alc_spec
*spec
= codec
->spec
;
3573 int i
, err
, noutputs
;
3575 noutputs
= cfg
->line_outs
;
3576 if (spec
->multi_ios
> 0 && cfg
->line_outs
< 3)
3577 noutputs
+= spec
->multi_ios
;
3579 for (i
= 0; i
< noutputs
; i
++) {
3585 dac
= spec
->multiout
.dac_nids
[i
];
3588 if (i
>= cfg
->line_outs
) {
3589 pin
= spec
->multi_io
[i
- 1].pin
;
3591 name
= channel_name
[i
];
3593 pin
= cfg
->line_out_pins
[i
];
3594 name
= alc_get_line_out_pfx(spec
, i
, true, &index
);
3597 sw
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3598 vol
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3599 if (!name
|| !strcmp(name
, "CLFE")) {
3601 err
= alc_auto_add_vol_ctl(codec
, "Center", 0, vol
, 1);
3604 err
= alc_auto_add_vol_ctl(codec
, "LFE", 0, vol
, 2);
3607 err
= alc_auto_add_sw_ctl(codec
, "Center", 0, sw
, 1);
3610 err
= alc_auto_add_sw_ctl(codec
, "LFE", 0, sw
, 2);
3614 err
= alc_auto_add_stereo_vol(codec
, name
, index
, vol
);
3617 err
= alc_auto_add_stereo_sw(codec
, name
, index
, sw
);
3625 static int alc_auto_create_extra_out(struct hda_codec
*codec
, hda_nid_t pin
,
3626 hda_nid_t dac
, const char *pfx
,
3629 struct alc_spec
*spec
= codec
->spec
;
3635 /* the corresponding DAC is already occupied */
3636 if (!(get_wcaps(codec
, pin
) & AC_WCAP_OUT_AMP
))
3637 return 0; /* no way */
3638 /* create a switch only */
3639 val
= HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
);
3640 if (is_ctl_used(spec
->sw_ctls
, val
))
3641 return 0; /* already created */
3642 mark_ctl_usage(spec
->sw_ctls
, val
);
3643 return __add_pb_sw_ctrl(spec
, ALC_CTL_WIDGET_MUTE
, pfx
, cidx
, val
);
3646 sw
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3647 vol
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3648 err
= alc_auto_add_stereo_vol(codec
, pfx
, cidx
, vol
);
3651 err
= alc_auto_add_stereo_sw(codec
, pfx
, cidx
, sw
);
3657 static struct hda_bind_ctls
*new_bind_ctl(struct hda_codec
*codec
,
3659 struct hda_ctl_ops
*ops
)
3661 struct alc_spec
*spec
= codec
->spec
;
3662 struct hda_bind_ctls
**ctlp
, *ctl
;
3663 snd_array_init(&spec
->bind_ctls
, sizeof(ctl
), 8);
3664 ctlp
= snd_array_new(&spec
->bind_ctls
);
3667 ctl
= kzalloc(sizeof(*ctl
) + sizeof(long) * (nums
+ 1), GFP_KERNEL
);
3674 /* add playback controls for speaker and HP outputs */
3675 static int alc_auto_create_extra_outs(struct hda_codec
*codec
, int num_pins
,
3676 const hda_nid_t
*pins
,
3677 const hda_nid_t
*dacs
,
3680 struct alc_spec
*spec
= codec
->spec
;
3681 struct hda_bind_ctls
*ctl
;
3685 if (!num_pins
|| !pins
[0])
3688 if (num_pins
== 1) {
3689 hda_nid_t dac
= *dacs
;
3691 dac
= spec
->multiout
.dac_nids
[0];
3692 return alc_auto_create_extra_out(codec
, *pins
, dac
, pfx
, 0);
3695 for (i
= 0; i
< num_pins
; i
++) {
3697 if (dacs
[num_pins
- 1])
3698 dac
= dacs
[i
]; /* with individual volumes */
3701 if (num_pins
== 2 && i
== 1 && !strcmp(pfx
, "Speaker")) {
3702 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3704 } else if (num_pins
>= 3) {
3705 snprintf(name
, sizeof(name
), "%s %s",
3706 pfx
, channel_name
[i
]);
3707 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3710 err
= alc_auto_create_extra_out(codec
, pins
[i
], dac
,
3716 if (dacs
[num_pins
- 1])
3719 /* Let's create a bind-controls for volumes */
3720 ctl
= new_bind_ctl(codec
, num_pins
, &snd_hda_bind_vol
);
3724 for (i
= 0; i
< num_pins
; i
++) {
3726 if (!pins
[i
] || !dacs
[i
])
3728 vol
= alc_look_for_out_vol_nid(codec
, pins
[i
], dacs
[i
]);
3731 HDA_COMPOSE_AMP_VAL(vol
, 3, 0, HDA_OUTPUT
);
3734 snprintf(name
, sizeof(name
), "%s Playback Volume", pfx
);
3735 err
= add_control(spec
, ALC_CTL_BIND_VOL
, name
, 0, (long)ctl
);
3742 static int alc_auto_create_hp_out(struct hda_codec
*codec
)
3744 struct alc_spec
*spec
= codec
->spec
;
3745 return alc_auto_create_extra_outs(codec
, spec
->autocfg
.hp_outs
,
3746 spec
->autocfg
.hp_pins
,
3747 spec
->multiout
.hp_out_nid
,
3751 static int alc_auto_create_speaker_out(struct hda_codec
*codec
)
3753 struct alc_spec
*spec
= codec
->spec
;
3754 return alc_auto_create_extra_outs(codec
, spec
->autocfg
.speaker_outs
,
3755 spec
->autocfg
.speaker_pins
,
3756 spec
->multiout
.extra_out_nid
,
3760 static void alc_auto_set_output_and_unmute(struct hda_codec
*codec
,
3761 hda_nid_t pin
, int pin_type
,
3765 hda_nid_t nid
, mix
= 0;
3766 hda_nid_t srcs
[HDA_MAX_CONNECTIONS
];
3768 alc_set_pin_output(codec
, pin
, pin_type
);
3769 nid
= alc_go_down_to_selector(codec
, pin
);
3770 num
= snd_hda_get_connections(codec
, nid
, srcs
, ARRAY_SIZE(srcs
));
3771 for (i
= 0; i
< num
; i
++) {
3772 if (alc_auto_mix_to_dac(codec
, srcs
[i
]) != dac
)
3780 /* need the manual connection? */
3782 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_CONNECT_SEL
, i
);
3783 /* unmute mixer widget inputs */
3784 if (nid_has_mute(codec
, mix
, HDA_INPUT
)) {
3785 snd_hda_codec_write(codec
, mix
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3787 snd_hda_codec_write(codec
, mix
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3790 /* initialize volume */
3791 nid
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3793 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3796 /* unmute DAC if it's not assigned to a mixer */
3797 nid
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3798 if (nid
== mix
&& nid_has_mute(codec
, dac
, HDA_OUTPUT
))
3799 snd_hda_codec_write(codec
, dac
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3803 static void alc_auto_init_multi_out(struct hda_codec
*codec
)
3805 struct alc_spec
*spec
= codec
->spec
;
3806 int pin_type
= get_pin_type(spec
->autocfg
.line_out_type
);
3809 for (i
= 0; i
<= HDA_SIDE
; i
++) {
3810 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
3812 alc_auto_set_output_and_unmute(codec
, nid
, pin_type
,
3813 spec
->multiout
.dac_nids
[i
]);
3817 static void alc_auto_init_extra_out(struct hda_codec
*codec
)
3819 struct alc_spec
*spec
= codec
->spec
;
3823 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
3824 if (spec
->autocfg
.line_out_type
== AUTO_PIN_HP_OUT
)
3826 pin
= spec
->autocfg
.hp_pins
[i
];
3829 dac
= spec
->multiout
.hp_out_nid
[i
];
3831 if (i
> 0 && spec
->multiout
.hp_out_nid
[0])
3832 dac
= spec
->multiout
.hp_out_nid
[0];
3834 dac
= spec
->multiout
.dac_nids
[0];
3836 alc_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, dac
);
3838 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++) {
3839 if (spec
->autocfg
.line_out_type
== AUTO_PIN_SPEAKER_OUT
)
3841 pin
= spec
->autocfg
.speaker_pins
[i
];
3844 dac
= spec
->multiout
.extra_out_nid
[i
];
3846 if (i
> 0 && spec
->multiout
.extra_out_nid
[0])
3847 dac
= spec
->multiout
.extra_out_nid
[0];
3849 dac
= spec
->multiout
.dac_nids
[0];
3851 alc_auto_set_output_and_unmute(codec
, pin
, PIN_OUT
, dac
);
3855 /* check whether the given pin can be a multi-io pin */
3856 static bool can_be_multiio_pin(struct hda_codec
*codec
,
3857 unsigned int location
, hda_nid_t nid
)
3859 unsigned int defcfg
, caps
;
3861 defcfg
= snd_hda_codec_get_pincfg(codec
, nid
);
3862 if (get_defcfg_connect(defcfg
) != AC_JACK_PORT_COMPLEX
)
3864 if (location
&& get_defcfg_location(defcfg
) != location
)
3866 caps
= snd_hda_query_pin_caps(codec
, nid
);
3867 if (!(caps
& AC_PINCAP_OUT
))
3875 * When hardwired is set, try to fill ony hardwired pins, and returns
3876 * zero if any pins are filled, non-zero if nothing found.
3877 * When hardwired is off, try to fill possible input pins, and returns
3878 * the badness value.
3880 static int alc_auto_fill_multi_ios(struct hda_codec
*codec
,
3881 hda_nid_t reference_pin
,
3882 bool hardwired
, int offset
)
3884 struct alc_spec
*spec
= codec
->spec
;
3885 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3886 int type
, i
, j
, dacs
, num_pins
, old_pins
;
3887 unsigned int defcfg
= snd_hda_codec_get_pincfg(codec
, reference_pin
);
3888 unsigned int location
= get_defcfg_location(defcfg
);
3891 old_pins
= spec
->multi_ios
;
3896 for (type
= AUTO_PIN_LINE_IN
; type
>= AUTO_PIN_MIC
; type
--) {
3897 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3898 if (cfg
->inputs
[i
].type
!= type
)
3900 if (can_be_multiio_pin(codec
, location
,
3901 cfg
->inputs
[i
].pin
))
3908 dacs
= spec
->multiout
.num_dacs
;
3909 for (type
= AUTO_PIN_LINE_IN
; type
>= AUTO_PIN_MIC
; type
--) {
3910 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3911 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
3914 if (cfg
->inputs
[i
].type
!= type
)
3916 if (!can_be_multiio_pin(codec
, location
, nid
))
3918 for (j
= 0; j
< spec
->multi_ios
; j
++) {
3919 if (nid
== spec
->multi_io
[j
].pin
)
3922 if (j
< spec
->multi_ios
)
3925 if (offset
&& offset
+ spec
->multi_ios
< dacs
) {
3926 dac
= spec
->private_dac_nids
[offset
+ spec
->multi_ios
];
3927 if (!alc_auto_is_dac_reachable(codec
, nid
, dac
))
3931 dac
= get_dac_if_single(codec
, nid
);
3933 dac
= alc_auto_look_for_dac(codec
, nid
);
3938 spec
->multi_io
[spec
->multi_ios
].pin
= nid
;
3939 spec
->multi_io
[spec
->multi_ios
].dac
= dac
;
3941 if (spec
->multi_ios
>= 2)
3947 badness
= BAD_MULTI_IO
;
3948 if (old_pins
== spec
->multi_ios
) {
3950 return 1; /* nothing found */
3952 return badness
; /* no badness if nothing found */
3954 if (!hardwired
&& spec
->multi_ios
< 2) {
3955 spec
->multi_ios
= old_pins
;
3962 static int alc_auto_ch_mode_info(struct snd_kcontrol
*kcontrol
,
3963 struct snd_ctl_elem_info
*uinfo
)
3965 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3966 struct alc_spec
*spec
= codec
->spec
;
3968 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
3970 uinfo
->value
.enumerated
.items
= spec
->multi_ios
+ 1;
3971 if (uinfo
->value
.enumerated
.item
> spec
->multi_ios
)
3972 uinfo
->value
.enumerated
.item
= spec
->multi_ios
;
3973 sprintf(uinfo
->value
.enumerated
.name
, "%dch",
3974 (uinfo
->value
.enumerated
.item
+ 1) * 2);
3978 static int alc_auto_ch_mode_get(struct snd_kcontrol
*kcontrol
,
3979 struct snd_ctl_elem_value
*ucontrol
)
3981 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3982 struct alc_spec
*spec
= codec
->spec
;
3983 ucontrol
->value
.enumerated
.item
[0] = (spec
->ext_channel_count
- 1) / 2;
3987 static int alc_set_multi_io(struct hda_codec
*codec
, int idx
, bool output
)
3989 struct alc_spec
*spec
= codec
->spec
;
3990 hda_nid_t nid
= spec
->multi_io
[idx
].pin
;
3992 if (!spec
->multi_io
[idx
].ctl_in
)
3993 spec
->multi_io
[idx
].ctl_in
=
3994 snd_hda_codec_read(codec
, nid
, 0,
3995 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
3997 snd_hda_codec_update_cache(codec
, nid
, 0,
3998 AC_VERB_SET_PIN_WIDGET_CONTROL
,
4000 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
4001 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
4003 alc_auto_select_dac(codec
, nid
, spec
->multi_io
[idx
].dac
);
4005 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
4006 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
4007 HDA_AMP_MUTE
, HDA_AMP_MUTE
);
4008 snd_hda_codec_update_cache(codec
, nid
, 0,
4009 AC_VERB_SET_PIN_WIDGET_CONTROL
,
4010 spec
->multi_io
[idx
].ctl_in
);
4015 static int alc_auto_ch_mode_put(struct snd_kcontrol
*kcontrol
,
4016 struct snd_ctl_elem_value
*ucontrol
)
4018 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
4019 struct alc_spec
*spec
= codec
->spec
;
4022 ch
= ucontrol
->value
.enumerated
.item
[0];
4023 if (ch
< 0 || ch
> spec
->multi_ios
)
4025 if (ch
== (spec
->ext_channel_count
- 1) / 2)
4027 spec
->ext_channel_count
= (ch
+ 1) * 2;
4028 for (i
= 0; i
< spec
->multi_ios
; i
++)
4029 alc_set_multi_io(codec
, i
, i
< ch
);
4030 spec
->multiout
.max_channels
= spec
->ext_channel_count
;
4031 if (spec
->need_dac_fix
&& !spec
->const_channel_count
)
4032 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
4036 static const struct snd_kcontrol_new alc_auto_channel_mode_enum
= {
4037 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4038 .name
= "Channel Mode",
4039 .info
= alc_auto_ch_mode_info
,
4040 .get
= alc_auto_ch_mode_get
,
4041 .put
= alc_auto_ch_mode_put
,
4044 static int alc_auto_add_multi_channel_mode(struct hda_codec
*codec
)
4046 struct alc_spec
*spec
= codec
->spec
;
4048 if (spec
->multi_ios
> 0) {
4049 struct snd_kcontrol_new
*knew
;
4051 knew
= alc_kcontrol_new(spec
);
4054 *knew
= alc_auto_channel_mode_enum
;
4055 knew
->name
= kstrdup("Channel Mode", GFP_KERNEL
);
4062 /* filter out invalid adc_nids (and capsrc_nids) that don't give all
4065 static void alc_remove_invalid_adc_nids(struct hda_codec
*codec
)
4067 struct alc_spec
*spec
= codec
->spec
;
4068 const struct hda_input_mux
*imux
;
4069 hda_nid_t adc_nids
[ARRAY_SIZE(spec
->private_adc_nids
)];
4070 hda_nid_t capsrc_nids
[ARRAY_SIZE(spec
->private_adc_nids
)];
4073 imux
= spec
->input_mux
;
4076 if (spec
->dyn_adc_switch
)
4080 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
4081 hda_nid_t cap
= spec
->private_capsrc_nids
[n
];
4082 int num_conns
= snd_hda_get_conn_list(codec
, cap
, NULL
);
4083 for (i
= 0; i
< imux
->num_items
; i
++) {
4084 hda_nid_t pin
= spec
->imux_pins
[i
];
4086 if (get_connection_index(codec
, cap
, pin
) < 0)
4088 } else if (num_conns
<= imux
->items
[i
].index
)
4091 if (i
>= imux
->num_items
) {
4092 adc_nids
[nums
] = spec
->private_adc_nids
[n
];
4093 capsrc_nids
[nums
++] = cap
;
4097 /* check whether ADC-switch is possible */
4098 if (!alc_check_dyn_adc_switch(codec
)) {
4099 printk(KERN_WARNING
"hda_codec: %s: no valid ADC found;"
4100 " using fallback 0x%x\n",
4101 codec
->chip_name
, spec
->private_adc_nids
[0]);
4102 spec
->num_adc_nids
= 1;
4106 } else if (nums
!= spec
->num_adc_nids
) {
4107 memcpy(spec
->private_adc_nids
, adc_nids
,
4108 nums
* sizeof(hda_nid_t
));
4109 memcpy(spec
->private_capsrc_nids
, capsrc_nids
,
4110 nums
* sizeof(hda_nid_t
));
4111 spec
->num_adc_nids
= nums
;
4115 alc_auto_mic_check_imux(codec
); /* check auto-mic setups */
4116 else if (spec
->input_mux
->num_items
== 1)
4117 spec
->num_adc_nids
= 1; /* reduce to a single ADC */
4121 * initialize ADC paths
4123 static void alc_auto_init_adc(struct hda_codec
*codec
, int adc_idx
)
4125 struct alc_spec
*spec
= codec
->spec
;
4128 nid
= spec
->adc_nids
[adc_idx
];
4130 if (nid_has_mute(codec
, nid
, HDA_INPUT
)) {
4131 snd_hda_codec_write(codec
, nid
, 0,
4132 AC_VERB_SET_AMP_GAIN_MUTE
,
4136 if (!spec
->capsrc_nids
)
4138 nid
= spec
->capsrc_nids
[adc_idx
];
4139 if (nid_has_mute(codec
, nid
, HDA_OUTPUT
))
4140 snd_hda_codec_write(codec
, nid
, 0,
4141 AC_VERB_SET_AMP_GAIN_MUTE
,
4145 static void alc_auto_init_input_src(struct hda_codec
*codec
)
4147 struct alc_spec
*spec
= codec
->spec
;
4150 for (c
= 0; c
< spec
->num_adc_nids
; c
++)
4151 alc_auto_init_adc(codec
, c
);
4152 if (spec
->dyn_adc_switch
)
4155 nums
= spec
->num_adc_nids
;
4156 for (c
= 0; c
< nums
; c
++)
4157 alc_mux_select(codec
, c
, spec
->cur_mux
[c
], true);
4160 /* add mic boosts if needed */
4161 static int alc_auto_add_mic_boost(struct hda_codec
*codec
)
4163 struct alc_spec
*spec
= codec
->spec
;
4164 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4168 const char *prev_label
= NULL
;
4170 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
4171 if (cfg
->inputs
[i
].type
> AUTO_PIN_MIC
)
4173 nid
= cfg
->inputs
[i
].pin
;
4174 if (get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
) {
4176 char boost_label
[32];
4178 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
4179 if (spec
->shared_mic_hp
&& !strcmp(label
, "Misc"))
4180 label
= "Headphone Mic";
4181 if (prev_label
&& !strcmp(label
, prev_label
))
4187 snprintf(boost_label
, sizeof(boost_label
),
4188 "%s Boost Volume", label
);
4189 err
= add_control(spec
, ALC_CTL_WIDGET_VOL
,
4190 boost_label
, type_idx
,
4191 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_INPUT
));
4199 /* select or unmute the given capsrc route */
4200 static void select_or_unmute_capsrc(struct hda_codec
*codec
, hda_nid_t cap
,
4203 if (get_wcaps_type(get_wcaps(codec
, cap
)) == AC_WID_AUD_MIX
) {
4204 snd_hda_codec_amp_stereo(codec
, cap
, HDA_INPUT
, idx
,
4206 } else if (snd_hda_get_conn_list(codec
, cap
, NULL
) > 1) {
4207 snd_hda_codec_write_cache(codec
, cap
, 0,
4208 AC_VERB_SET_CONNECT_SEL
, idx
);
4212 /* set the default connection to that pin */
4213 static int init_capsrc_for_pin(struct hda_codec
*codec
, hda_nid_t pin
)
4215 struct alc_spec
*spec
= codec
->spec
;
4220 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
4221 hda_nid_t cap
= get_capsrc(spec
, i
);
4224 idx
= get_connection_index(codec
, cap
, pin
);
4227 select_or_unmute_capsrc(codec
, cap
, idx
);
4228 return i
; /* return the found index */
4230 return -1; /* not found */
4233 /* initialize some special cases for input sources */
4234 static void alc_init_special_input_src(struct hda_codec
*codec
)
4236 struct alc_spec
*spec
= codec
->spec
;
4239 for (i
= 0; i
< spec
->autocfg
.num_inputs
; i
++)
4240 init_capsrc_for_pin(codec
, spec
->autocfg
.inputs
[i
].pin
);
4243 /* assign appropriate capture mixers */
4244 static void set_capture_mixer(struct hda_codec
*codec
)
4246 struct alc_spec
*spec
= codec
->spec
;
4247 static const struct snd_kcontrol_new
*caps
[2][3] = {
4248 { alc_capture_mixer_nosrc1
,
4249 alc_capture_mixer_nosrc2
,
4250 alc_capture_mixer_nosrc3
},
4251 { alc_capture_mixer1
,
4253 alc_capture_mixer3
},
4256 /* check whether either of ADC or MUX has a volume control */
4257 if (!nid_has_volume(codec
, spec
->adc_nids
[0], HDA_INPUT
)) {
4258 if (!spec
->capsrc_nids
)
4259 return; /* no volume */
4260 if (!nid_has_volume(codec
, spec
->capsrc_nids
[0], HDA_OUTPUT
))
4261 return; /* no volume in capsrc, too */
4262 spec
->vol_in_capsrc
= 1;
4265 if (spec
->num_adc_nids
> 0) {
4269 if (spec
->input_mux
&& spec
->input_mux
->num_items
> 1)
4271 if (spec
->auto_mic
) {
4274 } else if (spec
->dyn_adc_switch
)
4277 if (spec
->num_adc_nids
> 3)
4278 spec
->num_adc_nids
= 3;
4279 else if (!spec
->num_adc_nids
)
4281 num_adcs
= spec
->num_adc_nids
;
4283 spec
->cap_mixer
= caps
[mux
][num_adcs
- 1];
4288 * standard auto-parser initializations
4290 static void alc_auto_init_std(struct hda_codec
*codec
)
4292 struct alc_spec
*spec
= codec
->spec
;
4293 alc_auto_init_multi_out(codec
);
4294 alc_auto_init_extra_out(codec
);
4295 alc_auto_init_analog_input(codec
);
4296 alc_auto_init_input_src(codec
);
4297 alc_auto_init_digital(codec
);
4298 if (spec
->unsol_event
)
4299 alc_inithook(codec
);
4303 * Digital-beep handlers
4305 #ifdef CONFIG_SND_HDA_INPUT_BEEP
4306 #define set_beep_amp(spec, nid, idx, dir) \
4307 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4309 static const struct snd_pci_quirk beep_white_list
[] = {
4310 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
4311 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
4312 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
4313 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
4314 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
4315 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
4319 static inline int has_cdefine_beep(struct hda_codec
*codec
)
4321 struct alc_spec
*spec
= codec
->spec
;
4322 const struct snd_pci_quirk
*q
;
4323 q
= snd_pci_quirk_lookup(codec
->bus
->pci
, beep_white_list
);
4326 return spec
->cdefine
.enable_pcbeep
;
4329 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
4330 #define has_cdefine_beep(codec) 0
4333 /* parse the BIOS configuration and set up the alc_spec */
4334 /* return 1 if successful, 0 if the proper config is not found,
4335 * or a negative error code
4337 static int alc_parse_auto_config(struct hda_codec
*codec
,
4338 const hda_nid_t
*ignore_nids
,
4339 const hda_nid_t
*ssid_nids
)
4341 struct alc_spec
*spec
= codec
->spec
;
4342 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4345 err
= snd_hda_parse_pin_defcfg(codec
, cfg
, ignore_nids
,
4349 if (!cfg
->line_outs
) {
4350 if (cfg
->dig_outs
|| cfg
->dig_in_pin
) {
4351 spec
->multiout
.max_channels
= 2;
4352 spec
->no_analog
= 1;
4355 return 0; /* can't find valid BIOS pin config */
4358 if (cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
&&
4359 cfg
->line_outs
<= cfg
->hp_outs
) {
4360 /* use HP as primary out */
4361 cfg
->speaker_outs
= cfg
->line_outs
;
4362 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
4363 sizeof(cfg
->speaker_pins
));
4364 cfg
->line_outs
= cfg
->hp_outs
;
4365 memcpy(cfg
->line_out_pins
, cfg
->hp_pins
, sizeof(cfg
->hp_pins
));
4367 memset(cfg
->hp_pins
, 0, sizeof(cfg
->hp_pins
));
4368 cfg
->line_out_type
= AUTO_PIN_HP_OUT
;
4371 err
= alc_auto_fill_dac_nids(codec
);
4374 err
= alc_auto_add_multi_channel_mode(codec
);
4377 err
= alc_auto_create_multi_out_ctls(codec
, cfg
);
4380 err
= alc_auto_create_hp_out(codec
);
4383 err
= alc_auto_create_speaker_out(codec
);
4386 err
= alc_auto_create_shared_input(codec
);
4389 err
= alc_auto_create_input_ctls(codec
);
4393 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
4396 alc_auto_parse_digital(codec
);
4398 if (!spec
->no_analog
)
4399 alc_remove_invalid_adc_nids(codec
);
4402 alc_ssid_check(codec
, ssid_nids
);
4404 if (!spec
->no_analog
) {
4405 alc_auto_check_switches(codec
);
4406 err
= alc_auto_add_mic_boost(codec
);
4411 if (spec
->kctls
.list
)
4412 add_mixer(spec
, spec
->kctls
.list
);
4414 if (!spec
->no_analog
&& !spec
->cap_mixer
)
4415 set_capture_mixer(codec
);
4420 static int alc880_parse_auto_config(struct hda_codec
*codec
)
4422 static const hda_nid_t alc880_ignore
[] = { 0x1d, 0 };
4423 static const hda_nid_t alc880_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
4424 return alc_parse_auto_config(codec
, alc880_ignore
, alc880_ssids
);
4433 ALC880_FIXUP_MEDION_RIM
,
4436 ALC880_FIXUP_EAPD_COEF
,
4437 ALC880_FIXUP_TCL_S700
,
4438 ALC880_FIXUP_VOL_KNOB
,
4439 ALC880_FIXUP_FUJITSU
,
4441 ALC880_FIXUP_UNIWILL
,
4442 ALC880_FIXUP_UNIWILL_DIG
,
4444 ALC880_FIXUP_3ST_BASE
,
4446 ALC880_FIXUP_3ST_DIG
,
4447 ALC880_FIXUP_5ST_BASE
,
4449 ALC880_FIXUP_5ST_DIG
,
4450 ALC880_FIXUP_6ST_BASE
,
4452 ALC880_FIXUP_6ST_DIG
,
4455 /* enable the volume-knob widget support on NID 0x21 */
4456 static void alc880_fixup_vol_knob(struct hda_codec
*codec
,
4457 const struct alc_fixup
*fix
, int action
)
4459 if (action
== ALC_FIXUP_ACT_PROBE
)
4460 snd_hda_jack_detect_enable(codec
, 0x21, ALC_DCVOL_EVENT
);
4463 static const struct alc_fixup alc880_fixups
[] = {
4464 [ALC880_FIXUP_GPIO1
] = {
4465 .type
= ALC_FIXUP_VERBS
,
4466 .v
.verbs
= alc_gpio1_init_verbs
,
4468 [ALC880_FIXUP_GPIO2
] = {
4469 .type
= ALC_FIXUP_VERBS
,
4470 .v
.verbs
= alc_gpio2_init_verbs
,
4472 [ALC880_FIXUP_MEDION_RIM
] = {
4473 .type
= ALC_FIXUP_VERBS
,
4474 .v
.verbs
= (const struct hda_verb
[]) {
4475 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4476 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
4480 .chain_id
= ALC880_FIXUP_GPIO2
,
4482 [ALC880_FIXUP_LG
] = {
4483 .type
= ALC_FIXUP_PINS
,
4484 .v
.pins
= (const struct alc_pincfg
[]) {
4485 /* disable bogus unused pins */
4486 { 0x16, 0x411111f0 },
4487 { 0x18, 0x411111f0 },
4488 { 0x1a, 0x411111f0 },
4492 [ALC880_FIXUP_W810
] = {
4493 .type
= ALC_FIXUP_PINS
,
4494 .v
.pins
= (const struct alc_pincfg
[]) {
4495 /* disable bogus unused pins */
4496 { 0x17, 0x411111f0 },
4500 .chain_id
= ALC880_FIXUP_GPIO2
,
4502 [ALC880_FIXUP_EAPD_COEF
] = {
4503 .type
= ALC_FIXUP_VERBS
,
4504 .v
.verbs
= (const struct hda_verb
[]) {
4505 /* change to EAPD mode */
4506 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4507 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
4511 [ALC880_FIXUP_TCL_S700
] = {
4512 .type
= ALC_FIXUP_VERBS
,
4513 .v
.verbs
= (const struct hda_verb
[]) {
4514 /* change to EAPD mode */
4515 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4516 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
4520 .chain_id
= ALC880_FIXUP_GPIO2
,
4522 [ALC880_FIXUP_VOL_KNOB
] = {
4523 .type
= ALC_FIXUP_FUNC
,
4524 .v
.func
= alc880_fixup_vol_knob
,
4526 [ALC880_FIXUP_FUJITSU
] = {
4527 /* override all pins as BIOS on old Amilo is broken */
4528 .type
= ALC_FIXUP_PINS
,
4529 .v
.pins
= (const struct alc_pincfg
[]) {
4530 { 0x14, 0x0121411f }, /* HP */
4531 { 0x15, 0x99030120 }, /* speaker */
4532 { 0x16, 0x99030130 }, /* bass speaker */
4533 { 0x17, 0x411111f0 }, /* N/A */
4534 { 0x18, 0x411111f0 }, /* N/A */
4535 { 0x19, 0x01a19950 }, /* mic-in */
4536 { 0x1a, 0x411111f0 }, /* N/A */
4537 { 0x1b, 0x411111f0 }, /* N/A */
4538 { 0x1c, 0x411111f0 }, /* N/A */
4539 { 0x1d, 0x411111f0 }, /* N/A */
4540 { 0x1e, 0x01454140 }, /* SPDIF out */
4544 .chain_id
= ALC880_FIXUP_VOL_KNOB
,
4546 [ALC880_FIXUP_F1734
] = {
4547 /* almost compatible with FUJITSU, but no bass and SPDIF */
4548 .type
= ALC_FIXUP_PINS
,
4549 .v
.pins
= (const struct alc_pincfg
[]) {
4550 { 0x14, 0x0121411f }, /* HP */
4551 { 0x15, 0x99030120 }, /* speaker */
4552 { 0x16, 0x411111f0 }, /* N/A */
4553 { 0x17, 0x411111f0 }, /* N/A */
4554 { 0x18, 0x411111f0 }, /* N/A */
4555 { 0x19, 0x01a19950 }, /* mic-in */
4556 { 0x1a, 0x411111f0 }, /* N/A */
4557 { 0x1b, 0x411111f0 }, /* N/A */
4558 { 0x1c, 0x411111f0 }, /* N/A */
4559 { 0x1d, 0x411111f0 }, /* N/A */
4560 { 0x1e, 0x411111f0 }, /* N/A */
4564 .chain_id
= ALC880_FIXUP_VOL_KNOB
,
4566 [ALC880_FIXUP_UNIWILL
] = {
4567 /* need to fix HP and speaker pins to be parsed correctly */
4568 .type
= ALC_FIXUP_PINS
,
4569 .v
.pins
= (const struct alc_pincfg
[]) {
4570 { 0x14, 0x0121411f }, /* HP */
4571 { 0x15, 0x99030120 }, /* speaker */
4572 { 0x16, 0x99030130 }, /* bass speaker */
4576 [ALC880_FIXUP_UNIWILL_DIG
] = {
4577 .type
= ALC_FIXUP_PINS
,
4578 .v
.pins
= (const struct alc_pincfg
[]) {
4579 /* disable bogus unused pins */
4580 { 0x17, 0x411111f0 },
4581 { 0x19, 0x411111f0 },
4582 { 0x1b, 0x411111f0 },
4583 { 0x1f, 0x411111f0 },
4587 [ALC880_FIXUP_Z71V
] = {
4588 .type
= ALC_FIXUP_PINS
,
4589 .v
.pins
= (const struct alc_pincfg
[]) {
4590 /* set up the whole pins as BIOS is utterly broken */
4591 { 0x14, 0x99030120 }, /* speaker */
4592 { 0x15, 0x0121411f }, /* HP */
4593 { 0x16, 0x411111f0 }, /* N/A */
4594 { 0x17, 0x411111f0 }, /* N/A */
4595 { 0x18, 0x01a19950 }, /* mic-in */
4596 { 0x19, 0x411111f0 }, /* N/A */
4597 { 0x1a, 0x01813031 }, /* line-in */
4598 { 0x1b, 0x411111f0 }, /* N/A */
4599 { 0x1c, 0x411111f0 }, /* N/A */
4600 { 0x1d, 0x411111f0 }, /* N/A */
4601 { 0x1e, 0x0144111e }, /* SPDIF */
4605 [ALC880_FIXUP_3ST_BASE
] = {
4606 .type
= ALC_FIXUP_PINS
,
4607 .v
.pins
= (const struct alc_pincfg
[]) {
4608 { 0x14, 0x01014010 }, /* line-out */
4609 { 0x15, 0x411111f0 }, /* N/A */
4610 { 0x16, 0x411111f0 }, /* N/A */
4611 { 0x17, 0x411111f0 }, /* N/A */
4612 { 0x18, 0x01a19c30 }, /* mic-in */
4613 { 0x19, 0x0121411f }, /* HP */
4614 { 0x1a, 0x01813031 }, /* line-in */
4615 { 0x1b, 0x02a19c40 }, /* front-mic */
4616 { 0x1c, 0x411111f0 }, /* N/A */
4617 { 0x1d, 0x411111f0 }, /* N/A */
4618 /* 0x1e is filled in below */
4619 { 0x1f, 0x411111f0 }, /* N/A */
4623 [ALC880_FIXUP_3ST
] = {
4624 .type
= ALC_FIXUP_PINS
,
4625 .v
.pins
= (const struct alc_pincfg
[]) {
4626 { 0x1e, 0x411111f0 }, /* N/A */
4630 .chain_id
= ALC880_FIXUP_3ST_BASE
,
4632 [ALC880_FIXUP_3ST_DIG
] = {
4633 .type
= ALC_FIXUP_PINS
,
4634 .v
.pins
= (const struct alc_pincfg
[]) {
4635 { 0x1e, 0x0144111e }, /* SPDIF */
4639 .chain_id
= ALC880_FIXUP_3ST_BASE
,
4641 [ALC880_FIXUP_5ST_BASE
] = {
4642 .type
= ALC_FIXUP_PINS
,
4643 .v
.pins
= (const struct alc_pincfg
[]) {
4644 { 0x14, 0x01014010 }, /* front */
4645 { 0x15, 0x411111f0 }, /* N/A */
4646 { 0x16, 0x01011411 }, /* CLFE */
4647 { 0x17, 0x01016412 }, /* surr */
4648 { 0x18, 0x01a19c30 }, /* mic-in */
4649 { 0x19, 0x0121411f }, /* HP */
4650 { 0x1a, 0x01813031 }, /* line-in */
4651 { 0x1b, 0x02a19c40 }, /* front-mic */
4652 { 0x1c, 0x411111f0 }, /* N/A */
4653 { 0x1d, 0x411111f0 }, /* N/A */
4654 /* 0x1e is filled in below */
4655 { 0x1f, 0x411111f0 }, /* N/A */
4659 [ALC880_FIXUP_5ST
] = {
4660 .type
= ALC_FIXUP_PINS
,
4661 .v
.pins
= (const struct alc_pincfg
[]) {
4662 { 0x1e, 0x411111f0 }, /* N/A */
4666 .chain_id
= ALC880_FIXUP_5ST_BASE
,
4668 [ALC880_FIXUP_5ST_DIG
] = {
4669 .type
= ALC_FIXUP_PINS
,
4670 .v
.pins
= (const struct alc_pincfg
[]) {
4671 { 0x1e, 0x0144111e }, /* SPDIF */
4675 .chain_id
= ALC880_FIXUP_5ST_BASE
,
4677 [ALC880_FIXUP_6ST_BASE
] = {
4678 .type
= ALC_FIXUP_PINS
,
4679 .v
.pins
= (const struct alc_pincfg
[]) {
4680 { 0x14, 0x01014010 }, /* front */
4681 { 0x15, 0x01016412 }, /* surr */
4682 { 0x16, 0x01011411 }, /* CLFE */
4683 { 0x17, 0x01012414 }, /* side */
4684 { 0x18, 0x01a19c30 }, /* mic-in */
4685 { 0x19, 0x02a19c40 }, /* front-mic */
4686 { 0x1a, 0x01813031 }, /* line-in */
4687 { 0x1b, 0x0121411f }, /* HP */
4688 { 0x1c, 0x411111f0 }, /* N/A */
4689 { 0x1d, 0x411111f0 }, /* N/A */
4690 /* 0x1e is filled in below */
4691 { 0x1f, 0x411111f0 }, /* N/A */
4695 [ALC880_FIXUP_6ST
] = {
4696 .type
= ALC_FIXUP_PINS
,
4697 .v
.pins
= (const struct alc_pincfg
[]) {
4698 { 0x1e, 0x411111f0 }, /* N/A */
4702 .chain_id
= ALC880_FIXUP_6ST_BASE
,
4704 [ALC880_FIXUP_6ST_DIG
] = {
4705 .type
= ALC_FIXUP_PINS
,
4706 .v
.pins
= (const struct alc_pincfg
[]) {
4707 { 0x1e, 0x0144111e }, /* SPDIF */
4711 .chain_id
= ALC880_FIXUP_6ST_BASE
,
4715 static const struct snd_pci_quirk alc880_fixup_tbl
[] = {
4716 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810
),
4717 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V
),
4718 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1
),
4719 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2
),
4720 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF
),
4721 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG
),
4722 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734
),
4723 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL
),
4724 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB
),
4725 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810
),
4726 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM
),
4727 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734
),
4728 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU
),
4729 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734
),
4730 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU
),
4731 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG
),
4732 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG
),
4733 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG
),
4734 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700
),
4736 /* Below is the copied entries from alc880_quirks.c.
4737 * It's not quite sure whether BIOS sets the correct pin-config table
4738 * on these machines, thus they are kept to be compatible with
4739 * the old static quirks. Once when it's confirmed to work without
4740 * these overrides, it'd be better to remove.
4742 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG
),
4743 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST
),
4744 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG
),
4745 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG
),
4746 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG
),
4747 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG
),
4748 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG
),
4749 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST
),
4750 SND_PCI_QUIRK(0x1039, 0x1234, NULL
, ALC880_FIXUP_6ST_DIG
),
4751 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST
),
4752 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST
),
4753 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST
),
4754 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST
),
4755 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST
),
4756 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG
),
4757 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG
),
4758 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG
),
4759 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG
),
4760 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG
),
4761 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG
),
4762 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG
),
4763 SND_PCI_QUIRK(0x2668, 0x8086, NULL
, ALC880_FIXUP_6ST_DIG
), /* broken BIOS */
4764 SND_PCI_QUIRK(0x8086, 0x2668, NULL
, ALC880_FIXUP_6ST_DIG
),
4765 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4766 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4767 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4768 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4769 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4770 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4771 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG
),
4772 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4773 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4774 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG
),
4776 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST
),
4777 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG
),
4778 SND_PCI_QUIRK(0xe803, 0x1019, NULL
, ALC880_FIXUP_6ST_DIG
),
4782 static const struct alc_model_fixup alc880_fixup_models
[] = {
4783 {.id
= ALC880_FIXUP_3ST
, .name
= "3stack"},
4784 {.id
= ALC880_FIXUP_3ST_DIG
, .name
= "3stack-digout"},
4785 {.id
= ALC880_FIXUP_5ST
, .name
= "5stack"},
4786 {.id
= ALC880_FIXUP_5ST_DIG
, .name
= "5stack-digout"},
4787 {.id
= ALC880_FIXUP_6ST
, .name
= "6stack"},
4788 {.id
= ALC880_FIXUP_6ST_DIG
, .name
= "6stack-digout"},
4794 * OK, here we have finally the patch for ALC880
4796 static int patch_alc880(struct hda_codec
*codec
)
4798 struct alc_spec
*spec
;
4801 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4807 spec
->mixer_nid
= 0x0b;
4808 spec
->need_dac_fix
= 1;
4810 alc_pick_fixup(codec
, alc880_fixup_models
, alc880_fixup_tbl
,
4812 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
4814 /* automatic parse from the BIOS config */
4815 err
= alc880_parse_auto_config(codec
);
4819 if (!spec
->no_analog
) {
4820 err
= snd_hda_attach_beep_device(codec
, 0x1);
4823 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
4826 codec
->patch_ops
= alc_patch_ops
;
4828 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
4841 static int alc260_parse_auto_config(struct hda_codec
*codec
)
4843 static const hda_nid_t alc260_ignore
[] = { 0x17, 0 };
4844 static const hda_nid_t alc260_ssids
[] = { 0x10, 0x15, 0x0f, 0 };
4845 return alc_parse_auto_config(codec
, alc260_ignore
, alc260_ssids
);
4852 ALC260_FIXUP_HP_DC5750
,
4853 ALC260_FIXUP_HP_PIN_0F
,
4856 ALC260_FIXUP_GPIO1_TOGGLE
,
4857 ALC260_FIXUP_REPLACER
,
4858 ALC260_FIXUP_HP_B1900
,
4861 static void alc260_gpio1_automute(struct hda_codec
*codec
)
4863 struct alc_spec
*spec
= codec
->spec
;
4864 snd_hda_codec_write(codec
, 0x01, 0, AC_VERB_SET_GPIO_DATA
,
4865 spec
->hp_jack_present
);
4868 static void alc260_fixup_gpio1_toggle(struct hda_codec
*codec
,
4869 const struct alc_fixup
*fix
, int action
)
4871 struct alc_spec
*spec
= codec
->spec
;
4872 if (action
== ALC_FIXUP_ACT_PROBE
) {
4873 /* although the machine has only one output pin, we need to
4874 * toggle GPIO1 according to the jack state
4876 spec
->automute_hook
= alc260_gpio1_automute
;
4877 spec
->detect_hp
= 1;
4878 spec
->automute_speaker
= 1;
4879 spec
->autocfg
.hp_pins
[0] = 0x0f; /* copy it for automute */
4880 snd_hda_jack_detect_enable(codec
, 0x0f, ALC_HP_EVENT
);
4881 spec
->unsol_event
= alc_sku_unsol_event
;
4882 add_verb(codec
->spec
, alc_gpio1_init_verbs
);
4886 static const struct alc_fixup alc260_fixups
[] = {
4887 [ALC260_FIXUP_HP_DC5750
] = {
4888 .type
= ALC_FIXUP_PINS
,
4889 .v
.pins
= (const struct alc_pincfg
[]) {
4890 { 0x11, 0x90130110 }, /* speaker */
4894 [ALC260_FIXUP_HP_PIN_0F
] = {
4895 .type
= ALC_FIXUP_PINS
,
4896 .v
.pins
= (const struct alc_pincfg
[]) {
4897 { 0x0f, 0x01214000 }, /* HP */
4901 [ALC260_FIXUP_COEF
] = {
4902 .type
= ALC_FIXUP_VERBS
,
4903 .v
.verbs
= (const struct hda_verb
[]) {
4904 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4905 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3040 },
4909 .chain_id
= ALC260_FIXUP_HP_PIN_0F
,
4911 [ALC260_FIXUP_GPIO1
] = {
4912 .type
= ALC_FIXUP_VERBS
,
4913 .v
.verbs
= alc_gpio1_init_verbs
,
4915 [ALC260_FIXUP_GPIO1_TOGGLE
] = {
4916 .type
= ALC_FIXUP_FUNC
,
4917 .v
.func
= alc260_fixup_gpio1_toggle
,
4919 .chain_id
= ALC260_FIXUP_HP_PIN_0F
,
4921 [ALC260_FIXUP_REPLACER
] = {
4922 .type
= ALC_FIXUP_VERBS
,
4923 .v
.verbs
= (const struct hda_verb
[]) {
4924 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4925 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
4929 .chain_id
= ALC260_FIXUP_GPIO1_TOGGLE
,
4931 [ALC260_FIXUP_HP_B1900
] = {
4932 .type
= ALC_FIXUP_FUNC
,
4933 .v
.func
= alc260_fixup_gpio1_toggle
,
4935 .chain_id
= ALC260_FIXUP_COEF
,
4939 static const struct snd_pci_quirk alc260_fixup_tbl
[] = {
4940 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1
),
4941 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF
),
4942 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1
),
4943 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750
),
4944 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900
),
4945 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1
),
4946 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER
),
4947 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF
),
4953 static int patch_alc260(struct hda_codec
*codec
)
4955 struct alc_spec
*spec
;
4958 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4964 spec
->mixer_nid
= 0x07;
4966 alc_pick_fixup(codec
, NULL
, alc260_fixup_tbl
, alc260_fixups
);
4967 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
4969 /* automatic parse from the BIOS config */
4970 err
= alc260_parse_auto_config(codec
);
4974 if (!spec
->no_analog
) {
4975 err
= snd_hda_attach_beep_device(codec
, 0x1);
4978 set_beep_amp(spec
, 0x07, 0x05, HDA_INPUT
);
4981 codec
->patch_ops
= alc_patch_ops
;
4982 spec
->shutup
= alc_eapd_shutup
;
4984 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
4995 * ALC882/883/885/888/889 support
4997 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4998 * configuration. Each pin widget can choose any input DACs and a mixer.
4999 * Each ADC is connected from a mixer of all inputs. This makes possible
5000 * 6-channel independent captures.
5002 * In addition, an independent DAC for the multi-playback (not used in this
5010 ALC882_FIXUP_ABIT_AW9D_MAX
,
5011 ALC882_FIXUP_LENOVO_Y530
,
5012 ALC882_FIXUP_PB_M5210
,
5013 ALC882_FIXUP_ACER_ASPIRE_7736
,
5014 ALC882_FIXUP_ASUS_W90V
,
5016 ALC889_FIXUP_VAIO_TT
,
5017 ALC888_FIXUP_EEE1601
,
5020 ALC883_FIXUP_ACER_EAPD
,
5025 ALC882_FIXUP_ASUS_W2JC
,
5026 ALC882_FIXUP_ACER_ASPIRE_4930G
,
5027 ALC882_FIXUP_ACER_ASPIRE_8930G
,
5028 ALC882_FIXUP_ASPIRE_8930G_VERBS
,
5029 ALC885_FIXUP_MACPRO_GPIO
,
5030 ALC889_FIXUP_DAC_ROUTE
,
5031 ALC889_FIXUP_MBP_VREF
,
5032 ALC889_FIXUP_IMAC91_VREF
,
5035 static void alc889_fixup_coef(struct hda_codec
*codec
,
5036 const struct alc_fixup
*fix
, int action
)
5038 if (action
!= ALC_FIXUP_ACT_INIT
)
5040 alc889_coef_init(codec
);
5043 /* toggle speaker-output according to the hp-jack state */
5044 static void alc882_gpio_mute(struct hda_codec
*codec
, int pin
, int muted
)
5046 unsigned int gpiostate
, gpiomask
, gpiodir
;
5048 gpiostate
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5049 AC_VERB_GET_GPIO_DATA
, 0);
5052 gpiostate
|= (1 << pin
);
5054 gpiostate
&= ~(1 << pin
);
5056 gpiomask
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5057 AC_VERB_GET_GPIO_MASK
, 0);
5058 gpiomask
|= (1 << pin
);
5060 gpiodir
= snd_hda_codec_read(codec
, codec
->afg
, 0,
5061 AC_VERB_GET_GPIO_DIRECTION
, 0);
5062 gpiodir
|= (1 << pin
);
5065 snd_hda_codec_write(codec
, codec
->afg
, 0,
5066 AC_VERB_SET_GPIO_MASK
, gpiomask
);
5067 snd_hda_codec_write(codec
, codec
->afg
, 0,
5068 AC_VERB_SET_GPIO_DIRECTION
, gpiodir
);
5072 snd_hda_codec_write(codec
, codec
->afg
, 0,
5073 AC_VERB_SET_GPIO_DATA
, gpiostate
);
5076 /* set up GPIO at initialization */
5077 static void alc885_fixup_macpro_gpio(struct hda_codec
*codec
,
5078 const struct alc_fixup
*fix
, int action
)
5080 if (action
!= ALC_FIXUP_ACT_INIT
)
5082 alc882_gpio_mute(codec
, 0, 0);
5083 alc882_gpio_mute(codec
, 1, 0);
5086 /* Fix the connection of some pins for ALC889:
5087 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
5088 * work correctly (bko#42740)
5090 static void alc889_fixup_dac_route(struct hda_codec
*codec
,
5091 const struct alc_fixup
*fix
, int action
)
5093 if (action
== ALC_FIXUP_ACT_PRE_PROBE
) {
5094 /* fake the connections during parsing the tree */
5095 hda_nid_t conn1
[2] = { 0x0c, 0x0d };
5096 hda_nid_t conn2
[2] = { 0x0e, 0x0f };
5097 snd_hda_override_conn_list(codec
, 0x14, 2, conn1
);
5098 snd_hda_override_conn_list(codec
, 0x15, 2, conn1
);
5099 snd_hda_override_conn_list(codec
, 0x18, 2, conn2
);
5100 snd_hda_override_conn_list(codec
, 0x1a, 2, conn2
);
5101 } else if (action
== ALC_FIXUP_ACT_PROBE
) {
5102 /* restore the connections */
5103 hda_nid_t conn
[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
5104 snd_hda_override_conn_list(codec
, 0x14, 5, conn
);
5105 snd_hda_override_conn_list(codec
, 0x15, 5, conn
);
5106 snd_hda_override_conn_list(codec
, 0x18, 5, conn
);
5107 snd_hda_override_conn_list(codec
, 0x1a, 5, conn
);
5111 /* Set VREF on HP pin */
5112 static void alc889_fixup_mbp_vref(struct hda_codec
*codec
,
5113 const struct alc_fixup
*fix
, int action
)
5115 struct alc_spec
*spec
= codec
->spec
;
5116 static hda_nid_t nids
[2] = { 0x14, 0x15 };
5119 if (action
!= ALC_FIXUP_ACT_INIT
)
5121 for (i
= 0; i
< ARRAY_SIZE(nids
); i
++) {
5122 unsigned int val
= snd_hda_codec_get_pincfg(codec
, nids
[i
]);
5123 if (get_defcfg_device(val
) != AC_JACK_HP_OUT
)
5125 val
= snd_hda_codec_read(codec
, nids
[i
], 0,
5126 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
5127 val
|= AC_PINCTL_VREF_80
;
5128 snd_hda_codec_write(codec
, nids
[i
], 0,
5129 AC_VERB_SET_PIN_WIDGET_CONTROL
, val
);
5130 spec
->keep_vref_in_automute
= 1;
5135 /* Set VREF on speaker pins on imac91 */
5136 static void alc889_fixup_imac91_vref(struct hda_codec
*codec
,
5137 const struct alc_fixup
*fix
, int action
)
5139 struct alc_spec
*spec
= codec
->spec
;
5140 static hda_nid_t nids
[2] = { 0x18, 0x1a };
5143 if (action
!= ALC_FIXUP_ACT_INIT
)
5145 for (i
= 0; i
< ARRAY_SIZE(nids
); i
++) {
5147 val
= snd_hda_codec_read(codec
, nids
[i
], 0,
5148 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
5149 val
|= AC_PINCTL_VREF_50
;
5150 snd_hda_codec_write(codec
, nids
[i
], 0,
5151 AC_VERB_SET_PIN_WIDGET_CONTROL
, val
);
5153 spec
->keep_vref_in_automute
= 1;
5156 static const struct alc_fixup alc882_fixups
[] = {
5157 [ALC882_FIXUP_ABIT_AW9D_MAX
] = {
5158 .type
= ALC_FIXUP_PINS
,
5159 .v
.pins
= (const struct alc_pincfg
[]) {
5160 { 0x15, 0x01080104 }, /* side */
5161 { 0x16, 0x01011012 }, /* rear */
5162 { 0x17, 0x01016011 }, /* clfe */
5166 [ALC882_FIXUP_LENOVO_Y530
] = {
5167 .type
= ALC_FIXUP_PINS
,
5168 .v
.pins
= (const struct alc_pincfg
[]) {
5169 { 0x15, 0x99130112 }, /* rear int speakers */
5170 { 0x16, 0x99130111 }, /* subwoofer */
5174 [ALC882_FIXUP_PB_M5210
] = {
5175 .type
= ALC_FIXUP_VERBS
,
5176 .v
.verbs
= (const struct hda_verb
[]) {
5177 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF50
},
5181 [ALC882_FIXUP_ACER_ASPIRE_7736
] = {
5182 .type
= ALC_FIXUP_SKU
,
5183 .v
.sku
= ALC_FIXUP_SKU_IGNORE
,
5185 [ALC882_FIXUP_ASUS_W90V
] = {
5186 .type
= ALC_FIXUP_PINS
,
5187 .v
.pins
= (const struct alc_pincfg
[]) {
5188 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
5192 [ALC889_FIXUP_CD
] = {
5193 .type
= ALC_FIXUP_PINS
,
5194 .v
.pins
= (const struct alc_pincfg
[]) {
5195 { 0x1c, 0x993301f0 }, /* CD */
5199 [ALC889_FIXUP_VAIO_TT
] = {
5200 .type
= ALC_FIXUP_PINS
,
5201 .v
.pins
= (const struct alc_pincfg
[]) {
5202 { 0x17, 0x90170111 }, /* hidden surround speaker */
5206 [ALC888_FIXUP_EEE1601
] = {
5207 .type
= ALC_FIXUP_VERBS
,
5208 .v
.verbs
= (const struct hda_verb
[]) {
5209 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x0b },
5210 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0838 },
5214 [ALC882_FIXUP_EAPD
] = {
5215 .type
= ALC_FIXUP_VERBS
,
5216 .v
.verbs
= (const struct hda_verb
[]) {
5217 /* change to EAPD mode */
5218 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5219 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
5223 [ALC883_FIXUP_EAPD
] = {
5224 .type
= ALC_FIXUP_VERBS
,
5225 .v
.verbs
= (const struct hda_verb
[]) {
5226 /* change to EAPD mode */
5227 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5228 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
5232 [ALC883_FIXUP_ACER_EAPD
] = {
5233 .type
= ALC_FIXUP_VERBS
,
5234 .v
.verbs
= (const struct hda_verb
[]) {
5235 /* eanable EAPD on Acer laptops */
5236 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5237 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5241 [ALC882_FIXUP_GPIO1
] = {
5242 .type
= ALC_FIXUP_VERBS
,
5243 .v
.verbs
= alc_gpio1_init_verbs
,
5245 [ALC882_FIXUP_GPIO2
] = {
5246 .type
= ALC_FIXUP_VERBS
,
5247 .v
.verbs
= alc_gpio2_init_verbs
,
5249 [ALC882_FIXUP_GPIO3
] = {
5250 .type
= ALC_FIXUP_VERBS
,
5251 .v
.verbs
= alc_gpio3_init_verbs
,
5253 [ALC882_FIXUP_ASUS_W2JC
] = {
5254 .type
= ALC_FIXUP_VERBS
,
5255 .v
.verbs
= alc_gpio1_init_verbs
,
5257 .chain_id
= ALC882_FIXUP_EAPD
,
5259 [ALC889_FIXUP_COEF
] = {
5260 .type
= ALC_FIXUP_FUNC
,
5261 .v
.func
= alc889_fixup_coef
,
5263 [ALC882_FIXUP_ACER_ASPIRE_4930G
] = {
5264 .type
= ALC_FIXUP_PINS
,
5265 .v
.pins
= (const struct alc_pincfg
[]) {
5266 { 0x16, 0x99130111 }, /* CLFE speaker */
5267 { 0x17, 0x99130112 }, /* surround speaker */
5271 [ALC882_FIXUP_ACER_ASPIRE_8930G
] = {
5272 .type
= ALC_FIXUP_PINS
,
5273 .v
.pins
= (const struct alc_pincfg
[]) {
5274 { 0x16, 0x99130111 }, /* CLFE speaker */
5275 { 0x1b, 0x99130112 }, /* surround speaker */
5279 .chain_id
= ALC882_FIXUP_ASPIRE_8930G_VERBS
,
5281 [ALC882_FIXUP_ASPIRE_8930G_VERBS
] = {
5282 /* additional init verbs for Acer Aspire 8930G */
5283 .type
= ALC_FIXUP_VERBS
,
5284 .v
.verbs
= (const struct hda_verb
[]) {
5285 /* Enable all DACs */
5286 /* DAC DISABLE/MUTE 1? */
5287 /* setting bits 1-5 disables DAC nids 0x02-0x06
5288 * apparently. Init=0x38 */
5289 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x03 },
5290 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0000 },
5291 /* DAC DISABLE/MUTE 2? */
5292 /* some bit here disables the other DACs.
5294 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x08 },
5295 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0000 },
5297 * This laptop has a stereo digital microphone.
5298 * The mics are only 1cm apart which makes the stereo
5299 * useless. However, either the mic or the ALC889
5300 * makes the signal become a difference/sum signal
5301 * instead of standard stereo, which is annoying.
5302 * So instead we flip this bit which makes the
5303 * codec replicate the sum signal to both channels,
5304 * turning it into a normal mono mic.
5306 /* DMIC_CONTROL? Init value = 0x0001 */
5307 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x0b },
5308 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0003 },
5309 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5310 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5314 [ALC885_FIXUP_MACPRO_GPIO
] = {
5315 .type
= ALC_FIXUP_FUNC
,
5316 .v
.func
= alc885_fixup_macpro_gpio
,
5318 [ALC889_FIXUP_DAC_ROUTE
] = {
5319 .type
= ALC_FIXUP_FUNC
,
5320 .v
.func
= alc889_fixup_dac_route
,
5322 [ALC889_FIXUP_MBP_VREF
] = {
5323 .type
= ALC_FIXUP_FUNC
,
5324 .v
.func
= alc889_fixup_mbp_vref
,
5326 .chain_id
= ALC882_FIXUP_GPIO1
,
5328 [ALC889_FIXUP_IMAC91_VREF
] = {
5329 .type
= ALC_FIXUP_FUNC
,
5330 .v
.func
= alc889_fixup_imac91_vref
,
5332 .chain_id
= ALC882_FIXUP_GPIO1
,
5336 static const struct snd_pci_quirk alc882_fixup_tbl
[] = {
5337 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD
),
5338 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD
),
5339 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD
),
5340 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD
),
5341 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD
),
5342 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD
),
5343 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
5344 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5345 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
5346 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5347 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
5348 ALC882_FIXUP_ACER_ASPIRE_8930G
),
5349 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
5350 ALC882_FIXUP_ACER_ASPIRE_8930G
),
5351 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
5352 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5353 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
5354 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5355 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
5356 ALC882_FIXUP_ACER_ASPIRE_4930G
),
5357 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210
),
5358 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE
),
5359 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736
),
5360 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD
),
5361 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V
),
5362 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC
),
5363 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601
),
5364 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT
),
5366 /* All Apple entries are in codec SSIDs */
5367 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF
),
5368 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF
),
5369 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF
),
5370 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO
),
5371 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO
),
5372 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO
),
5373 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF
),
5374 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF
),
5375 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD
),
5376 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF
),
5377 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF
),
5378 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF
),
5379 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF
),
5380 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO
),
5381 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF
),
5382 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF
),
5383 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF
),
5384 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF
),
5385 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF
),
5386 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF
),
5388 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD
),
5389 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3
),
5390 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD
),
5391 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX
),
5392 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD
),
5393 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD
),
5394 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530
),
5395 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF
),
5400 * BIOS auto configuration
5402 /* almost identical with ALC880 parser... */
5403 static int alc882_parse_auto_config(struct hda_codec
*codec
)
5405 static const hda_nid_t alc882_ignore
[] = { 0x1d, 0 };
5406 static const hda_nid_t alc882_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5407 return alc_parse_auto_config(codec
, alc882_ignore
, alc882_ssids
);
5412 static int patch_alc882(struct hda_codec
*codec
)
5414 struct alc_spec
*spec
;
5417 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5423 spec
->mixer_nid
= 0x0b;
5425 switch (codec
->vendor_id
) {
5430 /* ALC883 and variants */
5431 alc_fix_pll_init(codec
, 0x20, 0x0a, 10);
5435 err
= alc_codec_rename_from_preset(codec
);
5439 alc_pick_fixup(codec
, NULL
, alc882_fixup_tbl
, alc882_fixups
);
5440 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5442 alc_auto_parse_customize_define(codec
);
5444 /* automatic parse from the BIOS config */
5445 err
= alc882_parse_auto_config(codec
);
5449 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
5450 err
= snd_hda_attach_beep_device(codec
, 0x1);
5453 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
5456 codec
->patch_ops
= alc_patch_ops
;
5458 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5471 static int alc262_parse_auto_config(struct hda_codec
*codec
)
5473 static const hda_nid_t alc262_ignore
[] = { 0x1d, 0 };
5474 static const hda_nid_t alc262_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5475 return alc_parse_auto_config(codec
, alc262_ignore
, alc262_ssids
);
5482 ALC262_FIXUP_FSC_H270
,
5483 ALC262_FIXUP_HP_Z200
,
5485 ALC262_FIXUP_LENOVO_3000
,
5487 ALC262_FIXUP_BENQ_T31
,
5490 static const struct alc_fixup alc262_fixups
[] = {
5491 [ALC262_FIXUP_FSC_H270
] = {
5492 .type
= ALC_FIXUP_PINS
,
5493 .v
.pins
= (const struct alc_pincfg
[]) {
5494 { 0x14, 0x99130110 }, /* speaker */
5495 { 0x15, 0x0221142f }, /* front HP */
5496 { 0x1b, 0x0121141f }, /* rear HP */
5500 [ALC262_FIXUP_HP_Z200
] = {
5501 .type
= ALC_FIXUP_PINS
,
5502 .v
.pins
= (const struct alc_pincfg
[]) {
5503 { 0x16, 0x99130120 }, /* internal speaker */
5507 [ALC262_FIXUP_TYAN
] = {
5508 .type
= ALC_FIXUP_PINS
,
5509 .v
.pins
= (const struct alc_pincfg
[]) {
5510 { 0x14, 0x1993e1f0 }, /* int AUX */
5514 [ALC262_FIXUP_LENOVO_3000
] = {
5515 .type
= ALC_FIXUP_VERBS
,
5516 .v
.verbs
= (const struct hda_verb
[]) {
5517 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF50
},
5521 .chain_id
= ALC262_FIXUP_BENQ
,
5523 [ALC262_FIXUP_BENQ
] = {
5524 .type
= ALC_FIXUP_VERBS
,
5525 .v
.verbs
= (const struct hda_verb
[]) {
5526 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5527 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
5531 [ALC262_FIXUP_BENQ_T31
] = {
5532 .type
= ALC_FIXUP_VERBS
,
5533 .v
.verbs
= (const struct hda_verb
[]) {
5534 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
5535 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
5541 static const struct snd_pci_quirk alc262_fixup_tbl
[] = {
5542 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200
),
5543 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ
),
5544 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ
),
5545 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN
),
5546 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270
),
5547 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000
),
5548 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ
),
5549 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31
),
5556 static int patch_alc262(struct hda_codec
*codec
)
5558 struct alc_spec
*spec
;
5561 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5567 spec
->mixer_nid
= 0x0b;
5570 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
5575 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
5576 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
5577 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
5578 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PROC_COEF
, tmp
| 0x80);
5581 alc_auto_parse_customize_define(codec
);
5583 alc_fix_pll_init(codec
, 0x20, 0x0a, 10);
5585 alc_pick_fixup(codec
, NULL
, alc262_fixup_tbl
, alc262_fixups
);
5586 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5588 /* automatic parse from the BIOS config */
5589 err
= alc262_parse_auto_config(codec
);
5593 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
5594 err
= snd_hda_attach_beep_device(codec
, 0x1);
5597 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
5600 codec
->patch_ops
= alc_patch_ops
;
5601 spec
->shutup
= alc_eapd_shutup
;
5603 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5615 /* bind Beep switches of both NID 0x0f and 0x10 */
5616 static const struct hda_bind_ctls alc268_bind_beep_sw
= {
5617 .ops
= &snd_hda_bind_sw
,
5619 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT
),
5620 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT
),
5625 static const struct snd_kcontrol_new alc268_beep_mixer
[] = {
5626 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT
),
5627 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw
),
5631 /* set PCBEEP vol = 0, mute connections */
5632 static const struct hda_verb alc268_beep_init_verbs
[] = {
5633 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
5634 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5635 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
5640 * BIOS auto configuration
5642 static int alc268_parse_auto_config(struct hda_codec
*codec
)
5644 static const hda_nid_t alc268_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5645 struct alc_spec
*spec
= codec
->spec
;
5646 int err
= alc_parse_auto_config(codec
, NULL
, alc268_ssids
);
5648 if (!spec
->no_analog
&& spec
->autocfg
.speaker_pins
[0] != 0x1d) {
5649 add_mixer(spec
, alc268_beep_mixer
);
5650 add_verb(spec
, alc268_beep_init_verbs
);
5658 static int patch_alc268(struct hda_codec
*codec
)
5660 struct alc_spec
*spec
;
5661 int i
, has_beep
, err
;
5663 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5669 /* ALC268 has no aa-loopback mixer */
5671 /* automatic parse from the BIOS config */
5672 err
= alc268_parse_auto_config(codec
);
5677 for (i
= 0; i
< spec
->num_mixers
; i
++) {
5678 if (spec
->mixers
[i
] == alc268_beep_mixer
) {
5685 err
= snd_hda_attach_beep_device(codec
, 0x1);
5688 if (!query_amp_caps(codec
, 0x1d, HDA_INPUT
))
5689 /* override the amp caps for beep generator */
5690 snd_hda_override_amp_caps(codec
, 0x1d, HDA_INPUT
,
5691 (0x0c << AC_AMPCAP_OFFSET_SHIFT
) |
5692 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT
) |
5693 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
5694 (0 << AC_AMPCAP_MUTE_SHIFT
));
5697 codec
->patch_ops
= alc_patch_ops
;
5698 spec
->shutup
= alc_eapd_shutup
;
5710 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback
= {
5714 .rates
= SNDRV_PCM_RATE_44100
, /* fixed rate */
5715 /* NID is set in alc_build_pcms */
5717 .open
= alc_playback_pcm_open
,
5718 .prepare
= alc_playback_pcm_prepare
,
5719 .cleanup
= alc_playback_pcm_cleanup
5723 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture
= {
5727 .rates
= SNDRV_PCM_RATE_44100
, /* fixed rate */
5728 /* NID is set in alc_build_pcms */
5731 /* different alc269-variants */
5733 ALC269_TYPE_ALC269VA
,
5734 ALC269_TYPE_ALC269VB
,
5735 ALC269_TYPE_ALC269VC
,
5739 * BIOS auto configuration
5741 static int alc269_parse_auto_config(struct hda_codec
*codec
)
5743 static const hda_nid_t alc269_ignore
[] = { 0x1d, 0 };
5744 static const hda_nid_t alc269_ssids
[] = { 0, 0x1b, 0x14, 0x21 };
5745 static const hda_nid_t alc269va_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5746 struct alc_spec
*spec
= codec
->spec
;
5747 const hda_nid_t
*ssids
= spec
->codec_variant
== ALC269_TYPE_ALC269VA
?
5748 alc269va_ssids
: alc269_ssids
;
5750 return alc_parse_auto_config(codec
, alc269_ignore
, ssids
);
5753 static void alc269_toggle_power_output(struct hda_codec
*codec
, int power_up
)
5755 int val
= alc_read_coef_idx(codec
, 0x04);
5760 alc_write_coef_idx(codec
, 0x04, val
);
5763 static void alc269_shutup(struct hda_codec
*codec
)
5765 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017)
5766 alc269_toggle_power_output(codec
, 0);
5767 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
5768 alc269_toggle_power_output(codec
, 0);
5774 static int alc269_resume(struct hda_codec
*codec
)
5776 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
5777 alc269_toggle_power_output(codec
, 0);
5781 codec
->patch_ops
.init(codec
);
5783 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017) {
5784 alc269_toggle_power_output(codec
, 1);
5788 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018)
5789 alc269_toggle_power_output(codec
, 1);
5791 snd_hda_codec_resume_amp(codec
);
5792 snd_hda_codec_resume_cache(codec
);
5793 hda_call_check_power_status(codec
, 0x01);
5796 #endif /* CONFIG_PM */
5798 static void alc269_fixup_hweq(struct hda_codec
*codec
,
5799 const struct alc_fixup
*fix
, int action
)
5803 if (action
!= ALC_FIXUP_ACT_INIT
)
5805 coef
= alc_read_coef_idx(codec
, 0x1e);
5806 alc_write_coef_idx(codec
, 0x1e, coef
| 0x80);
5809 static void alc271_fixup_dmic(struct hda_codec
*codec
,
5810 const struct alc_fixup
*fix
, int action
)
5812 static const struct hda_verb verbs
[] = {
5813 {0x20, AC_VERB_SET_COEF_INDEX
, 0x0d},
5814 {0x20, AC_VERB_SET_PROC_COEF
, 0x4000},
5819 if (strcmp(codec
->chip_name
, "ALC271X"))
5821 cfg
= snd_hda_codec_get_pincfg(codec
, 0x12);
5822 if (get_defcfg_connect(cfg
) == AC_JACK_PORT_FIXED
)
5823 snd_hda_sequence_write(codec
, verbs
);
5826 static void alc269_fixup_pcm_44k(struct hda_codec
*codec
,
5827 const struct alc_fixup
*fix
, int action
)
5829 struct alc_spec
*spec
= codec
->spec
;
5831 if (action
!= ALC_FIXUP_ACT_PROBE
)
5834 /* Due to a hardware problem on Lenovo Ideadpad, we need to
5835 * fix the sample rate of analog I/O to 44.1kHz
5837 spec
->stream_analog_playback
= &alc269_44k_pcm_analog_playback
;
5838 spec
->stream_analog_capture
= &alc269_44k_pcm_analog_capture
;
5841 static void alc269_fixup_stereo_dmic(struct hda_codec
*codec
,
5842 const struct alc_fixup
*fix
, int action
)
5846 if (action
!= ALC_FIXUP_ACT_INIT
)
5848 /* The digital-mic unit sends PDM (differential signal) instead of
5849 * the standard PCM, thus you can't record a valid mono stream as is.
5850 * Below is a workaround specific to ALC269 to control the dmic
5851 * signal source as mono.
5853 coef
= alc_read_coef_idx(codec
, 0x07);
5854 alc_write_coef_idx(codec
, 0x07, coef
| 0x80);
5857 static void alc269_quanta_automute(struct hda_codec
*codec
)
5859 update_outputs(codec
);
5861 snd_hda_codec_write(codec
, 0x20, 0,
5862 AC_VERB_SET_COEF_INDEX
, 0x0c);
5863 snd_hda_codec_write(codec
, 0x20, 0,
5864 AC_VERB_SET_PROC_COEF
, 0x680);
5866 snd_hda_codec_write(codec
, 0x20, 0,
5867 AC_VERB_SET_COEF_INDEX
, 0x0c);
5868 snd_hda_codec_write(codec
, 0x20, 0,
5869 AC_VERB_SET_PROC_COEF
, 0x480);
5872 static void alc269_fixup_quanta_mute(struct hda_codec
*codec
,
5873 const struct alc_fixup
*fix
, int action
)
5875 struct alc_spec
*spec
= codec
->spec
;
5876 if (action
!= ALC_FIXUP_ACT_PROBE
)
5878 spec
->automute_hook
= alc269_quanta_automute
;
5881 /* update mute-LED according to the speaker mute state via mic2 VREF pin */
5882 static void alc269_fixup_mic2_mute_hook(void *private_data
, int enabled
)
5884 struct hda_codec
*codec
= private_data
;
5885 unsigned int pinval
= enabled
? 0x20 : 0x24;
5886 snd_hda_codec_update_cache(codec
, 0x19, 0,
5887 AC_VERB_SET_PIN_WIDGET_CONTROL
,
5891 static void alc269_fixup_mic2_mute(struct hda_codec
*codec
,
5892 const struct alc_fixup
*fix
, int action
)
5894 struct alc_spec
*spec
= codec
->spec
;
5896 case ALC_FIXUP_ACT_BUILD
:
5897 if (!spec
->vmaster_sw_kctl
)
5899 snd_ctl_add_vmaster_hook(spec
->vmaster_sw_kctl
,
5900 alc269_fixup_mic2_mute_hook
, codec
);
5902 case ALC_FIXUP_ACT_INIT
:
5903 snd_ctl_sync_vmaster_hook(spec
->vmaster_sw_kctl
);
5909 ALC269_FIXUP_SONY_VAIO
,
5910 ALC275_FIXUP_SONY_VAIO_GPIO2
,
5911 ALC269_FIXUP_DELL_M101Z
,
5912 ALC269_FIXUP_SKU_IGNORE
,
5913 ALC269_FIXUP_ASUS_G73JW
,
5914 ALC269_FIXUP_LENOVO_EAPD
,
5915 ALC275_FIXUP_SONY_HWEQ
,
5917 ALC269_FIXUP_PCM_44K
,
5918 ALC269_FIXUP_STEREO_DMIC
,
5919 ALC269_FIXUP_QUANTA_MUTE
,
5920 ALC269_FIXUP_LIFEBOOK
,
5923 ALC269VB_FIXUP_AMIC
,
5924 ALC269VB_FIXUP_DMIC
,
5925 ALC269_FIXUP_MIC2_MUTE_LED
,
5928 static const struct alc_fixup alc269_fixups
[] = {
5929 [ALC269_FIXUP_SONY_VAIO
] = {
5930 .type
= ALC_FIXUP_VERBS
,
5931 .v
.verbs
= (const struct hda_verb
[]) {
5932 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREFGRD
},
5936 [ALC275_FIXUP_SONY_VAIO_GPIO2
] = {
5937 .type
= ALC_FIXUP_VERBS
,
5938 .v
.verbs
= (const struct hda_verb
[]) {
5939 {0x01, AC_VERB_SET_GPIO_MASK
, 0x04},
5940 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x04},
5941 {0x01, AC_VERB_SET_GPIO_DATA
, 0x00},
5945 .chain_id
= ALC269_FIXUP_SONY_VAIO
5947 [ALC269_FIXUP_DELL_M101Z
] = {
5948 .type
= ALC_FIXUP_VERBS
,
5949 .v
.verbs
= (const struct hda_verb
[]) {
5950 /* Enables internal speaker */
5951 {0x20, AC_VERB_SET_COEF_INDEX
, 13},
5952 {0x20, AC_VERB_SET_PROC_COEF
, 0x4040},
5956 [ALC269_FIXUP_SKU_IGNORE
] = {
5957 .type
= ALC_FIXUP_SKU
,
5958 .v
.sku
= ALC_FIXUP_SKU_IGNORE
,
5960 [ALC269_FIXUP_ASUS_G73JW
] = {
5961 .type
= ALC_FIXUP_PINS
,
5962 .v
.pins
= (const struct alc_pincfg
[]) {
5963 { 0x17, 0x99130111 }, /* subwoofer */
5967 [ALC269_FIXUP_LENOVO_EAPD
] = {
5968 .type
= ALC_FIXUP_VERBS
,
5969 .v
.verbs
= (const struct hda_verb
[]) {
5970 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 0},
5974 [ALC275_FIXUP_SONY_HWEQ
] = {
5975 .type
= ALC_FIXUP_FUNC
,
5976 .v
.func
= alc269_fixup_hweq
,
5978 .chain_id
= ALC275_FIXUP_SONY_VAIO_GPIO2
5980 [ALC271_FIXUP_DMIC
] = {
5981 .type
= ALC_FIXUP_FUNC
,
5982 .v
.func
= alc271_fixup_dmic
,
5984 [ALC269_FIXUP_PCM_44K
] = {
5985 .type
= ALC_FIXUP_FUNC
,
5986 .v
.func
= alc269_fixup_pcm_44k
,
5988 [ALC269_FIXUP_STEREO_DMIC
] = {
5989 .type
= ALC_FIXUP_FUNC
,
5990 .v
.func
= alc269_fixup_stereo_dmic
,
5992 [ALC269_FIXUP_QUANTA_MUTE
] = {
5993 .type
= ALC_FIXUP_FUNC
,
5994 .v
.func
= alc269_fixup_quanta_mute
,
5996 [ALC269_FIXUP_LIFEBOOK
] = {
5997 .type
= ALC_FIXUP_PINS
,
5998 .v
.pins
= (const struct alc_pincfg
[]) {
5999 { 0x1a, 0x2101103f }, /* dock line-out */
6000 { 0x1b, 0x23a11040 }, /* dock mic-in */
6004 .chain_id
= ALC269_FIXUP_QUANTA_MUTE
6006 [ALC269_FIXUP_AMIC
] = {
6007 .type
= ALC_FIXUP_PINS
,
6008 .v
.pins
= (const struct alc_pincfg
[]) {
6009 { 0x14, 0x99130110 }, /* speaker */
6010 { 0x15, 0x0121401f }, /* HP out */
6011 { 0x18, 0x01a19c20 }, /* mic */
6012 { 0x19, 0x99a3092f }, /* int-mic */
6016 [ALC269_FIXUP_DMIC
] = {
6017 .type
= ALC_FIXUP_PINS
,
6018 .v
.pins
= (const struct alc_pincfg
[]) {
6019 { 0x12, 0x99a3092f }, /* int-mic */
6020 { 0x14, 0x99130110 }, /* speaker */
6021 { 0x15, 0x0121401f }, /* HP out */
6022 { 0x18, 0x01a19c20 }, /* mic */
6026 [ALC269VB_FIXUP_AMIC
] = {
6027 .type
= ALC_FIXUP_PINS
,
6028 .v
.pins
= (const struct alc_pincfg
[]) {
6029 { 0x14, 0x99130110 }, /* speaker */
6030 { 0x18, 0x01a19c20 }, /* mic */
6031 { 0x19, 0x99a3092f }, /* int-mic */
6032 { 0x21, 0x0121401f }, /* HP out */
6036 [ALC269VB_FIXUP_DMIC
] = {
6037 .type
= ALC_FIXUP_PINS
,
6038 .v
.pins
= (const struct alc_pincfg
[]) {
6039 { 0x12, 0x99a3092f }, /* int-mic */
6040 { 0x14, 0x99130110 }, /* speaker */
6041 { 0x18, 0x01a19c20 }, /* mic */
6042 { 0x21, 0x0121401f }, /* HP out */
6046 [ALC269_FIXUP_MIC2_MUTE_LED
] = {
6047 .type
= ALC_FIXUP_FUNC
,
6048 .v
.func
= alc269_fixup_mic2_mute
,
6052 static const struct snd_pci_quirk alc269_fixup_tbl
[] = {
6053 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED
),
6054 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW
),
6055 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC
),
6056 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC
),
6057 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC
),
6058 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC
),
6059 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC
),
6060 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2
),
6061 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ
),
6062 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ
),
6063 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO
),
6064 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z
),
6065 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC
),
6066 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK
),
6067 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE
),
6068 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE
),
6069 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE
),
6070 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE
),
6071 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE
),
6072 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE
),
6073 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K
),
6074 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD
),
6077 /* Below is a quirk table taken from the old code.
6078 * Basically the device should work as is without the fixup table.
6079 * If BIOS doesn't give a proper info, enable the corresponding
6082 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
6084 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC
),
6085 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC
),
6086 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC
),
6087 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC
),
6088 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC
),
6089 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC
),
6090 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC
),
6091 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC
),
6092 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC
),
6093 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC
),
6094 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC
),
6095 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC
),
6096 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC
),
6097 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC
),
6098 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC
),
6099 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC
),
6100 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC
),
6101 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC
),
6102 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC
),
6103 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC
),
6104 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC
),
6105 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC
),
6106 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC
),
6107 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC
),
6108 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC
),
6109 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC
),
6110 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC
),
6111 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC
),
6112 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC
),
6113 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC
),
6114 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC
),
6115 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC
),
6116 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC
),
6117 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC
),
6118 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC
),
6119 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC
),
6120 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC
),
6121 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC
),
6122 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC
),
6127 static const struct alc_model_fixup alc269_fixup_models
[] = {
6128 {.id
= ALC269_FIXUP_AMIC
, .name
= "laptop-amic"},
6129 {.id
= ALC269_FIXUP_DMIC
, .name
= "laptop-dmic"},
6134 static void alc269_fill_coef(struct hda_codec
*codec
)
6136 struct alc_spec
*spec
= codec
->spec
;
6139 if (spec
->codec_variant
!= ALC269_TYPE_ALC269VB
)
6142 if ((alc_get_coef0(codec
) & 0x00ff) < 0x015) {
6143 alc_write_coef_idx(codec
, 0xf, 0x960b);
6144 alc_write_coef_idx(codec
, 0xe, 0x8817);
6147 if ((alc_get_coef0(codec
) & 0x00ff) == 0x016) {
6148 alc_write_coef_idx(codec
, 0xf, 0x960b);
6149 alc_write_coef_idx(codec
, 0xe, 0x8814);
6152 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017) {
6153 val
= alc_read_coef_idx(codec
, 0x04);
6154 /* Power up output pin */
6155 alc_write_coef_idx(codec
, 0x04, val
| (1<<11));
6158 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
6159 val
= alc_read_coef_idx(codec
, 0xd);
6160 if ((val
& 0x0c00) >> 10 != 0x1) {
6161 /* Capless ramp up clock control */
6162 alc_write_coef_idx(codec
, 0xd, val
| (1<<10));
6164 val
= alc_read_coef_idx(codec
, 0x17);
6165 if ((val
& 0x01c0) >> 6 != 0x4) {
6166 /* Class D power on reset */
6167 alc_write_coef_idx(codec
, 0x17, val
| (1<<7));
6171 val
= alc_read_coef_idx(codec
, 0xd); /* Class D */
6172 alc_write_coef_idx(codec
, 0xd, val
| (1<<14));
6174 val
= alc_read_coef_idx(codec
, 0x4); /* HP */
6175 alc_write_coef_idx(codec
, 0x4, val
| (1<<11));
6180 static int patch_alc269(struct hda_codec
*codec
)
6182 struct alc_spec
*spec
;
6185 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
6191 spec
->mixer_nid
= 0x0b;
6193 alc_auto_parse_customize_define(codec
);
6195 err
= alc_codec_rename_from_preset(codec
);
6199 if (codec
->vendor_id
== 0x10ec0269) {
6200 spec
->codec_variant
= ALC269_TYPE_ALC269VA
;
6201 switch (alc_get_coef0(codec
) & 0x00f0) {
6203 if (codec
->bus
->pci
->subsystem_vendor
== 0x1025 &&
6204 spec
->cdefine
.platform_type
== 1)
6205 err
= alc_codec_rename(codec
, "ALC271X");
6206 spec
->codec_variant
= ALC269_TYPE_ALC269VB
;
6209 if (codec
->bus
->pci
->subsystem_vendor
== 0x17aa &&
6210 codec
->bus
->pci
->subsystem_device
== 0x21f3)
6211 err
= alc_codec_rename(codec
, "ALC3202");
6212 spec
->codec_variant
= ALC269_TYPE_ALC269VC
;
6215 alc_fix_pll_init(codec
, 0x20, 0x04, 15);
6219 spec
->init_hook
= alc269_fill_coef
;
6220 alc269_fill_coef(codec
);
6223 alc_pick_fixup(codec
, alc269_fixup_models
,
6224 alc269_fixup_tbl
, alc269_fixups
);
6225 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6227 /* automatic parse from the BIOS config */
6228 err
= alc269_parse_auto_config(codec
);
6232 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
6233 err
= snd_hda_attach_beep_device(codec
, 0x1);
6236 set_beep_amp(spec
, 0x0b, 0x04, HDA_INPUT
);
6239 codec
->patch_ops
= alc_patch_ops
;
6241 codec
->patch_ops
.resume
= alc269_resume
;
6243 spec
->shutup
= alc269_shutup
;
6245 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6258 static int alc861_parse_auto_config(struct hda_codec
*codec
)
6260 static const hda_nid_t alc861_ignore
[] = { 0x1d, 0 };
6261 static const hda_nid_t alc861_ssids
[] = { 0x0e, 0x0f, 0x0b, 0 };
6262 return alc_parse_auto_config(codec
, alc861_ignore
, alc861_ssids
);
6265 /* Pin config fixes */
6267 ALC861_FIXUP_FSC_AMILO_PI1505
,
6268 ALC861_FIXUP_AMP_VREF_0F
,
6269 ALC861_FIXUP_NO_JACK_DETECT
,
6270 ALC861_FIXUP_ASUS_A6RP
,
6273 /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
6274 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec
*codec
,
6275 const struct alc_fixup
*fix
, int action
)
6277 struct alc_spec
*spec
= codec
->spec
;
6280 if (action
!= ALC_FIXUP_ACT_INIT
)
6282 val
= snd_hda_codec_read(codec
, 0x0f, 0,
6283 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
6284 if (!(val
& (AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
)))
6285 val
|= AC_PINCTL_IN_EN
;
6286 val
|= AC_PINCTL_VREF_50
;
6287 snd_hda_codec_write(codec
, 0x0f, 0,
6288 AC_VERB_SET_PIN_WIDGET_CONTROL
, val
);
6289 spec
->keep_vref_in_automute
= 1;
6292 /* suppress the jack-detection */
6293 static void alc_fixup_no_jack_detect(struct hda_codec
*codec
,
6294 const struct alc_fixup
*fix
, int action
)
6296 if (action
== ALC_FIXUP_ACT_PRE_PROBE
)
6297 codec
->no_jack_detect
= 1;
6300 static const struct alc_fixup alc861_fixups
[] = {
6301 [ALC861_FIXUP_FSC_AMILO_PI1505
] = {
6302 .type
= ALC_FIXUP_PINS
,
6303 .v
.pins
= (const struct alc_pincfg
[]) {
6304 { 0x0b, 0x0221101f }, /* HP */
6305 { 0x0f, 0x90170310 }, /* speaker */
6309 [ALC861_FIXUP_AMP_VREF_0F
] = {
6310 .type
= ALC_FIXUP_FUNC
,
6311 .v
.func
= alc861_fixup_asus_amp_vref_0f
,
6313 [ALC861_FIXUP_NO_JACK_DETECT
] = {
6314 .type
= ALC_FIXUP_FUNC
,
6315 .v
.func
= alc_fixup_no_jack_detect
,
6317 [ALC861_FIXUP_ASUS_A6RP
] = {
6318 .type
= ALC_FIXUP_FUNC
,
6319 .v
.func
= alc861_fixup_asus_amp_vref_0f
,
6321 .chain_id
= ALC861_FIXUP_NO_JACK_DETECT
,
6325 static const struct snd_pci_quirk alc861_fixup_tbl
[] = {
6326 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP
),
6327 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F
),
6328 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT
),
6329 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F
),
6330 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F
),
6331 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505
),
6337 static int patch_alc861(struct hda_codec
*codec
)
6339 struct alc_spec
*spec
;
6342 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
6348 spec
->mixer_nid
= 0x15;
6350 alc_pick_fixup(codec
, NULL
, alc861_fixup_tbl
, alc861_fixups
);
6351 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6353 /* automatic parse from the BIOS config */
6354 err
= alc861_parse_auto_config(codec
);
6358 if (!spec
->no_analog
) {
6359 err
= snd_hda_attach_beep_device(codec
, 0x23);
6362 set_beep_amp(spec
, 0x23, 0, HDA_OUTPUT
);
6365 codec
->patch_ops
= alc_patch_ops
;
6366 #ifdef CONFIG_SND_HDA_POWER_SAVE
6367 spec
->power_hook
= alc_power_eapd
;
6370 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6384 * In addition, an independent DAC
6386 static int alc861vd_parse_auto_config(struct hda_codec
*codec
)
6388 static const hda_nid_t alc861vd_ignore
[] = { 0x1d, 0 };
6389 static const hda_nid_t alc861vd_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
6390 return alc_parse_auto_config(codec
, alc861vd_ignore
, alc861vd_ssids
);
6394 ALC660VD_FIX_ASUS_GPIO1
,
6395 ALC861VD_FIX_DALLAS
,
6398 /* exclude VREF80 */
6399 static void alc861vd_fixup_dallas(struct hda_codec
*codec
,
6400 const struct alc_fixup
*fix
, int action
)
6402 if (action
== ALC_FIXUP_ACT_PRE_PROBE
) {
6403 snd_hda_override_pin_caps(codec
, 0x18, 0x00001714);
6404 snd_hda_override_pin_caps(codec
, 0x19, 0x0000171c);
6408 static const struct alc_fixup alc861vd_fixups
[] = {
6409 [ALC660VD_FIX_ASUS_GPIO1
] = {
6410 .type
= ALC_FIXUP_VERBS
,
6411 .v
.verbs
= (const struct hda_verb
[]) {
6413 {0x01, AC_VERB_SET_GPIO_MASK
, 0x03},
6414 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
6415 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
6419 [ALC861VD_FIX_DALLAS
] = {
6420 .type
= ALC_FIXUP_FUNC
,
6421 .v
.func
= alc861vd_fixup_dallas
,
6425 static const struct snd_pci_quirk alc861vd_fixup_tbl
[] = {
6426 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS
),
6427 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1
),
6428 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS
),
6432 static const struct hda_verb alc660vd_eapd_verbs
[] = {
6433 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 2},
6434 {0x15, AC_VERB_SET_EAPD_BTLENABLE
, 2},
6440 static int patch_alc861vd(struct hda_codec
*codec
)
6442 struct alc_spec
*spec
;
6445 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
6451 spec
->mixer_nid
= 0x0b;
6453 alc_pick_fixup(codec
, NULL
, alc861vd_fixup_tbl
, alc861vd_fixups
);
6454 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6456 /* automatic parse from the BIOS config */
6457 err
= alc861vd_parse_auto_config(codec
);
6461 if (codec
->vendor_id
== 0x10ec0660) {
6462 /* always turn on EAPD */
6463 add_verb(spec
, alc660vd_eapd_verbs
);
6466 if (!spec
->no_analog
) {
6467 err
= snd_hda_attach_beep_device(codec
, 0x23);
6470 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
6473 codec
->patch_ops
= alc_patch_ops
;
6475 spec
->shutup
= alc_eapd_shutup
;
6477 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6489 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
6490 * configuration. Each pin widget can choose any input DACs and a mixer.
6491 * Each ADC is connected from a mixer of all inputs. This makes possible
6492 * 6-channel independent captures.
6494 * In addition, an independent DAC for the multi-playback (not used in this
6499 * BIOS auto configuration
6502 static int alc662_parse_auto_config(struct hda_codec
*codec
)
6504 static const hda_nid_t alc662_ignore
[] = { 0x1d, 0 };
6505 static const hda_nid_t alc663_ssids
[] = { 0x15, 0x1b, 0x14, 0x21 };
6506 static const hda_nid_t alc662_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
6507 const hda_nid_t
*ssids
;
6509 if (codec
->vendor_id
== 0x10ec0272 || codec
->vendor_id
== 0x10ec0663 ||
6510 codec
->vendor_id
== 0x10ec0665 || codec
->vendor_id
== 0x10ec0670)
6511 ssids
= alc663_ssids
;
6513 ssids
= alc662_ssids
;
6514 return alc_parse_auto_config(codec
, alc662_ignore
, ssids
);
6517 static void alc272_fixup_mario(struct hda_codec
*codec
,
6518 const struct alc_fixup
*fix
, int action
)
6520 if (action
!= ALC_FIXUP_ACT_PROBE
)
6522 if (snd_hda_override_amp_caps(codec
, 0x2, HDA_OUTPUT
,
6523 (0x3b << AC_AMPCAP_OFFSET_SHIFT
) |
6524 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT
) |
6525 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
6526 (0 << AC_AMPCAP_MUTE_SHIFT
)))
6528 "hda_codec: failed to override amp caps for NID 0x2\n");
6532 ALC662_FIXUP_ASPIRE
,
6533 ALC662_FIXUP_IDEAPAD
,
6535 ALC662_FIXUP_CZC_P10T
,
6536 ALC662_FIXUP_SKU_IGNORE
,
6537 ALC662_FIXUP_HP_RP5800
,
6538 ALC662_FIXUP_ASUS_MODE1
,
6539 ALC662_FIXUP_ASUS_MODE2
,
6540 ALC662_FIXUP_ASUS_MODE3
,
6541 ALC662_FIXUP_ASUS_MODE4
,
6542 ALC662_FIXUP_ASUS_MODE5
,
6543 ALC662_FIXUP_ASUS_MODE6
,
6544 ALC662_FIXUP_ASUS_MODE7
,
6545 ALC662_FIXUP_ASUS_MODE8
,
6546 ALC662_FIXUP_NO_JACK_DETECT
,
6549 static const struct alc_fixup alc662_fixups
[] = {
6550 [ALC662_FIXUP_ASPIRE
] = {
6551 .type
= ALC_FIXUP_PINS
,
6552 .v
.pins
= (const struct alc_pincfg
[]) {
6553 { 0x15, 0x99130112 }, /* subwoofer */
6557 [ALC662_FIXUP_IDEAPAD
] = {
6558 .type
= ALC_FIXUP_PINS
,
6559 .v
.pins
= (const struct alc_pincfg
[]) {
6560 { 0x17, 0x99130112 }, /* subwoofer */
6564 [ALC272_FIXUP_MARIO
] = {
6565 .type
= ALC_FIXUP_FUNC
,
6566 .v
.func
= alc272_fixup_mario
,
6568 [ALC662_FIXUP_CZC_P10T
] = {
6569 .type
= ALC_FIXUP_VERBS
,
6570 .v
.verbs
= (const struct hda_verb
[]) {
6571 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 0},
6575 [ALC662_FIXUP_SKU_IGNORE
] = {
6576 .type
= ALC_FIXUP_SKU
,
6577 .v
.sku
= ALC_FIXUP_SKU_IGNORE
,
6579 [ALC662_FIXUP_HP_RP5800
] = {
6580 .type
= ALC_FIXUP_PINS
,
6581 .v
.pins
= (const struct alc_pincfg
[]) {
6582 { 0x14, 0x0221201f }, /* HP out */
6586 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6588 [ALC662_FIXUP_ASUS_MODE1
] = {
6589 .type
= ALC_FIXUP_PINS
,
6590 .v
.pins
= (const struct alc_pincfg
[]) {
6591 { 0x14, 0x99130110 }, /* speaker */
6592 { 0x18, 0x01a19c20 }, /* mic */
6593 { 0x19, 0x99a3092f }, /* int-mic */
6594 { 0x21, 0x0121401f }, /* HP out */
6598 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6600 [ALC662_FIXUP_ASUS_MODE2
] = {
6601 .type
= ALC_FIXUP_PINS
,
6602 .v
.pins
= (const struct alc_pincfg
[]) {
6603 { 0x14, 0x99130110 }, /* speaker */
6604 { 0x18, 0x01a19820 }, /* mic */
6605 { 0x19, 0x99a3092f }, /* int-mic */
6606 { 0x1b, 0x0121401f }, /* HP out */
6610 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6612 [ALC662_FIXUP_ASUS_MODE3
] = {
6613 .type
= ALC_FIXUP_PINS
,
6614 .v
.pins
= (const struct alc_pincfg
[]) {
6615 { 0x14, 0x99130110 }, /* speaker */
6616 { 0x15, 0x0121441f }, /* HP */
6617 { 0x18, 0x01a19840 }, /* mic */
6618 { 0x19, 0x99a3094f }, /* int-mic */
6619 { 0x21, 0x01211420 }, /* HP2 */
6623 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6625 [ALC662_FIXUP_ASUS_MODE4
] = {
6626 .type
= ALC_FIXUP_PINS
,
6627 .v
.pins
= (const struct alc_pincfg
[]) {
6628 { 0x14, 0x99130110 }, /* speaker */
6629 { 0x16, 0x99130111 }, /* speaker */
6630 { 0x18, 0x01a19840 }, /* mic */
6631 { 0x19, 0x99a3094f }, /* int-mic */
6632 { 0x21, 0x0121441f }, /* HP */
6636 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6638 [ALC662_FIXUP_ASUS_MODE5
] = {
6639 .type
= ALC_FIXUP_PINS
,
6640 .v
.pins
= (const struct alc_pincfg
[]) {
6641 { 0x14, 0x99130110 }, /* speaker */
6642 { 0x15, 0x0121441f }, /* HP */
6643 { 0x16, 0x99130111 }, /* speaker */
6644 { 0x18, 0x01a19840 }, /* mic */
6645 { 0x19, 0x99a3094f }, /* int-mic */
6649 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6651 [ALC662_FIXUP_ASUS_MODE6
] = {
6652 .type
= ALC_FIXUP_PINS
,
6653 .v
.pins
= (const struct alc_pincfg
[]) {
6654 { 0x14, 0x99130110 }, /* speaker */
6655 { 0x15, 0x01211420 }, /* HP2 */
6656 { 0x18, 0x01a19840 }, /* mic */
6657 { 0x19, 0x99a3094f }, /* int-mic */
6658 { 0x1b, 0x0121441f }, /* HP */
6662 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6664 [ALC662_FIXUP_ASUS_MODE7
] = {
6665 .type
= ALC_FIXUP_PINS
,
6666 .v
.pins
= (const struct alc_pincfg
[]) {
6667 { 0x14, 0x99130110 }, /* speaker */
6668 { 0x17, 0x99130111 }, /* speaker */
6669 { 0x18, 0x01a19840 }, /* mic */
6670 { 0x19, 0x99a3094f }, /* int-mic */
6671 { 0x1b, 0x01214020 }, /* HP */
6672 { 0x21, 0x0121401f }, /* HP */
6676 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6678 [ALC662_FIXUP_ASUS_MODE8
] = {
6679 .type
= ALC_FIXUP_PINS
,
6680 .v
.pins
= (const struct alc_pincfg
[]) {
6681 { 0x14, 0x99130110 }, /* speaker */
6682 { 0x12, 0x99a30970 }, /* int-mic */
6683 { 0x15, 0x01214020 }, /* HP */
6684 { 0x17, 0x99130111 }, /* speaker */
6685 { 0x18, 0x01a19840 }, /* mic */
6686 { 0x21, 0x0121401f }, /* HP */
6690 .chain_id
= ALC662_FIXUP_SKU_IGNORE
6692 [ALC662_FIXUP_NO_JACK_DETECT
] = {
6693 .type
= ALC_FIXUP_FUNC
,
6694 .v
.func
= alc_fixup_no_jack_detect
,
6698 static const struct snd_pci_quirk alc662_fixup_tbl
[] = {
6699 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2
),
6700 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE
),
6701 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE
),
6702 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE
),
6703 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800
),
6704 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT
),
6705 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2
),
6706 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD
),
6707 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD
),
6708 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD
),
6709 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T
),
6712 /* Below is a quirk table taken from the old code.
6713 * Basically the device should work as is without the fixup table.
6714 * If BIOS doesn't give a proper info, enable the corresponding
6717 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1
),
6718 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3
),
6719 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1
),
6720 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3
),
6721 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6722 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6723 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6724 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1
),
6725 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1
),
6726 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6727 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7
),
6728 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7
),
6729 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8
),
6730 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3
),
6731 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1
),
6732 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6733 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2
),
6734 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1
),
6735 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6736 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6737 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6738 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6739 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1
),
6740 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3
),
6741 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2
),
6742 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6743 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5
),
6744 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
6745 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6746 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1
),
6747 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6748 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6749 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3
),
6750 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3
),
6751 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1
),
6752 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1
),
6753 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1
),
6754 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1
),
6755 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1
),
6756 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
6757 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2
),
6758 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1
),
6759 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6760 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3
),
6761 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1
),
6762 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1
),
6763 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1
),
6764 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2
),
6765 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
6766 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4
),
6771 static const struct alc_model_fixup alc662_fixup_models
[] = {
6772 {.id
= ALC272_FIXUP_MARIO
, .name
= "mario"},
6773 {.id
= ALC662_FIXUP_ASUS_MODE1
, .name
= "asus-mode1"},
6774 {.id
= ALC662_FIXUP_ASUS_MODE2
, .name
= "asus-mode2"},
6775 {.id
= ALC662_FIXUP_ASUS_MODE3
, .name
= "asus-mode3"},
6776 {.id
= ALC662_FIXUP_ASUS_MODE4
, .name
= "asus-mode4"},
6777 {.id
= ALC662_FIXUP_ASUS_MODE5
, .name
= "asus-mode5"},
6778 {.id
= ALC662_FIXUP_ASUS_MODE6
, .name
= "asus-mode6"},
6779 {.id
= ALC662_FIXUP_ASUS_MODE7
, .name
= "asus-mode7"},
6780 {.id
= ALC662_FIXUP_ASUS_MODE8
, .name
= "asus-mode8"},
6787 static int patch_alc662(struct hda_codec
*codec
)
6789 struct alc_spec
*spec
;
6792 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
6798 spec
->mixer_nid
= 0x0b;
6800 /* handle multiple HPs as is */
6801 spec
->parse_flags
= HDA_PINCFG_NO_HP_FIXUP
;
6803 alc_auto_parse_customize_define(codec
);
6805 alc_fix_pll_init(codec
, 0x20, 0x04, 15);
6807 err
= alc_codec_rename_from_preset(codec
);
6811 if ((alc_get_coef0(codec
) & (1 << 14)) &&
6812 codec
->bus
->pci
->subsystem_vendor
== 0x1025 &&
6813 spec
->cdefine
.platform_type
== 1) {
6814 if (alc_codec_rename(codec
, "ALC272X") < 0)
6818 alc_pick_fixup(codec
, alc662_fixup_models
,
6819 alc662_fixup_tbl
, alc662_fixups
);
6820 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
6821 /* automatic parse from the BIOS config */
6822 err
= alc662_parse_auto_config(codec
);
6826 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
6827 err
= snd_hda_attach_beep_device(codec
, 0x1);
6830 switch (codec
->vendor_id
) {
6832 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
6837 set_beep_amp(spec
, 0x0b, 0x04, HDA_INPUT
);
6840 set_beep_amp(spec
, 0x0b, 0x03, HDA_INPUT
);
6845 codec
->patch_ops
= alc_patch_ops
;
6846 spec
->shutup
= alc_eapd_shutup
;
6848 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
6861 static int alc680_parse_auto_config(struct hda_codec
*codec
)
6863 return alc_parse_auto_config(codec
, NULL
, NULL
);
6868 static int patch_alc680(struct hda_codec
*codec
)
6870 struct alc_spec
*spec
;
6873 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
6879 /* ALC680 has no aa-loopback mixer */
6881 /* automatic parse from the BIOS config */
6882 err
= alc680_parse_auto_config(codec
);
6888 codec
->patch_ops
= alc_patch_ops
;
6896 static const struct hda_codec_preset snd_hda_preset_realtek
[] = {
6897 { .id
= 0x10ec0221, .name
= "ALC221", .patch
= patch_alc269
},
6898 { .id
= 0x10ec0260, .name
= "ALC260", .patch
= patch_alc260
},
6899 { .id
= 0x10ec0262, .name
= "ALC262", .patch
= patch_alc262
},
6900 { .id
= 0x10ec0267, .name
= "ALC267", .patch
= patch_alc268
},
6901 { .id
= 0x10ec0268, .name
= "ALC268", .patch
= patch_alc268
},
6902 { .id
= 0x10ec0269, .name
= "ALC269", .patch
= patch_alc269
},
6903 { .id
= 0x10ec0270, .name
= "ALC270", .patch
= patch_alc269
},
6904 { .id
= 0x10ec0272, .name
= "ALC272", .patch
= patch_alc662
},
6905 { .id
= 0x10ec0275, .name
= "ALC275", .patch
= patch_alc269
},
6906 { .id
= 0x10ec0276, .name
= "ALC276", .patch
= patch_alc269
},
6907 { .id
= 0x10ec0861, .rev
= 0x100340, .name
= "ALC660",
6908 .patch
= patch_alc861
},
6909 { .id
= 0x10ec0660, .name
= "ALC660-VD", .patch
= patch_alc861vd
},
6910 { .id
= 0x10ec0861, .name
= "ALC861", .patch
= patch_alc861
},
6911 { .id
= 0x10ec0862, .name
= "ALC861-VD", .patch
= patch_alc861vd
},
6912 { .id
= 0x10ec0662, .rev
= 0x100002, .name
= "ALC662 rev2",
6913 .patch
= patch_alc882
},
6914 { .id
= 0x10ec0662, .rev
= 0x100101, .name
= "ALC662 rev1",
6915 .patch
= patch_alc662
},
6916 { .id
= 0x10ec0662, .rev
= 0x100300, .name
= "ALC662 rev3",
6917 .patch
= patch_alc662
},
6918 { .id
= 0x10ec0663, .name
= "ALC663", .patch
= patch_alc662
},
6919 { .id
= 0x10ec0665, .name
= "ALC665", .patch
= patch_alc662
},
6920 { .id
= 0x10ec0670, .name
= "ALC670", .patch
= patch_alc662
},
6921 { .id
= 0x10ec0680, .name
= "ALC680", .patch
= patch_alc680
},
6922 { .id
= 0x10ec0880, .name
= "ALC880", .patch
= patch_alc880
},
6923 { .id
= 0x10ec0882, .name
= "ALC882", .patch
= patch_alc882
},
6924 { .id
= 0x10ec0883, .name
= "ALC883", .patch
= patch_alc882
},
6925 { .id
= 0x10ec0885, .rev
= 0x100101, .name
= "ALC889A",
6926 .patch
= patch_alc882
},
6927 { .id
= 0x10ec0885, .rev
= 0x100103, .name
= "ALC889A",
6928 .patch
= patch_alc882
},
6929 { .id
= 0x10ec0885, .name
= "ALC885", .patch
= patch_alc882
},
6930 { .id
= 0x10ec0887, .name
= "ALC887", .patch
= patch_alc882
},
6931 { .id
= 0x10ec0888, .rev
= 0x100101, .name
= "ALC1200",
6932 .patch
= patch_alc882
},
6933 { .id
= 0x10ec0888, .name
= "ALC888", .patch
= patch_alc882
},
6934 { .id
= 0x10ec0889, .name
= "ALC889", .patch
= patch_alc882
},
6935 { .id
= 0x10ec0892, .name
= "ALC892", .patch
= patch_alc662
},
6936 { .id
= 0x10ec0899, .name
= "ALC898", .patch
= patch_alc882
},
6940 MODULE_ALIAS("snd-hda-codec-id:10ec*");
6942 MODULE_LICENSE("GPL");
6943 MODULE_DESCRIPTION("Realtek HD-audio codec");
6945 static struct hda_codec_preset_list realtek_list
= {
6946 .preset
= snd_hda_preset_realtek
,
6947 .owner
= THIS_MODULE
,
6950 static int __init
patch_realtek_init(void)
6952 return snd_hda_add_codec_preset(&realtek_list
);
6955 static void __exit
patch_realtek_exit(void)
6957 snd_hda_delete_codec_preset(&realtek_list
);
6960 module_init(patch_realtek_init
)
6961 module_exit(patch_realtek_exit
)