Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Universal Interface for Intel High Definition Audio Codec | |
3 | * | |
1d045db9 | 4 | * HD audio interface patch for Realtek ALC codecs |
1da177e4 | 5 | * |
df694daa KY |
6 | * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> |
7 | * PeiSen Hou <pshou@realtek.com.tw> | |
1da177e4 | 8 | * Takashi Iwai <tiwai@suse.de> |
409a3e98 | 9 | * Jonathan Woithe <jwoithe@just42.net> |
1da177e4 LT |
10 | * |
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. | |
15 | * | |
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. | |
20 | * | |
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 | |
24 | */ | |
25 | ||
1da177e4 LT |
26 | #include <linux/init.h> |
27 | #include <linux/delay.h> | |
28 | #include <linux/slab.h> | |
29 | #include <linux/pci.h> | |
08fb0d0e | 30 | #include <linux/dmi.h> |
da155d5b | 31 | #include <linux/module.h> |
1da177e4 | 32 | #include <sound/core.h> |
9ad0e496 | 33 | #include <sound/jack.h> |
1da177e4 LT |
34 | #include "hda_codec.h" |
35 | #include "hda_local.h" | |
23d30f28 | 36 | #include "hda_auto_parser.h" |
1835a0f9 | 37 | #include "hda_jack.h" |
08c189f2 | 38 | #include "hda_generic.h" |
1da177e4 | 39 | |
1d045db9 | 40 | /* unsol event tags */ |
08c189f2 | 41 | #define ALC_DCVOL_EVENT 0x08 |
d4a86d81 | 42 | |
df694daa KY |
43 | /* for GPIO Poll */ |
44 | #define GPIO_MASK 0x03 | |
45 | ||
4a79ba34 TI |
46 | /* extra amp-initialization sequence types */ |
47 | enum { | |
48 | ALC_INIT_NONE, | |
49 | ALC_INIT_DEFAULT, | |
50 | ALC_INIT_GPIO1, | |
51 | ALC_INIT_GPIO2, | |
52 | ALC_INIT_GPIO3, | |
53 | }; | |
54 | ||
73bdd597 DH |
55 | enum { |
56 | ALC_HEADSET_MODE_UNKNOWN, | |
57 | ALC_HEADSET_MODE_UNPLUGGED, | |
58 | ALC_HEADSET_MODE_HEADSET, | |
59 | ALC_HEADSET_MODE_MIC, | |
60 | ALC_HEADSET_MODE_HEADPHONE, | |
61 | }; | |
62 | ||
63 | enum { | |
64 | ALC_HEADSET_TYPE_UNKNOWN, | |
65 | ALC_HEADSET_TYPE_CTIA, | |
66 | ALC_HEADSET_TYPE_OMTP, | |
67 | }; | |
68 | ||
da00c244 KY |
69 | struct alc_customize_define { |
70 | unsigned int sku_cfg; | |
71 | unsigned char port_connectivity; | |
72 | unsigned char check_sum; | |
73 | unsigned char customization; | |
74 | unsigned char external_amp; | |
75 | unsigned int enable_pcbeep:1; | |
76 | unsigned int platform_type:1; | |
77 | unsigned int swap:1; | |
78 | unsigned int override:1; | |
90622917 | 79 | unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */ |
da00c244 KY |
80 | }; |
81 | ||
1da177e4 | 82 | struct alc_spec { |
08c189f2 | 83 | struct hda_gen_spec gen; /* must be at head */ |
23d30f28 | 84 | |
1da177e4 | 85 | /* codec parameterization */ |
a9111321 | 86 | const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
1da177e4 | 87 | unsigned int num_mixers; |
45bdd1c1 | 88 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
1da177e4 | 89 | |
da00c244 | 90 | struct alc_customize_define cdefine; |
08c189f2 | 91 | unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */ |
834be88d | 92 | |
08c189f2 TI |
93 | /* inverted dmic fix */ |
94 | unsigned int inv_dmic_fixup:1; /* has inverted digital-mic workaround */ | |
95 | unsigned int inv_dmic_muted:1; /* R-ch of inv d-mic is muted? */ | |
125821ae | 96 | hda_nid_t inv_dmic_pin; |
834be88d | 97 | |
08fb0d0e TI |
98 | /* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */ |
99 | int mute_led_polarity; | |
100 | hda_nid_t mute_led_nid; | |
101 | ||
9f5c6faf TI |
102 | unsigned int gpio_led; /* used for alc269_fixup_hp_gpio_led() */ |
103 | ||
73bdd597 DH |
104 | hda_nid_t headset_mic_pin; |
105 | hda_nid_t headphone_mic_pin; | |
106 | int current_headset_mode; | |
107 | int current_headset_type; | |
108 | ||
ae6b813a TI |
109 | /* hooks */ |
110 | void (*init_hook)(struct hda_codec *codec); | |
83012a7c | 111 | #ifdef CONFIG_PM |
c97259df | 112 | void (*power_hook)(struct hda_codec *codec); |
f5de24b0 | 113 | #endif |
1c716153 | 114 | void (*shutup)(struct hda_codec *codec); |
d922b51d | 115 | |
4a79ba34 | 116 | int init_amp; |
d433a678 | 117 | int codec_variant; /* flag for other variants */ |
e64f14f4 | 118 | |
2c3bf9ab TI |
119 | /* for PLL fix */ |
120 | hda_nid_t pll_nid; | |
121 | unsigned int pll_coef_idx, pll_coef_bit; | |
1bb7e43e | 122 | unsigned int coef0; |
df694daa KY |
123 | }; |
124 | ||
d88897ea | 125 | /* |
1d045db9 TI |
126 | * Append the given mixer and verb elements for the later use |
127 | * The mixer array is referred in build_controls(), and init_verbs are | |
128 | * called in init(). | |
d88897ea | 129 | */ |
a9111321 | 130 | static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix) |
d88897ea TI |
131 | { |
132 | if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) | |
133 | return; | |
134 | spec->mixers[spec->num_mixers++] = mix; | |
135 | } | |
136 | ||
df694daa | 137 | /* |
1d045db9 | 138 | * GPIO setup tables, used in initialization |
df694daa | 139 | */ |
bc9f98a9 | 140 | /* Enable GPIO mask and set output */ |
a9111321 | 141 | static const struct hda_verb alc_gpio1_init_verbs[] = { |
bc9f98a9 KY |
142 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
143 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
144 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
145 | { } | |
146 | }; | |
147 | ||
a9111321 | 148 | static const struct hda_verb alc_gpio2_init_verbs[] = { |
bc9f98a9 KY |
149 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
150 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, | |
151 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, | |
152 | { } | |
153 | }; | |
154 | ||
a9111321 | 155 | static const struct hda_verb alc_gpio3_init_verbs[] = { |
bdd148a3 KY |
156 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
157 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
158 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
159 | { } | |
160 | }; | |
161 | ||
2c3bf9ab TI |
162 | /* |
163 | * Fix hardware PLL issue | |
164 | * On some codecs, the analog PLL gating control must be off while | |
165 | * the default value is 1. | |
166 | */ | |
167 | static void alc_fix_pll(struct hda_codec *codec) | |
168 | { | |
169 | struct alc_spec *spec = codec->spec; | |
170 | unsigned int val; | |
171 | ||
172 | if (!spec->pll_nid) | |
173 | return; | |
174 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, | |
175 | spec->pll_coef_idx); | |
176 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, | |
177 | AC_VERB_GET_PROC_COEF, 0); | |
8666dec8 TI |
178 | if (val == -1) |
179 | return; | |
2c3bf9ab TI |
180 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
181 | spec->pll_coef_idx); | |
182 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, | |
183 | val & ~(1 << spec->pll_coef_bit)); | |
184 | } | |
185 | ||
186 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, | |
187 | unsigned int coef_idx, unsigned int coef_bit) | |
188 | { | |
189 | struct alc_spec *spec = codec->spec; | |
190 | spec->pll_nid = nid; | |
191 | spec->pll_coef_idx = coef_idx; | |
192 | spec->pll_coef_bit = coef_bit; | |
193 | alc_fix_pll(codec); | |
194 | } | |
195 | ||
cf5a2279 | 196 | /* update the master volume per volume-knob's unsol event */ |
29adc4b9 | 197 | static void alc_update_knob_master(struct hda_codec *codec, struct hda_jack_tbl *jack) |
cf5a2279 TI |
198 | { |
199 | unsigned int val; | |
200 | struct snd_kcontrol *kctl; | |
201 | struct snd_ctl_elem_value *uctl; | |
202 | ||
203 | kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume"); | |
204 | if (!kctl) | |
205 | return; | |
206 | uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); | |
207 | if (!uctl) | |
208 | return; | |
29adc4b9 | 209 | val = snd_hda_codec_read(codec, jack->nid, 0, |
cf5a2279 TI |
210 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
211 | val &= HDA_AMP_VOLMASK; | |
212 | uctl->value.integer.value[0] = val; | |
213 | uctl->value.integer.value[1] = val; | |
214 | kctl->put(kctl, uctl); | |
215 | kfree(uctl); | |
216 | } | |
217 | ||
29adc4b9 | 218 | static void alc880_unsol_event(struct hda_codec *codec, unsigned int res) |
f21d78e2 | 219 | { |
29adc4b9 DH |
220 | /* For some reason, the res given from ALC880 is broken. |
221 | Here we adjust it properly. */ | |
222 | snd_hda_jack_unsol_event(codec, res >> 2); | |
f21d78e2 TI |
223 | } |
224 | ||
f9423e7a KY |
225 | /* additional initialization for ALC888 variants */ |
226 | static void alc888_coef_init(struct hda_codec *codec) | |
227 | { | |
228 | unsigned int tmp; | |
229 | ||
230 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); | |
231 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
232 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); | |
37db623a | 233 | if ((tmp & 0xf0) == 0x20) |
f9423e7a KY |
234 | /* alc888S-VC */ |
235 | snd_hda_codec_read(codec, 0x20, 0, | |
236 | AC_VERB_SET_PROC_COEF, 0x830); | |
237 | else | |
238 | /* alc888-VB */ | |
239 | snd_hda_codec_read(codec, 0x20, 0, | |
240 | AC_VERB_SET_PROC_COEF, 0x3030); | |
241 | } | |
242 | ||
1d045db9 | 243 | /* additional initialization for ALC889 variants */ |
87a8c370 JK |
244 | static void alc889_coef_init(struct hda_codec *codec) |
245 | { | |
246 | unsigned int tmp; | |
247 | ||
248 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); | |
249 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
250 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); | |
251 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); | |
252 | } | |
253 | ||
3fb4a508 TI |
254 | /* turn on/off EAPD control (only if available) */ |
255 | static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) | |
256 | { | |
257 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) | |
258 | return; | |
259 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) | |
260 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, | |
261 | on ? 2 : 0); | |
262 | } | |
263 | ||
691f1fcc TI |
264 | /* turn on/off EAPD controls of the codec */ |
265 | static void alc_auto_setup_eapd(struct hda_codec *codec, bool on) | |
266 | { | |
267 | /* We currently only handle front, HP */ | |
39fa84e9 | 268 | static hda_nid_t pins[] = { |
8f21510a | 269 | 0x0f, 0x10, 0x14, 0x15, 0x17, 0 |
39fa84e9 TI |
270 | }; |
271 | hda_nid_t *p; | |
272 | for (p = pins; *p; p++) | |
273 | set_eapd(codec, *p, on); | |
691f1fcc TI |
274 | } |
275 | ||
1c716153 TI |
276 | /* generic shutup callback; |
277 | * just turning off EPAD and a little pause for avoiding pop-noise | |
278 | */ | |
279 | static void alc_eapd_shutup(struct hda_codec *codec) | |
280 | { | |
281 | alc_auto_setup_eapd(codec, false); | |
282 | msleep(200); | |
283 | } | |
284 | ||
1d045db9 | 285 | /* generic EAPD initialization */ |
4a79ba34 | 286 | static void alc_auto_init_amp(struct hda_codec *codec, int type) |
bc9f98a9 | 287 | { |
4a79ba34 | 288 | unsigned int tmp; |
bc9f98a9 | 289 | |
39fa84e9 | 290 | alc_auto_setup_eapd(codec, true); |
4a79ba34 TI |
291 | switch (type) { |
292 | case ALC_INIT_GPIO1: | |
bc9f98a9 KY |
293 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); |
294 | break; | |
4a79ba34 | 295 | case ALC_INIT_GPIO2: |
bc9f98a9 KY |
296 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); |
297 | break; | |
4a79ba34 | 298 | case ALC_INIT_GPIO3: |
bdd148a3 KY |
299 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); |
300 | break; | |
4a79ba34 | 301 | case ALC_INIT_DEFAULT: |
c9b58006 KY |
302 | switch (codec->vendor_id) { |
303 | case 0x10ec0260: | |
304 | snd_hda_codec_write(codec, 0x1a, 0, | |
305 | AC_VERB_SET_COEF_INDEX, 7); | |
306 | tmp = snd_hda_codec_read(codec, 0x1a, 0, | |
307 | AC_VERB_GET_PROC_COEF, 0); | |
308 | snd_hda_codec_write(codec, 0x1a, 0, | |
309 | AC_VERB_SET_COEF_INDEX, 7); | |
310 | snd_hda_codec_write(codec, 0x1a, 0, | |
311 | AC_VERB_SET_PROC_COEF, | |
312 | tmp | 0x2010); | |
313 | break; | |
314 | case 0x10ec0262: | |
315 | case 0x10ec0880: | |
316 | case 0x10ec0882: | |
317 | case 0x10ec0883: | |
318 | case 0x10ec0885: | |
4a5a4c56 | 319 | case 0x10ec0887: |
20b67ddd | 320 | /*case 0x10ec0889:*/ /* this causes an SPDIF problem */ |
37a86af8 | 321 | case 0x10ec0900: |
87a8c370 | 322 | alc889_coef_init(codec); |
c9b58006 | 323 | break; |
f9423e7a | 324 | case 0x10ec0888: |
4a79ba34 | 325 | alc888_coef_init(codec); |
f9423e7a | 326 | break; |
0aea778e | 327 | #if 0 /* XXX: This may cause the silent output on speaker on some machines */ |
c9b58006 KY |
328 | case 0x10ec0267: |
329 | case 0x10ec0268: | |
330 | snd_hda_codec_write(codec, 0x20, 0, | |
331 | AC_VERB_SET_COEF_INDEX, 7); | |
332 | tmp = snd_hda_codec_read(codec, 0x20, 0, | |
333 | AC_VERB_GET_PROC_COEF, 0); | |
334 | snd_hda_codec_write(codec, 0x20, 0, | |
ea1fb29a | 335 | AC_VERB_SET_COEF_INDEX, 7); |
c9b58006 KY |
336 | snd_hda_codec_write(codec, 0x20, 0, |
337 | AC_VERB_SET_PROC_COEF, | |
338 | tmp | 0x3000); | |
339 | break; | |
0aea778e | 340 | #endif /* XXX */ |
bc9f98a9 | 341 | } |
4a79ba34 TI |
342 | break; |
343 | } | |
344 | } | |
345 | ||
08c189f2 | 346 | |
1d045db9 | 347 | /* |
08c189f2 | 348 | * Realtek SSID verification |
1d045db9 | 349 | */ |
42cf0d01 | 350 | |
08c189f2 TI |
351 | /* Could be any non-zero and even value. When used as fixup, tells |
352 | * the driver to ignore any present sku defines. | |
353 | */ | |
354 | #define ALC_FIXUP_SKU_IGNORE (2) | |
1a1455de | 355 | |
08c189f2 TI |
356 | static void alc_fixup_sku_ignore(struct hda_codec *codec, |
357 | const struct hda_fixup *fix, int action) | |
1a1455de | 358 | { |
1a1455de | 359 | struct alc_spec *spec = codec->spec; |
08c189f2 TI |
360 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
361 | spec->cdefine.fixup = 1; | |
362 | spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE; | |
1a1455de | 363 | } |
1a1455de TI |
364 | } |
365 | ||
08c189f2 | 366 | static int alc_auto_parse_customize_define(struct hda_codec *codec) |
4a79ba34 | 367 | { |
08c189f2 TI |
368 | unsigned int ass, tmp, i; |
369 | unsigned nid = 0; | |
4a79ba34 TI |
370 | struct alc_spec *spec = codec->spec; |
371 | ||
08c189f2 | 372 | spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ |
4a79ba34 | 373 | |
08c189f2 TI |
374 | if (spec->cdefine.fixup) { |
375 | ass = spec->cdefine.sku_cfg; | |
376 | if (ass == ALC_FIXUP_SKU_IGNORE) | |
377 | return -1; | |
378 | goto do_sku; | |
bb35febd TI |
379 | } |
380 | ||
08c189f2 TI |
381 | ass = codec->subsystem_id & 0xffff; |
382 | if (ass != codec->bus->pci->subsystem_device && (ass & 1)) | |
383 | goto do_sku; | |
4a79ba34 | 384 | |
08c189f2 TI |
385 | nid = 0x1d; |
386 | if (codec->vendor_id == 0x10ec0260) | |
387 | nid = 0x17; | |
388 | ass = snd_hda_codec_get_pincfg(codec, nid); | |
42cf0d01 | 389 | |
08c189f2 TI |
390 | if (!(ass & 1)) { |
391 | printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n", | |
392 | codec->chip_name, ass); | |
393 | return -1; | |
42cf0d01 DH |
394 | } |
395 | ||
08c189f2 TI |
396 | /* check sum */ |
397 | tmp = 0; | |
398 | for (i = 1; i < 16; i++) { | |
399 | if ((ass >> i) & 1) | |
400 | tmp++; | |
ae8a60a5 | 401 | } |
08c189f2 TI |
402 | if (((ass >> 16) & 0xf) != tmp) |
403 | return -1; | |
ae8a60a5 | 404 | |
da00c244 KY |
405 | spec->cdefine.port_connectivity = ass >> 30; |
406 | spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20; | |
407 | spec->cdefine.check_sum = (ass >> 16) & 0xf; | |
408 | spec->cdefine.customization = ass >> 8; | |
409 | do_sku: | |
410 | spec->cdefine.sku_cfg = ass; | |
411 | spec->cdefine.external_amp = (ass & 0x38) >> 3; | |
412 | spec->cdefine.platform_type = (ass & 0x4) >> 2; | |
413 | spec->cdefine.swap = (ass & 0x2) >> 1; | |
414 | spec->cdefine.override = ass & 0x1; | |
415 | ||
416 | snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n", | |
417 | nid, spec->cdefine.sku_cfg); | |
418 | snd_printd("SKU: port_connectivity=0x%x\n", | |
419 | spec->cdefine.port_connectivity); | |
420 | snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep); | |
421 | snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum); | |
422 | snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization); | |
423 | snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp); | |
424 | snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type); | |
425 | snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap); | |
426 | snd_printd("SKU: override=0x%x\n", spec->cdefine.override); | |
427 | ||
428 | return 0; | |
429 | } | |
430 | ||
08c189f2 TI |
431 | /* return the position of NID in the list, or -1 if not found */ |
432 | static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) | |
433 | { | |
434 | int i; | |
435 | for (i = 0; i < nums; i++) | |
436 | if (list[i] == nid) | |
437 | return i; | |
438 | return -1; | |
439 | } | |
1d045db9 | 440 | /* return true if the given NID is found in the list */ |
3af9ee6b TI |
441 | static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
442 | { | |
21268961 | 443 | return find_idx_in_nid_list(nid, list, nums) >= 0; |
3af9ee6b TI |
444 | } |
445 | ||
4a79ba34 TI |
446 | /* check subsystem ID and set up device-specific initialization; |
447 | * return 1 if initialized, 0 if invalid SSID | |
448 | */ | |
449 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. | |
450 | * 31 ~ 16 : Manufacture ID | |
451 | * 15 ~ 8 : SKU ID | |
452 | * 7 ~ 0 : Assembly ID | |
453 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 | |
454 | */ | |
455 | static int alc_subsystem_id(struct hda_codec *codec, | |
456 | hda_nid_t porta, hda_nid_t porte, | |
6227cdce | 457 | hda_nid_t portd, hda_nid_t porti) |
4a79ba34 TI |
458 | { |
459 | unsigned int ass, tmp, i; | |
460 | unsigned nid; | |
461 | struct alc_spec *spec = codec->spec; | |
462 | ||
90622917 DH |
463 | if (spec->cdefine.fixup) { |
464 | ass = spec->cdefine.sku_cfg; | |
465 | if (ass == ALC_FIXUP_SKU_IGNORE) | |
466 | return 0; | |
467 | goto do_sku; | |
468 | } | |
469 | ||
4a79ba34 TI |
470 | ass = codec->subsystem_id & 0xffff; |
471 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) | |
472 | goto do_sku; | |
473 | ||
474 | /* invalid SSID, check the special NID pin defcfg instead */ | |
475 | /* | |
def319f9 | 476 | * 31~30 : port connectivity |
4a79ba34 TI |
477 | * 29~21 : reserve |
478 | * 20 : PCBEEP input | |
479 | * 19~16 : Check sum (15:1) | |
480 | * 15~1 : Custom | |
481 | * 0 : override | |
482 | */ | |
483 | nid = 0x1d; | |
484 | if (codec->vendor_id == 0x10ec0260) | |
485 | nid = 0x17; | |
486 | ass = snd_hda_codec_get_pincfg(codec, nid); | |
487 | snd_printd("realtek: No valid SSID, " | |
488 | "checking pincfg 0x%08x for NID 0x%x\n", | |
cb6605c1 | 489 | ass, nid); |
6227cdce | 490 | if (!(ass & 1)) |
4a79ba34 TI |
491 | return 0; |
492 | if ((ass >> 30) != 1) /* no physical connection */ | |
493 | return 0; | |
494 | ||
495 | /* check sum */ | |
496 | tmp = 0; | |
497 | for (i = 1; i < 16; i++) { | |
498 | if ((ass >> i) & 1) | |
499 | tmp++; | |
500 | } | |
501 | if (((ass >> 16) & 0xf) != tmp) | |
502 | return 0; | |
503 | do_sku: | |
504 | snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", | |
505 | ass & 0xffff, codec->vendor_id); | |
506 | /* | |
507 | * 0 : override | |
508 | * 1 : Swap Jack | |
509 | * 2 : 0 --> Desktop, 1 --> Laptop | |
510 | * 3~5 : External Amplifier control | |
511 | * 7~6 : Reserved | |
512 | */ | |
513 | tmp = (ass & 0x38) >> 3; /* external Amp control */ | |
514 | switch (tmp) { | |
515 | case 1: | |
516 | spec->init_amp = ALC_INIT_GPIO1; | |
517 | break; | |
518 | case 3: | |
519 | spec->init_amp = ALC_INIT_GPIO2; | |
520 | break; | |
521 | case 7: | |
522 | spec->init_amp = ALC_INIT_GPIO3; | |
523 | break; | |
524 | case 5: | |
5a8cfb4e | 525 | default: |
4a79ba34 | 526 | spec->init_amp = ALC_INIT_DEFAULT; |
bc9f98a9 KY |
527 | break; |
528 | } | |
ea1fb29a | 529 | |
8c427226 | 530 | /* is laptop or Desktop and enable the function "Mute internal speaker |
c9b58006 KY |
531 | * when the external headphone out jack is plugged" |
532 | */ | |
8c427226 | 533 | if (!(ass & 0x8000)) |
4a79ba34 | 534 | return 1; |
c9b58006 KY |
535 | /* |
536 | * 10~8 : Jack location | |
537 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered | |
538 | * 14~13: Resvered | |
539 | * 15 : 1 --> enable the function "Mute internal speaker | |
540 | * when the external headphone out jack is plugged" | |
541 | */ | |
08c189f2 TI |
542 | if (!spec->gen.autocfg.hp_pins[0] && |
543 | !(spec->gen.autocfg.line_out_pins[0] && | |
544 | spec->gen.autocfg.line_out_type == AUTO_PIN_HP_OUT)) { | |
01d4825d | 545 | hda_nid_t nid; |
c9b58006 KY |
546 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ |
547 | if (tmp == 0) | |
01d4825d | 548 | nid = porta; |
c9b58006 | 549 | else if (tmp == 1) |
01d4825d | 550 | nid = porte; |
c9b58006 | 551 | else if (tmp == 2) |
01d4825d | 552 | nid = portd; |
6227cdce KY |
553 | else if (tmp == 3) |
554 | nid = porti; | |
c9b58006 | 555 | else |
4a79ba34 | 556 | return 1; |
08c189f2 TI |
557 | if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins, |
558 | spec->gen.autocfg.line_outs)) | |
3af9ee6b | 559 | return 1; |
08c189f2 | 560 | spec->gen.autocfg.hp_pins[0] = nid; |
c9b58006 | 561 | } |
4a79ba34 TI |
562 | return 1; |
563 | } | |
ea1fb29a | 564 | |
3e6179b8 TI |
565 | /* Check the validity of ALC subsystem-id |
566 | * ports contains an array of 4 pin NIDs for port-A, E, D and I */ | |
567 | static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports) | |
4a79ba34 | 568 | { |
3e6179b8 | 569 | if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) { |
4a79ba34 TI |
570 | struct alc_spec *spec = codec->spec; |
571 | snd_printd("realtek: " | |
572 | "Enable default setup for auto mode as fallback\n"); | |
573 | spec->init_amp = ALC_INIT_DEFAULT; | |
4a79ba34 | 574 | } |
21268961 | 575 | } |
1a1455de | 576 | |
1d045db9 TI |
577 | /* |
578 | * COEF access helper functions | |
579 | */ | |
274693f3 KY |
580 | static int alc_read_coef_idx(struct hda_codec *codec, |
581 | unsigned int coef_idx) | |
582 | { | |
583 | unsigned int val; | |
584 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, | |
585 | coef_idx); | |
586 | val = snd_hda_codec_read(codec, 0x20, 0, | |
587 | AC_VERB_GET_PROC_COEF, 0); | |
588 | return val; | |
589 | } | |
590 | ||
977ddd6b KY |
591 | static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, |
592 | unsigned int coef_val) | |
593 | { | |
594 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, | |
595 | coef_idx); | |
596 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, | |
597 | coef_val); | |
598 | } | |
599 | ||
1bb7e43e TI |
600 | /* a special bypass for COEF 0; read the cached value at the second time */ |
601 | static unsigned int alc_get_coef0(struct hda_codec *codec) | |
602 | { | |
603 | struct alc_spec *spec = codec->spec; | |
604 | if (!spec->coef0) | |
605 | spec->coef0 = alc_read_coef_idx(codec, 0); | |
606 | return spec->coef0; | |
607 | } | |
608 | ||
1d045db9 | 609 | /* |
ef8ef5fb | 610 | */ |
f9e336f6 | 611 | |
08c189f2 | 612 | static hda_nid_t get_adc_nid(struct hda_codec *codec, int adc_idx, int imux_idx) |
f9e336f6 | 613 | { |
08c189f2 TI |
614 | struct hda_gen_spec *spec = codec->spec; |
615 | if (spec->dyn_adc_switch) | |
616 | adc_idx = spec->dyn_adc_idx[imux_idx]; | |
617 | return spec->adc_nids[adc_idx]; | |
f9e336f6 TI |
618 | } |
619 | ||
666a70d4 | 620 | static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx) |
f9e336f6 | 621 | { |
f9e336f6 | 622 | struct alc_spec *spec = codec->spec; |
08c189f2 | 623 | struct hda_input_mux *imux = &spec->gen.input_mux; |
666a70d4 TI |
624 | struct nid_path *path; |
625 | hda_nid_t nid; | |
626 | int i, dir, parm; | |
627 | unsigned int val; | |
f9e336f6 | 628 | |
666a70d4 | 629 | for (i = 0; i < imux->num_items; i++) { |
08c189f2 | 630 | if (spec->gen.imux_pins[i] == spec->inv_dmic_pin) |
666a70d4 | 631 | break; |
a23b688f | 632 | } |
666a70d4 TI |
633 | if (i >= imux->num_items) |
634 | return; | |
a23b688f | 635 | |
08c189f2 TI |
636 | path = snd_hda_get_nid_path(codec, spec->inv_dmic_pin, |
637 | get_adc_nid(codec, adc_idx, i)); | |
666a70d4 TI |
638 | val = path->ctls[NID_PATH_MUTE_CTL]; |
639 | if (!val) | |
640 | return; | |
641 | nid = get_amp_nid_(val); | |
642 | dir = get_amp_direction_(val); | |
643 | parm = AC_AMP_SET_RIGHT | | |
644 | (dir == HDA_OUTPUT ? AC_AMP_SET_OUTPUT : AC_AMP_SET_INPUT); | |
a23b688f | 645 | |
c4f3ebed | 646 | /* flush all cached amps at first */ |
dc870f38 | 647 | snd_hda_codec_flush_cache(codec); |
a23b688f | 648 | |
666a70d4 TI |
649 | /* we care only right channel */ |
650 | val = snd_hda_codec_amp_read(codec, nid, 1, dir, 0); | |
651 | if (val & 0x80) /* if already muted, we don't need to touch */ | |
652 | return; | |
653 | val |= 0x80; | |
654 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
655 | parm | val); | |
f9e336f6 TI |
656 | } |
657 | ||
125821ae TI |
658 | /* |
659 | * Inverted digital-mic handling | |
660 | * | |
661 | * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch" | |
662 | * gives the additional mute only to the right channel of the digital mic | |
663 | * capture stream. This is a workaround for avoiding the almost silence | |
664 | * by summing the stereo stream from some (known to be ForteMedia) | |
665 | * digital mic unit. | |
666 | * | |
667 | * The logic is to call alc_inv_dmic_sync() after each action (possibly) | |
668 | * modifying ADC amp. When the mute flag is set, it mutes the R-channel | |
669 | * without caching so that the cache can still keep the original value. | |
670 | * The cached value is then restored when the flag is set off or any other | |
671 | * than d-mic is used as the current input source. | |
672 | */ | |
673 | static void alc_inv_dmic_sync(struct hda_codec *codec, bool force) | |
674 | { | |
675 | struct alc_spec *spec = codec->spec; | |
666a70d4 | 676 | int src, nums; |
125821ae TI |
677 | |
678 | if (!spec->inv_dmic_fixup) | |
679 | return; | |
680 | if (!spec->inv_dmic_muted && !force) | |
681 | return; | |
08c189f2 | 682 | nums = spec->gen.dyn_adc_switch ? 1 : spec->gen.num_adc_nids; |
666a70d4 | 683 | for (src = 0; src < nums; src++) { |
125821ae | 684 | bool dmic_fixup = false; |
125821ae TI |
685 | |
686 | if (spec->inv_dmic_muted && | |
08c189f2 | 687 | spec->gen.imux_pins[spec->gen.cur_mux[src]] == spec->inv_dmic_pin) |
125821ae TI |
688 | dmic_fixup = true; |
689 | if (!dmic_fixup && !force) | |
690 | continue; | |
666a70d4 | 691 | alc_inv_dmic_sync_adc(codec, src); |
125821ae TI |
692 | } |
693 | } | |
694 | ||
a90229e0 TI |
695 | static void alc_inv_dmic_hook(struct hda_codec *codec, |
696 | struct snd_ctl_elem_value *ucontrol) | |
08c189f2 TI |
697 | { |
698 | alc_inv_dmic_sync(codec, false); | |
699 | } | |
700 | ||
125821ae TI |
701 | static int alc_inv_dmic_sw_get(struct snd_kcontrol *kcontrol, |
702 | struct snd_ctl_elem_value *ucontrol) | |
703 | { | |
704 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
705 | struct alc_spec *spec = codec->spec; | |
706 | ||
707 | ucontrol->value.integer.value[0] = !spec->inv_dmic_muted; | |
708 | return 0; | |
709 | } | |
710 | ||
711 | static int alc_inv_dmic_sw_put(struct snd_kcontrol *kcontrol, | |
712 | struct snd_ctl_elem_value *ucontrol) | |
713 | { | |
714 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
715 | struct alc_spec *spec = codec->spec; | |
716 | unsigned int val = !ucontrol->value.integer.value[0]; | |
717 | ||
718 | if (val == spec->inv_dmic_muted) | |
719 | return 0; | |
720 | spec->inv_dmic_muted = val; | |
721 | alc_inv_dmic_sync(codec, true); | |
722 | return 0; | |
723 | } | |
724 | ||
725 | static const struct snd_kcontrol_new alc_inv_dmic_sw = { | |
726 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
bc549767 | 727 | .name = "Inverted Internal Mic Capture Switch", |
125821ae TI |
728 | .info = snd_ctl_boolean_mono_info, |
729 | .get = alc_inv_dmic_sw_get, | |
730 | .put = alc_inv_dmic_sw_put, | |
731 | }; | |
732 | ||
733 | static int alc_add_inv_dmic_mixer(struct hda_codec *codec, hda_nid_t nid) | |
734 | { | |
735 | struct alc_spec *spec = codec->spec; | |
668d1e96 | 736 | |
08c189f2 | 737 | if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &alc_inv_dmic_sw)) |
125821ae TI |
738 | return -ENOMEM; |
739 | spec->inv_dmic_fixup = 1; | |
740 | spec->inv_dmic_muted = 0; | |
741 | spec->inv_dmic_pin = nid; | |
08c189f2 | 742 | spec->gen.cap_sync_hook = alc_inv_dmic_hook; |
125821ae TI |
743 | return 0; |
744 | } | |
745 | ||
6e72aa5f TI |
746 | /* typically the digital mic is put at node 0x12 */ |
747 | static void alc_fixup_inv_dmic_0x12(struct hda_codec *codec, | |
1727a771 | 748 | const struct hda_fixup *fix, int action) |
6e72aa5f | 749 | { |
1727a771 | 750 | if (action == HDA_FIXUP_ACT_PROBE) |
6e72aa5f TI |
751 | alc_add_inv_dmic_mixer(codec, 0x12); |
752 | } | |
753 | ||
e9edcee0 | 754 | |
1d045db9 TI |
755 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
756 | /* additional beep mixers; the actual parameters are overwritten at build */ | |
757 | static const struct snd_kcontrol_new alc_beep_mixer[] = { | |
758 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), | |
759 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), | |
16ded525 TI |
760 | { } /* end */ |
761 | }; | |
1d045db9 | 762 | #endif |
16ded525 | 763 | |
08c189f2 | 764 | static int alc_build_controls(struct hda_codec *codec) |
1d045db9 TI |
765 | { |
766 | struct alc_spec *spec = codec->spec; | |
08c189f2 | 767 | int i, err; |
e9427969 | 768 | |
08c189f2 TI |
769 | err = snd_hda_gen_build_controls(codec); |
770 | if (err < 0) | |
771 | return err; | |
1da177e4 LT |
772 | |
773 | for (i = 0; i < spec->num_mixers; i++) { | |
774 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | |
775 | if (err < 0) | |
776 | return err; | |
777 | } | |
2134ea4f | 778 | |
67d634c0 | 779 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
45bdd1c1 TI |
780 | /* create beep controls if needed */ |
781 | if (spec->beep_amp) { | |
a9111321 | 782 | const struct snd_kcontrol_new *knew; |
45bdd1c1 TI |
783 | for (knew = alc_beep_mixer; knew->name; knew++) { |
784 | struct snd_kcontrol *kctl; | |
785 | kctl = snd_ctl_new1(knew, codec); | |
786 | if (!kctl) | |
08c189f2 TI |
787 | return -ENOMEM; |
788 | kctl->private_value = spec->beep_amp; | |
789 | err = snd_hda_ctl_add(codec, 0, kctl); | |
790 | if (err < 0) | |
791 | return err; | |
1d045db9 | 792 | } |
863b4518 | 793 | } |
08c189f2 | 794 | #endif |
1c4a54b4 | 795 | |
1727a771 | 796 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD); |
1c4a54b4 | 797 | return 0; |
a361d84b KY |
798 | } |
799 | ||
a361d84b | 800 | |
df694daa | 801 | /* |
08c189f2 | 802 | * Common callbacks |
df694daa | 803 | */ |
a361d84b | 804 | |
08c189f2 | 805 | static int alc_init(struct hda_codec *codec) |
1d045db9 TI |
806 | { |
807 | struct alc_spec *spec = codec->spec; | |
a361d84b | 808 | |
08c189f2 TI |
809 | if (spec->init_hook) |
810 | spec->init_hook(codec); | |
a361d84b | 811 | |
08c189f2 TI |
812 | alc_fix_pll(codec); |
813 | alc_auto_init_amp(codec, spec->init_amp); | |
3abf2f36 | 814 | |
08c189f2 | 815 | snd_hda_gen_init(codec); |
a361d84b | 816 | |
1727a771 | 817 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT); |
a361d84b | 818 | |
1d045db9 TI |
819 | return 0; |
820 | } | |
a361d84b | 821 | |
08c189f2 | 822 | static inline void alc_shutup(struct hda_codec *codec) |
1d045db9 TI |
823 | { |
824 | struct alc_spec *spec = codec->spec; | |
a361d84b | 825 | |
08c189f2 TI |
826 | if (spec && spec->shutup) |
827 | spec->shutup(codec); | |
828 | snd_hda_shutup_pins(codec); | |
1d045db9 TI |
829 | } |
830 | ||
7504b6cd | 831 | #define alc_free snd_hda_gen_free |
2134ea4f | 832 | |
08c189f2 TI |
833 | #ifdef CONFIG_PM |
834 | static void alc_power_eapd(struct hda_codec *codec) | |
1d045db9 | 835 | { |
08c189f2 | 836 | alc_auto_setup_eapd(codec, false); |
1d045db9 | 837 | } |
2134ea4f | 838 | |
08c189f2 | 839 | static int alc_suspend(struct hda_codec *codec) |
1d045db9 TI |
840 | { |
841 | struct alc_spec *spec = codec->spec; | |
08c189f2 TI |
842 | alc_shutup(codec); |
843 | if (spec && spec->power_hook) | |
844 | spec->power_hook(codec); | |
a361d84b KY |
845 | return 0; |
846 | } | |
08c189f2 | 847 | #endif |
a361d84b | 848 | |
08c189f2 TI |
849 | #ifdef CONFIG_PM |
850 | static int alc_resume(struct hda_codec *codec) | |
1d045db9 | 851 | { |
08c189f2 TI |
852 | msleep(150); /* to avoid pop noise */ |
853 | codec->patch_ops.init(codec); | |
854 | snd_hda_codec_resume_amp(codec); | |
855 | snd_hda_codec_resume_cache(codec); | |
856 | alc_inv_dmic_sync(codec, true); | |
857 | hda_call_check_power_status(codec, 0x01); | |
858 | return 0; | |
1d045db9 | 859 | } |
08c189f2 | 860 | #endif |
f6a92248 | 861 | |
1d045db9 | 862 | /* |
1d045db9 | 863 | */ |
08c189f2 TI |
864 | static const struct hda_codec_ops alc_patch_ops = { |
865 | .build_controls = alc_build_controls, | |
866 | .build_pcms = snd_hda_gen_build_pcms, | |
867 | .init = alc_init, | |
868 | .free = alc_free, | |
869 | .unsol_event = snd_hda_jack_unsol_event, | |
870 | #ifdef CONFIG_PM | |
871 | .resume = alc_resume, | |
08c189f2 | 872 | .suspend = alc_suspend, |
fce52a3b | 873 | .check_power_status = snd_hda_gen_check_power_status, |
08c189f2 TI |
874 | #endif |
875 | .reboot_notify = alc_shutup, | |
876 | }; | |
f6a92248 | 877 | |
f53281e6 | 878 | |
08c189f2 TI |
879 | /* replace the codec chip_name with the given string */ |
880 | static int alc_codec_rename(struct hda_codec *codec, const char *name) | |
1d045db9 | 881 | { |
08c189f2 TI |
882 | kfree(codec->chip_name); |
883 | codec->chip_name = kstrdup(name, GFP_KERNEL); | |
884 | if (!codec->chip_name) { | |
885 | alc_free(codec); | |
886 | return -ENOMEM; | |
1d045db9 | 887 | } |
a361d84b | 888 | return 0; |
1d045db9 | 889 | } |
e01bf509 | 890 | |
e4770629 | 891 | /* |
08c189f2 | 892 | * Rename codecs appropriately from COEF value |
e4770629 | 893 | */ |
08c189f2 TI |
894 | struct alc_codec_rename_table { |
895 | unsigned int vendor_id; | |
896 | unsigned short coef_mask; | |
897 | unsigned short coef_bits; | |
898 | const char *name; | |
899 | }; | |
84898e87 | 900 | |
08c189f2 TI |
901 | static struct alc_codec_rename_table rename_tbl[] = { |
902 | { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, | |
903 | { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, | |
904 | { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" }, | |
905 | { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" }, | |
906 | { 0x10ec0269, 0xffff, 0xa023, "ALC259" }, | |
907 | { 0x10ec0269, 0xffff, 0x6023, "ALC281X" }, | |
908 | { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" }, | |
909 | { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" }, | |
910 | { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" }, | |
911 | { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" }, | |
912 | { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" }, | |
913 | { 0x10ec0899, 0x2000, 0x2000, "ALC899" }, | |
914 | { 0x10ec0892, 0xffff, 0x8020, "ALC661" }, | |
915 | { 0x10ec0892, 0xffff, 0x8011, "ALC661" }, | |
916 | { 0x10ec0892, 0xffff, 0x4011, "ALC656" }, | |
917 | { } /* terminator */ | |
918 | }; | |
84898e87 | 919 | |
08c189f2 | 920 | static int alc_codec_rename_from_preset(struct hda_codec *codec) |
1d045db9 | 921 | { |
08c189f2 | 922 | const struct alc_codec_rename_table *p; |
60db6b53 | 923 | |
08c189f2 TI |
924 | for (p = rename_tbl; p->vendor_id; p++) { |
925 | if (p->vendor_id != codec->vendor_id) | |
926 | continue; | |
927 | if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) | |
928 | return alc_codec_rename(codec, p->name); | |
1d045db9 | 929 | } |
08c189f2 | 930 | return 0; |
1d045db9 | 931 | } |
f53281e6 | 932 | |
e4770629 | 933 | |
1d045db9 TI |
934 | /* |
935 | * Digital-beep handlers | |
936 | */ | |
937 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | |
938 | #define set_beep_amp(spec, nid, idx, dir) \ | |
939 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) | |
84898e87 | 940 | |
1d045db9 | 941 | static const struct snd_pci_quirk beep_white_list[] = { |
7110005e | 942 | SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1), |
4ce77a7a | 943 | SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1), |
1d045db9 | 944 | SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), |
8554ee40 | 945 | SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1), |
1d045db9 TI |
946 | SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), |
947 | SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), | |
948 | SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1), | |
78f8baf1 | 949 | SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1), |
1d045db9 TI |
950 | SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), |
951 | {} | |
fe3eb0a7 KY |
952 | }; |
953 | ||
1d045db9 TI |
954 | static inline int has_cdefine_beep(struct hda_codec *codec) |
955 | { | |
956 | struct alc_spec *spec = codec->spec; | |
957 | const struct snd_pci_quirk *q; | |
958 | q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); | |
959 | if (q) | |
960 | return q->value; | |
961 | return spec->cdefine.enable_pcbeep; | |
962 | } | |
963 | #else | |
964 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ | |
965 | #define has_cdefine_beep(codec) 0 | |
966 | #endif | |
84898e87 | 967 | |
1d045db9 TI |
968 | /* parse the BIOS configuration and set up the alc_spec */ |
969 | /* return 1 if successful, 0 if the proper config is not found, | |
970 | * or a negative error code | |
971 | */ | |
3e6179b8 TI |
972 | static int alc_parse_auto_config(struct hda_codec *codec, |
973 | const hda_nid_t *ignore_nids, | |
974 | const hda_nid_t *ssid_nids) | |
1d045db9 TI |
975 | { |
976 | struct alc_spec *spec = codec->spec; | |
08c189f2 | 977 | struct auto_pin_cfg *cfg = &spec->gen.autocfg; |
1d045db9 | 978 | int err; |
26f5df26 | 979 | |
53c334ad TI |
980 | err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids, |
981 | spec->parse_flags); | |
1d045db9 TI |
982 | if (err < 0) |
983 | return err; | |
3e6179b8 TI |
984 | |
985 | if (ssid_nids) | |
986 | alc_ssid_check(codec, ssid_nids); | |
64154835 | 987 | |
08c189f2 TI |
988 | err = snd_hda_gen_parse_auto_config(codec, cfg); |
989 | if (err < 0) | |
990 | return err; | |
070cff4c | 991 | |
1d045db9 | 992 | return 1; |
60db6b53 | 993 | } |
f6a92248 | 994 | |
3de95173 TI |
995 | /* common preparation job for alc_spec */ |
996 | static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid) | |
997 | { | |
998 | struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
999 | int err; | |
1000 | ||
1001 | if (!spec) | |
1002 | return -ENOMEM; | |
1003 | codec->spec = spec; | |
08c189f2 TI |
1004 | snd_hda_gen_spec_init(&spec->gen); |
1005 | spec->gen.mixer_nid = mixer_nid; | |
1006 | spec->gen.own_eapd_ctl = 1; | |
1098b7c2 | 1007 | codec->single_adc_amp = 1; |
08c189f2 TI |
1008 | /* FIXME: do we need this for all Realtek codec models? */ |
1009 | codec->spdif_status_reset = 1; | |
3de95173 TI |
1010 | |
1011 | err = alc_codec_rename_from_preset(codec); | |
1012 | if (err < 0) { | |
1013 | kfree(spec); | |
1014 | return err; | |
1015 | } | |
1016 | return 0; | |
1017 | } | |
1018 | ||
3e6179b8 TI |
1019 | static int alc880_parse_auto_config(struct hda_codec *codec) |
1020 | { | |
1021 | static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; | |
7d7eb9ea | 1022 | static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
3e6179b8 TI |
1023 | return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids); |
1024 | } | |
1025 | ||
ee3b2969 TI |
1026 | /* |
1027 | * ALC880 fix-ups | |
1028 | */ | |
1029 | enum { | |
411225a0 | 1030 | ALC880_FIXUP_GPIO1, |
ee3b2969 TI |
1031 | ALC880_FIXUP_GPIO2, |
1032 | ALC880_FIXUP_MEDION_RIM, | |
dc6af52d | 1033 | ALC880_FIXUP_LG, |
db3175e1 | 1034 | ALC880_FIXUP_LG_LW25, |
f02aab5d | 1035 | ALC880_FIXUP_W810, |
27e917f8 | 1036 | ALC880_FIXUP_EAPD_COEF, |
b9368f5c | 1037 | ALC880_FIXUP_TCL_S700, |
cf5a2279 TI |
1038 | ALC880_FIXUP_VOL_KNOB, |
1039 | ALC880_FIXUP_FUJITSU, | |
ba533818 | 1040 | ALC880_FIXUP_F1734, |
817de92f | 1041 | ALC880_FIXUP_UNIWILL, |
967b88c4 | 1042 | ALC880_FIXUP_UNIWILL_DIG, |
96e225f6 | 1043 | ALC880_FIXUP_Z71V, |
705f5ab4 | 1044 | ALC880_FIXUP_ASUS_W5A, |
67b6ec31 TI |
1045 | ALC880_FIXUP_3ST_BASE, |
1046 | ALC880_FIXUP_3ST, | |
1047 | ALC880_FIXUP_3ST_DIG, | |
1048 | ALC880_FIXUP_5ST_BASE, | |
1049 | ALC880_FIXUP_5ST, | |
1050 | ALC880_FIXUP_5ST_DIG, | |
1051 | ALC880_FIXUP_6ST_BASE, | |
1052 | ALC880_FIXUP_6ST, | |
1053 | ALC880_FIXUP_6ST_DIG, | |
5397145f | 1054 | ALC880_FIXUP_6ST_AUTOMUTE, |
ee3b2969 TI |
1055 | }; |
1056 | ||
cf5a2279 TI |
1057 | /* enable the volume-knob widget support on NID 0x21 */ |
1058 | static void alc880_fixup_vol_knob(struct hda_codec *codec, | |
1727a771 | 1059 | const struct hda_fixup *fix, int action) |
cf5a2279 | 1060 | { |
1727a771 | 1061 | if (action == HDA_FIXUP_ACT_PROBE) |
29adc4b9 | 1062 | snd_hda_jack_detect_enable_callback(codec, 0x21, ALC_DCVOL_EVENT, alc_update_knob_master); |
cf5a2279 TI |
1063 | } |
1064 | ||
1727a771 | 1065 | static const struct hda_fixup alc880_fixups[] = { |
411225a0 | 1066 | [ALC880_FIXUP_GPIO1] = { |
1727a771 | 1067 | .type = HDA_FIXUP_VERBS, |
411225a0 TI |
1068 | .v.verbs = alc_gpio1_init_verbs, |
1069 | }, | |
ee3b2969 | 1070 | [ALC880_FIXUP_GPIO2] = { |
1727a771 | 1071 | .type = HDA_FIXUP_VERBS, |
ee3b2969 TI |
1072 | .v.verbs = alc_gpio2_init_verbs, |
1073 | }, | |
1074 | [ALC880_FIXUP_MEDION_RIM] = { | |
1727a771 | 1075 | .type = HDA_FIXUP_VERBS, |
ee3b2969 TI |
1076 | .v.verbs = (const struct hda_verb[]) { |
1077 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, | |
1078 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, | |
1079 | { } | |
1080 | }, | |
1081 | .chained = true, | |
1082 | .chain_id = ALC880_FIXUP_GPIO2, | |
1083 | }, | |
dc6af52d | 1084 | [ALC880_FIXUP_LG] = { |
1727a771 TI |
1085 | .type = HDA_FIXUP_PINS, |
1086 | .v.pins = (const struct hda_pintbl[]) { | |
dc6af52d TI |
1087 | /* disable bogus unused pins */ |
1088 | { 0x16, 0x411111f0 }, | |
1089 | { 0x18, 0x411111f0 }, | |
1090 | { 0x1a, 0x411111f0 }, | |
1091 | { } | |
1092 | } | |
1093 | }, | |
db3175e1 TI |
1094 | [ALC880_FIXUP_LG_LW25] = { |
1095 | .type = HDA_FIXUP_PINS, | |
1096 | .v.pins = (const struct hda_pintbl[]) { | |
1097 | { 0x1a, 0x0181344f }, /* line-in */ | |
1098 | { 0x1b, 0x0321403f }, /* headphone */ | |
1099 | { } | |
1100 | } | |
1101 | }, | |
f02aab5d | 1102 | [ALC880_FIXUP_W810] = { |
1727a771 TI |
1103 | .type = HDA_FIXUP_PINS, |
1104 | .v.pins = (const struct hda_pintbl[]) { | |
f02aab5d TI |
1105 | /* disable bogus unused pins */ |
1106 | { 0x17, 0x411111f0 }, | |
1107 | { } | |
1108 | }, | |
1109 | .chained = true, | |
1110 | .chain_id = ALC880_FIXUP_GPIO2, | |
1111 | }, | |
27e917f8 | 1112 | [ALC880_FIXUP_EAPD_COEF] = { |
1727a771 | 1113 | .type = HDA_FIXUP_VERBS, |
27e917f8 TI |
1114 | .v.verbs = (const struct hda_verb[]) { |
1115 | /* change to EAPD mode */ | |
1116 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, | |
1117 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, | |
1118 | {} | |
1119 | }, | |
1120 | }, | |
b9368f5c | 1121 | [ALC880_FIXUP_TCL_S700] = { |
1727a771 | 1122 | .type = HDA_FIXUP_VERBS, |
b9368f5c TI |
1123 | .v.verbs = (const struct hda_verb[]) { |
1124 | /* change to EAPD mode */ | |
1125 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, | |
1126 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, | |
1127 | {} | |
1128 | }, | |
1129 | .chained = true, | |
1130 | .chain_id = ALC880_FIXUP_GPIO2, | |
1131 | }, | |
cf5a2279 | 1132 | [ALC880_FIXUP_VOL_KNOB] = { |
1727a771 | 1133 | .type = HDA_FIXUP_FUNC, |
cf5a2279 TI |
1134 | .v.func = alc880_fixup_vol_knob, |
1135 | }, | |
1136 | [ALC880_FIXUP_FUJITSU] = { | |
1137 | /* override all pins as BIOS on old Amilo is broken */ | |
1727a771 TI |
1138 | .type = HDA_FIXUP_PINS, |
1139 | .v.pins = (const struct hda_pintbl[]) { | |
e8c2bbe9 | 1140 | { 0x14, 0x0121401f }, /* HP */ |
cf5a2279 TI |
1141 | { 0x15, 0x99030120 }, /* speaker */ |
1142 | { 0x16, 0x99030130 }, /* bass speaker */ | |
1143 | { 0x17, 0x411111f0 }, /* N/A */ | |
1144 | { 0x18, 0x411111f0 }, /* N/A */ | |
1145 | { 0x19, 0x01a19950 }, /* mic-in */ | |
1146 | { 0x1a, 0x411111f0 }, /* N/A */ | |
1147 | { 0x1b, 0x411111f0 }, /* N/A */ | |
1148 | { 0x1c, 0x411111f0 }, /* N/A */ | |
1149 | { 0x1d, 0x411111f0 }, /* N/A */ | |
1150 | { 0x1e, 0x01454140 }, /* SPDIF out */ | |
1151 | { } | |
1152 | }, | |
1153 | .chained = true, | |
1154 | .chain_id = ALC880_FIXUP_VOL_KNOB, | |
1155 | }, | |
ba533818 TI |
1156 | [ALC880_FIXUP_F1734] = { |
1157 | /* almost compatible with FUJITSU, but no bass and SPDIF */ | |
1727a771 TI |
1158 | .type = HDA_FIXUP_PINS, |
1159 | .v.pins = (const struct hda_pintbl[]) { | |
e8c2bbe9 | 1160 | { 0x14, 0x0121401f }, /* HP */ |
ba533818 TI |
1161 | { 0x15, 0x99030120 }, /* speaker */ |
1162 | { 0x16, 0x411111f0 }, /* N/A */ | |
1163 | { 0x17, 0x411111f0 }, /* N/A */ | |
1164 | { 0x18, 0x411111f0 }, /* N/A */ | |
1165 | { 0x19, 0x01a19950 }, /* mic-in */ | |
1166 | { 0x1a, 0x411111f0 }, /* N/A */ | |
1167 | { 0x1b, 0x411111f0 }, /* N/A */ | |
1168 | { 0x1c, 0x411111f0 }, /* N/A */ | |
1169 | { 0x1d, 0x411111f0 }, /* N/A */ | |
1170 | { 0x1e, 0x411111f0 }, /* N/A */ | |
1171 | { } | |
1172 | }, | |
1173 | .chained = true, | |
1174 | .chain_id = ALC880_FIXUP_VOL_KNOB, | |
1175 | }, | |
817de92f TI |
1176 | [ALC880_FIXUP_UNIWILL] = { |
1177 | /* need to fix HP and speaker pins to be parsed correctly */ | |
1727a771 TI |
1178 | .type = HDA_FIXUP_PINS, |
1179 | .v.pins = (const struct hda_pintbl[]) { | |
817de92f TI |
1180 | { 0x14, 0x0121411f }, /* HP */ |
1181 | { 0x15, 0x99030120 }, /* speaker */ | |
1182 | { 0x16, 0x99030130 }, /* bass speaker */ | |
1183 | { } | |
1184 | }, | |
1185 | }, | |
967b88c4 | 1186 | [ALC880_FIXUP_UNIWILL_DIG] = { |
1727a771 TI |
1187 | .type = HDA_FIXUP_PINS, |
1188 | .v.pins = (const struct hda_pintbl[]) { | |
967b88c4 TI |
1189 | /* disable bogus unused pins */ |
1190 | { 0x17, 0x411111f0 }, | |
1191 | { 0x19, 0x411111f0 }, | |
1192 | { 0x1b, 0x411111f0 }, | |
1193 | { 0x1f, 0x411111f0 }, | |
1194 | { } | |
1195 | } | |
1196 | }, | |
96e225f6 | 1197 | [ALC880_FIXUP_Z71V] = { |
1727a771 TI |
1198 | .type = HDA_FIXUP_PINS, |
1199 | .v.pins = (const struct hda_pintbl[]) { | |
96e225f6 TI |
1200 | /* set up the whole pins as BIOS is utterly broken */ |
1201 | { 0x14, 0x99030120 }, /* speaker */ | |
1202 | { 0x15, 0x0121411f }, /* HP */ | |
1203 | { 0x16, 0x411111f0 }, /* N/A */ | |
1204 | { 0x17, 0x411111f0 }, /* N/A */ | |
1205 | { 0x18, 0x01a19950 }, /* mic-in */ | |
1206 | { 0x19, 0x411111f0 }, /* N/A */ | |
1207 | { 0x1a, 0x01813031 }, /* line-in */ | |
1208 | { 0x1b, 0x411111f0 }, /* N/A */ | |
1209 | { 0x1c, 0x411111f0 }, /* N/A */ | |
1210 | { 0x1d, 0x411111f0 }, /* N/A */ | |
1211 | { 0x1e, 0x0144111e }, /* SPDIF */ | |
1212 | { } | |
1213 | } | |
1214 | }, | |
705f5ab4 TI |
1215 | [ALC880_FIXUP_ASUS_W5A] = { |
1216 | .type = HDA_FIXUP_PINS, | |
1217 | .v.pins = (const struct hda_pintbl[]) { | |
1218 | /* set up the whole pins as BIOS is utterly broken */ | |
1219 | { 0x14, 0x0121411f }, /* HP */ | |
1220 | { 0x15, 0x411111f0 }, /* N/A */ | |
1221 | { 0x16, 0x411111f0 }, /* N/A */ | |
1222 | { 0x17, 0x411111f0 }, /* N/A */ | |
1223 | { 0x18, 0x90a60160 }, /* mic */ | |
1224 | { 0x19, 0x411111f0 }, /* N/A */ | |
1225 | { 0x1a, 0x411111f0 }, /* N/A */ | |
1226 | { 0x1b, 0x411111f0 }, /* N/A */ | |
1227 | { 0x1c, 0x411111f0 }, /* N/A */ | |
1228 | { 0x1d, 0x411111f0 }, /* N/A */ | |
1229 | { 0x1e, 0xb743111e }, /* SPDIF out */ | |
1230 | { } | |
1231 | }, | |
1232 | .chained = true, | |
1233 | .chain_id = ALC880_FIXUP_GPIO1, | |
1234 | }, | |
67b6ec31 | 1235 | [ALC880_FIXUP_3ST_BASE] = { |
1727a771 TI |
1236 | .type = HDA_FIXUP_PINS, |
1237 | .v.pins = (const struct hda_pintbl[]) { | |
67b6ec31 TI |
1238 | { 0x14, 0x01014010 }, /* line-out */ |
1239 | { 0x15, 0x411111f0 }, /* N/A */ | |
1240 | { 0x16, 0x411111f0 }, /* N/A */ | |
1241 | { 0x17, 0x411111f0 }, /* N/A */ | |
1242 | { 0x18, 0x01a19c30 }, /* mic-in */ | |
1243 | { 0x19, 0x0121411f }, /* HP */ | |
1244 | { 0x1a, 0x01813031 }, /* line-in */ | |
1245 | { 0x1b, 0x02a19c40 }, /* front-mic */ | |
1246 | { 0x1c, 0x411111f0 }, /* N/A */ | |
1247 | { 0x1d, 0x411111f0 }, /* N/A */ | |
1248 | /* 0x1e is filled in below */ | |
1249 | { 0x1f, 0x411111f0 }, /* N/A */ | |
1250 | { } | |
1251 | } | |
1252 | }, | |
1253 | [ALC880_FIXUP_3ST] = { | |
1727a771 TI |
1254 | .type = HDA_FIXUP_PINS, |
1255 | .v.pins = (const struct hda_pintbl[]) { | |
67b6ec31 TI |
1256 | { 0x1e, 0x411111f0 }, /* N/A */ |
1257 | { } | |
1258 | }, | |
1259 | .chained = true, | |
1260 | .chain_id = ALC880_FIXUP_3ST_BASE, | |
1261 | }, | |
1262 | [ALC880_FIXUP_3ST_DIG] = { | |
1727a771 TI |
1263 | .type = HDA_FIXUP_PINS, |
1264 | .v.pins = (const struct hda_pintbl[]) { | |
67b6ec31 TI |
1265 | { 0x1e, 0x0144111e }, /* SPDIF */ |
1266 | { } | |
1267 | }, | |
1268 | .chained = true, | |
1269 | .chain_id = ALC880_FIXUP_3ST_BASE, | |
1270 | }, | |
1271 | [ALC880_FIXUP_5ST_BASE] = { | |
1727a771 TI |
1272 | .type = HDA_FIXUP_PINS, |
1273 | .v.pins = (const struct hda_pintbl[]) { | |
67b6ec31 TI |
1274 | { 0x14, 0x01014010 }, /* front */ |
1275 | { 0x15, 0x411111f0 }, /* N/A */ | |
1276 | { 0x16, 0x01011411 }, /* CLFE */ | |
1277 | { 0x17, 0x01016412 }, /* surr */ | |
1278 | { 0x18, 0x01a19c30 }, /* mic-in */ | |
1279 | { 0x19, 0x0121411f }, /* HP */ | |
1280 | { 0x1a, 0x01813031 }, /* line-in */ | |
1281 | { 0x1b, 0x02a19c40 }, /* front-mic */ | |
1282 | { 0x1c, 0x411111f0 }, /* N/A */ | |
1283 | { 0x1d, 0x411111f0 }, /* N/A */ | |
1284 | /* 0x1e is filled in below */ | |
1285 | { 0x1f, 0x411111f0 }, /* N/A */ | |
1286 | { } | |
1287 | } | |
1288 | }, | |
1289 | [ALC880_FIXUP_5ST] = { | |
1727a771 TI |
1290 | .type = HDA_FIXUP_PINS, |
1291 | .v.pins = (const struct hda_pintbl[]) { | |
67b6ec31 TI |
1292 | { 0x1e, 0x411111f0 }, /* N/A */ |
1293 | { } | |
1294 | }, | |
1295 | .chained = true, | |
1296 | .chain_id = ALC880_FIXUP_5ST_BASE, | |
1297 | }, | |
1298 | [ALC880_FIXUP_5ST_DIG] = { | |
1727a771 TI |
1299 | .type = HDA_FIXUP_PINS, |
1300 | .v.pins = (const struct hda_pintbl[]) { | |
67b6ec31 TI |
1301 | { 0x1e, 0x0144111e }, /* SPDIF */ |
1302 | { } | |
1303 | }, | |
1304 | .chained = true, | |
1305 | .chain_id = ALC880_FIXUP_5ST_BASE, | |
1306 | }, | |
1307 | [ALC880_FIXUP_6ST_BASE] = { | |
1727a771 TI |
1308 | .type = HDA_FIXUP_PINS, |
1309 | .v.pins = (const struct hda_pintbl[]) { | |
67b6ec31 TI |
1310 | { 0x14, 0x01014010 }, /* front */ |
1311 | { 0x15, 0x01016412 }, /* surr */ | |
1312 | { 0x16, 0x01011411 }, /* CLFE */ | |
1313 | { 0x17, 0x01012414 }, /* side */ | |
1314 | { 0x18, 0x01a19c30 }, /* mic-in */ | |
1315 | { 0x19, 0x02a19c40 }, /* front-mic */ | |
1316 | { 0x1a, 0x01813031 }, /* line-in */ | |
1317 | { 0x1b, 0x0121411f }, /* HP */ | |
1318 | { 0x1c, 0x411111f0 }, /* N/A */ | |
1319 | { 0x1d, 0x411111f0 }, /* N/A */ | |
1320 | /* 0x1e is filled in below */ | |
1321 | { 0x1f, 0x411111f0 }, /* N/A */ | |
1322 | { } | |
1323 | } | |
1324 | }, | |
1325 | [ALC880_FIXUP_6ST] = { | |
1727a771 TI |
1326 | .type = HDA_FIXUP_PINS, |
1327 | .v.pins = (const struct hda_pintbl[]) { | |
67b6ec31 TI |
1328 | { 0x1e, 0x411111f0 }, /* N/A */ |
1329 | { } | |
1330 | }, | |
1331 | .chained = true, | |
1332 | .chain_id = ALC880_FIXUP_6ST_BASE, | |
1333 | }, | |
1334 | [ALC880_FIXUP_6ST_DIG] = { | |
1727a771 TI |
1335 | .type = HDA_FIXUP_PINS, |
1336 | .v.pins = (const struct hda_pintbl[]) { | |
67b6ec31 TI |
1337 | { 0x1e, 0x0144111e }, /* SPDIF */ |
1338 | { } | |
1339 | }, | |
1340 | .chained = true, | |
1341 | .chain_id = ALC880_FIXUP_6ST_BASE, | |
1342 | }, | |
5397145f TI |
1343 | [ALC880_FIXUP_6ST_AUTOMUTE] = { |
1344 | .type = HDA_FIXUP_PINS, | |
1345 | .v.pins = (const struct hda_pintbl[]) { | |
1346 | { 0x1b, 0x0121401f }, /* HP with jack detect */ | |
1347 | { } | |
1348 | }, | |
1349 | .chained_before = true, | |
1350 | .chain_id = ALC880_FIXUP_6ST_BASE, | |
1351 | }, | |
ee3b2969 TI |
1352 | }; |
1353 | ||
1354 | static const struct snd_pci_quirk alc880_fixup_tbl[] = { | |
f02aab5d | 1355 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810), |
705f5ab4 | 1356 | SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A), |
96e225f6 | 1357 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V), |
29e3fdcc TI |
1358 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1), |
1359 | SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2), | |
27e917f8 | 1360 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF), |
967b88c4 | 1361 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG), |
ba533818 | 1362 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734), |
817de92f | 1363 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL), |
7833c7e8 | 1364 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB), |
f02aab5d | 1365 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810), |
ee3b2969 | 1366 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM), |
5397145f | 1367 | SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE), |
4c9510d5 | 1368 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC Amilo M1437", ALC880_FIXUP_FUJITSU), |
cf5a2279 | 1369 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU), |
ba533818 | 1370 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734), |
cf5a2279 | 1371 | SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU), |
dc6af52d TI |
1372 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG), |
1373 | SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG), | |
1374 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG), | |
db3175e1 | 1375 | SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25), |
b9368f5c | 1376 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700), |
67b6ec31 TI |
1377 | |
1378 | /* Below is the copied entries from alc880_quirks.c. | |
1379 | * It's not quite sure whether BIOS sets the correct pin-config table | |
1380 | * on these machines, thus they are kept to be compatible with | |
1381 | * the old static quirks. Once when it's confirmed to work without | |
1382 | * these overrides, it'd be better to remove. | |
1383 | */ | |
1384 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG), | |
1385 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST), | |
1386 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG), | |
1387 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG), | |
1388 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG), | |
1389 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG), | |
1390 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG), | |
1391 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST), | |
1392 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG), | |
1393 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST), | |
1394 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST), | |
1395 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST), | |
1396 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST), | |
1397 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST), | |
1398 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG), | |
1399 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG), | |
1400 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG), | |
1401 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG), | |
1402 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG), | |
1403 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG), | |
1404 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG), | |
1405 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */ | |
1406 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG), | |
1407 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG), | |
1408 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG), | |
1409 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG), | |
1410 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG), | |
1411 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG), | |
1412 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG), | |
1413 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG), | |
1414 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG), | |
1415 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG), | |
1416 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG), | |
1417 | /* default Intel */ | |
1418 | SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST), | |
1419 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG), | |
1420 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG), | |
1421 | {} | |
1422 | }; | |
1423 | ||
1727a771 | 1424 | static const struct hda_model_fixup alc880_fixup_models[] = { |
67b6ec31 TI |
1425 | {.id = ALC880_FIXUP_3ST, .name = "3stack"}, |
1426 | {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"}, | |
1427 | {.id = ALC880_FIXUP_5ST, .name = "5stack"}, | |
1428 | {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"}, | |
1429 | {.id = ALC880_FIXUP_6ST, .name = "6stack"}, | |
1430 | {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"}, | |
5397145f | 1431 | {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"}, |
ee3b2969 TI |
1432 | {} |
1433 | }; | |
1434 | ||
1435 | ||
1d045db9 TI |
1436 | /* |
1437 | * OK, here we have finally the patch for ALC880 | |
1438 | */ | |
1d045db9 | 1439 | static int patch_alc880(struct hda_codec *codec) |
60db6b53 | 1440 | { |
1d045db9 | 1441 | struct alc_spec *spec; |
1d045db9 | 1442 | int err; |
f6a92248 | 1443 | |
3de95173 TI |
1444 | err = alc_alloc_spec(codec, 0x0b); |
1445 | if (err < 0) | |
1446 | return err; | |
64154835 | 1447 | |
3de95173 | 1448 | spec = codec->spec; |
08c189f2 | 1449 | spec->gen.need_dac_fix = 1; |
7504b6cd | 1450 | spec->gen.beep_nid = 0x01; |
f53281e6 | 1451 | |
1727a771 | 1452 | snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, |
67b6ec31 | 1453 | alc880_fixups); |
1727a771 | 1454 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
ee3b2969 | 1455 | |
67b6ec31 TI |
1456 | /* automatic parse from the BIOS config */ |
1457 | err = alc880_parse_auto_config(codec); | |
1458 | if (err < 0) | |
1459 | goto error; | |
fe3eb0a7 | 1460 | |
7504b6cd | 1461 | if (!spec->gen.no_analog) |
3e6179b8 | 1462 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
f53281e6 | 1463 | |
1d045db9 | 1464 | codec->patch_ops = alc_patch_ops; |
29adc4b9 DH |
1465 | codec->patch_ops.unsol_event = alc880_unsol_event; |
1466 | ||
f53281e6 | 1467 | |
1727a771 | 1468 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
589876e2 | 1469 | |
1d045db9 | 1470 | return 0; |
e16fb6d1 TI |
1471 | |
1472 | error: | |
1473 | alc_free(codec); | |
1474 | return err; | |
226b1ec8 KY |
1475 | } |
1476 | ||
1d045db9 | 1477 | |
60db6b53 | 1478 | /* |
1d045db9 | 1479 | * ALC260 support |
60db6b53 | 1480 | */ |
1d045db9 | 1481 | static int alc260_parse_auto_config(struct hda_codec *codec) |
f6a92248 | 1482 | { |
1d045db9 | 1483 | static const hda_nid_t alc260_ignore[] = { 0x17, 0 }; |
3e6179b8 TI |
1484 | static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 }; |
1485 | return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids); | |
f6a92248 KY |
1486 | } |
1487 | ||
1d045db9 TI |
1488 | /* |
1489 | * Pin config fixes | |
1490 | */ | |
1491 | enum { | |
ca8f0424 TI |
1492 | ALC260_FIXUP_HP_DC5750, |
1493 | ALC260_FIXUP_HP_PIN_0F, | |
1494 | ALC260_FIXUP_COEF, | |
15317ab2 | 1495 | ALC260_FIXUP_GPIO1, |
20f7d928 TI |
1496 | ALC260_FIXUP_GPIO1_TOGGLE, |
1497 | ALC260_FIXUP_REPLACER, | |
0a1c4fa2 | 1498 | ALC260_FIXUP_HP_B1900, |
118cb4a4 | 1499 | ALC260_FIXUP_KN1, |
39aedee7 | 1500 | ALC260_FIXUP_FSC_S7020, |
5ebd3bbd | 1501 | ALC260_FIXUP_FSC_S7020_JWSE, |
5bc7e35d | 1502 | ALC260_FIXUP_VAIO_PINS, |
1d045db9 TI |
1503 | }; |
1504 | ||
20f7d928 TI |
1505 | static void alc260_gpio1_automute(struct hda_codec *codec) |
1506 | { | |
1507 | struct alc_spec *spec = codec->spec; | |
1508 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, | |
08c189f2 | 1509 | spec->gen.hp_jack_present); |
20f7d928 TI |
1510 | } |
1511 | ||
1512 | static void alc260_fixup_gpio1_toggle(struct hda_codec *codec, | |
1727a771 | 1513 | const struct hda_fixup *fix, int action) |
20f7d928 TI |
1514 | { |
1515 | struct alc_spec *spec = codec->spec; | |
1727a771 | 1516 | if (action == HDA_FIXUP_ACT_PROBE) { |
20f7d928 TI |
1517 | /* although the machine has only one output pin, we need to |
1518 | * toggle GPIO1 according to the jack state | |
1519 | */ | |
08c189f2 TI |
1520 | spec->gen.automute_hook = alc260_gpio1_automute; |
1521 | spec->gen.detect_hp = 1; | |
1522 | spec->gen.automute_speaker = 1; | |
1523 | spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */ | |
1524 | snd_hda_jack_detect_enable_callback(codec, 0x0f, HDA_GEN_HP_EVENT, | |
1525 | snd_hda_gen_hp_automute); | |
c9ce6b26 | 1526 | snd_hda_add_verbs(codec, alc_gpio1_init_verbs); |
20f7d928 TI |
1527 | } |
1528 | } | |
1529 | ||
118cb4a4 | 1530 | static void alc260_fixup_kn1(struct hda_codec *codec, |
1727a771 | 1531 | const struct hda_fixup *fix, int action) |
118cb4a4 TI |
1532 | { |
1533 | struct alc_spec *spec = codec->spec; | |
1727a771 | 1534 | static const struct hda_pintbl pincfgs[] = { |
118cb4a4 TI |
1535 | { 0x0f, 0x02214000 }, /* HP/speaker */ |
1536 | { 0x12, 0x90a60160 }, /* int mic */ | |
1537 | { 0x13, 0x02a19000 }, /* ext mic */ | |
1538 | { 0x18, 0x01446000 }, /* SPDIF out */ | |
1539 | /* disable bogus I/O pins */ | |
1540 | { 0x10, 0x411111f0 }, | |
1541 | { 0x11, 0x411111f0 }, | |
1542 | { 0x14, 0x411111f0 }, | |
1543 | { 0x15, 0x411111f0 }, | |
1544 | { 0x16, 0x411111f0 }, | |
1545 | { 0x17, 0x411111f0 }, | |
1546 | { 0x19, 0x411111f0 }, | |
1547 | { } | |
1548 | }; | |
1549 | ||
1550 | switch (action) { | |
1727a771 TI |
1551 | case HDA_FIXUP_ACT_PRE_PROBE: |
1552 | snd_hda_apply_pincfgs(codec, pincfgs); | |
118cb4a4 | 1553 | break; |
1727a771 | 1554 | case HDA_FIXUP_ACT_PROBE: |
118cb4a4 TI |
1555 | spec->init_amp = ALC_INIT_NONE; |
1556 | break; | |
1557 | } | |
1558 | } | |
1559 | ||
39aedee7 TI |
1560 | static void alc260_fixup_fsc_s7020(struct hda_codec *codec, |
1561 | const struct hda_fixup *fix, int action) | |
1562 | { | |
1563 | struct alc_spec *spec = codec->spec; | |
5ebd3bbd TI |
1564 | if (action == HDA_FIXUP_ACT_PROBE) |
1565 | spec->init_amp = ALC_INIT_NONE; | |
1566 | } | |
39aedee7 | 1567 | |
5ebd3bbd TI |
1568 | static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec, |
1569 | const struct hda_fixup *fix, int action) | |
1570 | { | |
1571 | struct alc_spec *spec = codec->spec; | |
1572 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { | |
f811c3cf | 1573 | spec->gen.add_jack_modes = 1; |
5ebd3bbd | 1574 | spec->gen.hp_mic = 1; |
e6e0ee50 | 1575 | } |
39aedee7 TI |
1576 | } |
1577 | ||
1727a771 | 1578 | static const struct hda_fixup alc260_fixups[] = { |
ca8f0424 | 1579 | [ALC260_FIXUP_HP_DC5750] = { |
1727a771 TI |
1580 | .type = HDA_FIXUP_PINS, |
1581 | .v.pins = (const struct hda_pintbl[]) { | |
1d045db9 TI |
1582 | { 0x11, 0x90130110 }, /* speaker */ |
1583 | { } | |
1584 | } | |
1585 | }, | |
ca8f0424 | 1586 | [ALC260_FIXUP_HP_PIN_0F] = { |
1727a771 TI |
1587 | .type = HDA_FIXUP_PINS, |
1588 | .v.pins = (const struct hda_pintbl[]) { | |
ca8f0424 TI |
1589 | { 0x0f, 0x01214000 }, /* HP */ |
1590 | { } | |
1591 | } | |
1592 | }, | |
1593 | [ALC260_FIXUP_COEF] = { | |
1727a771 | 1594 | .type = HDA_FIXUP_VERBS, |
ca8f0424 | 1595 | .v.verbs = (const struct hda_verb[]) { |
b270c497 RM |
1596 | { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 }, |
1597 | { 0x1a, AC_VERB_SET_PROC_COEF, 0x3040 }, | |
ca8f0424 TI |
1598 | { } |
1599 | }, | |
ca8f0424 | 1600 | }, |
15317ab2 | 1601 | [ALC260_FIXUP_GPIO1] = { |
1727a771 | 1602 | .type = HDA_FIXUP_VERBS, |
15317ab2 TI |
1603 | .v.verbs = alc_gpio1_init_verbs, |
1604 | }, | |
20f7d928 | 1605 | [ALC260_FIXUP_GPIO1_TOGGLE] = { |
1727a771 | 1606 | .type = HDA_FIXUP_FUNC, |
20f7d928 TI |
1607 | .v.func = alc260_fixup_gpio1_toggle, |
1608 | .chained = true, | |
1609 | .chain_id = ALC260_FIXUP_HP_PIN_0F, | |
1610 | }, | |
1611 | [ALC260_FIXUP_REPLACER] = { | |
1727a771 | 1612 | .type = HDA_FIXUP_VERBS, |
20f7d928 | 1613 | .v.verbs = (const struct hda_verb[]) { |
873428ff TI |
1614 | { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 }, |
1615 | { 0x1a, AC_VERB_SET_PROC_COEF, 0x3050 }, | |
20f7d928 TI |
1616 | { } |
1617 | }, | |
1618 | .chained = true, | |
1619 | .chain_id = ALC260_FIXUP_GPIO1_TOGGLE, | |
1620 | }, | |
0a1c4fa2 | 1621 | [ALC260_FIXUP_HP_B1900] = { |
1727a771 | 1622 | .type = HDA_FIXUP_FUNC, |
0a1c4fa2 TI |
1623 | .v.func = alc260_fixup_gpio1_toggle, |
1624 | .chained = true, | |
1625 | .chain_id = ALC260_FIXUP_COEF, | |
118cb4a4 TI |
1626 | }, |
1627 | [ALC260_FIXUP_KN1] = { | |
1727a771 | 1628 | .type = HDA_FIXUP_FUNC, |
118cb4a4 TI |
1629 | .v.func = alc260_fixup_kn1, |
1630 | }, | |
39aedee7 TI |
1631 | [ALC260_FIXUP_FSC_S7020] = { |
1632 | .type = HDA_FIXUP_FUNC, | |
1633 | .v.func = alc260_fixup_fsc_s7020, | |
1634 | }, | |
5ebd3bbd TI |
1635 | [ALC260_FIXUP_FSC_S7020_JWSE] = { |
1636 | .type = HDA_FIXUP_FUNC, | |
1637 | .v.func = alc260_fixup_fsc_s7020_jwse, | |
1638 | .chained = true, | |
1639 | .chain_id = ALC260_FIXUP_FSC_S7020, | |
1640 | }, | |
5bc7e35d TI |
1641 | [ALC260_FIXUP_VAIO_PINS] = { |
1642 | .type = HDA_FIXUP_PINS, | |
1643 | .v.pins = (const struct hda_pintbl[]) { | |
1644 | /* Pin configs are missing completely on some VAIOs */ | |
1645 | { 0x0f, 0x01211020 }, | |
1646 | { 0x10, 0x0001003f }, | |
1647 | { 0x11, 0x411111f0 }, | |
1648 | { 0x12, 0x01a15930 }, | |
1649 | { 0x13, 0x411111f0 }, | |
1650 | { 0x14, 0x411111f0 }, | |
1651 | { 0x15, 0x411111f0 }, | |
1652 | { 0x16, 0x411111f0 }, | |
1653 | { 0x17, 0x411111f0 }, | |
1654 | { 0x18, 0x411111f0 }, | |
1655 | { 0x19, 0x411111f0 }, | |
1656 | { } | |
1657 | } | |
1658 | }, | |
1d045db9 TI |
1659 | }; |
1660 | ||
1661 | static const struct snd_pci_quirk alc260_fixup_tbl[] = { | |
15317ab2 | 1662 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1), |
ca8f0424 | 1663 | SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF), |
15317ab2 | 1664 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1), |
ca8f0424 | 1665 | SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750), |
0a1c4fa2 | 1666 | SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900), |
5bc7e35d | 1667 | SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS), |
a020c697 | 1668 | SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F), |
39aedee7 | 1669 | SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020), |
b1f58085 | 1670 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1), |
118cb4a4 | 1671 | SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1), |
20f7d928 | 1672 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER), |
ca8f0424 | 1673 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF), |
1d045db9 TI |
1674 | {} |
1675 | }; | |
1676 | ||
5ebd3bbd TI |
1677 | static const struct hda_model_fixup alc260_fixup_models[] = { |
1678 | {.id = ALC260_FIXUP_GPIO1, .name = "gpio1"}, | |
1679 | {.id = ALC260_FIXUP_COEF, .name = "coef"}, | |
1680 | {.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"}, | |
1681 | {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"}, | |
1682 | {} | |
1683 | }; | |
1684 | ||
1d045db9 TI |
1685 | /* |
1686 | */ | |
1d045db9 | 1687 | static int patch_alc260(struct hda_codec *codec) |
977ddd6b | 1688 | { |
1d045db9 | 1689 | struct alc_spec *spec; |
c3c2c9e7 | 1690 | int err; |
1d045db9 | 1691 | |
3de95173 TI |
1692 | err = alc_alloc_spec(codec, 0x07); |
1693 | if (err < 0) | |
1694 | return err; | |
1d045db9 | 1695 | |
3de95173 | 1696 | spec = codec->spec; |
ea46c3c8 TI |
1697 | /* as quite a few machines require HP amp for speaker outputs, |
1698 | * it's easier to enable it unconditionally; even if it's unneeded, | |
1699 | * it's almost harmless. | |
1700 | */ | |
1701 | spec->gen.prefer_hp_amp = 1; | |
7504b6cd | 1702 | spec->gen.beep_nid = 0x01; |
1d045db9 | 1703 | |
5ebd3bbd TI |
1704 | snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl, |
1705 | alc260_fixups); | |
1727a771 | 1706 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
977ddd6b | 1707 | |
c3c2c9e7 TI |
1708 | /* automatic parse from the BIOS config */ |
1709 | err = alc260_parse_auto_config(codec); | |
1710 | if (err < 0) | |
1711 | goto error; | |
977ddd6b | 1712 | |
7504b6cd | 1713 | if (!spec->gen.no_analog) |
3e6179b8 | 1714 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
977ddd6b | 1715 | |
1d045db9 | 1716 | codec->patch_ops = alc_patch_ops; |
1d045db9 | 1717 | spec->shutup = alc_eapd_shutup; |
6981d184 | 1718 | |
1727a771 | 1719 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
589876e2 | 1720 | |
1d045db9 | 1721 | return 0; |
e16fb6d1 TI |
1722 | |
1723 | error: | |
1724 | alc_free(codec); | |
1725 | return err; | |
6981d184 TI |
1726 | } |
1727 | ||
1d045db9 TI |
1728 | |
1729 | /* | |
1730 | * ALC882/883/885/888/889 support | |
1731 | * | |
1732 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible | |
1733 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
1734 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
1735 | * 6-channel independent captures. | |
1736 | * | |
1737 | * In addition, an independent DAC for the multi-playback (not used in this | |
1738 | * driver yet). | |
1739 | */ | |
1d045db9 TI |
1740 | |
1741 | /* | |
1742 | * Pin config fixes | |
1743 | */ | |
ff818c24 | 1744 | enum { |
5c0ebfbe TI |
1745 | ALC882_FIXUP_ABIT_AW9D_MAX, |
1746 | ALC882_FIXUP_LENOVO_Y530, | |
1747 | ALC882_FIXUP_PB_M5210, | |
1748 | ALC882_FIXUP_ACER_ASPIRE_7736, | |
1749 | ALC882_FIXUP_ASUS_W90V, | |
8f239214 | 1750 | ALC889_FIXUP_CD, |
5c0ebfbe | 1751 | ALC889_FIXUP_VAIO_TT, |
0e7cc2e7 | 1752 | ALC888_FIXUP_EEE1601, |
177943a3 | 1753 | ALC882_FIXUP_EAPD, |
7a6069bf | 1754 | ALC883_FIXUP_EAPD, |
8812c4f9 | 1755 | ALC883_FIXUP_ACER_EAPD, |
1a97b7f2 TI |
1756 | ALC882_FIXUP_GPIO1, |
1757 | ALC882_FIXUP_GPIO2, | |
eb844d51 | 1758 | ALC882_FIXUP_GPIO3, |
68ef0561 TI |
1759 | ALC889_FIXUP_COEF, |
1760 | ALC882_FIXUP_ASUS_W2JC, | |
c3e837bb TI |
1761 | ALC882_FIXUP_ACER_ASPIRE_4930G, |
1762 | ALC882_FIXUP_ACER_ASPIRE_8930G, | |
1763 | ALC882_FIXUP_ASPIRE_8930G_VERBS, | |
5671087f | 1764 | ALC885_FIXUP_MACPRO_GPIO, |
02a237b2 | 1765 | ALC889_FIXUP_DAC_ROUTE, |
1a97b7f2 TI |
1766 | ALC889_FIXUP_MBP_VREF, |
1767 | ALC889_FIXUP_IMAC91_VREF, | |
3cf79a3c | 1768 | ALC889_FIXUP_MBA11_VREF, |
64871fb0 | 1769 | ALC889_FIXUP_MBA21_VREF, |
1e8968b3 | 1770 | ALC889_FIXUP_MP11_VREF, |
6e72aa5f | 1771 | ALC882_FIXUP_INV_DMIC, |
e427c237 | 1772 | ALC882_FIXUP_NO_PRIMARY_HP, |
7f9bf8ad | 1773 | ALC887_FIXUP_ASUS_BASS, |
ff818c24 TI |
1774 | }; |
1775 | ||
68ef0561 | 1776 | static void alc889_fixup_coef(struct hda_codec *codec, |
1727a771 | 1777 | const struct hda_fixup *fix, int action) |
68ef0561 | 1778 | { |
1727a771 | 1779 | if (action != HDA_FIXUP_ACT_INIT) |
68ef0561 TI |
1780 | return; |
1781 | alc889_coef_init(codec); | |
1782 | } | |
1783 | ||
5671087f TI |
1784 | /* toggle speaker-output according to the hp-jack state */ |
1785 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) | |
1786 | { | |
1787 | unsigned int gpiostate, gpiomask, gpiodir; | |
1788 | ||
1789 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, | |
1790 | AC_VERB_GET_GPIO_DATA, 0); | |
1791 | ||
1792 | if (!muted) | |
1793 | gpiostate |= (1 << pin); | |
1794 | else | |
1795 | gpiostate &= ~(1 << pin); | |
1796 | ||
1797 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, | |
1798 | AC_VERB_GET_GPIO_MASK, 0); | |
1799 | gpiomask |= (1 << pin); | |
1800 | ||
1801 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, | |
1802 | AC_VERB_GET_GPIO_DIRECTION, 0); | |
1803 | gpiodir |= (1 << pin); | |
1804 | ||
1805 | ||
1806 | snd_hda_codec_write(codec, codec->afg, 0, | |
1807 | AC_VERB_SET_GPIO_MASK, gpiomask); | |
1808 | snd_hda_codec_write(codec, codec->afg, 0, | |
1809 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); | |
1810 | ||
1811 | msleep(1); | |
1812 | ||
1813 | snd_hda_codec_write(codec, codec->afg, 0, | |
1814 | AC_VERB_SET_GPIO_DATA, gpiostate); | |
1815 | } | |
1816 | ||
1817 | /* set up GPIO at initialization */ | |
1818 | static void alc885_fixup_macpro_gpio(struct hda_codec *codec, | |
1727a771 | 1819 | const struct hda_fixup *fix, int action) |
5671087f | 1820 | { |
1727a771 | 1821 | if (action != HDA_FIXUP_ACT_INIT) |
5671087f TI |
1822 | return; |
1823 | alc882_gpio_mute(codec, 0, 0); | |
1824 | alc882_gpio_mute(codec, 1, 0); | |
1825 | } | |
1826 | ||
02a237b2 TI |
1827 | /* Fix the connection of some pins for ALC889: |
1828 | * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't | |
1829 | * work correctly (bko#42740) | |
1830 | */ | |
1831 | static void alc889_fixup_dac_route(struct hda_codec *codec, | |
1727a771 | 1832 | const struct hda_fixup *fix, int action) |
02a237b2 | 1833 | { |
1727a771 | 1834 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
ef8d60fb | 1835 | /* fake the connections during parsing the tree */ |
02a237b2 TI |
1836 | hda_nid_t conn1[2] = { 0x0c, 0x0d }; |
1837 | hda_nid_t conn2[2] = { 0x0e, 0x0f }; | |
1838 | snd_hda_override_conn_list(codec, 0x14, 2, conn1); | |
1839 | snd_hda_override_conn_list(codec, 0x15, 2, conn1); | |
1840 | snd_hda_override_conn_list(codec, 0x18, 2, conn2); | |
1841 | snd_hda_override_conn_list(codec, 0x1a, 2, conn2); | |
1727a771 | 1842 | } else if (action == HDA_FIXUP_ACT_PROBE) { |
ef8d60fb TI |
1843 | /* restore the connections */ |
1844 | hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; | |
1845 | snd_hda_override_conn_list(codec, 0x14, 5, conn); | |
1846 | snd_hda_override_conn_list(codec, 0x15, 5, conn); | |
1847 | snd_hda_override_conn_list(codec, 0x18, 5, conn); | |
1848 | snd_hda_override_conn_list(codec, 0x1a, 5, conn); | |
02a237b2 TI |
1849 | } |
1850 | } | |
1851 | ||
1a97b7f2 TI |
1852 | /* Set VREF on HP pin */ |
1853 | static void alc889_fixup_mbp_vref(struct hda_codec *codec, | |
1727a771 | 1854 | const struct hda_fixup *fix, int action) |
1a97b7f2 TI |
1855 | { |
1856 | struct alc_spec *spec = codec->spec; | |
1857 | static hda_nid_t nids[2] = { 0x14, 0x15 }; | |
1858 | int i; | |
1859 | ||
1727a771 | 1860 | if (action != HDA_FIXUP_ACT_INIT) |
1a97b7f2 TI |
1861 | return; |
1862 | for (i = 0; i < ARRAY_SIZE(nids); i++) { | |
1863 | unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]); | |
1864 | if (get_defcfg_device(val) != AC_JACK_HP_OUT) | |
1865 | continue; | |
d3f02d60 | 1866 | val = snd_hda_codec_get_pin_target(codec, nids[i]); |
1a97b7f2 | 1867 | val |= AC_PINCTL_VREF_80; |
cdd03ced | 1868 | snd_hda_set_pin_ctl(codec, nids[i], val); |
08c189f2 | 1869 | spec->gen.keep_vref_in_automute = 1; |
1a97b7f2 TI |
1870 | break; |
1871 | } | |
1872 | } | |
1873 | ||
64871fb0 TI |
1874 | static void alc889_fixup_mac_pins(struct hda_codec *codec, |
1875 | const hda_nid_t *nids, int num_nids) | |
1a97b7f2 TI |
1876 | { |
1877 | struct alc_spec *spec = codec->spec; | |
1a97b7f2 TI |
1878 | int i; |
1879 | ||
64871fb0 | 1880 | for (i = 0; i < num_nids; i++) { |
1a97b7f2 | 1881 | unsigned int val; |
d3f02d60 | 1882 | val = snd_hda_codec_get_pin_target(codec, nids[i]); |
1a97b7f2 | 1883 | val |= AC_PINCTL_VREF_50; |
cdd03ced | 1884 | snd_hda_set_pin_ctl(codec, nids[i], val); |
1a97b7f2 | 1885 | } |
08c189f2 | 1886 | spec->gen.keep_vref_in_automute = 1; |
1a97b7f2 TI |
1887 | } |
1888 | ||
64871fb0 TI |
1889 | /* Set VREF on speaker pins on imac91 */ |
1890 | static void alc889_fixup_imac91_vref(struct hda_codec *codec, | |
1891 | const struct hda_fixup *fix, int action) | |
1892 | { | |
1893 | static hda_nid_t nids[2] = { 0x18, 0x1a }; | |
1894 | ||
1895 | if (action == HDA_FIXUP_ACT_INIT) | |
1896 | alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids)); | |
1897 | } | |
1898 | ||
3cf79a3c AV |
1899 | /* Set VREF on speaker pins on mba11 */ |
1900 | static void alc889_fixup_mba11_vref(struct hda_codec *codec, | |
1901 | const struct hda_fixup *fix, int action) | |
1902 | { | |
1903 | static hda_nid_t nids[1] = { 0x18 }; | |
1904 | ||
1905 | if (action == HDA_FIXUP_ACT_INIT) | |
1906 | alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids)); | |
1907 | } | |
1908 | ||
64871fb0 TI |
1909 | /* Set VREF on speaker pins on mba21 */ |
1910 | static void alc889_fixup_mba21_vref(struct hda_codec *codec, | |
1911 | const struct hda_fixup *fix, int action) | |
1912 | { | |
1913 | static hda_nid_t nids[2] = { 0x18, 0x19 }; | |
1914 | ||
1915 | if (action == HDA_FIXUP_ACT_INIT) | |
1916 | alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids)); | |
1917 | } | |
1918 | ||
e427c237 | 1919 | /* Don't take HP output as primary |
d9111496 FLVC |
1920 | * Strangely, the speaker output doesn't work on Vaio Z and some Vaio |
1921 | * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05 | |
e427c237 TI |
1922 | */ |
1923 | static void alc882_fixup_no_primary_hp(struct hda_codec *codec, | |
1727a771 | 1924 | const struct hda_fixup *fix, int action) |
e427c237 TI |
1925 | { |
1926 | struct alc_spec *spec = codec->spec; | |
1727a771 | 1927 | if (action == HDA_FIXUP_ACT_PRE_PROBE) |
08c189f2 | 1928 | spec->gen.no_primary_hp = 1; |
e427c237 TI |
1929 | } |
1930 | ||
1727a771 | 1931 | static const struct hda_fixup alc882_fixups[] = { |
5c0ebfbe | 1932 | [ALC882_FIXUP_ABIT_AW9D_MAX] = { |
1727a771 TI |
1933 | .type = HDA_FIXUP_PINS, |
1934 | .v.pins = (const struct hda_pintbl[]) { | |
1d045db9 TI |
1935 | { 0x15, 0x01080104 }, /* side */ |
1936 | { 0x16, 0x01011012 }, /* rear */ | |
1937 | { 0x17, 0x01016011 }, /* clfe */ | |
2785591a | 1938 | { } |
145a902b DH |
1939 | } |
1940 | }, | |
5c0ebfbe | 1941 | [ALC882_FIXUP_LENOVO_Y530] = { |
1727a771 TI |
1942 | .type = HDA_FIXUP_PINS, |
1943 | .v.pins = (const struct hda_pintbl[]) { | |
1d045db9 TI |
1944 | { 0x15, 0x99130112 }, /* rear int speakers */ |
1945 | { 0x16, 0x99130111 }, /* subwoofer */ | |
ac612407 DH |
1946 | { } |
1947 | } | |
1948 | }, | |
5c0ebfbe | 1949 | [ALC882_FIXUP_PB_M5210] = { |
fd108215 TI |
1950 | .type = HDA_FIXUP_PINCTLS, |
1951 | .v.pins = (const struct hda_pintbl[]) { | |
1952 | { 0x19, PIN_VREF50 }, | |
357f915e KY |
1953 | {} |
1954 | } | |
1955 | }, | |
5c0ebfbe | 1956 | [ALC882_FIXUP_ACER_ASPIRE_7736] = { |
1727a771 | 1957 | .type = HDA_FIXUP_FUNC, |
23d30f28 | 1958 | .v.func = alc_fixup_sku_ignore, |
6981d184 | 1959 | }, |
5c0ebfbe | 1960 | [ALC882_FIXUP_ASUS_W90V] = { |
1727a771 TI |
1961 | .type = HDA_FIXUP_PINS, |
1962 | .v.pins = (const struct hda_pintbl[]) { | |
5cdf745e TI |
1963 | { 0x16, 0x99130110 }, /* fix sequence for CLFE */ |
1964 | { } | |
1965 | } | |
1966 | }, | |
8f239214 | 1967 | [ALC889_FIXUP_CD] = { |
1727a771 TI |
1968 | .type = HDA_FIXUP_PINS, |
1969 | .v.pins = (const struct hda_pintbl[]) { | |
8f239214 MB |
1970 | { 0x1c, 0x993301f0 }, /* CD */ |
1971 | { } | |
1972 | } | |
1973 | }, | |
5c0ebfbe | 1974 | [ALC889_FIXUP_VAIO_TT] = { |
1727a771 TI |
1975 | .type = HDA_FIXUP_PINS, |
1976 | .v.pins = (const struct hda_pintbl[]) { | |
5c0ebfbe TI |
1977 | { 0x17, 0x90170111 }, /* hidden surround speaker */ |
1978 | { } | |
1979 | } | |
1980 | }, | |
0e7cc2e7 | 1981 | [ALC888_FIXUP_EEE1601] = { |
1727a771 | 1982 | .type = HDA_FIXUP_VERBS, |
0e7cc2e7 TI |
1983 | .v.verbs = (const struct hda_verb[]) { |
1984 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, | |
1985 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 }, | |
1986 | { } | |
1987 | } | |
177943a3 TI |
1988 | }, |
1989 | [ALC882_FIXUP_EAPD] = { | |
1727a771 | 1990 | .type = HDA_FIXUP_VERBS, |
177943a3 TI |
1991 | .v.verbs = (const struct hda_verb[]) { |
1992 | /* change to EAPD mode */ | |
1993 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, | |
1994 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, | |
1995 | { } | |
1996 | } | |
1997 | }, | |
7a6069bf | 1998 | [ALC883_FIXUP_EAPD] = { |
1727a771 | 1999 | .type = HDA_FIXUP_VERBS, |
7a6069bf TI |
2000 | .v.verbs = (const struct hda_verb[]) { |
2001 | /* change to EAPD mode */ | |
2002 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, | |
2003 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, | |
2004 | { } | |
2005 | } | |
2006 | }, | |
8812c4f9 | 2007 | [ALC883_FIXUP_ACER_EAPD] = { |
1727a771 | 2008 | .type = HDA_FIXUP_VERBS, |
8812c4f9 TI |
2009 | .v.verbs = (const struct hda_verb[]) { |
2010 | /* eanable EAPD on Acer laptops */ | |
2011 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, | |
2012 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, | |
2013 | { } | |
2014 | } | |
2015 | }, | |
1a97b7f2 | 2016 | [ALC882_FIXUP_GPIO1] = { |
1727a771 | 2017 | .type = HDA_FIXUP_VERBS, |
1a97b7f2 TI |
2018 | .v.verbs = alc_gpio1_init_verbs, |
2019 | }, | |
2020 | [ALC882_FIXUP_GPIO2] = { | |
1727a771 | 2021 | .type = HDA_FIXUP_VERBS, |
1a97b7f2 TI |
2022 | .v.verbs = alc_gpio2_init_verbs, |
2023 | }, | |
eb844d51 | 2024 | [ALC882_FIXUP_GPIO3] = { |
1727a771 | 2025 | .type = HDA_FIXUP_VERBS, |
eb844d51 TI |
2026 | .v.verbs = alc_gpio3_init_verbs, |
2027 | }, | |
68ef0561 | 2028 | [ALC882_FIXUP_ASUS_W2JC] = { |
1727a771 | 2029 | .type = HDA_FIXUP_VERBS, |
68ef0561 TI |
2030 | .v.verbs = alc_gpio1_init_verbs, |
2031 | .chained = true, | |
2032 | .chain_id = ALC882_FIXUP_EAPD, | |
2033 | }, | |
2034 | [ALC889_FIXUP_COEF] = { | |
1727a771 | 2035 | .type = HDA_FIXUP_FUNC, |
68ef0561 TI |
2036 | .v.func = alc889_fixup_coef, |
2037 | }, | |
c3e837bb | 2038 | [ALC882_FIXUP_ACER_ASPIRE_4930G] = { |
1727a771 TI |
2039 | .type = HDA_FIXUP_PINS, |
2040 | .v.pins = (const struct hda_pintbl[]) { | |
c3e837bb TI |
2041 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
2042 | { 0x17, 0x99130112 }, /* surround speaker */ | |
2043 | { } | |
038d4fef TI |
2044 | }, |
2045 | .chained = true, | |
2046 | .chain_id = ALC882_FIXUP_GPIO1, | |
c3e837bb TI |
2047 | }, |
2048 | [ALC882_FIXUP_ACER_ASPIRE_8930G] = { | |
1727a771 TI |
2049 | .type = HDA_FIXUP_PINS, |
2050 | .v.pins = (const struct hda_pintbl[]) { | |
c3e837bb TI |
2051 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
2052 | { 0x1b, 0x99130112 }, /* surround speaker */ | |
2053 | { } | |
2054 | }, | |
2055 | .chained = true, | |
2056 | .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS, | |
2057 | }, | |
2058 | [ALC882_FIXUP_ASPIRE_8930G_VERBS] = { | |
2059 | /* additional init verbs for Acer Aspire 8930G */ | |
1727a771 | 2060 | .type = HDA_FIXUP_VERBS, |
c3e837bb TI |
2061 | .v.verbs = (const struct hda_verb[]) { |
2062 | /* Enable all DACs */ | |
2063 | /* DAC DISABLE/MUTE 1? */ | |
2064 | /* setting bits 1-5 disables DAC nids 0x02-0x06 | |
2065 | * apparently. Init=0x38 */ | |
2066 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 }, | |
2067 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, | |
2068 | /* DAC DISABLE/MUTE 2? */ | |
2069 | /* some bit here disables the other DACs. | |
2070 | * Init=0x4900 */ | |
2071 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 }, | |
2072 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, | |
2073 | /* DMIC fix | |
2074 | * This laptop has a stereo digital microphone. | |
2075 | * The mics are only 1cm apart which makes the stereo | |
2076 | * useless. However, either the mic or the ALC889 | |
2077 | * makes the signal become a difference/sum signal | |
2078 | * instead of standard stereo, which is annoying. | |
2079 | * So instead we flip this bit which makes the | |
2080 | * codec replicate the sum signal to both channels, | |
2081 | * turning it into a normal mono mic. | |
2082 | */ | |
2083 | /* DMIC_CONTROL? Init value = 0x0001 */ | |
2084 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, | |
2085 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 }, | |
2086 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, | |
2087 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, | |
2088 | { } | |
038d4fef TI |
2089 | }, |
2090 | .chained = true, | |
2091 | .chain_id = ALC882_FIXUP_GPIO1, | |
c3e837bb | 2092 | }, |
5671087f | 2093 | [ALC885_FIXUP_MACPRO_GPIO] = { |
1727a771 | 2094 | .type = HDA_FIXUP_FUNC, |
5671087f TI |
2095 | .v.func = alc885_fixup_macpro_gpio, |
2096 | }, | |
02a237b2 | 2097 | [ALC889_FIXUP_DAC_ROUTE] = { |
1727a771 | 2098 | .type = HDA_FIXUP_FUNC, |
02a237b2 TI |
2099 | .v.func = alc889_fixup_dac_route, |
2100 | }, | |
1a97b7f2 | 2101 | [ALC889_FIXUP_MBP_VREF] = { |
1727a771 | 2102 | .type = HDA_FIXUP_FUNC, |
1a97b7f2 TI |
2103 | .v.func = alc889_fixup_mbp_vref, |
2104 | .chained = true, | |
2105 | .chain_id = ALC882_FIXUP_GPIO1, | |
2106 | }, | |
2107 | [ALC889_FIXUP_IMAC91_VREF] = { | |
1727a771 | 2108 | .type = HDA_FIXUP_FUNC, |
1a97b7f2 TI |
2109 | .v.func = alc889_fixup_imac91_vref, |
2110 | .chained = true, | |
2111 | .chain_id = ALC882_FIXUP_GPIO1, | |
2112 | }, | |
3cf79a3c AV |
2113 | [ALC889_FIXUP_MBA11_VREF] = { |
2114 | .type = HDA_FIXUP_FUNC, | |
2115 | .v.func = alc889_fixup_mba11_vref, | |
2116 | .chained = true, | |
2117 | .chain_id = ALC889_FIXUP_MBP_VREF, | |
2118 | }, | |
64871fb0 TI |
2119 | [ALC889_FIXUP_MBA21_VREF] = { |
2120 | .type = HDA_FIXUP_FUNC, | |
2121 | .v.func = alc889_fixup_mba21_vref, | |
2122 | .chained = true, | |
2123 | .chain_id = ALC889_FIXUP_MBP_VREF, | |
2124 | }, | |
1e8968b3 TI |
2125 | [ALC889_FIXUP_MP11_VREF] = { |
2126 | .type = HDA_FIXUP_FUNC, | |
2127 | .v.func = alc889_fixup_mba11_vref, | |
2128 | .chained = true, | |
2129 | .chain_id = ALC885_FIXUP_MACPRO_GPIO, | |
2130 | }, | |
6e72aa5f | 2131 | [ALC882_FIXUP_INV_DMIC] = { |
1727a771 | 2132 | .type = HDA_FIXUP_FUNC, |
6e72aa5f TI |
2133 | .v.func = alc_fixup_inv_dmic_0x12, |
2134 | }, | |
e427c237 | 2135 | [ALC882_FIXUP_NO_PRIMARY_HP] = { |
1727a771 | 2136 | .type = HDA_FIXUP_FUNC, |
e427c237 TI |
2137 | .v.func = alc882_fixup_no_primary_hp, |
2138 | }, | |
7f9bf8ad TI |
2139 | [ALC887_FIXUP_ASUS_BASS] = { |
2140 | .type = HDA_FIXUP_PINS, | |
2141 | .v.pins = (const struct hda_pintbl[]) { | |
2142 | {0x16, 0x99130130}, /* bass speaker */ | |
2143 | {} | |
2144 | }, | |
2145 | }, | |
ff818c24 TI |
2146 | }; |
2147 | ||
1d045db9 | 2148 | static const struct snd_pci_quirk alc882_fixup_tbl[] = { |
8812c4f9 TI |
2149 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD), |
2150 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), | |
432146b1 | 2151 | SND_PCI_QUIRK(0x1025, 0x0107, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
8812c4f9 TI |
2152 | SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD), |
2153 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), | |
2154 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD), | |
2155 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD), | |
c3e837bb TI |
2156 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", |
2157 | ALC882_FIXUP_ACER_ASPIRE_4930G), | |
2158 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", | |
2159 | ALC882_FIXUP_ACER_ASPIRE_4930G), | |
2160 | SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G", | |
2161 | ALC882_FIXUP_ACER_ASPIRE_8930G), | |
2162 | SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", | |
2163 | ALC882_FIXUP_ACER_ASPIRE_8930G), | |
2164 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", | |
2165 | ALC882_FIXUP_ACER_ASPIRE_4930G), | |
2166 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", | |
2167 | ALC882_FIXUP_ACER_ASPIRE_4930G), | |
2168 | SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", | |
2169 | ALC882_FIXUP_ACER_ASPIRE_4930G), | |
5c0ebfbe | 2170 | SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210), |
f5c53d89 TI |
2171 | SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G", |
2172 | ALC882_FIXUP_ACER_ASPIRE_4930G), | |
02a237b2 | 2173 | SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE), |
fe97da1f | 2174 | SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G), |
ac9b1cdd | 2175 | SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736), |
177943a3 | 2176 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD), |
5c0ebfbe | 2177 | SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V), |
68ef0561 | 2178 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), |
0e7cc2e7 | 2179 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), |
7f9bf8ad | 2180 | SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS), |
ac9b1cdd | 2181 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), |
e427c237 | 2182 | SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP), |
12e31a78 | 2183 | SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP), |
5671087f TI |
2184 | |
2185 | /* All Apple entries are in codec SSIDs */ | |
1a97b7f2 TI |
2186 | SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF), |
2187 | SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF), | |
2188 | SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), | |
1e8968b3 | 2189 | SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF), |
5671087f TI |
2190 | SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO), |
2191 | SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO), | |
1a97b7f2 TI |
2192 | SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF), |
2193 | SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF), | |
5671087f | 2194 | SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD), |
3cf79a3c | 2195 | SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF), |
64871fb0 | 2196 | SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF), |
1a97b7f2 TI |
2197 | SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF), |
2198 | SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), | |
5671087f | 2199 | SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO), |
1a97b7f2 TI |
2200 | SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF), |
2201 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF), | |
2202 | SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF), | |
29ebe402 | 2203 | SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO), |
05193639 | 2204 | SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF), |
1a97b7f2 TI |
2205 | SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF), |
2206 | SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF), | |
c97464e3 | 2207 | SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_MBA11_VREF), |
5671087f | 2208 | |
7a6069bf | 2209 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), |
bca40138 | 2210 | SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD), |
eb844d51 | 2211 | SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), |
8f239214 | 2212 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD), |
5c0ebfbe | 2213 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX), |
7a6069bf TI |
2214 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD), |
2215 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD), | |
ac9b1cdd | 2216 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530), |
68ef0561 | 2217 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF), |
ff818c24 TI |
2218 | {} |
2219 | }; | |
2220 | ||
1727a771 | 2221 | static const struct hda_model_fixup alc882_fixup_models[] = { |
912093bc TI |
2222 | {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"}, |
2223 | {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"}, | |
2224 | {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"}, | |
6e72aa5f | 2225 | {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
e427c237 | 2226 | {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"}, |
912093bc TI |
2227 | {} |
2228 | }; | |
2229 | ||
f6a92248 | 2230 | /* |
1d045db9 | 2231 | * BIOS auto configuration |
f6a92248 | 2232 | */ |
1d045db9 TI |
2233 | /* almost identical with ALC880 parser... */ |
2234 | static int alc882_parse_auto_config(struct hda_codec *codec) | |
2235 | { | |
1d045db9 | 2236 | static const hda_nid_t alc882_ignore[] = { 0x1d, 0 }; |
3e6179b8 TI |
2237 | static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
2238 | return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids); | |
1d045db9 | 2239 | } |
b896b4eb | 2240 | |
1d045db9 TI |
2241 | /* |
2242 | */ | |
1d045db9 | 2243 | static int patch_alc882(struct hda_codec *codec) |
f6a92248 KY |
2244 | { |
2245 | struct alc_spec *spec; | |
1a97b7f2 | 2246 | int err; |
f6a92248 | 2247 | |
3de95173 TI |
2248 | err = alc_alloc_spec(codec, 0x0b); |
2249 | if (err < 0) | |
2250 | return err; | |
f6a92248 | 2251 | |
3de95173 | 2252 | spec = codec->spec; |
1f0f4b80 | 2253 | |
1d045db9 TI |
2254 | switch (codec->vendor_id) { |
2255 | case 0x10ec0882: | |
2256 | case 0x10ec0885: | |
37a86af8 | 2257 | case 0x10ec0900: |
1d045db9 TI |
2258 | break; |
2259 | default: | |
2260 | /* ALC883 and variants */ | |
2261 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); | |
2262 | break; | |
c793bec5 | 2263 | } |
977ddd6b | 2264 | |
1727a771 | 2265 | snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, |
912093bc | 2266 | alc882_fixups); |
1727a771 | 2267 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
ff818c24 | 2268 | |
1d045db9 TI |
2269 | alc_auto_parse_customize_define(codec); |
2270 | ||
7504b6cd TI |
2271 | if (has_cdefine_beep(codec)) |
2272 | spec->gen.beep_nid = 0x01; | |
2273 | ||
1a97b7f2 TI |
2274 | /* automatic parse from the BIOS config */ |
2275 | err = alc882_parse_auto_config(codec); | |
2276 | if (err < 0) | |
2277 | goto error; | |
f6a92248 | 2278 | |
7504b6cd | 2279 | if (!spec->gen.no_analog && spec->gen.beep_nid) |
1d045db9 | 2280 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
f6a92248 KY |
2281 | |
2282 | codec->patch_ops = alc_patch_ops; | |
bf1b0225 | 2283 | |
1727a771 | 2284 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
589876e2 | 2285 | |
f6a92248 | 2286 | return 0; |
e16fb6d1 TI |
2287 | |
2288 | error: | |
2289 | alc_free(codec); | |
2290 | return err; | |
f6a92248 KY |
2291 | } |
2292 | ||
df694daa | 2293 | |
df694daa | 2294 | /* |
1d045db9 | 2295 | * ALC262 support |
df694daa | 2296 | */ |
1d045db9 | 2297 | static int alc262_parse_auto_config(struct hda_codec *codec) |
df694daa | 2298 | { |
1d045db9 | 2299 | static const hda_nid_t alc262_ignore[] = { 0x1d, 0 }; |
3e6179b8 TI |
2300 | static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
2301 | return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids); | |
df694daa KY |
2302 | } |
2303 | ||
df694daa | 2304 | /* |
1d045db9 | 2305 | * Pin config fixes |
df694daa | 2306 | */ |
cfc9b06f | 2307 | enum { |
ea4e7af1 | 2308 | ALC262_FIXUP_FSC_H270, |
7513e6da | 2309 | ALC262_FIXUP_FSC_S7110, |
ea4e7af1 TI |
2310 | ALC262_FIXUP_HP_Z200, |
2311 | ALC262_FIXUP_TYAN, | |
c470150c | 2312 | ALC262_FIXUP_LENOVO_3000, |
b42590b8 TI |
2313 | ALC262_FIXUP_BENQ, |
2314 | ALC262_FIXUP_BENQ_T31, | |
6e72aa5f | 2315 | ALC262_FIXUP_INV_DMIC, |
cfc9b06f TI |
2316 | }; |
2317 | ||
1727a771 | 2318 | static const struct hda_fixup alc262_fixups[] = { |
ea4e7af1 | 2319 | [ALC262_FIXUP_FSC_H270] = { |
1727a771 TI |
2320 | .type = HDA_FIXUP_PINS, |
2321 | .v.pins = (const struct hda_pintbl[]) { | |
1d045db9 TI |
2322 | { 0x14, 0x99130110 }, /* speaker */ |
2323 | { 0x15, 0x0221142f }, /* front HP */ | |
2324 | { 0x1b, 0x0121141f }, /* rear HP */ | |
2325 | { } | |
2326 | } | |
2327 | }, | |
7513e6da TI |
2328 | [ALC262_FIXUP_FSC_S7110] = { |
2329 | .type = HDA_FIXUP_PINS, | |
2330 | .v.pins = (const struct hda_pintbl[]) { | |
2331 | { 0x15, 0x90170110 }, /* speaker */ | |
2332 | { } | |
2333 | }, | |
2334 | .chained = true, | |
2335 | .chain_id = ALC262_FIXUP_BENQ, | |
2336 | }, | |
ea4e7af1 | 2337 | [ALC262_FIXUP_HP_Z200] = { |
1727a771 TI |
2338 | .type = HDA_FIXUP_PINS, |
2339 | .v.pins = (const struct hda_pintbl[]) { | |
1d045db9 | 2340 | { 0x16, 0x99130120 }, /* internal speaker */ |
73413b12 TI |
2341 | { } |
2342 | } | |
cfc9b06f | 2343 | }, |
ea4e7af1 | 2344 | [ALC262_FIXUP_TYAN] = { |
1727a771 TI |
2345 | .type = HDA_FIXUP_PINS, |
2346 | .v.pins = (const struct hda_pintbl[]) { | |
ea4e7af1 TI |
2347 | { 0x14, 0x1993e1f0 }, /* int AUX */ |
2348 | { } | |
2349 | } | |
2350 | }, | |
c470150c | 2351 | [ALC262_FIXUP_LENOVO_3000] = { |
fd108215 TI |
2352 | .type = HDA_FIXUP_PINCTLS, |
2353 | .v.pins = (const struct hda_pintbl[]) { | |
2354 | { 0x19, PIN_VREF50 }, | |
b42590b8 TI |
2355 | {} |
2356 | }, | |
2357 | .chained = true, | |
2358 | .chain_id = ALC262_FIXUP_BENQ, | |
2359 | }, | |
2360 | [ALC262_FIXUP_BENQ] = { | |
1727a771 | 2361 | .type = HDA_FIXUP_VERBS, |
b42590b8 | 2362 | .v.verbs = (const struct hda_verb[]) { |
c470150c TI |
2363 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
2364 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, | |
2365 | {} | |
2366 | } | |
2367 | }, | |
b42590b8 | 2368 | [ALC262_FIXUP_BENQ_T31] = { |
1727a771 | 2369 | .type = HDA_FIXUP_VERBS, |
b42590b8 TI |
2370 | .v.verbs = (const struct hda_verb[]) { |
2371 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, | |
2372 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, | |
2373 | {} | |
2374 | } | |
2375 | }, | |
6e72aa5f | 2376 | [ALC262_FIXUP_INV_DMIC] = { |
1727a771 | 2377 | .type = HDA_FIXUP_FUNC, |
6e72aa5f TI |
2378 | .v.func = alc_fixup_inv_dmic_0x12, |
2379 | }, | |
cfc9b06f TI |
2380 | }; |
2381 | ||
1d045db9 | 2382 | static const struct snd_pci_quirk alc262_fixup_tbl[] = { |
ea4e7af1 | 2383 | SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200), |
7513e6da | 2384 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110), |
3dcd3be3 | 2385 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ), |
ea4e7af1 TI |
2386 | SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN), |
2387 | SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270), | |
c470150c | 2388 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000), |
b42590b8 TI |
2389 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ), |
2390 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31), | |
cfc9b06f TI |
2391 | {} |
2392 | }; | |
df694daa | 2393 | |
1727a771 | 2394 | static const struct hda_model_fixup alc262_fixup_models[] = { |
6e72aa5f TI |
2395 | {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
2396 | {} | |
2397 | }; | |
1d045db9 | 2398 | |
1d045db9 TI |
2399 | /* |
2400 | */ | |
1d045db9 | 2401 | static int patch_alc262(struct hda_codec *codec) |
df694daa KY |
2402 | { |
2403 | struct alc_spec *spec; | |
df694daa KY |
2404 | int err; |
2405 | ||
3de95173 TI |
2406 | err = alc_alloc_spec(codec, 0x0b); |
2407 | if (err < 0) | |
2408 | return err; | |
df694daa | 2409 | |
3de95173 | 2410 | spec = codec->spec; |
08c189f2 | 2411 | spec->gen.shared_mic_vref_pin = 0x18; |
1d045db9 TI |
2412 | |
2413 | #if 0 | |
2414 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is | |
2415 | * under-run | |
2416 | */ | |
2417 | { | |
2418 | int tmp; | |
2419 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
2420 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
2421 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
2422 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); | |
2423 | } | |
2424 | #endif | |
1d045db9 TI |
2425 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
2426 | ||
1727a771 | 2427 | snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl, |
6e72aa5f | 2428 | alc262_fixups); |
1727a771 | 2429 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
9c7f852e | 2430 | |
af741c15 TI |
2431 | alc_auto_parse_customize_define(codec); |
2432 | ||
7504b6cd TI |
2433 | if (has_cdefine_beep(codec)) |
2434 | spec->gen.beep_nid = 0x01; | |
2435 | ||
42399f7a TI |
2436 | /* automatic parse from the BIOS config */ |
2437 | err = alc262_parse_auto_config(codec); | |
2438 | if (err < 0) | |
2439 | goto error; | |
df694daa | 2440 | |
7504b6cd | 2441 | if (!spec->gen.no_analog && spec->gen.beep_nid) |
1d045db9 | 2442 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
2134ea4f | 2443 | |
df694daa | 2444 | codec->patch_ops = alc_patch_ops; |
1d045db9 TI |
2445 | spec->shutup = alc_eapd_shutup; |
2446 | ||
1727a771 | 2447 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
589876e2 | 2448 | |
1da177e4 | 2449 | return 0; |
e16fb6d1 TI |
2450 | |
2451 | error: | |
2452 | alc_free(codec); | |
2453 | return err; | |
1da177e4 LT |
2454 | } |
2455 | ||
f32610ed | 2456 | /* |
1d045db9 | 2457 | * ALC268 |
f32610ed | 2458 | */ |
1d045db9 TI |
2459 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
2460 | static const struct hda_bind_ctls alc268_bind_beep_sw = { | |
2461 | .ops = &snd_hda_bind_sw, | |
2462 | .values = { | |
2463 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), | |
2464 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), | |
2465 | 0 | |
2466 | }, | |
f32610ed JS |
2467 | }; |
2468 | ||
1d045db9 TI |
2469 | static const struct snd_kcontrol_new alc268_beep_mixer[] = { |
2470 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), | |
2471 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), | |
2472 | { } | |
f32610ed JS |
2473 | }; |
2474 | ||
1d045db9 TI |
2475 | /* set PCBEEP vol = 0, mute connections */ |
2476 | static const struct hda_verb alc268_beep_init_verbs[] = { | |
2477 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2478 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2479 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
2480 | { } | |
f32610ed JS |
2481 | }; |
2482 | ||
6e72aa5f TI |
2483 | enum { |
2484 | ALC268_FIXUP_INV_DMIC, | |
cb766404 | 2485 | ALC268_FIXUP_HP_EAPD, |
0009160a | 2486 | ALC268_FIXUP_SPDIF, |
6e72aa5f TI |
2487 | }; |
2488 | ||
1727a771 | 2489 | static const struct hda_fixup alc268_fixups[] = { |
6e72aa5f | 2490 | [ALC268_FIXUP_INV_DMIC] = { |
1727a771 | 2491 | .type = HDA_FIXUP_FUNC, |
6e72aa5f TI |
2492 | .v.func = alc_fixup_inv_dmic_0x12, |
2493 | }, | |
cb766404 | 2494 | [ALC268_FIXUP_HP_EAPD] = { |
1727a771 | 2495 | .type = HDA_FIXUP_VERBS, |
cb766404 TI |
2496 | .v.verbs = (const struct hda_verb[]) { |
2497 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0}, | |
2498 | {} | |
2499 | } | |
2500 | }, | |
0009160a TI |
2501 | [ALC268_FIXUP_SPDIF] = { |
2502 | .type = HDA_FIXUP_PINS, | |
2503 | .v.pins = (const struct hda_pintbl[]) { | |
2504 | { 0x1e, 0x014b1180 }, /* enable SPDIF out */ | |
2505 | {} | |
2506 | } | |
2507 | }, | |
6e72aa5f TI |
2508 | }; |
2509 | ||
1727a771 | 2510 | static const struct hda_model_fixup alc268_fixup_models[] = { |
6e72aa5f | 2511 | {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
cb766404 TI |
2512 | {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"}, |
2513 | {} | |
2514 | }; | |
2515 | ||
2516 | static const struct snd_pci_quirk alc268_fixup_tbl[] = { | |
0009160a | 2517 | SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF), |
fcd8f3b1 | 2518 | SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC), |
cb766404 TI |
2519 | /* below is codec SSID since multiple Toshiba laptops have the |
2520 | * same PCI SSID 1179:ff00 | |
2521 | */ | |
2522 | SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD), | |
6e72aa5f TI |
2523 | {} |
2524 | }; | |
2525 | ||
f32610ed JS |
2526 | /* |
2527 | * BIOS auto configuration | |
2528 | */ | |
1d045db9 | 2529 | static int alc268_parse_auto_config(struct hda_codec *codec) |
f32610ed | 2530 | { |
3e6179b8 | 2531 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
7504b6cd | 2532 | return alc_parse_auto_config(codec, NULL, alc268_ssids); |
f32610ed JS |
2533 | } |
2534 | ||
1d045db9 TI |
2535 | /* |
2536 | */ | |
1d045db9 | 2537 | static int patch_alc268(struct hda_codec *codec) |
f32610ed JS |
2538 | { |
2539 | struct alc_spec *spec; | |
7504b6cd | 2540 | int err; |
f32610ed | 2541 | |
1d045db9 | 2542 | /* ALC268 has no aa-loopback mixer */ |
3de95173 TI |
2543 | err = alc_alloc_spec(codec, 0); |
2544 | if (err < 0) | |
2545 | return err; | |
2546 | ||
2547 | spec = codec->spec; | |
7504b6cd | 2548 | spec->gen.beep_nid = 0x01; |
1f0f4b80 | 2549 | |
1727a771 TI |
2550 | snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups); |
2551 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); | |
6e72aa5f | 2552 | |
6ebb8053 TI |
2553 | /* automatic parse from the BIOS config */ |
2554 | err = alc268_parse_auto_config(codec); | |
e16fb6d1 TI |
2555 | if (err < 0) |
2556 | goto error; | |
f32610ed | 2557 | |
7504b6cd TI |
2558 | if (err > 0 && !spec->gen.no_analog && |
2559 | spec->gen.autocfg.speaker_pins[0] != 0x1d) { | |
2560 | add_mixer(spec, alc268_beep_mixer); | |
2561 | snd_hda_add_verbs(codec, alc268_beep_init_verbs); | |
1d045db9 TI |
2562 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
2563 | /* override the amp caps for beep generator */ | |
2564 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, | |
2565 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | | |
2566 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
2567 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
2568 | (0 << AC_AMPCAP_MUTE_SHIFT)); | |
2f893286 KY |
2569 | } |
2570 | ||
f32610ed | 2571 | codec->patch_ops = alc_patch_ops; |
1c716153 | 2572 | spec->shutup = alc_eapd_shutup; |
1d045db9 | 2573 | |
1727a771 | 2574 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
6e72aa5f | 2575 | |
f32610ed | 2576 | return 0; |
e16fb6d1 TI |
2577 | |
2578 | error: | |
2579 | alc_free(codec); | |
2580 | return err; | |
f32610ed JS |
2581 | } |
2582 | ||
bc9f98a9 | 2583 | /* |
1d045db9 | 2584 | * ALC269 |
bc9f98a9 | 2585 | */ |
08c189f2 TI |
2586 | |
2587 | static int playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2588 | struct hda_codec *codec, | |
2589 | struct snd_pcm_substream *substream) | |
2590 | { | |
2591 | struct hda_gen_spec *spec = codec->spec; | |
2592 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, | |
2593 | hinfo); | |
2594 | } | |
2595 | ||
2596 | static int playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |
2597 | struct hda_codec *codec, | |
2598 | unsigned int stream_tag, | |
2599 | unsigned int format, | |
2600 | struct snd_pcm_substream *substream) | |
2601 | { | |
2602 | struct hda_gen_spec *spec = codec->spec; | |
2603 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, | |
2604 | stream_tag, format, substream); | |
2605 | } | |
2606 | ||
2607 | static int playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
2608 | struct hda_codec *codec, | |
2609 | struct snd_pcm_substream *substream) | |
2610 | { | |
2611 | struct hda_gen_spec *spec = codec->spec; | |
2612 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | |
2613 | } | |
2614 | ||
1d045db9 TI |
2615 | static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = { |
2616 | .substreams = 1, | |
2617 | .channels_min = 2, | |
2618 | .channels_max = 8, | |
2619 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ | |
2620 | /* NID is set in alc_build_pcms */ | |
2621 | .ops = { | |
08c189f2 TI |
2622 | .open = playback_pcm_open, |
2623 | .prepare = playback_pcm_prepare, | |
2624 | .cleanup = playback_pcm_cleanup | |
bc9f98a9 KY |
2625 | }, |
2626 | }; | |
2627 | ||
1d045db9 TI |
2628 | static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = { |
2629 | .substreams = 1, | |
2630 | .channels_min = 2, | |
2631 | .channels_max = 2, | |
2632 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ | |
2633 | /* NID is set in alc_build_pcms */ | |
bc9f98a9 | 2634 | }; |
291702f0 | 2635 | |
1d045db9 TI |
2636 | /* different alc269-variants */ |
2637 | enum { | |
2638 | ALC269_TYPE_ALC269VA, | |
2639 | ALC269_TYPE_ALC269VB, | |
2640 | ALC269_TYPE_ALC269VC, | |
adcc70b2 | 2641 | ALC269_TYPE_ALC269VD, |
065380f0 KY |
2642 | ALC269_TYPE_ALC280, |
2643 | ALC269_TYPE_ALC282, | |
2644 | ALC269_TYPE_ALC284, | |
7fc7d047 | 2645 | ALC269_TYPE_ALC286, |
51f75120 | 2646 | ALC269_TYPE_ALC255, |
bc9f98a9 KY |
2647 | }; |
2648 | ||
2649 | /* | |
1d045db9 | 2650 | * BIOS auto configuration |
bc9f98a9 | 2651 | */ |
1d045db9 TI |
2652 | static int alc269_parse_auto_config(struct hda_codec *codec) |
2653 | { | |
1d045db9 | 2654 | static const hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
3e6179b8 TI |
2655 | static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 }; |
2656 | static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 }; | |
2657 | struct alc_spec *spec = codec->spec; | |
adcc70b2 KY |
2658 | const hda_nid_t *ssids; |
2659 | ||
2660 | switch (spec->codec_variant) { | |
2661 | case ALC269_TYPE_ALC269VA: | |
2662 | case ALC269_TYPE_ALC269VC: | |
065380f0 KY |
2663 | case ALC269_TYPE_ALC280: |
2664 | case ALC269_TYPE_ALC284: | |
adcc70b2 KY |
2665 | ssids = alc269va_ssids; |
2666 | break; | |
2667 | case ALC269_TYPE_ALC269VB: | |
2668 | case ALC269_TYPE_ALC269VD: | |
065380f0 | 2669 | case ALC269_TYPE_ALC282: |
7fc7d047 | 2670 | case ALC269_TYPE_ALC286: |
51f75120 | 2671 | case ALC269_TYPE_ALC255: |
adcc70b2 KY |
2672 | ssids = alc269_ssids; |
2673 | break; | |
2674 | default: | |
2675 | ssids = alc269_ssids; | |
2676 | break; | |
2677 | } | |
bc9f98a9 | 2678 | |
3e6179b8 | 2679 | return alc_parse_auto_config(codec, alc269_ignore, ssids); |
1d045db9 | 2680 | } |
bc9f98a9 | 2681 | |
1387e2d1 | 2682 | static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up) |
1d045db9 TI |
2683 | { |
2684 | int val = alc_read_coef_idx(codec, 0x04); | |
8666dec8 TI |
2685 | if (val == -1) |
2686 | return; | |
1d045db9 TI |
2687 | if (power_up) |
2688 | val |= 1 << 11; | |
2689 | else | |
2690 | val &= ~(1 << 11); | |
2691 | alc_write_coef_idx(codec, 0x04, val); | |
2692 | } | |
291702f0 | 2693 | |
1d045db9 TI |
2694 | static void alc269_shutup(struct hda_codec *codec) |
2695 | { | |
adcc70b2 KY |
2696 | struct alc_spec *spec = codec->spec; |
2697 | ||
2698 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) | |
2699 | return; | |
2700 | ||
1387e2d1 KY |
2701 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
2702 | alc269vb_toggle_power_output(codec, 0); | |
2703 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && | |
2704 | (alc_get_coef0(codec) & 0x00ff) == 0x018) { | |
1d045db9 TI |
2705 | msleep(150); |
2706 | } | |
2707 | } | |
291702f0 | 2708 | |
2a43952a | 2709 | #ifdef CONFIG_PM |
1d045db9 TI |
2710 | static int alc269_resume(struct hda_codec *codec) |
2711 | { | |
adcc70b2 KY |
2712 | struct alc_spec *spec = codec->spec; |
2713 | ||
1387e2d1 KY |
2714 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
2715 | alc269vb_toggle_power_output(codec, 0); | |
2716 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && | |
adcc70b2 | 2717 | (alc_get_coef0(codec) & 0x00ff) == 0x018) { |
1d045db9 TI |
2718 | msleep(150); |
2719 | } | |
8c427226 | 2720 | |
1d045db9 | 2721 | codec->patch_ops.init(codec); |
f1d4e28b | 2722 | |
1387e2d1 KY |
2723 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
2724 | alc269vb_toggle_power_output(codec, 1); | |
2725 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && | |
adcc70b2 | 2726 | (alc_get_coef0(codec) & 0x00ff) == 0x017) { |
1d045db9 TI |
2727 | msleep(200); |
2728 | } | |
f1d4e28b | 2729 | |
1d045db9 TI |
2730 | snd_hda_codec_resume_amp(codec); |
2731 | snd_hda_codec_resume_cache(codec); | |
2732 | hda_call_check_power_status(codec, 0x01); | |
2733 | return 0; | |
2734 | } | |
2a43952a | 2735 | #endif /* CONFIG_PM */ |
f1d4e28b | 2736 | |
108cc108 | 2737 | static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec, |
1727a771 | 2738 | const struct hda_fixup *fix, int action) |
108cc108 DH |
2739 | { |
2740 | struct alc_spec *spec = codec->spec; | |
2741 | ||
1727a771 | 2742 | if (action == HDA_FIXUP_ACT_PRE_PROBE) |
108cc108 DH |
2743 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
2744 | } | |
2745 | ||
1d045db9 | 2746 | static void alc269_fixup_hweq(struct hda_codec *codec, |
1727a771 | 2747 | const struct hda_fixup *fix, int action) |
1d045db9 TI |
2748 | { |
2749 | int coef; | |
f1d4e28b | 2750 | |
1727a771 | 2751 | if (action != HDA_FIXUP_ACT_INIT) |
1d045db9 TI |
2752 | return; |
2753 | coef = alc_read_coef_idx(codec, 0x1e); | |
2754 | alc_write_coef_idx(codec, 0x1e, coef | 0x80); | |
2755 | } | |
f1d4e28b | 2756 | |
1d045db9 | 2757 | static void alc271_fixup_dmic(struct hda_codec *codec, |
1727a771 | 2758 | const struct hda_fixup *fix, int action) |
1d045db9 TI |
2759 | { |
2760 | static const struct hda_verb verbs[] = { | |
2761 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, | |
2762 | {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, | |
2763 | {} | |
2764 | }; | |
2765 | unsigned int cfg; | |
f1d4e28b | 2766 | |
42397004 DR |
2767 | if (strcmp(codec->chip_name, "ALC271X") && |
2768 | strcmp(codec->chip_name, "ALC269VB")) | |
1d045db9 TI |
2769 | return; |
2770 | cfg = snd_hda_codec_get_pincfg(codec, 0x12); | |
2771 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) | |
2772 | snd_hda_sequence_write(codec, verbs); | |
2773 | } | |
f1d4e28b | 2774 | |
017f2a10 | 2775 | static void alc269_fixup_pcm_44k(struct hda_codec *codec, |
1727a771 | 2776 | const struct hda_fixup *fix, int action) |
017f2a10 TI |
2777 | { |
2778 | struct alc_spec *spec = codec->spec; | |
2779 | ||
1727a771 | 2780 | if (action != HDA_FIXUP_ACT_PROBE) |
017f2a10 TI |
2781 | return; |
2782 | ||
2783 | /* Due to a hardware problem on Lenovo Ideadpad, we need to | |
2784 | * fix the sample rate of analog I/O to 44.1kHz | |
2785 | */ | |
08c189f2 TI |
2786 | spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback; |
2787 | spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture; | |
017f2a10 TI |
2788 | } |
2789 | ||
adabb3ec | 2790 | static void alc269_fixup_stereo_dmic(struct hda_codec *codec, |
1727a771 | 2791 | const struct hda_fixup *fix, int action) |
adabb3ec TI |
2792 | { |
2793 | int coef; | |
2794 | ||
1727a771 | 2795 | if (action != HDA_FIXUP_ACT_INIT) |
adabb3ec TI |
2796 | return; |
2797 | /* The digital-mic unit sends PDM (differential signal) instead of | |
2798 | * the standard PCM, thus you can't record a valid mono stream as is. | |
2799 | * Below is a workaround specific to ALC269 to control the dmic | |
2800 | * signal source as mono. | |
2801 | */ | |
2802 | coef = alc_read_coef_idx(codec, 0x07); | |
2803 | alc_write_coef_idx(codec, 0x07, coef | 0x80); | |
2804 | } | |
2805 | ||
24519911 TI |
2806 | static void alc269_quanta_automute(struct hda_codec *codec) |
2807 | { | |
08c189f2 | 2808 | snd_hda_gen_update_outputs(codec); |
24519911 TI |
2809 | |
2810 | snd_hda_codec_write(codec, 0x20, 0, | |
2811 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
2812 | snd_hda_codec_write(codec, 0x20, 0, | |
2813 | AC_VERB_SET_PROC_COEF, 0x680); | |
2814 | ||
2815 | snd_hda_codec_write(codec, 0x20, 0, | |
2816 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
2817 | snd_hda_codec_write(codec, 0x20, 0, | |
2818 | AC_VERB_SET_PROC_COEF, 0x480); | |
2819 | } | |
2820 | ||
2821 | static void alc269_fixup_quanta_mute(struct hda_codec *codec, | |
1727a771 | 2822 | const struct hda_fixup *fix, int action) |
24519911 TI |
2823 | { |
2824 | struct alc_spec *spec = codec->spec; | |
1727a771 | 2825 | if (action != HDA_FIXUP_ACT_PROBE) |
24519911 | 2826 | return; |
08c189f2 | 2827 | spec->gen.automute_hook = alc269_quanta_automute; |
24519911 TI |
2828 | } |
2829 | ||
d240d1dc DH |
2830 | static void alc269_x101_hp_automute_hook(struct hda_codec *codec, |
2831 | struct hda_jack_tbl *jack) | |
2832 | { | |
2833 | struct alc_spec *spec = codec->spec; | |
2834 | int vref; | |
2835 | msleep(200); | |
2836 | snd_hda_gen_hp_automute(codec, jack); | |
2837 | ||
2838 | vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0; | |
2839 | msleep(100); | |
2840 | snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2841 | vref); | |
2842 | msleep(500); | |
2843 | snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
2844 | vref); | |
2845 | } | |
2846 | ||
2847 | static void alc269_fixup_x101_headset_mic(struct hda_codec *codec, | |
2848 | const struct hda_fixup *fix, int action) | |
2849 | { | |
2850 | struct alc_spec *spec = codec->spec; | |
2851 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { | |
2852 | spec->parse_flags |= HDA_PINCFG_HEADSET_MIC; | |
2853 | spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook; | |
2854 | } | |
2855 | } | |
2856 | ||
2857 | ||
08fb0d0e TI |
2858 | /* update mute-LED according to the speaker mute state via mic VREF pin */ |
2859 | static void alc269_fixup_mic_mute_hook(void *private_data, int enabled) | |
6d3cd5d4 DH |
2860 | { |
2861 | struct hda_codec *codec = private_data; | |
08fb0d0e TI |
2862 | struct alc_spec *spec = codec->spec; |
2863 | unsigned int pinval; | |
2864 | ||
2865 | if (spec->mute_led_polarity) | |
2866 | enabled = !enabled; | |
db6338e0 TI |
2867 | pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid); |
2868 | pinval &= ~AC_PINCTL_VREFEN; | |
2869 | pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80; | |
08fb0d0e TI |
2870 | if (spec->mute_led_nid) |
2871 | snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval); | |
6d3cd5d4 DH |
2872 | } |
2873 | ||
ca4c12c0 DH |
2874 | /* Make sure the led works even in runtime suspend */ |
2875 | static unsigned int led_power_filter(struct hda_codec *codec, | |
2876 | hda_nid_t nid, | |
2877 | unsigned int power_state) | |
2878 | { | |
2879 | struct alc_spec *spec = codec->spec; | |
2880 | ||
2881 | if (power_state != AC_PWRST_D3 || nid != spec->mute_led_nid) | |
2882 | return power_state; | |
2883 | ||
2884 | /* Set pin ctl again, it might have just been set to 0 */ | |
2885 | snd_hda_set_pin_ctl(codec, nid, | |
2886 | snd_hda_codec_get_pin_target(codec, nid)); | |
2887 | ||
2888 | return AC_PWRST_D0; | |
2889 | } | |
2890 | ||
08fb0d0e TI |
2891 | static void alc269_fixup_hp_mute_led(struct hda_codec *codec, |
2892 | const struct hda_fixup *fix, int action) | |
6d3cd5d4 DH |
2893 | { |
2894 | struct alc_spec *spec = codec->spec; | |
08fb0d0e TI |
2895 | const struct dmi_device *dev = NULL; |
2896 | ||
2897 | if (action != HDA_FIXUP_ACT_PRE_PROBE) | |
2898 | return; | |
2899 | ||
2900 | while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) { | |
2901 | int pol, pin; | |
2902 | if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2) | |
2903 | continue; | |
2904 | if (pin < 0x0a || pin >= 0x10) | |
2905 | break; | |
2906 | spec->mute_led_polarity = pol; | |
2907 | spec->mute_led_nid = pin - 0x0a + 0x18; | |
2908 | spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; | |
fd25a97a | 2909 | spec->gen.vmaster_mute_enum = 1; |
ca4c12c0 | 2910 | codec->power_filter = led_power_filter; |
08fb0d0e TI |
2911 | snd_printd("Detected mute LED for %x:%d\n", spec->mute_led_nid, |
2912 | spec->mute_led_polarity); | |
6d3cd5d4 DH |
2913 | break; |
2914 | } | |
2915 | } | |
2916 | ||
d06ac143 DH |
2917 | static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec, |
2918 | const struct hda_fixup *fix, int action) | |
2919 | { | |
2920 | struct alc_spec *spec = codec->spec; | |
2921 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { | |
2922 | spec->mute_led_polarity = 0; | |
2923 | spec->mute_led_nid = 0x18; | |
2924 | spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; | |
2925 | spec->gen.vmaster_mute_enum = 1; | |
ca4c12c0 | 2926 | codec->power_filter = led_power_filter; |
d06ac143 DH |
2927 | } |
2928 | } | |
2929 | ||
08fb0d0e TI |
2930 | static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec, |
2931 | const struct hda_fixup *fix, int action) | |
420b0feb TI |
2932 | { |
2933 | struct alc_spec *spec = codec->spec; | |
9bb1f06f | 2934 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
08fb0d0e TI |
2935 | spec->mute_led_polarity = 0; |
2936 | spec->mute_led_nid = 0x19; | |
2937 | spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; | |
fd25a97a | 2938 | spec->gen.vmaster_mute_enum = 1; |
ca4c12c0 | 2939 | codec->power_filter = led_power_filter; |
420b0feb TI |
2940 | } |
2941 | } | |
2942 | ||
9f5c6faf TI |
2943 | /* turn on/off mute LED per vmaster hook */ |
2944 | static void alc269_fixup_hp_gpio_mute_hook(void *private_data, int enabled) | |
2945 | { | |
2946 | struct hda_codec *codec = private_data; | |
2947 | struct alc_spec *spec = codec->spec; | |
2948 | unsigned int oldval = spec->gpio_led; | |
2949 | ||
2950 | if (enabled) | |
2951 | spec->gpio_led &= ~0x08; | |
2952 | else | |
2953 | spec->gpio_led |= 0x08; | |
2954 | if (spec->gpio_led != oldval) | |
2955 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, | |
2956 | spec->gpio_led); | |
2957 | } | |
2958 | ||
2959 | /* turn on/off mic-mute LED per capture hook */ | |
2960 | static void alc269_fixup_hp_gpio_mic_mute_hook(struct hda_codec *codec, | |
2961 | struct snd_ctl_elem_value *ucontrol) | |
2962 | { | |
2963 | struct alc_spec *spec = codec->spec; | |
2964 | unsigned int oldval = spec->gpio_led; | |
2965 | ||
2966 | if (!ucontrol) | |
2967 | return; | |
2968 | ||
2969 | if (ucontrol->value.integer.value[0] || | |
2970 | ucontrol->value.integer.value[1]) | |
2971 | spec->gpio_led &= ~0x10; | |
2972 | else | |
2973 | spec->gpio_led |= 0x10; | |
2974 | if (spec->gpio_led != oldval) | |
2975 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, | |
2976 | spec->gpio_led); | |
2977 | } | |
2978 | ||
2979 | static void alc269_fixup_hp_gpio_led(struct hda_codec *codec, | |
2980 | const struct hda_fixup *fix, int action) | |
2981 | { | |
2982 | struct alc_spec *spec = codec->spec; | |
2983 | static const struct hda_verb gpio_init[] = { | |
2984 | { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 }, | |
2985 | { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 }, | |
2986 | {} | |
2987 | }; | |
2988 | ||
2989 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { | |
2990 | spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook; | |
2991 | spec->gen.cap_sync_hook = alc269_fixup_hp_gpio_mic_mute_hook; | |
2992 | spec->gpio_led = 0; | |
2993 | snd_hda_add_verbs(codec, gpio_init); | |
2994 | } | |
2995 | } | |
2996 | ||
73bdd597 DH |
2997 | static void alc_headset_mode_unplugged(struct hda_codec *codec) |
2998 | { | |
2999 | int val; | |
3000 | ||
3001 | switch (codec->vendor_id) { | |
3002 | case 0x10ec0283: | |
3003 | alc_write_coef_idx(codec, 0x1b, 0x0c0b); | |
3004 | alc_write_coef_idx(codec, 0x45, 0xc429); | |
3005 | val = alc_read_coef_idx(codec, 0x35); | |
3006 | alc_write_coef_idx(codec, 0x35, val & 0xbfff); | |
3007 | alc_write_coef_idx(codec, 0x06, 0x2104); | |
3008 | alc_write_coef_idx(codec, 0x1a, 0x0001); | |
3009 | alc_write_coef_idx(codec, 0x26, 0x0004); | |
3010 | alc_write_coef_idx(codec, 0x32, 0x42a3); | |
3011 | break; | |
3012 | case 0x10ec0292: | |
3013 | alc_write_coef_idx(codec, 0x76, 0x000e); | |
3014 | alc_write_coef_idx(codec, 0x6c, 0x2400); | |
3015 | alc_write_coef_idx(codec, 0x18, 0x7308); | |
3016 | alc_write_coef_idx(codec, 0x6b, 0xc429); | |
3017 | break; | |
3018 | case 0x10ec0668: | |
3019 | alc_write_coef_idx(codec, 0x15, 0x0d40); | |
3020 | alc_write_coef_idx(codec, 0xb7, 0x802b); | |
3021 | break; | |
3022 | } | |
3023 | snd_printdd("Headset jack set to unplugged mode.\n"); | |
3024 | } | |
3025 | ||
3026 | ||
3027 | static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin, | |
3028 | hda_nid_t mic_pin) | |
3029 | { | |
3030 | int val; | |
3031 | ||
3032 | switch (codec->vendor_id) { | |
3033 | case 0x10ec0283: | |
3034 | alc_write_coef_idx(codec, 0x45, 0xc429); | |
3035 | snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); | |
3036 | val = alc_read_coef_idx(codec, 0x35); | |
3037 | alc_write_coef_idx(codec, 0x35, val | 1<<14); | |
3038 | alc_write_coef_idx(codec, 0x06, 0x2100); | |
3039 | alc_write_coef_idx(codec, 0x1a, 0x0021); | |
3040 | alc_write_coef_idx(codec, 0x26, 0x008c); | |
3041 | snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); | |
3042 | break; | |
3043 | case 0x10ec0292: | |
3044 | snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); | |
3045 | alc_write_coef_idx(codec, 0x19, 0xa208); | |
3046 | alc_write_coef_idx(codec, 0x2e, 0xacf0); | |
3047 | break; | |
3048 | case 0x10ec0668: | |
3049 | alc_write_coef_idx(codec, 0x11, 0x0001); | |
3050 | snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); | |
3051 | alc_write_coef_idx(codec, 0xb7, 0x802b); | |
3052 | alc_write_coef_idx(codec, 0xb5, 0x1040); | |
3053 | val = alc_read_coef_idx(codec, 0xc3); | |
3054 | alc_write_coef_idx(codec, 0xc3, val | 1<<12); | |
3055 | snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); | |
3056 | break; | |
3057 | } | |
3058 | snd_printdd("Headset jack set to mic-in mode.\n"); | |
3059 | } | |
3060 | ||
3061 | static void alc_headset_mode_default(struct hda_codec *codec) | |
3062 | { | |
3063 | switch (codec->vendor_id) { | |
3064 | case 0x10ec0283: | |
3065 | alc_write_coef_idx(codec, 0x06, 0x2100); | |
3066 | alc_write_coef_idx(codec, 0x32, 0x4ea3); | |
3067 | break; | |
3068 | case 0x10ec0292: | |
3069 | alc_write_coef_idx(codec, 0x76, 0x000e); | |
3070 | alc_write_coef_idx(codec, 0x6c, 0x2400); | |
3071 | alc_write_coef_idx(codec, 0x6b, 0xc429); | |
3072 | alc_write_coef_idx(codec, 0x18, 0x7308); | |
3073 | break; | |
3074 | case 0x10ec0668: | |
3075 | alc_write_coef_idx(codec, 0x11, 0x0041); | |
3076 | alc_write_coef_idx(codec, 0x15, 0x0d40); | |
3077 | alc_write_coef_idx(codec, 0xb7, 0x802b); | |
3078 | break; | |
3079 | } | |
3080 | snd_printdd("Headset jack set to headphone (default) mode.\n"); | |
3081 | } | |
3082 | ||
3083 | /* Iphone type */ | |
3084 | static void alc_headset_mode_ctia(struct hda_codec *codec) | |
3085 | { | |
3086 | switch (codec->vendor_id) { | |
3087 | case 0x10ec0283: | |
3088 | alc_write_coef_idx(codec, 0x45, 0xd429); | |
3089 | alc_write_coef_idx(codec, 0x1b, 0x0c2b); | |
3090 | alc_write_coef_idx(codec, 0x32, 0x4ea3); | |
3091 | break; | |
3092 | case 0x10ec0292: | |
3093 | alc_write_coef_idx(codec, 0x6b, 0xd429); | |
3094 | alc_write_coef_idx(codec, 0x76, 0x0008); | |
3095 | alc_write_coef_idx(codec, 0x18, 0x7388); | |
3096 | break; | |
3097 | case 0x10ec0668: | |
c4fcb3cd | 3098 | alc_write_coef_idx(codec, 0x11, 0x0001); |
73bdd597 DH |
3099 | alc_write_coef_idx(codec, 0x15, 0x0d60); |
3100 | alc_write_coef_idx(codec, 0xc3, 0x0000); | |
3101 | break; | |
3102 | } | |
3103 | snd_printdd("Headset jack set to iPhone-style headset mode.\n"); | |
3104 | } | |
3105 | ||
3106 | /* Nokia type */ | |
3107 | static void alc_headset_mode_omtp(struct hda_codec *codec) | |
3108 | { | |
3109 | switch (codec->vendor_id) { | |
3110 | case 0x10ec0283: | |
3111 | alc_write_coef_idx(codec, 0x45, 0xe429); | |
3112 | alc_write_coef_idx(codec, 0x1b, 0x0c2b); | |
3113 | alc_write_coef_idx(codec, 0x32, 0x4ea3); | |
3114 | break; | |
3115 | case 0x10ec0292: | |
3116 | alc_write_coef_idx(codec, 0x6b, 0xe429); | |
3117 | alc_write_coef_idx(codec, 0x76, 0x0008); | |
3118 | alc_write_coef_idx(codec, 0x18, 0x7388); | |
3119 | break; | |
3120 | case 0x10ec0668: | |
c4fcb3cd | 3121 | alc_write_coef_idx(codec, 0x11, 0x0001); |
73bdd597 DH |
3122 | alc_write_coef_idx(codec, 0x15, 0x0d50); |
3123 | alc_write_coef_idx(codec, 0xc3, 0x0000); | |
3124 | break; | |
3125 | } | |
3126 | snd_printdd("Headset jack set to Nokia-style headset mode.\n"); | |
3127 | } | |
3128 | ||
3129 | static void alc_determine_headset_type(struct hda_codec *codec) | |
3130 | { | |
3131 | int val; | |
3132 | bool is_ctia = false; | |
3133 | struct alc_spec *spec = codec->spec; | |
3134 | ||
3135 | switch (codec->vendor_id) { | |
3136 | case 0x10ec0283: | |
3137 | alc_write_coef_idx(codec, 0x45, 0xd029); | |
3138 | msleep(300); | |
3139 | val = alc_read_coef_idx(codec, 0x46); | |
3140 | is_ctia = (val & 0x0070) == 0x0070; | |
3141 | break; | |
3142 | case 0x10ec0292: | |
3143 | alc_write_coef_idx(codec, 0x6b, 0xd429); | |
3144 | msleep(300); | |
3145 | val = alc_read_coef_idx(codec, 0x6c); | |
3146 | is_ctia = (val & 0x001c) == 0x001c; | |
3147 | break; | |
3148 | case 0x10ec0668: | |
3149 | alc_write_coef_idx(codec, 0x11, 0x0001); | |
3150 | alc_write_coef_idx(codec, 0xb7, 0x802b); | |
3151 | alc_write_coef_idx(codec, 0x15, 0x0d60); | |
3152 | alc_write_coef_idx(codec, 0xc3, 0x0c00); | |
3153 | msleep(300); | |
3154 | val = alc_read_coef_idx(codec, 0xbe); | |
3155 | is_ctia = (val & 0x1c02) == 0x1c02; | |
3156 | break; | |
3157 | } | |
3158 | ||
3159 | snd_printdd("Headset jack detected iPhone-style headset: %s\n", | |
3160 | is_ctia ? "yes" : "no"); | |
3161 | spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP; | |
3162 | } | |
3163 | ||
3164 | static void alc_update_headset_mode(struct hda_codec *codec) | |
3165 | { | |
3166 | struct alc_spec *spec = codec->spec; | |
3167 | ||
3168 | hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]]; | |
3169 | hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0]; | |
3170 | ||
3171 | int new_headset_mode; | |
3172 | ||
3173 | if (!snd_hda_jack_detect(codec, hp_pin)) | |
3174 | new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED; | |
3175 | else if (mux_pin == spec->headset_mic_pin) | |
3176 | new_headset_mode = ALC_HEADSET_MODE_HEADSET; | |
3177 | else if (mux_pin == spec->headphone_mic_pin) | |
3178 | new_headset_mode = ALC_HEADSET_MODE_MIC; | |
3179 | else | |
3180 | new_headset_mode = ALC_HEADSET_MODE_HEADPHONE; | |
3181 | ||
c6ebcc4a DH |
3182 | if (new_headset_mode == spec->current_headset_mode) { |
3183 | snd_hda_gen_update_outputs(codec); | |
73bdd597 | 3184 | return; |
c6ebcc4a | 3185 | } |
73bdd597 DH |
3186 | |
3187 | switch (new_headset_mode) { | |
3188 | case ALC_HEADSET_MODE_UNPLUGGED: | |
3189 | alc_headset_mode_unplugged(codec); | |
3190 | spec->gen.hp_jack_present = false; | |
3191 | break; | |
3192 | case ALC_HEADSET_MODE_HEADSET: | |
3193 | if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN) | |
3194 | alc_determine_headset_type(codec); | |
3195 | if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA) | |
3196 | alc_headset_mode_ctia(codec); | |
3197 | else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP) | |
3198 | alc_headset_mode_omtp(codec); | |
3199 | spec->gen.hp_jack_present = true; | |
3200 | break; | |
3201 | case ALC_HEADSET_MODE_MIC: | |
3202 | alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin); | |
3203 | spec->gen.hp_jack_present = false; | |
3204 | break; | |
3205 | case ALC_HEADSET_MODE_HEADPHONE: | |
3206 | alc_headset_mode_default(codec); | |
3207 | spec->gen.hp_jack_present = true; | |
3208 | break; | |
3209 | } | |
3210 | if (new_headset_mode != ALC_HEADSET_MODE_MIC) { | |
3211 | snd_hda_set_pin_ctl_cache(codec, hp_pin, | |
3212 | AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); | |
3213 | if (spec->headphone_mic_pin) | |
3214 | snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin, | |
3215 | PIN_VREFHIZ); | |
3216 | } | |
3217 | spec->current_headset_mode = new_headset_mode; | |
3218 | ||
3219 | snd_hda_gen_update_outputs(codec); | |
3220 | } | |
3221 | ||
3222 | static void alc_update_headset_mode_hook(struct hda_codec *codec, | |
3223 | struct snd_ctl_elem_value *ucontrol) | |
3224 | { | |
3225 | alc_update_headset_mode(codec); | |
3226 | } | |
3227 | ||
3228 | static void alc_update_headset_jack_cb(struct hda_codec *codec, struct hda_jack_tbl *jack) | |
3229 | { | |
3230 | struct alc_spec *spec = codec->spec; | |
3231 | spec->current_headset_type = ALC_HEADSET_MODE_UNKNOWN; | |
3232 | snd_hda_gen_hp_automute(codec, jack); | |
3233 | } | |
3234 | ||
3235 | static void alc_probe_headset_mode(struct hda_codec *codec) | |
3236 | { | |
3237 | int i; | |
3238 | struct alc_spec *spec = codec->spec; | |
3239 | struct auto_pin_cfg *cfg = &spec->gen.autocfg; | |
3240 | ||
3241 | /* Find mic pins */ | |
3242 | for (i = 0; i < cfg->num_inputs; i++) { | |
3243 | if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin) | |
3244 | spec->headset_mic_pin = cfg->inputs[i].pin; | |
3245 | if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin) | |
3246 | spec->headphone_mic_pin = cfg->inputs[i].pin; | |
3247 | } | |
3248 | ||
3249 | spec->gen.cap_sync_hook = alc_update_headset_mode_hook; | |
3250 | spec->gen.automute_hook = alc_update_headset_mode; | |
3251 | spec->gen.hp_automute_hook = alc_update_headset_jack_cb; | |
3252 | } | |
3253 | ||
3254 | static void alc_fixup_headset_mode(struct hda_codec *codec, | |
3255 | const struct hda_fixup *fix, int action) | |
3256 | { | |
3257 | struct alc_spec *spec = codec->spec; | |
3258 | ||
3259 | switch (action) { | |
3260 | case HDA_FIXUP_ACT_PRE_PROBE: | |
3261 | spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC; | |
3262 | break; | |
3263 | case HDA_FIXUP_ACT_PROBE: | |
3264 | alc_probe_headset_mode(codec); | |
3265 | break; | |
3266 | case HDA_FIXUP_ACT_INIT: | |
3267 | spec->current_headset_mode = 0; | |
3268 | alc_update_headset_mode(codec); | |
3269 | break; | |
3270 | } | |
3271 | } | |
3272 | ||
3273 | static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec, | |
3274 | const struct hda_fixup *fix, int action) | |
3275 | { | |
3276 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { | |
3277 | struct alc_spec *spec = codec->spec; | |
3278 | spec->parse_flags |= HDA_PINCFG_HEADSET_MIC; | |
3279 | } | |
3280 | else | |
3281 | alc_fixup_headset_mode(codec, fix, action); | |
3282 | } | |
3283 | ||
3284 | static void alc_fixup_headset_mode_alc668(struct hda_codec *codec, | |
3285 | const struct hda_fixup *fix, int action) | |
3286 | { | |
3287 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { | |
3288 | int val; | |
3289 | alc_write_coef_idx(codec, 0xc4, 0x8000); | |
3290 | val = alc_read_coef_idx(codec, 0xc2); | |
3291 | alc_write_coef_idx(codec, 0xc2, val & 0xfe); | |
3292 | snd_hda_set_pin_ctl_cache(codec, 0x18, 0); | |
3293 | } | |
3294 | alc_fixup_headset_mode(codec, fix, action); | |
3295 | } | |
3296 | ||
08a978db | 3297 | static void alc271_hp_gate_mic_jack(struct hda_codec *codec, |
1727a771 | 3298 | const struct hda_fixup *fix, |
08a978db DR |
3299 | int action) |
3300 | { | |
3301 | struct alc_spec *spec = codec->spec; | |
3302 | ||
0db75790 TI |
3303 | if (action == HDA_FIXUP_ACT_PROBE) { |
3304 | if (snd_BUG_ON(!spec->gen.am_entry[1].pin || | |
3305 | !spec->gen.autocfg.hp_pins[0])) | |
3306 | return; | |
08c189f2 TI |
3307 | snd_hda_jack_set_gating_jack(codec, spec->gen.am_entry[1].pin, |
3308 | spec->gen.autocfg.hp_pins[0]); | |
0db75790 | 3309 | } |
08a978db | 3310 | } |
693b613d | 3311 | |
3e0d611b DH |
3312 | static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec, |
3313 | const struct hda_fixup *fix, | |
3314 | int action) | |
3315 | { | |
3316 | struct alc_spec *spec = codec->spec; | |
3317 | struct auto_pin_cfg *cfg = &spec->gen.autocfg; | |
3318 | int i; | |
3319 | ||
3320 | /* The mic boosts on level 2 and 3 are too noisy | |
3321 | on the internal mic input. | |
3322 | Therefore limit the boost to 0 or 1. */ | |
3323 | ||
3324 | if (action != HDA_FIXUP_ACT_PROBE) | |
3325 | return; | |
3326 | ||
3327 | for (i = 0; i < cfg->num_inputs; i++) { | |
3328 | hda_nid_t nid = cfg->inputs[i].pin; | |
3329 | unsigned int defcfg; | |
3330 | if (cfg->inputs[i].type != AUTO_PIN_MIC) | |
3331 | continue; | |
3332 | defcfg = snd_hda_codec_get_pincfg(codec, nid); | |
3333 | if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) | |
3334 | continue; | |
3335 | ||
3336 | snd_hda_override_amp_caps(codec, nid, HDA_INPUT, | |
3337 | (0x00 << AC_AMPCAP_OFFSET_SHIFT) | | |
3338 | (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
3339 | (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
3340 | (0 << AC_AMPCAP_MUTE_SHIFT)); | |
3341 | } | |
3342 | } | |
3343 | ||
92a02b07 DH |
3344 | static void alc290_fixup_mono_speakers(struct hda_codec *codec, |
3345 | const struct hda_fixup *fix, int action) | |
3346 | { | |
3347 | if (action == HDA_FIXUP_ACT_PRE_PROBE) | |
3348 | /* Remove DAC node 0x03, as it seems to be | |
3349 | giving mono output */ | |
3350 | snd_hda_override_wcaps(codec, 0x03, 0); | |
3351 | } | |
3352 | ||
1d045db9 TI |
3353 | enum { |
3354 | ALC269_FIXUP_SONY_VAIO, | |
3355 | ALC275_FIXUP_SONY_VAIO_GPIO2, | |
3356 | ALC269_FIXUP_DELL_M101Z, | |
3357 | ALC269_FIXUP_SKU_IGNORE, | |
3358 | ALC269_FIXUP_ASUS_G73JW, | |
3359 | ALC269_FIXUP_LENOVO_EAPD, | |
3360 | ALC275_FIXUP_SONY_HWEQ, | |
3361 | ALC271_FIXUP_DMIC, | |
017f2a10 | 3362 | ALC269_FIXUP_PCM_44K, |
adabb3ec | 3363 | ALC269_FIXUP_STEREO_DMIC, |
24519911 TI |
3364 | ALC269_FIXUP_QUANTA_MUTE, |
3365 | ALC269_FIXUP_LIFEBOOK, | |
9c2f4849 | 3366 | ALC269_FIXUP_LIFEBOOK_EXTMIC, |
a13a3624 | 3367 | ALC269_FIXUP_LIFEBOOK_HP_PIN, |
b56a832e | 3368 | ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT, |
a4297b5d TI |
3369 | ALC269_FIXUP_AMIC, |
3370 | ALC269_FIXUP_DMIC, | |
3371 | ALC269VB_FIXUP_AMIC, | |
3372 | ALC269VB_FIXUP_DMIC, | |
08fb0d0e | 3373 | ALC269_FIXUP_HP_MUTE_LED, |
d06ac143 | 3374 | ALC269_FIXUP_HP_MUTE_LED_MIC1, |
08fb0d0e | 3375 | ALC269_FIXUP_HP_MUTE_LED_MIC2, |
9f5c6faf | 3376 | ALC269_FIXUP_HP_GPIO_LED, |
693b613d | 3377 | ALC269_FIXUP_INV_DMIC, |
108cc108 | 3378 | ALC269_FIXUP_LENOVO_DOCK, |
09c51743 | 3379 | ALC286_FIXUP_SONY_MIC_NO_PRESENCE, |
108cc108 | 3380 | ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT, |
73bdd597 DH |
3381 | ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, |
3382 | ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, | |
92a02b07 DH |
3383 | ALC269_FIXUP_DELL3_MIC_NO_PRESENCE, |
3384 | ALC290_FIXUP_MONO_SPEAKERS, | |
73bdd597 DH |
3385 | ALC269_FIXUP_HEADSET_MODE, |
3386 | ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, | |
78349144 | 3387 | ALC269_FIXUP_ASPIRE_HEADSET_MIC, |
d240d1dc DH |
3388 | ALC269_FIXUP_ASUS_X101_FUNC, |
3389 | ALC269_FIXUP_ASUS_X101_VERB, | |
3390 | ALC269_FIXUP_ASUS_X101, | |
08a978db DR |
3391 | ALC271_FIXUP_AMIC_MIC2, |
3392 | ALC271_FIXUP_HP_GATE_MIC_JACK, | |
42397004 | 3393 | ALC269_FIXUP_ACER_AC700, |
3e0d611b | 3394 | ALC269_FIXUP_LIMIT_INT_MIC_BOOST, |
f1d4e28b KY |
3395 | }; |
3396 | ||
1727a771 | 3397 | static const struct hda_fixup alc269_fixups[] = { |
1d045db9 | 3398 | [ALC269_FIXUP_SONY_VAIO] = { |
fd108215 TI |
3399 | .type = HDA_FIXUP_PINCTLS, |
3400 | .v.pins = (const struct hda_pintbl[]) { | |
3401 | {0x19, PIN_VREFGRD}, | |
1d045db9 TI |
3402 | {} |
3403 | } | |
f1d4e28b | 3404 | }, |
1d045db9 | 3405 | [ALC275_FIXUP_SONY_VAIO_GPIO2] = { |
1727a771 | 3406 | .type = HDA_FIXUP_VERBS, |
1d045db9 TI |
3407 | .v.verbs = (const struct hda_verb[]) { |
3408 | {0x01, AC_VERB_SET_GPIO_MASK, 0x04}, | |
3409 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04}, | |
3410 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
3411 | { } | |
3412 | }, | |
3413 | .chained = true, | |
3414 | .chain_id = ALC269_FIXUP_SONY_VAIO | |
3415 | }, | |
3416 | [ALC269_FIXUP_DELL_M101Z] = { | |
1727a771 | 3417 | .type = HDA_FIXUP_VERBS, |
1d045db9 TI |
3418 | .v.verbs = (const struct hda_verb[]) { |
3419 | /* Enables internal speaker */ | |
3420 | {0x20, AC_VERB_SET_COEF_INDEX, 13}, | |
3421 | {0x20, AC_VERB_SET_PROC_COEF, 0x4040}, | |
3422 | {} | |
3423 | } | |
3424 | }, | |
3425 | [ALC269_FIXUP_SKU_IGNORE] = { | |
1727a771 | 3426 | .type = HDA_FIXUP_FUNC, |
23d30f28 | 3427 | .v.func = alc_fixup_sku_ignore, |
1d045db9 TI |
3428 | }, |
3429 | [ALC269_FIXUP_ASUS_G73JW] = { | |
1727a771 TI |
3430 | .type = HDA_FIXUP_PINS, |
3431 | .v.pins = (const struct hda_pintbl[]) { | |
1d045db9 TI |
3432 | { 0x17, 0x99130111 }, /* subwoofer */ |
3433 | { } | |
3434 | } | |
3435 | }, | |
3436 | [ALC269_FIXUP_LENOVO_EAPD] = { | |
1727a771 | 3437 | .type = HDA_FIXUP_VERBS, |
1d045db9 TI |
3438 | .v.verbs = (const struct hda_verb[]) { |
3439 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, | |
3440 | {} | |
3441 | } | |
3442 | }, | |
3443 | [ALC275_FIXUP_SONY_HWEQ] = { | |
1727a771 | 3444 | .type = HDA_FIXUP_FUNC, |
1d045db9 TI |
3445 | .v.func = alc269_fixup_hweq, |
3446 | .chained = true, | |
3447 | .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2 | |
3448 | }, | |
3449 | [ALC271_FIXUP_DMIC] = { | |
1727a771 | 3450 | .type = HDA_FIXUP_FUNC, |
1d045db9 | 3451 | .v.func = alc271_fixup_dmic, |
f1d4e28b | 3452 | }, |
017f2a10 | 3453 | [ALC269_FIXUP_PCM_44K] = { |
1727a771 | 3454 | .type = HDA_FIXUP_FUNC, |
017f2a10 | 3455 | .v.func = alc269_fixup_pcm_44k, |
012e7eb1 DH |
3456 | .chained = true, |
3457 | .chain_id = ALC269_FIXUP_QUANTA_MUTE | |
017f2a10 | 3458 | }, |
adabb3ec | 3459 | [ALC269_FIXUP_STEREO_DMIC] = { |
1727a771 | 3460 | .type = HDA_FIXUP_FUNC, |
adabb3ec TI |
3461 | .v.func = alc269_fixup_stereo_dmic, |
3462 | }, | |
24519911 | 3463 | [ALC269_FIXUP_QUANTA_MUTE] = { |
1727a771 | 3464 | .type = HDA_FIXUP_FUNC, |
24519911 TI |
3465 | .v.func = alc269_fixup_quanta_mute, |
3466 | }, | |
3467 | [ALC269_FIXUP_LIFEBOOK] = { | |
1727a771 TI |
3468 | .type = HDA_FIXUP_PINS, |
3469 | .v.pins = (const struct hda_pintbl[]) { | |
24519911 TI |
3470 | { 0x1a, 0x2101103f }, /* dock line-out */ |
3471 | { 0x1b, 0x23a11040 }, /* dock mic-in */ | |
3472 | { } | |
3473 | }, | |
3474 | .chained = true, | |
3475 | .chain_id = ALC269_FIXUP_QUANTA_MUTE | |
3476 | }, | |
9c2f4849 DH |
3477 | [ALC269_FIXUP_LIFEBOOK_EXTMIC] = { |
3478 | .type = HDA_FIXUP_PINS, | |
3479 | .v.pins = (const struct hda_pintbl[]) { | |
3480 | { 0x19, 0x01a1903c }, /* headset mic, with jack detect */ | |
3481 | { } | |
3482 | }, | |
3483 | }, | |
a13a3624 TI |
3484 | [ALC269_FIXUP_LIFEBOOK_HP_PIN] = { |
3485 | .type = HDA_FIXUP_PINS, | |
3486 | .v.pins = (const struct hda_pintbl[]) { | |
3487 | { 0x21, 0x0221102f }, /* HP out */ | |
3488 | { } | |
3489 | }, | |
3490 | }, | |
b56a832e TI |
3491 | [ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT] = { |
3492 | .type = HDA_FIXUP_FUNC, | |
3493 | .v.func = alc269_fixup_pincfg_no_hp_to_lineout, | |
3494 | }, | |
a4297b5d | 3495 | [ALC269_FIXUP_AMIC] = { |
1727a771 TI |
3496 | .type = HDA_FIXUP_PINS, |
3497 | .v.pins = (const struct hda_pintbl[]) { | |
a4297b5d TI |
3498 | { 0x14, 0x99130110 }, /* speaker */ |
3499 | { 0x15, 0x0121401f }, /* HP out */ | |
3500 | { 0x18, 0x01a19c20 }, /* mic */ | |
3501 | { 0x19, 0x99a3092f }, /* int-mic */ | |
3502 | { } | |
3503 | }, | |
3504 | }, | |
3505 | [ALC269_FIXUP_DMIC] = { | |
1727a771 TI |
3506 | .type = HDA_FIXUP_PINS, |
3507 | .v.pins = (const struct hda_pintbl[]) { | |
a4297b5d TI |
3508 | { 0x12, 0x99a3092f }, /* int-mic */ |
3509 | { 0x14, 0x99130110 }, /* speaker */ | |
3510 | { 0x15, 0x0121401f }, /* HP out */ | |
3511 | { 0x18, 0x01a19c20 }, /* mic */ | |
3512 | { } | |
3513 | }, | |
3514 | }, | |
3515 | [ALC269VB_FIXUP_AMIC] = { | |
1727a771 TI |
3516 | .type = HDA_FIXUP_PINS, |
3517 | .v.pins = (const struct hda_pintbl[]) { | |
a4297b5d TI |
3518 | { 0x14, 0x99130110 }, /* speaker */ |
3519 | { 0x18, 0x01a19c20 }, /* mic */ | |
3520 | { 0x19, 0x99a3092f }, /* int-mic */ | |
3521 | { 0x21, 0x0121401f }, /* HP out */ | |
3522 | { } | |
3523 | }, | |
3524 | }, | |
2267ea97 | 3525 | [ALC269VB_FIXUP_DMIC] = { |
1727a771 TI |
3526 | .type = HDA_FIXUP_PINS, |
3527 | .v.pins = (const struct hda_pintbl[]) { | |
a4297b5d TI |
3528 | { 0x12, 0x99a3092f }, /* int-mic */ |
3529 | { 0x14, 0x99130110 }, /* speaker */ | |
3530 | { 0x18, 0x01a19c20 }, /* mic */ | |
3531 | { 0x21, 0x0121401f }, /* HP out */ | |
3532 | { } | |
3533 | }, | |
3534 | }, | |
08fb0d0e | 3535 | [ALC269_FIXUP_HP_MUTE_LED] = { |
1727a771 | 3536 | .type = HDA_FIXUP_FUNC, |
08fb0d0e | 3537 | .v.func = alc269_fixup_hp_mute_led, |
6d3cd5d4 | 3538 | }, |
d06ac143 DH |
3539 | [ALC269_FIXUP_HP_MUTE_LED_MIC1] = { |
3540 | .type = HDA_FIXUP_FUNC, | |
3541 | .v.func = alc269_fixup_hp_mute_led_mic1, | |
3542 | }, | |
08fb0d0e | 3543 | [ALC269_FIXUP_HP_MUTE_LED_MIC2] = { |
1727a771 | 3544 | .type = HDA_FIXUP_FUNC, |
08fb0d0e | 3545 | .v.func = alc269_fixup_hp_mute_led_mic2, |
420b0feb | 3546 | }, |
9f5c6faf TI |
3547 | [ALC269_FIXUP_HP_GPIO_LED] = { |
3548 | .type = HDA_FIXUP_FUNC, | |
3549 | .v.func = alc269_fixup_hp_gpio_led, | |
3550 | }, | |
693b613d | 3551 | [ALC269_FIXUP_INV_DMIC] = { |
1727a771 | 3552 | .type = HDA_FIXUP_FUNC, |
6e72aa5f | 3553 | .v.func = alc_fixup_inv_dmic_0x12, |
693b613d | 3554 | }, |
108cc108 | 3555 | [ALC269_FIXUP_LENOVO_DOCK] = { |
1727a771 TI |
3556 | .type = HDA_FIXUP_PINS, |
3557 | .v.pins = (const struct hda_pintbl[]) { | |
108cc108 DH |
3558 | { 0x19, 0x23a11040 }, /* dock mic */ |
3559 | { 0x1b, 0x2121103f }, /* dock headphone */ | |
3560 | { } | |
3561 | }, | |
3562 | .chained = true, | |
3563 | .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT | |
3564 | }, | |
3565 | [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = { | |
1727a771 | 3566 | .type = HDA_FIXUP_FUNC, |
108cc108 DH |
3567 | .v.func = alc269_fixup_pincfg_no_hp_to_lineout, |
3568 | }, | |
73bdd597 DH |
3569 | [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = { |
3570 | .type = HDA_FIXUP_PINS, | |
3571 | .v.pins = (const struct hda_pintbl[]) { | |
3572 | { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */ | |
3573 | { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */ | |
3574 | { } | |
3575 | }, | |
3576 | .chained = true, | |
3577 | .chain_id = ALC269_FIXUP_HEADSET_MODE | |
3578 | }, | |
3579 | [ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = { | |
3580 | .type = HDA_FIXUP_PINS, | |
3581 | .v.pins = (const struct hda_pintbl[]) { | |
3582 | { 0x16, 0x21014020 }, /* dock line out */ | |
3583 | { 0x19, 0x21a19030 }, /* dock mic */ | |
3584 | { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */ | |
3585 | { } | |
3586 | }, | |
3587 | .chained = true, | |
3588 | .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC | |
3589 | }, | |
92a02b07 DH |
3590 | [ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = { |
3591 | .type = HDA_FIXUP_PINS, | |
3592 | .v.pins = (const struct hda_pintbl[]) { | |
3593 | { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */ | |
3594 | { } | |
3595 | }, | |
3596 | .chained = true, | |
3597 | .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC | |
3598 | }, | |
73bdd597 DH |
3599 | [ALC269_FIXUP_HEADSET_MODE] = { |
3600 | .type = HDA_FIXUP_FUNC, | |
3601 | .v.func = alc_fixup_headset_mode, | |
3602 | }, | |
3603 | [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = { | |
3604 | .type = HDA_FIXUP_FUNC, | |
3605 | .v.func = alc_fixup_headset_mode_no_hp_mic, | |
3606 | }, | |
78349144 TI |
3607 | [ALC269_FIXUP_ASPIRE_HEADSET_MIC] = { |
3608 | .type = HDA_FIXUP_PINS, | |
3609 | .v.pins = (const struct hda_pintbl[]) { | |
3610 | { 0x19, 0x01a1913c }, /* headset mic w/o jack detect */ | |
3611 | { } | |
3612 | }, | |
3613 | .chained = true, | |
3614 | .chain_id = ALC269_FIXUP_HEADSET_MODE, | |
3615 | }, | |
09c51743 DH |
3616 | [ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = { |
3617 | .type = HDA_FIXUP_PINS, | |
3618 | .v.pins = (const struct hda_pintbl[]) { | |
3619 | { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */ | |
3620 | { } | |
3621 | }, | |
3622 | }, | |
d240d1dc DH |
3623 | [ALC269_FIXUP_ASUS_X101_FUNC] = { |
3624 | .type = HDA_FIXUP_FUNC, | |
3625 | .v.func = alc269_fixup_x101_headset_mic, | |
3626 | }, | |
3627 | [ALC269_FIXUP_ASUS_X101_VERB] = { | |
3628 | .type = HDA_FIXUP_VERBS, | |
3629 | .v.verbs = (const struct hda_verb[]) { | |
3630 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
3631 | {0x20, AC_VERB_SET_COEF_INDEX, 0x08}, | |
3632 | {0x20, AC_VERB_SET_PROC_COEF, 0x0310}, | |
3633 | { } | |
3634 | }, | |
3635 | .chained = true, | |
3636 | .chain_id = ALC269_FIXUP_ASUS_X101_FUNC | |
3637 | }, | |
3638 | [ALC269_FIXUP_ASUS_X101] = { | |
3639 | .type = HDA_FIXUP_PINS, | |
3640 | .v.pins = (const struct hda_pintbl[]) { | |
3641 | { 0x18, 0x04a1182c }, /* Headset mic */ | |
3642 | { } | |
3643 | }, | |
3644 | .chained = true, | |
3645 | .chain_id = ALC269_FIXUP_ASUS_X101_VERB | |
3646 | }, | |
08a978db | 3647 | [ALC271_FIXUP_AMIC_MIC2] = { |
1727a771 TI |
3648 | .type = HDA_FIXUP_PINS, |
3649 | .v.pins = (const struct hda_pintbl[]) { | |
08a978db DR |
3650 | { 0x14, 0x99130110 }, /* speaker */ |
3651 | { 0x19, 0x01a19c20 }, /* mic */ | |
3652 | { 0x1b, 0x99a7012f }, /* int-mic */ | |
3653 | { 0x21, 0x0121401f }, /* HP out */ | |
3654 | { } | |
3655 | }, | |
3656 | }, | |
3657 | [ALC271_FIXUP_HP_GATE_MIC_JACK] = { | |
1727a771 | 3658 | .type = HDA_FIXUP_FUNC, |
08a978db DR |
3659 | .v.func = alc271_hp_gate_mic_jack, |
3660 | .chained = true, | |
3661 | .chain_id = ALC271_FIXUP_AMIC_MIC2, | |
3662 | }, | |
42397004 DR |
3663 | [ALC269_FIXUP_ACER_AC700] = { |
3664 | .type = HDA_FIXUP_PINS, | |
3665 | .v.pins = (const struct hda_pintbl[]) { | |
3666 | { 0x12, 0x99a3092f }, /* int-mic */ | |
3667 | { 0x14, 0x99130110 }, /* speaker */ | |
3668 | { 0x18, 0x03a11c20 }, /* mic */ | |
3669 | { 0x1e, 0x0346101e }, /* SPDIF1 */ | |
3670 | { 0x21, 0x0321101f }, /* HP out */ | |
3671 | { } | |
3672 | }, | |
3673 | .chained = true, | |
3674 | .chain_id = ALC271_FIXUP_DMIC, | |
3675 | }, | |
3e0d611b DH |
3676 | [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = { |
3677 | .type = HDA_FIXUP_FUNC, | |
3678 | .v.func = alc269_fixup_limit_int_mic_boost, | |
3679 | }, | |
92a02b07 DH |
3680 | [ALC290_FIXUP_MONO_SPEAKERS] = { |
3681 | .type = HDA_FIXUP_FUNC, | |
3682 | .v.func = alc290_fixup_mono_speakers, | |
3683 | .chained = true, | |
3684 | .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE, | |
3685 | }, | |
f1d4e28b KY |
3686 | }; |
3687 | ||
1d045db9 | 3688 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
9bfc5d3d | 3689 | SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC), |
693b613d DH |
3690 | SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC), |
3691 | SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC), | |
73bdd597 DH |
3692 | SND_PCI_QUIRK(0x1028, 0x05bd, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), |
3693 | SND_PCI_QUIRK(0x1028, 0x05be, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), | |
3694 | SND_PCI_QUIRK(0x1028, 0x05c4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
3695 | SND_PCI_QUIRK(0x1028, 0x05c5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
3696 | SND_PCI_QUIRK(0x1028, 0x05c6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
3697 | SND_PCI_QUIRK(0x1028, 0x05c7, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
3698 | SND_PCI_QUIRK(0x1028, 0x05c8, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
3699 | SND_PCI_QUIRK(0x1028, 0x05c9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
3700 | SND_PCI_QUIRK(0x1028, 0x05ca, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), | |
3701 | SND_PCI_QUIRK(0x1028, 0x05cb, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), | |
436c4a0c | 3702 | SND_PCI_QUIRK(0x1028, 0x05de, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), |
d81bf8cf | 3703 | SND_PCI_QUIRK(0x1028, 0x05e0, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), |
73bdd597 DH |
3704 | SND_PCI_QUIRK(0x1028, 0x05e9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), |
3705 | SND_PCI_QUIRK(0x1028, 0x05ea, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
3706 | SND_PCI_QUIRK(0x1028, 0x05eb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
3707 | SND_PCI_QUIRK(0x1028, 0x05ec, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
3708 | SND_PCI_QUIRK(0x1028, 0x05ed, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
3709 | SND_PCI_QUIRK(0x1028, 0x05ee, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
3710 | SND_PCI_QUIRK(0x1028, 0x05f3, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
3711 | SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
3712 | SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
3713 | SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
3ee2102f | 3714 | SND_PCI_QUIRK(0x1028, 0x05f8, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), |
6d2c6593 DH |
3715 | SND_PCI_QUIRK(0x1028, 0x05f9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), |
3716 | SND_PCI_QUIRK(0x1028, 0x05fb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
d81bf8cf DH |
3717 | SND_PCI_QUIRK(0x1028, 0x0606, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), |
3718 | SND_PCI_QUIRK(0x1028, 0x0608, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
3ee2102f | 3719 | SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), |
49a84567 | 3720 | SND_PCI_QUIRK(0x1028, 0x0613, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), |
55b13703 | 3721 | SND_PCI_QUIRK(0x1028, 0x0614, "Dell Inspiron 3135", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), |
92a02b07 | 3722 | SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_MONO_SPEAKERS), |
87a226e9 | 3723 | SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS), |
08fb0d0e | 3724 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), |
9f5c6faf | 3725 | SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED), |
d06ac143 DH |
3726 | SND_PCI_QUIRK(0x103c, 0x1973, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
3727 | SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1), | |
08fb0d0e | 3728 | SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED), |
3e0d611b DH |
3729 | SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), |
3730 | SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), | |
5ac57550 | 3731 | SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC), |
148728f1 | 3732 | SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_DMIC), |
3e0d611b | 3733 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), |
017f2a10 | 3734 | SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), |
693b613d | 3735 | SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC), |
3e0d611b | 3736 | SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), |
adabb3ec TI |
3737 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), |
3738 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), | |
3739 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), | |
3740 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), | |
d240d1dc | 3741 | SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101), |
2fff6c25 | 3742 | SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE), |
09c51743 | 3743 | SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE), |
1d045db9 TI |
3744 | SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), |
3745 | SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), | |
3746 | SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), | |
3747 | SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), | |
3748 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), | |
42397004 | 3749 | SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700), |
78349144 TI |
3750 | SND_PCI_QUIRK(0x1025, 0x072d, "Acer Aspire V5-571G", ALC269_FIXUP_ASPIRE_HEADSET_MIC), |
3751 | SND_PCI_QUIRK(0x1025, 0x080d, "Acer Aspire V5-122P", ALC269_FIXUP_ASPIRE_HEADSET_MIC), | |
ec50b4ce | 3752 | SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK), |
08a978db | 3753 | SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK), |
1d045db9 | 3754 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), |
24519911 | 3755 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), |
b56a832e | 3756 | SND_PCI_QUIRK(0x10cf, 0x159f, "Lifebook E780", ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT), |
a13a3624 | 3757 | SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN), |
28bb832e | 3758 | SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN), |
9c2f4849 | 3759 | SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC), |
1d045db9 TI |
3760 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), |
3761 | SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), | |
3762 | SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), | |
3763 | SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE), | |
3764 | SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), | |
707fba3f | 3765 | SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK), |
c8415a48 | 3766 | SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK), |
84f98fdf | 3767 | SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK), |
4407be6b | 3768 | SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK), |
6b4dc2bd | 3769 | SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK), |
108cc108 | 3770 | SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK), |
012e7eb1 | 3771 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), |
1d045db9 | 3772 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), |
a4297b5d | 3773 | |
a7f3eedc | 3774 | #if 0 |
a4297b5d TI |
3775 | /* Below is a quirk table taken from the old code. |
3776 | * Basically the device should work as is without the fixup table. | |
3777 | * If BIOS doesn't give a proper info, enable the corresponding | |
3778 | * fixup entry. | |
7d7eb9ea | 3779 | */ |
a4297b5d TI |
3780 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
3781 | ALC269_FIXUP_AMIC), | |
3782 | SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), | |
a4297b5d TI |
3783 | SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC), |
3784 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC), | |
3785 | SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC), | |
3786 | SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC), | |
3787 | SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC), | |
3788 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC), | |
3789 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC), | |
3790 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC), | |
3791 | SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC), | |
3792 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC), | |
3793 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC), | |
3794 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC), | |
3795 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC), | |
3796 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC), | |
3797 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC), | |
3798 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC), | |
3799 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC), | |
3800 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC), | |
3801 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC), | |
3802 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC), | |
3803 | SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC), | |
3804 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC), | |
3805 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC), | |
3806 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC), | |
3807 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC), | |
3808 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC), | |
3809 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC), | |
3810 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC), | |
3811 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC), | |
3812 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC), | |
3813 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC), | |
3814 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC), | |
3815 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC), | |
3816 | SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC), | |
3817 | SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC), | |
3818 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC), | |
3819 | SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC), | |
3820 | SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC), | |
3821 | #endif | |
3822 | {} | |
3823 | }; | |
3824 | ||
1727a771 | 3825 | static const struct hda_model_fixup alc269_fixup_models[] = { |
a4297b5d TI |
3826 | {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"}, |
3827 | {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"}, | |
6e72aa5f TI |
3828 | {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"}, |
3829 | {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"}, | |
3830 | {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"}, | |
108cc108 | 3831 | {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"}, |
9f5c6faf | 3832 | {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"}, |
e32aa85a DH |
3833 | {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"}, |
3834 | {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"}, | |
1d045db9 | 3835 | {} |
6dda9f4a KY |
3836 | }; |
3837 | ||
6dda9f4a | 3838 | |
546bb678 | 3839 | static void alc269_fill_coef(struct hda_codec *codec) |
1d045db9 | 3840 | { |
526af6eb | 3841 | struct alc_spec *spec = codec->spec; |
1d045db9 | 3842 | int val; |
ebb83eeb | 3843 | |
526af6eb | 3844 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
546bb678 | 3845 | return; |
526af6eb | 3846 | |
1bb7e43e | 3847 | if ((alc_get_coef0(codec) & 0x00ff) < 0x015) { |
1d045db9 TI |
3848 | alc_write_coef_idx(codec, 0xf, 0x960b); |
3849 | alc_write_coef_idx(codec, 0xe, 0x8817); | |
3850 | } | |
ebb83eeb | 3851 | |
1bb7e43e | 3852 | if ((alc_get_coef0(codec) & 0x00ff) == 0x016) { |
1d045db9 TI |
3853 | alc_write_coef_idx(codec, 0xf, 0x960b); |
3854 | alc_write_coef_idx(codec, 0xe, 0x8814); | |
3855 | } | |
ebb83eeb | 3856 | |
1bb7e43e | 3857 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
1d045db9 TI |
3858 | val = alc_read_coef_idx(codec, 0x04); |
3859 | /* Power up output pin */ | |
8666dec8 TI |
3860 | if (val != -1) |
3861 | alc_write_coef_idx(codec, 0x04, val | (1<<11)); | |
1d045db9 | 3862 | } |
ebb83eeb | 3863 | |
1bb7e43e | 3864 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
1d045db9 | 3865 | val = alc_read_coef_idx(codec, 0xd); |
8666dec8 | 3866 | if (val != -1 && (val & 0x0c00) >> 10 != 0x1) { |
1d045db9 TI |
3867 | /* Capless ramp up clock control */ |
3868 | alc_write_coef_idx(codec, 0xd, val | (1<<10)); | |
3869 | } | |
3870 | val = alc_read_coef_idx(codec, 0x17); | |
8666dec8 | 3871 | if (val != -1 && (val & 0x01c0) >> 6 != 0x4) { |
1d045db9 TI |
3872 | /* Class D power on reset */ |
3873 | alc_write_coef_idx(codec, 0x17, val | (1<<7)); | |
3874 | } | |
3875 | } | |
ebb83eeb | 3876 | |
1d045db9 | 3877 | val = alc_read_coef_idx(codec, 0xd); /* Class D */ |
8666dec8 TI |
3878 | if (val != -1) |
3879 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); | |
bc9f98a9 | 3880 | |
1d045db9 | 3881 | val = alc_read_coef_idx(codec, 0x4); /* HP */ |
8666dec8 TI |
3882 | if (val != -1) |
3883 | alc_write_coef_idx(codec, 0x4, val | (1<<11)); | |
1d045db9 | 3884 | } |
a7f2371f | 3885 | |
1d045db9 TI |
3886 | /* |
3887 | */ | |
1d045db9 TI |
3888 | static int patch_alc269(struct hda_codec *codec) |
3889 | { | |
3890 | struct alc_spec *spec; | |
3de95173 | 3891 | int err; |
f1d4e28b | 3892 | |
3de95173 | 3893 | err = alc_alloc_spec(codec, 0x0b); |
e16fb6d1 | 3894 | if (err < 0) |
3de95173 TI |
3895 | return err; |
3896 | ||
3897 | spec = codec->spec; | |
08c189f2 | 3898 | spec->gen.shared_mic_vref_pin = 0x18; |
e16fb6d1 | 3899 | |
1727a771 | 3900 | snd_hda_pick_fixup(codec, alc269_fixup_models, |
9f720bb9 | 3901 | alc269_fixup_tbl, alc269_fixups); |
1727a771 | 3902 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
9f720bb9 HRK |
3903 | |
3904 | alc_auto_parse_customize_define(codec); | |
3905 | ||
7504b6cd TI |
3906 | if (has_cdefine_beep(codec)) |
3907 | spec->gen.beep_nid = 0x01; | |
3908 | ||
065380f0 KY |
3909 | switch (codec->vendor_id) { |
3910 | case 0x10ec0269: | |
1d045db9 | 3911 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
1bb7e43e TI |
3912 | switch (alc_get_coef0(codec) & 0x00f0) { |
3913 | case 0x0010: | |
1d045db9 | 3914 | if (codec->bus->pci->subsystem_vendor == 0x1025 && |
e16fb6d1 | 3915 | spec->cdefine.platform_type == 1) |
20ca0c35 | 3916 | err = alc_codec_rename(codec, "ALC271X"); |
1d045db9 | 3917 | spec->codec_variant = ALC269_TYPE_ALC269VB; |
1bb7e43e TI |
3918 | break; |
3919 | case 0x0020: | |
e16fb6d1 TI |
3920 | if (codec->bus->pci->subsystem_vendor == 0x17aa && |
3921 | codec->bus->pci->subsystem_device == 0x21f3) | |
20ca0c35 | 3922 | err = alc_codec_rename(codec, "ALC3202"); |
1d045db9 | 3923 | spec->codec_variant = ALC269_TYPE_ALC269VC; |
1bb7e43e | 3924 | break; |
adcc70b2 KY |
3925 | case 0x0030: |
3926 | spec->codec_variant = ALC269_TYPE_ALC269VD; | |
3927 | break; | |
1bb7e43e | 3928 | default: |
1d045db9 | 3929 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
1bb7e43e | 3930 | } |
e16fb6d1 TI |
3931 | if (err < 0) |
3932 | goto error; | |
546bb678 | 3933 | spec->init_hook = alc269_fill_coef; |
1d045db9 | 3934 | alc269_fill_coef(codec); |
065380f0 KY |
3935 | break; |
3936 | ||
3937 | case 0x10ec0280: | |
3938 | case 0x10ec0290: | |
3939 | spec->codec_variant = ALC269_TYPE_ALC280; | |
3940 | break; | |
84dfd0ac | 3941 | case 0x10ec0233: |
065380f0 KY |
3942 | case 0x10ec0282: |
3943 | case 0x10ec0283: | |
3944 | spec->codec_variant = ALC269_TYPE_ALC282; | |
3945 | break; | |
3946 | case 0x10ec0284: | |
3947 | case 0x10ec0292: | |
3948 | spec->codec_variant = ALC269_TYPE_ALC284; | |
3949 | break; | |
7fc7d047 | 3950 | case 0x10ec0286: |
fa8575dd | 3951 | case 0x10ec0288: |
7fc7d047 KY |
3952 | spec->codec_variant = ALC269_TYPE_ALC286; |
3953 | break; | |
51f75120 KY |
3954 | case 0x10ec0255: |
3955 | spec->codec_variant = ALC269_TYPE_ALC255; | |
3956 | break; | |
1d045db9 | 3957 | } |
6dda9f4a | 3958 | |
a4297b5d TI |
3959 | /* automatic parse from the BIOS config */ |
3960 | err = alc269_parse_auto_config(codec); | |
e16fb6d1 TI |
3961 | if (err < 0) |
3962 | goto error; | |
6dda9f4a | 3963 | |
7504b6cd | 3964 | if (!spec->gen.no_analog && spec->gen.beep_nid) |
1d045db9 | 3965 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
f1d4e28b | 3966 | |
1d045db9 | 3967 | codec->patch_ops = alc_patch_ops; |
2a43952a | 3968 | #ifdef CONFIG_PM |
1d045db9 TI |
3969 | codec->patch_ops.resume = alc269_resume; |
3970 | #endif | |
1d045db9 | 3971 | spec->shutup = alc269_shutup; |
ebb83eeb | 3972 | |
1727a771 | 3973 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
589876e2 | 3974 | |
1d045db9 | 3975 | return 0; |
e16fb6d1 TI |
3976 | |
3977 | error: | |
3978 | alc_free(codec); | |
3979 | return err; | |
1d045db9 | 3980 | } |
f1d4e28b | 3981 | |
1d045db9 TI |
3982 | /* |
3983 | * ALC861 | |
3984 | */ | |
622e84cd | 3985 | |
1d045db9 | 3986 | static int alc861_parse_auto_config(struct hda_codec *codec) |
6dda9f4a | 3987 | { |
1d045db9 | 3988 | static const hda_nid_t alc861_ignore[] = { 0x1d, 0 }; |
3e6179b8 TI |
3989 | static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 }; |
3990 | return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids); | |
604401a9 TI |
3991 | } |
3992 | ||
1d045db9 TI |
3993 | /* Pin config fixes */ |
3994 | enum { | |
e652f4c8 TI |
3995 | ALC861_FIXUP_FSC_AMILO_PI1505, |
3996 | ALC861_FIXUP_AMP_VREF_0F, | |
3997 | ALC861_FIXUP_NO_JACK_DETECT, | |
3998 | ALC861_FIXUP_ASUS_A6RP, | |
daba7617 | 3999 | ALC660_FIXUP_ASUS_W7J, |
1d045db9 | 4000 | }; |
7085ec12 | 4001 | |
31150f23 TI |
4002 | /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */ |
4003 | static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec, | |
1727a771 | 4004 | const struct hda_fixup *fix, int action) |
31150f23 TI |
4005 | { |
4006 | struct alc_spec *spec = codec->spec; | |
4007 | unsigned int val; | |
4008 | ||
1727a771 | 4009 | if (action != HDA_FIXUP_ACT_INIT) |
31150f23 | 4010 | return; |
d3f02d60 | 4011 | val = snd_hda_codec_get_pin_target(codec, 0x0f); |
31150f23 TI |
4012 | if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) |
4013 | val |= AC_PINCTL_IN_EN; | |
4014 | val |= AC_PINCTL_VREF_50; | |
cdd03ced | 4015 | snd_hda_set_pin_ctl(codec, 0x0f, val); |
08c189f2 | 4016 | spec->gen.keep_vref_in_automute = 1; |
31150f23 TI |
4017 | } |
4018 | ||
e652f4c8 TI |
4019 | /* suppress the jack-detection */ |
4020 | static void alc_fixup_no_jack_detect(struct hda_codec *codec, | |
1727a771 | 4021 | const struct hda_fixup *fix, int action) |
e652f4c8 | 4022 | { |
1727a771 | 4023 | if (action == HDA_FIXUP_ACT_PRE_PROBE) |
e652f4c8 | 4024 | codec->no_jack_detect = 1; |
7d7eb9ea | 4025 | } |
e652f4c8 | 4026 | |
1727a771 | 4027 | static const struct hda_fixup alc861_fixups[] = { |
e652f4c8 | 4028 | [ALC861_FIXUP_FSC_AMILO_PI1505] = { |
1727a771 TI |
4029 | .type = HDA_FIXUP_PINS, |
4030 | .v.pins = (const struct hda_pintbl[]) { | |
1d045db9 TI |
4031 | { 0x0b, 0x0221101f }, /* HP */ |
4032 | { 0x0f, 0x90170310 }, /* speaker */ | |
4033 | { } | |
4034 | } | |
4035 | }, | |
e652f4c8 | 4036 | [ALC861_FIXUP_AMP_VREF_0F] = { |
1727a771 | 4037 | .type = HDA_FIXUP_FUNC, |
31150f23 | 4038 | .v.func = alc861_fixup_asus_amp_vref_0f, |
3b25eb69 | 4039 | }, |
e652f4c8 | 4040 | [ALC861_FIXUP_NO_JACK_DETECT] = { |
1727a771 | 4041 | .type = HDA_FIXUP_FUNC, |
e652f4c8 TI |
4042 | .v.func = alc_fixup_no_jack_detect, |
4043 | }, | |
4044 | [ALC861_FIXUP_ASUS_A6RP] = { | |
1727a771 | 4045 | .type = HDA_FIXUP_FUNC, |
e652f4c8 TI |
4046 | .v.func = alc861_fixup_asus_amp_vref_0f, |
4047 | .chained = true, | |
4048 | .chain_id = ALC861_FIXUP_NO_JACK_DETECT, | |
daba7617 TI |
4049 | }, |
4050 | [ALC660_FIXUP_ASUS_W7J] = { | |
4051 | .type = HDA_FIXUP_VERBS, | |
4052 | .v.verbs = (const struct hda_verb[]) { | |
4053 | /* ASUS W7J needs a magic pin setup on unused NID 0x10 | |
4054 | * for enabling outputs | |
4055 | */ | |
4056 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4057 | { } | |
4058 | }, | |
e652f4c8 | 4059 | } |
1d045db9 | 4060 | }; |
7085ec12 | 4061 | |
1d045db9 | 4062 | static const struct snd_pci_quirk alc861_fixup_tbl[] = { |
daba7617 | 4063 | SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J), |
e0979ec7 | 4064 | SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J), |
e652f4c8 TI |
4065 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP), |
4066 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F), | |
4067 | SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT), | |
4068 | SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F), | |
4069 | SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F), | |
4070 | SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505), | |
1d045db9 TI |
4071 | {} |
4072 | }; | |
3af9ee6b | 4073 | |
1d045db9 TI |
4074 | /* |
4075 | */ | |
1d045db9 | 4076 | static int patch_alc861(struct hda_codec *codec) |
7085ec12 | 4077 | { |
1d045db9 | 4078 | struct alc_spec *spec; |
1d045db9 | 4079 | int err; |
7085ec12 | 4080 | |
3de95173 TI |
4081 | err = alc_alloc_spec(codec, 0x15); |
4082 | if (err < 0) | |
4083 | return err; | |
1d045db9 | 4084 | |
3de95173 | 4085 | spec = codec->spec; |
7504b6cd | 4086 | spec->gen.beep_nid = 0x23; |
1d045db9 | 4087 | |
1727a771 TI |
4088 | snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); |
4089 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); | |
3af9ee6b | 4090 | |
cb4e4824 TI |
4091 | /* automatic parse from the BIOS config */ |
4092 | err = alc861_parse_auto_config(codec); | |
e16fb6d1 TI |
4093 | if (err < 0) |
4094 | goto error; | |
3af9ee6b | 4095 | |
7504b6cd | 4096 | if (!spec->gen.no_analog) |
3e6179b8 | 4097 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
7085ec12 | 4098 | |
1d045db9 | 4099 | codec->patch_ops = alc_patch_ops; |
83012a7c | 4100 | #ifdef CONFIG_PM |
cb4e4824 | 4101 | spec->power_hook = alc_power_eapd; |
1d045db9 TI |
4102 | #endif |
4103 | ||
1727a771 | 4104 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
589876e2 | 4105 | |
1d045db9 | 4106 | return 0; |
e16fb6d1 TI |
4107 | |
4108 | error: | |
4109 | alc_free(codec); | |
4110 | return err; | |
7085ec12 TI |
4111 | } |
4112 | ||
1d045db9 TI |
4113 | /* |
4114 | * ALC861-VD support | |
4115 | * | |
4116 | * Based on ALC882 | |
4117 | * | |
4118 | * In addition, an independent DAC | |
4119 | */ | |
1d045db9 | 4120 | static int alc861vd_parse_auto_config(struct hda_codec *codec) |
bc9f98a9 | 4121 | { |
1d045db9 | 4122 | static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; |
3e6179b8 TI |
4123 | static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
4124 | return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids); | |
ce764ab2 TI |
4125 | } |
4126 | ||
1d045db9 | 4127 | enum { |
8fdcb6fe TI |
4128 | ALC660VD_FIX_ASUS_GPIO1, |
4129 | ALC861VD_FIX_DALLAS, | |
1d045db9 | 4130 | }; |
ce764ab2 | 4131 | |
8fdcb6fe TI |
4132 | /* exclude VREF80 */ |
4133 | static void alc861vd_fixup_dallas(struct hda_codec *codec, | |
1727a771 | 4134 | const struct hda_fixup *fix, int action) |
8fdcb6fe | 4135 | { |
1727a771 | 4136 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
b78562b1 TI |
4137 | snd_hda_override_pin_caps(codec, 0x18, 0x00000734); |
4138 | snd_hda_override_pin_caps(codec, 0x19, 0x0000073c); | |
8fdcb6fe TI |
4139 | } |
4140 | } | |
4141 | ||
1727a771 | 4142 | static const struct hda_fixup alc861vd_fixups[] = { |
1d045db9 | 4143 | [ALC660VD_FIX_ASUS_GPIO1] = { |
1727a771 | 4144 | .type = HDA_FIXUP_VERBS, |
1d045db9 | 4145 | .v.verbs = (const struct hda_verb[]) { |
8fdcb6fe | 4146 | /* reset GPIO1 */ |
1d045db9 TI |
4147 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
4148 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
4149 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
4150 | { } | |
4151 | } | |
4152 | }, | |
8fdcb6fe | 4153 | [ALC861VD_FIX_DALLAS] = { |
1727a771 | 4154 | .type = HDA_FIXUP_FUNC, |
8fdcb6fe TI |
4155 | .v.func = alc861vd_fixup_dallas, |
4156 | }, | |
1d045db9 | 4157 | }; |
ce764ab2 | 4158 | |
1d045db9 | 4159 | static const struct snd_pci_quirk alc861vd_fixup_tbl[] = { |
8fdcb6fe | 4160 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS), |
1d045db9 | 4161 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1), |
8fdcb6fe | 4162 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS), |
1d045db9 TI |
4163 | {} |
4164 | }; | |
ce764ab2 | 4165 | |
1d045db9 TI |
4166 | /* |
4167 | */ | |
1d045db9 | 4168 | static int patch_alc861vd(struct hda_codec *codec) |
ce764ab2 | 4169 | { |
1d045db9 | 4170 | struct alc_spec *spec; |
cb4e4824 | 4171 | int err; |
ce764ab2 | 4172 | |
3de95173 TI |
4173 | err = alc_alloc_spec(codec, 0x0b); |
4174 | if (err < 0) | |
4175 | return err; | |
1d045db9 | 4176 | |
3de95173 | 4177 | spec = codec->spec; |
7504b6cd | 4178 | spec->gen.beep_nid = 0x23; |
1d045db9 | 4179 | |
1727a771 TI |
4180 | snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); |
4181 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); | |
1d045db9 | 4182 | |
cb4e4824 TI |
4183 | /* automatic parse from the BIOS config */ |
4184 | err = alc861vd_parse_auto_config(codec); | |
e16fb6d1 TI |
4185 | if (err < 0) |
4186 | goto error; | |
ce764ab2 | 4187 | |
7504b6cd | 4188 | if (!spec->gen.no_analog) |
3e6179b8 | 4189 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
1d045db9 | 4190 | |
1d045db9 TI |
4191 | codec->patch_ops = alc_patch_ops; |
4192 | ||
1d045db9 | 4193 | spec->shutup = alc_eapd_shutup; |
1d045db9 | 4194 | |
1727a771 | 4195 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
589876e2 | 4196 | |
ce764ab2 | 4197 | return 0; |
e16fb6d1 TI |
4198 | |
4199 | error: | |
4200 | alc_free(codec); | |
4201 | return err; | |
ce764ab2 TI |
4202 | } |
4203 | ||
1d045db9 TI |
4204 | /* |
4205 | * ALC662 support | |
4206 | * | |
4207 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible | |
4208 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
4209 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
4210 | * 6-channel independent captures. | |
4211 | * | |
4212 | * In addition, an independent DAC for the multi-playback (not used in this | |
4213 | * driver yet). | |
4214 | */ | |
1d045db9 TI |
4215 | |
4216 | /* | |
4217 | * BIOS auto configuration | |
4218 | */ | |
4219 | ||
bc9f98a9 KY |
4220 | static int alc662_parse_auto_config(struct hda_codec *codec) |
4221 | { | |
4c6d72d1 | 4222 | static const hda_nid_t alc662_ignore[] = { 0x1d, 0 }; |
3e6179b8 TI |
4223 | static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 }; |
4224 | static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; | |
4225 | const hda_nid_t *ssids; | |
ee979a14 | 4226 | |
6227cdce | 4227 | if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || |
1d87caa6 RK |
4228 | codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670 || |
4229 | codec->vendor_id == 0x10ec0671) | |
3e6179b8 | 4230 | ssids = alc663_ssids; |
6227cdce | 4231 | else |
3e6179b8 TI |
4232 | ssids = alc662_ssids; |
4233 | return alc_parse_auto_config(codec, alc662_ignore, ssids); | |
bc9f98a9 KY |
4234 | } |
4235 | ||
6be7948f | 4236 | static void alc272_fixup_mario(struct hda_codec *codec, |
1727a771 | 4237 | const struct hda_fixup *fix, int action) |
6fc398cb | 4238 | { |
9bb1f06f | 4239 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
6fc398cb | 4240 | return; |
6be7948f TB |
4241 | if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT, |
4242 | (0x3b << AC_AMPCAP_OFFSET_SHIFT) | | |
4243 | (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
4244 | (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
4245 | (0 << AC_AMPCAP_MUTE_SHIFT))) | |
4246 | printk(KERN_WARNING | |
4247 | "hda_codec: failed to override amp caps for NID 0x2\n"); | |
4248 | } | |
4249 | ||
6cb3b707 | 4250 | enum { |
2df03514 | 4251 | ALC662_FIXUP_ASPIRE, |
6cb3b707 | 4252 | ALC662_FIXUP_IDEAPAD, |
6be7948f | 4253 | ALC272_FIXUP_MARIO, |
d2ebd479 | 4254 | ALC662_FIXUP_CZC_P10T, |
94024cd1 | 4255 | ALC662_FIXUP_SKU_IGNORE, |
e59ea3ed | 4256 | ALC662_FIXUP_HP_RP5800, |
53c334ad TI |
4257 | ALC662_FIXUP_ASUS_MODE1, |
4258 | ALC662_FIXUP_ASUS_MODE2, | |
4259 | ALC662_FIXUP_ASUS_MODE3, | |
4260 | ALC662_FIXUP_ASUS_MODE4, | |
4261 | ALC662_FIXUP_ASUS_MODE5, | |
4262 | ALC662_FIXUP_ASUS_MODE6, | |
4263 | ALC662_FIXUP_ASUS_MODE7, | |
4264 | ALC662_FIXUP_ASUS_MODE8, | |
1565cc35 | 4265 | ALC662_FIXUP_NO_JACK_DETECT, |
edfe3bfc | 4266 | ALC662_FIXUP_ZOTAC_Z68, |
125821ae | 4267 | ALC662_FIXUP_INV_DMIC, |
73bdd597 DH |
4268 | ALC668_FIXUP_DELL_MIC_NO_PRESENCE, |
4269 | ALC668_FIXUP_HEADSET_MODE, | |
6cb3b707 DH |
4270 | }; |
4271 | ||
1727a771 | 4272 | static const struct hda_fixup alc662_fixups[] = { |
2df03514 | 4273 | [ALC662_FIXUP_ASPIRE] = { |
1727a771 TI |
4274 | .type = HDA_FIXUP_PINS, |
4275 | .v.pins = (const struct hda_pintbl[]) { | |
2df03514 DC |
4276 | { 0x15, 0x99130112 }, /* subwoofer */ |
4277 | { } | |
4278 | } | |
4279 | }, | |
6cb3b707 | 4280 | [ALC662_FIXUP_IDEAPAD] = { |
1727a771 TI |
4281 | .type = HDA_FIXUP_PINS, |
4282 | .v.pins = (const struct hda_pintbl[]) { | |
6cb3b707 DH |
4283 | { 0x17, 0x99130112 }, /* subwoofer */ |
4284 | { } | |
4285 | } | |
4286 | }, | |
6be7948f | 4287 | [ALC272_FIXUP_MARIO] = { |
1727a771 | 4288 | .type = HDA_FIXUP_FUNC, |
b5bfbc67 | 4289 | .v.func = alc272_fixup_mario, |
d2ebd479 AA |
4290 | }, |
4291 | [ALC662_FIXUP_CZC_P10T] = { | |
1727a771 | 4292 | .type = HDA_FIXUP_VERBS, |
d2ebd479 AA |
4293 | .v.verbs = (const struct hda_verb[]) { |
4294 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, | |
4295 | {} | |
4296 | } | |
4297 | }, | |
94024cd1 | 4298 | [ALC662_FIXUP_SKU_IGNORE] = { |
1727a771 | 4299 | .type = HDA_FIXUP_FUNC, |
23d30f28 | 4300 | .v.func = alc_fixup_sku_ignore, |
c6b35874 | 4301 | }, |
e59ea3ed | 4302 | [ALC662_FIXUP_HP_RP5800] = { |
1727a771 TI |
4303 | .type = HDA_FIXUP_PINS, |
4304 | .v.pins = (const struct hda_pintbl[]) { | |
e59ea3ed TI |
4305 | { 0x14, 0x0221201f }, /* HP out */ |
4306 | { } | |
4307 | }, | |
4308 | .chained = true, | |
4309 | .chain_id = ALC662_FIXUP_SKU_IGNORE | |
4310 | }, | |
53c334ad | 4311 | [ALC662_FIXUP_ASUS_MODE1] = { |
1727a771 TI |
4312 | .type = HDA_FIXUP_PINS, |
4313 | .v.pins = (const struct hda_pintbl[]) { | |
53c334ad TI |
4314 | { 0x14, 0x99130110 }, /* speaker */ |
4315 | { 0x18, 0x01a19c20 }, /* mic */ | |
4316 | { 0x19, 0x99a3092f }, /* int-mic */ | |
4317 | { 0x21, 0x0121401f }, /* HP out */ | |
4318 | { } | |
4319 | }, | |
4320 | .chained = true, | |
4321 | .chain_id = ALC662_FIXUP_SKU_IGNORE | |
4322 | }, | |
4323 | [ALC662_FIXUP_ASUS_MODE2] = { | |
1727a771 TI |
4324 | .type = HDA_FIXUP_PINS, |
4325 | .v.pins = (const struct hda_pintbl[]) { | |
2996bdba TI |
4326 | { 0x14, 0x99130110 }, /* speaker */ |
4327 | { 0x18, 0x01a19820 }, /* mic */ | |
4328 | { 0x19, 0x99a3092f }, /* int-mic */ | |
4329 | { 0x1b, 0x0121401f }, /* HP out */ | |
4330 | { } | |
4331 | }, | |
53c334ad TI |
4332 | .chained = true, |
4333 | .chain_id = ALC662_FIXUP_SKU_IGNORE | |
4334 | }, | |
4335 | [ALC662_FIXUP_ASUS_MODE3] = { | |
1727a771 TI |
4336 | .type = HDA_FIXUP_PINS, |
4337 | .v.pins = (const struct hda_pintbl[]) { | |
53c334ad TI |
4338 | { 0x14, 0x99130110 }, /* speaker */ |
4339 | { 0x15, 0x0121441f }, /* HP */ | |
4340 | { 0x18, 0x01a19840 }, /* mic */ | |
4341 | { 0x19, 0x99a3094f }, /* int-mic */ | |
4342 | { 0x21, 0x01211420 }, /* HP2 */ | |
4343 | { } | |
4344 | }, | |
4345 | .chained = true, | |
4346 | .chain_id = ALC662_FIXUP_SKU_IGNORE | |
4347 | }, | |
4348 | [ALC662_FIXUP_ASUS_MODE4] = { | |
1727a771 TI |
4349 | .type = HDA_FIXUP_PINS, |
4350 | .v.pins = (const struct hda_pintbl[]) { | |
53c334ad TI |
4351 | { 0x14, 0x99130110 }, /* speaker */ |
4352 | { 0x16, 0x99130111 }, /* speaker */ | |
4353 | { 0x18, 0x01a19840 }, /* mic */ | |
4354 | { 0x19, 0x99a3094f }, /* int-mic */ | |
4355 | { 0x21, 0x0121441f }, /* HP */ | |
4356 | { } | |
4357 | }, | |
4358 | .chained = true, | |
4359 | .chain_id = ALC662_FIXUP_SKU_IGNORE | |
4360 | }, | |
4361 | [ALC662_FIXUP_ASUS_MODE5] = { | |
1727a771 TI |
4362 | .type = HDA_FIXUP_PINS, |
4363 | .v.pins = (const struct hda_pintbl[]) { | |
53c334ad TI |
4364 | { 0x14, 0x99130110 }, /* speaker */ |
4365 | { 0x15, 0x0121441f }, /* HP */ | |
4366 | { 0x16, 0x99130111 }, /* speaker */ | |
4367 | { 0x18, 0x01a19840 }, /* mic */ | |
4368 | { 0x19, 0x99a3094f }, /* int-mic */ | |
4369 | { } | |
4370 | }, | |
4371 | .chained = true, | |
4372 | .chain_id = ALC662_FIXUP_SKU_IGNORE | |
4373 | }, | |
4374 | [ALC662_FIXUP_ASUS_MODE6] = { | |
1727a771 TI |
4375 | .type = HDA_FIXUP_PINS, |
4376 | .v.pins = (const struct hda_pintbl[]) { | |
53c334ad TI |
4377 | { 0x14, 0x99130110 }, /* speaker */ |
4378 | { 0x15, 0x01211420 }, /* HP2 */ | |
4379 | { 0x18, 0x01a19840 }, /* mic */ | |
4380 | { 0x19, 0x99a3094f }, /* int-mic */ | |
4381 | { 0x1b, 0x0121441f }, /* HP */ | |
4382 | { } | |
4383 | }, | |
4384 | .chained = true, | |
4385 | .chain_id = ALC662_FIXUP_SKU_IGNORE | |
4386 | }, | |
4387 | [ALC662_FIXUP_ASUS_MODE7] = { | |
1727a771 TI |
4388 | .type = HDA_FIXUP_PINS, |
4389 | .v.pins = (const struct hda_pintbl[]) { | |
53c334ad TI |
4390 | { 0x14, 0x99130110 }, /* speaker */ |
4391 | { 0x17, 0x99130111 }, /* speaker */ | |
4392 | { 0x18, 0x01a19840 }, /* mic */ | |
4393 | { 0x19, 0x99a3094f }, /* int-mic */ | |
4394 | { 0x1b, 0x01214020 }, /* HP */ | |
4395 | { 0x21, 0x0121401f }, /* HP */ | |
4396 | { } | |
4397 | }, | |
4398 | .chained = true, | |
4399 | .chain_id = ALC662_FIXUP_SKU_IGNORE | |
4400 | }, | |
4401 | [ALC662_FIXUP_ASUS_MODE8] = { | |
1727a771 TI |
4402 | .type = HDA_FIXUP_PINS, |
4403 | .v.pins = (const struct hda_pintbl[]) { | |
53c334ad TI |
4404 | { 0x14, 0x99130110 }, /* speaker */ |
4405 | { 0x12, 0x99a30970 }, /* int-mic */ | |
4406 | { 0x15, 0x01214020 }, /* HP */ | |
4407 | { 0x17, 0x99130111 }, /* speaker */ | |
4408 | { 0x18, 0x01a19840 }, /* mic */ | |
4409 | { 0x21, 0x0121401f }, /* HP */ | |
4410 | { } | |
4411 | }, | |
4412 | .chained = true, | |
4413 | .chain_id = ALC662_FIXUP_SKU_IGNORE | |
2996bdba | 4414 | }, |
1565cc35 | 4415 | [ALC662_FIXUP_NO_JACK_DETECT] = { |
1727a771 | 4416 | .type = HDA_FIXUP_FUNC, |
1565cc35 TI |
4417 | .v.func = alc_fixup_no_jack_detect, |
4418 | }, | |
edfe3bfc | 4419 | [ALC662_FIXUP_ZOTAC_Z68] = { |
1727a771 TI |
4420 | .type = HDA_FIXUP_PINS, |
4421 | .v.pins = (const struct hda_pintbl[]) { | |
edfe3bfc DH |
4422 | { 0x1b, 0x02214020 }, /* Front HP */ |
4423 | { } | |
4424 | } | |
4425 | }, | |
125821ae | 4426 | [ALC662_FIXUP_INV_DMIC] = { |
1727a771 | 4427 | .type = HDA_FIXUP_FUNC, |
6e72aa5f | 4428 | .v.func = alc_fixup_inv_dmic_0x12, |
125821ae | 4429 | }, |
73bdd597 DH |
4430 | [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = { |
4431 | .type = HDA_FIXUP_PINS, | |
4432 | .v.pins = (const struct hda_pintbl[]) { | |
4433 | { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */ | |
4434 | { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */ | |
4435 | { } | |
4436 | }, | |
4437 | .chained = true, | |
4438 | .chain_id = ALC668_FIXUP_HEADSET_MODE | |
4439 | }, | |
4440 | [ALC668_FIXUP_HEADSET_MODE] = { | |
4441 | .type = HDA_FIXUP_FUNC, | |
4442 | .v.func = alc_fixup_headset_mode_alc668, | |
4443 | }, | |
6cb3b707 DH |
4444 | }; |
4445 | ||
a9111321 | 4446 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { |
53c334ad | 4447 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2), |
35133cc3 | 4448 | SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC), |
a6c47a85 | 4449 | SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), |
94024cd1 | 4450 | SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), |
125821ae | 4451 | SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC), |
fa392433 | 4452 | SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC), |
2df03514 | 4453 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), |
73bdd597 DH |
4454 | SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), |
4455 | SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), | |
e59ea3ed | 4456 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), |
74a8f08d | 4457 | SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_ASUS_MODE4), |
f08830db | 4458 | SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_ASUS_MODE4), |
1565cc35 | 4459 | SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), |
53c334ad | 4460 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), |
a0e90acc | 4461 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), |
d4118588 | 4462 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), |
6cb3b707 | 4463 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), |
edfe3bfc | 4464 | SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68), |
d2ebd479 | 4465 | SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), |
53c334ad TI |
4466 | |
4467 | #if 0 | |
4468 | /* Below is a quirk table taken from the old code. | |
4469 | * Basically the device should work as is without the fixup table. | |
4470 | * If BIOS doesn't give a proper info, enable the corresponding | |
4471 | * fixup entry. | |
7d7eb9ea | 4472 | */ |
53c334ad TI |
4473 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1), |
4474 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3), | |
4475 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), | |
4476 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3), | |
4477 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), | |
4478 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), | |
4479 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), | |
4480 | SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1), | |
4481 | SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1), | |
4482 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), | |
4483 | SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7), | |
4484 | SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7), | |
4485 | SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8), | |
4486 | SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3), | |
4487 | SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1), | |
4488 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), | |
4489 | SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2), | |
4490 | SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1), | |
4491 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), | |
4492 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), | |
4493 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), | |
4494 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), | |
4495 | SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1), | |
4496 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3), | |
4497 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2), | |
4498 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), | |
4499 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5), | |
4500 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), | |
4501 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), | |
4502 | SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1), | |
4503 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), | |
4504 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), | |
4505 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3), | |
4506 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3), | |
4507 | SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1), | |
4508 | SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1), | |
4509 | SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1), | |
4510 | SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1), | |
4511 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1), | |
4512 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), | |
4513 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2), | |
4514 | SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1), | |
4515 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), | |
4516 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3), | |
4517 | SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1), | |
4518 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1), | |
4519 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1), | |
4520 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2), | |
4521 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), | |
4522 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4), | |
4523 | #endif | |
6cb3b707 DH |
4524 | {} |
4525 | }; | |
4526 | ||
1727a771 | 4527 | static const struct hda_model_fixup alc662_fixup_models[] = { |
6be7948f | 4528 | {.id = ALC272_FIXUP_MARIO, .name = "mario"}, |
53c334ad TI |
4529 | {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"}, |
4530 | {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"}, | |
4531 | {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"}, | |
4532 | {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"}, | |
4533 | {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"}, | |
4534 | {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"}, | |
4535 | {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"}, | |
4536 | {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"}, | |
6e72aa5f | 4537 | {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
e32aa85a | 4538 | {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"}, |
6be7948f TB |
4539 | {} |
4540 | }; | |
6cb3b707 | 4541 | |
8663ff75 KY |
4542 | static void alc662_fill_coef(struct hda_codec *codec) |
4543 | { | |
4544 | int val, coef; | |
4545 | ||
4546 | coef = alc_get_coef0(codec); | |
4547 | ||
4548 | switch (codec->vendor_id) { | |
4549 | case 0x10ec0662: | |
4550 | if ((coef & 0x00f0) == 0x0030) { | |
4551 | val = alc_read_coef_idx(codec, 0x4); /* EAPD Ctrl */ | |
4552 | alc_write_coef_idx(codec, 0x4, val & ~(1<<10)); | |
4553 | } | |
4554 | break; | |
4555 | case 0x10ec0272: | |
4556 | case 0x10ec0273: | |
4557 | case 0x10ec0663: | |
4558 | case 0x10ec0665: | |
4559 | case 0x10ec0670: | |
4560 | case 0x10ec0671: | |
4561 | case 0x10ec0672: | |
4562 | val = alc_read_coef_idx(codec, 0xd); /* EAPD Ctrl */ | |
4563 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); | |
4564 | break; | |
4565 | } | |
4566 | } | |
6cb3b707 | 4567 | |
1d045db9 TI |
4568 | /* |
4569 | */ | |
bc9f98a9 KY |
4570 | static int patch_alc662(struct hda_codec *codec) |
4571 | { | |
4572 | struct alc_spec *spec; | |
3de95173 | 4573 | int err; |
bc9f98a9 | 4574 | |
3de95173 TI |
4575 | err = alc_alloc_spec(codec, 0x0b); |
4576 | if (err < 0) | |
4577 | return err; | |
bc9f98a9 | 4578 | |
3de95173 | 4579 | spec = codec->spec; |
1f0f4b80 | 4580 | |
53c334ad TI |
4581 | /* handle multiple HPs as is */ |
4582 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; | |
4583 | ||
2c3bf9ab TI |
4584 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
4585 | ||
8663ff75 KY |
4586 | spec->init_hook = alc662_fill_coef; |
4587 | alc662_fill_coef(codec); | |
4588 | ||
1727a771 | 4589 | snd_hda_pick_fixup(codec, alc662_fixup_models, |
8e5a0509 | 4590 | alc662_fixup_tbl, alc662_fixups); |
1727a771 | 4591 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
8e5a0509 TI |
4592 | |
4593 | alc_auto_parse_customize_define(codec); | |
4594 | ||
7504b6cd TI |
4595 | if (has_cdefine_beep(codec)) |
4596 | spec->gen.beep_nid = 0x01; | |
4597 | ||
1bb7e43e | 4598 | if ((alc_get_coef0(codec) & (1 << 14)) && |
e16fb6d1 TI |
4599 | codec->bus->pci->subsystem_vendor == 0x1025 && |
4600 | spec->cdefine.platform_type == 1) { | |
6134b1a2 WY |
4601 | err = alc_codec_rename(codec, "ALC272X"); |
4602 | if (err < 0) | |
e16fb6d1 | 4603 | goto error; |
20ca0c35 | 4604 | } |
274693f3 | 4605 | |
b9c5106c TI |
4606 | /* automatic parse from the BIOS config */ |
4607 | err = alc662_parse_auto_config(codec); | |
e16fb6d1 TI |
4608 | if (err < 0) |
4609 | goto error; | |
bc9f98a9 | 4610 | |
7504b6cd | 4611 | if (!spec->gen.no_analog && spec->gen.beep_nid) { |
da00c244 KY |
4612 | switch (codec->vendor_id) { |
4613 | case 0x10ec0662: | |
4614 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | |
4615 | break; | |
4616 | case 0x10ec0272: | |
4617 | case 0x10ec0663: | |
4618 | case 0x10ec0665: | |
e1a8b1a3 | 4619 | case 0x10ec0668: |
da00c244 KY |
4620 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
4621 | break; | |
4622 | case 0x10ec0273: | |
4623 | set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); | |
4624 | break; | |
4625 | } | |
cec27c89 | 4626 | } |
2134ea4f | 4627 | |
bc9f98a9 | 4628 | codec->patch_ops = alc_patch_ops; |
1c716153 | 4629 | spec->shutup = alc_eapd_shutup; |
6cb3b707 | 4630 | |
1727a771 | 4631 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
589876e2 | 4632 | |
bc9f98a9 | 4633 | return 0; |
801f49d3 | 4634 | |
e16fb6d1 TI |
4635 | error: |
4636 | alc_free(codec); | |
4637 | return err; | |
b478b998 KY |
4638 | } |
4639 | ||
d1eb57f4 KY |
4640 | /* |
4641 | * ALC680 support | |
4642 | */ | |
d1eb57f4 | 4643 | |
d1eb57f4 KY |
4644 | static int alc680_parse_auto_config(struct hda_codec *codec) |
4645 | { | |
3e6179b8 | 4646 | return alc_parse_auto_config(codec, NULL, NULL); |
d1eb57f4 KY |
4647 | } |
4648 | ||
d1eb57f4 | 4649 | /* |
d1eb57f4 | 4650 | */ |
d1eb57f4 KY |
4651 | static int patch_alc680(struct hda_codec *codec) |
4652 | { | |
d1eb57f4 KY |
4653 | int err; |
4654 | ||
1f0f4b80 | 4655 | /* ALC680 has no aa-loopback mixer */ |
3de95173 TI |
4656 | err = alc_alloc_spec(codec, 0); |
4657 | if (err < 0) | |
4658 | return err; | |
1f0f4b80 | 4659 | |
1ebec5f2 TI |
4660 | /* automatic parse from the BIOS config */ |
4661 | err = alc680_parse_auto_config(codec); | |
4662 | if (err < 0) { | |
4663 | alc_free(codec); | |
4664 | return err; | |
d1eb57f4 KY |
4665 | } |
4666 | ||
d1eb57f4 | 4667 | codec->patch_ops = alc_patch_ops; |
d1eb57f4 KY |
4668 | |
4669 | return 0; | |
4670 | } | |
4671 | ||
1da177e4 LT |
4672 | /* |
4673 | * patch entries | |
4674 | */ | |
a9111321 | 4675 | static const struct hda_codec_preset snd_hda_preset_realtek[] = { |
296f0338 | 4676 | { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, |
eda79138 | 4677 | { .id = 0x10ec0231, .name = "ALC231", .patch = patch_alc269 }, |
84dfd0ac | 4678 | { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 }, |
51f75120 | 4679 | { .id = 0x10ec0255, .name = "ALC255", .patch = patch_alc269 }, |
1da177e4 | 4680 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
df694daa | 4681 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
f6a92248 | 4682 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
a361d84b | 4683 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
f6a92248 | 4684 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
ebb83eeb | 4685 | { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, |
01afd41f | 4686 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
ebb83eeb | 4687 | { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, |
296f0338 | 4688 | { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 }, |
befae82e | 4689 | { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 }, |
4e01ec63 | 4690 | { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 }, |
7ff34ad8 | 4691 | { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 }, |
065380f0 | 4692 | { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 }, |
7fc7d047 | 4693 | { .id = 0x10ec0286, .name = "ALC286", .patch = patch_alc269 }, |
fa8575dd | 4694 | { .id = 0x10ec0288, .name = "ALC288", .patch = patch_alc269 }, |
7ff34ad8 | 4695 | { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 }, |
af02dde8 | 4696 | { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 }, |
f32610ed | 4697 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
bc9f98a9 | 4698 | .patch = patch_alc861 }, |
f32610ed JS |
4699 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
4700 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, | |
4701 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, | |
bc9f98a9 | 4702 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
4953550a | 4703 | .patch = patch_alc882 }, |
bc9f98a9 KY |
4704 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", |
4705 | .patch = patch_alc662 }, | |
cc667a72 DH |
4706 | { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3", |
4707 | .patch = patch_alc662 }, | |
6dda9f4a | 4708 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
cec27c89 | 4709 | { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, |
19a62823 | 4710 | { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 }, |
6227cdce | 4711 | { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, |
1d87caa6 | 4712 | { .id = 0x10ec0671, .name = "ALC671", .patch = patch_alc662 }, |
d1eb57f4 | 4713 | { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, |
f0fc1301 | 4714 | { .id = 0x10ec0867, .name = "ALC891", .patch = patch_alc882 }, |
f32610ed | 4715 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
1da177e4 | 4716 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
4953550a | 4717 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
669faba2 | 4718 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
4953550a | 4719 | .patch = patch_alc882 }, |
cb308f97 | 4720 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
4953550a | 4721 | .patch = patch_alc882 }, |
df694daa | 4722 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
e16fb6d1 | 4723 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
4442608d | 4724 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
4953550a | 4725 | .patch = patch_alc882 }, |
e16fb6d1 | 4726 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, |
4953550a | 4727 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
274693f3 | 4728 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, |
e16fb6d1 | 4729 | { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, |
19a62823 | 4730 | { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 }, |
1da177e4 LT |
4731 | {} /* terminator */ |
4732 | }; | |
1289e9e8 TI |
4733 | |
4734 | MODULE_ALIAS("snd-hda-codec-id:10ec*"); | |
4735 | ||
4736 | MODULE_LICENSE("GPL"); | |
4737 | MODULE_DESCRIPTION("Realtek HD-audio codec"); | |
4738 | ||
4739 | static struct hda_codec_preset_list realtek_list = { | |
4740 | .preset = snd_hda_preset_realtek, | |
4741 | .owner = THIS_MODULE, | |
4742 | }; | |
4743 | ||
4744 | static int __init patch_realtek_init(void) | |
4745 | { | |
4746 | return snd_hda_add_codec_preset(&realtek_list); | |
4747 | } | |
4748 | ||
4749 | static void __exit patch_realtek_exit(void) | |
4750 | { | |
4751 | snd_hda_delete_codec_preset(&realtek_list); | |
4752 | } | |
4753 | ||
4754 | module_init(patch_realtek_init) | |
4755 | module_exit(patch_realtek_exit) |