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"
37 /* unsol event tags */
38 #define ALC_FRONT_EVENT 0x01
39 #define ALC_DCVOL_EVENT 0x02
40 #define ALC_HP_EVENT 0x04
41 #define ALC_MIC_EVENT 0x08
44 #define GPIO_MASK 0x03
46 /* extra amp-initialization sequence types */
55 struct alc_customize_define
{
57 unsigned char port_connectivity
;
58 unsigned char check_sum
;
59 unsigned char customization
;
60 unsigned char external_amp
;
61 unsigned int enable_pcbeep
:1;
62 unsigned int platform_type
:1;
64 unsigned int override
:1;
65 unsigned int fixup
:1; /* Means that this sku is set by driver, not read from hw */
71 hda_nid_t pin
; /* multi-io widget pin NID */
72 hda_nid_t dac
; /* DAC to be connected */
73 unsigned int ctl_in
; /* cached input-pin control value */
77 ALC_AUTOMUTE_PIN
, /* change the pin control */
78 ALC_AUTOMUTE_AMP
, /* mute/unmute the pin AMP */
79 ALC_AUTOMUTE_MIXER
, /* mute/unmute mixer widget AMP */
83 /* codec parameterization */
84 const struct snd_kcontrol_new
*mixers
[5]; /* mixer arrays */
85 unsigned int num_mixers
;
86 const struct snd_kcontrol_new
*cap_mixer
; /* capture mixer */
87 unsigned int beep_amp
; /* beep amp value, set via set_beep_amp() */
89 const struct hda_verb
*init_verbs
[10]; /* initialization verbs
93 unsigned int num_init_verbs
;
95 char stream_name_analog
[32]; /* analog PCM stream */
96 const struct hda_pcm_stream
*stream_analog_playback
;
97 const struct hda_pcm_stream
*stream_analog_capture
;
98 const struct hda_pcm_stream
*stream_analog_alt_playback
;
99 const struct hda_pcm_stream
*stream_analog_alt_capture
;
101 char stream_name_digital
[32]; /* digital PCM stream */
102 const struct hda_pcm_stream
*stream_digital_playback
;
103 const struct hda_pcm_stream
*stream_digital_capture
;
106 struct hda_multi_out multiout
; /* playback set-up
107 * max_channels, dacs must be set
108 * dig_out_nid and hp_nid are optional
110 hda_nid_t alt_dac_nid
;
111 hda_nid_t slave_dig_outs
[3]; /* optional - for auto-parsing */
115 unsigned int num_adc_nids
;
116 const hda_nid_t
*adc_nids
;
117 const hda_nid_t
*capsrc_nids
;
118 hda_nid_t dig_in_nid
; /* digital-in NID; optional */
119 hda_nid_t mixer_nid
; /* analog-mixer NID */
120 DECLARE_BITMAP(vol_ctls
, 0x20 << 1);
121 DECLARE_BITMAP(sw_ctls
, 0x20 << 1);
123 /* capture setup for dynamic dual-adc switch */
125 unsigned int cur_adc_stream_tag
;
126 unsigned int cur_adc_format
;
129 unsigned int num_mux_defs
;
130 const struct hda_input_mux
*input_mux
;
131 unsigned int cur_mux
[3];
132 hda_nid_t ext_mic_pin
;
133 hda_nid_t dock_mic_pin
;
134 hda_nid_t int_mic_pin
;
137 const struct hda_channel_mode
*channel_mode
;
138 int num_channel_mode
;
140 int const_channel_count
;
141 int ext_channel_count
;
143 /* PCM information */
144 struct hda_pcm pcm_rec
[3]; /* used in alc_build_pcms() */
146 /* dynamic controls, init_verbs and input_mux */
147 struct auto_pin_cfg autocfg
;
148 struct alc_customize_define cdefine
;
149 struct snd_array kctls
;
150 struct hda_input_mux private_imux
[3];
151 hda_nid_t private_dac_nids
[AUTO_CFG_MAX_OUTS
];
152 hda_nid_t private_adc_nids
[AUTO_CFG_MAX_OUTS
];
153 hda_nid_t private_capsrc_nids
[AUTO_CFG_MAX_OUTS
];
154 hda_nid_t imux_pins
[HDA_MAX_NUM_INPUTS
];
155 unsigned int dyn_adc_idx
[HDA_MAX_NUM_INPUTS
];
156 int int_mic_idx
, ext_mic_idx
, dock_mic_idx
; /* for auto-mic */
159 void (*init_hook
)(struct hda_codec
*codec
);
160 void (*unsol_event
)(struct hda_codec
*codec
, unsigned int res
);
161 #ifdef CONFIG_SND_HDA_POWER_SAVE
162 void (*power_hook
)(struct hda_codec
*codec
);
164 void (*shutup
)(struct hda_codec
*codec
);
165 void (*automute_hook
)(struct hda_codec
*codec
);
167 /* for pin sensing */
168 unsigned int hp_jack_present
:1;
169 unsigned int line_jack_present
:1;
170 unsigned int master_mute
:1;
171 unsigned int auto_mic
:1;
172 unsigned int auto_mic_valid_imux
:1; /* valid imux for auto-mic */
173 unsigned int automute_speaker
:1; /* automute speaker outputs */
174 unsigned int automute_lo
:1; /* automute LO outputs */
175 unsigned int detect_hp
:1; /* Headphone detection enabled */
176 unsigned int detect_lo
:1; /* Line-out detection enabled */
177 unsigned int automute_speaker_possible
:1; /* there are speakers and either LO or HP */
178 unsigned int automute_lo_possible
:1; /* there are line outs and HP */
181 unsigned int no_analog
:1; /* digital I/O only */
182 unsigned int dyn_adc_switch
:1; /* switch ADCs (for ALC275) */
183 unsigned int single_input_src
:1;
184 unsigned int vol_in_capsrc
:1; /* use capsrc volume (ADC has no vol) */
185 unsigned int parse_flags
; /* passed to snd_hda_parse_pin_defcfg() */
186 unsigned int shared_mic_hp
:1; /* HP/Mic-in sharing */
188 /* auto-mute control */
190 hda_nid_t automute_mixer_nid
[AUTO_CFG_MAX_OUTS
];
193 int codec_variant
; /* flag for other variants */
195 /* for virtual master */
196 hda_nid_t vmaster_nid
;
197 #ifdef CONFIG_SND_HDA_POWER_SAVE
198 struct hda_loopback_check loopback
;
203 unsigned int pll_coef_idx
, pll_coef_bit
;
208 const struct alc_fixup
*fixup_list
;
209 const char *fixup_name
;
213 struct alc_multi_io multi_io
[4];
216 struct snd_array bind_ctls
;
219 #define ALC_MODEL_AUTO 0 /* common for all chips */
221 static bool check_amp_caps(struct hda_codec
*codec
, hda_nid_t nid
,
222 int dir
, unsigned int bits
)
226 if (get_wcaps(codec
, nid
) & (1 << (dir
+ 1)))
227 if (query_amp_caps(codec
, nid
, dir
) & bits
)
232 #define nid_has_mute(codec, nid, dir) \
233 check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE)
234 #define nid_has_volume(codec, nid, dir) \
235 check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS)
240 static int alc_mux_enum_info(struct snd_kcontrol
*kcontrol
,
241 struct snd_ctl_elem_info
*uinfo
)
243 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
244 struct alc_spec
*spec
= codec
->spec
;
245 unsigned int mux_idx
= snd_ctl_get_ioffidx(kcontrol
, &uinfo
->id
);
246 if (mux_idx
>= spec
->num_mux_defs
)
248 if (!spec
->input_mux
[mux_idx
].num_items
&& mux_idx
> 0)
250 return snd_hda_input_mux_info(&spec
->input_mux
[mux_idx
], uinfo
);
253 static int alc_mux_enum_get(struct snd_kcontrol
*kcontrol
,
254 struct snd_ctl_elem_value
*ucontrol
)
256 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
257 struct alc_spec
*spec
= codec
->spec
;
258 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
260 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
264 static bool alc_dyn_adc_pcm_resetup(struct hda_codec
*codec
, int cur
)
266 struct alc_spec
*spec
= codec
->spec
;
267 hda_nid_t new_adc
= spec
->adc_nids
[spec
->dyn_adc_idx
[cur
]];
269 if (spec
->cur_adc
&& spec
->cur_adc
!= new_adc
) {
270 /* stream is running, let's swap the current ADC */
271 __snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
, 1);
272 spec
->cur_adc
= new_adc
;
273 snd_hda_codec_setup_stream(codec
, new_adc
,
274 spec
->cur_adc_stream_tag
, 0,
275 spec
->cur_adc_format
);
281 static void call_update_outputs(struct hda_codec
*codec
);
283 /* select the given imux item; either unmute exclusively or select the route */
284 static int alc_mux_select(struct hda_codec
*codec
, unsigned int adc_idx
,
285 unsigned int idx
, bool force
)
287 struct alc_spec
*spec
= codec
->spec
;
288 const struct hda_input_mux
*imux
;
289 unsigned int mux_idx
;
290 int i
, type
, num_conns
;
293 mux_idx
= adc_idx
>= spec
->num_mux_defs
? 0 : adc_idx
;
294 imux
= &spec
->input_mux
[mux_idx
];
295 if (!imux
->num_items
&& mux_idx
> 0)
296 imux
= &spec
->input_mux
[0];
298 if (idx
>= imux
->num_items
)
299 idx
= imux
->num_items
- 1;
300 if (spec
->cur_mux
[adc_idx
] == idx
&& !force
)
302 spec
->cur_mux
[adc_idx
] = idx
;
304 /* for shared I/O, change the pin-control accordingly */
305 if (spec
->shared_mic_hp
) {
306 /* NOTE: this assumes that there are only two inputs, the
307 * first is the real internal mic and the second is HP jack.
309 snd_hda_codec_write(codec
, spec
->autocfg
.inputs
[1].pin
, 0,
310 AC_VERB_SET_PIN_WIDGET_CONTROL
,
311 spec
->cur_mux
[adc_idx
] ?
312 PIN_VREF80
: PIN_HP
);
313 spec
->automute_speaker
= !spec
->cur_mux
[adc_idx
];
314 call_update_outputs(codec
);
317 if (spec
->dyn_adc_switch
) {
318 alc_dyn_adc_pcm_resetup(codec
, idx
);
319 adc_idx
= spec
->dyn_adc_idx
[idx
];
322 nid
= spec
->capsrc_nids
?
323 spec
->capsrc_nids
[adc_idx
] : spec
->adc_nids
[adc_idx
];
326 num_conns
= snd_hda_get_conn_list(codec
, nid
, NULL
);
330 type
= get_wcaps_type(get_wcaps(codec
, nid
));
331 if (type
== AC_WID_AUD_MIX
) {
332 /* Matrix-mixer style (e.g. ALC882) */
333 int active
= imux
->items
[idx
].index
;
334 for (i
= 0; i
< num_conns
; i
++) {
335 unsigned int v
= (i
== active
) ? 0 : HDA_AMP_MUTE
;
336 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, i
,
340 /* MUX style (e.g. ALC880) */
341 snd_hda_codec_write_cache(codec
, nid
, 0,
342 AC_VERB_SET_CONNECT_SEL
,
343 imux
->items
[idx
].index
);
348 static int alc_mux_enum_put(struct snd_kcontrol
*kcontrol
,
349 struct snd_ctl_elem_value
*ucontrol
)
351 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
352 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
353 return alc_mux_select(codec
, adc_idx
,
354 ucontrol
->value
.enumerated
.item
[0], false);
358 * set up the input pin config (depending on the given auto-pin type)
360 static void alc_set_input_pin(struct hda_codec
*codec
, hda_nid_t nid
,
363 unsigned int val
= PIN_IN
;
365 if (auto_pin_type
== AUTO_PIN_MIC
) {
368 oldval
= snd_hda_codec_read(codec
, nid
, 0,
369 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
370 pincap
= snd_hda_query_pin_caps(codec
, nid
);
371 pincap
= (pincap
& AC_PINCAP_VREF
) >> AC_PINCAP_VREF_SHIFT
;
372 /* if the default pin setup is vref50, we give it priority */
373 if ((pincap
& AC_PINCAP_VREF_80
) && oldval
!= PIN_VREF50
)
375 else if (pincap
& AC_PINCAP_VREF_50
)
377 else if (pincap
& AC_PINCAP_VREF_100
)
379 else if (pincap
& AC_PINCAP_VREF_GRD
)
382 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, val
);
386 * Append the given mixer and verb elements for the later use
387 * The mixer array is referred in build_controls(), and init_verbs are
390 static void add_mixer(struct alc_spec
*spec
, const struct snd_kcontrol_new
*mix
)
392 if (snd_BUG_ON(spec
->num_mixers
>= ARRAY_SIZE(spec
->mixers
)))
394 spec
->mixers
[spec
->num_mixers
++] = mix
;
397 static void add_verb(struct alc_spec
*spec
, const struct hda_verb
*verb
)
399 if (snd_BUG_ON(spec
->num_init_verbs
>= ARRAY_SIZE(spec
->init_verbs
)))
401 spec
->init_verbs
[spec
->num_init_verbs
++] = verb
;
405 * GPIO setup tables, used in initialization
407 /* Enable GPIO mask and set output */
408 static const struct hda_verb alc_gpio1_init_verbs
[] = {
409 {0x01, AC_VERB_SET_GPIO_MASK
, 0x01},
410 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
411 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
415 static const struct hda_verb alc_gpio2_init_verbs
[] = {
416 {0x01, AC_VERB_SET_GPIO_MASK
, 0x02},
417 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x02},
418 {0x01, AC_VERB_SET_GPIO_DATA
, 0x02},
422 static const struct hda_verb alc_gpio3_init_verbs
[] = {
423 {0x01, AC_VERB_SET_GPIO_MASK
, 0x03},
424 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x03},
425 {0x01, AC_VERB_SET_GPIO_DATA
, 0x03},
430 * Fix hardware PLL issue
431 * On some codecs, the analog PLL gating control must be off while
432 * the default value is 1.
434 static void alc_fix_pll(struct hda_codec
*codec
)
436 struct alc_spec
*spec
= codec
->spec
;
441 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_COEF_INDEX
,
443 val
= snd_hda_codec_read(codec
, spec
->pll_nid
, 0,
444 AC_VERB_GET_PROC_COEF
, 0);
445 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_COEF_INDEX
,
447 snd_hda_codec_write(codec
, spec
->pll_nid
, 0, AC_VERB_SET_PROC_COEF
,
448 val
& ~(1 << spec
->pll_coef_bit
));
451 static void alc_fix_pll_init(struct hda_codec
*codec
, hda_nid_t nid
,
452 unsigned int coef_idx
, unsigned int coef_bit
)
454 struct alc_spec
*spec
= codec
->spec
;
456 spec
->pll_coef_idx
= coef_idx
;
457 spec
->pll_coef_bit
= coef_bit
;
462 * Jack-reporting via input-jack layer
465 /* initialization of jacks; currently checks only a few known pins */
466 static int alc_init_jacks(struct hda_codec
*codec
)
468 #ifdef CONFIG_SND_HDA_INPUT_JACK
469 struct alc_spec
*spec
= codec
->spec
;
471 unsigned int hp_nid
= spec
->autocfg
.hp_pins
[0];
472 unsigned int mic_nid
= spec
->ext_mic_pin
;
473 unsigned int dock_nid
= spec
->dock_mic_pin
;
476 err
= snd_hda_input_jack_add(codec
, hp_nid
,
477 SND_JACK_HEADPHONE
, NULL
);
480 snd_hda_input_jack_report(codec
, hp_nid
);
484 err
= snd_hda_input_jack_add(codec
, mic_nid
,
485 SND_JACK_MICROPHONE
, NULL
);
488 snd_hda_input_jack_report(codec
, mic_nid
);
491 err
= snd_hda_input_jack_add(codec
, dock_nid
,
492 SND_JACK_MICROPHONE
, NULL
);
495 snd_hda_input_jack_report(codec
, dock_nid
);
497 #endif /* CONFIG_SND_HDA_INPUT_JACK */
502 * Jack detections for HP auto-mute and mic-switch
505 /* check each pin in the given array; returns true if any of them is plugged */
506 static bool detect_jacks(struct hda_codec
*codec
, int num_pins
, hda_nid_t
*pins
)
510 for (i
= 0; i
< num_pins
; i
++) {
511 hda_nid_t nid
= pins
[i
];
514 snd_hda_input_jack_report(codec
, nid
);
515 present
|= snd_hda_jack_detect(codec
, nid
);
520 /* standard HP/line-out auto-mute helper */
521 static void do_automute(struct hda_codec
*codec
, int num_pins
, hda_nid_t
*pins
,
522 bool mute
, bool hp_out
)
524 struct alc_spec
*spec
= codec
->spec
;
525 unsigned int mute_bits
= mute
? HDA_AMP_MUTE
: 0;
526 unsigned int pin_bits
= mute
? 0 : (hp_out
? PIN_HP
: PIN_OUT
);
529 for (i
= 0; i
< num_pins
; i
++) {
530 hda_nid_t nid
= pins
[i
];
533 switch (spec
->automute_mode
) {
534 case ALC_AUTOMUTE_PIN
:
535 snd_hda_codec_write(codec
, nid
, 0,
536 AC_VERB_SET_PIN_WIDGET_CONTROL
,
539 case ALC_AUTOMUTE_AMP
:
540 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
541 HDA_AMP_MUTE
, mute_bits
);
543 case ALC_AUTOMUTE_MIXER
:
544 nid
= spec
->automute_mixer_nid
[i
];
547 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, 0,
548 HDA_AMP_MUTE
, mute_bits
);
549 snd_hda_codec_amp_stereo(codec
, nid
, HDA_INPUT
, 1,
550 HDA_AMP_MUTE
, mute_bits
);
556 /* Toggle outputs muting */
557 static void update_outputs(struct hda_codec
*codec
)
559 struct alc_spec
*spec
= codec
->spec
;
562 /* Control HP pins/amps depending on master_mute state;
563 * in general, HP pins/amps control should be enabled in all cases,
564 * but currently set only for master_mute, just to be safe
566 if (!spec
->shared_mic_hp
) /* don't change HP-pin when shared with mic */
567 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.hp_pins
),
568 spec
->autocfg
.hp_pins
, spec
->master_mute
, true);
570 if (!spec
->automute_speaker
)
573 on
= spec
->hp_jack_present
| spec
->line_jack_present
;
574 on
|= spec
->master_mute
;
575 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.speaker_pins
),
576 spec
->autocfg
.speaker_pins
, on
, false);
578 /* toggle line-out mutes if needed, too */
579 /* if LO is a copy of either HP or Speaker, don't need to handle it */
580 if (spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.hp_pins
[0] ||
581 spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.speaker_pins
[0])
583 if (!spec
->automute_lo
)
586 on
= spec
->hp_jack_present
;
587 on
|= spec
->master_mute
;
588 do_automute(codec
, ARRAY_SIZE(spec
->autocfg
.line_out_pins
),
589 spec
->autocfg
.line_out_pins
, on
, false);
592 static void call_update_outputs(struct hda_codec
*codec
)
594 struct alc_spec
*spec
= codec
->spec
;
595 if (spec
->automute_hook
)
596 spec
->automute_hook(codec
);
598 update_outputs(codec
);
601 /* standard HP-automute helper */
602 static void alc_hp_automute(struct hda_codec
*codec
)
604 struct alc_spec
*spec
= codec
->spec
;
606 spec
->hp_jack_present
=
607 detect_jacks(codec
, ARRAY_SIZE(spec
->autocfg
.hp_pins
),
608 spec
->autocfg
.hp_pins
);
609 if (!spec
->detect_hp
|| (!spec
->automute_speaker
&& !spec
->automute_lo
))
611 call_update_outputs(codec
);
614 /* standard line-out-automute helper */
615 static void alc_line_automute(struct hda_codec
*codec
)
617 struct alc_spec
*spec
= codec
->spec
;
619 /* check LO jack only when it's different from HP */
620 if (spec
->autocfg
.line_out_pins
[0] == spec
->autocfg
.hp_pins
[0])
623 spec
->line_jack_present
=
624 detect_jacks(codec
, ARRAY_SIZE(spec
->autocfg
.line_out_pins
),
625 spec
->autocfg
.line_out_pins
);
626 if (!spec
->automute_speaker
|| !spec
->detect_lo
)
628 call_update_outputs(codec
);
631 #define get_connection_index(codec, mux, nid) \
632 snd_hda_get_conn_index(codec, mux, nid, 0)
634 /* standard mic auto-switch helper */
635 static void alc_mic_automute(struct hda_codec
*codec
)
637 struct alc_spec
*spec
= codec
->spec
;
638 hda_nid_t
*pins
= spec
->imux_pins
;
640 if (!spec
->auto_mic
|| !spec
->auto_mic_valid_imux
)
642 if (snd_BUG_ON(!spec
->adc_nids
))
644 if (snd_BUG_ON(spec
->int_mic_idx
< 0 || spec
->ext_mic_idx
< 0))
647 if (snd_hda_jack_detect(codec
, pins
[spec
->ext_mic_idx
]))
648 alc_mux_select(codec
, 0, spec
->ext_mic_idx
, false);
649 else if (spec
->dock_mic_idx
>= 0 &&
650 snd_hda_jack_detect(codec
, pins
[spec
->dock_mic_idx
]))
651 alc_mux_select(codec
, 0, spec
->dock_mic_idx
, false);
653 alc_mux_select(codec
, 0, spec
->int_mic_idx
, false);
655 snd_hda_input_jack_report(codec
, pins
[spec
->ext_mic_idx
]);
656 if (spec
->dock_mic_idx
>= 0)
657 snd_hda_input_jack_report(codec
, pins
[spec
->dock_mic_idx
]);
660 /* unsolicited event for HP jack sensing */
661 static void alc_sku_unsol_event(struct hda_codec
*codec
, unsigned int res
)
663 if (codec
->vendor_id
== 0x10ec0880)
669 alc_hp_automute(codec
);
671 case ALC_FRONT_EVENT
:
672 alc_line_automute(codec
);
675 alc_mic_automute(codec
);
680 /* call init functions of standard auto-mute helpers */
681 static void alc_inithook(struct hda_codec
*codec
)
683 alc_hp_automute(codec
);
684 alc_line_automute(codec
);
685 alc_mic_automute(codec
);
688 /* additional initialization for ALC888 variants */
689 static void alc888_coef_init(struct hda_codec
*codec
)
693 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 0);
694 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
695 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
696 if ((tmp
& 0xf0) == 0x20)
698 snd_hda_codec_read(codec
, 0x20, 0,
699 AC_VERB_SET_PROC_COEF
, 0x830);
702 snd_hda_codec_read(codec
, 0x20, 0,
703 AC_VERB_SET_PROC_COEF
, 0x3030);
706 /* additional initialization for ALC889 variants */
707 static void alc889_coef_init(struct hda_codec
*codec
)
711 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
712 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
713 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
, 7);
714 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_PROC_COEF
, tmp
|0x2010);
717 /* turn on/off EAPD control (only if available) */
718 static void set_eapd(struct hda_codec
*codec
, hda_nid_t nid
, int on
)
720 if (get_wcaps_type(get_wcaps(codec
, nid
)) != AC_WID_PIN
)
722 if (snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_EAPD
)
723 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_EAPD_BTLENABLE
,
727 /* turn on/off EAPD controls of the codec */
728 static void alc_auto_setup_eapd(struct hda_codec
*codec
, bool on
)
730 /* We currently only handle front, HP */
731 static hda_nid_t pins
[] = {
732 0x0f, 0x10, 0x14, 0x15, 0
735 for (p
= pins
; *p
; p
++)
736 set_eapd(codec
, *p
, on
);
739 /* generic shutup callback;
740 * just turning off EPAD and a little pause for avoiding pop-noise
742 static void alc_eapd_shutup(struct hda_codec
*codec
)
744 alc_auto_setup_eapd(codec
, false);
748 /* generic EAPD initialization */
749 static void alc_auto_init_amp(struct hda_codec
*codec
, int type
)
753 alc_auto_setup_eapd(codec
, true);
756 snd_hda_sequence_write(codec
, alc_gpio1_init_verbs
);
759 snd_hda_sequence_write(codec
, alc_gpio2_init_verbs
);
762 snd_hda_sequence_write(codec
, alc_gpio3_init_verbs
);
764 case ALC_INIT_DEFAULT
:
765 switch (codec
->vendor_id
) {
767 snd_hda_codec_write(codec
, 0x1a, 0,
768 AC_VERB_SET_COEF_INDEX
, 7);
769 tmp
= snd_hda_codec_read(codec
, 0x1a, 0,
770 AC_VERB_GET_PROC_COEF
, 0);
771 snd_hda_codec_write(codec
, 0x1a, 0,
772 AC_VERB_SET_COEF_INDEX
, 7);
773 snd_hda_codec_write(codec
, 0x1a, 0,
774 AC_VERB_SET_PROC_COEF
,
783 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
784 alc889_coef_init(codec
);
787 alc888_coef_init(codec
);
789 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
792 snd_hda_codec_write(codec
, 0x20, 0,
793 AC_VERB_SET_COEF_INDEX
, 7);
794 tmp
= snd_hda_codec_read(codec
, 0x20, 0,
795 AC_VERB_GET_PROC_COEF
, 0);
796 snd_hda_codec_write(codec
, 0x20, 0,
797 AC_VERB_SET_COEF_INDEX
, 7);
798 snd_hda_codec_write(codec
, 0x20, 0,
799 AC_VERB_SET_PROC_COEF
,
809 * Auto-Mute mode mixer enum support
811 static int alc_automute_mode_info(struct snd_kcontrol
*kcontrol
,
812 struct snd_ctl_elem_info
*uinfo
)
814 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
815 struct alc_spec
*spec
= codec
->spec
;
816 static const char * const texts2
[] = {
817 "Disabled", "Enabled"
819 static const char * const texts3
[] = {
820 "Disabled", "Speaker Only", "Line-Out+Speaker"
822 const char * const *texts
;
824 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
826 if (spec
->automute_speaker_possible
&& spec
->automute_lo_possible
) {
827 uinfo
->value
.enumerated
.items
= 3;
830 uinfo
->value
.enumerated
.items
= 2;
833 if (uinfo
->value
.enumerated
.item
>= uinfo
->value
.enumerated
.items
)
834 uinfo
->value
.enumerated
.item
= uinfo
->value
.enumerated
.items
- 1;
835 strcpy(uinfo
->value
.enumerated
.name
,
836 texts
[uinfo
->value
.enumerated
.item
]);
840 static int alc_automute_mode_get(struct snd_kcontrol
*kcontrol
,
841 struct snd_ctl_elem_value
*ucontrol
)
843 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
844 struct alc_spec
*spec
= codec
->spec
;
845 unsigned int val
= 0;
846 if (spec
->automute_speaker
)
848 if (spec
->automute_lo
)
851 ucontrol
->value
.enumerated
.item
[0] = val
;
855 static int alc_automute_mode_put(struct snd_kcontrol
*kcontrol
,
856 struct snd_ctl_elem_value
*ucontrol
)
858 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
859 struct alc_spec
*spec
= codec
->spec
;
861 switch (ucontrol
->value
.enumerated
.item
[0]) {
863 if (!spec
->automute_speaker
&& !spec
->automute_lo
)
865 spec
->automute_speaker
= 0;
866 spec
->automute_lo
= 0;
869 if (spec
->automute_speaker_possible
) {
870 if (!spec
->automute_lo
&& spec
->automute_speaker
)
872 spec
->automute_speaker
= 1;
873 spec
->automute_lo
= 0;
874 } else if (spec
->automute_lo_possible
) {
875 if (spec
->automute_lo
)
877 spec
->automute_lo
= 1;
882 if (!spec
->automute_lo_possible
|| !spec
->automute_speaker_possible
)
884 if (spec
->automute_speaker
&& spec
->automute_lo
)
886 spec
->automute_speaker
= 1;
887 spec
->automute_lo
= 1;
892 call_update_outputs(codec
);
896 static const struct snd_kcontrol_new alc_automute_mode_enum
= {
897 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
898 .name
= "Auto-Mute Mode",
899 .info
= alc_automute_mode_info
,
900 .get
= alc_automute_mode_get
,
901 .put
= alc_automute_mode_put
,
904 static struct snd_kcontrol_new
*alc_kcontrol_new(struct alc_spec
*spec
)
906 snd_array_init(&spec
->kctls
, sizeof(struct snd_kcontrol_new
), 32);
907 return snd_array_new(&spec
->kctls
);
910 static int alc_add_automute_mode_enum(struct hda_codec
*codec
)
912 struct alc_spec
*spec
= codec
->spec
;
913 struct snd_kcontrol_new
*knew
;
915 knew
= alc_kcontrol_new(spec
);
918 *knew
= alc_automute_mode_enum
;
919 knew
->name
= kstrdup("Auto-Mute Mode", GFP_KERNEL
);
926 * Check the availability of HP/line-out auto-mute;
927 * Set up appropriately if really supported
929 static void alc_init_automute(struct hda_codec
*codec
)
931 struct alc_spec
*spec
= codec
->spec
;
932 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
938 if (cfg
->line_out_pins
[0])
940 if (cfg
->speaker_pins
[0])
942 if (present
< 2) /* need two different output types */
945 if (!cfg
->speaker_pins
[0] &&
946 cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
) {
947 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
948 sizeof(cfg
->speaker_pins
));
949 cfg
->speaker_outs
= cfg
->line_outs
;
952 if (!cfg
->hp_pins
[0] &&
953 cfg
->line_out_type
== AUTO_PIN_HP_OUT
) {
954 memcpy(cfg
->hp_pins
, cfg
->line_out_pins
,
955 sizeof(cfg
->hp_pins
));
956 cfg
->hp_outs
= cfg
->line_outs
;
959 spec
->automute_mode
= ALC_AUTOMUTE_PIN
;
961 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
962 hda_nid_t nid
= cfg
->hp_pins
[i
];
963 if (!is_jack_detectable(codec
, nid
))
965 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
967 snd_hda_codec_write_cache(codec
, nid
, 0,
968 AC_VERB_SET_UNSOLICITED_ENABLE
,
969 AC_USRSP_EN
| ALC_HP_EVENT
);
973 if (cfg
->line_out_type
== AUTO_PIN_LINE_OUT
&& cfg
->line_outs
) {
974 if (cfg
->speaker_outs
)
975 for (i
= 0; i
< cfg
->line_outs
; i
++) {
976 hda_nid_t nid
= cfg
->line_out_pins
[i
];
977 if (!is_jack_detectable(codec
, nid
))
979 snd_printdd("realtek: Enable Line-Out "
980 "auto-muting on NID 0x%x\n", nid
);
981 snd_hda_codec_write_cache(codec
, nid
, 0,
982 AC_VERB_SET_UNSOLICITED_ENABLE
,
983 AC_USRSP_EN
| ALC_FRONT_EVENT
);
986 spec
->automute_lo_possible
= spec
->detect_hp
;
989 spec
->automute_speaker_possible
= cfg
->speaker_outs
&&
990 (spec
->detect_hp
|| spec
->detect_lo
);
992 spec
->automute_lo
= spec
->automute_lo_possible
;
993 spec
->automute_speaker
= spec
->automute_speaker_possible
;
995 if (spec
->automute_speaker_possible
|| spec
->automute_lo_possible
) {
996 /* create a control for automute mode */
997 alc_add_automute_mode_enum(codec
);
998 spec
->unsol_event
= alc_sku_unsol_event
;
1002 /* return the position of NID in the list, or -1 if not found */
1003 static int find_idx_in_nid_list(hda_nid_t nid
, const hda_nid_t
*list
, int nums
)
1006 for (i
= 0; i
< nums
; i
++)
1012 /* check whether dynamic ADC-switching is available */
1013 static bool alc_check_dyn_adc_switch(struct hda_codec
*codec
)
1015 struct alc_spec
*spec
= codec
->spec
;
1016 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
1020 if (imux
!= spec
->input_mux
) /* no dynamic imux? */
1023 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
1024 cap
= spec
->private_capsrc_nids
[n
];
1025 for (i
= 0; i
< imux
->num_items
; i
++) {
1026 pin
= spec
->imux_pins
[i
];
1029 if (get_connection_index(codec
, cap
, pin
) < 0)
1032 if (i
>= imux
->num_items
)
1033 return true; /* no ADC-switch is needed */
1036 for (i
= 0; i
< imux
->num_items
; i
++) {
1037 pin
= spec
->imux_pins
[i
];
1038 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
1039 cap
= spec
->private_capsrc_nids
[n
];
1040 idx
= get_connection_index(codec
, cap
, pin
);
1042 imux
->items
[i
].index
= idx
;
1043 spec
->dyn_adc_idx
[i
] = n
;
1049 snd_printdd("realtek: enabling ADC switching\n");
1050 spec
->dyn_adc_switch
= 1;
1054 /* rebuild imux for matching with the given auto-mic pins (if not yet) */
1055 static bool alc_rebuild_imux_for_auto_mic(struct hda_codec
*codec
)
1057 struct alc_spec
*spec
= codec
->spec
;
1058 struct hda_input_mux
*imux
;
1059 static char * const texts
[3] = {
1060 "Mic", "Internal Mic", "Dock Mic"
1064 if (!spec
->auto_mic
)
1066 imux
= &spec
->private_imux
[0];
1067 if (spec
->input_mux
== imux
)
1069 spec
->imux_pins
[0] = spec
->ext_mic_pin
;
1070 spec
->imux_pins
[1] = spec
->int_mic_pin
;
1071 spec
->imux_pins
[2] = spec
->dock_mic_pin
;
1072 for (i
= 0; i
< 3; i
++) {
1073 strcpy(imux
->items
[i
].label
, texts
[i
]);
1074 if (spec
->imux_pins
[i
])
1075 imux
->num_items
= i
+ 1;
1077 spec
->num_mux_defs
= 1;
1078 spec
->input_mux
= imux
;
1082 /* check whether all auto-mic pins are valid; setup indices if OK */
1083 static bool alc_auto_mic_check_imux(struct hda_codec
*codec
)
1085 struct alc_spec
*spec
= codec
->spec
;
1086 const struct hda_input_mux
*imux
;
1088 if (!spec
->auto_mic
)
1090 if (spec
->auto_mic_valid_imux
)
1091 return true; /* already checked */
1093 /* fill up imux indices */
1094 if (!alc_check_dyn_adc_switch(codec
)) {
1099 imux
= spec
->input_mux
;
1100 spec
->ext_mic_idx
= find_idx_in_nid_list(spec
->ext_mic_pin
,
1101 spec
->imux_pins
, imux
->num_items
);
1102 spec
->int_mic_idx
= find_idx_in_nid_list(spec
->int_mic_pin
,
1103 spec
->imux_pins
, imux
->num_items
);
1104 spec
->dock_mic_idx
= find_idx_in_nid_list(spec
->dock_mic_pin
,
1105 spec
->imux_pins
, imux
->num_items
);
1106 if (spec
->ext_mic_idx
< 0 || spec
->int_mic_idx
< 0) {
1108 return false; /* no corresponding imux */
1111 snd_hda_codec_write_cache(codec
, spec
->ext_mic_pin
, 0,
1112 AC_VERB_SET_UNSOLICITED_ENABLE
,
1113 AC_USRSP_EN
| ALC_MIC_EVENT
);
1114 if (spec
->dock_mic_pin
)
1115 snd_hda_codec_write_cache(codec
, spec
->dock_mic_pin
, 0,
1116 AC_VERB_SET_UNSOLICITED_ENABLE
,
1117 AC_USRSP_EN
| ALC_MIC_EVENT
);
1119 spec
->auto_mic_valid_imux
= 1;
1125 * Check the availability of auto-mic switch;
1126 * Set up if really supported
1128 static void alc_init_auto_mic(struct hda_codec
*codec
)
1130 struct alc_spec
*spec
= codec
->spec
;
1131 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1132 hda_nid_t fixed
, ext
, dock
;
1135 if (spec
->shared_mic_hp
)
1136 return; /* no auto-mic for the shared I/O */
1138 spec
->ext_mic_idx
= spec
->int_mic_idx
= spec
->dock_mic_idx
= -1;
1140 fixed
= ext
= dock
= 0;
1141 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
1142 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
1143 unsigned int defcfg
;
1144 defcfg
= snd_hda_codec_get_pincfg(codec
, nid
);
1145 switch (snd_hda_get_input_pin_attr(defcfg
)) {
1146 case INPUT_PIN_ATTR_INT
:
1148 return; /* already occupied */
1149 if (cfg
->inputs
[i
].type
!= AUTO_PIN_MIC
)
1150 return; /* invalid type */
1153 case INPUT_PIN_ATTR_UNUSED
:
1154 return; /* invalid entry */
1155 case INPUT_PIN_ATTR_DOCK
:
1157 return; /* already occupied */
1158 if (cfg
->inputs
[i
].type
> AUTO_PIN_LINE_IN
)
1159 return; /* invalid type */
1164 return; /* already occupied */
1165 if (cfg
->inputs
[i
].type
!= AUTO_PIN_MIC
)
1166 return; /* invalid type */
1177 if (!is_jack_detectable(codec
, ext
))
1178 return; /* no unsol support */
1179 if (dock
&& !is_jack_detectable(codec
, dock
))
1180 return; /* no unsol support */
1182 /* check imux indices */
1183 spec
->ext_mic_pin
= ext
;
1184 spec
->int_mic_pin
= fixed
;
1185 spec
->dock_mic_pin
= dock
;
1188 if (!alc_auto_mic_check_imux(codec
))
1191 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
1193 spec
->unsol_event
= alc_sku_unsol_event
;
1196 /* check the availabilities of auto-mute and auto-mic switches */
1197 static void alc_auto_check_switches(struct hda_codec
*codec
)
1199 alc_init_automute(codec
);
1200 alc_init_auto_mic(codec
);
1204 * Realtek SSID verification
1207 /* Could be any non-zero and even value. When used as fixup, tells
1208 * the driver to ignore any present sku defines.
1210 #define ALC_FIXUP_SKU_IGNORE (2)
1212 static int alc_auto_parse_customize_define(struct hda_codec
*codec
)
1214 unsigned int ass
, tmp
, i
;
1216 struct alc_spec
*spec
= codec
->spec
;
1218 spec
->cdefine
.enable_pcbeep
= 1; /* assume always enabled */
1220 if (spec
->cdefine
.fixup
) {
1221 ass
= spec
->cdefine
.sku_cfg
;
1222 if (ass
== ALC_FIXUP_SKU_IGNORE
)
1227 ass
= codec
->subsystem_id
& 0xffff;
1228 if (ass
!= codec
->bus
->pci
->subsystem_device
&& (ass
& 1))
1232 if (codec
->vendor_id
== 0x10ec0260)
1234 ass
= snd_hda_codec_get_pincfg(codec
, nid
);
1237 printk(KERN_INFO
"hda_codec: %s: SKU not ready 0x%08x\n",
1238 codec
->chip_name
, ass
);
1244 for (i
= 1; i
< 16; i
++) {
1248 if (((ass
>> 16) & 0xf) != tmp
)
1251 spec
->cdefine
.port_connectivity
= ass
>> 30;
1252 spec
->cdefine
.enable_pcbeep
= (ass
& 0x100000) >> 20;
1253 spec
->cdefine
.check_sum
= (ass
>> 16) & 0xf;
1254 spec
->cdefine
.customization
= ass
>> 8;
1256 spec
->cdefine
.sku_cfg
= ass
;
1257 spec
->cdefine
.external_amp
= (ass
& 0x38) >> 3;
1258 spec
->cdefine
.platform_type
= (ass
& 0x4) >> 2;
1259 spec
->cdefine
.swap
= (ass
& 0x2) >> 1;
1260 spec
->cdefine
.override
= ass
& 0x1;
1262 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1263 nid
, spec
->cdefine
.sku_cfg
);
1264 snd_printd("SKU: port_connectivity=0x%x\n",
1265 spec
->cdefine
.port_connectivity
);
1266 snd_printd("SKU: enable_pcbeep=0x%x\n", spec
->cdefine
.enable_pcbeep
);
1267 snd_printd("SKU: check_sum=0x%08x\n", spec
->cdefine
.check_sum
);
1268 snd_printd("SKU: customization=0x%08x\n", spec
->cdefine
.customization
);
1269 snd_printd("SKU: external_amp=0x%x\n", spec
->cdefine
.external_amp
);
1270 snd_printd("SKU: platform_type=0x%x\n", spec
->cdefine
.platform_type
);
1271 snd_printd("SKU: swap=0x%x\n", spec
->cdefine
.swap
);
1272 snd_printd("SKU: override=0x%x\n", spec
->cdefine
.override
);
1277 /* return true if the given NID is found in the list */
1278 static bool found_in_nid_list(hda_nid_t nid
, const hda_nid_t
*list
, int nums
)
1280 return find_idx_in_nid_list(nid
, list
, nums
) >= 0;
1283 /* check subsystem ID and set up device-specific initialization;
1284 * return 1 if initialized, 0 if invalid SSID
1286 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1287 * 31 ~ 16 : Manufacture ID
1289 * 7 ~ 0 : Assembly ID
1290 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1292 static int alc_subsystem_id(struct hda_codec
*codec
,
1293 hda_nid_t porta
, hda_nid_t porte
,
1294 hda_nid_t portd
, hda_nid_t porti
)
1296 unsigned int ass
, tmp
, i
;
1298 struct alc_spec
*spec
= codec
->spec
;
1300 if (spec
->cdefine
.fixup
) {
1301 ass
= spec
->cdefine
.sku_cfg
;
1302 if (ass
== ALC_FIXUP_SKU_IGNORE
)
1307 ass
= codec
->subsystem_id
& 0xffff;
1308 if ((ass
!= codec
->bus
->pci
->subsystem_device
) && (ass
& 1))
1311 /* invalid SSID, check the special NID pin defcfg instead */
1313 * 31~30 : port connectivity
1316 * 19~16 : Check sum (15:1)
1321 if (codec
->vendor_id
== 0x10ec0260)
1323 ass
= snd_hda_codec_get_pincfg(codec
, nid
);
1324 snd_printd("realtek: No valid SSID, "
1325 "checking pincfg 0x%08x for NID 0x%x\n",
1329 if ((ass
>> 30) != 1) /* no physical connection */
1334 for (i
= 1; i
< 16; i
++) {
1338 if (((ass
>> 16) & 0xf) != tmp
)
1341 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1342 ass
& 0xffff, codec
->vendor_id
);
1346 * 2 : 0 --> Desktop, 1 --> Laptop
1347 * 3~5 : External Amplifier control
1350 tmp
= (ass
& 0x38) >> 3; /* external Amp control */
1353 spec
->init_amp
= ALC_INIT_GPIO1
;
1356 spec
->init_amp
= ALC_INIT_GPIO2
;
1359 spec
->init_amp
= ALC_INIT_GPIO3
;
1363 spec
->init_amp
= ALC_INIT_DEFAULT
;
1367 /* is laptop or Desktop and enable the function "Mute internal speaker
1368 * when the external headphone out jack is plugged"
1370 if (!(ass
& 0x8000))
1373 * 10~8 : Jack location
1374 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1376 * 15 : 1 --> enable the function "Mute internal speaker
1377 * when the external headphone out jack is plugged"
1379 if (!spec
->autocfg
.hp_pins
[0] &&
1380 !(spec
->autocfg
.line_out_pins
[0] &&
1381 spec
->autocfg
.line_out_type
== AUTO_PIN_HP_OUT
)) {
1383 tmp
= (ass
>> 11) & 0x3; /* HP to chassis */
1394 if (found_in_nid_list(nid
, spec
->autocfg
.line_out_pins
,
1395 spec
->autocfg
.line_outs
))
1397 spec
->autocfg
.hp_pins
[0] = nid
;
1402 /* Check the validity of ALC subsystem-id
1403 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
1404 static void alc_ssid_check(struct hda_codec
*codec
, const hda_nid_t
*ports
)
1406 if (!alc_subsystem_id(codec
, ports
[0], ports
[1], ports
[2], ports
[3])) {
1407 struct alc_spec
*spec
= codec
->spec
;
1408 snd_printd("realtek: "
1409 "Enable default setup for auto mode as fallback\n");
1410 spec
->init_amp
= ALC_INIT_DEFAULT
;
1415 * Fix-up pin default configurations and add default verbs
1423 struct alc_model_fixup
{
1434 const struct alc_pincfg
*pins
;
1435 const struct hda_verb
*verbs
;
1436 void (*func
)(struct hda_codec
*codec
,
1437 const struct alc_fixup
*fix
,
1451 ALC_FIXUP_ACT_PRE_PROBE
,
1452 ALC_FIXUP_ACT_PROBE
,
1456 static void alc_apply_fixup(struct hda_codec
*codec
, int action
)
1458 struct alc_spec
*spec
= codec
->spec
;
1459 int id
= spec
->fixup_id
;
1460 #ifdef CONFIG_SND_DEBUG_VERBOSE
1461 const char *modelname
= spec
->fixup_name
;
1465 if (!spec
->fixup_list
)
1469 const struct alc_fixup
*fix
= spec
->fixup_list
+ id
;
1470 const struct alc_pincfg
*cfg
;
1472 switch (fix
->type
) {
1474 if (action
!= ALC_FIXUP_ACT_PRE_PROBE
|| !fix
->v
.sku
)
1476 snd_printdd(KERN_INFO
"hda_codec: %s: "
1477 "Apply sku override for %s\n",
1478 codec
->chip_name
, modelname
);
1479 spec
->cdefine
.sku_cfg
= fix
->v
.sku
;
1480 spec
->cdefine
.fixup
= 1;
1482 case ALC_FIXUP_PINS
:
1484 if (action
!= ALC_FIXUP_ACT_PRE_PROBE
|| !cfg
)
1486 snd_printdd(KERN_INFO
"hda_codec: %s: "
1487 "Apply pincfg for %s\n",
1488 codec
->chip_name
, modelname
);
1489 for (; cfg
->nid
; cfg
++)
1490 snd_hda_codec_set_pincfg(codec
, cfg
->nid
,
1493 case ALC_FIXUP_VERBS
:
1494 if (action
!= ALC_FIXUP_ACT_PROBE
|| !fix
->v
.verbs
)
1496 snd_printdd(KERN_INFO
"hda_codec: %s: "
1497 "Apply fix-verbs for %s\n",
1498 codec
->chip_name
, modelname
);
1499 add_verb(codec
->spec
, fix
->v
.verbs
);
1501 case ALC_FIXUP_FUNC
:
1504 snd_printdd(KERN_INFO
"hda_codec: %s: "
1505 "Apply fix-func for %s\n",
1506 codec
->chip_name
, modelname
);
1507 fix
->v
.func(codec
, fix
, action
);
1510 snd_printk(KERN_ERR
"hda_codec: %s: "
1511 "Invalid fixup type %d\n",
1512 codec
->chip_name
, fix
->type
);
1523 static void alc_pick_fixup(struct hda_codec
*codec
,
1524 const struct alc_model_fixup
*models
,
1525 const struct snd_pci_quirk
*quirk
,
1526 const struct alc_fixup
*fixlist
)
1528 struct alc_spec
*spec
= codec
->spec
;
1529 const struct snd_pci_quirk
*q
;
1531 const char *name
= NULL
;
1533 if (codec
->modelname
&& models
) {
1534 while (models
->name
) {
1535 if (!strcmp(codec
->modelname
, models
->name
)) {
1537 name
= models
->name
;
1544 q
= snd_pci_quirk_lookup(codec
->bus
->pci
, quirk
);
1547 #ifdef CONFIG_SND_DEBUG_VERBOSE
1553 for (q
= quirk
; q
->subvendor
; q
++) {
1554 unsigned int vendorid
=
1555 q
->subdevice
| (q
->subvendor
<< 16);
1556 if (vendorid
== codec
->subsystem_id
) {
1558 #ifdef CONFIG_SND_DEBUG_VERBOSE
1566 spec
->fixup_id
= id
;
1568 spec
->fixup_list
= fixlist
;
1569 spec
->fixup_name
= name
;
1574 * COEF access helper functions
1576 static int alc_read_coef_idx(struct hda_codec
*codec
,
1577 unsigned int coef_idx
)
1580 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
,
1582 val
= snd_hda_codec_read(codec
, 0x20, 0,
1583 AC_VERB_GET_PROC_COEF
, 0);
1587 static void alc_write_coef_idx(struct hda_codec
*codec
, unsigned int coef_idx
,
1588 unsigned int coef_val
)
1590 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_COEF_INDEX
,
1592 snd_hda_codec_write(codec
, 0x20, 0, AC_VERB_SET_PROC_COEF
,
1596 /* a special bypass for COEF 0; read the cached value at the second time */
1597 static unsigned int alc_get_coef0(struct hda_codec
*codec
)
1599 struct alc_spec
*spec
= codec
->spec
;
1601 spec
->coef0
= alc_read_coef_idx(codec
, 0);
1606 * Digital I/O handling
1609 /* set right pin controls for digital I/O */
1610 static void alc_auto_init_digital(struct hda_codec
*codec
)
1612 struct alc_spec
*spec
= codec
->spec
;
1616 for (i
= 0; i
< spec
->autocfg
.dig_outs
; i
++) {
1617 pin
= spec
->autocfg
.dig_out_pins
[i
];
1620 snd_hda_codec_write(codec
, pin
, 0,
1621 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
);
1623 dac
= spec
->multiout
.dig_out_nid
;
1625 dac
= spec
->slave_dig_outs
[i
- 1];
1626 if (!dac
|| !(get_wcaps(codec
, dac
) & AC_WCAP_OUT_AMP
))
1628 snd_hda_codec_write(codec
, dac
, 0,
1629 AC_VERB_SET_AMP_GAIN_MUTE
,
1632 pin
= spec
->autocfg
.dig_in_pin
;
1634 snd_hda_codec_write(codec
, pin
, 0,
1635 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1639 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1640 static void alc_auto_parse_digital(struct hda_codec
*codec
)
1642 struct alc_spec
*spec
= codec
->spec
;
1646 /* support multiple SPDIFs; the secondary is set up as a slave */
1648 for (i
= 0; i
< spec
->autocfg
.dig_outs
; i
++) {
1650 err
= snd_hda_get_connections(codec
,
1651 spec
->autocfg
.dig_out_pins
[i
],
1652 conn
, ARRAY_SIZE(conn
));
1655 dig_nid
= conn
[0]; /* assume the first element is audio-out */
1657 spec
->multiout
.dig_out_nid
= dig_nid
;
1658 spec
->dig_out_type
= spec
->autocfg
.dig_out_type
[0];
1660 spec
->multiout
.slave_dig_outs
= spec
->slave_dig_outs
;
1661 if (nums
>= ARRAY_SIZE(spec
->slave_dig_outs
) - 1)
1663 spec
->slave_dig_outs
[nums
- 1] = dig_nid
;
1668 if (spec
->autocfg
.dig_in_pin
) {
1669 dig_nid
= codec
->start_nid
;
1670 for (i
= 0; i
< codec
->num_nodes
; i
++, dig_nid
++) {
1671 unsigned int wcaps
= get_wcaps(codec
, dig_nid
);
1672 if (get_wcaps_type(wcaps
) != AC_WID_AUD_IN
)
1674 if (!(wcaps
& AC_WCAP_DIGITAL
))
1676 if (!(wcaps
& AC_WCAP_CONN_LIST
))
1678 err
= get_connection_index(codec
, dig_nid
,
1679 spec
->autocfg
.dig_in_pin
);
1681 spec
->dig_in_nid
= dig_nid
;
1689 * capture mixer elements
1691 static int alc_cap_vol_info(struct snd_kcontrol
*kcontrol
,
1692 struct snd_ctl_elem_info
*uinfo
)
1694 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1695 struct alc_spec
*spec
= codec
->spec
;
1699 mutex_lock(&codec
->control_mutex
);
1700 if (spec
->vol_in_capsrc
)
1701 val
= HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[0], 3, 0, HDA_OUTPUT
);
1703 val
= HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[0], 3, 0, HDA_INPUT
);
1704 kcontrol
->private_value
= val
;
1705 err
= snd_hda_mixer_amp_volume_info(kcontrol
, uinfo
);
1706 mutex_unlock(&codec
->control_mutex
);
1710 static int alc_cap_vol_tlv(struct snd_kcontrol
*kcontrol
, int op_flag
,
1711 unsigned int size
, unsigned int __user
*tlv
)
1713 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1714 struct alc_spec
*spec
= codec
->spec
;
1718 mutex_lock(&codec
->control_mutex
);
1719 if (spec
->vol_in_capsrc
)
1720 val
= HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[0], 3, 0, HDA_OUTPUT
);
1722 val
= HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[0], 3, 0, HDA_INPUT
);
1723 kcontrol
->private_value
= val
;
1724 err
= snd_hda_mixer_amp_tlv(kcontrol
, op_flag
, size
, tlv
);
1725 mutex_unlock(&codec
->control_mutex
);
1729 typedef int (*getput_call_t
)(struct snd_kcontrol
*kcontrol
,
1730 struct snd_ctl_elem_value
*ucontrol
);
1732 static int alc_cap_getput_caller(struct snd_kcontrol
*kcontrol
,
1733 struct snd_ctl_elem_value
*ucontrol
,
1734 getput_call_t func
, bool check_adc_switch
)
1736 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1737 struct alc_spec
*spec
= codec
->spec
;
1740 mutex_lock(&codec
->control_mutex
);
1741 if (check_adc_switch
&& spec
->dyn_adc_switch
) {
1742 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
1743 kcontrol
->private_value
=
1744 HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[i
],
1746 err
= func(kcontrol
, ucontrol
);
1751 i
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
1752 if (spec
->vol_in_capsrc
)
1753 kcontrol
->private_value
=
1754 HDA_COMPOSE_AMP_VAL(spec
->capsrc_nids
[i
],
1757 kcontrol
->private_value
=
1758 HDA_COMPOSE_AMP_VAL(spec
->adc_nids
[i
],
1760 err
= func(kcontrol
, ucontrol
);
1763 mutex_unlock(&codec
->control_mutex
);
1767 static int alc_cap_vol_get(struct snd_kcontrol
*kcontrol
,
1768 struct snd_ctl_elem_value
*ucontrol
)
1770 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1771 snd_hda_mixer_amp_volume_get
, false);
1774 static int alc_cap_vol_put(struct snd_kcontrol
*kcontrol
,
1775 struct snd_ctl_elem_value
*ucontrol
)
1777 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1778 snd_hda_mixer_amp_volume_put
, true);
1781 /* capture mixer elements */
1782 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1784 static int alc_cap_sw_get(struct snd_kcontrol
*kcontrol
,
1785 struct snd_ctl_elem_value
*ucontrol
)
1787 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1788 snd_hda_mixer_amp_switch_get
, false);
1791 static int alc_cap_sw_put(struct snd_kcontrol
*kcontrol
,
1792 struct snd_ctl_elem_value
*ucontrol
)
1794 return alc_cap_getput_caller(kcontrol
, ucontrol
,
1795 snd_hda_mixer_amp_switch_put
, true);
1798 #define _DEFINE_CAPMIX(num) \
1800 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1801 .name = "Capture Switch", \
1802 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1804 .info = alc_cap_sw_info, \
1805 .get = alc_cap_sw_get, \
1806 .put = alc_cap_sw_put, \
1809 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1810 .name = "Capture Volume", \
1811 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1812 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1813 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1815 .info = alc_cap_vol_info, \
1816 .get = alc_cap_vol_get, \
1817 .put = alc_cap_vol_put, \
1818 .tlv = { .c = alc_cap_vol_tlv }, \
1821 #define _DEFINE_CAPSRC(num) \
1823 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1824 /* .name = "Capture Source", */ \
1825 .name = "Input Source", \
1827 .info = alc_mux_enum_info, \
1828 .get = alc_mux_enum_get, \
1829 .put = alc_mux_enum_put, \
1832 #define DEFINE_CAPMIX(num) \
1833 static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1834 _DEFINE_CAPMIX(num), \
1835 _DEFINE_CAPSRC(num), \
1839 #define DEFINE_CAPMIX_NOSRC(num) \
1840 static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1841 _DEFINE_CAPMIX(num), \
1845 /* up to three ADCs */
1849 DEFINE_CAPMIX_NOSRC(1);
1850 DEFINE_CAPMIX_NOSRC(2);
1851 DEFINE_CAPMIX_NOSRC(3);
1854 * virtual master controls
1858 * slave controls for virtual master
1860 static const char * const alc_slave_vols
[] = {
1861 "Front Playback Volume",
1862 "Surround Playback Volume",
1863 "Center Playback Volume",
1864 "LFE Playback Volume",
1865 "Side Playback Volume",
1866 "Headphone Playback Volume",
1867 "Speaker Playback Volume",
1868 "Mono Playback Volume",
1869 "Line-Out Playback Volume",
1870 "PCM Playback Volume",
1874 static const char * const alc_slave_sws
[] = {
1875 "Front Playback Switch",
1876 "Surround Playback Switch",
1877 "Center Playback Switch",
1878 "LFE Playback Switch",
1879 "Side Playback Switch",
1880 "Headphone Playback Switch",
1881 "Speaker Playback Switch",
1882 "Mono Playback Switch",
1883 "IEC958 Playback Switch",
1884 "Line-Out Playback Switch",
1885 "PCM Playback Switch",
1890 * build control elements
1893 #define NID_MAPPING (-1)
1895 #define SUBDEV_SPEAKER_ (0 << 6)
1896 #define SUBDEV_HP_ (1 << 6)
1897 #define SUBDEV_LINE_ (2 << 6)
1898 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
1899 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
1900 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
1902 static void alc_free_kctls(struct hda_codec
*codec
);
1904 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1905 /* additional beep mixers; the actual parameters are overwritten at build */
1906 static const struct snd_kcontrol_new alc_beep_mixer
[] = {
1907 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT
),
1908 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT
),
1913 static int alc_build_controls(struct hda_codec
*codec
)
1915 struct alc_spec
*spec
= codec
->spec
;
1916 struct snd_kcontrol
*kctl
= NULL
;
1917 const struct snd_kcontrol_new
*knew
;
1922 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1923 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
1927 if (spec
->cap_mixer
) {
1928 err
= snd_hda_add_new_ctls(codec
, spec
->cap_mixer
);
1932 if (spec
->multiout
.dig_out_nid
) {
1933 err
= snd_hda_create_spdif_out_ctls(codec
,
1934 spec
->multiout
.dig_out_nid
,
1935 spec
->multiout
.dig_out_nid
);
1938 if (!spec
->no_analog
) {
1939 err
= snd_hda_create_spdif_share_sw(codec
,
1943 spec
->multiout
.share_spdif
= 1;
1946 if (spec
->dig_in_nid
) {
1947 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
1952 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1953 /* create beep controls if needed */
1954 if (spec
->beep_amp
) {
1955 const struct snd_kcontrol_new
*knew
;
1956 for (knew
= alc_beep_mixer
; knew
->name
; knew
++) {
1957 struct snd_kcontrol
*kctl
;
1958 kctl
= snd_ctl_new1(knew
, codec
);
1961 kctl
->private_value
= spec
->beep_amp
;
1962 err
= snd_hda_ctl_add(codec
, 0, kctl
);
1969 /* if we have no master control, let's create it */
1970 if (!spec
->no_analog
&&
1971 !snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
1972 unsigned int vmaster_tlv
[4];
1973 snd_hda_set_vmaster_tlv(codec
, spec
->vmaster_nid
,
1974 HDA_OUTPUT
, vmaster_tlv
);
1975 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
1976 vmaster_tlv
, alc_slave_vols
);
1980 if (!spec
->no_analog
&&
1981 !snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
1982 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
1983 NULL
, alc_slave_sws
);
1988 /* assign Capture Source enums to NID */
1989 if (spec
->capsrc_nids
|| spec
->adc_nids
) {
1990 kctl
= snd_hda_find_mixer_ctl(codec
, "Capture Source");
1992 kctl
= snd_hda_find_mixer_ctl(codec
, "Input Source");
1993 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
1994 const hda_nid_t
*nids
= spec
->capsrc_nids
;
1996 nids
= spec
->adc_nids
;
1997 err
= snd_hda_add_nid(codec
, kctl
, i
, nids
[i
]);
2002 if (spec
->cap_mixer
&& spec
->adc_nids
) {
2003 const char *kname
= kctl
? kctl
->id
.name
: NULL
;
2004 for (knew
= spec
->cap_mixer
; knew
->name
; knew
++) {
2005 if (kname
&& strcmp(knew
->name
, kname
) == 0)
2007 kctl
= snd_hda_find_mixer_ctl(codec
, knew
->name
);
2008 for (i
= 0; kctl
&& i
< kctl
->count
; i
++) {
2009 err
= snd_hda_add_nid(codec
, kctl
, i
,
2017 /* other nid->control mapping */
2018 for (i
= 0; i
< spec
->num_mixers
; i
++) {
2019 for (knew
= spec
->mixers
[i
]; knew
->name
; knew
++) {
2020 if (knew
->iface
!= NID_MAPPING
)
2022 kctl
= snd_hda_find_mixer_ctl(codec
, knew
->name
);
2025 u
= knew
->subdevice
;
2026 for (j
= 0; j
< 4; j
++, u
>>= 8) {
2031 case SUBDEV_SPEAKER_
:
2032 nid
= spec
->autocfg
.speaker_pins
[nid
];
2035 nid
= spec
->autocfg
.line_out_pins
[nid
];
2038 nid
= spec
->autocfg
.hp_pins
[nid
];
2043 err
= snd_hda_add_nid(codec
, kctl
, 0, nid
);
2047 u
= knew
->private_value
;
2048 for (j
= 0; j
< 4; j
++, u
>>= 8) {
2052 err
= snd_hda_add_nid(codec
, kctl
, 0, nid
);
2059 alc_free_kctls(codec
); /* no longer needed */
2069 static void alc_init_special_input_src(struct hda_codec
*codec
);
2071 static int alc_init(struct hda_codec
*codec
)
2073 struct alc_spec
*spec
= codec
->spec
;
2077 alc_auto_init_amp(codec
, spec
->init_amp
);
2079 for (i
= 0; i
< spec
->num_init_verbs
; i
++)
2080 snd_hda_sequence_write(codec
, spec
->init_verbs
[i
]);
2081 alc_init_special_input_src(codec
);
2083 if (spec
->init_hook
)
2084 spec
->init_hook(codec
);
2086 alc_apply_fixup(codec
, ALC_FIXUP_ACT_INIT
);
2088 hda_call_check_power_status(codec
, 0x01);
2092 static void alc_unsol_event(struct hda_codec
*codec
, unsigned int res
)
2094 struct alc_spec
*spec
= codec
->spec
;
2096 if (spec
->unsol_event
)
2097 spec
->unsol_event(codec
, res
);
2100 #ifdef CONFIG_SND_HDA_POWER_SAVE
2101 static int alc_check_power_status(struct hda_codec
*codec
, hda_nid_t nid
)
2103 struct alc_spec
*spec
= codec
->spec
;
2104 return snd_hda_check_amp_list_power(codec
, &spec
->loopback
, nid
);
2109 * Analog playback callbacks
2111 static int alc_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2112 struct hda_codec
*codec
,
2113 struct snd_pcm_substream
*substream
)
2115 struct alc_spec
*spec
= codec
->spec
;
2116 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
2120 static int alc_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2121 struct hda_codec
*codec
,
2122 unsigned int stream_tag
,
2123 unsigned int format
,
2124 struct snd_pcm_substream
*substream
)
2126 struct alc_spec
*spec
= codec
->spec
;
2127 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
,
2128 stream_tag
, format
, substream
);
2131 static int alc_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2132 struct hda_codec
*codec
,
2133 struct snd_pcm_substream
*substream
)
2135 struct alc_spec
*spec
= codec
->spec
;
2136 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
2142 static int alc_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2143 struct hda_codec
*codec
,
2144 struct snd_pcm_substream
*substream
)
2146 struct alc_spec
*spec
= codec
->spec
;
2147 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
2150 static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2151 struct hda_codec
*codec
,
2152 unsigned int stream_tag
,
2153 unsigned int format
,
2154 struct snd_pcm_substream
*substream
)
2156 struct alc_spec
*spec
= codec
->spec
;
2157 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
2158 stream_tag
, format
, substream
);
2161 static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2162 struct hda_codec
*codec
,
2163 struct snd_pcm_substream
*substream
)
2165 struct alc_spec
*spec
= codec
->spec
;
2166 return snd_hda_multi_out_dig_cleanup(codec
, &spec
->multiout
);
2169 static int alc_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
2170 struct hda_codec
*codec
,
2171 struct snd_pcm_substream
*substream
)
2173 struct alc_spec
*spec
= codec
->spec
;
2174 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
2180 static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2181 struct hda_codec
*codec
,
2182 unsigned int stream_tag
,
2183 unsigned int format
,
2184 struct snd_pcm_substream
*substream
)
2186 struct alc_spec
*spec
= codec
->spec
;
2188 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
+ 1],
2189 stream_tag
, 0, format
);
2193 static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2194 struct hda_codec
*codec
,
2195 struct snd_pcm_substream
*substream
)
2197 struct alc_spec
*spec
= codec
->spec
;
2199 snd_hda_codec_cleanup_stream(codec
,
2200 spec
->adc_nids
[substream
->number
+ 1]);
2204 /* analog capture with dynamic dual-adc changes */
2205 static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2206 struct hda_codec
*codec
,
2207 unsigned int stream_tag
,
2208 unsigned int format
,
2209 struct snd_pcm_substream
*substream
)
2211 struct alc_spec
*spec
= codec
->spec
;
2212 spec
->cur_adc
= spec
->adc_nids
[spec
->dyn_adc_idx
[spec
->cur_mux
[0]]];
2213 spec
->cur_adc_stream_tag
= stream_tag
;
2214 spec
->cur_adc_format
= format
;
2215 snd_hda_codec_setup_stream(codec
, spec
->cur_adc
, stream_tag
, 0, format
);
2219 static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2220 struct hda_codec
*codec
,
2221 struct snd_pcm_substream
*substream
)
2223 struct alc_spec
*spec
= codec
->spec
;
2224 snd_hda_codec_cleanup_stream(codec
, spec
->cur_adc
);
2229 static const struct hda_pcm_stream dyn_adc_pcm_analog_capture
= {
2233 .nid
= 0, /* fill later */
2235 .prepare
= dyn_adc_capture_pcm_prepare
,
2236 .cleanup
= dyn_adc_capture_pcm_cleanup
2242 static const struct hda_pcm_stream alc_pcm_analog_playback
= {
2246 /* NID is set in alc_build_pcms */
2248 .open
= alc_playback_pcm_open
,
2249 .prepare
= alc_playback_pcm_prepare
,
2250 .cleanup
= alc_playback_pcm_cleanup
2254 static const struct hda_pcm_stream alc_pcm_analog_capture
= {
2258 /* NID is set in alc_build_pcms */
2261 static const struct hda_pcm_stream alc_pcm_analog_alt_playback
= {
2265 /* NID is set in alc_build_pcms */
2268 static const struct hda_pcm_stream alc_pcm_analog_alt_capture
= {
2269 .substreams
= 2, /* can be overridden */
2272 /* NID is set in alc_build_pcms */
2274 .prepare
= alc_alt_capture_pcm_prepare
,
2275 .cleanup
= alc_alt_capture_pcm_cleanup
2279 static const struct hda_pcm_stream alc_pcm_digital_playback
= {
2283 /* NID is set in alc_build_pcms */
2285 .open
= alc_dig_playback_pcm_open
,
2286 .close
= alc_dig_playback_pcm_close
,
2287 .prepare
= alc_dig_playback_pcm_prepare
,
2288 .cleanup
= alc_dig_playback_pcm_cleanup
2292 static const struct hda_pcm_stream alc_pcm_digital_capture
= {
2296 /* NID is set in alc_build_pcms */
2299 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2300 static const struct hda_pcm_stream alc_pcm_null_stream
= {
2306 static int alc_build_pcms(struct hda_codec
*codec
)
2308 struct alc_spec
*spec
= codec
->spec
;
2309 struct hda_pcm
*info
= spec
->pcm_rec
;
2310 const struct hda_pcm_stream
*p
;
2311 bool have_multi_adcs
;
2314 codec
->num_pcms
= 1;
2315 codec
->pcm_info
= info
;
2317 if (spec
->no_analog
)
2320 snprintf(spec
->stream_name_analog
, sizeof(spec
->stream_name_analog
),
2321 "%s Analog", codec
->chip_name
);
2322 info
->name
= spec
->stream_name_analog
;
2324 if (spec
->multiout
.dac_nids
> 0) {
2325 p
= spec
->stream_analog_playback
;
2327 p
= &alc_pcm_analog_playback
;
2328 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2329 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dac_nids
[0];
2331 if (spec
->adc_nids
) {
2332 p
= spec
->stream_analog_capture
;
2334 if (spec
->dyn_adc_switch
)
2335 p
= &dyn_adc_pcm_analog_capture
;
2337 p
= &alc_pcm_analog_capture
;
2339 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2340 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
2343 if (spec
->channel_mode
) {
2344 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= 0;
2345 for (i
= 0; i
< spec
->num_channel_mode
; i
++) {
2346 if (spec
->channel_mode
[i
].channels
> info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
) {
2347 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].channels_max
= spec
->channel_mode
[i
].channels
;
2353 /* SPDIF for stream index #1 */
2354 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
2355 snprintf(spec
->stream_name_digital
,
2356 sizeof(spec
->stream_name_digital
),
2357 "%s Digital", codec
->chip_name
);
2358 codec
->num_pcms
= 2;
2359 codec
->slave_dig_outs
= spec
->multiout
.slave_dig_outs
;
2360 info
= spec
->pcm_rec
+ 1;
2361 info
->name
= spec
->stream_name_digital
;
2362 if (spec
->dig_out_type
)
2363 info
->pcm_type
= spec
->dig_out_type
;
2365 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
2366 if (spec
->multiout
.dig_out_nid
) {
2367 p
= spec
->stream_digital_playback
;
2369 p
= &alc_pcm_digital_playback
;
2370 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2371 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
2373 if (spec
->dig_in_nid
) {
2374 p
= spec
->stream_digital_capture
;
2376 p
= &alc_pcm_digital_capture
;
2377 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2378 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
2380 /* FIXME: do we need this for all Realtek codec models? */
2381 codec
->spdif_status_reset
= 1;
2384 if (spec
->no_analog
)
2387 /* If the use of more than one ADC is requested for the current
2388 * model, configure a second analog capture-only PCM.
2390 have_multi_adcs
= (spec
->num_adc_nids
> 1) &&
2391 !spec
->dyn_adc_switch
&& !spec
->auto_mic
&&
2392 (!spec
->input_mux
|| spec
->input_mux
->num_items
> 1);
2393 /* Additional Analaog capture for index #2 */
2394 if (spec
->alt_dac_nid
|| have_multi_adcs
) {
2395 codec
->num_pcms
= 3;
2396 info
= spec
->pcm_rec
+ 2;
2397 info
->name
= spec
->stream_name_analog
;
2398 if (spec
->alt_dac_nid
) {
2399 p
= spec
->stream_analog_alt_playback
;
2401 p
= &alc_pcm_analog_alt_playback
;
2402 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = *p
;
2403 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
2406 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] =
2407 alc_pcm_null_stream
;
2408 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= 0;
2410 if (have_multi_adcs
) {
2411 p
= spec
->stream_analog_alt_capture
;
2413 p
= &alc_pcm_analog_alt_capture
;
2414 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = *p
;
2415 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
=
2417 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
=
2418 spec
->num_adc_nids
- 1;
2420 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] =
2421 alc_pcm_null_stream
;
2422 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= 0;
2429 static inline void alc_shutup(struct hda_codec
*codec
)
2431 struct alc_spec
*spec
= codec
->spec
;
2433 if (spec
&& spec
->shutup
)
2434 spec
->shutup(codec
);
2435 snd_hda_shutup_pins(codec
);
2438 static void alc_free_kctls(struct hda_codec
*codec
)
2440 struct alc_spec
*spec
= codec
->spec
;
2442 if (spec
->kctls
.list
) {
2443 struct snd_kcontrol_new
*kctl
= spec
->kctls
.list
;
2445 for (i
= 0; i
< spec
->kctls
.used
; i
++)
2446 kfree(kctl
[i
].name
);
2448 snd_array_free(&spec
->kctls
);
2451 static void alc_free_bind_ctls(struct hda_codec
*codec
)
2453 struct alc_spec
*spec
= codec
->spec
;
2454 if (spec
->bind_ctls
.list
) {
2455 struct hda_bind_ctls
**ctl
= spec
->bind_ctls
.list
;
2457 for (i
= 0; i
< spec
->bind_ctls
.used
; i
++)
2460 snd_array_free(&spec
->bind_ctls
);
2463 static void alc_free(struct hda_codec
*codec
)
2465 struct alc_spec
*spec
= codec
->spec
;
2471 snd_hda_input_jack_free(codec
);
2472 alc_free_kctls(codec
);
2473 alc_free_bind_ctls(codec
);
2475 snd_hda_detach_beep_device(codec
);
2478 #ifdef CONFIG_SND_HDA_POWER_SAVE
2479 static void alc_power_eapd(struct hda_codec
*codec
)
2481 alc_auto_setup_eapd(codec
, false);
2484 static int alc_suspend(struct hda_codec
*codec
, pm_message_t state
)
2486 struct alc_spec
*spec
= codec
->spec
;
2488 if (spec
&& spec
->power_hook
)
2489 spec
->power_hook(codec
);
2495 static int alc_resume(struct hda_codec
*codec
)
2497 msleep(150); /* to avoid pop noise */
2498 codec
->patch_ops
.init(codec
);
2499 snd_hda_codec_resume_amp(codec
);
2500 snd_hda_codec_resume_cache(codec
);
2501 hda_call_check_power_status(codec
, 0x01);
2508 static const struct hda_codec_ops alc_patch_ops
= {
2509 .build_controls
= alc_build_controls
,
2510 .build_pcms
= alc_build_pcms
,
2513 .unsol_event
= alc_unsol_event
,
2515 .resume
= alc_resume
,
2517 #ifdef CONFIG_SND_HDA_POWER_SAVE
2518 .suspend
= alc_suspend
,
2519 .check_power_status
= alc_check_power_status
,
2521 .reboot_notify
= alc_shutup
,
2524 /* replace the codec chip_name with the given string */
2525 static int alc_codec_rename(struct hda_codec
*codec
, const char *name
)
2527 kfree(codec
->chip_name
);
2528 codec
->chip_name
= kstrdup(name
, GFP_KERNEL
);
2529 if (!codec
->chip_name
) {
2537 * Rename codecs appropriately from COEF value
2539 struct alc_codec_rename_table
{
2540 unsigned int vendor_id
;
2541 unsigned short coef_mask
;
2542 unsigned short coef_bits
;
2546 static struct alc_codec_rename_table rename_tbl
[] = {
2547 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
2548 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
2549 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
2550 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
2551 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
2552 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
2553 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
2554 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
2555 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
2556 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
2557 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
2558 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
2559 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
2560 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
2561 { } /* terminator */
2564 static int alc_codec_rename_from_preset(struct hda_codec
*codec
)
2566 const struct alc_codec_rename_table
*p
;
2568 for (p
= rename_tbl
; p
->vendor_id
; p
++) {
2569 if (p
->vendor_id
!= codec
->vendor_id
)
2571 if ((alc_get_coef0(codec
) & p
->coef_mask
) == p
->coef_bits
)
2572 return alc_codec_rename(codec
, p
->name
);
2578 * Automatic parse of I/O pins from the BIOS configuration
2583 ALC_CTL_WIDGET_MUTE
,
2588 static const struct snd_kcontrol_new alc_control_templates
[] = {
2589 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2590 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2591 HDA_BIND_MUTE(NULL
, 0, 0, 0),
2592 HDA_BIND_VOL(NULL
, 0),
2593 HDA_BIND_SW(NULL
, 0),
2596 /* add dynamic controls */
2597 static int add_control(struct alc_spec
*spec
, int type
, const char *name
,
2598 int cidx
, unsigned long val
)
2600 struct snd_kcontrol_new
*knew
;
2602 knew
= alc_kcontrol_new(spec
);
2605 *knew
= alc_control_templates
[type
];
2606 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2610 if (get_amp_nid_(val
))
2611 knew
->subdevice
= HDA_SUBDEV_AMP_FLAG
;
2612 knew
->private_value
= val
;
2616 static int add_control_with_pfx(struct alc_spec
*spec
, int type
,
2617 const char *pfx
, const char *dir
,
2618 const char *sfx
, int cidx
, unsigned long val
)
2621 snprintf(name
, sizeof(name
), "%s %s %s", pfx
, dir
, sfx
);
2622 return add_control(spec
, type
, name
, cidx
, val
);
2625 #define add_pb_vol_ctrl(spec, type, pfx, val) \
2626 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
2627 #define add_pb_sw_ctrl(spec, type, pfx, val) \
2628 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
2629 #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
2630 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
2631 #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
2632 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
2634 static const char * const channel_name
[4] = {
2635 "Front", "Surround", "CLFE", "Side"
2638 static const char *alc_get_line_out_pfx(struct alc_spec
*spec
, int ch
,
2639 bool can_be_master
, int *index
)
2641 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2644 if (cfg
->line_outs
== 1 && !spec
->multi_ios
&&
2645 !cfg
->hp_outs
&& !cfg
->speaker_outs
&& can_be_master
)
2648 switch (cfg
->line_out_type
) {
2649 case AUTO_PIN_SPEAKER_OUT
:
2650 if (cfg
->line_outs
== 1)
2653 case AUTO_PIN_HP_OUT
:
2654 /* for multi-io case, only the primary out */
2655 if (ch
&& spec
->multi_ios
)
2660 if (cfg
->line_outs
== 1 && !spec
->multi_ios
)
2664 if (snd_BUG_ON(ch
>= ARRAY_SIZE(channel_name
)))
2667 return channel_name
[ch
];
2670 /* create input playback/capture controls for the given pin */
2671 static int new_analog_input(struct alc_spec
*spec
, hda_nid_t pin
,
2672 const char *ctlname
, int ctlidx
,
2673 int idx
, hda_nid_t mix_nid
)
2677 err
= __add_pb_vol_ctrl(spec
, ALC_CTL_WIDGET_VOL
, ctlname
, ctlidx
,
2678 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
));
2681 err
= __add_pb_sw_ctrl(spec
, ALC_CTL_WIDGET_MUTE
, ctlname
, ctlidx
,
2682 HDA_COMPOSE_AMP_VAL(mix_nid
, 3, idx
, HDA_INPUT
));
2688 static int alc_is_input_pin(struct hda_codec
*codec
, hda_nid_t nid
)
2690 unsigned int pincap
= snd_hda_query_pin_caps(codec
, nid
);
2691 return (pincap
& AC_PINCAP_IN
) != 0;
2694 /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */
2695 static int alc_auto_fill_adc_caps(struct hda_codec
*codec
)
2697 struct alc_spec
*spec
= codec
->spec
;
2699 hda_nid_t
*adc_nids
= spec
->private_adc_nids
;
2700 hda_nid_t
*cap_nids
= spec
->private_capsrc_nids
;
2701 int max_nums
= ARRAY_SIZE(spec
->private_adc_nids
);
2704 if (spec
->shared_mic_hp
)
2705 max_nums
= 1; /* no multi streams with the shared HP/mic */
2707 nid
= codec
->start_nid
;
2708 for (i
= 0; i
< codec
->num_nodes
; i
++, nid
++) {
2710 const hda_nid_t
*list
;
2711 unsigned int caps
= get_wcaps(codec
, nid
);
2712 int type
= get_wcaps_type(caps
);
2714 if (type
!= AC_WID_AUD_IN
|| (caps
& AC_WCAP_DIGITAL
))
2716 adc_nids
[nums
] = nid
;
2717 cap_nids
[nums
] = nid
;
2721 type
= get_wcaps_type(get_wcaps(codec
, src
));
2722 if (type
== AC_WID_PIN
)
2724 if (type
== AC_WID_AUD_SEL
) {
2725 cap_nids
[nums
] = src
;
2728 n
= snd_hda_get_conn_list(codec
, src
, &list
);
2730 cap_nids
[nums
] = src
;
2736 if (++nums
>= max_nums
)
2739 spec
->adc_nids
= spec
->private_adc_nids
;
2740 spec
->capsrc_nids
= spec
->private_capsrc_nids
;
2741 spec
->num_adc_nids
= nums
;
2745 /* create playback/capture controls for input pins */
2746 static int alc_auto_create_input_ctls(struct hda_codec
*codec
)
2748 struct alc_spec
*spec
= codec
->spec
;
2749 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2750 hda_nid_t mixer
= spec
->mixer_nid
;
2751 struct hda_input_mux
*imux
= &spec
->private_imux
[0];
2753 int i
, c
, err
, idx
, type_idx
= 0;
2754 const char *prev_label
= NULL
;
2756 num_adcs
= alc_auto_fill_adc_caps(codec
);
2760 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2764 pin
= cfg
->inputs
[i
].pin
;
2765 if (!alc_is_input_pin(codec
, pin
))
2768 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
2769 if (spec
->shared_mic_hp
&& !strcmp(label
, "Misc"))
2770 label
= "Headphone Mic";
2771 if (prev_label
&& !strcmp(label
, prev_label
))
2778 idx
= get_connection_index(codec
, mixer
, pin
);
2780 err
= new_analog_input(spec
, pin
,
2788 for (c
= 0; c
< num_adcs
; c
++) {
2789 hda_nid_t cap
= spec
->capsrc_nids
?
2790 spec
->capsrc_nids
[c
] : spec
->adc_nids
[c
];
2791 idx
= get_connection_index(codec
, cap
, pin
);
2793 spec
->imux_pins
[imux
->num_items
] = pin
;
2794 snd_hda_add_imux_item(imux
, label
, idx
, NULL
);
2800 spec
->num_mux_defs
= 1;
2801 spec
->input_mux
= imux
;
2806 /* create a shared input with the headphone out */
2807 static int alc_auto_create_shared_input(struct hda_codec
*codec
)
2809 struct alc_spec
*spec
= codec
->spec
;
2810 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2811 unsigned int defcfg
;
2814 /* only one internal input pin? */
2815 if (cfg
->num_inputs
!= 1)
2817 defcfg
= snd_hda_codec_get_pincfg(codec
, cfg
->inputs
[0].pin
);
2818 if (snd_hda_get_input_pin_attr(defcfg
) != INPUT_PIN_ATTR_INT
)
2821 if (cfg
->hp_outs
== 1 && cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
)
2822 nid
= cfg
->hp_pins
[0]; /* OK, we have a single HP-out */
2823 else if (cfg
->line_outs
== 1 && cfg
->line_out_type
== AUTO_PIN_HP_OUT
)
2824 nid
= cfg
->line_out_pins
[0]; /* OK, we have a single line-out */
2826 return 0; /* both not available */
2828 if (!(snd_hda_query_pin_caps(codec
, nid
) & AC_PINCAP_IN
))
2829 return 0; /* no input */
2831 cfg
->inputs
[1].pin
= nid
;
2832 cfg
->inputs
[1].type
= AUTO_PIN_MIC
;
2833 cfg
->num_inputs
= 2;
2834 spec
->shared_mic_hp
= 1;
2835 snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid
);
2839 static void alc_set_pin_output(struct hda_codec
*codec
, hda_nid_t nid
,
2840 unsigned int pin_type
)
2842 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
,
2845 if (nid_has_mute(codec
, nid
, HDA_OUTPUT
))
2846 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
2850 static int get_pin_type(int line_out_type
)
2852 if (line_out_type
== AUTO_PIN_HP_OUT
)
2858 static void alc_auto_init_analog_input(struct hda_codec
*codec
)
2860 struct alc_spec
*spec
= codec
->spec
;
2861 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2864 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2865 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
2866 if (alc_is_input_pin(codec
, nid
)) {
2867 alc_set_input_pin(codec
, nid
, cfg
->inputs
[i
].type
);
2868 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
2869 snd_hda_codec_write(codec
, nid
, 0,
2870 AC_VERB_SET_AMP_GAIN_MUTE
,
2875 /* mute all loopback inputs */
2876 if (spec
->mixer_nid
) {
2877 int nums
= snd_hda_get_conn_list(codec
, spec
->mixer_nid
, NULL
);
2878 for (i
= 0; i
< nums
; i
++)
2879 snd_hda_codec_write(codec
, spec
->mixer_nid
, 0,
2880 AC_VERB_SET_AMP_GAIN_MUTE
,
2885 /* convert from MIX nid to DAC */
2886 static hda_nid_t
alc_auto_mix_to_dac(struct hda_codec
*codec
, hda_nid_t nid
)
2891 if (get_wcaps_type(get_wcaps(codec
, nid
)) == AC_WID_AUD_OUT
)
2893 num
= snd_hda_get_connections(codec
, nid
, list
, ARRAY_SIZE(list
));
2894 for (i
= 0; i
< num
; i
++) {
2895 if (get_wcaps_type(get_wcaps(codec
, list
[i
])) == AC_WID_AUD_OUT
)
2901 /* go down to the selector widget before the mixer */
2902 static hda_nid_t
alc_go_down_to_selector(struct hda_codec
*codec
, hda_nid_t pin
)
2905 int num
= snd_hda_get_connections(codec
, pin
, srcs
,
2908 get_wcaps_type(get_wcaps(codec
, srcs
[0])) != AC_WID_AUD_SEL
)
2913 /* get MIX nid connected to the given pin targeted to DAC */
2914 static hda_nid_t
alc_auto_dac_to_mix(struct hda_codec
*codec
, hda_nid_t pin
,
2920 pin
= alc_go_down_to_selector(codec
, pin
);
2921 num
= snd_hda_get_connections(codec
, pin
, mix
, ARRAY_SIZE(mix
));
2922 for (i
= 0; i
< num
; i
++) {
2923 if (alc_auto_mix_to_dac(codec
, mix
[i
]) == dac
)
2929 /* select the connection from pin to DAC if needed */
2930 static int alc_auto_select_dac(struct hda_codec
*codec
, hda_nid_t pin
,
2936 pin
= alc_go_down_to_selector(codec
, pin
);
2937 num
= snd_hda_get_connections(codec
, pin
, mix
, ARRAY_SIZE(mix
));
2940 for (i
= 0; i
< num
; i
++) {
2941 if (alc_auto_mix_to_dac(codec
, mix
[i
]) == dac
) {
2942 snd_hda_codec_update_cache(codec
, pin
, 0,
2943 AC_VERB_SET_CONNECT_SEL
, i
);
2950 /* look for an empty DAC slot */
2951 static hda_nid_t
alc_auto_look_for_dac(struct hda_codec
*codec
, hda_nid_t pin
)
2953 struct alc_spec
*spec
= codec
->spec
;
2957 pin
= alc_go_down_to_selector(codec
, pin
);
2958 num
= snd_hda_get_connections(codec
, pin
, srcs
, ARRAY_SIZE(srcs
));
2959 for (i
= 0; i
< num
; i
++) {
2960 hda_nid_t nid
= alc_auto_mix_to_dac(codec
, srcs
[i
]);
2963 if (found_in_nid_list(nid
, spec
->multiout
.dac_nids
,
2964 spec
->multiout
.num_dacs
))
2966 if (found_in_nid_list(nid
, spec
->multiout
.hp_out_nid
,
2967 ARRAY_SIZE(spec
->multiout
.hp_out_nid
)))
2969 if (found_in_nid_list(nid
, spec
->multiout
.extra_out_nid
,
2970 ARRAY_SIZE(spec
->multiout
.extra_out_nid
)))
2977 static hda_nid_t
get_dac_if_single(struct hda_codec
*codec
, hda_nid_t pin
)
2979 hda_nid_t sel
= alc_go_down_to_selector(codec
, pin
);
2980 if (snd_hda_get_conn_list(codec
, sel
, NULL
) == 1)
2981 return alc_auto_look_for_dac(codec
, pin
);
2985 static int alc_auto_fill_extra_dacs(struct hda_codec
*codec
, int num_outs
,
2986 const hda_nid_t
*pins
, hda_nid_t
*dacs
)
2990 if (num_outs
&& !dacs
[0]) {
2991 dacs
[0] = alc_auto_look_for_dac(codec
, pins
[0]);
2996 for (i
= 1; i
< num_outs
; i
++)
2997 dacs
[i
] = get_dac_if_single(codec
, pins
[i
]);
2998 for (i
= 1; i
< num_outs
; i
++) {
3000 dacs
[i
] = alc_auto_look_for_dac(codec
, pins
[i
]);
3005 static int alc_auto_fill_multi_ios(struct hda_codec
*codec
,
3006 unsigned int location
);
3008 /* fill in the dac_nids table from the parsed pin configuration */
3009 static int alc_auto_fill_dac_nids(struct hda_codec
*codec
)
3011 struct alc_spec
*spec
= codec
->spec
;
3012 const struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3013 bool redone
= false;
3017 /* set num_dacs once to full for alc_auto_look_for_dac() */
3018 spec
->multiout
.num_dacs
= cfg
->line_outs
;
3019 spec
->multiout
.hp_out_nid
[0] = 0;
3020 spec
->multiout
.extra_out_nid
[0] = 0;
3021 memset(spec
->private_dac_nids
, 0, sizeof(spec
->private_dac_nids
));
3022 spec
->multiout
.dac_nids
= spec
->private_dac_nids
;
3024 /* fill hard-wired DACs first */
3026 for (i
= 0; i
< cfg
->line_outs
; i
++)
3027 spec
->private_dac_nids
[i
] =
3028 get_dac_if_single(codec
, cfg
->line_out_pins
[i
]);
3030 spec
->multiout
.hp_out_nid
[0] =
3031 get_dac_if_single(codec
, cfg
->hp_pins
[0]);
3032 if (cfg
->speaker_outs
)
3033 spec
->multiout
.extra_out_nid
[0] =
3034 get_dac_if_single(codec
, cfg
->speaker_pins
[0]);
3037 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3038 hda_nid_t pin
= cfg
->line_out_pins
[i
];
3039 if (spec
->private_dac_nids
[i
])
3041 spec
->private_dac_nids
[i
] = alc_auto_look_for_dac(codec
, pin
);
3042 if (!spec
->private_dac_nids
[i
] && !redone
) {
3043 /* if we can't find primary DACs, re-probe without
3044 * checking the hard-wired DACs
3051 /* re-count num_dacs and squash invalid entries */
3052 spec
->multiout
.num_dacs
= 0;
3053 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3054 if (spec
->private_dac_nids
[i
])
3055 spec
->multiout
.num_dacs
++;
3057 memmove(spec
->private_dac_nids
+ i
,
3058 spec
->private_dac_nids
+ i
+ 1,
3059 sizeof(hda_nid_t
) * (cfg
->line_outs
- i
- 1));
3062 if (cfg
->line_outs
== 1 && cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
) {
3063 /* try to fill multi-io first */
3064 unsigned int location
, defcfg
;
3067 defcfg
= snd_hda_codec_get_pincfg(codec
, cfg
->line_out_pins
[0]);
3068 location
= get_defcfg_location(defcfg
);
3070 num_pins
= alc_auto_fill_multi_ios(codec
, location
);
3072 spec
->multi_ios
= num_pins
;
3073 spec
->ext_channel_count
= 2;
3074 spec
->multiout
.num_dacs
= num_pins
+ 1;
3078 if (cfg
->line_out_type
!= AUTO_PIN_HP_OUT
)
3079 alc_auto_fill_extra_dacs(codec
, cfg
->hp_outs
, cfg
->hp_pins
,
3080 spec
->multiout
.hp_out_nid
);
3081 if (cfg
->line_out_type
!= AUTO_PIN_SPEAKER_OUT
)
3082 alc_auto_fill_extra_dacs(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
,
3083 spec
->multiout
.extra_out_nid
);
3088 static inline unsigned int get_ctl_pos(unsigned int data
)
3090 hda_nid_t nid
= get_amp_nid_(data
);
3091 unsigned int dir
= get_amp_direction_(data
);
3092 return (nid
<< 1) | dir
;
3095 #define is_ctl_used(bits, data) \
3096 test_bit(get_ctl_pos(data), bits)
3097 #define mark_ctl_usage(bits, data) \
3098 set_bit(get_ctl_pos(data), bits)
3100 static int alc_auto_add_vol_ctl(struct hda_codec
*codec
,
3101 const char *pfx
, int cidx
,
3102 hda_nid_t nid
, unsigned int chs
)
3104 struct alc_spec
*spec
= codec
->spec
;
3108 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
);
3109 if (is_ctl_used(spec
->vol_ctls
, val
) && chs
!= 2) /* exclude LFE */
3111 mark_ctl_usage(spec
->vol_ctls
, val
);
3112 return __add_pb_vol_ctrl(codec
->spec
, ALC_CTL_WIDGET_VOL
, pfx
, cidx
,
3116 #define alc_auto_add_stereo_vol(codec, pfx, cidx, nid) \
3117 alc_auto_add_vol_ctl(codec, pfx, cidx, nid, 3)
3119 /* create a mute-switch for the given mixer widget;
3120 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
3122 static int alc_auto_add_sw_ctl(struct hda_codec
*codec
,
3123 const char *pfx
, int cidx
,
3124 hda_nid_t nid
, unsigned int chs
)
3126 struct alc_spec
*spec
= codec
->spec
;
3132 wid_type
= get_wcaps_type(get_wcaps(codec
, nid
));
3133 if (wid_type
== AC_WID_PIN
|| wid_type
== AC_WID_AUD_OUT
) {
3134 type
= ALC_CTL_WIDGET_MUTE
;
3135 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
);
3136 } else if (snd_hda_get_conn_list(codec
, nid
, NULL
) == 1) {
3137 type
= ALC_CTL_WIDGET_MUTE
;
3138 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_INPUT
);
3140 type
= ALC_CTL_BIND_MUTE
;
3141 val
= HDA_COMPOSE_AMP_VAL(nid
, chs
, 2, HDA_INPUT
);
3143 if (is_ctl_used(spec
->sw_ctls
, val
) && chs
!= 2) /* exclude LFE */
3145 mark_ctl_usage(spec
->sw_ctls
, val
);
3146 return __add_pb_sw_ctrl(codec
->spec
, type
, pfx
, cidx
, val
);
3149 #define alc_auto_add_stereo_sw(codec, pfx, cidx, nid) \
3150 alc_auto_add_sw_ctl(codec, pfx, cidx, nid, 3)
3152 static hda_nid_t
alc_look_for_out_mute_nid(struct hda_codec
*codec
,
3153 hda_nid_t pin
, hda_nid_t dac
)
3155 hda_nid_t mix
= alc_auto_dac_to_mix(codec
, pin
, dac
);
3156 if (nid_has_mute(codec
, pin
, HDA_OUTPUT
))
3158 else if (mix
&& nid_has_mute(codec
, mix
, HDA_INPUT
))
3160 else if (nid_has_mute(codec
, dac
, HDA_OUTPUT
))
3165 static hda_nid_t
alc_look_for_out_vol_nid(struct hda_codec
*codec
,
3166 hda_nid_t pin
, hda_nid_t dac
)
3168 hda_nid_t mix
= alc_auto_dac_to_mix(codec
, pin
, dac
);
3169 if (nid_has_volume(codec
, dac
, HDA_OUTPUT
))
3171 else if (nid_has_volume(codec
, mix
, HDA_OUTPUT
))
3173 else if (nid_has_volume(codec
, pin
, HDA_OUTPUT
))
3178 /* add playback controls from the parsed DAC table */
3179 static int alc_auto_create_multi_out_ctls(struct hda_codec
*codec
,
3180 const struct auto_pin_cfg
*cfg
)
3182 struct alc_spec
*spec
= codec
->spec
;
3183 int i
, err
, noutputs
;
3185 noutputs
= cfg
->line_outs
;
3186 if (spec
->multi_ios
> 0)
3187 noutputs
+= spec
->multi_ios
;
3189 for (i
= 0; i
< noutputs
; i
++) {
3195 dac
= spec
->multiout
.dac_nids
[i
];
3198 if (i
>= cfg
->line_outs
)
3199 pin
= spec
->multi_io
[i
- 1].pin
;
3201 pin
= cfg
->line_out_pins
[i
];
3203 sw
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3204 vol
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3205 name
= alc_get_line_out_pfx(spec
, i
, true, &index
);
3206 if (!name
|| !strcmp(name
, "CLFE")) {
3208 err
= alc_auto_add_vol_ctl(codec
, "Center", 0, vol
, 1);
3211 err
= alc_auto_add_vol_ctl(codec
, "LFE", 0, vol
, 2);
3214 err
= alc_auto_add_sw_ctl(codec
, "Center", 0, sw
, 1);
3217 err
= alc_auto_add_sw_ctl(codec
, "LFE", 0, sw
, 2);
3221 err
= alc_auto_add_stereo_vol(codec
, name
, index
, vol
);
3224 err
= alc_auto_add_stereo_sw(codec
, name
, index
, sw
);
3232 static int alc_auto_create_extra_out(struct hda_codec
*codec
, hda_nid_t pin
,
3233 hda_nid_t dac
, const char *pfx
)
3235 struct alc_spec
*spec
= codec
->spec
;
3241 /* the corresponding DAC is already occupied */
3242 if (!(get_wcaps(codec
, pin
) & AC_WCAP_OUT_AMP
))
3243 return 0; /* no way */
3244 /* create a switch only */
3245 val
= HDA_COMPOSE_AMP_VAL(pin
, 3, 0, HDA_OUTPUT
);
3246 if (is_ctl_used(spec
->sw_ctls
, val
))
3247 return 0; /* already created */
3248 mark_ctl_usage(spec
->sw_ctls
, val
);
3249 return add_pb_sw_ctrl(spec
, ALC_CTL_WIDGET_MUTE
, pfx
, val
);
3252 sw
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3253 vol
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3254 err
= alc_auto_add_stereo_vol(codec
, pfx
, 0, vol
);
3257 err
= alc_auto_add_stereo_sw(codec
, pfx
, 0, sw
);
3263 static struct hda_bind_ctls
*new_bind_ctl(struct hda_codec
*codec
,
3265 struct hda_ctl_ops
*ops
)
3267 struct alc_spec
*spec
= codec
->spec
;
3268 struct hda_bind_ctls
**ctlp
, *ctl
;
3269 snd_array_init(&spec
->bind_ctls
, sizeof(ctl
), 8);
3270 ctlp
= snd_array_new(&spec
->bind_ctls
);
3273 ctl
= kzalloc(sizeof(*ctl
) + sizeof(long) * (nums
+ 1), GFP_KERNEL
);
3280 /* add playback controls for speaker and HP outputs */
3281 static int alc_auto_create_extra_outs(struct hda_codec
*codec
, int num_pins
,
3282 const hda_nid_t
*pins
,
3283 const hda_nid_t
*dacs
,
3286 struct alc_spec
*spec
= codec
->spec
;
3287 struct hda_bind_ctls
*ctl
;
3291 if (!num_pins
|| !pins
[0])
3294 if (num_pins
== 1) {
3295 hda_nid_t dac
= *dacs
;
3297 dac
= spec
->multiout
.dac_nids
[0];
3298 return alc_auto_create_extra_out(codec
, *pins
, dac
, pfx
);
3301 if (dacs
[num_pins
- 1]) {
3302 /* OK, we have a multi-output system with individual volumes */
3303 for (i
= 0; i
< num_pins
; i
++) {
3304 snprintf(name
, sizeof(name
), "%s %s",
3305 pfx
, channel_name
[i
]);
3306 err
= alc_auto_create_extra_out(codec
, pins
[i
], dacs
[i
],
3314 /* Let's create a bind-controls */
3315 ctl
= new_bind_ctl(codec
, num_pins
, &snd_hda_bind_sw
);
3319 for (i
= 0; i
< num_pins
; i
++) {
3320 if (get_wcaps(codec
, pins
[i
]) & AC_WCAP_OUT_AMP
)
3322 HDA_COMPOSE_AMP_VAL(pins
[i
], 3, 0, HDA_OUTPUT
);
3325 snprintf(name
, sizeof(name
), "%s Playback Switch", pfx
);
3326 err
= add_control(spec
, ALC_CTL_BIND_SW
, name
, 0, (long)ctl
);
3331 ctl
= new_bind_ctl(codec
, num_pins
, &snd_hda_bind_vol
);
3335 for (i
= 0; i
< num_pins
; i
++) {
3337 if (!pins
[i
] || !dacs
[i
])
3339 vol
= alc_look_for_out_vol_nid(codec
, pins
[i
], dacs
[i
]);
3342 HDA_COMPOSE_AMP_VAL(vol
, 3, 0, HDA_OUTPUT
);
3345 snprintf(name
, sizeof(name
), "%s Playback Volume", pfx
);
3346 err
= add_control(spec
, ALC_CTL_BIND_VOL
, name
, 0, (long)ctl
);
3353 static int alc_auto_create_hp_out(struct hda_codec
*codec
)
3355 struct alc_spec
*spec
= codec
->spec
;
3356 return alc_auto_create_extra_outs(codec
, spec
->autocfg
.hp_outs
,
3357 spec
->autocfg
.hp_pins
,
3358 spec
->multiout
.hp_out_nid
,
3362 static int alc_auto_create_speaker_out(struct hda_codec
*codec
)
3364 struct alc_spec
*spec
= codec
->spec
;
3365 return alc_auto_create_extra_outs(codec
, spec
->autocfg
.speaker_outs
,
3366 spec
->autocfg
.speaker_pins
,
3367 spec
->multiout
.extra_out_nid
,
3371 static void alc_auto_set_output_and_unmute(struct hda_codec
*codec
,
3372 hda_nid_t pin
, int pin_type
,
3376 hda_nid_t nid
, mix
= 0;
3377 hda_nid_t srcs
[HDA_MAX_CONNECTIONS
];
3379 alc_set_pin_output(codec
, pin
, pin_type
);
3380 nid
= alc_go_down_to_selector(codec
, pin
);
3381 num
= snd_hda_get_connections(codec
, nid
, srcs
, ARRAY_SIZE(srcs
));
3382 for (i
= 0; i
< num
; i
++) {
3383 if (alc_auto_mix_to_dac(codec
, srcs
[i
]) != dac
)
3391 /* need the manual connection? */
3393 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_CONNECT_SEL
, i
);
3394 /* unmute mixer widget inputs */
3395 if (nid_has_mute(codec
, mix
, HDA_INPUT
)) {
3396 snd_hda_codec_write(codec
, mix
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3398 snd_hda_codec_write(codec
, mix
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3401 /* initialize volume */
3402 nid
= alc_look_for_out_vol_nid(codec
, pin
, dac
);
3404 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3407 /* unmute DAC if it's not assigned to a mixer */
3408 nid
= alc_look_for_out_mute_nid(codec
, pin
, dac
);
3409 if (nid
== mix
&& nid_has_mute(codec
, dac
, HDA_OUTPUT
))
3410 snd_hda_codec_write(codec
, dac
, 0, AC_VERB_SET_AMP_GAIN_MUTE
,
3414 static void alc_auto_init_multi_out(struct hda_codec
*codec
)
3416 struct alc_spec
*spec
= codec
->spec
;
3417 int pin_type
= get_pin_type(spec
->autocfg
.line_out_type
);
3420 for (i
= 0; i
<= HDA_SIDE
; i
++) {
3421 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
3423 alc_auto_set_output_and_unmute(codec
, nid
, pin_type
,
3424 spec
->multiout
.dac_nids
[i
]);
3428 static void alc_auto_init_extra_out(struct hda_codec
*codec
)
3430 struct alc_spec
*spec
= codec
->spec
;
3434 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
3435 if (spec
->autocfg
.line_out_type
== AUTO_PIN_HP_OUT
)
3437 pin
= spec
->autocfg
.hp_pins
[i
];
3440 dac
= spec
->multiout
.hp_out_nid
[i
];
3442 if (i
> 0 && spec
->multiout
.hp_out_nid
[0])
3443 dac
= spec
->multiout
.hp_out_nid
[0];
3445 dac
= spec
->multiout
.dac_nids
[0];
3447 alc_auto_set_output_and_unmute(codec
, pin
, PIN_HP
, dac
);
3449 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++) {
3450 if (spec
->autocfg
.line_out_type
== AUTO_PIN_SPEAKER_OUT
)
3452 pin
= spec
->autocfg
.speaker_pins
[i
];
3455 dac
= spec
->multiout
.extra_out_nid
[i
];
3457 if (i
> 0 && spec
->multiout
.extra_out_nid
[0])
3458 dac
= spec
->multiout
.extra_out_nid
[0];
3460 dac
= spec
->multiout
.dac_nids
[0];
3462 alc_auto_set_output_and_unmute(codec
, pin
, PIN_OUT
, dac
);
3469 static int alc_auto_fill_multi_ios(struct hda_codec
*codec
,
3470 unsigned int location
)
3472 struct alc_spec
*spec
= codec
->spec
;
3473 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3474 hda_nid_t prime_dac
= spec
->private_dac_nids
[0];
3475 int type
, i
, num_pins
= 0;
3477 for (type
= AUTO_PIN_LINE_IN
; type
>= AUTO_PIN_MIC
; type
--) {
3478 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3479 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
3481 unsigned int defcfg
, caps
;
3482 if (cfg
->inputs
[i
].type
!= type
)
3484 defcfg
= snd_hda_codec_get_pincfg(codec
, nid
);
3485 if (get_defcfg_connect(defcfg
) != AC_JACK_PORT_COMPLEX
)
3487 if (location
&& get_defcfg_location(defcfg
) != location
)
3489 caps
= snd_hda_query_pin_caps(codec
, nid
);
3490 if (!(caps
& AC_PINCAP_OUT
))
3492 dac
= alc_auto_look_for_dac(codec
, nid
);
3495 spec
->multi_io
[num_pins
].pin
= nid
;
3496 spec
->multi_io
[num_pins
].dac
= dac
;
3498 spec
->private_dac_nids
[spec
->multiout
.num_dacs
++] = dac
;
3501 spec
->multiout
.num_dacs
= 1;
3503 /* clear up again */
3504 memset(spec
->private_dac_nids
, 0,
3505 sizeof(spec
->private_dac_nids
));
3506 spec
->private_dac_nids
[0] = prime_dac
;
3512 static int alc_auto_ch_mode_info(struct snd_kcontrol
*kcontrol
,
3513 struct snd_ctl_elem_info
*uinfo
)
3515 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3516 struct alc_spec
*spec
= codec
->spec
;
3518 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
3520 uinfo
->value
.enumerated
.items
= spec
->multi_ios
+ 1;
3521 if (uinfo
->value
.enumerated
.item
> spec
->multi_ios
)
3522 uinfo
->value
.enumerated
.item
= spec
->multi_ios
;
3523 sprintf(uinfo
->value
.enumerated
.name
, "%dch",
3524 (uinfo
->value
.enumerated
.item
+ 1) * 2);
3528 static int alc_auto_ch_mode_get(struct snd_kcontrol
*kcontrol
,
3529 struct snd_ctl_elem_value
*ucontrol
)
3531 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3532 struct alc_spec
*spec
= codec
->spec
;
3533 ucontrol
->value
.enumerated
.item
[0] = (spec
->ext_channel_count
- 1) / 2;
3537 static int alc_set_multi_io(struct hda_codec
*codec
, int idx
, bool output
)
3539 struct alc_spec
*spec
= codec
->spec
;
3540 hda_nid_t nid
= spec
->multi_io
[idx
].pin
;
3542 if (!spec
->multi_io
[idx
].ctl_in
)
3543 spec
->multi_io
[idx
].ctl_in
=
3544 snd_hda_codec_read(codec
, nid
, 0,
3545 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
3547 snd_hda_codec_update_cache(codec
, nid
, 0,
3548 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3550 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
3551 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
3553 alc_auto_select_dac(codec
, nid
, spec
->multi_io
[idx
].dac
);
3555 if (get_wcaps(codec
, nid
) & AC_WCAP_OUT_AMP
)
3556 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
3557 HDA_AMP_MUTE
, HDA_AMP_MUTE
);
3558 snd_hda_codec_update_cache(codec
, nid
, 0,
3559 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3560 spec
->multi_io
[idx
].ctl_in
);
3565 static int alc_auto_ch_mode_put(struct snd_kcontrol
*kcontrol
,
3566 struct snd_ctl_elem_value
*ucontrol
)
3568 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3569 struct alc_spec
*spec
= codec
->spec
;
3572 ch
= ucontrol
->value
.enumerated
.item
[0];
3573 if (ch
< 0 || ch
> spec
->multi_ios
)
3575 if (ch
== (spec
->ext_channel_count
- 1) / 2)
3577 spec
->ext_channel_count
= (ch
+ 1) * 2;
3578 for (i
= 0; i
< spec
->multi_ios
; i
++)
3579 alc_set_multi_io(codec
, i
, i
< ch
);
3580 spec
->multiout
.max_channels
= spec
->ext_channel_count
;
3581 if (spec
->need_dac_fix
&& !spec
->const_channel_count
)
3582 spec
->multiout
.num_dacs
= spec
->multiout
.max_channels
/ 2;
3586 static const struct snd_kcontrol_new alc_auto_channel_mode_enum
= {
3587 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3588 .name
= "Channel Mode",
3589 .info
= alc_auto_ch_mode_info
,
3590 .get
= alc_auto_ch_mode_get
,
3591 .put
= alc_auto_ch_mode_put
,
3594 static int alc_auto_add_multi_channel_mode(struct hda_codec
*codec
)
3596 struct alc_spec
*spec
= codec
->spec
;
3598 if (spec
->multi_ios
> 0) {
3599 struct snd_kcontrol_new
*knew
;
3601 knew
= alc_kcontrol_new(spec
);
3604 *knew
= alc_auto_channel_mode_enum
;
3605 knew
->name
= kstrdup("Channel Mode", GFP_KERNEL
);
3612 /* filter out invalid adc_nids (and capsrc_nids) that don't give all
3615 static void alc_remove_invalid_adc_nids(struct hda_codec
*codec
)
3617 struct alc_spec
*spec
= codec
->spec
;
3618 const struct hda_input_mux
*imux
;
3619 hda_nid_t adc_nids
[ARRAY_SIZE(spec
->private_adc_nids
)];
3620 hda_nid_t capsrc_nids
[ARRAY_SIZE(spec
->private_adc_nids
)];
3623 imux
= spec
->input_mux
;
3626 if (spec
->dyn_adc_switch
)
3630 for (n
= 0; n
< spec
->num_adc_nids
; n
++) {
3631 hda_nid_t cap
= spec
->private_capsrc_nids
[n
];
3632 int num_conns
= snd_hda_get_conn_list(codec
, cap
, NULL
);
3633 for (i
= 0; i
< imux
->num_items
; i
++) {
3634 hda_nid_t pin
= spec
->imux_pins
[i
];
3636 if (get_connection_index(codec
, cap
, pin
) < 0)
3638 } else if (num_conns
<= imux
->items
[i
].index
)
3641 if (i
>= imux
->num_items
) {
3642 adc_nids
[nums
] = spec
->private_adc_nids
[n
];
3643 capsrc_nids
[nums
++] = cap
;
3647 /* check whether ADC-switch is possible */
3648 if (!alc_check_dyn_adc_switch(codec
)) {
3649 printk(KERN_WARNING
"hda_codec: %s: no valid ADC found;"
3650 " using fallback 0x%x\n",
3651 codec
->chip_name
, spec
->private_adc_nids
[0]);
3652 spec
->num_adc_nids
= 1;
3656 } else if (nums
!= spec
->num_adc_nids
) {
3657 memcpy(spec
->private_adc_nids
, adc_nids
,
3658 nums
* sizeof(hda_nid_t
));
3659 memcpy(spec
->private_capsrc_nids
, capsrc_nids
,
3660 nums
* sizeof(hda_nid_t
));
3661 spec
->num_adc_nids
= nums
;
3665 alc_auto_mic_check_imux(codec
); /* check auto-mic setups */
3666 else if (spec
->input_mux
->num_items
== 1)
3667 spec
->num_adc_nids
= 1; /* reduce to a single ADC */
3671 * initialize ADC paths
3673 static void alc_auto_init_adc(struct hda_codec
*codec
, int adc_idx
)
3675 struct alc_spec
*spec
= codec
->spec
;
3678 nid
= spec
->adc_nids
[adc_idx
];
3680 if (nid_has_mute(codec
, nid
, HDA_INPUT
)) {
3681 snd_hda_codec_write(codec
, nid
, 0,
3682 AC_VERB_SET_AMP_GAIN_MUTE
,
3686 if (!spec
->capsrc_nids
)
3688 nid
= spec
->capsrc_nids
[adc_idx
];
3689 if (nid_has_mute(codec
, nid
, HDA_OUTPUT
))
3690 snd_hda_codec_write(codec
, nid
, 0,
3691 AC_VERB_SET_AMP_GAIN_MUTE
,
3695 static void alc_auto_init_input_src(struct hda_codec
*codec
)
3697 struct alc_spec
*spec
= codec
->spec
;
3700 for (c
= 0; c
< spec
->num_adc_nids
; c
++)
3701 alc_auto_init_adc(codec
, c
);
3702 if (spec
->dyn_adc_switch
)
3705 nums
= spec
->num_adc_nids
;
3706 for (c
= 0; c
< nums
; c
++)
3707 alc_mux_select(codec
, 0, spec
->cur_mux
[c
], true);
3710 /* add mic boosts if needed */
3711 static int alc_auto_add_mic_boost(struct hda_codec
*codec
)
3713 struct alc_spec
*spec
= codec
->spec
;
3714 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3718 const char *prev_label
= NULL
;
3720 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3721 if (cfg
->inputs
[i
].type
> AUTO_PIN_MIC
)
3723 nid
= cfg
->inputs
[i
].pin
;
3724 if (get_wcaps(codec
, nid
) & AC_WCAP_IN_AMP
) {
3726 char boost_label
[32];
3728 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3729 if (spec
->shared_mic_hp
&& !strcmp(label
, "Misc"))
3730 label
= "Headphone Mic";
3731 if (prev_label
&& !strcmp(label
, prev_label
))
3737 snprintf(boost_label
, sizeof(boost_label
),
3738 "%s Boost Volume", label
);
3739 err
= add_control(spec
, ALC_CTL_WIDGET_VOL
,
3740 boost_label
, type_idx
,
3741 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_INPUT
));
3749 /* select or unmute the given capsrc route */
3750 static void select_or_unmute_capsrc(struct hda_codec
*codec
, hda_nid_t cap
,
3753 if (get_wcaps_type(get_wcaps(codec
, cap
)) == AC_WID_AUD_MIX
) {
3754 snd_hda_codec_amp_stereo(codec
, cap
, HDA_INPUT
, idx
,
3756 } else if (snd_hda_get_conn_list(codec
, cap
, NULL
) > 1) {
3757 snd_hda_codec_write_cache(codec
, cap
, 0,
3758 AC_VERB_SET_CONNECT_SEL
, idx
);
3762 /* set the default connection to that pin */
3763 static int init_capsrc_for_pin(struct hda_codec
*codec
, hda_nid_t pin
)
3765 struct alc_spec
*spec
= codec
->spec
;
3770 for (i
= 0; i
< spec
->num_adc_nids
; i
++) {
3771 hda_nid_t cap
= spec
->capsrc_nids
?
3772 spec
->capsrc_nids
[i
] : spec
->adc_nids
[i
];
3775 idx
= get_connection_index(codec
, cap
, pin
);
3778 select_or_unmute_capsrc(codec
, cap
, idx
);
3779 return i
; /* return the found index */
3781 return -1; /* not found */
3784 /* initialize some special cases for input sources */
3785 static void alc_init_special_input_src(struct hda_codec
*codec
)
3787 struct alc_spec
*spec
= codec
->spec
;
3790 for (i
= 0; i
< spec
->autocfg
.num_inputs
; i
++)
3791 init_capsrc_for_pin(codec
, spec
->autocfg
.inputs
[i
].pin
);
3794 /* assign appropriate capture mixers */
3795 static void set_capture_mixer(struct hda_codec
*codec
)
3797 struct alc_spec
*spec
= codec
->spec
;
3798 static const struct snd_kcontrol_new
*caps
[2][3] = {
3799 { alc_capture_mixer_nosrc1
,
3800 alc_capture_mixer_nosrc2
,
3801 alc_capture_mixer_nosrc3
},
3802 { alc_capture_mixer1
,
3804 alc_capture_mixer3
},
3807 /* check whether either of ADC or MUX has a volume control */
3808 if (!nid_has_volume(codec
, spec
->adc_nids
[0], HDA_INPUT
)) {
3809 if (!spec
->capsrc_nids
)
3810 return; /* no volume */
3811 if (!nid_has_volume(codec
, spec
->capsrc_nids
[0], HDA_OUTPUT
))
3812 return; /* no volume in capsrc, too */
3813 spec
->vol_in_capsrc
= 1;
3816 if (spec
->num_adc_nids
> 0) {
3820 if (spec
->input_mux
&& spec
->input_mux
->num_items
> 1)
3822 if (spec
->auto_mic
) {
3825 } else if (spec
->dyn_adc_switch
)
3828 if (spec
->num_adc_nids
> 3)
3829 spec
->num_adc_nids
= 3;
3830 else if (!spec
->num_adc_nids
)
3832 num_adcs
= spec
->num_adc_nids
;
3834 spec
->cap_mixer
= caps
[mux
][num_adcs
- 1];
3839 * standard auto-parser initializations
3841 static void alc_auto_init_std(struct hda_codec
*codec
)
3843 struct alc_spec
*spec
= codec
->spec
;
3844 alc_auto_init_multi_out(codec
);
3845 alc_auto_init_extra_out(codec
);
3846 alc_auto_init_analog_input(codec
);
3847 alc_auto_init_input_src(codec
);
3848 alc_auto_init_digital(codec
);
3849 if (spec
->unsol_event
)
3850 alc_inithook(codec
);
3854 * Digital-beep handlers
3856 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3857 #define set_beep_amp(spec, nid, idx, dir) \
3858 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
3860 static const struct snd_pci_quirk beep_white_list
[] = {
3861 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
3862 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
3863 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
3864 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
3865 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
3869 static inline int has_cdefine_beep(struct hda_codec
*codec
)
3871 struct alc_spec
*spec
= codec
->spec
;
3872 const struct snd_pci_quirk
*q
;
3873 q
= snd_pci_quirk_lookup(codec
->bus
->pci
, beep_white_list
);
3876 return spec
->cdefine
.enable_pcbeep
;
3879 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
3880 #define has_cdefine_beep(codec) 0
3883 /* parse the BIOS configuration and set up the alc_spec */
3884 /* return 1 if successful, 0 if the proper config is not found,
3885 * or a negative error code
3887 static int alc_parse_auto_config(struct hda_codec
*codec
,
3888 const hda_nid_t
*ignore_nids
,
3889 const hda_nid_t
*ssid_nids
)
3891 struct alc_spec
*spec
= codec
->spec
;
3892 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3895 err
= snd_hda_parse_pin_defcfg(codec
, cfg
, ignore_nids
,
3899 if (!cfg
->line_outs
) {
3900 if (cfg
->dig_outs
|| cfg
->dig_in_pin
) {
3901 spec
->multiout
.max_channels
= 2;
3902 spec
->no_analog
= 1;
3905 return 0; /* can't find valid BIOS pin config */
3908 if (cfg
->line_out_type
== AUTO_PIN_SPEAKER_OUT
&&
3909 cfg
->line_outs
<= cfg
->hp_outs
) {
3910 /* use HP as primary out */
3911 cfg
->speaker_outs
= cfg
->line_outs
;
3912 memcpy(cfg
->speaker_pins
, cfg
->line_out_pins
,
3913 sizeof(cfg
->speaker_pins
));
3914 cfg
->line_outs
= cfg
->hp_outs
;
3915 memcpy(cfg
->line_out_pins
, cfg
->hp_pins
, sizeof(cfg
->hp_pins
));
3917 memset(cfg
->hp_pins
, 0, sizeof(cfg
->hp_pins
));
3918 cfg
->line_out_type
= AUTO_PIN_HP_OUT
;
3921 err
= alc_auto_fill_dac_nids(codec
);
3924 err
= alc_auto_add_multi_channel_mode(codec
);
3927 err
= alc_auto_create_multi_out_ctls(codec
, cfg
);
3930 err
= alc_auto_create_hp_out(codec
);
3933 err
= alc_auto_create_speaker_out(codec
);
3936 err
= alc_auto_create_shared_input(codec
);
3939 err
= alc_auto_create_input_ctls(codec
);
3943 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3946 alc_auto_parse_digital(codec
);
3948 if (!spec
->no_analog
)
3949 alc_remove_invalid_adc_nids(codec
);
3952 alc_ssid_check(codec
, ssid_nids
);
3954 if (!spec
->no_analog
) {
3955 alc_auto_check_switches(codec
);
3956 err
= alc_auto_add_mic_boost(codec
);
3961 if (spec
->kctls
.list
)
3962 add_mixer(spec
, spec
->kctls
.list
);
3967 static int alc880_parse_auto_config(struct hda_codec
*codec
)
3969 static const hda_nid_t alc880_ignore
[] = { 0x1d, 0 };
3970 static const hda_nid_t alc880_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
3971 return alc_parse_auto_config(codec
, alc880_ignore
, alc880_ssids
);
3974 #ifdef CONFIG_SND_HDA_POWER_SAVE
3975 static const struct hda_amp_list alc880_loopbacks
[] = {
3976 { 0x0b, HDA_INPUT
, 0 },
3977 { 0x0b, HDA_INPUT
, 1 },
3978 { 0x0b, HDA_INPUT
, 2 },
3979 { 0x0b, HDA_INPUT
, 3 },
3980 { 0x0b, HDA_INPUT
, 4 },
3988 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
3989 #define alc_board_config \
3990 snd_hda_check_board_config
3991 #define alc_board_codec_sid_config \
3992 snd_hda_check_board_codec_sid_config
3993 #include "alc_quirks.c"
3995 #define alc_board_config(codec, nums, models, tbl) -1
3996 #define alc_board_codec_sid_config(codec, nums, models, tbl) -1
3997 #define setup_preset(codec, x) /* NOP */
4001 * OK, here we have finally the patch for ALC880
4003 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4004 #include "alc880_quirks.c"
4007 static int patch_alc880(struct hda_codec
*codec
)
4009 struct alc_spec
*spec
;
4013 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4019 spec
->mixer_nid
= 0x0b;
4020 spec
->need_dac_fix
= 1;
4022 board_config
= alc_board_config(codec
, ALC880_MODEL_LAST
,
4023 alc880_models
, alc880_cfg_tbl
);
4024 if (board_config
< 0) {
4025 printk(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
4027 board_config
= ALC_MODEL_AUTO
;
4030 if (board_config
== ALC_MODEL_AUTO
) {
4031 /* automatic parse from the BIOS config */
4032 err
= alc880_parse_auto_config(codec
);
4035 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4038 "hda_codec: Cannot set up configuration "
4039 "from BIOS. Using 3-stack mode...\n");
4040 board_config
= ALC880_3ST
;
4045 if (board_config
!= ALC_MODEL_AUTO
)
4046 setup_preset(codec
, &alc880_presets
[board_config
]);
4048 if (!spec
->no_analog
&& !spec
->adc_nids
) {
4049 alc_auto_fill_adc_caps(codec
);
4050 alc_rebuild_imux_for_auto_mic(codec
);
4051 alc_remove_invalid_adc_nids(codec
);
4054 if (!spec
->no_analog
&& !spec
->cap_mixer
)
4055 set_capture_mixer(codec
);
4057 if (!spec
->no_analog
) {
4058 err
= snd_hda_attach_beep_device(codec
, 0x1);
4061 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
4064 spec
->vmaster_nid
= 0x0c;
4066 codec
->patch_ops
= alc_patch_ops
;
4067 if (board_config
== ALC_MODEL_AUTO
)
4068 spec
->init_hook
= alc_auto_init_std
;
4069 #ifdef CONFIG_SND_HDA_POWER_SAVE
4070 if (!spec
->loopback
.amplist
)
4071 spec
->loopback
.amplist
= alc880_loopbacks
;
4085 static int alc260_parse_auto_config(struct hda_codec
*codec
)
4087 static const hda_nid_t alc260_ignore
[] = { 0x17, 0 };
4088 static const hda_nid_t alc260_ssids
[] = { 0x10, 0x15, 0x0f, 0 };
4089 return alc_parse_auto_config(codec
, alc260_ignore
, alc260_ssids
);
4092 #ifdef CONFIG_SND_HDA_POWER_SAVE
4093 static const struct hda_amp_list alc260_loopbacks
[] = {
4094 { 0x07, HDA_INPUT
, 0 },
4095 { 0x07, HDA_INPUT
, 1 },
4096 { 0x07, HDA_INPUT
, 2 },
4097 { 0x07, HDA_INPUT
, 3 },
4098 { 0x07, HDA_INPUT
, 4 },
4110 static const struct alc_fixup alc260_fixups
[] = {
4111 [PINFIX_HP_DC5750
] = {
4112 .type
= ALC_FIXUP_PINS
,
4113 .v
.pins
= (const struct alc_pincfg
[]) {
4114 { 0x11, 0x90130110 }, /* speaker */
4120 static const struct snd_pci_quirk alc260_fixup_tbl
[] = {
4121 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750
),
4127 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4128 #include "alc260_quirks.c"
4131 static int patch_alc260(struct hda_codec
*codec
)
4133 struct alc_spec
*spec
;
4134 int err
, board_config
;
4136 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4142 spec
->mixer_nid
= 0x07;
4144 board_config
= alc_board_config(codec
, ALC260_MODEL_LAST
,
4145 alc260_models
, alc260_cfg_tbl
);
4146 if (board_config
< 0) {
4147 snd_printd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
4149 board_config
= ALC_MODEL_AUTO
;
4152 if (board_config
== ALC_MODEL_AUTO
) {
4153 alc_pick_fixup(codec
, NULL
, alc260_fixup_tbl
, alc260_fixups
);
4154 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
4157 if (board_config
== ALC_MODEL_AUTO
) {
4158 /* automatic parse from the BIOS config */
4159 err
= alc260_parse_auto_config(codec
);
4162 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4165 "hda_codec: Cannot set up configuration "
4166 "from BIOS. Using base mode...\n");
4167 board_config
= ALC260_BASIC
;
4172 if (board_config
!= ALC_MODEL_AUTO
)
4173 setup_preset(codec
, &alc260_presets
[board_config
]);
4175 if (!spec
->no_analog
&& !spec
->adc_nids
) {
4176 alc_auto_fill_adc_caps(codec
);
4177 alc_rebuild_imux_for_auto_mic(codec
);
4178 alc_remove_invalid_adc_nids(codec
);
4181 if (!spec
->no_analog
&& !spec
->cap_mixer
)
4182 set_capture_mixer(codec
);
4184 if (!spec
->no_analog
) {
4185 err
= snd_hda_attach_beep_device(codec
, 0x1);
4188 set_beep_amp(spec
, 0x07, 0x05, HDA_INPUT
);
4191 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
4193 spec
->vmaster_nid
= 0x08;
4195 codec
->patch_ops
= alc_patch_ops
;
4196 if (board_config
== ALC_MODEL_AUTO
)
4197 spec
->init_hook
= alc_auto_init_std
;
4198 spec
->shutup
= alc_eapd_shutup
;
4199 #ifdef CONFIG_SND_HDA_POWER_SAVE
4200 if (!spec
->loopback
.amplist
)
4201 spec
->loopback
.amplist
= alc260_loopbacks
;
4213 * ALC882/883/885/888/889 support
4215 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4216 * configuration. Each pin widget can choose any input DACs and a mixer.
4217 * Each ADC is connected from a mixer of all inputs. This makes possible
4218 * 6-channel independent captures.
4220 * In addition, an independent DAC for the multi-playback (not used in this
4223 #ifdef CONFIG_SND_HDA_POWER_SAVE
4224 #define alc882_loopbacks alc880_loopbacks
4231 ALC882_FIXUP_ABIT_AW9D_MAX
,
4232 ALC882_FIXUP_LENOVO_Y530
,
4233 ALC882_FIXUP_PB_M5210
,
4234 ALC882_FIXUP_ACER_ASPIRE_7736
,
4235 ALC882_FIXUP_ASUS_W90V
,
4236 ALC889_FIXUP_VAIO_TT
,
4237 ALC888_FIXUP_EEE1601
,
4241 static const struct alc_fixup alc882_fixups
[] = {
4242 [ALC882_FIXUP_ABIT_AW9D_MAX
] = {
4243 .type
= ALC_FIXUP_PINS
,
4244 .v
.pins
= (const struct alc_pincfg
[]) {
4245 { 0x15, 0x01080104 }, /* side */
4246 { 0x16, 0x01011012 }, /* rear */
4247 { 0x17, 0x01016011 }, /* clfe */
4251 [ALC882_FIXUP_LENOVO_Y530
] = {
4252 .type
= ALC_FIXUP_PINS
,
4253 .v
.pins
= (const struct alc_pincfg
[]) {
4254 { 0x15, 0x99130112 }, /* rear int speakers */
4255 { 0x16, 0x99130111 }, /* subwoofer */
4259 [ALC882_FIXUP_PB_M5210
] = {
4260 .type
= ALC_FIXUP_VERBS
,
4261 .v
.verbs
= (const struct hda_verb
[]) {
4262 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF50
},
4266 [ALC882_FIXUP_ACER_ASPIRE_7736
] = {
4267 .type
= ALC_FIXUP_SKU
,
4268 .v
.sku
= ALC_FIXUP_SKU_IGNORE
,
4270 [ALC882_FIXUP_ASUS_W90V
] = {
4271 .type
= ALC_FIXUP_PINS
,
4272 .v
.pins
= (const struct alc_pincfg
[]) {
4273 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
4277 [ALC889_FIXUP_VAIO_TT
] = {
4278 .type
= ALC_FIXUP_PINS
,
4279 .v
.pins
= (const struct alc_pincfg
[]) {
4280 { 0x17, 0x90170111 }, /* hidden surround speaker */
4284 [ALC888_FIXUP_EEE1601
] = {
4285 .type
= ALC_FIXUP_VERBS
,
4286 .v
.verbs
= (const struct hda_verb
[]) {
4287 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x0b },
4288 { 0x20, AC_VERB_SET_PROC_COEF
, 0x0838 },
4292 [ALC882_FIXUP_EAPD
] = {
4293 .type
= ALC_FIXUP_VERBS
,
4294 .v
.verbs
= (const struct hda_verb
[]) {
4295 /* change to EAPD mode */
4296 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4297 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3060 },
4303 static const struct snd_pci_quirk alc882_fixup_tbl
[] = {
4304 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210
),
4305 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD
),
4306 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V
),
4307 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601
),
4308 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530
),
4309 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD
), /* codec SSID */
4310 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX
),
4311 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736
),
4312 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT
),
4317 * BIOS auto configuration
4319 /* almost identical with ALC880 parser... */
4320 static int alc882_parse_auto_config(struct hda_codec
*codec
)
4322 static const hda_nid_t alc882_ignore
[] = { 0x1d, 0 };
4323 static const hda_nid_t alc882_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
4324 return alc_parse_auto_config(codec
, alc882_ignore
, alc882_ssids
);
4329 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4330 #include "alc882_quirks.c"
4333 static int patch_alc882(struct hda_codec
*codec
)
4335 struct alc_spec
*spec
;
4336 int err
, board_config
;
4338 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4344 spec
->mixer_nid
= 0x0b;
4346 switch (codec
->vendor_id
) {
4351 /* ALC883 and variants */
4352 alc_fix_pll_init(codec
, 0x20, 0x0a, 10);
4356 err
= alc_codec_rename_from_preset(codec
);
4360 board_config
= alc_board_config(codec
, ALC882_MODEL_LAST
,
4361 alc882_models
, alc882_cfg_tbl
);
4363 if (board_config
< 0)
4364 board_config
= alc_board_codec_sid_config(codec
,
4365 ALC882_MODEL_LAST
, alc882_models
, alc882_ssid_cfg_tbl
);
4367 if (board_config
< 0) {
4368 printk(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
4370 board_config
= ALC_MODEL_AUTO
;
4373 if (board_config
== ALC_MODEL_AUTO
) {
4374 alc_pick_fixup(codec
, NULL
, alc882_fixup_tbl
, alc882_fixups
);
4375 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
4378 alc_auto_parse_customize_define(codec
);
4380 if (board_config
== ALC_MODEL_AUTO
) {
4381 /* automatic parse from the BIOS config */
4382 err
= alc882_parse_auto_config(codec
);
4385 #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
4388 "hda_codec: Cannot set up configuration "
4389 "from BIOS. Using base mode...\n");
4390 board_config
= ALC882_3ST_DIG
;
4395 if (board_config
!= ALC_MODEL_AUTO
)
4396 setup_preset(codec
, &alc882_presets
[board_config
]);
4398 if (!spec
->no_analog
&& !spec
->adc_nids
) {
4399 alc_auto_fill_adc_caps(codec
);
4400 alc_rebuild_imux_for_auto_mic(codec
);
4401 alc_remove_invalid_adc_nids(codec
);
4404 if (!spec
->no_analog
&& !spec
->cap_mixer
)
4405 set_capture_mixer(codec
);
4407 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
4408 err
= snd_hda_attach_beep_device(codec
, 0x1);
4411 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
4414 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
4416 spec
->vmaster_nid
= 0x0c;
4418 codec
->patch_ops
= alc_patch_ops
;
4419 if (board_config
== ALC_MODEL_AUTO
)
4420 spec
->init_hook
= alc_auto_init_std
;
4422 alc_init_jacks(codec
);
4423 #ifdef CONFIG_SND_HDA_POWER_SAVE
4424 if (!spec
->loopback
.amplist
)
4425 spec
->loopback
.amplist
= alc882_loopbacks
;
4439 static int alc262_parse_auto_config(struct hda_codec
*codec
)
4441 static const hda_nid_t alc262_ignore
[] = { 0x1d, 0 };
4442 static const hda_nid_t alc262_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
4443 return alc_parse_auto_config(codec
, alc262_ignore
, alc262_ssids
);
4450 ALC262_FIXUP_FSC_H270
,
4451 ALC262_FIXUP_HP_Z200
,
4453 ALC262_FIXUP_TOSHIBA_RX1
,
4454 ALC262_FIXUP_LENOVO_3000
,
4456 ALC262_FIXUP_BENQ_T31
,
4459 static const struct alc_fixup alc262_fixups
[] = {
4460 [ALC262_FIXUP_FSC_H270
] = {
4461 .type
= ALC_FIXUP_PINS
,
4462 .v
.pins
= (const struct alc_pincfg
[]) {
4463 { 0x14, 0x99130110 }, /* speaker */
4464 { 0x15, 0x0221142f }, /* front HP */
4465 { 0x1b, 0x0121141f }, /* rear HP */
4469 [ALC262_FIXUP_HP_Z200
] = {
4470 .type
= ALC_FIXUP_PINS
,
4471 .v
.pins
= (const struct alc_pincfg
[]) {
4472 { 0x16, 0x99130120 }, /* internal speaker */
4476 [ALC262_FIXUP_TYAN
] = {
4477 .type
= ALC_FIXUP_PINS
,
4478 .v
.pins
= (const struct alc_pincfg
[]) {
4479 { 0x14, 0x1993e1f0 }, /* int AUX */
4483 [ALC262_FIXUP_TOSHIBA_RX1
] = {
4484 .type
= ALC_FIXUP_PINS
,
4485 .v
.pins
= (const struct alc_pincfg
[]) {
4486 { 0x14, 0x90170110 }, /* speaker */
4487 { 0x15, 0x0421101f }, /* HP */
4488 { 0x1a, 0x40f000f0 }, /* N/A */
4489 { 0x1b, 0x40f000f0 }, /* N/A */
4490 { 0x1e, 0x40f000f0 }, /* N/A */
4493 [ALC262_FIXUP_LENOVO_3000
] = {
4494 .type
= ALC_FIXUP_VERBS
,
4495 .v
.verbs
= (const struct hda_verb
[]) {
4496 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF50
},
4500 .chain_id
= ALC262_FIXUP_BENQ
,
4502 [ALC262_FIXUP_BENQ
] = {
4503 .type
= ALC_FIXUP_VERBS
,
4504 .v
.verbs
= (const struct hda_verb
[]) {
4505 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4506 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3070 },
4510 [ALC262_FIXUP_BENQ_T31
] = {
4511 .type
= ALC_FIXUP_VERBS
,
4512 .v
.verbs
= (const struct hda_verb
[]) {
4513 { 0x20, AC_VERB_SET_COEF_INDEX
, 0x07 },
4514 { 0x20, AC_VERB_SET_PROC_COEF
, 0x3050 },
4520 static const struct snd_pci_quirk alc262_fixup_tbl
[] = {
4521 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200
),
4522 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ
),
4523 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ
),
4524 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN
),
4525 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
4526 ALC262_FIXUP_TOSHIBA_RX1
),
4527 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270
),
4528 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000
),
4529 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ
),
4530 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31
),
4535 #ifdef CONFIG_SND_HDA_POWER_SAVE
4536 #define alc262_loopbacks alc880_loopbacks
4541 static int patch_alc262(struct hda_codec
*codec
)
4543 struct alc_spec
*spec
;
4546 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4552 spec
->mixer_nid
= 0x0b;
4555 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
4560 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
4561 tmp
= snd_hda_codec_read(codec
, 0x20, 0, AC_VERB_GET_PROC_COEF
, 0);
4562 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_COEF_INDEX
, 7);
4563 snd_hda_codec_write(codec
, 0x1a, 0, AC_VERB_SET_PROC_COEF
, tmp
| 0x80);
4566 alc_auto_parse_customize_define(codec
);
4568 alc_fix_pll_init(codec
, 0x20, 0x0a, 10);
4570 alc_pick_fixup(codec
, NULL
, alc262_fixup_tbl
, alc262_fixups
);
4571 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
4573 /* automatic parse from the BIOS config */
4574 err
= alc262_parse_auto_config(codec
);
4578 if (!spec
->no_analog
&& !spec
->adc_nids
) {
4579 alc_auto_fill_adc_caps(codec
);
4580 alc_rebuild_imux_for_auto_mic(codec
);
4581 alc_remove_invalid_adc_nids(codec
);
4584 if (!spec
->no_analog
&& !spec
->cap_mixer
)
4585 set_capture_mixer(codec
);
4587 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
4588 err
= snd_hda_attach_beep_device(codec
, 0x1);
4591 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
4594 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
4596 spec
->vmaster_nid
= 0x0c;
4598 codec
->patch_ops
= alc_patch_ops
;
4599 spec
->init_hook
= alc_auto_init_std
;
4600 spec
->shutup
= alc_eapd_shutup
;
4602 alc_init_jacks(codec
);
4603 #ifdef CONFIG_SND_HDA_POWER_SAVE
4604 if (!spec
->loopback
.amplist
)
4605 spec
->loopback
.amplist
= alc262_loopbacks
;
4618 /* bind Beep switches of both NID 0x0f and 0x10 */
4619 static const struct hda_bind_ctls alc268_bind_beep_sw
= {
4620 .ops
= &snd_hda_bind_sw
,
4622 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT
),
4623 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT
),
4628 static const struct snd_kcontrol_new alc268_beep_mixer
[] = {
4629 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT
),
4630 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw
),
4634 /* set PCBEEP vol = 0, mute connections */
4635 static const struct hda_verb alc268_beep_init_verbs
[] = {
4636 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
4637 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4638 {0x10, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(1)},
4643 * BIOS auto configuration
4645 static int alc268_parse_auto_config(struct hda_codec
*codec
)
4647 static const hda_nid_t alc268_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
4648 struct alc_spec
*spec
= codec
->spec
;
4649 int err
= alc_parse_auto_config(codec
, NULL
, alc268_ssids
);
4651 if (!spec
->no_analog
&& spec
->autocfg
.speaker_pins
[0] != 0x1d) {
4652 add_mixer(spec
, alc268_beep_mixer
);
4653 add_verb(spec
, alc268_beep_init_verbs
);
4661 static int patch_alc268(struct hda_codec
*codec
)
4663 struct alc_spec
*spec
;
4664 int i
, has_beep
, err
;
4666 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4672 /* ALC268 has no aa-loopback mixer */
4674 /* automatic parse from the BIOS config */
4675 err
= alc268_parse_auto_config(codec
);
4680 for (i
= 0; i
< spec
->num_mixers
; i
++) {
4681 if (spec
->mixers
[i
] == alc268_beep_mixer
) {
4688 err
= snd_hda_attach_beep_device(codec
, 0x1);
4691 if (!query_amp_caps(codec
, 0x1d, HDA_INPUT
))
4692 /* override the amp caps for beep generator */
4693 snd_hda_override_amp_caps(codec
, 0x1d, HDA_INPUT
,
4694 (0x0c << AC_AMPCAP_OFFSET_SHIFT
) |
4695 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT
) |
4696 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
4697 (0 << AC_AMPCAP_MUTE_SHIFT
));
4700 if (!spec
->no_analog
&& !spec
->adc_nids
) {
4701 alc_auto_fill_adc_caps(codec
);
4702 alc_rebuild_imux_for_auto_mic(codec
);
4703 alc_remove_invalid_adc_nids(codec
);
4706 if (!spec
->no_analog
&& !spec
->cap_mixer
)
4707 set_capture_mixer(codec
);
4709 spec
->vmaster_nid
= 0x02;
4711 codec
->patch_ops
= alc_patch_ops
;
4712 spec
->init_hook
= alc_auto_init_std
;
4713 spec
->shutup
= alc_eapd_shutup
;
4715 alc_init_jacks(codec
);
4727 #ifdef CONFIG_SND_HDA_POWER_SAVE
4728 #define alc269_loopbacks alc880_loopbacks
4731 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback
= {
4735 .rates
= SNDRV_PCM_RATE_44100
, /* fixed rate */
4736 /* NID is set in alc_build_pcms */
4738 .open
= alc_playback_pcm_open
,
4739 .prepare
= alc_playback_pcm_prepare
,
4740 .cleanup
= alc_playback_pcm_cleanup
4744 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture
= {
4748 .rates
= SNDRV_PCM_RATE_44100
, /* fixed rate */
4749 /* NID is set in alc_build_pcms */
4752 #ifdef CONFIG_SND_HDA_POWER_SAVE
4753 static int alc269_mic2_for_mute_led(struct hda_codec
*codec
)
4755 switch (codec
->subsystem_id
) {
4762 static int alc269_mic2_mute_check_ps(struct hda_codec
*codec
, hda_nid_t nid
)
4764 /* update mute-LED according to the speaker mute state */
4765 if (nid
== 0x01 || nid
== 0x14) {
4767 if (snd_hda_codec_amp_read(codec
, 0x14, 0, HDA_OUTPUT
, 0) &
4772 /* mic2 vref pin is used for mute LED control */
4773 snd_hda_codec_update_cache(codec
, 0x19, 0,
4774 AC_VERB_SET_PIN_WIDGET_CONTROL
,
4777 return alc_check_power_status(codec
, nid
);
4779 #endif /* CONFIG_SND_HDA_POWER_SAVE */
4781 /* different alc269-variants */
4783 ALC269_TYPE_ALC269VA
,
4784 ALC269_TYPE_ALC269VB
,
4785 ALC269_TYPE_ALC269VC
,
4789 * BIOS auto configuration
4791 static int alc269_parse_auto_config(struct hda_codec
*codec
)
4793 static const hda_nid_t alc269_ignore
[] = { 0x1d, 0 };
4794 static const hda_nid_t alc269_ssids
[] = { 0, 0x1b, 0x14, 0x21 };
4795 static const hda_nid_t alc269va_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
4796 struct alc_spec
*spec
= codec
->spec
;
4797 const hda_nid_t
*ssids
= spec
->codec_variant
== ALC269_TYPE_ALC269VA
?
4798 alc269va_ssids
: alc269_ssids
;
4800 return alc_parse_auto_config(codec
, alc269_ignore
, ssids
);
4803 static void alc269_toggle_power_output(struct hda_codec
*codec
, int power_up
)
4805 int val
= alc_read_coef_idx(codec
, 0x04);
4810 alc_write_coef_idx(codec
, 0x04, val
);
4813 static void alc269_shutup(struct hda_codec
*codec
)
4815 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017)
4816 alc269_toggle_power_output(codec
, 0);
4817 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
4818 alc269_toggle_power_output(codec
, 0);
4824 static int alc269_resume(struct hda_codec
*codec
)
4826 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
4827 alc269_toggle_power_output(codec
, 0);
4831 codec
->patch_ops
.init(codec
);
4833 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017) {
4834 alc269_toggle_power_output(codec
, 1);
4838 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018)
4839 alc269_toggle_power_output(codec
, 1);
4841 snd_hda_codec_resume_amp(codec
);
4842 snd_hda_codec_resume_cache(codec
);
4843 hda_call_check_power_status(codec
, 0x01);
4846 #endif /* CONFIG_PM */
4848 static void alc269_fixup_hweq(struct hda_codec
*codec
,
4849 const struct alc_fixup
*fix
, int action
)
4853 if (action
!= ALC_FIXUP_ACT_INIT
)
4855 coef
= alc_read_coef_idx(codec
, 0x1e);
4856 alc_write_coef_idx(codec
, 0x1e, coef
| 0x80);
4859 static void alc271_fixup_dmic(struct hda_codec
*codec
,
4860 const struct alc_fixup
*fix
, int action
)
4862 static const struct hda_verb verbs
[] = {
4863 {0x20, AC_VERB_SET_COEF_INDEX
, 0x0d},
4864 {0x20, AC_VERB_SET_PROC_COEF
, 0x4000},
4869 if (strcmp(codec
->chip_name
, "ALC271X"))
4871 cfg
= snd_hda_codec_get_pincfg(codec
, 0x12);
4872 if (get_defcfg_connect(cfg
) == AC_JACK_PORT_FIXED
)
4873 snd_hda_sequence_write(codec
, verbs
);
4876 static void alc269_fixup_pcm_44k(struct hda_codec
*codec
,
4877 const struct alc_fixup
*fix
, int action
)
4879 struct alc_spec
*spec
= codec
->spec
;
4881 if (action
!= ALC_FIXUP_ACT_PROBE
)
4884 /* Due to a hardware problem on Lenovo Ideadpad, we need to
4885 * fix the sample rate of analog I/O to 44.1kHz
4887 spec
->stream_analog_playback
= &alc269_44k_pcm_analog_playback
;
4888 spec
->stream_analog_capture
= &alc269_44k_pcm_analog_capture
;
4891 static void alc269_fixup_stereo_dmic(struct hda_codec
*codec
,
4892 const struct alc_fixup
*fix
, int action
)
4896 if (action
!= ALC_FIXUP_ACT_INIT
)
4898 /* The digital-mic unit sends PDM (differential signal) instead of
4899 * the standard PCM, thus you can't record a valid mono stream as is.
4900 * Below is a workaround specific to ALC269 to control the dmic
4901 * signal source as mono.
4903 coef
= alc_read_coef_idx(codec
, 0x07);
4904 alc_write_coef_idx(codec
, 0x07, coef
| 0x80);
4907 static void alc269_quanta_automute(struct hda_codec
*codec
)
4909 update_outputs(codec
);
4911 snd_hda_codec_write(codec
, 0x20, 0,
4912 AC_VERB_SET_COEF_INDEX
, 0x0c);
4913 snd_hda_codec_write(codec
, 0x20, 0,
4914 AC_VERB_SET_PROC_COEF
, 0x680);
4916 snd_hda_codec_write(codec
, 0x20, 0,
4917 AC_VERB_SET_COEF_INDEX
, 0x0c);
4918 snd_hda_codec_write(codec
, 0x20, 0,
4919 AC_VERB_SET_PROC_COEF
, 0x480);
4922 static void alc269_fixup_quanta_mute(struct hda_codec
*codec
,
4923 const struct alc_fixup
*fix
, int action
)
4925 struct alc_spec
*spec
= codec
->spec
;
4926 if (action
!= ALC_FIXUP_ACT_PROBE
)
4928 spec
->automute_hook
= alc269_quanta_automute
;
4932 ALC269_FIXUP_SONY_VAIO
,
4933 ALC275_FIXUP_SONY_VAIO_GPIO2
,
4934 ALC269_FIXUP_DELL_M101Z
,
4935 ALC269_FIXUP_SKU_IGNORE
,
4936 ALC269_FIXUP_ASUS_G73JW
,
4937 ALC269_FIXUP_LENOVO_EAPD
,
4938 ALC275_FIXUP_SONY_HWEQ
,
4940 ALC269_FIXUP_PCM_44K
,
4941 ALC269_FIXUP_STEREO_DMIC
,
4942 ALC269_FIXUP_QUANTA_MUTE
,
4943 ALC269_FIXUP_LIFEBOOK
,
4946 ALC269VB_FIXUP_AMIC
,
4947 ALC269VB_FIXUP_DMIC
,
4950 static const struct alc_fixup alc269_fixups
[] = {
4951 [ALC269_FIXUP_SONY_VAIO
] = {
4952 .type
= ALC_FIXUP_VERBS
,
4953 .v
.verbs
= (const struct hda_verb
[]) {
4954 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREFGRD
},
4958 [ALC275_FIXUP_SONY_VAIO_GPIO2
] = {
4959 .type
= ALC_FIXUP_VERBS
,
4960 .v
.verbs
= (const struct hda_verb
[]) {
4961 {0x01, AC_VERB_SET_GPIO_MASK
, 0x04},
4962 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x04},
4963 {0x01, AC_VERB_SET_GPIO_DATA
, 0x00},
4967 .chain_id
= ALC269_FIXUP_SONY_VAIO
4969 [ALC269_FIXUP_DELL_M101Z
] = {
4970 .type
= ALC_FIXUP_VERBS
,
4971 .v
.verbs
= (const struct hda_verb
[]) {
4972 /* Enables internal speaker */
4973 {0x20, AC_VERB_SET_COEF_INDEX
, 13},
4974 {0x20, AC_VERB_SET_PROC_COEF
, 0x4040},
4978 [ALC269_FIXUP_SKU_IGNORE
] = {
4979 .type
= ALC_FIXUP_SKU
,
4980 .v
.sku
= ALC_FIXUP_SKU_IGNORE
,
4982 [ALC269_FIXUP_ASUS_G73JW
] = {
4983 .type
= ALC_FIXUP_PINS
,
4984 .v
.pins
= (const struct alc_pincfg
[]) {
4985 { 0x17, 0x99130111 }, /* subwoofer */
4989 [ALC269_FIXUP_LENOVO_EAPD
] = {
4990 .type
= ALC_FIXUP_VERBS
,
4991 .v
.verbs
= (const struct hda_verb
[]) {
4992 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 0},
4996 [ALC275_FIXUP_SONY_HWEQ
] = {
4997 .type
= ALC_FIXUP_FUNC
,
4998 .v
.func
= alc269_fixup_hweq
,
5000 .chain_id
= ALC275_FIXUP_SONY_VAIO_GPIO2
5002 [ALC271_FIXUP_DMIC
] = {
5003 .type
= ALC_FIXUP_FUNC
,
5004 .v
.func
= alc271_fixup_dmic
,
5006 [ALC269_FIXUP_PCM_44K
] = {
5007 .type
= ALC_FIXUP_FUNC
,
5008 .v
.func
= alc269_fixup_pcm_44k
,
5010 [ALC269_FIXUP_STEREO_DMIC
] = {
5011 .type
= ALC_FIXUP_FUNC
,
5012 .v
.func
= alc269_fixup_stereo_dmic
,
5014 [ALC269_FIXUP_QUANTA_MUTE
] = {
5015 .type
= ALC_FIXUP_FUNC
,
5016 .v
.func
= alc269_fixup_quanta_mute
,
5018 [ALC269_FIXUP_LIFEBOOK
] = {
5019 .type
= ALC_FIXUP_PINS
,
5020 .v
.pins
= (const struct alc_pincfg
[]) {
5021 { 0x1a, 0x2101103f }, /* dock line-out */
5022 { 0x1b, 0x23a11040 }, /* dock mic-in */
5026 .chain_id
= ALC269_FIXUP_QUANTA_MUTE
5028 [ALC269_FIXUP_AMIC
] = {
5029 .type
= ALC_FIXUP_PINS
,
5030 .v
.pins
= (const struct alc_pincfg
[]) {
5031 { 0x14, 0x99130110 }, /* speaker */
5032 { 0x15, 0x0121401f }, /* HP out */
5033 { 0x18, 0x01a19c20 }, /* mic */
5034 { 0x19, 0x99a3092f }, /* int-mic */
5038 [ALC269_FIXUP_DMIC
] = {
5039 .type
= ALC_FIXUP_PINS
,
5040 .v
.pins
= (const struct alc_pincfg
[]) {
5041 { 0x12, 0x99a3092f }, /* int-mic */
5042 { 0x14, 0x99130110 }, /* speaker */
5043 { 0x15, 0x0121401f }, /* HP out */
5044 { 0x18, 0x01a19c20 }, /* mic */
5048 [ALC269VB_FIXUP_AMIC
] = {
5049 .type
= ALC_FIXUP_PINS
,
5050 .v
.pins
= (const struct alc_pincfg
[]) {
5051 { 0x14, 0x99130110 }, /* speaker */
5052 { 0x18, 0x01a19c20 }, /* mic */
5053 { 0x19, 0x99a3092f }, /* int-mic */
5054 { 0x21, 0x0121401f }, /* HP out */
5058 [ALC269_FIXUP_DMIC
] = {
5059 .type
= ALC_FIXUP_PINS
,
5060 .v
.pins
= (const struct alc_pincfg
[]) {
5061 { 0x12, 0x99a3092f }, /* int-mic */
5062 { 0x14, 0x99130110 }, /* speaker */
5063 { 0x18, 0x01a19c20 }, /* mic */
5064 { 0x21, 0x0121401f }, /* HP out */
5070 static const struct snd_pci_quirk alc269_fixup_tbl
[] = {
5071 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW
),
5072 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC
),
5073 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC
),
5074 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC
),
5075 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC
),
5076 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC
),
5077 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2
),
5078 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ
),
5079 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ
),
5080 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO
),
5081 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z
),
5082 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC
),
5083 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK
),
5084 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE
),
5085 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE
),
5086 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE
),
5087 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE
),
5088 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE
),
5089 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE
),
5090 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K
),
5091 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD
),
5094 /* Below is a quirk table taken from the old code.
5095 * Basically the device should work as is without the fixup table.
5096 * If BIOS doesn't give a proper info, enable the corresponding
5099 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
5101 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC
),
5102 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269_FIXUP_AMIC
),
5103 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC
),
5104 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC
),
5105 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC
),
5106 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC
),
5107 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC
),
5108 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC
),
5109 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC
),
5110 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC
),
5111 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC
),
5112 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC
),
5113 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC
),
5114 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC
),
5115 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC
),
5116 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC
),
5117 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC
),
5118 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC
),
5119 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC
),
5120 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC
),
5121 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC
),
5122 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC
),
5123 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC
),
5124 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC
),
5125 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC
),
5126 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC
),
5127 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC
),
5128 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC
),
5129 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC
),
5130 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC
),
5131 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC
),
5132 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC
),
5133 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC
),
5134 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC
),
5135 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC
),
5136 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC
),
5137 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC
),
5138 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC
),
5139 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC
),
5140 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC
),
5145 static const struct alc_model_fixup alc269_fixup_models
[] = {
5146 {.id
= ALC269_FIXUP_AMIC
, .name
= "laptop-amic"},
5147 {.id
= ALC269_FIXUP_DMIC
, .name
= "laptop-dmic"},
5152 static int alc269_fill_coef(struct hda_codec
*codec
)
5156 if ((alc_get_coef0(codec
) & 0x00ff) < 0x015) {
5157 alc_write_coef_idx(codec
, 0xf, 0x960b);
5158 alc_write_coef_idx(codec
, 0xe, 0x8817);
5161 if ((alc_get_coef0(codec
) & 0x00ff) == 0x016) {
5162 alc_write_coef_idx(codec
, 0xf, 0x960b);
5163 alc_write_coef_idx(codec
, 0xe, 0x8814);
5166 if ((alc_get_coef0(codec
) & 0x00ff) == 0x017) {
5167 val
= alc_read_coef_idx(codec
, 0x04);
5168 /* Power up output pin */
5169 alc_write_coef_idx(codec
, 0x04, val
| (1<<11));
5172 if ((alc_get_coef0(codec
) & 0x00ff) == 0x018) {
5173 val
= alc_read_coef_idx(codec
, 0xd);
5174 if ((val
& 0x0c00) >> 10 != 0x1) {
5175 /* Capless ramp up clock control */
5176 alc_write_coef_idx(codec
, 0xd, val
| (1<<10));
5178 val
= alc_read_coef_idx(codec
, 0x17);
5179 if ((val
& 0x01c0) >> 6 != 0x4) {
5180 /* Class D power on reset */
5181 alc_write_coef_idx(codec
, 0x17, val
| (1<<7));
5185 val
= alc_read_coef_idx(codec
, 0xd); /* Class D */
5186 alc_write_coef_idx(codec
, 0xd, val
| (1<<14));
5188 val
= alc_read_coef_idx(codec
, 0x4); /* HP */
5189 alc_write_coef_idx(codec
, 0x4, val
| (1<<11));
5196 static int patch_alc269(struct hda_codec
*codec
)
5198 struct alc_spec
*spec
;
5201 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5207 spec
->mixer_nid
= 0x0b;
5209 alc_auto_parse_customize_define(codec
);
5211 err
= alc_codec_rename_from_preset(codec
);
5215 if (codec
->vendor_id
== 0x10ec0269) {
5216 spec
->codec_variant
= ALC269_TYPE_ALC269VA
;
5217 switch (alc_get_coef0(codec
) & 0x00f0) {
5219 if (codec
->bus
->pci
->subsystem_vendor
== 0x1025 &&
5220 spec
->cdefine
.platform_type
== 1)
5221 err
= alc_codec_rename(codec
, "ALC271X");
5222 spec
->codec_variant
= ALC269_TYPE_ALC269VB
;
5225 if (codec
->bus
->pci
->subsystem_vendor
== 0x17aa &&
5226 codec
->bus
->pci
->subsystem_device
== 0x21f3)
5227 err
= alc_codec_rename(codec
, "ALC3202");
5228 spec
->codec_variant
= ALC269_TYPE_ALC269VC
;
5231 alc_fix_pll_init(codec
, 0x20, 0x04, 15);
5235 alc269_fill_coef(codec
);
5238 alc_pick_fixup(codec
, alc269_fixup_models
,
5239 alc269_fixup_tbl
, alc269_fixups
);
5240 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5242 /* automatic parse from the BIOS config */
5243 err
= alc269_parse_auto_config(codec
);
5247 if (!spec
->no_analog
&& !spec
->adc_nids
) {
5248 alc_auto_fill_adc_caps(codec
);
5249 alc_rebuild_imux_for_auto_mic(codec
);
5250 alc_remove_invalid_adc_nids(codec
);
5253 if (!spec
->no_analog
&& !spec
->cap_mixer
)
5254 set_capture_mixer(codec
);
5256 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
5257 err
= snd_hda_attach_beep_device(codec
, 0x1);
5260 set_beep_amp(spec
, 0x0b, 0x04, HDA_INPUT
);
5263 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5265 spec
->vmaster_nid
= 0x02;
5267 codec
->patch_ops
= alc_patch_ops
;
5269 codec
->patch_ops
.resume
= alc269_resume
;
5271 spec
->init_hook
= alc_auto_init_std
;
5272 spec
->shutup
= alc269_shutup
;
5274 alc_init_jacks(codec
);
5275 #ifdef CONFIG_SND_HDA_POWER_SAVE
5276 if (!spec
->loopback
.amplist
)
5277 spec
->loopback
.amplist
= alc269_loopbacks
;
5278 if (alc269_mic2_for_mute_led(codec
))
5279 codec
->patch_ops
.check_power_status
= alc269_mic2_mute_check_ps
;
5293 static int alc861_parse_auto_config(struct hda_codec
*codec
)
5295 static const hda_nid_t alc861_ignore
[] = { 0x1d, 0 };
5296 static const hda_nid_t alc861_ssids
[] = { 0x0e, 0x0f, 0x0b, 0 };
5297 return alc_parse_auto_config(codec
, alc861_ignore
, alc861_ssids
);
5300 #ifdef CONFIG_SND_HDA_POWER_SAVE
5301 static const struct hda_amp_list alc861_loopbacks
[] = {
5302 { 0x15, HDA_INPUT
, 0 },
5303 { 0x15, HDA_INPUT
, 1 },
5304 { 0x15, HDA_INPUT
, 2 },
5305 { 0x15, HDA_INPUT
, 3 },
5311 /* Pin config fixes */
5313 PINFIX_FSC_AMILO_PI1505
,
5316 static const struct alc_fixup alc861_fixups
[] = {
5317 [PINFIX_FSC_AMILO_PI1505
] = {
5318 .type
= ALC_FIXUP_PINS
,
5319 .v
.pins
= (const struct alc_pincfg
[]) {
5320 { 0x0b, 0x0221101f }, /* HP */
5321 { 0x0f, 0x90170310 }, /* speaker */
5327 static const struct snd_pci_quirk alc861_fixup_tbl
[] = {
5328 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505
),
5334 static int patch_alc861(struct hda_codec
*codec
)
5336 struct alc_spec
*spec
;
5339 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5345 spec
->mixer_nid
= 0x15;
5347 alc_pick_fixup(codec
, NULL
, alc861_fixup_tbl
, alc861_fixups
);
5348 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5350 /* automatic parse from the BIOS config */
5351 err
= alc861_parse_auto_config(codec
);
5355 if (!spec
->no_analog
&& !spec
->adc_nids
) {
5356 alc_auto_fill_adc_caps(codec
);
5357 alc_rebuild_imux_for_auto_mic(codec
);
5358 alc_remove_invalid_adc_nids(codec
);
5361 if (!spec
->no_analog
&& !spec
->cap_mixer
)
5362 set_capture_mixer(codec
);
5364 if (!spec
->no_analog
) {
5365 err
= snd_hda_attach_beep_device(codec
, 0x23);
5368 set_beep_amp(spec
, 0x23, 0, HDA_OUTPUT
);
5371 spec
->vmaster_nid
= 0x03;
5373 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5375 codec
->patch_ops
= alc_patch_ops
;
5376 spec
->init_hook
= alc_auto_init_std
;
5377 #ifdef CONFIG_SND_HDA_POWER_SAVE
5378 spec
->power_hook
= alc_power_eapd
;
5379 if (!spec
->loopback
.amplist
)
5380 spec
->loopback
.amplist
= alc861_loopbacks
;
5395 * In addition, an independent DAC
5397 #ifdef CONFIG_SND_HDA_POWER_SAVE
5398 #define alc861vd_loopbacks alc880_loopbacks
5401 static int alc861vd_parse_auto_config(struct hda_codec
*codec
)
5403 static const hda_nid_t alc861vd_ignore
[] = { 0x1d, 0 };
5404 static const hda_nid_t alc861vd_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5405 return alc_parse_auto_config(codec
, alc861vd_ignore
, alc861vd_ssids
);
5409 ALC660VD_FIX_ASUS_GPIO1
,
5410 ALC861VD_FIX_DALLAS
,
5413 /* exclude VREF80 */
5414 static void alc861vd_fixup_dallas(struct hda_codec
*codec
,
5415 const struct alc_fixup
*fix
, int action
)
5417 if (action
== ALC_FIXUP_ACT_PRE_PROBE
) {
5418 snd_hda_override_pin_caps(codec
, 0x18, 0x00001714);
5419 snd_hda_override_pin_caps(codec
, 0x19, 0x0000171c);
5423 static const struct alc_fixup alc861vd_fixups
[] = {
5424 [ALC660VD_FIX_ASUS_GPIO1
] = {
5425 .type
= ALC_FIXUP_VERBS
,
5426 .v
.verbs
= (const struct hda_verb
[]) {
5428 {0x01, AC_VERB_SET_GPIO_MASK
, 0x03},
5429 {0x01, AC_VERB_SET_GPIO_DIRECTION
, 0x01},
5430 {0x01, AC_VERB_SET_GPIO_DATA
, 0x01},
5434 [ALC861VD_FIX_DALLAS
] = {
5435 .type
= ALC_FIXUP_FUNC
,
5436 .v
.func
= alc861vd_fixup_dallas
,
5440 static const struct snd_pci_quirk alc861vd_fixup_tbl
[] = {
5441 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS
),
5442 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1
),
5443 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS
),
5447 static const struct hda_verb alc660vd_eapd_verbs
[] = {
5448 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 2},
5449 {0x15, AC_VERB_SET_EAPD_BTLENABLE
, 2},
5455 static int patch_alc861vd(struct hda_codec
*codec
)
5457 struct alc_spec
*spec
;
5460 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5466 spec
->mixer_nid
= 0x0b;
5468 alc_pick_fixup(codec
, NULL
, alc861vd_fixup_tbl
, alc861vd_fixups
);
5469 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5471 /* automatic parse from the BIOS config */
5472 err
= alc861vd_parse_auto_config(codec
);
5476 if (codec
->vendor_id
== 0x10ec0660) {
5477 /* always turn on EAPD */
5478 add_verb(spec
, alc660vd_eapd_verbs
);
5481 if (!spec
->no_analog
&& !spec
->adc_nids
) {
5482 alc_auto_fill_adc_caps(codec
);
5483 alc_rebuild_imux_for_auto_mic(codec
);
5484 alc_remove_invalid_adc_nids(codec
);
5487 if (!spec
->no_analog
&& !spec
->cap_mixer
)
5488 set_capture_mixer(codec
);
5490 if (!spec
->no_analog
) {
5491 err
= snd_hda_attach_beep_device(codec
, 0x23);
5494 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
5497 spec
->vmaster_nid
= 0x02;
5499 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5501 codec
->patch_ops
= alc_patch_ops
;
5503 spec
->init_hook
= alc_auto_init_std
;
5504 spec
->shutup
= alc_eapd_shutup
;
5505 #ifdef CONFIG_SND_HDA_POWER_SAVE
5506 if (!spec
->loopback
.amplist
)
5507 spec
->loopback
.amplist
= alc861vd_loopbacks
;
5520 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
5521 * configuration. Each pin widget can choose any input DACs and a mixer.
5522 * Each ADC is connected from a mixer of all inputs. This makes possible
5523 * 6-channel independent captures.
5525 * In addition, an independent DAC for the multi-playback (not used in this
5528 #ifdef CONFIG_SND_HDA_POWER_SAVE
5529 #define alc662_loopbacks alc880_loopbacks
5533 * BIOS auto configuration
5536 static int alc662_parse_auto_config(struct hda_codec
*codec
)
5538 static const hda_nid_t alc662_ignore
[] = { 0x1d, 0 };
5539 static const hda_nid_t alc663_ssids
[] = { 0x15, 0x1b, 0x14, 0x21 };
5540 static const hda_nid_t alc662_ssids
[] = { 0x15, 0x1b, 0x14, 0 };
5541 const hda_nid_t
*ssids
;
5543 if (codec
->vendor_id
== 0x10ec0272 || codec
->vendor_id
== 0x10ec0663 ||
5544 codec
->vendor_id
== 0x10ec0665 || codec
->vendor_id
== 0x10ec0670)
5545 ssids
= alc663_ssids
;
5547 ssids
= alc662_ssids
;
5548 return alc_parse_auto_config(codec
, alc662_ignore
, ssids
);
5551 static void alc272_fixup_mario(struct hda_codec
*codec
,
5552 const struct alc_fixup
*fix
, int action
)
5554 if (action
!= ALC_FIXUP_ACT_PROBE
)
5556 if (snd_hda_override_amp_caps(codec
, 0x2, HDA_OUTPUT
,
5557 (0x3b << AC_AMPCAP_OFFSET_SHIFT
) |
5558 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT
) |
5559 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
5560 (0 << AC_AMPCAP_MUTE_SHIFT
)))
5562 "hda_codec: failed to override amp caps for NID 0x2\n");
5566 ALC662_FIXUP_ASPIRE
,
5567 ALC662_FIXUP_IDEAPAD
,
5569 ALC662_FIXUP_CZC_P10T
,
5570 ALC662_FIXUP_SKU_IGNORE
,
5571 ALC662_FIXUP_HP_RP5800
,
5572 ALC662_FIXUP_ASUS_MODE1
,
5573 ALC662_FIXUP_ASUS_MODE2
,
5574 ALC662_FIXUP_ASUS_MODE3
,
5575 ALC662_FIXUP_ASUS_MODE4
,
5576 ALC662_FIXUP_ASUS_MODE5
,
5577 ALC662_FIXUP_ASUS_MODE6
,
5578 ALC662_FIXUP_ASUS_MODE7
,
5579 ALC662_FIXUP_ASUS_MODE8
,
5582 static const struct alc_fixup alc662_fixups
[] = {
5583 [ALC662_FIXUP_ASPIRE
] = {
5584 .type
= ALC_FIXUP_PINS
,
5585 .v
.pins
= (const struct alc_pincfg
[]) {
5586 { 0x15, 0x99130112 }, /* subwoofer */
5590 [ALC662_FIXUP_IDEAPAD
] = {
5591 .type
= ALC_FIXUP_PINS
,
5592 .v
.pins
= (const struct alc_pincfg
[]) {
5593 { 0x17, 0x99130112 }, /* subwoofer */
5597 [ALC272_FIXUP_MARIO
] = {
5598 .type
= ALC_FIXUP_FUNC
,
5599 .v
.func
= alc272_fixup_mario
,
5601 [ALC662_FIXUP_CZC_P10T
] = {
5602 .type
= ALC_FIXUP_VERBS
,
5603 .v
.verbs
= (const struct hda_verb
[]) {
5604 {0x14, AC_VERB_SET_EAPD_BTLENABLE
, 0},
5608 [ALC662_FIXUP_SKU_IGNORE
] = {
5609 .type
= ALC_FIXUP_SKU
,
5610 .v
.sku
= ALC_FIXUP_SKU_IGNORE
,
5612 [ALC662_FIXUP_HP_RP5800
] = {
5613 .type
= ALC_FIXUP_PINS
,
5614 .v
.pins
= (const struct alc_pincfg
[]) {
5615 { 0x14, 0x0221201f }, /* HP out */
5619 .chain_id
= ALC662_FIXUP_SKU_IGNORE
5621 [ALC662_FIXUP_ASUS_MODE1
] = {
5622 .type
= ALC_FIXUP_PINS
,
5623 .v
.pins
= (const struct alc_pincfg
[]) {
5624 { 0x14, 0x99130110 }, /* speaker */
5625 { 0x18, 0x01a19c20 }, /* mic */
5626 { 0x19, 0x99a3092f }, /* int-mic */
5627 { 0x21, 0x0121401f }, /* HP out */
5631 .chain_id
= ALC662_FIXUP_SKU_IGNORE
5633 [ALC662_FIXUP_ASUS_MODE2
] = {
5634 .type
= ALC_FIXUP_PINS
,
5635 .v
.pins
= (const struct alc_pincfg
[]) {
5636 { 0x14, 0x99130110 }, /* speaker */
5637 { 0x18, 0x01a19820 }, /* mic */
5638 { 0x19, 0x99a3092f }, /* int-mic */
5639 { 0x1b, 0x0121401f }, /* HP out */
5643 .chain_id
= ALC662_FIXUP_SKU_IGNORE
5645 [ALC662_FIXUP_ASUS_MODE3
] = {
5646 .type
= ALC_FIXUP_PINS
,
5647 .v
.pins
= (const struct alc_pincfg
[]) {
5648 { 0x14, 0x99130110 }, /* speaker */
5649 { 0x15, 0x0121441f }, /* HP */
5650 { 0x18, 0x01a19840 }, /* mic */
5651 { 0x19, 0x99a3094f }, /* int-mic */
5652 { 0x21, 0x01211420 }, /* HP2 */
5656 .chain_id
= ALC662_FIXUP_SKU_IGNORE
5658 [ALC662_FIXUP_ASUS_MODE4
] = {
5659 .type
= ALC_FIXUP_PINS
,
5660 .v
.pins
= (const struct alc_pincfg
[]) {
5661 { 0x14, 0x99130110 }, /* speaker */
5662 { 0x16, 0x99130111 }, /* speaker */
5663 { 0x18, 0x01a19840 }, /* mic */
5664 { 0x19, 0x99a3094f }, /* int-mic */
5665 { 0x21, 0x0121441f }, /* HP */
5669 .chain_id
= ALC662_FIXUP_SKU_IGNORE
5671 [ALC662_FIXUP_ASUS_MODE5
] = {
5672 .type
= ALC_FIXUP_PINS
,
5673 .v
.pins
= (const struct alc_pincfg
[]) {
5674 { 0x14, 0x99130110 }, /* speaker */
5675 { 0x15, 0x0121441f }, /* HP */
5676 { 0x16, 0x99130111 }, /* speaker */
5677 { 0x18, 0x01a19840 }, /* mic */
5678 { 0x19, 0x99a3094f }, /* int-mic */
5682 .chain_id
= ALC662_FIXUP_SKU_IGNORE
5684 [ALC662_FIXUP_ASUS_MODE6
] = {
5685 .type
= ALC_FIXUP_PINS
,
5686 .v
.pins
= (const struct alc_pincfg
[]) {
5687 { 0x14, 0x99130110 }, /* speaker */
5688 { 0x15, 0x01211420 }, /* HP2 */
5689 { 0x18, 0x01a19840 }, /* mic */
5690 { 0x19, 0x99a3094f }, /* int-mic */
5691 { 0x1b, 0x0121441f }, /* HP */
5695 .chain_id
= ALC662_FIXUP_SKU_IGNORE
5697 [ALC662_FIXUP_ASUS_MODE7
] = {
5698 .type
= ALC_FIXUP_PINS
,
5699 .v
.pins
= (const struct alc_pincfg
[]) {
5700 { 0x14, 0x99130110 }, /* speaker */
5701 { 0x17, 0x99130111 }, /* speaker */
5702 { 0x18, 0x01a19840 }, /* mic */
5703 { 0x19, 0x99a3094f }, /* int-mic */
5704 { 0x1b, 0x01214020 }, /* HP */
5705 { 0x21, 0x0121401f }, /* HP */
5709 .chain_id
= ALC662_FIXUP_SKU_IGNORE
5711 [ALC662_FIXUP_ASUS_MODE8
] = {
5712 .type
= ALC_FIXUP_PINS
,
5713 .v
.pins
= (const struct alc_pincfg
[]) {
5714 { 0x14, 0x99130110 }, /* speaker */
5715 { 0x12, 0x99a30970 }, /* int-mic */
5716 { 0x15, 0x01214020 }, /* HP */
5717 { 0x17, 0x99130111 }, /* speaker */
5718 { 0x18, 0x01a19840 }, /* mic */
5719 { 0x21, 0x0121401f }, /* HP */
5723 .chain_id
= ALC662_FIXUP_SKU_IGNORE
5727 static const struct snd_pci_quirk alc662_fixup_tbl
[] = {
5728 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2
),
5729 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE
),
5730 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE
),
5731 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE
),
5732 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800
),
5733 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2
),
5734 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD
),
5735 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD
),
5736 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD
),
5737 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T
),
5740 /* Below is a quirk table taken from the old code.
5741 * Basically the device should work as is without the fixup table.
5742 * If BIOS doesn't give a proper info, enable the corresponding
5745 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1
),
5746 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3
),
5747 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1
),
5748 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3
),
5749 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
5750 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
5751 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
5752 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1
),
5753 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1
),
5754 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
5755 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7
),
5756 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7
),
5757 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8
),
5758 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3
),
5759 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1
),
5760 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
5761 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2
),
5762 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1
),
5763 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
5764 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
5765 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
5766 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
5767 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1
),
5768 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3
),
5769 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2
),
5770 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
5771 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5
),
5772 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6
),
5773 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
5774 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1
),
5775 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
5776 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
5777 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3
),
5778 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3
),
5779 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1
),
5780 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1
),
5781 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1
),
5782 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1
),
5783 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1
),
5784 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2
),
5785 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2
),
5786 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1
),
5787 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
5788 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3
),
5789 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1
),
5790 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1
),
5791 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1
),
5792 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2
),
5793 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1
),
5794 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4
),
5799 static const struct alc_model_fixup alc662_fixup_models
[] = {
5800 {.id
= ALC272_FIXUP_MARIO
, .name
= "mario"},
5801 {.id
= ALC662_FIXUP_ASUS_MODE1
, .name
= "asus-mode1"},
5802 {.id
= ALC662_FIXUP_ASUS_MODE2
, .name
= "asus-mode2"},
5803 {.id
= ALC662_FIXUP_ASUS_MODE3
, .name
= "asus-mode3"},
5804 {.id
= ALC662_FIXUP_ASUS_MODE4
, .name
= "asus-mode4"},
5805 {.id
= ALC662_FIXUP_ASUS_MODE5
, .name
= "asus-mode5"},
5806 {.id
= ALC662_FIXUP_ASUS_MODE6
, .name
= "asus-mode6"},
5807 {.id
= ALC662_FIXUP_ASUS_MODE7
, .name
= "asus-mode7"},
5808 {.id
= ALC662_FIXUP_ASUS_MODE8
, .name
= "asus-mode8"},
5815 static int patch_alc662(struct hda_codec
*codec
)
5817 struct alc_spec
*spec
;
5820 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5826 spec
->mixer_nid
= 0x0b;
5828 /* handle multiple HPs as is */
5829 spec
->parse_flags
= HDA_PINCFG_NO_HP_FIXUP
;
5831 alc_auto_parse_customize_define(codec
);
5833 alc_fix_pll_init(codec
, 0x20, 0x04, 15);
5835 err
= alc_codec_rename_from_preset(codec
);
5839 if ((alc_get_coef0(codec
) & (1 << 14)) &&
5840 codec
->bus
->pci
->subsystem_vendor
== 0x1025 &&
5841 spec
->cdefine
.platform_type
== 1) {
5842 if (alc_codec_rename(codec
, "ALC272X") < 0)
5846 alc_pick_fixup(codec
, alc662_fixup_models
,
5847 alc662_fixup_tbl
, alc662_fixups
);
5848 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PRE_PROBE
);
5849 /* automatic parse from the BIOS config */
5850 err
= alc662_parse_auto_config(codec
);
5854 if (!spec
->no_analog
&& !spec
->adc_nids
) {
5855 alc_auto_fill_adc_caps(codec
);
5856 alc_rebuild_imux_for_auto_mic(codec
);
5857 alc_remove_invalid_adc_nids(codec
);
5860 if (!spec
->no_analog
&& !spec
->cap_mixer
)
5861 set_capture_mixer(codec
);
5863 if (!spec
->no_analog
&& has_cdefine_beep(codec
)) {
5864 err
= snd_hda_attach_beep_device(codec
, 0x1);
5867 switch (codec
->vendor_id
) {
5869 set_beep_amp(spec
, 0x0b, 0x05, HDA_INPUT
);
5874 set_beep_amp(spec
, 0x0b, 0x04, HDA_INPUT
);
5877 set_beep_amp(spec
, 0x0b, 0x03, HDA_INPUT
);
5881 spec
->vmaster_nid
= 0x02;
5883 alc_apply_fixup(codec
, ALC_FIXUP_ACT_PROBE
);
5885 codec
->patch_ops
= alc_patch_ops
;
5886 spec
->init_hook
= alc_auto_init_std
;
5887 spec
->shutup
= alc_eapd_shutup
;
5889 alc_init_jacks(codec
);
5891 #ifdef CONFIG_SND_HDA_POWER_SAVE
5892 if (!spec
->loopback
.amplist
)
5893 spec
->loopback
.amplist
= alc662_loopbacks
;
5907 static int alc680_parse_auto_config(struct hda_codec
*codec
)
5909 return alc_parse_auto_config(codec
, NULL
, NULL
);
5914 static int patch_alc680(struct hda_codec
*codec
)
5916 struct alc_spec
*spec
;
5919 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5925 /* ALC680 has no aa-loopback mixer */
5927 /* automatic parse from the BIOS config */
5928 err
= alc680_parse_auto_config(codec
);
5934 if (!spec
->no_analog
&& !spec
->cap_mixer
)
5935 set_capture_mixer(codec
);
5937 spec
->vmaster_nid
= 0x02;
5939 codec
->patch_ops
= alc_patch_ops
;
5940 spec
->init_hook
= alc_auto_init_std
;
5948 static const struct hda_codec_preset snd_hda_preset_realtek
[] = {
5949 { .id
= 0x10ec0221, .name
= "ALC221", .patch
= patch_alc269
},
5950 { .id
= 0x10ec0260, .name
= "ALC260", .patch
= patch_alc260
},
5951 { .id
= 0x10ec0262, .name
= "ALC262", .patch
= patch_alc262
},
5952 { .id
= 0x10ec0267, .name
= "ALC267", .patch
= patch_alc268
},
5953 { .id
= 0x10ec0268, .name
= "ALC268", .patch
= patch_alc268
},
5954 { .id
= 0x10ec0269, .name
= "ALC269", .patch
= patch_alc269
},
5955 { .id
= 0x10ec0270, .name
= "ALC270", .patch
= patch_alc269
},
5956 { .id
= 0x10ec0272, .name
= "ALC272", .patch
= patch_alc662
},
5957 { .id
= 0x10ec0275, .name
= "ALC275", .patch
= patch_alc269
},
5958 { .id
= 0x10ec0276, .name
= "ALC276", .patch
= patch_alc269
},
5959 { .id
= 0x10ec0861, .rev
= 0x100340, .name
= "ALC660",
5960 .patch
= patch_alc861
},
5961 { .id
= 0x10ec0660, .name
= "ALC660-VD", .patch
= patch_alc861vd
},
5962 { .id
= 0x10ec0861, .name
= "ALC861", .patch
= patch_alc861
},
5963 { .id
= 0x10ec0862, .name
= "ALC861-VD", .patch
= patch_alc861vd
},
5964 { .id
= 0x10ec0662, .rev
= 0x100002, .name
= "ALC662 rev2",
5965 .patch
= patch_alc882
},
5966 { .id
= 0x10ec0662, .rev
= 0x100101, .name
= "ALC662 rev1",
5967 .patch
= patch_alc662
},
5968 { .id
= 0x10ec0662, .rev
= 0x100300, .name
= "ALC662 rev3",
5969 .patch
= patch_alc662
},
5970 { .id
= 0x10ec0663, .name
= "ALC663", .patch
= patch_alc662
},
5971 { .id
= 0x10ec0665, .name
= "ALC665", .patch
= patch_alc662
},
5972 { .id
= 0x10ec0670, .name
= "ALC670", .patch
= patch_alc662
},
5973 { .id
= 0x10ec0680, .name
= "ALC680", .patch
= patch_alc680
},
5974 { .id
= 0x10ec0880, .name
= "ALC880", .patch
= patch_alc880
},
5975 { .id
= 0x10ec0882, .name
= "ALC882", .patch
= patch_alc882
},
5976 { .id
= 0x10ec0883, .name
= "ALC883", .patch
= patch_alc882
},
5977 { .id
= 0x10ec0885, .rev
= 0x100101, .name
= "ALC889A",
5978 .patch
= patch_alc882
},
5979 { .id
= 0x10ec0885, .rev
= 0x100103, .name
= "ALC889A",
5980 .patch
= patch_alc882
},
5981 { .id
= 0x10ec0885, .name
= "ALC885", .patch
= patch_alc882
},
5982 { .id
= 0x10ec0887, .name
= "ALC887", .patch
= patch_alc882
},
5983 { .id
= 0x10ec0888, .rev
= 0x100101, .name
= "ALC1200",
5984 .patch
= patch_alc882
},
5985 { .id
= 0x10ec0888, .name
= "ALC888", .patch
= patch_alc882
},
5986 { .id
= 0x10ec0889, .name
= "ALC889", .patch
= patch_alc882
},
5987 { .id
= 0x10ec0892, .name
= "ALC892", .patch
= patch_alc662
},
5988 { .id
= 0x10ec0899, .name
= "ALC898", .patch
= patch_alc882
},
5992 MODULE_ALIAS("snd-hda-codec-id:10ec*");
5994 MODULE_LICENSE("GPL");
5995 MODULE_DESCRIPTION("Realtek HD-audio codec");
5997 static struct hda_codec_preset_list realtek_list
= {
5998 .preset
= snd_hda_preset_realtek
,
5999 .owner
= THIS_MODULE
,
6002 static int __init
patch_realtek_init(void)
6004 return snd_hda_add_codec_preset(&realtek_list
);
6007 static void __exit
patch_realtek_exit(void)
6009 snd_hda_delete_codec_preset(&realtek_list
);
6012 module_init(patch_realtek_init
)
6013 module_exit(patch_realtek_exit
)