]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - sound/pci/hda/patch_realtek.c
ALSA: hda-intel: Cleanups for widget connection list handling
[mirror_ubuntu-bionic-kernel.git] / sound / pci / hda / patch_realtek.c
CommitLineData
1da177e4
LT
1/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
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>
7cf51e48 9 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
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>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
680cd536 33#include "hda_beep.h"
1da177e4 34
ccc656ce
KY
35#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
1da177e4
LT
39
40/* ALC880 board config type */
41enum {
1da177e4
LT
42 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
dfc0ff62 47 ALC880_Z71V,
b6482d48 48 ALC880_6ST,
16ded525
TI
49 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
df694daa 54 ALC880_ASUS_DIG2,
2cf9f0fc 55 ALC880_FUJITSU,
16ded525 56 ALC880_UNIWILL_DIG,
ccc656ce
KY
57 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
df694daa
KY
59 ALC880_CLEVO,
60 ALC880_TCL_S700,
ae6b813a 61 ALC880_LG,
d681518a 62 ALC880_LG_LW,
df99cd33 63 ALC880_MEDION_RIM,
e9edcee0
TI
64#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
df694daa 67 ALC880_AUTO,
16ded525
TI
68 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
3f878308 75 ALC260_HP_DC7600,
df694daa
KY
76 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
0bfc90e9 78 ALC260_ACER,
bc9f98a9
KY
79 ALC260_WILL,
80 ALC260_REPLACER_672V,
cc959489 81 ALC260_FAVORIT100,
7cf51e48
JW
82#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
df694daa 85 ALC260_AUTO,
16ded525 86 ALC260_MODEL_LAST /* last tag */
1da177e4
LT
87};
88
df694daa
KY
89/* ALC262 models */
90enum {
91 ALC262_BASIC,
ccc656ce
KY
92 ALC262_HIPPO,
93 ALC262_HIPPO_1,
834be88d 94 ALC262_FUJITSU,
9c7f852e 95 ALC262_HP_BPC,
cd7509a4
KY
96 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
66d2a9d6 98 ALC262_HP_TC_T5735,
8c427226 99 ALC262_HP_RP5700,
304dcaac 100 ALC262_BENQ_ED8,
272a527c 101 ALC262_SONY_ASSAMD,
83c34218 102 ALC262_BENQ_T31,
f651b50b 103 ALC262_ULTRA,
0e31daf7 104 ALC262_LENOVO_3000,
e8f9ae2a 105 ALC262_NEC,
4e555fe5 106 ALC262_TOSHIBA_S06,
9f99a638 107 ALC262_TOSHIBA_RX1,
ba340e82 108 ALC262_TYAN,
df694daa
KY
109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
a361d84b
KY
113/* ALC268 models */
114enum {
eb5a6621 115 ALC267_QUANTA_IL1,
a361d84b 116 ALC268_3ST,
d1a991a6 117 ALC268_TOSHIBA,
d273809e 118 ALC268_ACER,
c238b4f4 119 ALC268_ACER_DMIC,
8ef355da 120 ALC268_ACER_ASPIRE_ONE,
3866f0b0 121 ALC268_DELL,
f12462c5 122 ALC268_ZEPTO,
86c53bd2
JW
123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
a361d84b
KY
126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
f6a92248
KY
130/* ALC269 models */
131enum {
132 ALC269_BASIC,
60db6b53 133 ALC269_QUANTA_FL1,
f53281e6
KY
134 ALC269_ASUS_EEEPC_P703,
135 ALC269_ASUS_EEEPC_P901,
26f5df26 136 ALC269_FUJITSU,
64154835 137 ALC269_LIFEBOOK,
f6a92248
KY
138 ALC269_AUTO,
139 ALC269_MODEL_LAST /* last tag */
140};
141
df694daa
KY
142/* ALC861 models */
143enum {
144 ALC861_3ST,
9c7f852e 145 ALC660_3ST,
df694daa
KY
146 ALC861_3ST_DIG,
147 ALC861_6ST_DIG,
22309c3e 148 ALC861_UNIWILL_M31,
a53d1aec 149 ALC861_TOSHIBA,
7cdbff94 150 ALC861_ASUS,
56bb0cab 151 ALC861_ASUS_LAPTOP,
df694daa
KY
152 ALC861_AUTO,
153 ALC861_MODEL_LAST,
154};
155
f32610ed
JS
156/* ALC861-VD models */
157enum {
158 ALC660VD_3ST,
6963f84c 159 ALC660VD_3ST_DIG,
13c94744 160 ALC660VD_ASUS_V1S,
f32610ed
JS
161 ALC861VD_3ST,
162 ALC861VD_3ST_DIG,
163 ALC861VD_6ST_DIG,
bdd148a3 164 ALC861VD_LENOVO,
272a527c 165 ALC861VD_DALLAS,
d1a991a6 166 ALC861VD_HP,
f32610ed
JS
167 ALC861VD_AUTO,
168 ALC861VD_MODEL_LAST,
169};
170
bc9f98a9
KY
171/* ALC662 models */
172enum {
173 ALC662_3ST_2ch_DIG,
174 ALC662_3ST_6ch_DIG,
175 ALC662_3ST_6ch,
176 ALC662_5ST_DIG,
177 ALC662_LENOVO_101E,
291702f0 178 ALC662_ASUS_EEEPC_P701,
8c427226 179 ALC662_ASUS_EEEPC_EP20,
6dda9f4a
KY
180 ALC663_ASUS_M51VA,
181 ALC663_ASUS_G71V,
182 ALC663_ASUS_H13,
183 ALC663_ASUS_G50V,
f1d4e28b
KY
184 ALC662_ECS,
185 ALC663_ASUS_MODE1,
186 ALC662_ASUS_MODE2,
187 ALC663_ASUS_MODE3,
188 ALC663_ASUS_MODE4,
189 ALC663_ASUS_MODE5,
190 ALC663_ASUS_MODE6,
622e84cd
KY
191 ALC272_DELL,
192 ALC272_DELL_ZM1,
9541ba1d 193 ALC272_SAMSUNG_NC10,
bc9f98a9
KY
194 ALC662_AUTO,
195 ALC662_MODEL_LAST,
196};
197
df694daa
KY
198/* ALC882 models */
199enum {
200 ALC882_3ST_DIG,
201 ALC882_6ST_DIG,
4b146cb0 202 ALC882_ARIMA,
bdd148a3 203 ALC882_W2JC,
272a527c
KY
204 ALC882_TARGA,
205 ALC882_ASUS_A7J,
914759b7 206 ALC882_ASUS_A7M,
9102cd1c 207 ALC885_MACPRO,
87350ad0 208 ALC885_MBP3,
41d5545d 209 ALC885_MB5,
c54728d8 210 ALC885_IMAC24,
9c7f852e
TI
211 ALC883_3ST_2ch_DIG,
212 ALC883_3ST_6ch_DIG,
213 ALC883_3ST_6ch,
214 ALC883_6ST_DIG,
ccc656ce
KY
215 ALC883_TARGA_DIG,
216 ALC883_TARGA_2ch_DIG,
64a8be74 217 ALC883_TARGA_8ch_DIG,
bab282b9 218 ALC883_ACER,
2880a867 219 ALC883_ACER_ASPIRE,
5b2d1eca 220 ALC888_ACER_ASPIRE_4930G,
d2fd4b09 221 ALC888_ACER_ASPIRE_6530G,
3b315d70 222 ALC888_ACER_ASPIRE_8930G,
c07584c8 223 ALC883_MEDION,
ea1fb29a 224 ALC883_MEDION_MD2,
b373bdeb 225 ALC883_LAPTOP_EAPD,
bc9f98a9 226 ALC883_LENOVO_101E_2ch,
272a527c 227 ALC883_LENOVO_NB0763,
189609ae 228 ALC888_LENOVO_MS7195_DIG,
e2757d5e 229 ALC888_LENOVO_SKY,
ea1fb29a 230 ALC883_HAIER_W66,
4723c022 231 ALC888_3ST_HP,
5795b9e6 232 ALC888_6ST_DELL,
a8848bd6 233 ALC883_MITAC,
0c4cc443 234 ALC883_CLEVO_M720,
fb97dc67 235 ALC883_FUJITSU_PI2515,
ef8ef5fb 236 ALC888_FUJITSU_XA3530,
17bba1b7 237 ALC883_3ST_6ch_INTEL,
e2757d5e
KY
238 ALC888_ASUS_M90V,
239 ALC888_ASUS_EEE1601,
eb4c41d3 240 ALC889A_MB31,
3ab90935 241 ALC1200_ASUS_P5Q,
3e1647c5 242 ALC883_SONY_VAIO_TT,
4953550a
TI
243 ALC882_AUTO,
244 ALC882_MODEL_LAST,
9c7f852e
TI
245};
246
df694daa
KY
247/* for GPIO Poll */
248#define GPIO_MASK 0x03
249
4a79ba34
TI
250/* extra amp-initialization sequence types */
251enum {
252 ALC_INIT_NONE,
253 ALC_INIT_DEFAULT,
254 ALC_INIT_GPIO1,
255 ALC_INIT_GPIO2,
256 ALC_INIT_GPIO3,
257};
258
1da177e4
LT
259struct alc_spec {
260 /* codec parameterization */
df694daa 261 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
1da177e4 262 unsigned int num_mixers;
f9e336f6 263 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
45bdd1c1 264 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
1da177e4 265
df694daa 266 const struct hda_verb *init_verbs[5]; /* initialization verbs
9c7f852e
TI
267 * don't forget NULL
268 * termination!
e9edcee0
TI
269 */
270 unsigned int num_init_verbs;
1da177e4 271
812a2cca 272 char stream_name_analog[16]; /* analog PCM stream */
1da177e4
LT
273 struct hda_pcm_stream *stream_analog_playback;
274 struct hda_pcm_stream *stream_analog_capture;
6330079f
TI
275 struct hda_pcm_stream *stream_analog_alt_playback;
276 struct hda_pcm_stream *stream_analog_alt_capture;
1da177e4 277
812a2cca 278 char stream_name_digital[16]; /* digital PCM stream */
1da177e4
LT
279 struct hda_pcm_stream *stream_digital_playback;
280 struct hda_pcm_stream *stream_digital_capture;
281
282 /* playback */
16ded525
TI
283 struct hda_multi_out multiout; /* playback set-up
284 * max_channels, dacs must be set
285 * dig_out_nid and hp_nid are optional
286 */
6330079f 287 hda_nid_t alt_dac_nid;
6a05ac4a 288 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
8c441982 289 int dig_out_type;
1da177e4
LT
290
291 /* capture */
292 unsigned int num_adc_nids;
293 hda_nid_t *adc_nids;
e1406348 294 hda_nid_t *capsrc_nids;
16ded525 295 hda_nid_t dig_in_nid; /* digital-in NID; optional */
1da177e4
LT
296
297 /* capture source */
a1e8d2da 298 unsigned int num_mux_defs;
1da177e4
LT
299 const struct hda_input_mux *input_mux;
300 unsigned int cur_mux[3];
301
302 /* channel model */
d2a6d7dc 303 const struct hda_channel_mode *channel_mode;
1da177e4 304 int num_channel_mode;
4e195a7b 305 int need_dac_fix;
3b315d70
HM
306 int const_channel_count;
307 int ext_channel_count;
1da177e4
LT
308
309 /* PCM information */
4c5186ed 310 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
41e41f1f 311
e9edcee0
TI
312 /* dynamic controls, init_verbs and input_mux */
313 struct auto_pin_cfg autocfg;
603c4019 314 struct snd_array kctls;
61b9b9b1 315 struct hda_input_mux private_imux[3];
41923e44 316 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
4953550a
TI
317 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
318 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
834be88d 319
ae6b813a
TI
320 /* hooks */
321 void (*init_hook)(struct hda_codec *codec);
322 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
323
834be88d
TI
324 /* for pin sensing */
325 unsigned int sense_updated: 1;
326 unsigned int jack_present: 1;
bec15c3a 327 unsigned int master_sw: 1;
cb53c626 328
e64f14f4
TI
329 /* other flags */
330 unsigned int no_analog :1; /* digital I/O only */
4a79ba34 331 int init_amp;
e64f14f4 332
2134ea4f
TI
333 /* for virtual master */
334 hda_nid_t vmaster_nid;
cb53c626
TI
335#ifdef CONFIG_SND_HDA_POWER_SAVE
336 struct hda_loopback_check loopback;
337#endif
2c3bf9ab
TI
338
339 /* for PLL fix */
340 hda_nid_t pll_nid;
341 unsigned int pll_coef_idx, pll_coef_bit;
df694daa
KY
342};
343
344/*
345 * configuration template - to be copied to the spec instance
346 */
347struct alc_config_preset {
9c7f852e
TI
348 struct snd_kcontrol_new *mixers[5]; /* should be identical size
349 * with spec
350 */
f9e336f6 351 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
df694daa
KY
352 const struct hda_verb *init_verbs[5];
353 unsigned int num_dacs;
354 hda_nid_t *dac_nids;
355 hda_nid_t dig_out_nid; /* optional */
356 hda_nid_t hp_nid; /* optional */
b25c9da1 357 hda_nid_t *slave_dig_outs;
df694daa
KY
358 unsigned int num_adc_nids;
359 hda_nid_t *adc_nids;
e1406348 360 hda_nid_t *capsrc_nids;
df694daa
KY
361 hda_nid_t dig_in_nid;
362 unsigned int num_channel_mode;
363 const struct hda_channel_mode *channel_mode;
4e195a7b 364 int need_dac_fix;
3b315d70 365 int const_channel_count;
a1e8d2da 366 unsigned int num_mux_defs;
df694daa 367 const struct hda_input_mux *input_mux;
ae6b813a
TI
368 void (*unsol_event)(struct hda_codec *, unsigned int);
369 void (*init_hook)(struct hda_codec *);
cb53c626
TI
370#ifdef CONFIG_SND_HDA_POWER_SAVE
371 struct hda_amp_list *loopbacks;
372#endif
1da177e4
LT
373};
374
1da177e4
LT
375
376/*
377 * input MUX handling
378 */
9c7f852e
TI
379static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
380 struct snd_ctl_elem_info *uinfo)
1da177e4
LT
381{
382 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
383 struct alc_spec *spec = codec->spec;
a1e8d2da
JW
384 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
385 if (mux_idx >= spec->num_mux_defs)
386 mux_idx = 0;
387 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
1da177e4
LT
388}
389
9c7f852e
TI
390static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
391 struct snd_ctl_elem_value *ucontrol)
1da177e4
LT
392{
393 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
394 struct alc_spec *spec = codec->spec;
395 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
396
397 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
398 return 0;
399}
400
9c7f852e
TI
401static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
402 struct snd_ctl_elem_value *ucontrol)
1da177e4
LT
403{
404 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
405 struct alc_spec *spec = codec->spec;
cd896c33 406 const struct hda_input_mux *imux;
1da177e4 407 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
cd896c33 408 unsigned int mux_idx;
e1406348
TI
409 hda_nid_t nid = spec->capsrc_nids ?
410 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
0169b6b3 411 unsigned int type;
1da177e4 412
cd896c33
TI
413 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
414 imux = &spec->input_mux[mux_idx];
415
0169b6b3
TI
416 type = (get_wcaps(codec, nid) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
417 if (type == AC_WID_AUD_MIX) {
54cbc9ab
TI
418 /* Matrix-mixer style (e.g. ALC882) */
419 unsigned int *cur_val = &spec->cur_mux[adc_idx];
420 unsigned int i, idx;
421
422 idx = ucontrol->value.enumerated.item[0];
423 if (idx >= imux->num_items)
424 idx = imux->num_items - 1;
425 if (*cur_val == idx)
426 return 0;
427 for (i = 0; i < imux->num_items; i++) {
428 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
429 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
430 imux->items[i].index,
431 HDA_AMP_MUTE, v);
432 }
433 *cur_val = idx;
434 return 1;
435 } else {
436 /* MUX style (e.g. ALC880) */
cd896c33 437 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
54cbc9ab
TI
438 &spec->cur_mux[adc_idx]);
439 }
440}
e9edcee0 441
1da177e4
LT
442/*
443 * channel mode setting
444 */
9c7f852e
TI
445static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
446 struct snd_ctl_elem_info *uinfo)
1da177e4
LT
447{
448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
449 struct alc_spec *spec = codec->spec;
d2a6d7dc
TI
450 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
451 spec->num_channel_mode);
1da177e4
LT
452}
453
9c7f852e
TI
454static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
455 struct snd_ctl_elem_value *ucontrol)
1da177e4
LT
456{
457 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
458 struct alc_spec *spec = codec->spec;
d2a6d7dc 459 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
9c7f852e 460 spec->num_channel_mode,
3b315d70 461 spec->ext_channel_count);
1da177e4
LT
462}
463
9c7f852e
TI
464static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_value *ucontrol)
1da177e4
LT
466{
467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
468 struct alc_spec *spec = codec->spec;
4e195a7b
TI
469 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
470 spec->num_channel_mode,
3b315d70
HM
471 &spec->ext_channel_count);
472 if (err >= 0 && !spec->const_channel_count) {
473 spec->multiout.max_channels = spec->ext_channel_count;
474 if (spec->need_dac_fix)
475 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
476 }
4e195a7b 477 return err;
1da177e4
LT
478}
479
a9430dd8 480/*
4c5186ed 481 * Control the mode of pin widget settings via the mixer. "pc" is used
ea1fb29a 482 * instead of "%" to avoid consequences of accidently treating the % as
4c5186ed
JW
483 * being part of a format specifier. Maximum allowed length of a value is
484 * 63 characters plus NULL terminator.
7cf51e48
JW
485 *
486 * Note: some retasking pin complexes seem to ignore requests for input
487 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
488 * are requested. Therefore order this list so that this behaviour will not
489 * cause problems when mixer clients move through the enum sequentially.
a1e8d2da
JW
490 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
491 * March 2006.
4c5186ed
JW
492 */
493static char *alc_pin_mode_names[] = {
7cf51e48
JW
494 "Mic 50pc bias", "Mic 80pc bias",
495 "Line in", "Line out", "Headphone out",
4c5186ed
JW
496};
497static unsigned char alc_pin_mode_values[] = {
7cf51e48 498 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
4c5186ed
JW
499};
500/* The control can present all 5 options, or it can limit the options based
a1e8d2da
JW
501 * in the pin being assumed to be exclusively an input or an output pin. In
502 * addition, "input" pins may or may not process the mic bias option
503 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
504 * accept requests for bias as of chip versions up to March 2006) and/or
505 * wiring in the computer.
a9430dd8 506 */
a1e8d2da
JW
507#define ALC_PIN_DIR_IN 0x00
508#define ALC_PIN_DIR_OUT 0x01
509#define ALC_PIN_DIR_INOUT 0x02
510#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
511#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
4c5186ed 512
ea1fb29a 513/* Info about the pin modes supported by the different pin direction modes.
4c5186ed
JW
514 * For each direction the minimum and maximum values are given.
515 */
a1e8d2da 516static signed char alc_pin_mode_dir_info[5][2] = {
4c5186ed
JW
517 { 0, 2 }, /* ALC_PIN_DIR_IN */
518 { 3, 4 }, /* ALC_PIN_DIR_OUT */
519 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
a1e8d2da
JW
520 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
521 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
4c5186ed
JW
522};
523#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
524#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
525#define alc_pin_mode_n_items(_dir) \
526 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
527
9c7f852e
TI
528static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
529 struct snd_ctl_elem_info *uinfo)
a9430dd8 530{
4c5186ed
JW
531 unsigned int item_num = uinfo->value.enumerated.item;
532 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
533
534 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
a9430dd8 535 uinfo->count = 1;
4c5186ed
JW
536 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
537
538 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
539 item_num = alc_pin_mode_min(dir);
540 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
a9430dd8
JW
541 return 0;
542}
543
9c7f852e
TI
544static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
545 struct snd_ctl_elem_value *ucontrol)
a9430dd8 546{
4c5186ed 547 unsigned int i;
a9430dd8
JW
548 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
549 hda_nid_t nid = kcontrol->private_value & 0xffff;
4c5186ed 550 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
a9430dd8 551 long *valp = ucontrol->value.integer.value;
9c7f852e
TI
552 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
553 AC_VERB_GET_PIN_WIDGET_CONTROL,
554 0x00);
a9430dd8 555
4c5186ed
JW
556 /* Find enumerated value for current pinctl setting */
557 i = alc_pin_mode_min(dir);
9c7f852e 558 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
4c5186ed 559 i++;
9c7f852e 560 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
a9430dd8
JW
561 return 0;
562}
563
9c7f852e
TI
564static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
565 struct snd_ctl_elem_value *ucontrol)
a9430dd8 566{
4c5186ed 567 signed int change;
a9430dd8
JW
568 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
569 hda_nid_t nid = kcontrol->private_value & 0xffff;
4c5186ed
JW
570 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
571 long val = *ucontrol->value.integer.value;
9c7f852e
TI
572 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
573 AC_VERB_GET_PIN_WIDGET_CONTROL,
574 0x00);
a9430dd8 575
f12ab1e0 576 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
4c5186ed
JW
577 val = alc_pin_mode_min(dir);
578
579 change = pinctl != alc_pin_mode_values[val];
cdcd9268
JW
580 if (change) {
581 /* Set pin mode to that requested */
82beb8fd
TI
582 snd_hda_codec_write_cache(codec, nid, 0,
583 AC_VERB_SET_PIN_WIDGET_CONTROL,
584 alc_pin_mode_values[val]);
cdcd9268 585
ea1fb29a 586 /* Also enable the retasking pin's input/output as required
cdcd9268
JW
587 * for the requested pin mode. Enum values of 2 or less are
588 * input modes.
589 *
590 * Dynamically switching the input/output buffers probably
a1e8d2da
JW
591 * reduces noise slightly (particularly on input) so we'll
592 * do it. However, having both input and output buffers
593 * enabled simultaneously doesn't seem to be problematic if
594 * this turns out to be necessary in the future.
cdcd9268
JW
595 */
596 if (val <= 2) {
47fd830a
TI
597 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
598 HDA_AMP_MUTE, HDA_AMP_MUTE);
599 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
600 HDA_AMP_MUTE, 0);
cdcd9268 601 } else {
47fd830a
TI
602 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
603 HDA_AMP_MUTE, HDA_AMP_MUTE);
604 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
605 HDA_AMP_MUTE, 0);
cdcd9268
JW
606 }
607 }
a9430dd8
JW
608 return change;
609}
610
4c5186ed 611#define ALC_PIN_MODE(xname, nid, dir) \
a9430dd8 612 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
4c5186ed
JW
613 .info = alc_pin_mode_info, \
614 .get = alc_pin_mode_get, \
615 .put = alc_pin_mode_put, \
616 .private_value = nid | (dir<<16) }
df694daa 617
5c8f858d
JW
618/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
619 * together using a mask with more than one bit set. This control is
620 * currently used only by the ALC260 test model. At this stage they are not
621 * needed for any "production" models.
622 */
623#ifdef CONFIG_SND_DEBUG
a5ce8890 624#define alc_gpio_data_info snd_ctl_boolean_mono_info
f12ab1e0 625
9c7f852e
TI
626static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
627 struct snd_ctl_elem_value *ucontrol)
5c8f858d
JW
628{
629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
630 hda_nid_t nid = kcontrol->private_value & 0xffff;
631 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
632 long *valp = ucontrol->value.integer.value;
9c7f852e
TI
633 unsigned int val = snd_hda_codec_read(codec, nid, 0,
634 AC_VERB_GET_GPIO_DATA, 0x00);
5c8f858d
JW
635
636 *valp = (val & mask) != 0;
637 return 0;
638}
9c7f852e
TI
639static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
640 struct snd_ctl_elem_value *ucontrol)
5c8f858d
JW
641{
642 signed int change;
643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
644 hda_nid_t nid = kcontrol->private_value & 0xffff;
645 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
646 long val = *ucontrol->value.integer.value;
9c7f852e
TI
647 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
648 AC_VERB_GET_GPIO_DATA,
649 0x00);
5c8f858d
JW
650
651 /* Set/unset the masked GPIO bit(s) as needed */
9c7f852e
TI
652 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
653 if (val == 0)
5c8f858d
JW
654 gpio_data &= ~mask;
655 else
656 gpio_data |= mask;
82beb8fd
TI
657 snd_hda_codec_write_cache(codec, nid, 0,
658 AC_VERB_SET_GPIO_DATA, gpio_data);
5c8f858d
JW
659
660 return change;
661}
662#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
663 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
664 .info = alc_gpio_data_info, \
665 .get = alc_gpio_data_get, \
666 .put = alc_gpio_data_put, \
667 .private_value = nid | (mask<<16) }
668#endif /* CONFIG_SND_DEBUG */
669
92621f13
JW
670/* A switch control to allow the enabling of the digital IO pins on the
671 * ALC260. This is incredibly simplistic; the intention of this control is
672 * to provide something in the test model allowing digital outputs to be
673 * identified if present. If models are found which can utilise these
674 * outputs a more complete mixer control can be devised for those models if
675 * necessary.
676 */
677#ifdef CONFIG_SND_DEBUG
a5ce8890 678#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
f12ab1e0 679
9c7f852e
TI
680static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
681 struct snd_ctl_elem_value *ucontrol)
92621f13
JW
682{
683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
684 hda_nid_t nid = kcontrol->private_value & 0xffff;
685 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
686 long *valp = ucontrol->value.integer.value;
9c7f852e 687 unsigned int val = snd_hda_codec_read(codec, nid, 0,
3982d17e 688 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
92621f13
JW
689
690 *valp = (val & mask) != 0;
691 return 0;
692}
9c7f852e
TI
693static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
694 struct snd_ctl_elem_value *ucontrol)
92621f13
JW
695{
696 signed int change;
697 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
698 hda_nid_t nid = kcontrol->private_value & 0xffff;
699 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
700 long val = *ucontrol->value.integer.value;
9c7f852e 701 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
3982d17e 702 AC_VERB_GET_DIGI_CONVERT_1,
9c7f852e 703 0x00);
92621f13
JW
704
705 /* Set/unset the masked control bit(s) as needed */
9c7f852e 706 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
92621f13
JW
707 if (val==0)
708 ctrl_data &= ~mask;
709 else
710 ctrl_data |= mask;
82beb8fd
TI
711 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
712 ctrl_data);
92621f13
JW
713
714 return change;
715}
716#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
717 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
718 .info = alc_spdif_ctrl_info, \
719 .get = alc_spdif_ctrl_get, \
720 .put = alc_spdif_ctrl_put, \
721 .private_value = nid | (mask<<16) }
722#endif /* CONFIG_SND_DEBUG */
723
f8225f6d
JW
724/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
725 * Again, this is only used in the ALC26x test models to help identify when
726 * the EAPD line must be asserted for features to work.
727 */
728#ifdef CONFIG_SND_DEBUG
729#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
730
731static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
732 struct snd_ctl_elem_value *ucontrol)
733{
734 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
735 hda_nid_t nid = kcontrol->private_value & 0xffff;
736 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
737 long *valp = ucontrol->value.integer.value;
738 unsigned int val = snd_hda_codec_read(codec, nid, 0,
739 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
740
741 *valp = (val & mask) != 0;
742 return 0;
743}
744
745static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
746 struct snd_ctl_elem_value *ucontrol)
747{
748 int change;
749 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
750 hda_nid_t nid = kcontrol->private_value & 0xffff;
751 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
752 long val = *ucontrol->value.integer.value;
753 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
754 AC_VERB_GET_EAPD_BTLENABLE,
755 0x00);
756
757 /* Set/unset the masked control bit(s) as needed */
758 change = (!val ? 0 : mask) != (ctrl_data & mask);
759 if (!val)
760 ctrl_data &= ~mask;
761 else
762 ctrl_data |= mask;
763 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
764 ctrl_data);
765
766 return change;
767}
768
769#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
770 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
771 .info = alc_eapd_ctrl_info, \
772 .get = alc_eapd_ctrl_get, \
773 .put = alc_eapd_ctrl_put, \
774 .private_value = nid | (mask<<16) }
775#endif /* CONFIG_SND_DEBUG */
776
23f0c048
TI
777/*
778 * set up the input pin config (depending on the given auto-pin type)
779 */
780static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
781 int auto_pin_type)
782{
783 unsigned int val = PIN_IN;
784
785 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
786 unsigned int pincap;
1327a32b 787 pincap = snd_hda_query_pin_caps(codec, nid);
23f0c048
TI
788 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
789 if (pincap & AC_PINCAP_VREF_80)
790 val = PIN_VREF80;
461c6c3a
TI
791 else if (pincap & AC_PINCAP_VREF_50)
792 val = PIN_VREF50;
793 else if (pincap & AC_PINCAP_VREF_100)
794 val = PIN_VREF100;
795 else if (pincap & AC_PINCAP_VREF_GRD)
796 val = PIN_VREFGRD;
23f0c048
TI
797 }
798 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
799}
800
d88897ea
TI
801/*
802 */
803static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
804{
805 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
806 return;
807 spec->mixers[spec->num_mixers++] = mix;
808}
809
810static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
811{
812 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
813 return;
814 spec->init_verbs[spec->num_init_verbs++] = verb;
815}
816
daead538
TI
817#ifdef CONFIG_PROC_FS
818/*
819 * hook for proc
820 */
821static void print_realtek_coef(struct snd_info_buffer *buffer,
822 struct hda_codec *codec, hda_nid_t nid)
823{
824 int coeff;
825
826 if (nid != 0x20)
827 return;
828 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
829 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
830 coeff = snd_hda_codec_read(codec, nid, 0,
831 AC_VERB_GET_COEF_INDEX, 0);
832 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
833}
834#else
835#define print_realtek_coef NULL
836#endif
837
df694daa
KY
838/*
839 * set up from the preset table
840 */
9c7f852e
TI
841static void setup_preset(struct alc_spec *spec,
842 const struct alc_config_preset *preset)
df694daa
KY
843{
844 int i;
845
846 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
d88897ea 847 add_mixer(spec, preset->mixers[i]);
f9e336f6 848 spec->cap_mixer = preset->cap_mixer;
9c7f852e
TI
849 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
850 i++)
d88897ea 851 add_verb(spec, preset->init_verbs[i]);
ea1fb29a 852
df694daa
KY
853 spec->channel_mode = preset->channel_mode;
854 spec->num_channel_mode = preset->num_channel_mode;
4e195a7b 855 spec->need_dac_fix = preset->need_dac_fix;
3b315d70 856 spec->const_channel_count = preset->const_channel_count;
df694daa 857
3b315d70
HM
858 if (preset->const_channel_count)
859 spec->multiout.max_channels = preset->const_channel_count;
860 else
861 spec->multiout.max_channels = spec->channel_mode[0].channels;
862 spec->ext_channel_count = spec->channel_mode[0].channels;
df694daa
KY
863
864 spec->multiout.num_dacs = preset->num_dacs;
865 spec->multiout.dac_nids = preset->dac_nids;
866 spec->multiout.dig_out_nid = preset->dig_out_nid;
b25c9da1 867 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
df694daa 868 spec->multiout.hp_nid = preset->hp_nid;
ea1fb29a 869
a1e8d2da 870 spec->num_mux_defs = preset->num_mux_defs;
f12ab1e0 871 if (!spec->num_mux_defs)
a1e8d2da 872 spec->num_mux_defs = 1;
df694daa
KY
873 spec->input_mux = preset->input_mux;
874
875 spec->num_adc_nids = preset->num_adc_nids;
876 spec->adc_nids = preset->adc_nids;
e1406348 877 spec->capsrc_nids = preset->capsrc_nids;
df694daa 878 spec->dig_in_nid = preset->dig_in_nid;
ae6b813a
TI
879
880 spec->unsol_event = preset->unsol_event;
881 spec->init_hook = preset->init_hook;
cb53c626
TI
882#ifdef CONFIG_SND_HDA_POWER_SAVE
883 spec->loopback.amplist = preset->loopbacks;
884#endif
df694daa
KY
885}
886
bc9f98a9
KY
887/* Enable GPIO mask and set output */
888static struct hda_verb alc_gpio1_init_verbs[] = {
889 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
890 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
891 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
892 { }
893};
894
895static struct hda_verb alc_gpio2_init_verbs[] = {
896 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
897 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
898 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
899 { }
900};
901
bdd148a3
KY
902static struct hda_verb alc_gpio3_init_verbs[] = {
903 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
904 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
905 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
906 { }
907};
908
2c3bf9ab
TI
909/*
910 * Fix hardware PLL issue
911 * On some codecs, the analog PLL gating control must be off while
912 * the default value is 1.
913 */
914static void alc_fix_pll(struct hda_codec *codec)
915{
916 struct alc_spec *spec = codec->spec;
917 unsigned int val;
918
919 if (!spec->pll_nid)
920 return;
921 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
922 spec->pll_coef_idx);
923 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
924 AC_VERB_GET_PROC_COEF, 0);
925 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
926 spec->pll_coef_idx);
927 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
928 val & ~(1 << spec->pll_coef_bit));
929}
930
931static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
932 unsigned int coef_idx, unsigned int coef_bit)
933{
934 struct alc_spec *spec = codec->spec;
935 spec->pll_nid = nid;
936 spec->pll_coef_idx = coef_idx;
937 spec->pll_coef_bit = coef_bit;
938 alc_fix_pll(codec);
939}
940
a9fd4f3f 941static void alc_automute_pin(struct hda_codec *codec)
c9b58006
KY
942{
943 struct alc_spec *spec = codec->spec;
261c2407 944 unsigned int present, pincap;
a9fd4f3f
TI
945 unsigned int nid = spec->autocfg.hp_pins[0];
946 int i;
c9b58006 947
261c2407
TI
948 pincap = snd_hda_query_pin_caps(codec, nid);
949 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
950 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
a9fd4f3f 951 present = snd_hda_codec_read(codec, nid, 0,
c9b58006 952 AC_VERB_GET_PIN_SENSE, 0);
a9fd4f3f
TI
953 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
954 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
955 nid = spec->autocfg.speaker_pins[i];
956 if (!nid)
957 break;
958 snd_hda_codec_write(codec, nid, 0,
959 AC_VERB_SET_PIN_WIDGET_CONTROL,
960 spec->jack_present ? 0 : PIN_OUT);
961 }
c9b58006
KY
962}
963
def319f9 964#if 0 /* it's broken in some cases -- temporarily disabled */
7fb0d78f
KY
965static void alc_mic_automute(struct hda_codec *codec)
966{
967 struct alc_spec *spec = codec->spec;
968 unsigned int present;
969 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
970 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
971 unsigned int mix_nid = spec->capsrc_nids[0];
972 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
973
974 capsrc_idx_mic = mic_nid - 0x18;
975 capsrc_idx_fmic = fmic_nid - 0x18;
976 present = snd_hda_codec_read(codec, mic_nid, 0,
977 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
978 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
979 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
980 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
981 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
982 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
983 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
984}
4605b718 985#else
45bdd1c1 986#define alc_mic_automute(codec) do {} while(0) /* NOP */
4605b718 987#endif /* disabled */
7fb0d78f 988
c9b58006
KY
989/* unsolicited event for HP jack sensing */
990static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
991{
992 if (codec->vendor_id == 0x10ec0880)
993 res >>= 28;
994 else
995 res >>= 26;
a9fd4f3f
TI
996 switch (res) {
997 case ALC880_HP_EVENT:
998 alc_automute_pin(codec);
999 break;
1000 case ALC880_MIC_EVENT:
7fb0d78f 1001 alc_mic_automute(codec);
a9fd4f3f
TI
1002 break;
1003 }
7fb0d78f
KY
1004}
1005
1006static void alc_inithook(struct hda_codec *codec)
1007{
a9fd4f3f 1008 alc_automute_pin(codec);
7fb0d78f 1009 alc_mic_automute(codec);
c9b58006
KY
1010}
1011
f9423e7a
KY
1012/* additional initialization for ALC888 variants */
1013static void alc888_coef_init(struct hda_codec *codec)
1014{
1015 unsigned int tmp;
1016
1017 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1018 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1019 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
37db623a 1020 if ((tmp & 0xf0) == 0x20)
f9423e7a
KY
1021 /* alc888S-VC */
1022 snd_hda_codec_read(codec, 0x20, 0,
1023 AC_VERB_SET_PROC_COEF, 0x830);
1024 else
1025 /* alc888-VB */
1026 snd_hda_codec_read(codec, 0x20, 0,
1027 AC_VERB_SET_PROC_COEF, 0x3030);
1028}
1029
4a79ba34 1030static void alc_auto_init_amp(struct hda_codec *codec, int type)
bc9f98a9 1031{
4a79ba34 1032 unsigned int tmp;
bc9f98a9 1033
4a79ba34
TI
1034 switch (type) {
1035 case ALC_INIT_GPIO1:
bc9f98a9
KY
1036 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1037 break;
4a79ba34 1038 case ALC_INIT_GPIO2:
bc9f98a9
KY
1039 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1040 break;
4a79ba34 1041 case ALC_INIT_GPIO3:
bdd148a3
KY
1042 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1043 break;
4a79ba34 1044 case ALC_INIT_DEFAULT:
bdd148a3 1045 switch (codec->vendor_id) {
c9b58006
KY
1046 case 0x10ec0260:
1047 snd_hda_codec_write(codec, 0x0f, 0,
1048 AC_VERB_SET_EAPD_BTLENABLE, 2);
1049 snd_hda_codec_write(codec, 0x10, 0,
1050 AC_VERB_SET_EAPD_BTLENABLE, 2);
1051 break;
1052 case 0x10ec0262:
bdd148a3
KY
1053 case 0x10ec0267:
1054 case 0x10ec0268:
c9b58006 1055 case 0x10ec0269:
c6e8f2da 1056 case 0x10ec0272:
f9423e7a
KY
1057 case 0x10ec0660:
1058 case 0x10ec0662:
1059 case 0x10ec0663:
c9b58006 1060 case 0x10ec0862:
20a3a05d 1061 case 0x10ec0889:
bdd148a3
KY
1062 snd_hda_codec_write(codec, 0x14, 0,
1063 AC_VERB_SET_EAPD_BTLENABLE, 2);
1064 snd_hda_codec_write(codec, 0x15, 0,
1065 AC_VERB_SET_EAPD_BTLENABLE, 2);
c9b58006 1066 break;
bdd148a3 1067 }
c9b58006
KY
1068 switch (codec->vendor_id) {
1069 case 0x10ec0260:
1070 snd_hda_codec_write(codec, 0x1a, 0,
1071 AC_VERB_SET_COEF_INDEX, 7);
1072 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1073 AC_VERB_GET_PROC_COEF, 0);
1074 snd_hda_codec_write(codec, 0x1a, 0,
1075 AC_VERB_SET_COEF_INDEX, 7);
1076 snd_hda_codec_write(codec, 0x1a, 0,
1077 AC_VERB_SET_PROC_COEF,
1078 tmp | 0x2010);
1079 break;
1080 case 0x10ec0262:
1081 case 0x10ec0880:
1082 case 0x10ec0882:
1083 case 0x10ec0883:
1084 case 0x10ec0885:
4a5a4c56 1085 case 0x10ec0887:
20a3a05d 1086 case 0x10ec0889:
c9b58006
KY
1087 snd_hda_codec_write(codec, 0x20, 0,
1088 AC_VERB_SET_COEF_INDEX, 7);
1089 tmp = snd_hda_codec_read(codec, 0x20, 0,
1090 AC_VERB_GET_PROC_COEF, 0);
1091 snd_hda_codec_write(codec, 0x20, 0,
ea1fb29a 1092 AC_VERB_SET_COEF_INDEX, 7);
c9b58006
KY
1093 snd_hda_codec_write(codec, 0x20, 0,
1094 AC_VERB_SET_PROC_COEF,
1095 tmp | 0x2010);
1096 break;
f9423e7a 1097 case 0x10ec0888:
4a79ba34 1098 alc888_coef_init(codec);
f9423e7a 1099 break;
c9b58006
KY
1100 case 0x10ec0267:
1101 case 0x10ec0268:
1102 snd_hda_codec_write(codec, 0x20, 0,
1103 AC_VERB_SET_COEF_INDEX, 7);
1104 tmp = snd_hda_codec_read(codec, 0x20, 0,
1105 AC_VERB_GET_PROC_COEF, 0);
1106 snd_hda_codec_write(codec, 0x20, 0,
ea1fb29a 1107 AC_VERB_SET_COEF_INDEX, 7);
c9b58006
KY
1108 snd_hda_codec_write(codec, 0x20, 0,
1109 AC_VERB_SET_PROC_COEF,
1110 tmp | 0x3000);
1111 break;
bc9f98a9 1112 }
4a79ba34
TI
1113 break;
1114 }
1115}
1116
1117static void alc_init_auto_hp(struct hda_codec *codec)
1118{
1119 struct alc_spec *spec = codec->spec;
1120
1121 if (!spec->autocfg.hp_pins[0])
1122 return;
1123
1124 if (!spec->autocfg.speaker_pins[0]) {
2a2ed0df
TI
1125 if (spec->autocfg.line_out_pins[0] &&
1126 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
4a79ba34
TI
1127 spec->autocfg.speaker_pins[0] =
1128 spec->autocfg.line_out_pins[0];
1129 else
1130 return;
1131 }
1132
2a2ed0df
TI
1133 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1134 spec->autocfg.hp_pins[0]);
4a79ba34
TI
1135 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1136 AC_VERB_SET_UNSOLICITED_ENABLE,
1137 AC_USRSP_EN | ALC880_HP_EVENT);
1138 spec->unsol_event = alc_sku_unsol_event;
1139}
1140
1141/* check subsystem ID and set up device-specific initialization;
1142 * return 1 if initialized, 0 if invalid SSID
1143 */
1144/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1145 * 31 ~ 16 : Manufacture ID
1146 * 15 ~ 8 : SKU ID
1147 * 7 ~ 0 : Assembly ID
1148 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1149 */
1150static int alc_subsystem_id(struct hda_codec *codec,
1151 hda_nid_t porta, hda_nid_t porte,
1152 hda_nid_t portd)
1153{
1154 unsigned int ass, tmp, i;
1155 unsigned nid;
1156 struct alc_spec *spec = codec->spec;
1157
1158 ass = codec->subsystem_id & 0xffff;
1159 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1160 goto do_sku;
1161
1162 /* invalid SSID, check the special NID pin defcfg instead */
1163 /*
def319f9 1164 * 31~30 : port connectivity
4a79ba34
TI
1165 * 29~21 : reserve
1166 * 20 : PCBEEP input
1167 * 19~16 : Check sum (15:1)
1168 * 15~1 : Custom
1169 * 0 : override
1170 */
1171 nid = 0x1d;
1172 if (codec->vendor_id == 0x10ec0260)
1173 nid = 0x17;
1174 ass = snd_hda_codec_get_pincfg(codec, nid);
1175 snd_printd("realtek: No valid SSID, "
1176 "checking pincfg 0x%08x for NID 0x%x\n",
cb6605c1 1177 ass, nid);
4a79ba34
TI
1178 if (!(ass & 1) && !(ass & 0x100000))
1179 return 0;
1180 if ((ass >> 30) != 1) /* no physical connection */
1181 return 0;
1182
1183 /* check sum */
1184 tmp = 0;
1185 for (i = 1; i < 16; i++) {
1186 if ((ass >> i) & 1)
1187 tmp++;
1188 }
1189 if (((ass >> 16) & 0xf) != tmp)
1190 return 0;
1191do_sku:
1192 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1193 ass & 0xffff, codec->vendor_id);
1194 /*
1195 * 0 : override
1196 * 1 : Swap Jack
1197 * 2 : 0 --> Desktop, 1 --> Laptop
1198 * 3~5 : External Amplifier control
1199 * 7~6 : Reserved
1200 */
1201 tmp = (ass & 0x38) >> 3; /* external Amp control */
1202 switch (tmp) {
1203 case 1:
1204 spec->init_amp = ALC_INIT_GPIO1;
1205 break;
1206 case 3:
1207 spec->init_amp = ALC_INIT_GPIO2;
1208 break;
1209 case 7:
1210 spec->init_amp = ALC_INIT_GPIO3;
1211 break;
1212 case 5:
1213 spec->init_amp = ALC_INIT_DEFAULT;
bc9f98a9
KY
1214 break;
1215 }
ea1fb29a 1216
8c427226 1217 /* is laptop or Desktop and enable the function "Mute internal speaker
c9b58006
KY
1218 * when the external headphone out jack is plugged"
1219 */
8c427226 1220 if (!(ass & 0x8000))
4a79ba34 1221 return 1;
c9b58006
KY
1222 /*
1223 * 10~8 : Jack location
1224 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1225 * 14~13: Resvered
1226 * 15 : 1 --> enable the function "Mute internal speaker
1227 * when the external headphone out jack is plugged"
1228 */
c9b58006
KY
1229 if (!spec->autocfg.hp_pins[0]) {
1230 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1231 if (tmp == 0)
1232 spec->autocfg.hp_pins[0] = porta;
1233 else if (tmp == 1)
1234 spec->autocfg.hp_pins[0] = porte;
1235 else if (tmp == 2)
1236 spec->autocfg.hp_pins[0] = portd;
1237 else
4a79ba34 1238 return 1;
c9b58006
KY
1239 }
1240
4a79ba34
TI
1241 alc_init_auto_hp(codec);
1242 return 1;
1243}
ea1fb29a 1244
4a79ba34
TI
1245static void alc_ssid_check(struct hda_codec *codec,
1246 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1247{
1248 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1249 struct alc_spec *spec = codec->spec;
1250 snd_printd("realtek: "
1251 "Enable default setup for auto mode as fallback\n");
1252 spec->init_amp = ALC_INIT_DEFAULT;
1253 alc_init_auto_hp(codec);
1254 }
bc9f98a9
KY
1255}
1256
f95474ec
TI
1257/*
1258 * Fix-up pin default configurations
1259 */
1260
1261struct alc_pincfg {
1262 hda_nid_t nid;
1263 u32 val;
1264};
1265
1266static void alc_fix_pincfg(struct hda_codec *codec,
1267 const struct snd_pci_quirk *quirk,
1268 const struct alc_pincfg **pinfix)
1269{
1270 const struct alc_pincfg *cfg;
1271
1272 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1273 if (!quirk)
1274 return;
1275
1276 cfg = pinfix[quirk->value];
0e8a21b5
TI
1277 for (; cfg->nid; cfg++)
1278 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
f95474ec
TI
1279}
1280
ef8ef5fb
VP
1281/*
1282 * ALC888
1283 */
1284
1285/*
1286 * 2ch mode
1287 */
1288static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1289/* Mic-in jack as mic in */
1290 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1291 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1292/* Line-in jack as Line in */
1293 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1294 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1295/* Line-Out as Front */
1296 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1297 { } /* end */
1298};
1299
1300/*
1301 * 4ch mode
1302 */
1303static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1304/* Mic-in jack as mic in */
1305 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1306 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1307/* Line-in jack as Surround */
1308 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1309 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1310/* Line-Out as Front */
1311 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1312 { } /* end */
1313};
1314
1315/*
1316 * 6ch mode
1317 */
1318static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1319/* Mic-in jack as CLFE */
1320 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1321 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1322/* Line-in jack as Surround */
1323 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1324 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1325/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1326 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1327 { } /* end */
1328};
1329
1330/*
1331 * 8ch mode
1332 */
1333static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1334/* Mic-in jack as CLFE */
1335 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1336 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1337/* Line-in jack as Surround */
1338 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1339 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1340/* Line-Out as Side */
1341 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1342 { } /* end */
1343};
1344
1345static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1346 { 2, alc888_4ST_ch2_intel_init },
1347 { 4, alc888_4ST_ch4_intel_init },
1348 { 6, alc888_4ST_ch6_intel_init },
1349 { 8, alc888_4ST_ch8_intel_init },
1350};
1351
1352/*
1353 * ALC888 Fujitsu Siemens Amillo xa3530
1354 */
1355
1356static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1357/* Front Mic: set to PIN_IN (empty by default) */
1358 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1359/* Connect Internal HP to Front */
1360 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1361 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1362 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1363/* Connect Bass HP to Front */
1364 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1365 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1366 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1367/* Connect Line-Out side jack (SPDIF) to Side */
1368 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1369 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1370 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1371/* Connect Mic jack to CLFE */
1372 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1373 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1374 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1375/* Connect Line-in jack to Surround */
1376 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1377 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1378 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1379/* Connect HP out jack to Front */
1380 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1381 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1382 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1383/* Enable unsolicited event for HP jack and Line-out jack */
1384 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1385 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1386 {}
1387};
1388
a9fd4f3f 1389static void alc_automute_amp(struct hda_codec *codec)
ef8ef5fb 1390{
a9fd4f3f 1391 struct alc_spec *spec = codec->spec;
261c2407 1392 unsigned int val, mute, pincap;
a9fd4f3f
TI
1393 hda_nid_t nid;
1394 int i;
1395
1396 spec->jack_present = 0;
1397 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1398 nid = spec->autocfg.hp_pins[i];
1399 if (!nid)
1400 break;
261c2407
TI
1401 pincap = snd_hda_query_pin_caps(codec, nid);
1402 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1403 snd_hda_codec_read(codec, nid, 0,
1404 AC_VERB_SET_PIN_SENSE, 0);
a9fd4f3f
TI
1405 val = snd_hda_codec_read(codec, nid, 0,
1406 AC_VERB_GET_PIN_SENSE, 0);
1407 if (val & AC_PINSENSE_PRESENCE) {
1408 spec->jack_present = 1;
1409 break;
1410 }
1411 }
1412
1413 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
ef8ef5fb 1414 /* Toggle internal speakers muting */
a9fd4f3f
TI
1415 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1416 nid = spec->autocfg.speaker_pins[i];
1417 if (!nid)
1418 break;
1419 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1420 HDA_AMP_MUTE, mute);
1421 }
ef8ef5fb
VP
1422}
1423
a9fd4f3f
TI
1424static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1425 unsigned int res)
ef8ef5fb 1426{
a9fd4f3f
TI
1427 if (codec->vendor_id == 0x10ec0880)
1428 res >>= 28;
1429 else
1430 res >>= 26;
1431 if (res == ALC880_HP_EVENT)
1432 alc_automute_amp(codec);
ef8ef5fb
VP
1433}
1434
a9fd4f3f
TI
1435static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1436{
1437 struct alc_spec *spec = codec->spec;
1438
1439 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1440 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1441 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1442 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1443 alc_automute_amp(codec);
1444}
ef8ef5fb 1445
5b2d1eca
VP
1446/*
1447 * ALC888 Acer Aspire 4930G model
1448 */
1449
1450static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1451/* Front Mic: set to PIN_IN (empty by default) */
1452 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1453/* Unselect Front Mic by default in input mixer 3 */
1454 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
ef8ef5fb 1455/* Enable unsolicited event for HP jack */
5b2d1eca
VP
1456 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1457/* Connect Internal HP to front */
1458 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1459 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1460 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1461/* Connect HP out to front */
1462 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1463 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1464 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1465 { }
1466};
1467
d2fd4b09
TV
1468/*
1469 * ALC888 Acer Aspire 6530G model
1470 */
1471
1472static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1473/* Bias voltage on for external mic port */
1474 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
320d5920
EL
1475/* Front Mic: set to PIN_IN (empty by default) */
1476 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1477/* Unselect Front Mic by default in input mixer 3 */
1478 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
d2fd4b09
TV
1479/* Enable unsolicited event for HP jack */
1480 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1481/* Enable speaker output */
1482 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1483 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1484/* Enable headphone output */
1485 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1486 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1487 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1488 { }
1489};
1490
3b315d70 1491/*
018df418 1492 * ALC889 Acer Aspire 8930G model
3b315d70
HM
1493 */
1494
018df418 1495static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
3b315d70
HM
1496/* Front Mic: set to PIN_IN (empty by default) */
1497 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1498/* Unselect Front Mic by default in input mixer 3 */
1499 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1500/* Enable unsolicited event for HP jack */
1501 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1502/* Connect Internal Front to Front */
1503 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1504 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1505 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1506/* Connect Internal Rear to Rear */
1507 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1508 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1509 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1510/* Connect Internal CLFE to CLFE */
1511 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1512 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1513 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1514/* Connect HP out to Front */
018df418 1515 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
3b315d70
HM
1516 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1517 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1518/* Enable all DACs */
1519/* DAC DISABLE/MUTE 1? */
1520/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1521 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1522 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1523/* DAC DISABLE/MUTE 2? */
1524/* some bit here disables the other DACs. Init=0x4900 */
1525 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1526 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1527/* Enable amplifiers */
1528 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1529 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
018df418
HM
1530/* DMIC fix
1531 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1532 * which makes the stereo useless. However, either the mic or the ALC889
1533 * makes the signal become a difference/sum signal instead of standard
1534 * stereo, which is annoying. So instead we flip this bit which makes the
1535 * codec replicate the sum signal to both channels, turning it into a
1536 * normal mono mic.
1537 */
1538/* DMIC_CONTROL? Init value = 0x0001 */
1539 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1540 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
3b315d70
HM
1541 { }
1542};
1543
ef8ef5fb 1544static struct hda_input_mux alc888_2_capture_sources[2] = {
5b2d1eca
VP
1545 /* Front mic only available on one ADC */
1546 {
1547 .num_items = 4,
1548 .items = {
1549 { "Mic", 0x0 },
1550 { "Line", 0x2 },
1551 { "CD", 0x4 },
1552 { "Front Mic", 0xb },
1553 },
1554 },
1555 {
1556 .num_items = 3,
1557 .items = {
1558 { "Mic", 0x0 },
1559 { "Line", 0x2 },
1560 { "CD", 0x4 },
1561 },
1562 }
1563};
1564
d2fd4b09
TV
1565static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1566 /* Interal mic only available on one ADC */
1567 {
684a8842 1568 .num_items = 5,
d2fd4b09
TV
1569 .items = {
1570 { "Ext Mic", 0x0 },
684a8842 1571 { "Line In", 0x2 },
d2fd4b09 1572 { "CD", 0x4 },
684a8842 1573 { "Input Mix", 0xa },
d2fd4b09
TV
1574 { "Int Mic", 0xb },
1575 },
1576 },
1577 {
684a8842 1578 .num_items = 4,
d2fd4b09
TV
1579 .items = {
1580 { "Ext Mic", 0x0 },
684a8842 1581 { "Line In", 0x2 },
d2fd4b09 1582 { "CD", 0x4 },
684a8842 1583 { "Input Mix", 0xa },
d2fd4b09
TV
1584 },
1585 }
1586};
1587
018df418
HM
1588static struct hda_input_mux alc889_capture_sources[3] = {
1589 /* Digital mic only available on first "ADC" */
1590 {
1591 .num_items = 5,
1592 .items = {
1593 { "Mic", 0x0 },
1594 { "Line", 0x2 },
1595 { "CD", 0x4 },
1596 { "Front Mic", 0xb },
1597 { "Input Mix", 0xa },
1598 },
1599 },
1600 {
1601 .num_items = 4,
1602 .items = {
1603 { "Mic", 0x0 },
1604 { "Line", 0x2 },
1605 { "CD", 0x4 },
1606 { "Input Mix", 0xa },
1607 },
1608 },
1609 {
1610 .num_items = 4,
1611 .items = {
1612 { "Mic", 0x0 },
1613 { "Line", 0x2 },
1614 { "CD", 0x4 },
1615 { "Input Mix", 0xa },
1616 },
1617 }
1618};
1619
ef8ef5fb 1620static struct snd_kcontrol_new alc888_base_mixer[] = {
5b2d1eca
VP
1621 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1622 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1623 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1624 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1625 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1626 HDA_OUTPUT),
1627 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1628 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1629 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1630 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1631 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1632 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1633 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1634 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1635 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1637 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1638 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5b2d1eca
VP
1639 { } /* end */
1640};
1641
a9fd4f3f 1642static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
5b2d1eca 1643{
a9fd4f3f 1644 struct alc_spec *spec = codec->spec;
5b2d1eca 1645
a9fd4f3f
TI
1646 spec->autocfg.hp_pins[0] = 0x15;
1647 spec->autocfg.speaker_pins[0] = 0x14;
1648 alc_automute_amp(codec);
5b2d1eca
VP
1649}
1650
320d5920
EL
1651static void alc888_acer_aspire_6530g_init_hook(struct hda_codec *codec)
1652{
1653 struct alc_spec *spec = codec->spec;
1654
1655 spec->autocfg.hp_pins[0] = 0x15;
1656 spec->autocfg.speaker_pins[0] = 0x14;
1657 spec->autocfg.speaker_pins[1] = 0x16;
1658 spec->autocfg.speaker_pins[2] = 0x17;
1659 alc_automute_amp(codec);
1660}
1661
018df418 1662static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
3b315d70
HM
1663{
1664 struct alc_spec *spec = codec->spec;
1665
1666 spec->autocfg.hp_pins[0] = 0x15;
1667 spec->autocfg.speaker_pins[0] = 0x14;
1668 spec->autocfg.speaker_pins[1] = 0x16;
1669 spec->autocfg.speaker_pins[2] = 0x1b;
1670 alc_automute_amp(codec);
1671}
1672
1da177e4 1673/*
e9edcee0
TI
1674 * ALC880 3-stack model
1675 *
1676 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
9c7f852e
TI
1677 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1678 * F-Mic = 0x1b, HP = 0x19
1da177e4
LT
1679 */
1680
e9edcee0
TI
1681static hda_nid_t alc880_dac_nids[4] = {
1682 /* front, rear, clfe, rear_surr */
1683 0x02, 0x05, 0x04, 0x03
1684};
1685
1686static hda_nid_t alc880_adc_nids[3] = {
1687 /* ADC0-2 */
1688 0x07, 0x08, 0x09,
1689};
1690
1691/* The datasheet says the node 0x07 is connected from inputs,
1692 * but it shows zero connection in the real implementation on some devices.
df694daa 1693 * Note: this is a 915GAV bug, fixed on 915GLV
1da177e4 1694 */
e9edcee0
TI
1695static hda_nid_t alc880_adc_nids_alt[2] = {
1696 /* ADC1-2 */
1697 0x08, 0x09,
1698};
1699
1700#define ALC880_DIGOUT_NID 0x06
1701#define ALC880_DIGIN_NID 0x0a
1702
1703static struct hda_input_mux alc880_capture_source = {
1704 .num_items = 4,
1705 .items = {
1706 { "Mic", 0x0 },
1707 { "Front Mic", 0x3 },
1708 { "Line", 0x2 },
1709 { "CD", 0x4 },
1710 },
1711};
1712
1713/* channel source setting (2/6 channel selection for 3-stack) */
1714/* 2ch mode */
1715static struct hda_verb alc880_threestack_ch2_init[] = {
1716 /* set line-in to input, mute it */
1717 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1718 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1719 /* set mic-in to input vref 80%, mute it */
1720 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1721 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1722 { } /* end */
1723};
1724
1725/* 6ch mode */
1726static struct hda_verb alc880_threestack_ch6_init[] = {
1727 /* set line-in to output, unmute it */
1728 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1729 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1730 /* set mic-in to output, unmute it */
1731 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1732 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1733 { } /* end */
1734};
1735
d2a6d7dc 1736static struct hda_channel_mode alc880_threestack_modes[2] = {
e9edcee0
TI
1737 { 2, alc880_threestack_ch2_init },
1738 { 6, alc880_threestack_ch6_init },
1739};
1740
c8b6bf9b 1741static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
05acb863 1742 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
985be54b 1743 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
05acb863 1744 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
985be54b 1745 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
05acb863
TI
1746 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1747 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
985be54b
TI
1748 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1749 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1da177e4
LT
1750 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1751 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1752 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1753 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1754 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1755 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1756 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1757 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
e9edcee0
TI
1758 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1759 {
1760 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1761 .name = "Channel Mode",
df694daa
KY
1762 .info = alc_ch_mode_info,
1763 .get = alc_ch_mode_get,
1764 .put = alc_ch_mode_put,
e9edcee0
TI
1765 },
1766 { } /* end */
1767};
1768
1769/* capture mixer elements */
f9e336f6
TI
1770static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1771 struct snd_ctl_elem_info *uinfo)
1772{
1773 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1774 struct alc_spec *spec = codec->spec;
1775 int err;
1da177e4 1776
5a9e02e9 1777 mutex_lock(&codec->control_mutex);
f9e336f6
TI
1778 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1779 HDA_INPUT);
1780 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
5a9e02e9 1781 mutex_unlock(&codec->control_mutex);
f9e336f6
TI
1782 return err;
1783}
1784
1785static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1786 unsigned int size, unsigned int __user *tlv)
1787{
1788 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1789 struct alc_spec *spec = codec->spec;
1790 int err;
1da177e4 1791
5a9e02e9 1792 mutex_lock(&codec->control_mutex);
f9e336f6
TI
1793 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1794 HDA_INPUT);
1795 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
5a9e02e9 1796 mutex_unlock(&codec->control_mutex);
f9e336f6
TI
1797 return err;
1798}
1799
1800typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1801 struct snd_ctl_elem_value *ucontrol);
1802
1803static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1804 struct snd_ctl_elem_value *ucontrol,
1805 getput_call_t func)
1806{
1807 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1808 struct alc_spec *spec = codec->spec;
1809 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1810 int err;
1811
5a9e02e9 1812 mutex_lock(&codec->control_mutex);
f9e336f6
TI
1813 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1814 3, 0, HDA_INPUT);
1815 err = func(kcontrol, ucontrol);
5a9e02e9 1816 mutex_unlock(&codec->control_mutex);
f9e336f6
TI
1817 return err;
1818}
1819
1820static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1821 struct snd_ctl_elem_value *ucontrol)
1822{
1823 return alc_cap_getput_caller(kcontrol, ucontrol,
1824 snd_hda_mixer_amp_volume_get);
1825}
1826
1827static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1828 struct snd_ctl_elem_value *ucontrol)
1829{
1830 return alc_cap_getput_caller(kcontrol, ucontrol,
1831 snd_hda_mixer_amp_volume_put);
1832}
1833
1834/* capture mixer elements */
1835#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1836
1837static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1838 struct snd_ctl_elem_value *ucontrol)
1839{
1840 return alc_cap_getput_caller(kcontrol, ucontrol,
1841 snd_hda_mixer_amp_switch_get);
1842}
1843
1844static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1845 struct snd_ctl_elem_value *ucontrol)
1846{
1847 return alc_cap_getput_caller(kcontrol, ucontrol,
1848 snd_hda_mixer_amp_switch_put);
1849}
1850
a23b688f 1851#define _DEFINE_CAPMIX(num) \
f9e336f6
TI
1852 { \
1853 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1854 .name = "Capture Switch", \
1855 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1856 .count = num, \
1857 .info = alc_cap_sw_info, \
1858 .get = alc_cap_sw_get, \
1859 .put = alc_cap_sw_put, \
1860 }, \
1861 { \
1862 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1863 .name = "Capture Volume", \
1864 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1865 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1866 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1867 .count = num, \
1868 .info = alc_cap_vol_info, \
1869 .get = alc_cap_vol_get, \
1870 .put = alc_cap_vol_put, \
1871 .tlv = { .c = alc_cap_vol_tlv }, \
a23b688f
TI
1872 }
1873
1874#define _DEFINE_CAPSRC(num) \
3c3e9892
TI
1875 { \
1876 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1877 /* .name = "Capture Source", */ \
1878 .name = "Input Source", \
1879 .count = num, \
1880 .info = alc_mux_enum_info, \
1881 .get = alc_mux_enum_get, \
1882 .put = alc_mux_enum_put, \
a23b688f
TI
1883 }
1884
1885#define DEFINE_CAPMIX(num) \
1886static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1887 _DEFINE_CAPMIX(num), \
1888 _DEFINE_CAPSRC(num), \
1889 { } /* end */ \
1890}
1891
1892#define DEFINE_CAPMIX_NOSRC(num) \
1893static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1894 _DEFINE_CAPMIX(num), \
1895 { } /* end */ \
f9e336f6
TI
1896}
1897
1898/* up to three ADCs */
1899DEFINE_CAPMIX(1);
1900DEFINE_CAPMIX(2);
1901DEFINE_CAPMIX(3);
a23b688f
TI
1902DEFINE_CAPMIX_NOSRC(1);
1903DEFINE_CAPMIX_NOSRC(2);
1904DEFINE_CAPMIX_NOSRC(3);
e9edcee0
TI
1905
1906/*
1907 * ALC880 5-stack model
1908 *
9c7f852e
TI
1909 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1910 * Side = 0x02 (0xd)
e9edcee0
TI
1911 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1912 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1913 */
1914
1915/* additional mixers to alc880_three_stack_mixer */
c8b6bf9b 1916static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
e9edcee0 1917 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
985be54b 1918 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
1da177e4
LT
1919 { } /* end */
1920};
1921
e9edcee0
TI
1922/* channel source setting (6/8 channel selection for 5-stack) */
1923/* 6ch mode */
1924static struct hda_verb alc880_fivestack_ch6_init[] = {
1925 /* set line-in to input, mute it */
1926 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1927 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
dfc0ff62
TI
1928 { } /* end */
1929};
1930
e9edcee0
TI
1931/* 8ch mode */
1932static struct hda_verb alc880_fivestack_ch8_init[] = {
1933 /* set line-in to output, unmute it */
1934 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1935 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1936 { } /* end */
1937};
1938
d2a6d7dc 1939static struct hda_channel_mode alc880_fivestack_modes[2] = {
e9edcee0
TI
1940 { 6, alc880_fivestack_ch6_init },
1941 { 8, alc880_fivestack_ch8_init },
1942};
1943
1944
1945/*
1946 * ALC880 6-stack model
1947 *
9c7f852e
TI
1948 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1949 * Side = 0x05 (0x0f)
e9edcee0
TI
1950 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1951 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1952 */
1953
1954static hda_nid_t alc880_6st_dac_nids[4] = {
1955 /* front, rear, clfe, rear_surr */
1956 0x02, 0x03, 0x04, 0x05
f12ab1e0 1957};
e9edcee0
TI
1958
1959static struct hda_input_mux alc880_6stack_capture_source = {
1960 .num_items = 4,
1961 .items = {
1962 { "Mic", 0x0 },
1963 { "Front Mic", 0x1 },
1964 { "Line", 0x2 },
1965 { "CD", 0x4 },
1966 },
1967};
1968
1969/* fixed 8-channels */
d2a6d7dc 1970static struct hda_channel_mode alc880_sixstack_modes[1] = {
e9edcee0
TI
1971 { 8, NULL },
1972};
1973
c8b6bf9b 1974static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
16ded525 1975 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
985be54b 1976 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16ded525 1977 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
985be54b 1978 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16ded525
TI
1979 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1980 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
985be54b
TI
1981 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1982 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16ded525 1983 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
985be54b 1984 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16ded525
TI
1985 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1986 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1987 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1988 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1989 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1990 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1991 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1992 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16ded525
TI
1993 {
1994 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1995 .name = "Channel Mode",
df694daa
KY
1996 .info = alc_ch_mode_info,
1997 .get = alc_ch_mode_get,
1998 .put = alc_ch_mode_put,
16ded525
TI
1999 },
2000 { } /* end */
2001};
2002
e9edcee0
TI
2003
2004/*
2005 * ALC880 W810 model
2006 *
2007 * W810 has rear IO for:
2008 * Front (DAC 02)
2009 * Surround (DAC 03)
2010 * Center/LFE (DAC 04)
2011 * Digital out (06)
2012 *
2013 * The system also has a pair of internal speakers, and a headphone jack.
2014 * These are both connected to Line2 on the codec, hence to DAC 02.
ea1fb29a 2015 *
e9edcee0
TI
2016 * There is a variable resistor to control the speaker or headphone
2017 * volume. This is a hardware-only device without a software API.
2018 *
2019 * Plugging headphones in will disable the internal speakers. This is
2020 * implemented in hardware, not via the driver using jack sense. In
2021 * a similar fashion, plugging into the rear socket marked "front" will
2022 * disable both the speakers and headphones.
2023 *
2024 * For input, there's a microphone jack, and an "audio in" jack.
2025 * These may not do anything useful with this driver yet, because I
2026 * haven't setup any initialization verbs for these yet...
2027 */
2028
2029static hda_nid_t alc880_w810_dac_nids[3] = {
2030 /* front, rear/surround, clfe */
2031 0x02, 0x03, 0x04
16ded525
TI
2032};
2033
e9edcee0 2034/* fixed 6 channels */
d2a6d7dc 2035static struct hda_channel_mode alc880_w810_modes[1] = {
e9edcee0
TI
2036 { 6, NULL }
2037};
2038
2039/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
c8b6bf9b 2040static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
16ded525 2041 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
985be54b 2042 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16ded525 2043 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
985be54b 2044 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16ded525
TI
2045 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2046 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
985be54b
TI
2047 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2048 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
e9edcee0
TI
2049 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2050 { } /* end */
2051};
2052
2053
2054/*
2055 * Z710V model
2056 *
2057 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
9c7f852e
TI
2058 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2059 * Line = 0x1a
e9edcee0
TI
2060 */
2061
2062static hda_nid_t alc880_z71v_dac_nids[1] = {
2063 0x02
2064};
2065#define ALC880_Z71V_HP_DAC 0x03
2066
2067/* fixed 2 channels */
d2a6d7dc 2068static struct hda_channel_mode alc880_2_jack_modes[1] = {
e9edcee0
TI
2069 { 2, NULL }
2070};
2071
c8b6bf9b 2072static struct snd_kcontrol_new alc880_z71v_mixer[] = {
e9edcee0 2073 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
985be54b 2074 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
e9edcee0 2075 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
985be54b 2076 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16ded525
TI
2077 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2078 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16ded525
TI
2079 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2080 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16ded525
TI
2081 { } /* end */
2082};
2083
e9edcee0 2084
e9edcee0
TI
2085/*
2086 * ALC880 F1734 model
2087 *
2088 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2089 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2090 */
2091
2092static hda_nid_t alc880_f1734_dac_nids[1] = {
2093 0x03
2094};
2095#define ALC880_F1734_HP_DAC 0x02
2096
c8b6bf9b 2097static struct snd_kcontrol_new alc880_f1734_mixer[] = {
e9edcee0 2098 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
985be54b 2099 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2134ea4f
TI
2100 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2101 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
e9edcee0
TI
2102 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2103 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
937b4160
TI
2104 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2105 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
e9edcee0
TI
2106 { } /* end */
2107};
2108
937b4160
TI
2109static struct hda_input_mux alc880_f1734_capture_source = {
2110 .num_items = 2,
2111 .items = {
2112 { "Mic", 0x1 },
2113 { "CD", 0x4 },
2114 },
2115};
2116
e9edcee0 2117
e9edcee0
TI
2118/*
2119 * ALC880 ASUS model
2120 *
2121 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2122 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2123 * Mic = 0x18, Line = 0x1a
2124 */
2125
2126#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2127#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2128
c8b6bf9b 2129static struct snd_kcontrol_new alc880_asus_mixer[] = {
16ded525 2130 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
985be54b 2131 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16ded525 2132 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
985be54b 2133 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16ded525
TI
2134 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2135 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
985be54b
TI
2136 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2137 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16ded525
TI
2138 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2139 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2140 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2141 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16ded525
TI
2142 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2143 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16ded525
TI
2144 {
2145 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2146 .name = "Channel Mode",
df694daa
KY
2147 .info = alc_ch_mode_info,
2148 .get = alc_ch_mode_get,
2149 .put = alc_ch_mode_put,
16ded525
TI
2150 },
2151 { } /* end */
2152};
e9edcee0 2153
e9edcee0
TI
2154/*
2155 * ALC880 ASUS W1V model
2156 *
2157 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2158 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2159 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2160 */
2161
2162/* additional mixers to alc880_asus_mixer */
c8b6bf9b 2163static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
e9edcee0
TI
2164 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2165 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
2166 { } /* end */
2167};
2168
df694daa
KY
2169/* TCL S700 */
2170static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2171 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2172 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2173 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2174 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2175 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2177 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2178 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2179 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
df694daa
KY
2180 { } /* end */
2181};
2182
ccc656ce
KY
2183/* Uniwill */
2184static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
2134ea4f
TI
2185 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2186 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2187 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2188 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
ccc656ce
KY
2189 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2190 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2191 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2192 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2193 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2194 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2195 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2196 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2197 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2198 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2199 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2200 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
ccc656ce
KY
2201 {
2202 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2203 .name = "Channel Mode",
2204 .info = alc_ch_mode_info,
2205 .get = alc_ch_mode_get,
2206 .put = alc_ch_mode_put,
2207 },
2208 { } /* end */
2209};
2210
2cf9f0fc
TD
2211static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2212 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2213 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2214 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2215 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2216 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2217 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2218 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2219 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2220 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2221 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2222 { } /* end */
2223};
2224
ccc656ce 2225static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
2134ea4f
TI
2226 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2227 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2228 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2229 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
ccc656ce
KY
2230 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2231 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2232 { } /* end */
2233};
2234
2134ea4f
TI
2235/*
2236 * virtual master controls
2237 */
2238
2239/*
2240 * slave controls for virtual master
2241 */
2242static const char *alc_slave_vols[] = {
2243 "Front Playback Volume",
2244 "Surround Playback Volume",
2245 "Center Playback Volume",
2246 "LFE Playback Volume",
2247 "Side Playback Volume",
2248 "Headphone Playback Volume",
2249 "Speaker Playback Volume",
2250 "Mono Playback Volume",
2134ea4f 2251 "Line-Out Playback Volume",
26f5df26 2252 "PCM Playback Volume",
2134ea4f
TI
2253 NULL,
2254};
2255
2256static const char *alc_slave_sws[] = {
2257 "Front Playback Switch",
2258 "Surround Playback Switch",
2259 "Center Playback Switch",
2260 "LFE Playback Switch",
2261 "Side Playback Switch",
2262 "Headphone Playback Switch",
2263 "Speaker Playback Switch",
2264 "Mono Playback Switch",
edb54a55 2265 "IEC958 Playback Switch",
2134ea4f
TI
2266 NULL,
2267};
2268
1da177e4 2269/*
e9edcee0 2270 * build control elements
1da177e4 2271 */
603c4019
TI
2272
2273static void alc_free_kctls(struct hda_codec *codec);
2274
45bdd1c1
TI
2275/* additional beep mixers; the actual parameters are overwritten at build */
2276static struct snd_kcontrol_new alc_beep_mixer[] = {
2277 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2278 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2279 { } /* end */
2280};
2281
1da177e4
LT
2282static int alc_build_controls(struct hda_codec *codec)
2283{
2284 struct alc_spec *spec = codec->spec;
2285 int err;
2286 int i;
2287
2288 for (i = 0; i < spec->num_mixers; i++) {
2289 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2290 if (err < 0)
2291 return err;
2292 }
f9e336f6
TI
2293 if (spec->cap_mixer) {
2294 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2295 if (err < 0)
2296 return err;
2297 }
1da177e4 2298 if (spec->multiout.dig_out_nid) {
9c7f852e
TI
2299 err = snd_hda_create_spdif_out_ctls(codec,
2300 spec->multiout.dig_out_nid);
1da177e4
LT
2301 if (err < 0)
2302 return err;
e64f14f4
TI
2303 if (!spec->no_analog) {
2304 err = snd_hda_create_spdif_share_sw(codec,
2305 &spec->multiout);
2306 if (err < 0)
2307 return err;
2308 spec->multiout.share_spdif = 1;
2309 }
1da177e4
LT
2310 }
2311 if (spec->dig_in_nid) {
2312 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2313 if (err < 0)
2314 return err;
2315 }
2134ea4f 2316
45bdd1c1
TI
2317 /* create beep controls if needed */
2318 if (spec->beep_amp) {
2319 struct snd_kcontrol_new *knew;
2320 for (knew = alc_beep_mixer; knew->name; knew++) {
2321 struct snd_kcontrol *kctl;
2322 kctl = snd_ctl_new1(knew, codec);
2323 if (!kctl)
2324 return -ENOMEM;
2325 kctl->private_value = spec->beep_amp;
2326 err = snd_hda_ctl_add(codec, kctl);
2327 if (err < 0)
2328 return err;
2329 }
2330 }
2331
2134ea4f 2332 /* if we have no master control, let's create it */
e64f14f4
TI
2333 if (!spec->no_analog &&
2334 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1c82ed1b 2335 unsigned int vmaster_tlv[4];
2134ea4f 2336 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1c82ed1b 2337 HDA_OUTPUT, vmaster_tlv);
2134ea4f 2338 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1c82ed1b 2339 vmaster_tlv, alc_slave_vols);
2134ea4f
TI
2340 if (err < 0)
2341 return err;
2342 }
e64f14f4
TI
2343 if (!spec->no_analog &&
2344 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2134ea4f
TI
2345 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2346 NULL, alc_slave_sws);
2347 if (err < 0)
2348 return err;
2349 }
2350
603c4019 2351 alc_free_kctls(codec); /* no longer needed */
1da177e4
LT
2352 return 0;
2353}
2354
e9edcee0 2355
1da177e4
LT
2356/*
2357 * initialize the codec volumes, etc
2358 */
2359
e9edcee0
TI
2360/*
2361 * generic initialization of ADC, input mixers and output mixers
2362 */
2363static struct hda_verb alc880_volume_init_verbs[] = {
2364 /*
2365 * Unmute ADC0-2 and set the default input to mic-in
2366 */
71fe7b82 2367 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
e9edcee0 2368 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
71fe7b82 2369 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
e9edcee0 2370 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
71fe7b82 2371 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
e9edcee0 2372 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1da177e4 2373
e9edcee0
TI
2374 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2375 * mixer widget
9c7f852e
TI
2376 * Note: PASD motherboards uses the Line In 2 as the input for front
2377 * panel mic (mic 2)
1da177e4 2378 */
e9edcee0 2379 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
cb53c626
TI
2380 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2381 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2382 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2383 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2384 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2385 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2386 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1da177e4 2387
e9edcee0
TI
2388 /*
2389 * Set up output mixers (0x0c - 0x0f)
1da177e4 2390 */
e9edcee0
TI
2391 /* set vol=0 to output mixers */
2392 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2393 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2394 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2395 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2396 /* set up input amps for analog loopback */
2397 /* Amp Indices: DAC = 0, mixer = 1 */
05acb863
TI
2398 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2399 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
05acb863
TI
2400 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2401 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
05acb863
TI
2402 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2403 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
05acb863
TI
2404 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2405 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1da177e4
LT
2406
2407 { }
2408};
2409
e9edcee0
TI
2410/*
2411 * 3-stack pin configuration:
2412 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2413 */
2414static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2415 /*
2416 * preset connection lists of input pins
2417 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2418 */
2419 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2420 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2421 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2422
2423 /*
2424 * Set pin mode and muting
2425 */
2426 /* set front pin widgets 0x14 for output */
05acb863 2427 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
e9edcee0
TI
2428 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2429 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2430 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2431 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2432 /* Mic2 (as headphone out) for HP output */
2433 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2434 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1da177e4 2435 /* Line In pin widget for input */
05acb863 2436 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
e9edcee0
TI
2437 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2438 /* Line2 (as front mic) pin widget for input and vref at 80% */
2439 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2440 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1da177e4 2441 /* CD pin widget for input */
05acb863 2442 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1da177e4 2443
e9edcee0
TI
2444 { }
2445};
1da177e4 2446
e9edcee0
TI
2447/*
2448 * 5-stack pin configuration:
2449 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2450 * line-in/side = 0x1a, f-mic = 0x1b
2451 */
2452static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2453 /*
2454 * preset connection lists of input pins
2455 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1da177e4 2456 */
e9edcee0
TI
2457 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2458 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1da177e4 2459
e9edcee0
TI
2460 /*
2461 * Set pin mode and muting
1da177e4 2462 */
e9edcee0
TI
2463 /* set pin widgets 0x14-0x17 for output */
2464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2465 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2466 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2467 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2468 /* unmute pins for output (no gain on this amp) */
2469 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2470 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2471 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2472 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2473
2474 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2475 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2476 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2477 /* Mic2 (as headphone out) for HP output */
2478 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2479 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2480 /* Line In pin widget for input */
2481 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2482 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2483 /* Line2 (as front mic) pin widget for input and vref at 80% */
2484 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2485 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2486 /* CD pin widget for input */
2487 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1da177e4
LT
2488
2489 { }
2490};
2491
e9edcee0
TI
2492/*
2493 * W810 pin configuration:
2494 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2495 */
2496static struct hda_verb alc880_pin_w810_init_verbs[] = {
2497 /* hphone/speaker input selector: front DAC */
2498 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1da177e4 2499
05acb863 2500 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
e9edcee0 2501 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
05acb863 2502 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
e9edcee0 2503 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
05acb863 2504 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
e9edcee0 2505 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1da177e4 2506
e9edcee0 2507 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
05acb863 2508 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1da177e4 2509
1da177e4
LT
2510 { }
2511};
2512
e9edcee0
TI
2513/*
2514 * Z71V pin configuration:
2515 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2516 */
2517static struct hda_verb alc880_pin_z71v_init_verbs[] = {
05acb863 2518 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
e9edcee0 2519 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
05acb863 2520 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
e9edcee0 2521 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
dfc0ff62 2522
16ded525 2523 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
e9edcee0 2524 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16ded525 2525 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
e9edcee0 2526 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16ded525
TI
2527
2528 { }
2529};
2530
e9edcee0
TI
2531/*
2532 * 6-stack pin configuration:
9c7f852e
TI
2533 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2534 * f-mic = 0x19, line = 0x1a, HP = 0x1b
e9edcee0
TI
2535 */
2536static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2537 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2538
16ded525 2539 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
e9edcee0 2540 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16ded525 2541 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
e9edcee0 2542 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16ded525 2543 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
e9edcee0 2544 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16ded525 2545 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
e9edcee0
TI
2546 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2547
16ded525 2548 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
e9edcee0 2549 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16ded525 2550 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
e9edcee0 2551 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16ded525 2552 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
e9edcee0 2553 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16ded525 2554 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
e9edcee0 2555 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16ded525 2556 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
ea1fb29a 2557
e9edcee0
TI
2558 { }
2559};
2560
ccc656ce
KY
2561/*
2562 * Uniwill pin configuration:
2563 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2564 * line = 0x1a
2565 */
2566static struct hda_verb alc880_uniwill_init_verbs[] = {
2567 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2568
2569 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2570 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2571 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2572 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2573 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2574 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2575 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2576 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2577 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2578 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2579 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2580 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2581 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2582 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2583
2584 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2585 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2586 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2587 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2588 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2589 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2590 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2591 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2592 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2593
2594 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2595 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2596
2597 { }
2598};
2599
2600/*
2601* Uniwill P53
ea1fb29a 2602* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
ccc656ce
KY
2603 */
2604static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2605 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2606
2607 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2608 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2609 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2610 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2611 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2612 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2613 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2614 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2615 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2616 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2617 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2618 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2619
2620 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2621 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2622 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2623 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2624 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2625 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2626
2627 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2628 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2629
2630 { }
2631};
2632
2cf9f0fc
TD
2633static struct hda_verb alc880_beep_init_verbs[] = {
2634 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2635 { }
2636};
2637
458a4fab
TI
2638/* auto-toggle front mic */
2639static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2640{
2641 unsigned int present;
2642 unsigned char bits;
ccc656ce
KY
2643
2644 present = snd_hda_codec_read(codec, 0x18, 0,
2645 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
47fd830a
TI
2646 bits = present ? HDA_AMP_MUTE : 0;
2647 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
458a4fab
TI
2648}
2649
a9fd4f3f 2650static void alc880_uniwill_init_hook(struct hda_codec *codec)
458a4fab 2651{
a9fd4f3f
TI
2652 struct alc_spec *spec = codec->spec;
2653
2654 spec->autocfg.hp_pins[0] = 0x14;
2655 spec->autocfg.speaker_pins[0] = 0x15;
2656 spec->autocfg.speaker_pins[0] = 0x16;
2657 alc_automute_amp(codec);
458a4fab 2658 alc880_uniwill_mic_automute(codec);
ccc656ce
KY
2659}
2660
2661static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2662 unsigned int res)
2663{
2664 /* Looks like the unsol event is incompatible with the standard
2665 * definition. 4bit tag is placed at 28 bit!
2666 */
458a4fab 2667 switch (res >> 28) {
458a4fab
TI
2668 case ALC880_MIC_EVENT:
2669 alc880_uniwill_mic_automute(codec);
2670 break;
a9fd4f3f
TI
2671 default:
2672 alc_automute_amp_unsol_event(codec, res);
2673 break;
458a4fab 2674 }
ccc656ce
KY
2675}
2676
a9fd4f3f 2677static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
ccc656ce 2678{
a9fd4f3f 2679 struct alc_spec *spec = codec->spec;
ccc656ce 2680
a9fd4f3f
TI
2681 spec->autocfg.hp_pins[0] = 0x14;
2682 spec->autocfg.speaker_pins[0] = 0x15;
2683 alc_automute_amp(codec);
ccc656ce
KY
2684}
2685
2686static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2687{
2688 unsigned int present;
ea1fb29a 2689
ccc656ce 2690 present = snd_hda_codec_read(codec, 0x21, 0,
47fd830a
TI
2691 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2692 present &= HDA_AMP_VOLMASK;
2693 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2694 HDA_AMP_VOLMASK, present);
2695 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2696 HDA_AMP_VOLMASK, present);
ccc656ce 2697}
47fd830a 2698
ccc656ce
KY
2699static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2700 unsigned int res)
2701{
2702 /* Looks like the unsol event is incompatible with the standard
2703 * definition. 4bit tag is placed at 28 bit!
2704 */
f12ab1e0 2705 if ((res >> 28) == ALC880_DCVOL_EVENT)
ccc656ce 2706 alc880_uniwill_p53_dcvol_automute(codec);
a9fd4f3f
TI
2707 else
2708 alc_automute_amp_unsol_event(codec, res);
ccc656ce
KY
2709}
2710
e9edcee0
TI
2711/*
2712 * F1734 pin configuration:
2713 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2714 */
2715static struct hda_verb alc880_pin_f1734_init_verbs[] = {
ee7a9c7c 2716 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
16ded525
TI
2717 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2718 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2719 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2720 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2721
e9edcee0 2722 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16ded525 2723 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
e9edcee0 2724 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16ded525 2725 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16ded525 2726
e9edcee0
TI
2727 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2728 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
ee7a9c7c 2729 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
e9edcee0 2730 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16ded525 2731 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
e9edcee0 2732 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16ded525 2733 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
e9edcee0 2734 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16ded525 2735 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
dfc0ff62 2736
937b4160
TI
2737 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2738 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2739
dfc0ff62
TI
2740 { }
2741};
2742
e9edcee0
TI
2743/*
2744 * ASUS pin configuration:
2745 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2746 */
2747static struct hda_verb alc880_pin_asus_init_verbs[] = {
16ded525
TI
2748 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2749 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2750 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2751 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2752
2753 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
e9edcee0 2754 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16ded525 2755 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
e9edcee0 2756 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16ded525 2757 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
e9edcee0 2758 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16ded525 2759 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
e9edcee0
TI
2760 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2761
2762 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2763 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2764 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2765 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2766 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2767 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16ded525 2768 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
e9edcee0 2769 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16ded525 2770 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
ea1fb29a 2771
e9edcee0
TI
2772 { }
2773};
16ded525 2774
e9edcee0 2775/* Enable GPIO mask and set output */
bc9f98a9
KY
2776#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2777#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
64a8be74 2778#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
df694daa
KY
2779
2780/* Clevo m520g init */
2781static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2782 /* headphone output */
2783 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2784 /* line-out */
2785 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2786 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2787 /* Line-in */
2788 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2789 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2790 /* CD */
2791 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2792 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2793 /* Mic1 (rear panel) */
2794 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2795 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2796 /* Mic2 (front panel) */
2797 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2798 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2799 /* headphone */
2800 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2801 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2802 /* change to EAPD mode */
2803 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2804 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2805
2806 { }
16ded525
TI
2807};
2808
df694daa 2809static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
4b146cb0
TI
2810 /* change to EAPD mode */
2811 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2812 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2813
df694daa
KY
2814 /* Headphone output */
2815 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2816 /* Front output*/
2817 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2818 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2819
2820 /* Line In pin widget for input */
2821 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2822 /* CD pin widget for input */
2823 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2824 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2825 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2826
2827 /* change to EAPD mode */
2828 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2829 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2830
2831 { }
2832};
16ded525 2833
e9edcee0 2834/*
ae6b813a
TI
2835 * LG m1 express dual
2836 *
2837 * Pin assignment:
2838 * Rear Line-In/Out (blue): 0x14
2839 * Build-in Mic-In: 0x15
2840 * Speaker-out: 0x17
2841 * HP-Out (green): 0x1b
2842 * Mic-In/Out (red): 0x19
2843 * SPDIF-Out: 0x1e
2844 */
2845
2846/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2847static hda_nid_t alc880_lg_dac_nids[3] = {
2848 0x05, 0x02, 0x03
2849};
2850
2851/* seems analog CD is not working */
2852static struct hda_input_mux alc880_lg_capture_source = {
2853 .num_items = 3,
2854 .items = {
2855 { "Mic", 0x1 },
2856 { "Line", 0x5 },
2857 { "Internal Mic", 0x6 },
2858 },
2859};
2860
2861/* 2,4,6 channel modes */
2862static struct hda_verb alc880_lg_ch2_init[] = {
2863 /* set line-in and mic-in to input */
2864 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2865 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2866 { }
2867};
2868
2869static struct hda_verb alc880_lg_ch4_init[] = {
2870 /* set line-in to out and mic-in to input */
2871 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2872 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2873 { }
2874};
2875
2876static struct hda_verb alc880_lg_ch6_init[] = {
2877 /* set line-in and mic-in to output */
2878 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2879 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2880 { }
2881};
2882
2883static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2884 { 2, alc880_lg_ch2_init },
2885 { 4, alc880_lg_ch4_init },
2886 { 6, alc880_lg_ch6_init },
2887};
2888
2889static struct snd_kcontrol_new alc880_lg_mixer[] = {
2134ea4f
TI
2890 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2891 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
ae6b813a
TI
2892 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2893 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2894 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2895 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2896 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2897 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2898 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2899 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2900 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2901 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2902 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2903 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2904 {
2905 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2906 .name = "Channel Mode",
2907 .info = alc_ch_mode_info,
2908 .get = alc_ch_mode_get,
2909 .put = alc_ch_mode_put,
2910 },
2911 { } /* end */
2912};
2913
2914static struct hda_verb alc880_lg_init_verbs[] = {
2915 /* set capture source to mic-in */
2916 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2917 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2918 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2919 /* mute all amp mixer inputs */
2920 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
cb53c626
TI
2921 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2922 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
ae6b813a
TI
2923 /* line-in to input */
2924 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2925 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2926 /* built-in mic */
2927 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2928 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2929 /* speaker-out */
2930 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2931 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2932 /* mic-in to input */
2933 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2934 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2935 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2936 /* HP-out */
2937 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2938 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2939 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2940 /* jack sense */
a9fd4f3f 2941 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
ae6b813a
TI
2942 { }
2943};
2944
2945/* toggle speaker-output according to the hp-jack state */
a9fd4f3f 2946static void alc880_lg_init_hook(struct hda_codec *codec)
ae6b813a 2947{
a9fd4f3f 2948 struct alc_spec *spec = codec->spec;
ae6b813a 2949
a9fd4f3f
TI
2950 spec->autocfg.hp_pins[0] = 0x1b;
2951 spec->autocfg.speaker_pins[0] = 0x17;
2952 alc_automute_amp(codec);
ae6b813a
TI
2953}
2954
d681518a
TI
2955/*
2956 * LG LW20
2957 *
2958 * Pin assignment:
2959 * Speaker-out: 0x14
2960 * Mic-In: 0x18
e4f41da9
CM
2961 * Built-in Mic-In: 0x19
2962 * Line-In: 0x1b
2963 * HP-Out: 0x1a
d681518a
TI
2964 * SPDIF-Out: 0x1e
2965 */
2966
d681518a 2967static struct hda_input_mux alc880_lg_lw_capture_source = {
e4f41da9 2968 .num_items = 3,
d681518a
TI
2969 .items = {
2970 { "Mic", 0x0 },
2971 { "Internal Mic", 0x1 },
e4f41da9 2972 { "Line In", 0x2 },
d681518a
TI
2973 },
2974};
2975
0a8c5da3
CM
2976#define alc880_lg_lw_modes alc880_threestack_modes
2977
d681518a 2978static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
0a8c5da3
CM
2979 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2980 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2981 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2982 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2983 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2984 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2985 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2986 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2987 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2988 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
d681518a
TI
2989 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2990 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2991 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2992 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
0a8c5da3
CM
2993 {
2994 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2995 .name = "Channel Mode",
2996 .info = alc_ch_mode_info,
2997 .get = alc_ch_mode_get,
2998 .put = alc_ch_mode_put,
2999 },
d681518a
TI
3000 { } /* end */
3001};
3002
3003static struct hda_verb alc880_lg_lw_init_verbs[] = {
0a8c5da3
CM
3004 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3005 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3006 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3007
d681518a
TI
3008 /* set capture source to mic-in */
3009 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3010 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3011 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
cb53c626 3012 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
d681518a
TI
3013 /* speaker-out */
3014 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3015 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3016 /* HP-out */
d681518a
TI
3017 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3018 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3019 /* mic-in to input */
3020 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3021 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3022 /* built-in mic */
3023 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3024 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3025 /* jack sense */
a9fd4f3f 3026 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
d681518a
TI
3027 { }
3028};
3029
3030/* toggle speaker-output according to the hp-jack state */
a9fd4f3f 3031static void alc880_lg_lw_init_hook(struct hda_codec *codec)
d681518a 3032{
a9fd4f3f 3033 struct alc_spec *spec = codec->spec;
d681518a 3034
a9fd4f3f
TI
3035 spec->autocfg.hp_pins[0] = 0x1b;
3036 spec->autocfg.speaker_pins[0] = 0x14;
3037 alc_automute_amp(codec);
d681518a
TI
3038}
3039
df99cd33
TI
3040static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3041 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3042 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3043 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3044 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3045 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3046 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3047 { } /* end */
3048};
3049
3050static struct hda_input_mux alc880_medion_rim_capture_source = {
3051 .num_items = 2,
3052 .items = {
3053 { "Mic", 0x0 },
3054 { "Internal Mic", 0x1 },
3055 },
3056};
3057
3058static struct hda_verb alc880_medion_rim_init_verbs[] = {
3059 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3060
3061 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3062 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3063
3064 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3065 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3066 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3067 /* Mic2 (as headphone out) for HP output */
3068 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3069 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3070 /* Internal Speaker */
3071 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3072 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3073
3074 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3075 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3076
3077 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3078 { }
3079};
3080
3081/* toggle speaker-output according to the hp-jack state */
3082static void alc880_medion_rim_automute(struct hda_codec *codec)
3083{
a9fd4f3f
TI
3084 struct alc_spec *spec = codec->spec;
3085 alc_automute_amp(codec);
3086 /* toggle EAPD */
3087 if (spec->jack_present)
df99cd33
TI
3088 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3089 else
3090 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3091}
3092
3093static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3094 unsigned int res)
3095{
3096 /* Looks like the unsol event is incompatible with the standard
3097 * definition. 4bit tag is placed at 28 bit!
3098 */
3099 if ((res >> 28) == ALC880_HP_EVENT)
3100 alc880_medion_rim_automute(codec);
3101}
3102
a9fd4f3f
TI
3103static void alc880_medion_rim_init_hook(struct hda_codec *codec)
3104{
3105 struct alc_spec *spec = codec->spec;
3106
3107 spec->autocfg.hp_pins[0] = 0x14;
3108 spec->autocfg.speaker_pins[0] = 0x1b;
3109 alc880_medion_rim_automute(codec);
3110}
3111
cb53c626
TI
3112#ifdef CONFIG_SND_HDA_POWER_SAVE
3113static struct hda_amp_list alc880_loopbacks[] = {
3114 { 0x0b, HDA_INPUT, 0 },
3115 { 0x0b, HDA_INPUT, 1 },
3116 { 0x0b, HDA_INPUT, 2 },
3117 { 0x0b, HDA_INPUT, 3 },
3118 { 0x0b, HDA_INPUT, 4 },
3119 { } /* end */
3120};
3121
3122static struct hda_amp_list alc880_lg_loopbacks[] = {
3123 { 0x0b, HDA_INPUT, 1 },
3124 { 0x0b, HDA_INPUT, 6 },
3125 { 0x0b, HDA_INPUT, 7 },
3126 { } /* end */
3127};
3128#endif
3129
ae6b813a
TI
3130/*
3131 * Common callbacks
e9edcee0
TI
3132 */
3133
1da177e4
LT
3134static int alc_init(struct hda_codec *codec)
3135{
3136 struct alc_spec *spec = codec->spec;
e9edcee0
TI
3137 unsigned int i;
3138
2c3bf9ab 3139 alc_fix_pll(codec);
4a79ba34 3140 alc_auto_init_amp(codec, spec->init_amp);
2c3bf9ab 3141
e9edcee0
TI
3142 for (i = 0; i < spec->num_init_verbs; i++)
3143 snd_hda_sequence_write(codec, spec->init_verbs[i]);
ae6b813a
TI
3144
3145 if (spec->init_hook)
3146 spec->init_hook(codec);
3147
1da177e4
LT
3148 return 0;
3149}
3150
ae6b813a
TI
3151static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3152{
3153 struct alc_spec *spec = codec->spec;
3154
3155 if (spec->unsol_event)
3156 spec->unsol_event(codec, res);
3157}
3158
cb53c626
TI
3159#ifdef CONFIG_SND_HDA_POWER_SAVE
3160static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3161{
3162 struct alc_spec *spec = codec->spec;
3163 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3164}
3165#endif
3166
1da177e4
LT
3167/*
3168 * Analog playback callbacks
3169 */
3170static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3171 struct hda_codec *codec,
c8b6bf9b 3172 struct snd_pcm_substream *substream)
1da177e4
LT
3173{
3174 struct alc_spec *spec = codec->spec;
9a08160b
TI
3175 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3176 hinfo);
1da177e4
LT
3177}
3178
3179static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3180 struct hda_codec *codec,
3181 unsigned int stream_tag,
3182 unsigned int format,
c8b6bf9b 3183 struct snd_pcm_substream *substream)
1da177e4
LT
3184{
3185 struct alc_spec *spec = codec->spec;
9c7f852e
TI
3186 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3187 stream_tag, format, substream);
1da177e4
LT
3188}
3189
3190static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3191 struct hda_codec *codec,
c8b6bf9b 3192 struct snd_pcm_substream *substream)
1da177e4
LT
3193{
3194 struct alc_spec *spec = codec->spec;
3195 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3196}
3197
3198/*
3199 * Digital out
3200 */
3201static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3202 struct hda_codec *codec,
c8b6bf9b 3203 struct snd_pcm_substream *substream)
1da177e4
LT
3204{
3205 struct alc_spec *spec = codec->spec;
3206 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3207}
3208
6b97eb45
TI
3209static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3210 struct hda_codec *codec,
3211 unsigned int stream_tag,
3212 unsigned int format,
3213 struct snd_pcm_substream *substream)
3214{
3215 struct alc_spec *spec = codec->spec;
3216 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3217 stream_tag, format, substream);
3218}
3219
9b5f12e5
TI
3220static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3221 struct hda_codec *codec,
3222 struct snd_pcm_substream *substream)
3223{
3224 struct alc_spec *spec = codec->spec;
3225 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3226}
3227
1da177e4
LT
3228static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3229 struct hda_codec *codec,
c8b6bf9b 3230 struct snd_pcm_substream *substream)
1da177e4
LT
3231{
3232 struct alc_spec *spec = codec->spec;
3233 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3234}
3235
3236/*
3237 * Analog capture
3238 */
6330079f 3239static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1da177e4
LT
3240 struct hda_codec *codec,
3241 unsigned int stream_tag,
3242 unsigned int format,
c8b6bf9b 3243 struct snd_pcm_substream *substream)
1da177e4
LT
3244{
3245 struct alc_spec *spec = codec->spec;
3246
6330079f 3247 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
1da177e4
LT
3248 stream_tag, 0, format);
3249 return 0;
3250}
3251
6330079f 3252static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1da177e4 3253 struct hda_codec *codec,
c8b6bf9b 3254 struct snd_pcm_substream *substream)
1da177e4
LT
3255{
3256 struct alc_spec *spec = codec->spec;
3257
888afa15
TI
3258 snd_hda_codec_cleanup_stream(codec,
3259 spec->adc_nids[substream->number + 1]);
1da177e4
LT
3260 return 0;
3261}
3262
3263
3264/*
3265 */
3266static struct hda_pcm_stream alc880_pcm_analog_playback = {
3267 .substreams = 1,
3268 .channels_min = 2,
3269 .channels_max = 8,
e9edcee0 3270 /* NID is set in alc_build_pcms */
1da177e4
LT
3271 .ops = {
3272 .open = alc880_playback_pcm_open,
3273 .prepare = alc880_playback_pcm_prepare,
3274 .cleanup = alc880_playback_pcm_cleanup
3275 },
3276};
3277
3278static struct hda_pcm_stream alc880_pcm_analog_capture = {
6330079f
TI
3279 .substreams = 1,
3280 .channels_min = 2,
3281 .channels_max = 2,
3282 /* NID is set in alc_build_pcms */
3283};
3284
3285static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3286 .substreams = 1,
3287 .channels_min = 2,
3288 .channels_max = 2,
3289 /* NID is set in alc_build_pcms */
3290};
3291
3292static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3293 .substreams = 2, /* can be overridden */
1da177e4
LT
3294 .channels_min = 2,
3295 .channels_max = 2,
e9edcee0 3296 /* NID is set in alc_build_pcms */
1da177e4 3297 .ops = {
6330079f
TI
3298 .prepare = alc880_alt_capture_pcm_prepare,
3299 .cleanup = alc880_alt_capture_pcm_cleanup
1da177e4
LT
3300 },
3301};
3302
3303static struct hda_pcm_stream alc880_pcm_digital_playback = {
3304 .substreams = 1,
3305 .channels_min = 2,
3306 .channels_max = 2,
3307 /* NID is set in alc_build_pcms */
3308 .ops = {
3309 .open = alc880_dig_playback_pcm_open,
6b97eb45 3310 .close = alc880_dig_playback_pcm_close,
9b5f12e5
TI
3311 .prepare = alc880_dig_playback_pcm_prepare,
3312 .cleanup = alc880_dig_playback_pcm_cleanup
1da177e4
LT
3313 },
3314};
3315
3316static struct hda_pcm_stream alc880_pcm_digital_capture = {
3317 .substreams = 1,
3318 .channels_min = 2,
3319 .channels_max = 2,
3320 /* NID is set in alc_build_pcms */
3321};
3322
4c5186ed 3323/* Used by alc_build_pcms to flag that a PCM has no playback stream */
6330079f 3324static struct hda_pcm_stream alc_pcm_null_stream = {
4c5186ed
JW
3325 .substreams = 0,
3326 .channels_min = 0,
3327 .channels_max = 0,
3328};
3329
1da177e4
LT
3330static int alc_build_pcms(struct hda_codec *codec)
3331{
3332 struct alc_spec *spec = codec->spec;
3333 struct hda_pcm *info = spec->pcm_rec;
3334 int i;
3335
3336 codec->num_pcms = 1;
3337 codec->pcm_info = info;
3338
e64f14f4
TI
3339 if (spec->no_analog)
3340 goto skip_analog;
3341
812a2cca
TI
3342 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3343 "%s Analog", codec->chip_name);
1da177e4 3344 info->name = spec->stream_name_analog;
812a2cca 3345
4a471b7d 3346 if (spec->stream_analog_playback) {
da3cec35
TI
3347 if (snd_BUG_ON(!spec->multiout.dac_nids))
3348 return -EINVAL;
4a471b7d
TI
3349 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3350 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3351 }
3352 if (spec->stream_analog_capture) {
da3cec35
TI
3353 if (snd_BUG_ON(!spec->adc_nids))
3354 return -EINVAL;
4a471b7d
TI
3355 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3356 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3357 }
3358
3359 if (spec->channel_mode) {
3360 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3361 for (i = 0; i < spec->num_channel_mode; i++) {
3362 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3363 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3364 }
1da177e4
LT
3365 }
3366 }
3367
e64f14f4 3368 skip_analog:
e08a007d 3369 /* SPDIF for stream index #1 */
1da177e4 3370 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
812a2cca
TI
3371 snprintf(spec->stream_name_digital,
3372 sizeof(spec->stream_name_digital),
3373 "%s Digital", codec->chip_name);
e08a007d 3374 codec->num_pcms = 2;
b25c9da1 3375 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
c06134d7 3376 info = spec->pcm_rec + 1;
1da177e4 3377 info->name = spec->stream_name_digital;
8c441982
TI
3378 if (spec->dig_out_type)
3379 info->pcm_type = spec->dig_out_type;
3380 else
3381 info->pcm_type = HDA_PCM_TYPE_SPDIF;
4a471b7d
TI
3382 if (spec->multiout.dig_out_nid &&
3383 spec->stream_digital_playback) {
1da177e4
LT
3384 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3385 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3386 }
4a471b7d
TI
3387 if (spec->dig_in_nid &&
3388 spec->stream_digital_capture) {
1da177e4
LT
3389 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3390 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3391 }
963f803f
TI
3392 /* FIXME: do we need this for all Realtek codec models? */
3393 codec->spdif_status_reset = 1;
1da177e4
LT
3394 }
3395
e64f14f4
TI
3396 if (spec->no_analog)
3397 return 0;
3398
e08a007d
TI
3399 /* If the use of more than one ADC is requested for the current
3400 * model, configure a second analog capture-only PCM.
3401 */
3402 /* Additional Analaog capture for index #2 */
6330079f
TI
3403 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3404 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
e08a007d 3405 codec->num_pcms = 3;
c06134d7 3406 info = spec->pcm_rec + 2;
e08a007d 3407 info->name = spec->stream_name_analog;
6330079f
TI
3408 if (spec->alt_dac_nid) {
3409 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3410 *spec->stream_analog_alt_playback;
3411 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3412 spec->alt_dac_nid;
3413 } else {
3414 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3415 alc_pcm_null_stream;
3416 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3417 }
3418 if (spec->num_adc_nids > 1) {
3419 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3420 *spec->stream_analog_alt_capture;
3421 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3422 spec->adc_nids[1];
3423 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3424 spec->num_adc_nids - 1;
3425 } else {
3426 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3427 alc_pcm_null_stream;
3428 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
e08a007d
TI
3429 }
3430 }
3431
1da177e4
LT
3432 return 0;
3433}
3434
603c4019
TI
3435static void alc_free_kctls(struct hda_codec *codec)
3436{
3437 struct alc_spec *spec = codec->spec;
3438
3439 if (spec->kctls.list) {
3440 struct snd_kcontrol_new *kctl = spec->kctls.list;
3441 int i;
3442 for (i = 0; i < spec->kctls.used; i++)
3443 kfree(kctl[i].name);
3444 }
3445 snd_array_free(&spec->kctls);
3446}
3447
1da177e4
LT
3448static void alc_free(struct hda_codec *codec)
3449{
e9edcee0 3450 struct alc_spec *spec = codec->spec;
e9edcee0 3451
f12ab1e0 3452 if (!spec)
e9edcee0
TI
3453 return;
3454
603c4019 3455 alc_free_kctls(codec);
e9edcee0 3456 kfree(spec);
680cd536 3457 snd_hda_detach_beep_device(codec);
1da177e4
LT
3458}
3459
e044c39a 3460#ifdef SND_HDA_NEEDS_RESUME
e044c39a
TI
3461static int alc_resume(struct hda_codec *codec)
3462{
e044c39a
TI
3463 codec->patch_ops.init(codec);
3464 snd_hda_codec_resume_amp(codec);
3465 snd_hda_codec_resume_cache(codec);
3466 return 0;
3467}
e044c39a
TI
3468#endif
3469
1da177e4
LT
3470/*
3471 */
3472static struct hda_codec_ops alc_patch_ops = {
3473 .build_controls = alc_build_controls,
3474 .build_pcms = alc_build_pcms,
3475 .init = alc_init,
3476 .free = alc_free,
ae6b813a 3477 .unsol_event = alc_unsol_event,
e044c39a
TI
3478#ifdef SND_HDA_NEEDS_RESUME
3479 .resume = alc_resume,
3480#endif
cb53c626
TI
3481#ifdef CONFIG_SND_HDA_POWER_SAVE
3482 .check_power_status = alc_check_power_status,
3483#endif
1da177e4
LT
3484};
3485
2fa522be
TI
3486
3487/*
3488 * Test configuration for debugging
3489 *
3490 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3491 * enum controls.
3492 */
3493#ifdef CONFIG_SND_DEBUG
3494static hda_nid_t alc880_test_dac_nids[4] = {
3495 0x02, 0x03, 0x04, 0x05
3496};
3497
3498static struct hda_input_mux alc880_test_capture_source = {
ae6b813a 3499 .num_items = 7,
2fa522be
TI
3500 .items = {
3501 { "In-1", 0x0 },
3502 { "In-2", 0x1 },
3503 { "In-3", 0x2 },
3504 { "In-4", 0x3 },
3505 { "CD", 0x4 },
ae6b813a
TI
3506 { "Front", 0x5 },
3507 { "Surround", 0x6 },
2fa522be
TI
3508 },
3509};
3510
d2a6d7dc 3511static struct hda_channel_mode alc880_test_modes[4] = {
2fa522be 3512 { 2, NULL },
fd2c326d 3513 { 4, NULL },
2fa522be 3514 { 6, NULL },
fd2c326d 3515 { 8, NULL },
2fa522be
TI
3516};
3517
9c7f852e
TI
3518static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3519 struct snd_ctl_elem_info *uinfo)
2fa522be
TI
3520{
3521 static char *texts[] = {
3522 "N/A", "Line Out", "HP Out",
3523 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3524 };
3525 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3526 uinfo->count = 1;
3527 uinfo->value.enumerated.items = 8;
3528 if (uinfo->value.enumerated.item >= 8)
3529 uinfo->value.enumerated.item = 7;
3530 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3531 return 0;
3532}
3533
9c7f852e
TI
3534static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3535 struct snd_ctl_elem_value *ucontrol)
2fa522be
TI
3536{
3537 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3538 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3539 unsigned int pin_ctl, item = 0;
3540
3541 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3542 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3543 if (pin_ctl & AC_PINCTL_OUT_EN) {
3544 if (pin_ctl & AC_PINCTL_HP_EN)
3545 item = 2;
3546 else
3547 item = 1;
3548 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3549 switch (pin_ctl & AC_PINCTL_VREFEN) {
3550 case AC_PINCTL_VREF_HIZ: item = 3; break;
3551 case AC_PINCTL_VREF_50: item = 4; break;
3552 case AC_PINCTL_VREF_GRD: item = 5; break;
3553 case AC_PINCTL_VREF_80: item = 6; break;
3554 case AC_PINCTL_VREF_100: item = 7; break;
3555 }
3556 }
3557 ucontrol->value.enumerated.item[0] = item;
3558 return 0;
3559}
3560
9c7f852e
TI
3561static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3562 struct snd_ctl_elem_value *ucontrol)
2fa522be
TI
3563{
3564 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3565 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3566 static unsigned int ctls[] = {
3567 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3568 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3569 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3570 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3571 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3572 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3573 };
3574 unsigned int old_ctl, new_ctl;
3575
3576 old_ctl = snd_hda_codec_read(codec, nid, 0,
3577 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3578 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3579 if (old_ctl != new_ctl) {
82beb8fd
TI
3580 int val;
3581 snd_hda_codec_write_cache(codec, nid, 0,
3582 AC_VERB_SET_PIN_WIDGET_CONTROL,
3583 new_ctl);
47fd830a
TI
3584 val = ucontrol->value.enumerated.item[0] >= 3 ?
3585 HDA_AMP_MUTE : 0;
3586 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3587 HDA_AMP_MUTE, val);
2fa522be
TI
3588 return 1;
3589 }
3590 return 0;
3591}
3592
9c7f852e
TI
3593static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3594 struct snd_ctl_elem_info *uinfo)
2fa522be
TI
3595{
3596 static char *texts[] = {
3597 "Front", "Surround", "CLFE", "Side"
3598 };
3599 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3600 uinfo->count = 1;
3601 uinfo->value.enumerated.items = 4;
3602 if (uinfo->value.enumerated.item >= 4)
3603 uinfo->value.enumerated.item = 3;
3604 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3605 return 0;
3606}
3607
9c7f852e
TI
3608static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3609 struct snd_ctl_elem_value *ucontrol)
2fa522be
TI
3610{
3611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3612 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3613 unsigned int sel;
3614
3615 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3616 ucontrol->value.enumerated.item[0] = sel & 3;
3617 return 0;
3618}
3619
9c7f852e
TI
3620static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3621 struct snd_ctl_elem_value *ucontrol)
2fa522be
TI
3622{
3623 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3624 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3625 unsigned int sel;
3626
3627 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3628 if (ucontrol->value.enumerated.item[0] != sel) {
3629 sel = ucontrol->value.enumerated.item[0] & 3;
82beb8fd
TI
3630 snd_hda_codec_write_cache(codec, nid, 0,
3631 AC_VERB_SET_CONNECT_SEL, sel);
2fa522be
TI
3632 return 1;
3633 }
3634 return 0;
3635}
3636
3637#define PIN_CTL_TEST(xname,nid) { \
3638 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3639 .name = xname, \
3640 .info = alc_test_pin_ctl_info, \
3641 .get = alc_test_pin_ctl_get, \
3642 .put = alc_test_pin_ctl_put, \
3643 .private_value = nid \
3644 }
3645
3646#define PIN_SRC_TEST(xname,nid) { \
3647 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3648 .name = xname, \
3649 .info = alc_test_pin_src_info, \
3650 .get = alc_test_pin_src_get, \
3651 .put = alc_test_pin_src_put, \
3652 .private_value = nid \
3653 }
3654
c8b6bf9b 3655static struct snd_kcontrol_new alc880_test_mixer[] = {
05acb863
TI
3656 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3657 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3658 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3659 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
985be54b
TI
3660 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3661 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3662 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3663 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2fa522be
TI
3664 PIN_CTL_TEST("Front Pin Mode", 0x14),
3665 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3666 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3667 PIN_CTL_TEST("Side Pin Mode", 0x17),
3668 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3669 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3670 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3671 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3672 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3673 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3674 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3675 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3676 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3677 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3678 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3679 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3680 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3681 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3682 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3683 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3684 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3685 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2fa522be
TI
3686 {
3687 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3688 .name = "Channel Mode",
df694daa
KY
3689 .info = alc_ch_mode_info,
3690 .get = alc_ch_mode_get,
3691 .put = alc_ch_mode_put,
2fa522be
TI
3692 },
3693 { } /* end */
3694};
3695
3696static struct hda_verb alc880_test_init_verbs[] = {
3697 /* Unmute inputs of 0x0c - 0x0f */
05acb863
TI
3698 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3699 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3700 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3701 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3702 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3703 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3704 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3705 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2fa522be 3706 /* Vol output for 0x0c-0x0f */
05acb863
TI
3707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3708 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3709 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3710 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2fa522be 3711 /* Set output pins 0x14-0x17 */
05acb863
TI
3712 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3713 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3714 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3715 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2fa522be 3716 /* Unmute output pins 0x14-0x17 */
05acb863
TI
3717 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3718 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3719 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3720 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2fa522be 3721 /* Set input pins 0x18-0x1c */
16ded525
TI
3722 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3723 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
05acb863
TI
3724 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3725 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3726 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2fa522be 3727 /* Mute input pins 0x18-0x1b */
05acb863
TI
3728 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3729 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3730 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3731 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
71fe7b82 3732 /* ADC set up */
05acb863 3733 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
71fe7b82 3734 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
05acb863 3735 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
71fe7b82 3736 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
05acb863 3737 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
71fe7b82 3738 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
05acb863
TI
3739 /* Analog input/passthru */
3740 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3741 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3742 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3743 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2fa522be
TI
3745 { }
3746};
3747#endif
3748
1da177e4
LT
3749/*
3750 */
3751
f5fcc13c
TI
3752static const char *alc880_models[ALC880_MODEL_LAST] = {
3753 [ALC880_3ST] = "3stack",
3754 [ALC880_TCL_S700] = "tcl",
3755 [ALC880_3ST_DIG] = "3stack-digout",
3756 [ALC880_CLEVO] = "clevo",
3757 [ALC880_5ST] = "5stack",
3758 [ALC880_5ST_DIG] = "5stack-digout",
3759 [ALC880_W810] = "w810",
3760 [ALC880_Z71V] = "z71v",
3761 [ALC880_6ST] = "6stack",
3762 [ALC880_6ST_DIG] = "6stack-digout",
3763 [ALC880_ASUS] = "asus",
3764 [ALC880_ASUS_W1V] = "asus-w1v",
3765 [ALC880_ASUS_DIG] = "asus-dig",
3766 [ALC880_ASUS_DIG2] = "asus-dig2",
3767 [ALC880_UNIWILL_DIG] = "uniwill",
2cf9f0fc
TD
3768 [ALC880_UNIWILL_P53] = "uniwill-p53",
3769 [ALC880_FUJITSU] = "fujitsu",
f5fcc13c
TI
3770 [ALC880_F1734] = "F1734",
3771 [ALC880_LG] = "lg",
3772 [ALC880_LG_LW] = "lg-lw",
df99cd33 3773 [ALC880_MEDION_RIM] = "medion",
2fa522be 3774#ifdef CONFIG_SND_DEBUG
f5fcc13c 3775 [ALC880_TEST] = "test",
2fa522be 3776#endif
f5fcc13c
TI
3777 [ALC880_AUTO] = "auto",
3778};
3779
3780static struct snd_pci_quirk alc880_cfg_tbl[] = {
ac3e3741 3781 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
f5fcc13c
TI
3782 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3783 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3784 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3785 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3786 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3787 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3788 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3789 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
f5fcc13c
TI
3790 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3791 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
f5fcc13c
TI
3792 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3793 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3794 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3795 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3796 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3797 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3798 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3799 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3800 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3801 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
186c3117 3802 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
f5fcc13c
TI
3803 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3804 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3805 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
dea0a509 3806 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
f5fcc13c 3807 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
ac3e3741
TI
3808 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3809 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
f5fcc13c
TI
3810 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3811 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
f5fcc13c
TI
3812 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3813 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3814 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3815 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
ac3e3741
TI
3816 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3817 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
f5fcc13c 3818 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
ac3e3741 3819 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
f5fcc13c 3820 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
ac3e3741 3821 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
f5fcc13c
TI
3822 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3823 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
ac3e3741 3824 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
df99cd33 3825 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
ac3e3741 3826 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
f5fcc13c 3827 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
f5fcc13c 3828 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
1d11604e 3829 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
ac3e3741 3830 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2cf9f0fc 3831 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
ac3e3741 3832 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
f5fcc13c
TI
3833 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3834 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
f5fcc13c 3835 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
ac3e3741
TI
3836 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3837 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3838 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3839 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
f5fcc13c
TI
3840 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3841 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
ac3e3741 3842 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
f5fcc13c 3843 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
ac3e3741
TI
3844 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3845 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
f5fcc13c
TI
3846 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3847 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3848 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
dea0a509
TI
3849 /* default Intel */
3850 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
ac3e3741
TI
3851 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3852 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
1da177e4
LT
3853 {}
3854};
3855
16ded525 3856/*
df694daa 3857 * ALC880 codec presets
16ded525 3858 */
16ded525
TI
3859static struct alc_config_preset alc880_presets[] = {
3860 [ALC880_3ST] = {
e9edcee0 3861 .mixers = { alc880_three_stack_mixer },
f12ab1e0
TI
3862 .init_verbs = { alc880_volume_init_verbs,
3863 alc880_pin_3stack_init_verbs },
16ded525 3864 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
16ded525 3865 .dac_nids = alc880_dac_nids,
16ded525
TI
3866 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3867 .channel_mode = alc880_threestack_modes,
4e195a7b 3868 .need_dac_fix = 1,
16ded525
TI
3869 .input_mux = &alc880_capture_source,
3870 },
3871 [ALC880_3ST_DIG] = {
e9edcee0 3872 .mixers = { alc880_three_stack_mixer },
f12ab1e0
TI
3873 .init_verbs = { alc880_volume_init_verbs,
3874 alc880_pin_3stack_init_verbs },
16ded525 3875 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
16ded525
TI
3876 .dac_nids = alc880_dac_nids,
3877 .dig_out_nid = ALC880_DIGOUT_NID,
16ded525
TI
3878 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3879 .channel_mode = alc880_threestack_modes,
4e195a7b 3880 .need_dac_fix = 1,
16ded525
TI
3881 .input_mux = &alc880_capture_source,
3882 },
df694daa
KY
3883 [ALC880_TCL_S700] = {
3884 .mixers = { alc880_tcl_s700_mixer },
3885 .init_verbs = { alc880_volume_init_verbs,
3886 alc880_pin_tcl_S700_init_verbs,
3887 alc880_gpio2_init_verbs },
3888 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3889 .dac_nids = alc880_dac_nids,
f9e336f6
TI
3890 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3891 .num_adc_nids = 1, /* single ADC */
df694daa
KY
3892 .hp_nid = 0x03,
3893 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3894 .channel_mode = alc880_2_jack_modes,
3895 .input_mux = &alc880_capture_source,
3896 },
16ded525 3897 [ALC880_5ST] = {
f12ab1e0
TI
3898 .mixers = { alc880_three_stack_mixer,
3899 alc880_five_stack_mixer},
3900 .init_verbs = { alc880_volume_init_verbs,
3901 alc880_pin_5stack_init_verbs },
16ded525
TI
3902 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3903 .dac_nids = alc880_dac_nids,
16ded525
TI
3904 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3905 .channel_mode = alc880_fivestack_modes,
3906 .input_mux = &alc880_capture_source,
3907 },
3908 [ALC880_5ST_DIG] = {
f12ab1e0
TI
3909 .mixers = { alc880_three_stack_mixer,
3910 alc880_five_stack_mixer },
3911 .init_verbs = { alc880_volume_init_verbs,
3912 alc880_pin_5stack_init_verbs },
16ded525
TI
3913 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3914 .dac_nids = alc880_dac_nids,
3915 .dig_out_nid = ALC880_DIGOUT_NID,
16ded525
TI
3916 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3917 .channel_mode = alc880_fivestack_modes,
3918 .input_mux = &alc880_capture_source,
3919 },
b6482d48
TI
3920 [ALC880_6ST] = {
3921 .mixers = { alc880_six_stack_mixer },
f12ab1e0
TI
3922 .init_verbs = { alc880_volume_init_verbs,
3923 alc880_pin_6stack_init_verbs },
b6482d48
TI
3924 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3925 .dac_nids = alc880_6st_dac_nids,
3926 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3927 .channel_mode = alc880_sixstack_modes,
3928 .input_mux = &alc880_6stack_capture_source,
3929 },
16ded525 3930 [ALC880_6ST_DIG] = {
e9edcee0 3931 .mixers = { alc880_six_stack_mixer },
f12ab1e0
TI
3932 .init_verbs = { alc880_volume_init_verbs,
3933 alc880_pin_6stack_init_verbs },
16ded525
TI
3934 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3935 .dac_nids = alc880_6st_dac_nids,
3936 .dig_out_nid = ALC880_DIGOUT_NID,
16ded525
TI
3937 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3938 .channel_mode = alc880_sixstack_modes,
3939 .input_mux = &alc880_6stack_capture_source,
3940 },
3941 [ALC880_W810] = {
e9edcee0 3942 .mixers = { alc880_w810_base_mixer },
f12ab1e0
TI
3943 .init_verbs = { alc880_volume_init_verbs,
3944 alc880_pin_w810_init_verbs,
b0af0de5 3945 alc880_gpio2_init_verbs },
16ded525
TI
3946 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3947 .dac_nids = alc880_w810_dac_nids,
3948 .dig_out_nid = ALC880_DIGOUT_NID,
16ded525
TI
3949 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3950 .channel_mode = alc880_w810_modes,
3951 .input_mux = &alc880_capture_source,
3952 },
3953 [ALC880_Z71V] = {
e9edcee0 3954 .mixers = { alc880_z71v_mixer },
f12ab1e0
TI
3955 .init_verbs = { alc880_volume_init_verbs,
3956 alc880_pin_z71v_init_verbs },
16ded525
TI
3957 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3958 .dac_nids = alc880_z71v_dac_nids,
3959 .dig_out_nid = ALC880_DIGOUT_NID,
3960 .hp_nid = 0x03,
e9edcee0
TI
3961 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3962 .channel_mode = alc880_2_jack_modes,
16ded525
TI
3963 .input_mux = &alc880_capture_source,
3964 },
3965 [ALC880_F1734] = {
e9edcee0 3966 .mixers = { alc880_f1734_mixer },
f12ab1e0
TI
3967 .init_verbs = { alc880_volume_init_verbs,
3968 alc880_pin_f1734_init_verbs },
e9edcee0
TI
3969 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3970 .dac_nids = alc880_f1734_dac_nids,
3971 .hp_nid = 0x02,
3972 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3973 .channel_mode = alc880_2_jack_modes,
937b4160
TI
3974 .input_mux = &alc880_f1734_capture_source,
3975 .unsol_event = alc880_uniwill_p53_unsol_event,
a9fd4f3f 3976 .init_hook = alc880_uniwill_p53_init_hook,
16ded525
TI
3977 },
3978 [ALC880_ASUS] = {
e9edcee0 3979 .mixers = { alc880_asus_mixer },
f12ab1e0
TI
3980 .init_verbs = { alc880_volume_init_verbs,
3981 alc880_pin_asus_init_verbs,
e9edcee0
TI
3982 alc880_gpio1_init_verbs },
3983 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3984 .dac_nids = alc880_asus_dac_nids,
3985 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3986 .channel_mode = alc880_asus_modes,
4e195a7b 3987 .need_dac_fix = 1,
16ded525
TI
3988 .input_mux = &alc880_capture_source,
3989 },
3990 [ALC880_ASUS_DIG] = {
e9edcee0 3991 .mixers = { alc880_asus_mixer },
f12ab1e0
TI
3992 .init_verbs = { alc880_volume_init_verbs,
3993 alc880_pin_asus_init_verbs,
e9edcee0
TI
3994 alc880_gpio1_init_verbs },
3995 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3996 .dac_nids = alc880_asus_dac_nids,
16ded525 3997 .dig_out_nid = ALC880_DIGOUT_NID,
e9edcee0
TI
3998 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3999 .channel_mode = alc880_asus_modes,
4e195a7b 4000 .need_dac_fix = 1,
16ded525
TI
4001 .input_mux = &alc880_capture_source,
4002 },
df694daa
KY
4003 [ALC880_ASUS_DIG2] = {
4004 .mixers = { alc880_asus_mixer },
f12ab1e0
TI
4005 .init_verbs = { alc880_volume_init_verbs,
4006 alc880_pin_asus_init_verbs,
df694daa
KY
4007 alc880_gpio2_init_verbs }, /* use GPIO2 */
4008 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4009 .dac_nids = alc880_asus_dac_nids,
4010 .dig_out_nid = ALC880_DIGOUT_NID,
4011 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4012 .channel_mode = alc880_asus_modes,
4e195a7b 4013 .need_dac_fix = 1,
df694daa
KY
4014 .input_mux = &alc880_capture_source,
4015 },
16ded525 4016 [ALC880_ASUS_W1V] = {
e9edcee0 4017 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
f12ab1e0
TI
4018 .init_verbs = { alc880_volume_init_verbs,
4019 alc880_pin_asus_init_verbs,
e9edcee0
TI
4020 alc880_gpio1_init_verbs },
4021 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4022 .dac_nids = alc880_asus_dac_nids,
16ded525 4023 .dig_out_nid = ALC880_DIGOUT_NID,
e9edcee0
TI
4024 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4025 .channel_mode = alc880_asus_modes,
4e195a7b 4026 .need_dac_fix = 1,
16ded525
TI
4027 .input_mux = &alc880_capture_source,
4028 },
4029 [ALC880_UNIWILL_DIG] = {
45bdd1c1 4030 .mixers = { alc880_asus_mixer },
ccc656ce
KY
4031 .init_verbs = { alc880_volume_init_verbs,
4032 alc880_pin_asus_init_verbs },
e9edcee0
TI
4033 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4034 .dac_nids = alc880_asus_dac_nids,
16ded525 4035 .dig_out_nid = ALC880_DIGOUT_NID,
e9edcee0
TI
4036 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4037 .channel_mode = alc880_asus_modes,
4e195a7b 4038 .need_dac_fix = 1,
16ded525
TI
4039 .input_mux = &alc880_capture_source,
4040 },
ccc656ce
KY
4041 [ALC880_UNIWILL] = {
4042 .mixers = { alc880_uniwill_mixer },
4043 .init_verbs = { alc880_volume_init_verbs,
4044 alc880_uniwill_init_verbs },
4045 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4046 .dac_nids = alc880_asus_dac_nids,
4047 .dig_out_nid = ALC880_DIGOUT_NID,
4048 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4049 .channel_mode = alc880_threestack_modes,
4050 .need_dac_fix = 1,
4051 .input_mux = &alc880_capture_source,
4052 .unsol_event = alc880_uniwill_unsol_event,
a9fd4f3f 4053 .init_hook = alc880_uniwill_init_hook,
ccc656ce
KY
4054 },
4055 [ALC880_UNIWILL_P53] = {
4056 .mixers = { alc880_uniwill_p53_mixer },
4057 .init_verbs = { alc880_volume_init_verbs,
4058 alc880_uniwill_p53_init_verbs },
4059 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4060 .dac_nids = alc880_asus_dac_nids,
4061 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2cf9f0fc
TD
4062 .channel_mode = alc880_threestack_modes,
4063 .input_mux = &alc880_capture_source,
4064 .unsol_event = alc880_uniwill_p53_unsol_event,
a9fd4f3f 4065 .init_hook = alc880_uniwill_p53_init_hook,
2cf9f0fc
TD
4066 },
4067 [ALC880_FUJITSU] = {
45bdd1c1 4068 .mixers = { alc880_fujitsu_mixer },
2cf9f0fc
TD
4069 .init_verbs = { alc880_volume_init_verbs,
4070 alc880_uniwill_p53_init_verbs,
4071 alc880_beep_init_verbs },
4072 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4073 .dac_nids = alc880_dac_nids,
d53d7d9e 4074 .dig_out_nid = ALC880_DIGOUT_NID,
2cf9f0fc
TD
4075 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4076 .channel_mode = alc880_2_jack_modes,
ccc656ce
KY
4077 .input_mux = &alc880_capture_source,
4078 .unsol_event = alc880_uniwill_p53_unsol_event,
a9fd4f3f 4079 .init_hook = alc880_uniwill_p53_init_hook,
ccc656ce 4080 },
df694daa
KY
4081 [ALC880_CLEVO] = {
4082 .mixers = { alc880_three_stack_mixer },
4083 .init_verbs = { alc880_volume_init_verbs,
4084 alc880_pin_clevo_init_verbs },
4085 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4086 .dac_nids = alc880_dac_nids,
4087 .hp_nid = 0x03,
4088 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4089 .channel_mode = alc880_threestack_modes,
4e195a7b 4090 .need_dac_fix = 1,
df694daa
KY
4091 .input_mux = &alc880_capture_source,
4092 },
ae6b813a
TI
4093 [ALC880_LG] = {
4094 .mixers = { alc880_lg_mixer },
4095 .init_verbs = { alc880_volume_init_verbs,
4096 alc880_lg_init_verbs },
4097 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4098 .dac_nids = alc880_lg_dac_nids,
4099 .dig_out_nid = ALC880_DIGOUT_NID,
4100 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4101 .channel_mode = alc880_lg_ch_modes,
4e195a7b 4102 .need_dac_fix = 1,
ae6b813a 4103 .input_mux = &alc880_lg_capture_source,
a9fd4f3f
TI
4104 .unsol_event = alc_automute_amp_unsol_event,
4105 .init_hook = alc880_lg_init_hook,
cb53c626
TI
4106#ifdef CONFIG_SND_HDA_POWER_SAVE
4107 .loopbacks = alc880_lg_loopbacks,
4108#endif
ae6b813a 4109 },
d681518a
TI
4110 [ALC880_LG_LW] = {
4111 .mixers = { alc880_lg_lw_mixer },
4112 .init_verbs = { alc880_volume_init_verbs,
4113 alc880_lg_lw_init_verbs },
0a8c5da3 4114 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
d681518a
TI
4115 .dac_nids = alc880_dac_nids,
4116 .dig_out_nid = ALC880_DIGOUT_NID,
0a8c5da3
CM
4117 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4118 .channel_mode = alc880_lg_lw_modes,
d681518a 4119 .input_mux = &alc880_lg_lw_capture_source,
a9fd4f3f
TI
4120 .unsol_event = alc_automute_amp_unsol_event,
4121 .init_hook = alc880_lg_lw_init_hook,
d681518a 4122 },
df99cd33
TI
4123 [ALC880_MEDION_RIM] = {
4124 .mixers = { alc880_medion_rim_mixer },
4125 .init_verbs = { alc880_volume_init_verbs,
4126 alc880_medion_rim_init_verbs,
4127 alc_gpio2_init_verbs },
4128 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4129 .dac_nids = alc880_dac_nids,
4130 .dig_out_nid = ALC880_DIGOUT_NID,
4131 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4132 .channel_mode = alc880_2_jack_modes,
4133 .input_mux = &alc880_medion_rim_capture_source,
4134 .unsol_event = alc880_medion_rim_unsol_event,
a9fd4f3f 4135 .init_hook = alc880_medion_rim_init_hook,
df99cd33 4136 },
16ded525
TI
4137#ifdef CONFIG_SND_DEBUG
4138 [ALC880_TEST] = {
e9edcee0
TI
4139 .mixers = { alc880_test_mixer },
4140 .init_verbs = { alc880_test_init_verbs },
16ded525
TI
4141 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4142 .dac_nids = alc880_test_dac_nids,
4143 .dig_out_nid = ALC880_DIGOUT_NID,
16ded525
TI
4144 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4145 .channel_mode = alc880_test_modes,
4146 .input_mux = &alc880_test_capture_source,
4147 },
4148#endif
4149};
4150
e9edcee0
TI
4151/*
4152 * Automatic parse of I/O pins from the BIOS configuration
4153 */
4154
e9edcee0
TI
4155enum {
4156 ALC_CTL_WIDGET_VOL,
4157 ALC_CTL_WIDGET_MUTE,
4158 ALC_CTL_BIND_MUTE,
4159};
c8b6bf9b 4160static struct snd_kcontrol_new alc880_control_templates[] = {
e9edcee0
TI
4161 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4162 HDA_CODEC_MUTE(NULL, 0, 0, 0),
985be54b 4163 HDA_BIND_MUTE(NULL, 0, 0, 0),
e9edcee0
TI
4164};
4165
4166/* add dynamic controls */
f12ab1e0
TI
4167static int add_control(struct alc_spec *spec, int type, const char *name,
4168 unsigned long val)
e9edcee0 4169{
c8b6bf9b 4170 struct snd_kcontrol_new *knew;
e9edcee0 4171
603c4019
TI
4172 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4173 knew = snd_array_new(&spec->kctls);
4174 if (!knew)
4175 return -ENOMEM;
e9edcee0 4176 *knew = alc880_control_templates[type];
543537bd 4177 knew->name = kstrdup(name, GFP_KERNEL);
f12ab1e0 4178 if (!knew->name)
e9edcee0
TI
4179 return -ENOMEM;
4180 knew->private_value = val;
e9edcee0
TI
4181 return 0;
4182}
4183
4184#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4185#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4186#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4187#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4188#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4189#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4190#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4191#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4192#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4193#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4194#define ALC880_PIN_CD_NID 0x1c
4195
4196/* fill in the dac_nids table from the parsed pin configuration */
f12ab1e0
TI
4197static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4198 const struct auto_pin_cfg *cfg)
e9edcee0
TI
4199{
4200 hda_nid_t nid;
4201 int assigned[4];
4202 int i, j;
4203
4204 memset(assigned, 0, sizeof(assigned));
b0af0de5 4205 spec->multiout.dac_nids = spec->private_dac_nids;
e9edcee0
TI
4206
4207 /* check the pins hardwired to audio widget */
4208 for (i = 0; i < cfg->line_outs; i++) {
4209 nid = cfg->line_out_pins[i];
4210 if (alc880_is_fixed_pin(nid)) {
4211 int idx = alc880_fixed_pin_idx(nid);
5014f193 4212 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
e9edcee0
TI
4213 assigned[idx] = 1;
4214 }
4215 }
4216 /* left pins can be connect to any audio widget */
4217 for (i = 0; i < cfg->line_outs; i++) {
4218 nid = cfg->line_out_pins[i];
4219 if (alc880_is_fixed_pin(nid))
4220 continue;
4221 /* search for an empty channel */
4222 for (j = 0; j < cfg->line_outs; j++) {
f12ab1e0
TI
4223 if (!assigned[j]) {
4224 spec->multiout.dac_nids[i] =
4225 alc880_idx_to_dac(j);
e9edcee0
TI
4226 assigned[j] = 1;
4227 break;
4228 }
4229 }
4230 }
4231 spec->multiout.num_dacs = cfg->line_outs;
4232 return 0;
4233}
4234
4235/* add playback controls from the parsed DAC table */
df694daa
KY
4236static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4237 const struct auto_pin_cfg *cfg)
e9edcee0
TI
4238{
4239 char name[32];
f12ab1e0
TI
4240 static const char *chname[4] = {
4241 "Front", "Surround", NULL /*CLFE*/, "Side"
4242 };
e9edcee0
TI
4243 hda_nid_t nid;
4244 int i, err;
4245
4246 for (i = 0; i < cfg->line_outs; i++) {
f12ab1e0 4247 if (!spec->multiout.dac_nids[i])
e9edcee0
TI
4248 continue;
4249 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4250 if (i == 2) {
4251 /* Center/LFE */
f12ab1e0
TI
4252 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4253 "Center Playback Volume",
4254 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4255 HDA_OUTPUT));
4256 if (err < 0)
e9edcee0 4257 return err;
f12ab1e0
TI
4258 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4259 "LFE Playback Volume",
4260 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4261 HDA_OUTPUT));
4262 if (err < 0)
e9edcee0 4263 return err;
f12ab1e0
TI
4264 err = add_control(spec, ALC_CTL_BIND_MUTE,
4265 "Center Playback Switch",
4266 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4267 HDA_INPUT));
4268 if (err < 0)
e9edcee0 4269 return err;
f12ab1e0
TI
4270 err = add_control(spec, ALC_CTL_BIND_MUTE,
4271 "LFE Playback Switch",
4272 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4273 HDA_INPUT));
4274 if (err < 0)
e9edcee0
TI
4275 return err;
4276 } else {
4277 sprintf(name, "%s Playback Volume", chname[i]);
f12ab1e0
TI
4278 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4279 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4280 HDA_OUTPUT));
4281 if (err < 0)
e9edcee0
TI
4282 return err;
4283 sprintf(name, "%s Playback Switch", chname[i]);
f12ab1e0
TI
4284 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4285 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4286 HDA_INPUT));
4287 if (err < 0)
e9edcee0
TI
4288 return err;
4289 }
4290 }
e9edcee0
TI
4291 return 0;
4292}
4293
8d88bc3d
TI
4294/* add playback controls for speaker and HP outputs */
4295static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4296 const char *pfx)
e9edcee0
TI
4297{
4298 hda_nid_t nid;
4299 int err;
8d88bc3d 4300 char name[32];
e9edcee0 4301
f12ab1e0 4302 if (!pin)
e9edcee0
TI
4303 return 0;
4304
4305 if (alc880_is_fixed_pin(pin)) {
4306 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
82bc955f 4307 /* specify the DAC as the extra output */
f12ab1e0 4308 if (!spec->multiout.hp_nid)
e9edcee0 4309 spec->multiout.hp_nid = nid;
82bc955f
TI
4310 else
4311 spec->multiout.extra_out_nid[0] = nid;
e9edcee0
TI
4312 /* control HP volume/switch on the output mixer amp */
4313 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
8d88bc3d 4314 sprintf(name, "%s Playback Volume", pfx);
f12ab1e0
TI
4315 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4316 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4317 if (err < 0)
e9edcee0 4318 return err;
8d88bc3d 4319 sprintf(name, "%s Playback Switch", pfx);
f12ab1e0
TI
4320 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4321 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4322 if (err < 0)
e9edcee0
TI
4323 return err;
4324 } else if (alc880_is_multi_pin(pin)) {
4325 /* set manual connection */
e9edcee0 4326 /* we have only a switch on HP-out PIN */
8d88bc3d 4327 sprintf(name, "%s Playback Switch", pfx);
f12ab1e0
TI
4328 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4329 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4330 if (err < 0)
e9edcee0
TI
4331 return err;
4332 }
4333 return 0;
4334}
4335
4336/* create input playback/capture controls for the given pin */
f12ab1e0
TI
4337static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4338 const char *ctlname,
df694daa 4339 int idx, hda_nid_t mix_nid)
e9edcee0
TI
4340{
4341 char name[32];
df694daa 4342 int err;
e9edcee0
TI
4343
4344 sprintf(name, "%s Playback Volume", ctlname);
f12ab1e0
TI
4345 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4346 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4347 if (err < 0)
e9edcee0
TI
4348 return err;
4349 sprintf(name, "%s Playback Switch", ctlname);
f12ab1e0
TI
4350 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4351 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4352 if (err < 0)
e9edcee0
TI
4353 return err;
4354 return 0;
4355}
4356
4357/* create playback/capture controls for input pins */
df694daa
KY
4358static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4359 const struct auto_pin_cfg *cfg)
e9edcee0 4360{
61b9b9b1 4361 struct hda_input_mux *imux = &spec->private_imux[0];
df694daa 4362 int i, err, idx;
e9edcee0
TI
4363
4364 for (i = 0; i < AUTO_PIN_LAST; i++) {
4365 if (alc880_is_input_pin(cfg->input_pins[i])) {
df694daa 4366 idx = alc880_input_pin_idx(cfg->input_pins[i]);
4a471b7d
TI
4367 err = new_analog_input(spec, cfg->input_pins[i],
4368 auto_pin_cfg_labels[i],
df694daa 4369 idx, 0x0b);
e9edcee0
TI
4370 if (err < 0)
4371 return err;
f12ab1e0
TI
4372 imux->items[imux->num_items].label =
4373 auto_pin_cfg_labels[i];
4374 imux->items[imux->num_items].index =
4375 alc880_input_pin_idx(cfg->input_pins[i]);
e9edcee0
TI
4376 imux->num_items++;
4377 }
4378 }
4379 return 0;
4380}
4381
f6c7e546
TI
4382static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4383 unsigned int pin_type)
4384{
4385 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4386 pin_type);
4387 /* unmute pin */
d260cdf6
TI
4388 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4389 AMP_OUT_UNMUTE);
f6c7e546
TI
4390}
4391
df694daa
KY
4392static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4393 hda_nid_t nid, int pin_type,
e9edcee0
TI
4394 int dac_idx)
4395{
f6c7e546 4396 alc_set_pin_output(codec, nid, pin_type);
e9edcee0
TI
4397 /* need the manual connection? */
4398 if (alc880_is_multi_pin(nid)) {
4399 struct alc_spec *spec = codec->spec;
4400 int idx = alc880_multi_pin_idx(nid);
4401 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4402 AC_VERB_SET_CONNECT_SEL,
4403 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4404 }
4405}
4406
baba8ee9
TI
4407static int get_pin_type(int line_out_type)
4408{
4409 if (line_out_type == AUTO_PIN_HP_OUT)
4410 return PIN_HP;
4411 else
4412 return PIN_OUT;
4413}
4414
e9edcee0
TI
4415static void alc880_auto_init_multi_out(struct hda_codec *codec)
4416{
4417 struct alc_spec *spec = codec->spec;
4418 int i;
ea1fb29a 4419
e9edcee0
TI
4420 for (i = 0; i < spec->autocfg.line_outs; i++) {
4421 hda_nid_t nid = spec->autocfg.line_out_pins[i];
baba8ee9
TI
4422 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4423 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
e9edcee0
TI
4424 }
4425}
4426
8d88bc3d 4427static void alc880_auto_init_extra_out(struct hda_codec *codec)
e9edcee0
TI
4428{
4429 struct alc_spec *spec = codec->spec;
4430 hda_nid_t pin;
4431
82bc955f 4432 pin = spec->autocfg.speaker_pins[0];
8d88bc3d
TI
4433 if (pin) /* connect to front */
4434 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
eb06ed8f 4435 pin = spec->autocfg.hp_pins[0];
e9edcee0
TI
4436 if (pin) /* connect to front */
4437 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4438}
4439
4440static void alc880_auto_init_analog_input(struct hda_codec *codec)
4441{
4442 struct alc_spec *spec = codec->spec;
4443 int i;
4444
4445 for (i = 0; i < AUTO_PIN_LAST; i++) {
4446 hda_nid_t nid = spec->autocfg.input_pins[i];
4447 if (alc880_is_input_pin(nid)) {
23f0c048 4448 alc_set_input_pin(codec, nid, i);
e82c025b
TI
4449 if (nid != ALC880_PIN_CD_NID &&
4450 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
f12ab1e0
TI
4451 snd_hda_codec_write(codec, nid, 0,
4452 AC_VERB_SET_AMP_GAIN_MUTE,
e9edcee0
TI
4453 AMP_OUT_MUTE);
4454 }
4455 }
4456}
4457
4458/* parse the BIOS configuration and set up the alc_spec */
f12ab1e0
TI
4459/* return 1 if successful, 0 if the proper config is not found,
4460 * or a negative error code
4461 */
e9edcee0
TI
4462static int alc880_parse_auto_config(struct hda_codec *codec)
4463{
4464 struct alc_spec *spec = codec->spec;
6a05ac4a 4465 int i, err;
df694daa 4466 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
e9edcee0 4467
f12ab1e0
TI
4468 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4469 alc880_ignore);
4470 if (err < 0)
e9edcee0 4471 return err;
f12ab1e0 4472 if (!spec->autocfg.line_outs)
e9edcee0 4473 return 0; /* can't find valid BIOS pin config */
df694daa 4474
f12ab1e0
TI
4475 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4476 if (err < 0)
4477 return err;
4478 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4479 if (err < 0)
4480 return err;
4481 err = alc880_auto_create_extra_out(spec,
4482 spec->autocfg.speaker_pins[0],
4483 "Speaker");
4484 if (err < 0)
4485 return err;
4486 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4487 "Headphone");
4488 if (err < 0)
4489 return err;
4490 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4491 if (err < 0)
e9edcee0
TI
4492 return err;
4493
4494 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4495
6a05ac4a
TI
4496 /* check multiple SPDIF-out (for recent codecs) */
4497 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4498 hda_nid_t dig_nid;
4499 err = snd_hda_get_connections(codec,
4500 spec->autocfg.dig_out_pins[i],
4501 &dig_nid, 1);
4502 if (err < 0)
4503 continue;
4504 if (!i)
4505 spec->multiout.dig_out_nid = dig_nid;
4506 else {
4507 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4508 spec->slave_dig_outs[i - 1] = dig_nid;
4509 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4510 break;
4511 }
4512 }
e9edcee0
TI
4513 if (spec->autocfg.dig_in_pin)
4514 spec->dig_in_nid = ALC880_DIGIN_NID;
4515
603c4019 4516 if (spec->kctls.list)
d88897ea 4517 add_mixer(spec, spec->kctls.list);
e9edcee0 4518
d88897ea 4519 add_verb(spec, alc880_volume_init_verbs);
e9edcee0 4520
a1e8d2da 4521 spec->num_mux_defs = 1;
61b9b9b1 4522 spec->input_mux = &spec->private_imux[0];
e9edcee0 4523
4a79ba34
TI
4524 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4525
e9edcee0
TI
4526 return 1;
4527}
4528
ae6b813a
TI
4529/* additional initialization for auto-configuration model */
4530static void alc880_auto_init(struct hda_codec *codec)
e9edcee0 4531{
f6c7e546 4532 struct alc_spec *spec = codec->spec;
e9edcee0 4533 alc880_auto_init_multi_out(codec);
8d88bc3d 4534 alc880_auto_init_extra_out(codec);
e9edcee0 4535 alc880_auto_init_analog_input(codec);
f6c7e546 4536 if (spec->unsol_event)
7fb0d78f 4537 alc_inithook(codec);
e9edcee0
TI
4538}
4539
f9e336f6
TI
4540static void set_capture_mixer(struct alc_spec *spec)
4541{
a23b688f
TI
4542 static struct snd_kcontrol_new *caps[2][3] = {
4543 { alc_capture_mixer_nosrc1,
4544 alc_capture_mixer_nosrc2,
4545 alc_capture_mixer_nosrc3 },
4546 { alc_capture_mixer1,
4547 alc_capture_mixer2,
4548 alc_capture_mixer3 },
f9e336f6 4549 };
a23b688f
TI
4550 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4551 int mux;
4552 if (spec->input_mux && spec->input_mux->num_items > 1)
4553 mux = 1;
4554 else
4555 mux = 0;
4556 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4557 }
f9e336f6
TI
4558}
4559
45bdd1c1
TI
4560#define set_beep_amp(spec, nid, idx, dir) \
4561 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4562
4563/*
4564 * OK, here we have finally the patch for ALC880
4565 */
4566
1da177e4
LT
4567static int patch_alc880(struct hda_codec *codec)
4568{
4569 struct alc_spec *spec;
4570 int board_config;
df694daa 4571 int err;
1da177e4 4572
e560d8d8 4573 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1da177e4
LT
4574 if (spec == NULL)
4575 return -ENOMEM;
4576
4577 codec->spec = spec;
4578
f5fcc13c
TI
4579 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4580 alc880_models,
4581 alc880_cfg_tbl);
4582 if (board_config < 0) {
6c627f39
TI
4583 printk(KERN_INFO "hda_codec: Unknown model for %s, "
4584 "trying auto-probe from BIOS...\n", codec->chip_name);
e9edcee0 4585 board_config = ALC880_AUTO;
1da177e4 4586 }
1da177e4 4587
e9edcee0
TI
4588 if (board_config == ALC880_AUTO) {
4589 /* automatic parse from the BIOS config */
4590 err = alc880_parse_auto_config(codec);
4591 if (err < 0) {
4592 alc_free(codec);
4593 return err;
f12ab1e0 4594 } else if (!err) {
9c7f852e
TI
4595 printk(KERN_INFO
4596 "hda_codec: Cannot set up configuration "
4597 "from BIOS. Using 3-stack mode...\n");
e9edcee0
TI
4598 board_config = ALC880_3ST;
4599 }
1da177e4
LT
4600 }
4601
680cd536
KK
4602 err = snd_hda_attach_beep_device(codec, 0x1);
4603 if (err < 0) {
4604 alc_free(codec);
4605 return err;
4606 }
4607
df694daa
KY
4608 if (board_config != ALC880_AUTO)
4609 setup_preset(spec, &alc880_presets[board_config]);
1da177e4 4610
1da177e4
LT
4611 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4612 spec->stream_analog_capture = &alc880_pcm_analog_capture;
6330079f 4613 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
1da177e4 4614
1da177e4
LT
4615 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4616 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4617
f12ab1e0 4618 if (!spec->adc_nids && spec->input_mux) {
e9edcee0 4619 /* check whether NID 0x07 is valid */
54d17403 4620 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
f12ab1e0
TI
4621 /* get type */
4622 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
e9edcee0
TI
4623 if (wcap != AC_WID_AUD_IN) {
4624 spec->adc_nids = alc880_adc_nids_alt;
4625 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
e9edcee0
TI
4626 } else {
4627 spec->adc_nids = alc880_adc_nids;
4628 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
e9edcee0
TI
4629 }
4630 }
f9e336f6 4631 set_capture_mixer(spec);
45bdd1c1 4632 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
1da177e4 4633
2134ea4f
TI
4634 spec->vmaster_nid = 0x0c;
4635
1da177e4 4636 codec->patch_ops = alc_patch_ops;
e9edcee0 4637 if (board_config == ALC880_AUTO)
ae6b813a 4638 spec->init_hook = alc880_auto_init;
cb53c626
TI
4639#ifdef CONFIG_SND_HDA_POWER_SAVE
4640 if (!spec->loopback.amplist)
4641 spec->loopback.amplist = alc880_loopbacks;
4642#endif
daead538 4643 codec->proc_widget_hook = print_realtek_coef;
1da177e4
LT
4644
4645 return 0;
4646}
4647
e9edcee0 4648
1da177e4
LT
4649/*
4650 * ALC260 support
4651 */
4652
e9edcee0
TI
4653static hda_nid_t alc260_dac_nids[1] = {
4654 /* front */
4655 0x02,
4656};
4657
4658static hda_nid_t alc260_adc_nids[1] = {
4659 /* ADC0 */
4660 0x04,
4661};
4662
df694daa 4663static hda_nid_t alc260_adc_nids_alt[1] = {
e9edcee0
TI
4664 /* ADC1 */
4665 0x05,
4666};
4667
d57fdac0
JW
4668/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4669 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4670 */
4671static hda_nid_t alc260_dual_adc_nids[2] = {
4c5186ed
JW
4672 /* ADC0, ADC1 */
4673 0x04, 0x05
4674};
4675
e9edcee0
TI
4676#define ALC260_DIGOUT_NID 0x03
4677#define ALC260_DIGIN_NID 0x06
4678
4679static struct hda_input_mux alc260_capture_source = {
4680 .num_items = 4,
4681 .items = {
4682 { "Mic", 0x0 },
4683 { "Front Mic", 0x1 },
4684 { "Line", 0x2 },
4685 { "CD", 0x4 },
4686 },
4687};
4688
17e7aec6 4689/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
a1e8d2da
JW
4690 * headphone jack and the internal CD lines since these are the only pins at
4691 * which audio can appear. For flexibility, also allow the option of
4692 * recording the mixer output on the second ADC (ADC0 doesn't have a
4693 * connection to the mixer output).
a9430dd8 4694 */
a1e8d2da
JW
4695static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4696 {
4697 .num_items = 3,
4698 .items = {
4699 { "Mic/Line", 0x0 },
4700 { "CD", 0x4 },
4701 { "Headphone", 0x2 },
4702 },
a9430dd8 4703 },
a1e8d2da
JW
4704 {
4705 .num_items = 4,
4706 .items = {
4707 { "Mic/Line", 0x0 },
4708 { "CD", 0x4 },
4709 { "Headphone", 0x2 },
4710 { "Mixer", 0x5 },
4711 },
4712 },
4713
a9430dd8
JW
4714};
4715
a1e8d2da
JW
4716/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4717 * the Fujitsu S702x, but jacks are marked differently.
0bfc90e9 4718 */
a1e8d2da
JW
4719static struct hda_input_mux alc260_acer_capture_sources[2] = {
4720 {
4721 .num_items = 4,
4722 .items = {
4723 { "Mic", 0x0 },
4724 { "Line", 0x2 },
4725 { "CD", 0x4 },
4726 { "Headphone", 0x5 },
4727 },
4728 },
4729 {
4730 .num_items = 5,
4731 .items = {
4732 { "Mic", 0x0 },
4733 { "Line", 0x2 },
4734 { "CD", 0x4 },
4735 { "Headphone", 0x6 },
4736 { "Mixer", 0x5 },
4737 },
0bfc90e9
JW
4738 },
4739};
cc959489
MS
4740
4741/* Maxdata Favorit 100XS */
4742static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4743 {
4744 .num_items = 2,
4745 .items = {
4746 { "Line/Mic", 0x0 },
4747 { "CD", 0x4 },
4748 },
4749 },
4750 {
4751 .num_items = 3,
4752 .items = {
4753 { "Line/Mic", 0x0 },
4754 { "CD", 0x4 },
4755 { "Mixer", 0x5 },
4756 },
4757 },
4758};
4759
1da177e4
LT
4760/*
4761 * This is just place-holder, so there's something for alc_build_pcms to look
4762 * at when it calculates the maximum number of channels. ALC260 has no mixer
4763 * element which allows changing the channel mode, so the verb list is
4764 * never used.
4765 */
d2a6d7dc 4766static struct hda_channel_mode alc260_modes[1] = {
1da177e4
LT
4767 { 2, NULL },
4768};
4769
df694daa
KY
4770
4771/* Mixer combinations
4772 *
4773 * basic: base_output + input + pc_beep + capture
4774 * HP: base_output + input + capture_alt
4775 * HP_3013: hp_3013 + input + capture
4776 * fujitsu: fujitsu + capture
0bfc90e9 4777 * acer: acer + capture
df694daa
KY
4778 */
4779
4780static struct snd_kcontrol_new alc260_base_output_mixer[] = {
05acb863 4781 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
985be54b 4782 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
05acb863 4783 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
985be54b 4784 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
05acb863 4785 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
985be54b 4786 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
1da177e4 4787 { } /* end */
f12ab1e0 4788};
1da177e4 4789
df694daa 4790static struct snd_kcontrol_new alc260_input_mixer[] = {
16ded525
TI
4791 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4792 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4793 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4794 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4795 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4796 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4797 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4798 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
df694daa
KY
4799 { } /* end */
4800};
4801
bec15c3a
TI
4802/* update HP, line and mono out pins according to the master switch */
4803static void alc260_hp_master_update(struct hda_codec *codec,
4804 hda_nid_t hp, hda_nid_t line,
4805 hda_nid_t mono)
4806{
4807 struct alc_spec *spec = codec->spec;
4808 unsigned int val = spec->master_sw ? PIN_HP : 0;
4809 /* change HP and line-out pins */
30cde0aa 4810 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
bec15c3a 4811 val);
30cde0aa 4812 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
bec15c3a
TI
4813 val);
4814 /* mono (speaker) depending on the HP jack sense */
4815 val = (val && !spec->jack_present) ? PIN_OUT : 0;
30cde0aa 4816 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
bec15c3a
TI
4817 val);
4818}
4819
4820static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4821 struct snd_ctl_elem_value *ucontrol)
4822{
4823 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4824 struct alc_spec *spec = codec->spec;
4825 *ucontrol->value.integer.value = spec->master_sw;
4826 return 0;
4827}
4828
4829static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4830 struct snd_ctl_elem_value *ucontrol)
4831{
4832 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4833 struct alc_spec *spec = codec->spec;
4834 int val = !!*ucontrol->value.integer.value;
4835 hda_nid_t hp, line, mono;
4836
4837 if (val == spec->master_sw)
4838 return 0;
4839 spec->master_sw = val;
4840 hp = (kcontrol->private_value >> 16) & 0xff;
4841 line = (kcontrol->private_value >> 8) & 0xff;
4842 mono = kcontrol->private_value & 0xff;
4843 alc260_hp_master_update(codec, hp, line, mono);
4844 return 1;
4845}
4846
4847static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4848 {
4849 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4850 .name = "Master Playback Switch",
4851 .info = snd_ctl_boolean_mono_info,
4852 .get = alc260_hp_master_sw_get,
4853 .put = alc260_hp_master_sw_put,
4854 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4855 },
4856 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4857 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4858 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4859 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4860 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4861 HDA_OUTPUT),
4862 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4863 { } /* end */
4864};
4865
4866static struct hda_verb alc260_hp_unsol_verbs[] = {
4867 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4868 {},
4869};
4870
4871static void alc260_hp_automute(struct hda_codec *codec)
4872{
4873 struct alc_spec *spec = codec->spec;
4874 unsigned int present;
4875
4876 present = snd_hda_codec_read(codec, 0x10, 0,
4877 AC_VERB_GET_PIN_SENSE, 0);
4878 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4879 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4880}
4881
4882static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4883{
4884 if ((res >> 26) == ALC880_HP_EVENT)
4885 alc260_hp_automute(codec);
4886}
4887
df694daa 4888static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
bec15c3a
TI
4889 {
4890 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4891 .name = "Master Playback Switch",
4892 .info = snd_ctl_boolean_mono_info,
4893 .get = alc260_hp_master_sw_get,
4894 .put = alc260_hp_master_sw_put,
30cde0aa 4895 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
bec15c3a 4896 },
df694daa
KY
4897 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4898 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4899 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4900 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4901 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4902 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
86cd9298
TI
4903 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4904 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
16ded525
TI
4905 { } /* end */
4906};
4907
3f878308
KY
4908static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4909 .ops = &snd_hda_bind_vol,
4910 .values = {
4911 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4912 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4913 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4914 0
4915 },
4916};
4917
4918static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4919 .ops = &snd_hda_bind_sw,
4920 .values = {
4921 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4922 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4923 0
4924 },
4925};
4926
4927static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4928 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4929 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4930 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4931 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4932 { } /* end */
4933};
4934
bec15c3a
TI
4935static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4936 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4937 {},
4938};
4939
4940static void alc260_hp_3013_automute(struct hda_codec *codec)
4941{
4942 struct alc_spec *spec = codec->spec;
4943 unsigned int present;
4944
4945 present = snd_hda_codec_read(codec, 0x15, 0,
4946 AC_VERB_GET_PIN_SENSE, 0);
4947 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
30cde0aa 4948 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
bec15c3a
TI
4949}
4950
4951static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4952 unsigned int res)
4953{
4954 if ((res >> 26) == ALC880_HP_EVENT)
4955 alc260_hp_3013_automute(codec);
4956}
4957
3f878308
KY
4958static void alc260_hp_3012_automute(struct hda_codec *codec)
4959{
4960 unsigned int present, bits;
4961
4962 present = snd_hda_codec_read(codec, 0x10, 0,
4963 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4964
4965 bits = present ? 0 : PIN_OUT;
4966 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4967 bits);
4968 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4969 bits);
4970 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4971 bits);
4972}
4973
4974static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4975 unsigned int res)
4976{
4977 if ((res >> 26) == ALC880_HP_EVENT)
4978 alc260_hp_3012_automute(codec);
4979}
4980
4981/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
a1e8d2da
JW
4982 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4983 */
c8b6bf9b 4984static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
a9430dd8 4985 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
985be54b 4986 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
4c5186ed 4987 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
a9430dd8
JW
4988 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4989 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4990 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4991 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
4c5186ed 4992 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
31bffaa9
TI
4993 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4994 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
df694daa
KY
4995 { } /* end */
4996};
4997
a1e8d2da
JW
4998/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4999 * versions of the ALC260 don't act on requests to enable mic bias from NID
5000 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5001 * datasheet doesn't mention this restriction. At this stage it's not clear
5002 * whether this behaviour is intentional or is a hardware bug in chip
5003 * revisions available in early 2006. Therefore for now allow the
5004 * "Headphone Jack Mode" control to span all choices, but if it turns out
5005 * that the lack of mic bias for this NID is intentional we could change the
5006 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5007 *
5008 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5009 * don't appear to make the mic bias available from the "line" jack, even
5010 * though the NID used for this jack (0x14) can supply it. The theory is
5011 * that perhaps Acer have included blocking capacitors between the ALC260
5012 * and the output jack. If this turns out to be the case for all such
5013 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5014 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
bd869485
JW
5015 *
5016 * The C20x Tablet series have a mono internal speaker which is controlled
5017 * via the chip's Mono sum widget and pin complex, so include the necessary
5018 * controls for such models. On models without a "mono speaker" the control
5019 * won't do anything.
a1e8d2da 5020 */
0bfc90e9
JW
5021static struct snd_kcontrol_new alc260_acer_mixer[] = {
5022 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5023 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
a1e8d2da 5024 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
31bffaa9 5025 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
bd869485 5026 HDA_OUTPUT),
31bffaa9 5027 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
bd869485 5028 HDA_INPUT),
0bfc90e9
JW
5029 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5030 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5031 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5032 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5033 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5034 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5035 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5036 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
0bfc90e9
JW
5037 { } /* end */
5038};
5039
cc959489
MS
5040/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5041 */
5042static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5043 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5044 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5045 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5046 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5047 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5048 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5049 { } /* end */
5050};
5051
bc9f98a9
KY
5052/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5053 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5054 */
5055static struct snd_kcontrol_new alc260_will_mixer[] = {
5056 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5057 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5059 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5060 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5061 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5062 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5063 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5064 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5065 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
bc9f98a9
KY
5066 { } /* end */
5067};
5068
5069/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5070 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5071 */
5072static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5073 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5074 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5076 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5077 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5078 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5079 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5080 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5081 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5082 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5083 { } /* end */
5084};
5085
df694daa
KY
5086/*
5087 * initialization verbs
5088 */
1da177e4
LT
5089static struct hda_verb alc260_init_verbs[] = {
5090 /* Line In pin widget for input */
05acb863 5091 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1da177e4 5092 /* CD pin widget for input */
05acb863 5093 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1da177e4 5094 /* Mic1 (rear panel) pin widget for input and vref at 80% */
16ded525 5095 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1da177e4 5096 /* Mic2 (front panel) pin widget for input and vref at 80% */
16ded525 5097 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1da177e4 5098 /* LINE-2 is used for line-out in rear */
05acb863 5099 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1da177e4 5100 /* select line-out */
fd56f2db 5101 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
1da177e4 5102 /* LINE-OUT pin */
05acb863 5103 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1da177e4 5104 /* enable HP */
05acb863 5105 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1da177e4 5106 /* enable Mono */
05acb863
TI
5107 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5108 /* mute capture amp left and right */
16ded525 5109 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1da177e4
LT
5110 /* set connection select to line in (default select for this ADC) */
5111 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
16ded525
TI
5112 /* mute capture amp left and right */
5113 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5114 /* set connection select to line in (default select for this ADC) */
5115 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
05acb863
TI
5116 /* set vol=0 Line-Out mixer amp left and right */
5117 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5118 /* unmute pin widget amp left and right (no gain on this amp) */
5119 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5120 /* set vol=0 HP mixer amp left and right */
5121 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5122 /* unmute pin widget amp left and right (no gain on this amp) */
5123 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5124 /* set vol=0 Mono mixer amp left and right */
5125 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5126 /* unmute pin widget amp left and right (no gain on this amp) */
5127 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5128 /* unmute LINE-2 out pin */
5129 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
f12ab1e0
TI
5130 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5131 * Line In 2 = 0x03
5132 */
cb53c626
TI
5133 /* mute analog inputs */
5134 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5135 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5136 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5137 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5138 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1da177e4 5139 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
05acb863
TI
5140 /* mute Front out path */
5141 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5142 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5143 /* mute Headphone out path */
5144 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5145 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5146 /* mute Mono out path */
5147 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5148 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1da177e4
LT
5149 { }
5150};
5151
474167d6 5152#if 0 /* should be identical with alc260_init_verbs? */
df694daa
KY
5153static struct hda_verb alc260_hp_init_verbs[] = {
5154 /* Headphone and output */
5155 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5156 /* mono output */
5157 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5158 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5159 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5160 /* Mic2 (front panel) pin widget for input and vref at 80% */
5161 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5162 /* Line In pin widget for input */
5163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5164 /* Line-2 pin widget for output */
5165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5166 /* CD pin widget for input */
5167 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5168 /* unmute amp left and right */
5169 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5170 /* set connection select to line in (default select for this ADC) */
5171 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5172 /* unmute Line-Out mixer amp left and right (volume = 0) */
5173 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5174 /* mute pin widget amp left and right (no gain on this amp) */
5175 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5176 /* unmute HP mixer amp left and right (volume = 0) */
5177 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5178 /* mute pin widget amp left and right (no gain on this amp) */
5179 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
f12ab1e0
TI
5180 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5181 * Line In 2 = 0x03
5182 */
cb53c626
TI
5183 /* mute analog inputs */
5184 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5185 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5186 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5187 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5188 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
df694daa
KY
5189 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5190 /* Unmute Front out path */
5191 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5192 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5193 /* Unmute Headphone out path */
5194 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5195 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5196 /* Unmute Mono out path */
5197 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5198 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5199 { }
5200};
474167d6 5201#endif
df694daa
KY
5202
5203static struct hda_verb alc260_hp_3013_init_verbs[] = {
5204 /* Line out and output */
5205 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5206 /* mono output */
5207 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5208 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5209 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5210 /* Mic2 (front panel) pin widget for input and vref at 80% */
5211 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5212 /* Line In pin widget for input */
5213 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5214 /* Headphone pin widget for output */
5215 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5216 /* CD pin widget for input */
5217 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5218 /* unmute amp left and right */
5219 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5220 /* set connection select to line in (default select for this ADC) */
5221 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5222 /* unmute Line-Out mixer amp left and right (volume = 0) */
5223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5224 /* mute pin widget amp left and right (no gain on this amp) */
5225 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5226 /* unmute HP mixer amp left and right (volume = 0) */
5227 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5228 /* mute pin widget amp left and right (no gain on this amp) */
5229 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
f12ab1e0
TI
5230 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5231 * Line In 2 = 0x03
5232 */
cb53c626
TI
5233 /* mute analog inputs */
5234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5235 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5236 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5237 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5238 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
df694daa
KY
5239 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5240 /* Unmute Front out path */
5241 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5242 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5243 /* Unmute Headphone out path */
5244 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5245 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5246 /* Unmute Mono out path */
5247 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5248 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5249 { }
5250};
5251
a9430dd8 5252/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
a1e8d2da
JW
5253 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5254 * audio = 0x16, internal speaker = 0x10.
a9430dd8
JW
5255 */
5256static struct hda_verb alc260_fujitsu_init_verbs[] = {
5257 /* Disable all GPIOs */
5258 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5259 /* Internal speaker is connected to headphone pin */
5260 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5261 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5262 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
f7ace40d
JW
5263 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5264 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5265 /* Ensure all other unused pins are disabled and muted. */
5266 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5267 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
a9430dd8 5268 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
f7ace40d 5269 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
a9430dd8 5270 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
f7ace40d
JW
5271 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5272 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5273 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5274
5275 /* Disable digital (SPDIF) pins */
5276 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5277 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
a9430dd8 5278
ea1fb29a 5279 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
f7ace40d
JW
5280 * when acting as an output.
5281 */
5282 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4c5186ed 5283
f7ace40d 5284 /* Start with output sum widgets muted and their output gains at min */
8b33a5aa
TI
5285 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5286 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5287 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5288 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5289 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5290 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5291 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5292 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5293 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
a9430dd8 5294
f7ace40d
JW
5295 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5296 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5297 /* Unmute Line1 pin widget output buffer since it starts as an output.
5298 * If the pin mode is changed by the user the pin mode control will
5299 * take care of enabling the pin's input/output buffers as needed.
5300 * Therefore there's no need to enable the input buffer at this
5301 * stage.
cdcd9268 5302 */
f7ace40d 5303 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
ea1fb29a 5304 /* Unmute input buffer of pin widget used for Line-in (no equiv
cdcd9268
JW
5305 * mixer ctrl)
5306 */
f7ace40d
JW
5307 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5308
5309 /* Mute capture amp left and right */
5310 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
ea1fb29a 5311 /* Set ADC connection select to match default mixer setting - line
f7ace40d
JW
5312 * in (on mic1 pin)
5313 */
5314 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5315
5316 /* Do the same for the second ADC: mute capture input amp and
5317 * set ADC connection to line in (on mic1 pin)
5318 */
5319 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5320 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5321
5322 /* Mute all inputs to mixer widget (even unconnected ones) */
5323 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5324 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5325 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5326 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5327 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5328 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5329 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5330 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4a471b7d
TI
5331
5332 { }
a9430dd8
JW
5333};
5334
0bfc90e9
JW
5335/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5336 * similar laptops (adapted from Fujitsu init verbs).
5337 */
5338static struct hda_verb alc260_acer_init_verbs[] = {
5339 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5340 * the headphone jack. Turn this on and rely on the standard mute
5341 * methods whenever the user wants to turn these outputs off.
5342 */
5343 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5344 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5345 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5346 /* Internal speaker/Headphone jack is connected to Line-out pin */
5347 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5348 /* Internal microphone/Mic jack is connected to Mic1 pin */
5349 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5350 /* Line In jack is connected to Line1 pin */
5351 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
bd869485
JW
5352 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5353 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
0bfc90e9
JW
5354 /* Ensure all other unused pins are disabled and muted. */
5355 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5356 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
0bfc90e9
JW
5357 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5358 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5359 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5361 /* Disable digital (SPDIF) pins */
5362 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5363 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5364
ea1fb29a 5365 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
0bfc90e9
JW
5366 * bus when acting as outputs.
5367 */
5368 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5369 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5370
5371 /* Start with output sum widgets muted and their output gains at min */
5372 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5373 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5374 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5375 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5376 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5377 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5378 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5379 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5380 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5381
f12ab1e0
TI
5382 /* Unmute Line-out pin widget amp left and right
5383 * (no equiv mixer ctrl)
5384 */
0bfc90e9 5385 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
bd869485
JW
5386 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5387 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
0bfc90e9
JW
5388 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5389 * inputs. If the pin mode is changed by the user the pin mode control
5390 * will take care of enabling the pin's input/output buffers as needed.
5391 * Therefore there's no need to enable the input buffer at this
5392 * stage.
5393 */
5394 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5395 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5396
5397 /* Mute capture amp left and right */
5398 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5399 /* Set ADC connection select to match default mixer setting - mic
5400 * (on mic1 pin)
5401 */
5402 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5403
5404 /* Do similar with the second ADC: mute capture input amp and
a1e8d2da 5405 * set ADC connection to mic to match ALSA's default state.
0bfc90e9
JW
5406 */
5407 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
a1e8d2da 5408 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
0bfc90e9
JW
5409
5410 /* Mute all inputs to mixer widget (even unconnected ones) */
5411 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5412 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5413 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5414 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5415 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5416 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5418 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5419
5420 { }
5421};
5422
cc959489
MS
5423/* Initialisation sequence for Maxdata Favorit 100XS
5424 * (adapted from Acer init verbs).
5425 */
5426static struct hda_verb alc260_favorit100_init_verbs[] = {
5427 /* GPIO 0 enables the output jack.
5428 * Turn this on and rely on the standard mute
5429 * methods whenever the user wants to turn these outputs off.
5430 */
5431 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5432 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5433 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5434 /* Line/Mic input jack is connected to Mic1 pin */
5435 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5436 /* Ensure all other unused pins are disabled and muted. */
5437 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5438 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5439 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5440 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5441 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5442 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5445 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5446 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5447 /* Disable digital (SPDIF) pins */
5448 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5449 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5450
5451 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5452 * bus when acting as outputs.
5453 */
5454 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5455 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5456
5457 /* Start with output sum widgets muted and their output gains at min */
5458 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5459 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5460 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5461 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5462 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5463 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5464 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5465 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5466 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5467
5468 /* Unmute Line-out pin widget amp left and right
5469 * (no equiv mixer ctrl)
5470 */
5471 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5472 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5473 * inputs. If the pin mode is changed by the user the pin mode control
5474 * will take care of enabling the pin's input/output buffers as needed.
5475 * Therefore there's no need to enable the input buffer at this
5476 * stage.
5477 */
5478 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5479
5480 /* Mute capture amp left and right */
5481 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5482 /* Set ADC connection select to match default mixer setting - mic
5483 * (on mic1 pin)
5484 */
5485 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5486
5487 /* Do similar with the second ADC: mute capture input amp and
5488 * set ADC connection to mic to match ALSA's default state.
5489 */
5490 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5491 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5492
5493 /* Mute all inputs to mixer widget (even unconnected ones) */
5494 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5495 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5496 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5497 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5498 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5499 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5500 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5501 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5502
5503 { }
5504};
5505
bc9f98a9
KY
5506static struct hda_verb alc260_will_verbs[] = {
5507 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5508 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5509 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5510 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5511 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5512 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5513 {}
5514};
5515
5516static struct hda_verb alc260_replacer_672v_verbs[] = {
5517 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5518 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5519 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5520
5521 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5522 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5523 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5524
5525 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5526 {}
5527};
5528
5529/* toggle speaker-output according to the hp-jack state */
5530static void alc260_replacer_672v_automute(struct hda_codec *codec)
5531{
5532 unsigned int present;
5533
5534 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5535 present = snd_hda_codec_read(codec, 0x0f, 0,
5536 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5537 if (present) {
82beb8fd
TI
5538 snd_hda_codec_write_cache(codec, 0x01, 0,
5539 AC_VERB_SET_GPIO_DATA, 1);
5540 snd_hda_codec_write_cache(codec, 0x0f, 0,
5541 AC_VERB_SET_PIN_WIDGET_CONTROL,
5542 PIN_HP);
bc9f98a9 5543 } else {
82beb8fd
TI
5544 snd_hda_codec_write_cache(codec, 0x01, 0,
5545 AC_VERB_SET_GPIO_DATA, 0);
5546 snd_hda_codec_write_cache(codec, 0x0f, 0,
5547 AC_VERB_SET_PIN_WIDGET_CONTROL,
5548 PIN_OUT);
bc9f98a9
KY
5549 }
5550}
5551
5552static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5553 unsigned int res)
5554{
5555 if ((res >> 26) == ALC880_HP_EVENT)
5556 alc260_replacer_672v_automute(codec);
5557}
5558
3f878308
KY
5559static struct hda_verb alc260_hp_dc7600_verbs[] = {
5560 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5561 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5562 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5563 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5564 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5565 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5566 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5567 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5568 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5569 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5570 {}
5571};
5572
7cf51e48
JW
5573/* Test configuration for debugging, modelled after the ALC880 test
5574 * configuration.
5575 */
5576#ifdef CONFIG_SND_DEBUG
5577static hda_nid_t alc260_test_dac_nids[1] = {
5578 0x02,
5579};
5580static hda_nid_t alc260_test_adc_nids[2] = {
5581 0x04, 0x05,
5582};
a1e8d2da 5583/* For testing the ALC260, each input MUX needs its own definition since
ea1fb29a 5584 * the signal assignments are different. This assumes that the first ADC
a1e8d2da 5585 * is NID 0x04.
17e7aec6 5586 */
a1e8d2da
JW
5587static struct hda_input_mux alc260_test_capture_sources[2] = {
5588 {
5589 .num_items = 7,
5590 .items = {
5591 { "MIC1 pin", 0x0 },
5592 { "MIC2 pin", 0x1 },
5593 { "LINE1 pin", 0x2 },
5594 { "LINE2 pin", 0x3 },
5595 { "CD pin", 0x4 },
5596 { "LINE-OUT pin", 0x5 },
5597 { "HP-OUT pin", 0x6 },
5598 },
5599 },
5600 {
5601 .num_items = 8,
5602 .items = {
5603 { "MIC1 pin", 0x0 },
5604 { "MIC2 pin", 0x1 },
5605 { "LINE1 pin", 0x2 },
5606 { "LINE2 pin", 0x3 },
5607 { "CD pin", 0x4 },
5608 { "Mixer", 0x5 },
5609 { "LINE-OUT pin", 0x6 },
5610 { "HP-OUT pin", 0x7 },
5611 },
7cf51e48
JW
5612 },
5613};
5614static struct snd_kcontrol_new alc260_test_mixer[] = {
5615 /* Output driver widgets */
5616 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5617 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5618 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5619 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5620 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5621 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5622
a1e8d2da
JW
5623 /* Modes for retasking pin widgets
5624 * Note: the ALC260 doesn't seem to act on requests to enable mic
5625 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5626 * mention this restriction. At this stage it's not clear whether
5627 * this behaviour is intentional or is a hardware bug in chip
5628 * revisions available at least up until early 2006. Therefore for
5629 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5630 * choices, but if it turns out that the lack of mic bias for these
5631 * NIDs is intentional we could change their modes from
5632 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5633 */
7cf51e48
JW
5634 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5635 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5636 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5637 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5638 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5639 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5640
5641 /* Loopback mixer controls */
5642 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5643 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5644 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5645 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5646 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5647 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5648 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5649 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5650 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5651 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
7cf51e48
JW
5652 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5653 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5654 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5655 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
5c8f858d
JW
5656
5657 /* Controls for GPIO pins, assuming they are configured as outputs */
5658 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5659 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5660 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5661 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5662
92621f13
JW
5663 /* Switches to allow the digital IO pins to be enabled. The datasheet
5664 * is ambigious as to which NID is which; testing on laptops which
ea1fb29a 5665 * make this output available should provide clarification.
92621f13
JW
5666 */
5667 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5668 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5669
f8225f6d
JW
5670 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5671 * this output to turn on an external amplifier.
5672 */
5673 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5674 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5675
7cf51e48
JW
5676 { } /* end */
5677};
5678static struct hda_verb alc260_test_init_verbs[] = {
5c8f858d
JW
5679 /* Enable all GPIOs as outputs with an initial value of 0 */
5680 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5681 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5682 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5683
7cf51e48
JW
5684 /* Enable retasking pins as output, initially without power amp */
5685 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5686 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5687 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5688 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5689 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5690 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5691
92621f13
JW
5692 /* Disable digital (SPDIF) pins initially, but users can enable
5693 * them via a mixer switch. In the case of SPDIF-out, this initverb
5694 * payload also sets the generation to 0, output to be in "consumer"
5695 * PCM format, copyright asserted, no pre-emphasis and no validity
5696 * control.
5697 */
7cf51e48
JW
5698 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5699 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5700
ea1fb29a 5701 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
7cf51e48
JW
5702 * OUT1 sum bus when acting as an output.
5703 */
5704 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5705 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5706 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5707 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5708
5709 /* Start with output sum widgets muted and their output gains at min */
5710 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5711 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5712 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5713 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5714 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5715 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5716 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5717 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5718 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5719
cdcd9268
JW
5720 /* Unmute retasking pin widget output buffers since the default
5721 * state appears to be output. As the pin mode is changed by the
5722 * user the pin mode control will take care of enabling the pin's
5723 * input/output buffers as needed.
5724 */
7cf51e48
JW
5725 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5726 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5727 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5728 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5729 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5730 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5731 /* Also unmute the mono-out pin widget */
5732 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5733
7cf51e48
JW
5734 /* Mute capture amp left and right */
5735 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
f7ace40d
JW
5736 /* Set ADC connection select to match default mixer setting (mic1
5737 * pin)
7cf51e48
JW
5738 */
5739 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5740
5741 /* Do the same for the second ADC: mute capture input amp and
f7ace40d 5742 * set ADC connection to mic1 pin
7cf51e48
JW
5743 */
5744 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5745 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5746
5747 /* Mute all inputs to mixer widget (even unconnected ones) */
5748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5749 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5750 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5752 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5754 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5755 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5756
5757 { }
5758};
5759#endif
5760
6330079f
TI
5761#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5762#define alc260_pcm_analog_capture alc880_pcm_analog_capture
1da177e4 5763
a3bcba38
TI
5764#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5765#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5766
df694daa
KY
5767/*
5768 * for BIOS auto-configuration
5769 */
16ded525 5770
df694daa 5771static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
863b4518 5772 const char *pfx, int *vol_bits)
df694daa
KY
5773{
5774 hda_nid_t nid_vol;
5775 unsigned long vol_val, sw_val;
5776 char name[32];
5777 int err;
5778
5779 if (nid >= 0x0f && nid < 0x11) {
5780 nid_vol = nid - 0x7;
5781 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5782 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5783 } else if (nid == 0x11) {
5784 nid_vol = nid - 0x7;
5785 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5786 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5787 } else if (nid >= 0x12 && nid <= 0x15) {
5788 nid_vol = 0x08;
5789 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5790 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5791 } else
5792 return 0; /* N/A */
ea1fb29a 5793
863b4518
TI
5794 if (!(*vol_bits & (1 << nid_vol))) {
5795 /* first control for the volume widget */
5796 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5797 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5798 if (err < 0)
5799 return err;
5800 *vol_bits |= (1 << nid_vol);
5801 }
df694daa 5802 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
f12ab1e0
TI
5803 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5804 if (err < 0)
df694daa
KY
5805 return err;
5806 return 1;
5807}
5808
5809/* add playback controls from the parsed DAC table */
5810static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5811 const struct auto_pin_cfg *cfg)
5812{
5813 hda_nid_t nid;
5814 int err;
863b4518 5815 int vols = 0;
df694daa
KY
5816
5817 spec->multiout.num_dacs = 1;
5818 spec->multiout.dac_nids = spec->private_dac_nids;
5819 spec->multiout.dac_nids[0] = 0x02;
5820
5821 nid = cfg->line_out_pins[0];
5822 if (nid) {
863b4518 5823 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
df694daa
KY
5824 if (err < 0)
5825 return err;
5826 }
5827
82bc955f 5828 nid = cfg->speaker_pins[0];
df694daa 5829 if (nid) {
863b4518 5830 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
df694daa
KY
5831 if (err < 0)
5832 return err;
5833 }
5834
eb06ed8f 5835 nid = cfg->hp_pins[0];
df694daa 5836 if (nid) {
863b4518
TI
5837 err = alc260_add_playback_controls(spec, nid, "Headphone",
5838 &vols);
df694daa
KY
5839 if (err < 0)
5840 return err;
5841 }
f12ab1e0 5842 return 0;
df694daa
KY
5843}
5844
5845/* create playback/capture controls for input pins */
5846static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5847 const struct auto_pin_cfg *cfg)
5848{
61b9b9b1 5849 struct hda_input_mux *imux = &spec->private_imux[0];
df694daa
KY
5850 int i, err, idx;
5851
5852 for (i = 0; i < AUTO_PIN_LAST; i++) {
5853 if (cfg->input_pins[i] >= 0x12) {
5854 idx = cfg->input_pins[i] - 0x12;
4a471b7d 5855 err = new_analog_input(spec, cfg->input_pins[i],
f12ab1e0
TI
5856 auto_pin_cfg_labels[i], idx,
5857 0x07);
df694daa
KY
5858 if (err < 0)
5859 return err;
f12ab1e0
TI
5860 imux->items[imux->num_items].label =
5861 auto_pin_cfg_labels[i];
df694daa
KY
5862 imux->items[imux->num_items].index = idx;
5863 imux->num_items++;
5864 }
f12ab1e0 5865 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
df694daa 5866 idx = cfg->input_pins[i] - 0x09;
4a471b7d 5867 err = new_analog_input(spec, cfg->input_pins[i],
f12ab1e0
TI
5868 auto_pin_cfg_labels[i], idx,
5869 0x07);
df694daa
KY
5870 if (err < 0)
5871 return err;
f12ab1e0
TI
5872 imux->items[imux->num_items].label =
5873 auto_pin_cfg_labels[i];
df694daa
KY
5874 imux->items[imux->num_items].index = idx;
5875 imux->num_items++;
5876 }
5877 }
5878 return 0;
5879}
5880
5881static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5882 hda_nid_t nid, int pin_type,
5883 int sel_idx)
5884{
f6c7e546 5885 alc_set_pin_output(codec, nid, pin_type);
df694daa
KY
5886 /* need the manual connection? */
5887 if (nid >= 0x12) {
5888 int idx = nid - 0x12;
5889 snd_hda_codec_write(codec, idx + 0x0b, 0,
5890 AC_VERB_SET_CONNECT_SEL, sel_idx);
df694daa
KY
5891 }
5892}
5893
5894static void alc260_auto_init_multi_out(struct hda_codec *codec)
5895{
5896 struct alc_spec *spec = codec->spec;
5897 hda_nid_t nid;
5898
f12ab1e0 5899 nid = spec->autocfg.line_out_pins[0];
baba8ee9
TI
5900 if (nid) {
5901 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5902 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5903 }
ea1fb29a 5904
82bc955f 5905 nid = spec->autocfg.speaker_pins[0];
df694daa
KY
5906 if (nid)
5907 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5908
eb06ed8f 5909 nid = spec->autocfg.hp_pins[0];
df694daa 5910 if (nid)
baba8ee9 5911 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
f12ab1e0 5912}
df694daa
KY
5913
5914#define ALC260_PIN_CD_NID 0x16
5915static void alc260_auto_init_analog_input(struct hda_codec *codec)
5916{
5917 struct alc_spec *spec = codec->spec;
5918 int i;
5919
5920 for (i = 0; i < AUTO_PIN_LAST; i++) {
5921 hda_nid_t nid = spec->autocfg.input_pins[i];
5922 if (nid >= 0x12) {
23f0c048 5923 alc_set_input_pin(codec, nid, i);
e82c025b
TI
5924 if (nid != ALC260_PIN_CD_NID &&
5925 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
f12ab1e0
TI
5926 snd_hda_codec_write(codec, nid, 0,
5927 AC_VERB_SET_AMP_GAIN_MUTE,
df694daa
KY
5928 AMP_OUT_MUTE);
5929 }
5930 }
5931}
5932
5933/*
5934 * generic initialization of ADC, input mixers and output mixers
5935 */
5936static struct hda_verb alc260_volume_init_verbs[] = {
5937 /*
5938 * Unmute ADC0-1 and set the default input to mic-in
5939 */
5940 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5941 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5942 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5943 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
ea1fb29a 5944
df694daa
KY
5945 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5946 * mixer widget
f12ab1e0
TI
5947 * Note: PASD motherboards uses the Line In 2 as the input for
5948 * front panel mic (mic 2)
df694daa
KY
5949 */
5950 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
cb53c626
TI
5951 /* mute analog inputs */
5952 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5953 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5954 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5955 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5956 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
df694daa
KY
5957
5958 /*
5959 * Set up output mixers (0x08 - 0x0a)
5960 */
5961 /* set vol=0 to output mixers */
5962 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5963 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5964 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5965 /* set up input amps for analog loopback */
5966 /* Amp Indices: DAC = 0, mixer = 1 */
5967 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5968 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5969 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5970 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5971 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5972 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
ea1fb29a 5973
df694daa
KY
5974 { }
5975};
5976
5977static int alc260_parse_auto_config(struct hda_codec *codec)
5978{
5979 struct alc_spec *spec = codec->spec;
df694daa
KY
5980 int err;
5981 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5982
f12ab1e0
TI
5983 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5984 alc260_ignore);
5985 if (err < 0)
df694daa 5986 return err;
f12ab1e0
TI
5987 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5988 if (err < 0)
4a471b7d 5989 return err;
603c4019 5990 if (!spec->kctls.list)
df694daa 5991 return 0; /* can't find valid BIOS pin config */
f12ab1e0
TI
5992 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5993 if (err < 0)
df694daa
KY
5994 return err;
5995
5996 spec->multiout.max_channels = 2;
5997
0852d7a6 5998 if (spec->autocfg.dig_outs)
df694daa 5999 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
603c4019 6000 if (spec->kctls.list)
d88897ea 6001 add_mixer(spec, spec->kctls.list);
df694daa 6002
d88897ea 6003 add_verb(spec, alc260_volume_init_verbs);
df694daa 6004
a1e8d2da 6005 spec->num_mux_defs = 1;
61b9b9b1 6006 spec->input_mux = &spec->private_imux[0];
df694daa 6007
4a79ba34
TI
6008 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6009
df694daa
KY
6010 return 1;
6011}
6012
ae6b813a
TI
6013/* additional initialization for auto-configuration model */
6014static void alc260_auto_init(struct hda_codec *codec)
df694daa 6015{
f6c7e546 6016 struct alc_spec *spec = codec->spec;
df694daa
KY
6017 alc260_auto_init_multi_out(codec);
6018 alc260_auto_init_analog_input(codec);
f6c7e546 6019 if (spec->unsol_event)
7fb0d78f 6020 alc_inithook(codec);
df694daa
KY
6021}
6022
cb53c626
TI
6023#ifdef CONFIG_SND_HDA_POWER_SAVE
6024static struct hda_amp_list alc260_loopbacks[] = {
6025 { 0x07, HDA_INPUT, 0 },
6026 { 0x07, HDA_INPUT, 1 },
6027 { 0x07, HDA_INPUT, 2 },
6028 { 0x07, HDA_INPUT, 3 },
6029 { 0x07, HDA_INPUT, 4 },
6030 { } /* end */
6031};
6032#endif
6033
df694daa
KY
6034/*
6035 * ALC260 configurations
6036 */
f5fcc13c
TI
6037static const char *alc260_models[ALC260_MODEL_LAST] = {
6038 [ALC260_BASIC] = "basic",
6039 [ALC260_HP] = "hp",
6040 [ALC260_HP_3013] = "hp-3013",
2922c9af 6041 [ALC260_HP_DC7600] = "hp-dc7600",
f5fcc13c
TI
6042 [ALC260_FUJITSU_S702X] = "fujitsu",
6043 [ALC260_ACER] = "acer",
bc9f98a9
KY
6044 [ALC260_WILL] = "will",
6045 [ALC260_REPLACER_672V] = "replacer",
cc959489 6046 [ALC260_FAVORIT100] = "favorit100",
7cf51e48 6047#ifdef CONFIG_SND_DEBUG
f5fcc13c 6048 [ALC260_TEST] = "test",
7cf51e48 6049#endif
f5fcc13c
TI
6050 [ALC260_AUTO] = "auto",
6051};
6052
6053static struct snd_pci_quirk alc260_cfg_tbl[] = {
bd869485 6054 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
f5fcc13c 6055 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
cc959489 6056 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
9720b718 6057 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
a8a5d067 6058 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
f5fcc13c 6059 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
34ec8a0a 6060 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
3f878308 6061 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
f5fcc13c
TI
6062 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6063 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6064 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6065 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6066 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6067 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6068 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6069 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6070 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
bc9f98a9 6071 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
ac3e3741 6072 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
df694daa
KY
6073 {}
6074};
6075
6076static struct alc_config_preset alc260_presets[] = {
6077 [ALC260_BASIC] = {
6078 .mixers = { alc260_base_output_mixer,
45bdd1c1 6079 alc260_input_mixer },
df694daa
KY
6080 .init_verbs = { alc260_init_verbs },
6081 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6082 .dac_nids = alc260_dac_nids,
f9e336f6 6083 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
df694daa
KY
6084 .adc_nids = alc260_adc_nids,
6085 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6086 .channel_mode = alc260_modes,
6087 .input_mux = &alc260_capture_source,
6088 },
6089 [ALC260_HP] = {
bec15c3a 6090 .mixers = { alc260_hp_output_mixer,
f9e336f6 6091 alc260_input_mixer },
bec15c3a
TI
6092 .init_verbs = { alc260_init_verbs,
6093 alc260_hp_unsol_verbs },
df694daa
KY
6094 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6095 .dac_nids = alc260_dac_nids,
f9e336f6
TI
6096 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6097 .adc_nids = alc260_adc_nids_alt,
df694daa
KY
6098 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6099 .channel_mode = alc260_modes,
6100 .input_mux = &alc260_capture_source,
bec15c3a
TI
6101 .unsol_event = alc260_hp_unsol_event,
6102 .init_hook = alc260_hp_automute,
df694daa 6103 },
3f878308
KY
6104 [ALC260_HP_DC7600] = {
6105 .mixers = { alc260_hp_dc7600_mixer,
f9e336f6 6106 alc260_input_mixer },
3f878308
KY
6107 .init_verbs = { alc260_init_verbs,
6108 alc260_hp_dc7600_verbs },
6109 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6110 .dac_nids = alc260_dac_nids,
f9e336f6
TI
6111 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6112 .adc_nids = alc260_adc_nids_alt,
3f878308
KY
6113 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6114 .channel_mode = alc260_modes,
6115 .input_mux = &alc260_capture_source,
6116 .unsol_event = alc260_hp_3012_unsol_event,
6117 .init_hook = alc260_hp_3012_automute,
6118 },
df694daa
KY
6119 [ALC260_HP_3013] = {
6120 .mixers = { alc260_hp_3013_mixer,
f9e336f6 6121 alc260_input_mixer },
bec15c3a
TI
6122 .init_verbs = { alc260_hp_3013_init_verbs,
6123 alc260_hp_3013_unsol_verbs },
df694daa
KY
6124 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6125 .dac_nids = alc260_dac_nids,
f9e336f6
TI
6126 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6127 .adc_nids = alc260_adc_nids_alt,
df694daa
KY
6128 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6129 .channel_mode = alc260_modes,
6130 .input_mux = &alc260_capture_source,
bec15c3a
TI
6131 .unsol_event = alc260_hp_3013_unsol_event,
6132 .init_hook = alc260_hp_3013_automute,
df694daa
KY
6133 },
6134 [ALC260_FUJITSU_S702X] = {
f9e336f6 6135 .mixers = { alc260_fujitsu_mixer },
df694daa
KY
6136 .init_verbs = { alc260_fujitsu_init_verbs },
6137 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6138 .dac_nids = alc260_dac_nids,
d57fdac0
JW
6139 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6140 .adc_nids = alc260_dual_adc_nids,
df694daa
KY
6141 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6142 .channel_mode = alc260_modes,
a1e8d2da
JW
6143 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6144 .input_mux = alc260_fujitsu_capture_sources,
df694daa 6145 },
0bfc90e9 6146 [ALC260_ACER] = {
f9e336f6 6147 .mixers = { alc260_acer_mixer },
0bfc90e9
JW
6148 .init_verbs = { alc260_acer_init_verbs },
6149 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6150 .dac_nids = alc260_dac_nids,
6151 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6152 .adc_nids = alc260_dual_adc_nids,
6153 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6154 .channel_mode = alc260_modes,
a1e8d2da
JW
6155 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6156 .input_mux = alc260_acer_capture_sources,
0bfc90e9 6157 },
cc959489
MS
6158 [ALC260_FAVORIT100] = {
6159 .mixers = { alc260_favorit100_mixer },
6160 .init_verbs = { alc260_favorit100_init_verbs },
6161 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6162 .dac_nids = alc260_dac_nids,
6163 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6164 .adc_nids = alc260_dual_adc_nids,
6165 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6166 .channel_mode = alc260_modes,
6167 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6168 .input_mux = alc260_favorit100_capture_sources,
6169 },
bc9f98a9 6170 [ALC260_WILL] = {
f9e336f6 6171 .mixers = { alc260_will_mixer },
bc9f98a9
KY
6172 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6173 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6174 .dac_nids = alc260_dac_nids,
6175 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6176 .adc_nids = alc260_adc_nids,
6177 .dig_out_nid = ALC260_DIGOUT_NID,
6178 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6179 .channel_mode = alc260_modes,
6180 .input_mux = &alc260_capture_source,
6181 },
6182 [ALC260_REPLACER_672V] = {
f9e336f6 6183 .mixers = { alc260_replacer_672v_mixer },
bc9f98a9
KY
6184 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6185 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6186 .dac_nids = alc260_dac_nids,
6187 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6188 .adc_nids = alc260_adc_nids,
6189 .dig_out_nid = ALC260_DIGOUT_NID,
6190 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6191 .channel_mode = alc260_modes,
6192 .input_mux = &alc260_capture_source,
6193 .unsol_event = alc260_replacer_672v_unsol_event,
6194 .init_hook = alc260_replacer_672v_automute,
6195 },
7cf51e48
JW
6196#ifdef CONFIG_SND_DEBUG
6197 [ALC260_TEST] = {
f9e336f6 6198 .mixers = { alc260_test_mixer },
7cf51e48
JW
6199 .init_verbs = { alc260_test_init_verbs },
6200 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6201 .dac_nids = alc260_test_dac_nids,
6202 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6203 .adc_nids = alc260_test_adc_nids,
6204 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6205 .channel_mode = alc260_modes,
a1e8d2da
JW
6206 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6207 .input_mux = alc260_test_capture_sources,
7cf51e48
JW
6208 },
6209#endif
df694daa
KY
6210};
6211
6212static int patch_alc260(struct hda_codec *codec)
1da177e4
LT
6213{
6214 struct alc_spec *spec;
df694daa 6215 int err, board_config;
1da177e4 6216
e560d8d8 6217 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1da177e4
LT
6218 if (spec == NULL)
6219 return -ENOMEM;
6220
6221 codec->spec = spec;
6222
f5fcc13c
TI
6223 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6224 alc260_models,
6225 alc260_cfg_tbl);
6226 if (board_config < 0) {
6c627f39
TI
6227 snd_printd(KERN_INFO "hda_codec: Unknown model for %s, "
6228 "trying auto-probe from BIOS...\n",
6229 codec->chip_name);
df694daa 6230 board_config = ALC260_AUTO;
16ded525 6231 }
1da177e4 6232
df694daa
KY
6233 if (board_config == ALC260_AUTO) {
6234 /* automatic parse from the BIOS config */
6235 err = alc260_parse_auto_config(codec);
6236 if (err < 0) {
6237 alc_free(codec);
6238 return err;
f12ab1e0 6239 } else if (!err) {
9c7f852e
TI
6240 printk(KERN_INFO
6241 "hda_codec: Cannot set up configuration "
6242 "from BIOS. Using base mode...\n");
df694daa
KY
6243 board_config = ALC260_BASIC;
6244 }
a9430dd8 6245 }
e9edcee0 6246
680cd536
KK
6247 err = snd_hda_attach_beep_device(codec, 0x1);
6248 if (err < 0) {
6249 alc_free(codec);
6250 return err;
6251 }
6252
df694daa
KY
6253 if (board_config != ALC260_AUTO)
6254 setup_preset(spec, &alc260_presets[board_config]);
1da177e4 6255
1da177e4
LT
6256 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6257 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6258
a3bcba38
TI
6259 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6260 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6261
4ef0ef19
TI
6262 if (!spec->adc_nids && spec->input_mux) {
6263 /* check whether NID 0x04 is valid */
6264 unsigned int wcap = get_wcaps(codec, 0x04);
6265 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6266 /* get type */
6267 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6268 spec->adc_nids = alc260_adc_nids_alt;
6269 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6270 } else {
6271 spec->adc_nids = alc260_adc_nids;
6272 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6273 }
6274 }
f9e336f6 6275 set_capture_mixer(spec);
45bdd1c1 6276 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
f9e336f6 6277
2134ea4f
TI
6278 spec->vmaster_nid = 0x08;
6279
1da177e4 6280 codec->patch_ops = alc_patch_ops;
df694daa 6281 if (board_config == ALC260_AUTO)
ae6b813a 6282 spec->init_hook = alc260_auto_init;
cb53c626
TI
6283#ifdef CONFIG_SND_HDA_POWER_SAVE
6284 if (!spec->loopback.amplist)
6285 spec->loopback.amplist = alc260_loopbacks;
6286#endif
daead538 6287 codec->proc_widget_hook = print_realtek_coef;
1da177e4
LT
6288
6289 return 0;
6290}
6291
e9edcee0 6292
1da177e4 6293/*
4953550a 6294 * ALC882/883/885/888/889 support
1da177e4
LT
6295 *
6296 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6297 * configuration. Each pin widget can choose any input DACs and a mixer.
6298 * Each ADC is connected from a mixer of all inputs. This makes possible
6299 * 6-channel independent captures.
6300 *
6301 * In addition, an independent DAC for the multi-playback (not used in this
6302 * driver yet).
6303 */
df694daa
KY
6304#define ALC882_DIGOUT_NID 0x06
6305#define ALC882_DIGIN_NID 0x0a
4953550a
TI
6306#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6307#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6308#define ALC1200_DIGOUT_NID 0x10
6309
1da177e4 6310
d2a6d7dc 6311static struct hda_channel_mode alc882_ch_modes[1] = {
1da177e4
LT
6312 { 8, NULL }
6313};
6314
4953550a 6315/* DACs */
1da177e4
LT
6316static hda_nid_t alc882_dac_nids[4] = {
6317 /* front, rear, clfe, rear_surr */
6318 0x02, 0x03, 0x04, 0x05
6319};
4953550a 6320#define alc883_dac_nids alc882_dac_nids
1da177e4 6321
4953550a 6322/* ADCs */
df694daa
KY
6323#define alc882_adc_nids alc880_adc_nids
6324#define alc882_adc_nids_alt alc880_adc_nids_alt
4953550a
TI
6325#define alc883_adc_nids alc882_adc_nids_alt
6326static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6327static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6328#define alc889_adc_nids alc880_adc_nids
1da177e4 6329
e1406348
TI
6330static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6331static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
4953550a
TI
6332#define alc883_capsrc_nids alc882_capsrc_nids_alt
6333static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6334#define alc889_capsrc_nids alc882_capsrc_nids
e1406348 6335
1da177e4
LT
6336/* input MUX */
6337/* FIXME: should be a matrix-type input source selection */
6338
6339static struct hda_input_mux alc882_capture_source = {
6340 .num_items = 4,
6341 .items = {
6342 { "Mic", 0x0 },
6343 { "Front Mic", 0x1 },
6344 { "Line", 0x2 },
6345 { "CD", 0x4 },
6346 },
6347};
41d5545d 6348
4953550a
TI
6349#define alc883_capture_source alc882_capture_source
6350
41d5545d
KS
6351static struct hda_input_mux mb5_capture_source = {
6352 .num_items = 3,
6353 .items = {
6354 { "Mic", 0x1 },
6355 { "Line", 0x2 },
6356 { "CD", 0x4 },
6357 },
6358};
6359
4953550a
TI
6360static struct hda_input_mux alc883_3stack_6ch_intel = {
6361 .num_items = 4,
6362 .items = {
6363 { "Mic", 0x1 },
6364 { "Front Mic", 0x0 },
6365 { "Line", 0x2 },
6366 { "CD", 0x4 },
6367 },
6368};
6369
6370static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6371 .num_items = 2,
6372 .items = {
6373 { "Mic", 0x1 },
6374 { "Line", 0x2 },
6375 },
6376};
6377
6378static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6379 .num_items = 4,
6380 .items = {
6381 { "Mic", 0x0 },
6382 { "iMic", 0x1 },
6383 { "Line", 0x2 },
6384 { "CD", 0x4 },
6385 },
6386};
6387
6388static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6389 .num_items = 2,
6390 .items = {
6391 { "Mic", 0x0 },
6392 { "Int Mic", 0x1 },
6393 },
6394};
6395
6396static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6397 .num_items = 3,
6398 .items = {
6399 { "Mic", 0x0 },
6400 { "Front Mic", 0x1 },
6401 { "Line", 0x4 },
6402 },
6403};
6404
6405static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6406 .num_items = 2,
6407 .items = {
6408 { "Mic", 0x0 },
6409 { "Line", 0x2 },
6410 },
6411};
6412
6413static struct hda_input_mux alc889A_mb31_capture_source = {
6414 .num_items = 2,
6415 .items = {
6416 { "Mic", 0x0 },
6417 /* Front Mic (0x01) unused */
6418 { "Line", 0x2 },
6419 /* Line 2 (0x03) unused */
6420 /* CD (0x04) unsused? */
6421 },
6422};
6423
6424/*
6425 * 2ch mode
6426 */
6427static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6428 { 2, NULL }
6429};
6430
272a527c
KY
6431/*
6432 * 2ch mode
6433 */
6434static struct hda_verb alc882_3ST_ch2_init[] = {
6435 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6436 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6437 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6438 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6439 { } /* end */
6440};
6441
4953550a
TI
6442/*
6443 * 4ch mode
6444 */
6445static struct hda_verb alc882_3ST_ch4_init[] = {
6446 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6447 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6448 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6449 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6450 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6451 { } /* end */
6452};
6453
272a527c
KY
6454/*
6455 * 6ch mode
6456 */
6457static struct hda_verb alc882_3ST_ch6_init[] = {
6458 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6459 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6460 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6461 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6462 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6463 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6464 { } /* end */
6465};
6466
4953550a 6467static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
272a527c 6468 { 2, alc882_3ST_ch2_init },
4953550a 6469 { 4, alc882_3ST_ch4_init },
272a527c
KY
6470 { 6, alc882_3ST_ch6_init },
6471};
6472
4953550a
TI
6473#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6474
df694daa
KY
6475/*
6476 * 6ch mode
6477 */
6478static struct hda_verb alc882_sixstack_ch6_init[] = {
6479 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6480 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6481 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6482 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6483 { } /* end */
6484};
6485
6486/*
6487 * 8ch mode
6488 */
6489static struct hda_verb alc882_sixstack_ch8_init[] = {
6490 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6491 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6492 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6493 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6494 { } /* end */
6495};
6496
6497static struct hda_channel_mode alc882_sixstack_modes[2] = {
6498 { 6, alc882_sixstack_ch6_init },
6499 { 8, alc882_sixstack_ch8_init },
6500};
6501
87350ad0 6502/*
def319f9 6503 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
87350ad0
TI
6504 */
6505
6506/*
6507 * 2ch mode
6508 */
6509static struct hda_verb alc885_mbp_ch2_init[] = {
6510 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6511 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6512 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6513 { } /* end */
6514};
6515
6516/*
6517 * 6ch mode
6518 */
6519static struct hda_verb alc885_mbp_ch6_init[] = {
6520 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6521 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6522 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6523 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6524 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6525 { } /* end */
6526};
6527
6528static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6529 { 2, alc885_mbp_ch2_init },
6530 { 6, alc885_mbp_ch6_init },
6531};
6532
92b9de83
KS
6533/*
6534 * 2ch
6535 * Speakers/Woofer/HP = Front
6536 * LineIn = Input
6537 */
6538static struct hda_verb alc885_mb5_ch2_init[] = {
6539 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6540 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6541 { } /* end */
6542};
6543
6544/*
6545 * 6ch mode
6546 * Speakers/HP = Front
6547 * Woofer = LFE
6548 * LineIn = Surround
6549 */
6550static struct hda_verb alc885_mb5_ch6_init[] = {
6551 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6552 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6553 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6554 { } /* end */
6555};
6556
6557static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6558 { 2, alc885_mb5_ch2_init },
6559 { 6, alc885_mb5_ch6_init },
6560};
87350ad0 6561
4953550a
TI
6562
6563/*
6564 * 2ch mode
6565 */
6566static struct hda_verb alc883_4ST_ch2_init[] = {
6567 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6568 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6569 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6570 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6571 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6572 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6573 { } /* end */
6574};
6575
6576/*
6577 * 4ch mode
6578 */
6579static struct hda_verb alc883_4ST_ch4_init[] = {
6580 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6581 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6582 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6583 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6584 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6585 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6586 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6587 { } /* end */
6588};
6589
6590/*
6591 * 6ch mode
6592 */
6593static struct hda_verb alc883_4ST_ch6_init[] = {
6594 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6595 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6596 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6597 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6598 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6599 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6600 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6601 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6602 { } /* end */
6603};
6604
6605/*
6606 * 8ch mode
6607 */
6608static struct hda_verb alc883_4ST_ch8_init[] = {
6609 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6610 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6611 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6612 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6613 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6614 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6615 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6616 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6617 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6618 { } /* end */
6619};
6620
6621static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6622 { 2, alc883_4ST_ch2_init },
6623 { 4, alc883_4ST_ch4_init },
6624 { 6, alc883_4ST_ch6_init },
6625 { 8, alc883_4ST_ch8_init },
6626};
6627
6628
6629/*
6630 * 2ch mode
6631 */
6632static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6633 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6634 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6635 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6636 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6637 { } /* end */
6638};
6639
6640/*
6641 * 4ch mode
6642 */
6643static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6644 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6645 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6646 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6647 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6648 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6649 { } /* end */
6650};
6651
6652/*
6653 * 6ch mode
6654 */
6655static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6656 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6657 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6658 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6659 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6660 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6661 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6662 { } /* end */
6663};
6664
6665static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6666 { 2, alc883_3ST_ch2_intel_init },
6667 { 4, alc883_3ST_ch4_intel_init },
6668 { 6, alc883_3ST_ch6_intel_init },
6669};
6670
6671/*
6672 * 6ch mode
6673 */
6674static struct hda_verb alc883_sixstack_ch6_init[] = {
6675 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6676 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6677 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6678 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6679 { } /* end */
6680};
6681
6682/*
6683 * 8ch mode
6684 */
6685static struct hda_verb alc883_sixstack_ch8_init[] = {
6686 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6687 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6688 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6689 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6690 { } /* end */
6691};
6692
6693static struct hda_channel_mode alc883_sixstack_modes[2] = {
6694 { 6, alc883_sixstack_ch6_init },
6695 { 8, alc883_sixstack_ch8_init },
6696};
6697
6698
1da177e4
LT
6699/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6700 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6701 */
c8b6bf9b 6702static struct snd_kcontrol_new alc882_base_mixer[] = {
05acb863 6703 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
985be54b 6704 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
05acb863 6705 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
985be54b 6706 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
05acb863
TI
6707 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6708 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
985be54b
TI
6709 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6710 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
05acb863 6711 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
985be54b 6712 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1da177e4
LT
6713 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6714 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6715 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6716 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6717 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
32360416 6719 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1da177e4
LT
6720 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6721 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
32360416 6722 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
1da177e4 6723 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1da177e4
LT
6724 { } /* end */
6725};
6726
87350ad0 6727static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
2134ea4f
TI
6728 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6729 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6730 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6731 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6732 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6733 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
87350ad0
TI
6734 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6735 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
2134ea4f 6736 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
87350ad0
TI
6737 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6738 { } /* end */
6739};
41d5545d
KS
6740
6741static struct snd_kcontrol_new alc885_mb5_mixer[] = {
92b9de83
KS
6742 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6743 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6744 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6745 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6746 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6747 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6748 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6749 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
41d5545d
KS
6750 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6751 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6752 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6753 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6754 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6755 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6756 { } /* end */
6757};
92b9de83 6758
bdd148a3
KY
6759static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6760 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6761 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6762 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6763 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6764 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6765 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6766 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6767 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6768 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
bdd148a3
KY
6769 { } /* end */
6770};
6771
272a527c
KY
6772static struct snd_kcontrol_new alc882_targa_mixer[] = {
6773 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6774 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6775 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6776 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6777 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6778 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6779 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6780 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6781 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
96fe7cc8 6782 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
272a527c
KY
6783 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6784 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
96fe7cc8 6785 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
272a527c
KY
6786 { } /* end */
6787};
6788
6789/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6790 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6791 */
6792static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6793 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6794 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6795 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6796 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6797 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6798 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6799 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6800 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6801 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6802 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6803 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
96fe7cc8 6805 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
272a527c
KY
6806 { } /* end */
6807};
6808
914759b7
TI
6809static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6810 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6811 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6813 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6814 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6815 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6816 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6817 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6818 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6819 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
914759b7
TI
6820 { } /* end */
6821};
6822
df694daa
KY
6823static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6824 {
6825 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6826 .name = "Channel Mode",
6827 .info = alc_ch_mode_info,
6828 .get = alc_ch_mode_get,
6829 .put = alc_ch_mode_put,
6830 },
6831 { } /* end */
6832};
6833
4953550a 6834static struct hda_verb alc882_base_init_verbs[] = {
1da177e4 6835 /* Front mixer: unmute input/output amp left and right (volume = 0) */
05acb863
TI
6836 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6838 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1da177e4 6839 /* Rear mixer */
05acb863
TI
6840 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6841 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6842 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1da177e4 6843 /* CLFE mixer */
05acb863
TI
6844 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6845 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6846 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1da177e4 6847 /* Side mixer */
05acb863
TI
6848 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6849 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6850 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1da177e4 6851
cb638122
TI
6852 /* mute analog input loopbacks */
6853 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6854 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6855 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6856 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6857 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6858
e9edcee0 6859 /* Front Pin: output 0 (0x0c) */
05acb863 6860 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
05acb863 6861 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1da177e4 6862 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
e9edcee0 6863 /* Rear Pin: output 1 (0x0d) */
05acb863 6864 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
05acb863 6865 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1da177e4 6866 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
e9edcee0 6867 /* CLFE Pin: output 2 (0x0e) */
05acb863 6868 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
05acb863 6869 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1da177e4 6870 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
e9edcee0 6871 /* Side Pin: output 3 (0x0f) */
05acb863 6872 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
05acb863 6873 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1da177e4 6874 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
e9edcee0 6875 /* Mic (rear) pin: input vref at 80% */
16ded525 6876 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
e9edcee0
TI
6877 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6878 /* Front Mic pin: input vref at 80% */
16ded525 6879 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
e9edcee0
TI
6880 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6881 /* Line In pin: input */
05acb863 6882 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
e9edcee0
TI
6883 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6884 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6885 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6886 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6887 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1da177e4 6888 /* CD pin widget for input */
05acb863 6889 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1da177e4
LT
6890
6891 /* FIXME: use matrix-type input source selection */
6892 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
1da177e4 6893 /* Input mixer2 */
05acb863
TI
6894 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6895 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6896 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6897 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1da177e4 6898 /* Input mixer3 */
05acb863
TI
6899 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6900 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6901 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
05acb863
TI
6903 /* ADC2: mute amp left and right */
6904 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
71fe7b82 6905 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
05acb863
TI
6906 /* ADC3: mute amp left and right */
6907 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
71fe7b82 6908 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1da177e4
LT
6909
6910 { }
6911};
6912
4953550a
TI
6913static struct hda_verb alc882_adc1_init_verbs[] = {
6914 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6915 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6916 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6917 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6918 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6919 /* ADC1: mute amp left and right */
6920 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6921 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6922 { }
6923};
6924
4b146cb0
TI
6925static struct hda_verb alc882_eapd_verbs[] = {
6926 /* change to EAPD mode */
6927 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
b373bdeb 6928 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
f12ab1e0 6929 { }
4b146cb0
TI
6930};
6931
4953550a
TI
6932#define alc883_init_verbs alc882_base_init_verbs
6933
9102cd1c
TD
6934/* Mac Pro test */
6935static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6936 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6937 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6938 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6939 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6940 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
45bdd1c1 6941 /* FIXME: this looks suspicious...
9102cd1c
TD
6942 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6943 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
45bdd1c1 6944 */
9102cd1c
TD
6945 { } /* end */
6946};
6947
6948static struct hda_verb alc882_macpro_init_verbs[] = {
6949 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6950 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6951 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6952 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6953 /* Front Pin: output 0 (0x0c) */
6954 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6955 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6956 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6957 /* Front Mic pin: input vref at 80% */
6958 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6959 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6960 /* Speaker: output */
6961 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6962 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6963 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6964 /* Headphone output (output 0 - 0x0c) */
6965 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6966 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6967 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6968
6969 /* FIXME: use matrix-type input source selection */
6970 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6971 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6972 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6973 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6974 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6975 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6976 /* Input mixer2 */
6977 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6978 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6979 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6980 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6981 /* Input mixer3 */
6982 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6983 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6984 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6985 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6986 /* ADC1: mute amp left and right */
6987 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6988 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6989 /* ADC2: mute amp left and right */
6990 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6991 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6992 /* ADC3: mute amp left and right */
6993 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6994 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6995
6996 { }
6997};
f12ab1e0 6998
41d5545d
KS
6999/* Macbook 5,1 */
7000static struct hda_verb alc885_mb5_init_verbs[] = {
92b9de83
KS
7001 /* DACs */
7002 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7003 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7004 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7005 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
41d5545d 7006 /* Front mixer */
41d5545d
KS
7007 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7008 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7009 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
92b9de83
KS
7010 /* Surround mixer */
7011 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7012 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7013 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7014 /* LFE mixer */
7015 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7016 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7017 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7018 /* HP mixer */
7019 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7020 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7021 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7022 /* Front Pin (0x0c) */
41d5545d
KS
7023 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7024 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
92b9de83
KS
7025 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7026 /* LFE Pin (0x0e) */
7027 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7028 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7029 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7030 /* HP Pin (0x0f) */
41d5545d
KS
7031 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7032 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
92b9de83 7033 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
41d5545d
KS
7034 /* Front Mic pin: input vref at 80% */
7035 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7036 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7037 /* Line In pin */
7038 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7039 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7040
7041 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7042 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7043 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7044 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7045 { }
7046};
7047
87350ad0
TI
7048/* Macbook Pro rev3 */
7049static struct hda_verb alc885_mbp3_init_verbs[] = {
7050 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7051 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7052 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7054 /* Rear mixer */
7055 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7056 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7057 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7058 /* Front Pin: output 0 (0x0c) */
7059 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7060 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7061 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7062 /* HP Pin: output 0 (0x0d) */
7063 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7064 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7065 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7066 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7067 /* Mic (rear) pin: input vref at 80% */
7068 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7069 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7070 /* Front Mic pin: input vref at 80% */
7071 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7072 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7073 /* Line In pin: use output 1 when in LineOut mode */
7074 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7075 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7076 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7077
7078 /* FIXME: use matrix-type input source selection */
7079 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7080 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7081 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7082 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7083 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7084 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7085 /* Input mixer2 */
7086 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7087 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7088 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7089 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7090 /* Input mixer3 */
7091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7092 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7093 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7094 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7095 /* ADC1: mute amp left and right */
7096 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7097 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7098 /* ADC2: mute amp left and right */
7099 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7100 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7101 /* ADC3: mute amp left and right */
7102 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7103 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7104
7105 { }
7106};
7107
c54728d8
NF
7108/* iMac 24 mixer. */
7109static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7110 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7111 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7112 { } /* end */
7113};
7114
7115/* iMac 24 init verbs. */
7116static struct hda_verb alc885_imac24_init_verbs[] = {
7117 /* Internal speakers: output 0 (0x0c) */
7118 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7119 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7120 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7121 /* Internal speakers: output 0 (0x0c) */
7122 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7123 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7124 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7125 /* Headphone: output 0 (0x0c) */
7126 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7127 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7128 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7129 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7130 /* Front Mic: input vref at 80% */
7131 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7132 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7133 { }
7134};
7135
7136/* Toggle speaker-output according to the hp-jack state */
a9fd4f3f 7137static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
c54728d8 7138{
a9fd4f3f 7139 struct alc_spec *spec = codec->spec;
c54728d8 7140
a9fd4f3f
TI
7141 spec->autocfg.hp_pins[0] = 0x14;
7142 spec->autocfg.speaker_pins[0] = 0x18;
7143 spec->autocfg.speaker_pins[1] = 0x1a;
7144 alc_automute_amp(codec);
c54728d8
NF
7145}
7146
a9fd4f3f 7147static void alc885_mbp3_init_hook(struct hda_codec *codec)
87350ad0 7148{
a9fd4f3f 7149 struct alc_spec *spec = codec->spec;
87350ad0 7150
a9fd4f3f
TI
7151 spec->autocfg.hp_pins[0] = 0x15;
7152 spec->autocfg.speaker_pins[0] = 0x14;
7153 alc_automute_amp(codec);
87350ad0
TI
7154}
7155
7156
272a527c
KY
7157static struct hda_verb alc882_targa_verbs[] = {
7158 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7159 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7160
7161 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7162 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
ea1fb29a 7163
272a527c
KY
7164 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7165 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7166 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7167
7168 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
272a527c
KY
7169 { } /* end */
7170};
7171
7172/* toggle speaker-output according to the hp-jack state */
7173static void alc882_targa_automute(struct hda_codec *codec)
7174{
a9fd4f3f
TI
7175 struct alc_spec *spec = codec->spec;
7176 alc_automute_amp(codec);
82beb8fd 7177 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
a9fd4f3f
TI
7178 spec->jack_present ? 1 : 3);
7179}
7180
7181static void alc882_targa_init_hook(struct hda_codec *codec)
7182{
7183 struct alc_spec *spec = codec->spec;
7184
7185 spec->autocfg.hp_pins[0] = 0x14;
7186 spec->autocfg.speaker_pins[0] = 0x1b;
7187 alc882_targa_automute(codec);
272a527c
KY
7188}
7189
7190static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7191{
a9fd4f3f 7192 if ((res >> 26) == ALC880_HP_EVENT)
272a527c 7193 alc882_targa_automute(codec);
272a527c
KY
7194}
7195
7196static struct hda_verb alc882_asus_a7j_verbs[] = {
7197 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7199
7200 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7201 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7202 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
ea1fb29a 7203
272a527c
KY
7204 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7205 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7206 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7207
7208 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7209 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7210 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7211 { } /* end */
7212};
7213
914759b7
TI
7214static struct hda_verb alc882_asus_a7m_verbs[] = {
7215 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7216 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7217
7218 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7219 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7220 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
ea1fb29a 7221
914759b7
TI
7222 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7223 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7224 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7225
7226 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7227 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7228 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7229 { } /* end */
7230};
7231
9102cd1c
TD
7232static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7233{
7234 unsigned int gpiostate, gpiomask, gpiodir;
7235
7236 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7237 AC_VERB_GET_GPIO_DATA, 0);
7238
7239 if (!muted)
7240 gpiostate |= (1 << pin);
7241 else
7242 gpiostate &= ~(1 << pin);
7243
7244 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7245 AC_VERB_GET_GPIO_MASK, 0);
7246 gpiomask |= (1 << pin);
7247
7248 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7249 AC_VERB_GET_GPIO_DIRECTION, 0);
7250 gpiodir |= (1 << pin);
7251
7252
7253 snd_hda_codec_write(codec, codec->afg, 0,
7254 AC_VERB_SET_GPIO_MASK, gpiomask);
7255 snd_hda_codec_write(codec, codec->afg, 0,
7256 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7257
7258 msleep(1);
7259
7260 snd_hda_codec_write(codec, codec->afg, 0,
7261 AC_VERB_SET_GPIO_DATA, gpiostate);
7262}
7263
7debbe51
TI
7264/* set up GPIO at initialization */
7265static void alc885_macpro_init_hook(struct hda_codec *codec)
7266{
7267 alc882_gpio_mute(codec, 0, 0);
7268 alc882_gpio_mute(codec, 1, 0);
7269}
7270
7271/* set up GPIO and update auto-muting at initialization */
7272static void alc885_imac24_init_hook(struct hda_codec *codec)
7273{
7274 alc885_macpro_init_hook(codec);
a9fd4f3f 7275 alc885_imac24_automute_init_hook(codec);
7debbe51
TI
7276}
7277
df694daa
KY
7278/*
7279 * generic initialization of ADC, input mixers and output mixers
7280 */
4953550a 7281static struct hda_verb alc883_auto_init_verbs[] = {
df694daa
KY
7282 /*
7283 * Unmute ADC0-2 and set the default input to mic-in
7284 */
4953550a
TI
7285 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7286 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7287 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7288 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17bba1b7 7289
4953550a
TI
7290 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7291 * mixer widget
7292 * Note: PASD motherboards uses the Line In 2 as the input for
7293 * front panel mic (mic 2)
7294 */
7295 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7296 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7297 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7298 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7299 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7300 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
17bba1b7 7301
4953550a
TI
7302 /*
7303 * Set up output mixers (0x0c - 0x0f)
7304 */
7305 /* set vol=0 to output mixers */
7306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7307 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7308 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7309 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7310 /* set up input amps for analog loopback */
7311 /* Amp Indices: DAC = 0, mixer = 1 */
7312 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7313 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7314 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7315 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7316 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7317 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7318 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7319 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7320 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7321 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9c7f852e 7322
4953550a
TI
7323 /* FIXME: use matrix-type input source selection */
7324 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7325 /* Input mixer2 */
7326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7327 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7328 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7329 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7330 /* Input mixer3 */
7331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7332 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7333 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7334 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9c7f852e 7335
4953550a 7336 { }
9c7f852e
TI
7337};
7338
eb4c41d3
TS
7339/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7340static struct hda_verb alc889A_mb31_ch2_init[] = {
7341 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7342 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7343 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7344 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7345 { } /* end */
7346};
7347
7348/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7349static struct hda_verb alc889A_mb31_ch4_init[] = {
7350 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7351 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7352 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7353 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7354 { } /* end */
7355};
7356
7357/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7358static struct hda_verb alc889A_mb31_ch5_init[] = {
7359 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7360 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7361 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7362 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7363 { } /* end */
7364};
7365
7366/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7367static struct hda_verb alc889A_mb31_ch6_init[] = {
7368 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7369 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7370 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7371 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7372 { } /* end */
7373};
7374
7375static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7376 { 2, alc889A_mb31_ch2_init },
7377 { 4, alc889A_mb31_ch4_init },
7378 { 5, alc889A_mb31_ch5_init },
7379 { 6, alc889A_mb31_ch6_init },
7380};
7381
b373bdeb
AN
7382static struct hda_verb alc883_medion_eapd_verbs[] = {
7383 /* eanable EAPD on medion laptop */
7384 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7385 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7386 { }
7387};
7388
4953550a 7389#define alc883_base_mixer alc882_base_mixer
834be88d 7390
a8848bd6
AS
7391static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7392 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7393 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7394 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7395 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7396 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7397 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7398 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7399 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7400 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7401 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7402 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7403 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7404 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
a8848bd6
AS
7405 { } /* end */
7406};
7407
0c4cc443 7408static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
368c7a95
J
7409 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7410 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7411 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7412 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7413 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7414 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7415 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7416 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7417 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7418 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
368c7a95
J
7419 { } /* end */
7420};
7421
fb97dc67
J
7422static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7423 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7424 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7425 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7426 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7427 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7428 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7429 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7430 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7431 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7432 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
fb97dc67
J
7433 { } /* end */
7434};
7435
9c7f852e
TI
7436static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7437 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7438 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7439 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7440 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7441 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7442 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7443 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7444 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
32360416 7445 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9c7f852e
TI
7446 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7447 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
32360416 7448 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9c7f852e 7449 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9c7f852e
TI
7450 { } /* end */
7451};
df694daa 7452
9c7f852e
TI
7453static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7454 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7455 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7456 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7457 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7458 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7459 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7460 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7461 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7462 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7463 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7464 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7465 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7466 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7467 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
32360416 7468 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9c7f852e
TI
7469 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7470 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
32360416 7471 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9c7f852e 7472 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9c7f852e
TI
7473 { } /* end */
7474};
7475
17bba1b7
J
7476static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7477 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7478 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7479 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7480 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7481 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7482 HDA_OUTPUT),
7483 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7484 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7485 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7486 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7487 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7488 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7489 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7490 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7491 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7492 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7493 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7494 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7495 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7496 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17bba1b7
J
7497 { } /* end */
7498};
7499
d1d985f0 7500static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
c07584c8 7501 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
0701e064 7502 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
c07584c8 7503 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
0701e064 7504 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
c07584c8
TD
7505 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7506 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
0701e064
TI
7507 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7508 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
c07584c8
TD
7509 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7510 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7511 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7512 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7513 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
32360416 7515 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
c07584c8
TD
7516 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7517 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
32360416 7518 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
c07584c8 7519 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
c07584c8
TD
7520 { } /* end */
7521};
7522
c259249f 7523static struct snd_kcontrol_new alc883_targa_mixer[] = {
ccc656ce
KY
7524 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7525 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7526 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7527 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7528 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7529 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7530 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7531 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7532 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7533 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7534 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7535 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7536 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7537 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
32360416 7538 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
ccc656ce 7539 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
ccc656ce 7540 { } /* end */
f12ab1e0 7541};
ccc656ce 7542
c259249f 7543static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
ccc656ce
KY
7544 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7545 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7546 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7547 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7548 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
32360416 7550 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
ccc656ce 7551 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4383fae0
J
7552 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7553 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7554 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
ccc656ce 7555 { } /* end */
f12ab1e0 7556};
ccc656ce 7557
bc9f98a9
KY
7558static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7559 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7560 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
86cd9298
TI
7561 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7562 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
bc9f98a9
KY
7563 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7564 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7565 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7566 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
bc9f98a9 7567 { } /* end */
f12ab1e0 7568};
bc9f98a9 7569
272a527c
KY
7570static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7571 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7572 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7573 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7574 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7575 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7576 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7577 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7578 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7579 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
272a527c
KY
7580 { } /* end */
7581};
7582
7583static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7584 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7585 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7586 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7587 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7588 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7589 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7590 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7591 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7592 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
272a527c 7593 { } /* end */
ea1fb29a 7594};
272a527c 7595
2880a867 7596static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
d1a991a6
KY
7597 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7598 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2880a867 7599 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2880a867
TD
7600 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7601 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
d1a991a6
KY
7602 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7603 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2880a867 7605 { } /* end */
d1a991a6 7606};
2880a867 7607
d2fd4b09
TV
7608static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
7609 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7610 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7611 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7612 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
684a8842
TV
7613 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7614 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
d2fd4b09
TV
7615 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7616 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7618 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7619 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7620 { } /* end */
7621};
7622
e2757d5e
KY
7623static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7624 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7625 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7626 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7627 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7628 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7629 0x0d, 1, 0x0, HDA_OUTPUT),
7630 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7631 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7632 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7633 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7634 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
e2757d5e
KY
7635 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7636 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7637 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7638 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7639 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7640 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7641 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7642 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7643 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7644 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
e2757d5e
KY
7645 { } /* end */
7646};
7647
eb4c41d3
TS
7648static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
7649 /* Output mixers */
7650 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7651 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7652 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7653 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7654 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
7655 HDA_OUTPUT),
7656 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
7657 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
7658 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
7659 /* Output switches */
7660 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
7661 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
7662 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
7663 /* Boost mixers */
7664 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7665 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
7666 /* Input mixers */
7667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7668 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7669 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7670 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7671 { } /* end */
7672};
7673
3e1647c5
GG
7674static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
7675 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7676 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7678 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7679 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7680 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7681 { } /* end */
7682};
7683
e2757d5e
KY
7684static struct hda_bind_ctls alc883_bind_cap_vol = {
7685 .ops = &snd_hda_bind_vol,
7686 .values = {
7687 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7688 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7689 0
7690 },
7691};
7692
7693static struct hda_bind_ctls alc883_bind_cap_switch = {
7694 .ops = &snd_hda_bind_sw,
7695 .values = {
7696 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7697 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7698 0
7699 },
7700};
7701
7702static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7703 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7704 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7705 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7706 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7707 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7708 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4953550a
TI
7709 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7710 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7711 { } /* end */
7712};
df694daa 7713
4953550a
TI
7714static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
7715 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7716 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7717 {
7718 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7719 /* .name = "Capture Source", */
7720 .name = "Input Source",
7721 .count = 1,
7722 .info = alc_mux_enum_info,
7723 .get = alc_mux_enum_get,
7724 .put = alc_mux_enum_put,
7725 },
7726 { } /* end */
7727};
9c7f852e 7728
4953550a
TI
7729static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7730 {
7731 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7732 .name = "Channel Mode",
7733 .info = alc_ch_mode_info,
7734 .get = alc_ch_mode_get,
7735 .put = alc_ch_mode_put,
7736 },
7737 { } /* end */
9c7f852e
TI
7738};
7739
a8848bd6 7740/* toggle speaker-output according to the hp-jack state */
a9fd4f3f 7741static void alc883_mitac_init_hook(struct hda_codec *codec)
a8848bd6 7742{
a9fd4f3f 7743 struct alc_spec *spec = codec->spec;
a8848bd6 7744
a9fd4f3f
TI
7745 spec->autocfg.hp_pins[0] = 0x15;
7746 spec->autocfg.speaker_pins[0] = 0x14;
7747 spec->autocfg.speaker_pins[1] = 0x17;
7748 alc_automute_amp(codec);
a8848bd6
AS
7749}
7750
7751/* auto-toggle front mic */
7752/*
7753static void alc883_mitac_mic_automute(struct hda_codec *codec)
7754{
7755 unsigned int present;
7756 unsigned char bits;
7757
7758 present = snd_hda_codec_read(codec, 0x18, 0,
7759 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7760 bits = present ? HDA_AMP_MUTE : 0;
7761 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7762}
7763*/
7764
a8848bd6
AS
7765static struct hda_verb alc883_mitac_verbs[] = {
7766 /* HP */
7767 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7768 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7769 /* Subwoofer */
7770 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7771 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7772
7773 /* enable unsolicited event */
7774 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7775 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7776
7777 { } /* end */
7778};
7779
0c4cc443 7780static struct hda_verb alc883_clevo_m720_verbs[] = {
368c7a95
J
7781 /* HP */
7782 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7783 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7784 /* Int speaker */
7785 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7786 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7787
7788 /* enable unsolicited event */
7789 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
0c4cc443 7790 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
368c7a95
J
7791
7792 { } /* end */
7793};
7794
fb97dc67
J
7795static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7796 /* HP */
7797 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7798 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7799 /* Subwoofer */
7800 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7801 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7802
7803 /* enable unsolicited event */
7804 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7805
7806 { } /* end */
7807};
7808
c259249f 7809static struct hda_verb alc883_targa_verbs[] = {
ccc656ce
KY
7810 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7811 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7812
7813 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7814 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
ea1fb29a 7815
64a8be74
DH
7816/* Connect Line-Out side jack (SPDIF) to Side */
7817 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7818 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7819 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7820/* Connect Mic jack to CLFE */
7821 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7822 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7823 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
7824/* Connect Line-in jack to Surround */
7825 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7826 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7827 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7828/* Connect HP out jack to Front */
7829 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7830 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7831 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
ccc656ce
KY
7832
7833 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
ccc656ce
KY
7834
7835 { } /* end */
7836};
7837
bc9f98a9
KY
7838static struct hda_verb alc883_lenovo_101e_verbs[] = {
7839 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7840 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7841 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7842 { } /* end */
7843};
7844
272a527c
KY
7845static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7846 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7847 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7848 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7849 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7850 { } /* end */
7851};
7852
7853static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7854 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7855 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7856 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7857 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7858 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7859 { } /* end */
7860};
7861
189609ae
KY
7862static struct hda_verb alc883_haier_w66_verbs[] = {
7863 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7864 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7865
7866 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7867
7868 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7869 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7870 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7871 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7872 { } /* end */
7873};
7874
e2757d5e
KY
7875static struct hda_verb alc888_lenovo_sky_verbs[] = {
7876 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7877 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7878 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7879 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7880 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7881 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7882 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7883 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7884 { } /* end */
7885};
7886
8718b700
HRK
7887static struct hda_verb alc888_6st_dell_verbs[] = {
7888 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7889 { }
7890};
7891
3e1647c5
GG
7892static struct hda_verb alc883_vaiott_verbs[] = {
7893 /* HP */
7894 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7895 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7896
7897 /* enable unsolicited event */
7898 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7899
7900 { } /* end */
7901};
7902
a9fd4f3f 7903static void alc888_3st_hp_init_hook(struct hda_codec *codec)
8718b700 7904{
a9fd4f3f 7905 struct alc_spec *spec = codec->spec;
8718b700 7906
a9fd4f3f
TI
7907 spec->autocfg.hp_pins[0] = 0x1b;
7908 spec->autocfg.speaker_pins[0] = 0x14;
7909 spec->autocfg.speaker_pins[1] = 0x16;
7910 spec->autocfg.speaker_pins[2] = 0x18;
7911 alc_automute_amp(codec);
8718b700
HRK
7912}
7913
4723c022 7914static struct hda_verb alc888_3st_hp_verbs[] = {
8341de60 7915 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
f32a19e3
HRK
7916 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7917 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
5795b9e6 7918 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8718b700 7919 { } /* end */
5795b9e6
CM
7920};
7921
3ea0d7cf
HRK
7922/*
7923 * 2ch mode
7924 */
4723c022 7925static struct hda_verb alc888_3st_hp_2ch_init[] = {
8341de60
CM
7926 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7927 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7928 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7929 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
3ea0d7cf 7930 { } /* end */
8341de60
CM
7931};
7932
3ea0d7cf
HRK
7933/*
7934 * 4ch mode
7935 */
7936static struct hda_verb alc888_3st_hp_4ch_init[] = {
7937 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7938 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7939 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7940 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7941 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
7942 { } /* end */
7943};
7944
7945/*
7946 * 6ch mode
7947 */
4723c022 7948static struct hda_verb alc888_3st_hp_6ch_init[] = {
8341de60
CM
7949 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7950 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
3ea0d7cf 7951 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
8341de60
CM
7952 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7953 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
3ea0d7cf
HRK
7954 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
7955 { } /* end */
8341de60
CM
7956};
7957
3ea0d7cf 7958static struct hda_channel_mode alc888_3st_hp_modes[3] = {
4723c022 7959 { 2, alc888_3st_hp_2ch_init },
3ea0d7cf 7960 { 4, alc888_3st_hp_4ch_init },
4723c022 7961 { 6, alc888_3st_hp_6ch_init },
8341de60
CM
7962};
7963
272a527c
KY
7964/* toggle front-jack and RCA according to the hp-jack state */
7965static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7966{
7967 unsigned int present;
ea1fb29a 7968
272a527c
KY
7969 present = snd_hda_codec_read(codec, 0x1b, 0,
7970 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
47fd830a
TI
7971 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7972 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7973 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7974 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
272a527c
KY
7975}
7976
7977/* toggle RCA according to the front-jack state */
7978static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7979{
7980 unsigned int present;
ea1fb29a 7981
272a527c
KY
7982 present = snd_hda_codec_read(codec, 0x14, 0,
7983 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
47fd830a
TI
7984 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7985 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
272a527c 7986}
47fd830a 7987
272a527c
KY
7988static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7989 unsigned int res)
7990{
7991 if ((res >> 26) == ALC880_HP_EVENT)
7992 alc888_lenovo_ms7195_front_automute(codec);
7993 if ((res >> 26) == ALC880_FRONT_EVENT)
7994 alc888_lenovo_ms7195_rca_automute(codec);
7995}
7996
7997static struct hda_verb alc883_medion_md2_verbs[] = {
7998 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7999 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8000
8001 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8002
8003 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8004 { } /* end */
8005};
8006
8007/* toggle speaker-output according to the hp-jack state */
a9fd4f3f 8008static void alc883_medion_md2_init_hook(struct hda_codec *codec)
272a527c 8009{
a9fd4f3f 8010 struct alc_spec *spec = codec->spec;
272a527c 8011
a9fd4f3f
TI
8012 spec->autocfg.hp_pins[0] = 0x14;
8013 spec->autocfg.speaker_pins[0] = 0x15;
8014 alc_automute_amp(codec);
272a527c
KY
8015}
8016
ccc656ce 8017/* toggle speaker-output according to the hp-jack state */
c259249f
SA
8018#define alc883_targa_init_hook alc882_targa_init_hook
8019#define alc883_targa_unsol_event alc882_targa_unsol_event
368c7a95 8020
0c4cc443
HRK
8021static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8022{
8023 unsigned int present;
8024
8025 present = snd_hda_codec_read(codec, 0x18, 0,
8026 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8027 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8028 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8029}
8030
a9fd4f3f 8031static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
0c4cc443 8032{
a9fd4f3f
TI
8033 struct alc_spec *spec = codec->spec;
8034
8035 spec->autocfg.hp_pins[0] = 0x15;
8036 spec->autocfg.speaker_pins[0] = 0x14;
8037 alc_automute_amp(codec);
0c4cc443
HRK
8038 alc883_clevo_m720_mic_automute(codec);
8039}
8040
8041static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
368c7a95
J
8042 unsigned int res)
8043{
0c4cc443 8044 switch (res >> 26) {
0c4cc443
HRK
8045 case ALC880_MIC_EVENT:
8046 alc883_clevo_m720_mic_automute(codec);
8047 break;
a9fd4f3f
TI
8048 default:
8049 alc_automute_amp_unsol_event(codec, res);
8050 break;
0c4cc443 8051 }
368c7a95
J
8052}
8053
fb97dc67 8054/* toggle speaker-output according to the hp-jack state */
a9fd4f3f 8055static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
fb97dc67 8056{
a9fd4f3f 8057 struct alc_spec *spec = codec->spec;
fb97dc67 8058
a9fd4f3f
TI
8059 spec->autocfg.hp_pins[0] = 0x14;
8060 spec->autocfg.speaker_pins[0] = 0x15;
8061 alc_automute_amp(codec);
fb97dc67
J
8062}
8063
a9fd4f3f 8064static void alc883_haier_w66_init_hook(struct hda_codec *codec)
fb97dc67 8065{
a9fd4f3f 8066 struct alc_spec *spec = codec->spec;
189609ae 8067
a9fd4f3f
TI
8068 spec->autocfg.hp_pins[0] = 0x1b;
8069 spec->autocfg.speaker_pins[0] = 0x14;
8070 alc_automute_amp(codec);
189609ae
KY
8071}
8072
bc9f98a9
KY
8073static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8074{
8075 unsigned int present;
f12ab1e0 8076 unsigned char bits;
bc9f98a9 8077
64a8be74
DH
8078 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8079 & AC_PINSENSE_PRESENCE;
47fd830a
TI
8080 bits = present ? HDA_AMP_MUTE : 0;
8081 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8082 HDA_AMP_MUTE, bits);
bc9f98a9
KY
8083}
8084
8085static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8086{
8087 unsigned int present;
f12ab1e0 8088 unsigned char bits;
bc9f98a9
KY
8089
8090 present = snd_hda_codec_read(codec, 0x1b, 0,
8091 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
47fd830a
TI
8092 bits = present ? HDA_AMP_MUTE : 0;
8093 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8094 HDA_AMP_MUTE, bits);
8095 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8096 HDA_AMP_MUTE, bits);
bc9f98a9
KY
8097}
8098
8099static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8100 unsigned int res)
8101{
8102 if ((res >> 26) == ALC880_HP_EVENT)
8103 alc883_lenovo_101e_all_automute(codec);
8104 if ((res >> 26) == ALC880_FRONT_EVENT)
8105 alc883_lenovo_101e_ispeaker_automute(codec);
8106}
8107
676a9b53 8108/* toggle speaker-output according to the hp-jack state */
a9fd4f3f 8109static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
676a9b53 8110{
a9fd4f3f 8111 struct alc_spec *spec = codec->spec;
676a9b53 8112
a9fd4f3f
TI
8113 spec->autocfg.hp_pins[0] = 0x14;
8114 spec->autocfg.speaker_pins[0] = 0x15;
8115 spec->autocfg.speaker_pins[1] = 0x16;
8116 alc_automute_amp(codec);
676a9b53
TI
8117}
8118
d1a991a6
KY
8119static struct hda_verb alc883_acer_eapd_verbs[] = {
8120 /* HP Pin: output 0 (0x0c) */
8121 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8122 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8123 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8124 /* Front Pin: output 0 (0x0c) */
676a9b53
TI
8125 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8126 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
d1a991a6 8127 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
d1a991a6
KY
8128 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8129 /* eanable EAPD on medion laptop */
8130 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8131 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
676a9b53
TI
8132 /* enable unsolicited event */
8133 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
d1a991a6
KY
8134 { }
8135};
8136
a9fd4f3f 8137static void alc888_6st_dell_init_hook(struct hda_codec *codec)
5795b9e6 8138{
a9fd4f3f 8139 struct alc_spec *spec = codec->spec;
5795b9e6 8140
a9fd4f3f
TI
8141 spec->autocfg.hp_pins[0] = 0x1b;
8142 spec->autocfg.speaker_pins[0] = 0x14;
8143 spec->autocfg.speaker_pins[1] = 0x15;
8144 spec->autocfg.speaker_pins[2] = 0x16;
8145 spec->autocfg.speaker_pins[3] = 0x17;
8146 alc_automute_amp(codec);
5795b9e6
CM
8147}
8148
a9fd4f3f 8149static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
e2757d5e 8150{
a9fd4f3f 8151 struct alc_spec *spec = codec->spec;
e2757d5e 8152
a9fd4f3f
TI
8153 spec->autocfg.hp_pins[0] = 0x1b;
8154 spec->autocfg.speaker_pins[0] = 0x14;
8155 spec->autocfg.speaker_pins[1] = 0x15;
8156 spec->autocfg.speaker_pins[2] = 0x16;
8157 spec->autocfg.speaker_pins[3] = 0x17;
8158 spec->autocfg.speaker_pins[4] = 0x1a;
8159 alc_automute_amp(codec);
e2757d5e
KY
8160}
8161
3e1647c5
GG
8162static void alc883_vaiott_init_hook(struct hda_codec *codec)
8163{
8164 struct alc_spec *spec = codec->spec;
8165
8166 spec->autocfg.hp_pins[0] = 0x15;
8167 spec->autocfg.speaker_pins[0] = 0x14;
8168 spec->autocfg.speaker_pins[1] = 0x17;
8169 alc_automute_amp(codec);
8170}
8171
e2757d5e
KY
8172static struct hda_verb alc888_asus_m90v_verbs[] = {
8173 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8174 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8175 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8176 /* enable unsolicited event */
8177 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8178 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8179 { } /* end */
8180};
8181
8182static void alc883_nb_mic_automute(struct hda_codec *codec)
8183{
8184 unsigned int present;
8185
8186 present = snd_hda_codec_read(codec, 0x18, 0,
8187 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8188 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8189 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8190 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8191 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8192}
8193
a9fd4f3f 8194static void alc883_M90V_init_hook(struct hda_codec *codec)
e2757d5e 8195{
a9fd4f3f 8196 struct alc_spec *spec = codec->spec;
e2757d5e 8197
a9fd4f3f
TI
8198 spec->autocfg.hp_pins[0] = 0x1b;
8199 spec->autocfg.speaker_pins[0] = 0x14;
8200 spec->autocfg.speaker_pins[1] = 0x15;
8201 spec->autocfg.speaker_pins[2] = 0x16;
8202 alc_automute_pin(codec);
e2757d5e
KY
8203}
8204
8205static void alc883_mode2_unsol_event(struct hda_codec *codec,
8206 unsigned int res)
8207{
8208 switch (res >> 26) {
e2757d5e
KY
8209 case ALC880_MIC_EVENT:
8210 alc883_nb_mic_automute(codec);
8211 break;
a9fd4f3f
TI
8212 default:
8213 alc_sku_unsol_event(codec, res);
8214 break;
e2757d5e
KY
8215 }
8216}
8217
8218static void alc883_mode2_inithook(struct hda_codec *codec)
8219{
a9fd4f3f 8220 alc883_M90V_init_hook(codec);
e2757d5e
KY
8221 alc883_nb_mic_automute(codec);
8222}
8223
8224static struct hda_verb alc888_asus_eee1601_verbs[] = {
8225 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8226 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8227 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8228 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8229 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8230 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8231 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8232 /* enable unsolicited event */
8233 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8234 { } /* end */
8235};
8236
e2757d5e
KY
8237static void alc883_eee1601_inithook(struct hda_codec *codec)
8238{
a9fd4f3f
TI
8239 struct alc_spec *spec = codec->spec;
8240
8241 spec->autocfg.hp_pins[0] = 0x14;
8242 spec->autocfg.speaker_pins[0] = 0x1b;
8243 alc_automute_pin(codec);
e2757d5e
KY
8244}
8245
eb4c41d3
TS
8246static struct hda_verb alc889A_mb31_verbs[] = {
8247 /* Init rear pin (used as headphone output) */
8248 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8249 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8250 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8251 /* Init line pin (used as output in 4ch and 6ch mode) */
8252 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8253 /* Init line 2 pin (used as headphone out by default) */
8254 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8255 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8256 { } /* end */
8257};
8258
8259/* Mute speakers according to the headphone jack state */
8260static void alc889A_mb31_automute(struct hda_codec *codec)
8261{
8262 unsigned int present;
8263
8264 /* Mute only in 2ch or 4ch mode */
8265 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8266 == 0x00) {
8267 present = snd_hda_codec_read(codec, 0x15, 0,
8268 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8269 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8270 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8271 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8272 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8273 }
8274}
8275
8276static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8277{
8278 if ((res >> 26) == ALC880_HP_EVENT)
8279 alc889A_mb31_automute(codec);
8280}
8281
4953550a 8282
cb53c626 8283#ifdef CONFIG_SND_HDA_POWER_SAVE
4953550a 8284#define alc882_loopbacks alc880_loopbacks
cb53c626
TI
8285#endif
8286
def319f9 8287/* pcm configuration: identical with ALC880 */
4953550a
TI
8288#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8289#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8290#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8291#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8292
8293static hda_nid_t alc883_slave_dig_outs[] = {
8294 ALC1200_DIGOUT_NID, 0,
8295};
8296
8297static hda_nid_t alc1200_slave_dig_outs[] = {
8298 ALC883_DIGOUT_NID, 0,
8299};
9c7f852e
TI
8300
8301/*
8302 * configuration and preset
8303 */
4953550a
TI
8304static const char *alc882_models[ALC882_MODEL_LAST] = {
8305 [ALC882_3ST_DIG] = "3stack-dig",
8306 [ALC882_6ST_DIG] = "6stack-dig",
8307 [ALC882_ARIMA] = "arima",
8308 [ALC882_W2JC] = "w2jc",
8309 [ALC882_TARGA] = "targa",
8310 [ALC882_ASUS_A7J] = "asus-a7j",
8311 [ALC882_ASUS_A7M] = "asus-a7m",
8312 [ALC885_MACPRO] = "macpro",
8313 [ALC885_MB5] = "mb5",
8314 [ALC885_MBP3] = "mbp3",
8315 [ALC885_IMAC24] = "imac24",
8316 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
f5fcc13c
TI
8317 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8318 [ALC883_3ST_6ch] = "3stack-6ch",
4953550a 8319 [ALC883_6ST_DIG] = "alc883-6stack-dig",
f5fcc13c
TI
8320 [ALC883_TARGA_DIG] = "targa-dig",
8321 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
64a8be74 8322 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
f5fcc13c 8323 [ALC883_ACER] = "acer",
2880a867 8324 [ALC883_ACER_ASPIRE] = "acer-aspire",
5b2d1eca 8325 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
b1a91469 8326 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
3b315d70 8327 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
f5fcc13c 8328 [ALC883_MEDION] = "medion",
272a527c 8329 [ALC883_MEDION_MD2] = "medion-md2",
f5fcc13c 8330 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
bc9f98a9 8331 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
272a527c
KY
8332 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8333 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
e2757d5e 8334 [ALC888_LENOVO_SKY] = "lenovo-sky",
189609ae 8335 [ALC883_HAIER_W66] = "haier-w66",
4723c022 8336 [ALC888_3ST_HP] = "3stack-hp",
5795b9e6 8337 [ALC888_6ST_DELL] = "6stack-dell",
a8848bd6 8338 [ALC883_MITAC] = "mitac",
0c4cc443 8339 [ALC883_CLEVO_M720] = "clevo-m720",
fb97dc67 8340 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
ef8ef5fb 8341 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
17bba1b7 8342 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
3ab90935 8343 [ALC1200_ASUS_P5Q] = "asus-p5q",
eb4c41d3 8344 [ALC889A_MB31] = "mb31",
3e1647c5 8345 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
4953550a 8346 [ALC882_AUTO] = "auto",
f5fcc13c
TI
8347};
8348
4953550a
TI
8349static struct snd_pci_quirk alc882_cfg_tbl[] = {
8350 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8351
ac3e3741 8352 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
69e50282 8353 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
9b6682ff 8354 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
ac3e3741
TI
8355 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8356 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
0b18cb18 8357 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
5b2d1eca
VP
8358 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8359 ALC888_ACER_ASPIRE_4930G),
a8e4f9dd
LW
8360 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8361 ALC888_ACER_ASPIRE_4930G),
3b315d70
HM
8362 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8363 ALC888_ACER_ASPIRE_8930G),
e46b0c8c
TI
8364 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8365 ALC888_ACER_ASPIRE_8930G),
4953550a
TI
8366 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8367 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
a8e4f9dd 8368 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
dde65356 8369 ALC888_ACER_ASPIRE_6530G),
cc374c47 8370 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
d2fd4b09 8371 ALC888_ACER_ASPIRE_6530G),
22b530e0
TI
8372 /* default Acer -- disabled as it causes more problems.
8373 * model=auto should work fine now
8374 */
8375 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
4953550a 8376
5795b9e6 8377 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
4953550a 8378
febe3375 8379 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
ac3e3741
TI
8380 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8381 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
5d85f8d0 8382 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
06bf3e15 8383 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
7ec30f0e 8384 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
4953550a
TI
8385
8386 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8387 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8388 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
a01c30cb 8389 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
4953550a
TI
8390 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8391 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8392 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
ac3e3741 8393 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
44a678d0 8394 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
3ab90935 8395 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
e2757d5e 8396 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
4953550a
TI
8397
8398 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
97ec710c 8399 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
4953550a 8400 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
2de686d2 8401 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
ac3e3741
TI
8402 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8403 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
e2757d5e 8404 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
ac3e3741 8405 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
4953550a
TI
8406 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8407
6f3bf657 8408 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
bba8dee7 8409 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
ac3e3741 8410 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
4953550a 8411 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
4383fae0 8412 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
4953550a 8413 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
dd146a60 8414 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
82808236 8415 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
f5fcc13c 8416 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
ac3e3741 8417 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
f5fcc13c
TI
8418 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8419 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
ac3e3741 8420 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
64ca1c29 8421 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
b1e4422f 8422 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
f5fcc13c
TI
8423 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8424 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8425 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
64a8be74 8426 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
ac3e3741
TI
8427 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8428 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
8429 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
ee09543c 8430 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
86d34b7e 8431 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
ac3e3741
TI
8432 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
8433 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
df01b8af 8434 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
f5fcc13c 8435 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
b1e4422f 8436 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
4953550a 8437
ac3e3741 8438 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
0c4cc443
HRK
8439 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8440 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
dea0a509 8441 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
e60623b4 8442 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
4953550a 8443 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
f5fcc13c 8444 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
bfb53037 8445 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
f67d8176 8446 ALC883_FUJITSU_PI2515),
bfb53037 8447 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
ef8ef5fb 8448 ALC888_FUJITSU_XA3530),
272a527c 8449 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
272a527c 8450 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
ac3e3741
TI
8451 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8452 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
e2757d5e 8453 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
272a527c 8454 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
959973b9 8455 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
0b167bf4 8456 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
189609ae 8457 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
4953550a 8458
17bba1b7
J
8459 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8460 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
2de686d2 8461 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
4b558991 8462 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
ac3e3741 8463 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
9c7f852e 8464
4953550a 8465 {}
f3cd3f5d
WF
8466};
8467
4953550a
TI
8468/* codec SSID table for Intel Mac */
8469static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8470 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8471 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8472 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8473 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8474 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8475 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8476 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8477 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8478 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8479 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8480 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8481 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8482 * no perfect solution yet
8483 */
8484 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8485 {} /* terminator */
b25c9da1
WF
8486};
8487
4953550a
TI
8488static struct alc_config_preset alc882_presets[] = {
8489 [ALC882_3ST_DIG] = {
8490 .mixers = { alc882_base_mixer },
8ab9e0af
TI
8491 .init_verbs = { alc882_base_init_verbs,
8492 alc882_adc1_init_verbs },
4953550a
TI
8493 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8494 .dac_nids = alc882_dac_nids,
8495 .dig_out_nid = ALC882_DIGOUT_NID,
8496 .dig_in_nid = ALC882_DIGIN_NID,
8497 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8498 .channel_mode = alc882_ch_modes,
8499 .need_dac_fix = 1,
8500 .input_mux = &alc882_capture_source,
8501 },
8502 [ALC882_6ST_DIG] = {
8503 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
8ab9e0af
TI
8504 .init_verbs = { alc882_base_init_verbs,
8505 alc882_adc1_init_verbs },
4953550a
TI
8506 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8507 .dac_nids = alc882_dac_nids,
8508 .dig_out_nid = ALC882_DIGOUT_NID,
8509 .dig_in_nid = ALC882_DIGIN_NID,
8510 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8511 .channel_mode = alc882_sixstack_modes,
8512 .input_mux = &alc882_capture_source,
8513 },
8514 [ALC882_ARIMA] = {
8515 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
8ab9e0af
TI
8516 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8517 alc882_eapd_verbs },
4953550a
TI
8518 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8519 .dac_nids = alc882_dac_nids,
8520 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8521 .channel_mode = alc882_sixstack_modes,
8522 .input_mux = &alc882_capture_source,
8523 },
8524 [ALC882_W2JC] = {
8525 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
8ab9e0af
TI
8526 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8527 alc882_eapd_verbs, alc880_gpio1_init_verbs },
4953550a
TI
8528 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8529 .dac_nids = alc882_dac_nids,
8530 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8531 .channel_mode = alc880_threestack_modes,
8532 .need_dac_fix = 1,
8533 .input_mux = &alc882_capture_source,
8534 .dig_out_nid = ALC882_DIGOUT_NID,
8535 },
8536 [ALC885_MBP3] = {
8537 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8538 .init_verbs = { alc885_mbp3_init_verbs,
8539 alc880_gpio1_init_verbs },
8540 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8541 .dac_nids = alc882_dac_nids,
8542 .channel_mode = alc885_mbp_6ch_modes,
8543 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
8544 .input_mux = &alc882_capture_source,
8545 .dig_out_nid = ALC882_DIGOUT_NID,
8546 .dig_in_nid = ALC882_DIGIN_NID,
8547 .unsol_event = alc_automute_amp_unsol_event,
8548 .init_hook = alc885_mbp3_init_hook,
8549 },
8550 [ALC885_MB5] = {
8551 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8552 .init_verbs = { alc885_mb5_init_verbs,
8553 alc880_gpio1_init_verbs },
8554 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8555 .dac_nids = alc882_dac_nids,
8556 .channel_mode = alc885_mb5_6ch_modes,
8557 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8558 .input_mux = &mb5_capture_source,
8559 .dig_out_nid = ALC882_DIGOUT_NID,
8560 .dig_in_nid = ALC882_DIGIN_NID,
8561 },
8562 [ALC885_MACPRO] = {
8563 .mixers = { alc882_macpro_mixer },
8564 .init_verbs = { alc882_macpro_init_verbs },
8565 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8566 .dac_nids = alc882_dac_nids,
8567 .dig_out_nid = ALC882_DIGOUT_NID,
8568 .dig_in_nid = ALC882_DIGIN_NID,
8569 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8570 .channel_mode = alc882_ch_modes,
8571 .input_mux = &alc882_capture_source,
8572 .init_hook = alc885_macpro_init_hook,
8573 },
8574 [ALC885_IMAC24] = {
8575 .mixers = { alc885_imac24_mixer },
8576 .init_verbs = { alc885_imac24_init_verbs },
8577 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8578 .dac_nids = alc882_dac_nids,
8579 .dig_out_nid = ALC882_DIGOUT_NID,
8580 .dig_in_nid = ALC882_DIGIN_NID,
8581 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8582 .channel_mode = alc882_ch_modes,
8583 .input_mux = &alc882_capture_source,
8584 .unsol_event = alc_automute_amp_unsol_event,
8585 .init_hook = alc885_imac24_init_hook,
8586 },
8587 [ALC882_TARGA] = {
8588 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
8ab9e0af 8589 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
31909b83 8590 alc880_gpio3_init_verbs, alc882_targa_verbs},
4953550a
TI
8591 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8592 .dac_nids = alc882_dac_nids,
8593 .dig_out_nid = ALC882_DIGOUT_NID,
8594 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8595 .adc_nids = alc882_adc_nids,
8596 .capsrc_nids = alc882_capsrc_nids,
8597 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8598 .channel_mode = alc882_3ST_6ch_modes,
8599 .need_dac_fix = 1,
8600 .input_mux = &alc882_capture_source,
8601 .unsol_event = alc882_targa_unsol_event,
8602 .init_hook = alc882_targa_init_hook,
8603 },
8604 [ALC882_ASUS_A7J] = {
8605 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
8ab9e0af
TI
8606 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8607 alc882_asus_a7j_verbs},
4953550a
TI
8608 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8609 .dac_nids = alc882_dac_nids,
8610 .dig_out_nid = ALC882_DIGOUT_NID,
8611 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8612 .adc_nids = alc882_adc_nids,
8613 .capsrc_nids = alc882_capsrc_nids,
8614 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8615 .channel_mode = alc882_3ST_6ch_modes,
8616 .need_dac_fix = 1,
8617 .input_mux = &alc882_capture_source,
8618 },
8619 [ALC882_ASUS_A7M] = {
8620 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
8ab9e0af
TI
8621 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8622 alc882_eapd_verbs, alc880_gpio1_init_verbs,
4953550a
TI
8623 alc882_asus_a7m_verbs },
8624 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8625 .dac_nids = alc882_dac_nids,
8626 .dig_out_nid = ALC882_DIGOUT_NID,
8627 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8628 .channel_mode = alc880_threestack_modes,
8629 .need_dac_fix = 1,
8630 .input_mux = &alc882_capture_source,
8631 },
9c7f852e
TI
8632 [ALC883_3ST_2ch_DIG] = {
8633 .mixers = { alc883_3ST_2ch_mixer },
8634 .init_verbs = { alc883_init_verbs },
8635 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8636 .dac_nids = alc883_dac_nids,
8637 .dig_out_nid = ALC883_DIGOUT_NID,
9c7f852e
TI
8638 .dig_in_nid = ALC883_DIGIN_NID,
8639 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8640 .channel_mode = alc883_3ST_2ch_modes,
8641 .input_mux = &alc883_capture_source,
8642 },
8643 [ALC883_3ST_6ch_DIG] = {
8644 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8645 .init_verbs = { alc883_init_verbs },
8646 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8647 .dac_nids = alc883_dac_nids,
8648 .dig_out_nid = ALC883_DIGOUT_NID,
9c7f852e
TI
8649 .dig_in_nid = ALC883_DIGIN_NID,
8650 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8651 .channel_mode = alc883_3ST_6ch_modes,
4e195a7b 8652 .need_dac_fix = 1,
9c7f852e 8653 .input_mux = &alc883_capture_source,
f12ab1e0 8654 },
9c7f852e
TI
8655 [ALC883_3ST_6ch] = {
8656 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8657 .init_verbs = { alc883_init_verbs },
8658 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8659 .dac_nids = alc883_dac_nids,
9c7f852e
TI
8660 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8661 .channel_mode = alc883_3ST_6ch_modes,
4e195a7b 8662 .need_dac_fix = 1,
9c7f852e 8663 .input_mux = &alc883_capture_source,
f12ab1e0 8664 },
17bba1b7
J
8665 [ALC883_3ST_6ch_INTEL] = {
8666 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8667 .init_verbs = { alc883_init_verbs },
8668 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8669 .dac_nids = alc883_dac_nids,
8670 .dig_out_nid = ALC883_DIGOUT_NID,
8671 .dig_in_nid = ALC883_DIGIN_NID,
f3cd3f5d 8672 .slave_dig_outs = alc883_slave_dig_outs,
17bba1b7
J
8673 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8674 .channel_mode = alc883_3ST_6ch_intel_modes,
8675 .need_dac_fix = 1,
8676 .input_mux = &alc883_3stack_6ch_intel,
8677 },
9c7f852e
TI
8678 [ALC883_6ST_DIG] = {
8679 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8680 .init_verbs = { alc883_init_verbs },
8681 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8682 .dac_nids = alc883_dac_nids,
8683 .dig_out_nid = ALC883_DIGOUT_NID,
9c7f852e
TI
8684 .dig_in_nid = ALC883_DIGIN_NID,
8685 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8686 .channel_mode = alc883_sixstack_modes,
8687 .input_mux = &alc883_capture_source,
8688 },
ccc656ce 8689 [ALC883_TARGA_DIG] = {
c259249f 8690 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
005b1076
DH
8691 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
8692 alc883_targa_verbs},
ccc656ce
KY
8693 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8694 .dac_nids = alc883_dac_nids,
8695 .dig_out_nid = ALC883_DIGOUT_NID,
ccc656ce
KY
8696 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8697 .channel_mode = alc883_3ST_6ch_modes,
8698 .need_dac_fix = 1,
8699 .input_mux = &alc883_capture_source,
c259249f
SA
8700 .unsol_event = alc883_targa_unsol_event,
8701 .init_hook = alc883_targa_init_hook,
ccc656ce
KY
8702 },
8703 [ALC883_TARGA_2ch_DIG] = {
c259249f 8704 .mixers = { alc883_targa_2ch_mixer},
005b1076
DH
8705 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
8706 alc883_targa_verbs},
ccc656ce
KY
8707 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8708 .dac_nids = alc883_dac_nids,
f9e336f6
TI
8709 .adc_nids = alc883_adc_nids_alt,
8710 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
ccc656ce 8711 .dig_out_nid = ALC883_DIGOUT_NID,
ccc656ce
KY
8712 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8713 .channel_mode = alc883_3ST_2ch_modes,
8714 .input_mux = &alc883_capture_source,
c259249f
SA
8715 .unsol_event = alc883_targa_unsol_event,
8716 .init_hook = alc883_targa_init_hook,
ccc656ce 8717 },
64a8be74
DH
8718 [ALC883_TARGA_8ch_DIG] = {
8719 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8720 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
c259249f 8721 alc883_targa_verbs },
64a8be74
DH
8722 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8723 .dac_nids = alc883_dac_nids,
8724 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8725 .adc_nids = alc883_adc_nids_rev,
8726 .capsrc_nids = alc883_capsrc_nids_rev,
8727 .dig_out_nid = ALC883_DIGOUT_NID,
8728 .dig_in_nid = ALC883_DIGIN_NID,
8729 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
8730 .channel_mode = alc883_4ST_8ch_modes,
8731 .need_dac_fix = 1,
8732 .input_mux = &alc883_capture_source,
c259249f
SA
8733 .unsol_event = alc883_targa_unsol_event,
8734 .init_hook = alc883_targa_init_hook,
64a8be74 8735 },
bab282b9 8736 [ALC883_ACER] = {
676a9b53 8737 .mixers = { alc883_base_mixer },
bab282b9
VA
8738 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8739 * and the headphone jack. Turn this on and rely on the
8740 * standard mute methods whenever the user wants to turn
8741 * these outputs off.
8742 */
8743 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8744 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8745 .dac_nids = alc883_dac_nids,
bab282b9
VA
8746 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8747 .channel_mode = alc883_3ST_2ch_modes,
8748 .input_mux = &alc883_capture_source,
8749 },
2880a867 8750 [ALC883_ACER_ASPIRE] = {
676a9b53 8751 .mixers = { alc883_acer_aspire_mixer },
d1a991a6 8752 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
2880a867
TD
8753 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8754 .dac_nids = alc883_dac_nids,
8755 .dig_out_nid = ALC883_DIGOUT_NID,
2880a867
TD
8756 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8757 .channel_mode = alc883_3ST_2ch_modes,
8758 .input_mux = &alc883_capture_source,
a9fd4f3f
TI
8759 .unsol_event = alc_automute_amp_unsol_event,
8760 .init_hook = alc883_acer_aspire_init_hook,
d1a991a6 8761 },
5b2d1eca 8762 [ALC888_ACER_ASPIRE_4930G] = {
ef8ef5fb 8763 .mixers = { alc888_base_mixer,
5b2d1eca
VP
8764 alc883_chmode_mixer },
8765 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8766 alc888_acer_aspire_4930g_verbs },
8767 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8768 .dac_nids = alc883_dac_nids,
8769 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8770 .adc_nids = alc883_adc_nids_rev,
8771 .capsrc_nids = alc883_capsrc_nids_rev,
8772 .dig_out_nid = ALC883_DIGOUT_NID,
8773 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8774 .channel_mode = alc883_3ST_6ch_modes,
8775 .need_dac_fix = 1,
8776 .num_mux_defs =
ef8ef5fb
VP
8777 ARRAY_SIZE(alc888_2_capture_sources),
8778 .input_mux = alc888_2_capture_sources,
d2fd4b09
TV
8779 .unsol_event = alc_automute_amp_unsol_event,
8780 .init_hook = alc888_acer_aspire_4930g_init_hook,
8781 },
8782 [ALC888_ACER_ASPIRE_6530G] = {
8783 .mixers = { alc888_acer_aspire_6530_mixer },
8784 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8785 alc888_acer_aspire_6530g_verbs },
8786 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8787 .dac_nids = alc883_dac_nids,
8788 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8789 .adc_nids = alc883_adc_nids_rev,
8790 .capsrc_nids = alc883_capsrc_nids_rev,
8791 .dig_out_nid = ALC883_DIGOUT_NID,
8792 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8793 .channel_mode = alc883_3ST_2ch_modes,
8794 .num_mux_defs =
8795 ARRAY_SIZE(alc888_2_capture_sources),
8796 .input_mux = alc888_acer_aspire_6530_sources,
a9fd4f3f 8797 .unsol_event = alc_automute_amp_unsol_event,
320d5920 8798 .init_hook = alc888_acer_aspire_6530g_init_hook,
5b2d1eca 8799 },
3b315d70
HM
8800 [ALC888_ACER_ASPIRE_8930G] = {
8801 .mixers = { alc888_base_mixer,
8802 alc883_chmode_mixer },
8803 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
018df418 8804 alc889_acer_aspire_8930g_verbs },
3b315d70
HM
8805 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8806 .dac_nids = alc883_dac_nids,
018df418
HM
8807 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
8808 .adc_nids = alc889_adc_nids,
8809 .capsrc_nids = alc889_capsrc_nids,
3b315d70
HM
8810 .dig_out_nid = ALC883_DIGOUT_NID,
8811 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8812 .channel_mode = alc883_3ST_6ch_modes,
8813 .need_dac_fix = 1,
8814 .const_channel_count = 6,
8815 .num_mux_defs =
018df418
HM
8816 ARRAY_SIZE(alc889_capture_sources),
8817 .input_mux = alc889_capture_sources,
3b315d70 8818 .unsol_event = alc_automute_amp_unsol_event,
018df418 8819 .init_hook = alc889_acer_aspire_8930g_init_hook,
3b315d70 8820 },
c07584c8
TD
8821 [ALC883_MEDION] = {
8822 .mixers = { alc883_fivestack_mixer,
8823 alc883_chmode_mixer },
8824 .init_verbs = { alc883_init_verbs,
b373bdeb 8825 alc883_medion_eapd_verbs },
c07584c8
TD
8826 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8827 .dac_nids = alc883_dac_nids,
f9e336f6
TI
8828 .adc_nids = alc883_adc_nids_alt,
8829 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
c07584c8
TD
8830 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8831 .channel_mode = alc883_sixstack_modes,
8832 .input_mux = &alc883_capture_source,
b373bdeb 8833 },
272a527c
KY
8834 [ALC883_MEDION_MD2] = {
8835 .mixers = { alc883_medion_md2_mixer},
8836 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8837 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8838 .dac_nids = alc883_dac_nids,
8839 .dig_out_nid = ALC883_DIGOUT_NID,
272a527c
KY
8840 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8841 .channel_mode = alc883_3ST_2ch_modes,
8842 .input_mux = &alc883_capture_source,
a9fd4f3f
TI
8843 .unsol_event = alc_automute_amp_unsol_event,
8844 .init_hook = alc883_medion_md2_init_hook,
ea1fb29a 8845 },
b373bdeb 8846 [ALC883_LAPTOP_EAPD] = {
676a9b53 8847 .mixers = { alc883_base_mixer },
b373bdeb
AN
8848 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8849 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8850 .dac_nids = alc883_dac_nids,
b373bdeb
AN
8851 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8852 .channel_mode = alc883_3ST_2ch_modes,
8853 .input_mux = &alc883_capture_source,
8854 },
0c4cc443
HRK
8855 [ALC883_CLEVO_M720] = {
8856 .mixers = { alc883_clevo_m720_mixer },
8857 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
368c7a95
J
8858 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8859 .dac_nids = alc883_dac_nids,
8860 .dig_out_nid = ALC883_DIGOUT_NID,
8861 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8862 .channel_mode = alc883_3ST_2ch_modes,
8863 .input_mux = &alc883_capture_source,
0c4cc443 8864 .unsol_event = alc883_clevo_m720_unsol_event,
a9fd4f3f 8865 .init_hook = alc883_clevo_m720_init_hook,
368c7a95 8866 },
bc9f98a9
KY
8867 [ALC883_LENOVO_101E_2ch] = {
8868 .mixers = { alc883_lenovo_101e_2ch_mixer},
8869 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8870 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8871 .dac_nids = alc883_dac_nids,
f9e336f6
TI
8872 .adc_nids = alc883_adc_nids_alt,
8873 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
bc9f98a9
KY
8874 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8875 .channel_mode = alc883_3ST_2ch_modes,
8876 .input_mux = &alc883_lenovo_101e_capture_source,
8877 .unsol_event = alc883_lenovo_101e_unsol_event,
8878 .init_hook = alc883_lenovo_101e_all_automute,
8879 },
272a527c
KY
8880 [ALC883_LENOVO_NB0763] = {
8881 .mixers = { alc883_lenovo_nb0763_mixer },
8882 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8883 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8884 .dac_nids = alc883_dac_nids,
272a527c
KY
8885 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8886 .channel_mode = alc883_3ST_2ch_modes,
8887 .need_dac_fix = 1,
8888 .input_mux = &alc883_lenovo_nb0763_capture_source,
a9fd4f3f
TI
8889 .unsol_event = alc_automute_amp_unsol_event,
8890 .init_hook = alc883_medion_md2_init_hook,
272a527c
KY
8891 },
8892 [ALC888_LENOVO_MS7195_DIG] = {
8893 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8894 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8895 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8896 .dac_nids = alc883_dac_nids,
8897 .dig_out_nid = ALC883_DIGOUT_NID,
272a527c
KY
8898 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8899 .channel_mode = alc883_3ST_6ch_modes,
8900 .need_dac_fix = 1,
8901 .input_mux = &alc883_capture_source,
8902 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8903 .init_hook = alc888_lenovo_ms7195_front_automute,
189609ae
KY
8904 },
8905 [ALC883_HAIER_W66] = {
c259249f 8906 .mixers = { alc883_targa_2ch_mixer},
189609ae
KY
8907 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8908 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8909 .dac_nids = alc883_dac_nids,
8910 .dig_out_nid = ALC883_DIGOUT_NID,
189609ae
KY
8911 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8912 .channel_mode = alc883_3ST_2ch_modes,
8913 .input_mux = &alc883_capture_source,
a9fd4f3f
TI
8914 .unsol_event = alc_automute_amp_unsol_event,
8915 .init_hook = alc883_haier_w66_init_hook,
eea6419e 8916 },
4723c022 8917 [ALC888_3ST_HP] = {
eea6419e 8918 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
4723c022 8919 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
8341de60
CM
8920 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8921 .dac_nids = alc883_dac_nids,
4723c022
CM
8922 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8923 .channel_mode = alc888_3st_hp_modes,
8341de60
CM
8924 .need_dac_fix = 1,
8925 .input_mux = &alc883_capture_source,
a9fd4f3f
TI
8926 .unsol_event = alc_automute_amp_unsol_event,
8927 .init_hook = alc888_3st_hp_init_hook,
8341de60 8928 },
5795b9e6 8929 [ALC888_6ST_DELL] = {
f24dbdc6 8930 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5795b9e6
CM
8931 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8932 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8933 .dac_nids = alc883_dac_nids,
8934 .dig_out_nid = ALC883_DIGOUT_NID,
5795b9e6
CM
8935 .dig_in_nid = ALC883_DIGIN_NID,
8936 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8937 .channel_mode = alc883_sixstack_modes,
8938 .input_mux = &alc883_capture_source,
a9fd4f3f
TI
8939 .unsol_event = alc_automute_amp_unsol_event,
8940 .init_hook = alc888_6st_dell_init_hook,
5795b9e6 8941 },
a8848bd6
AS
8942 [ALC883_MITAC] = {
8943 .mixers = { alc883_mitac_mixer },
8944 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8945 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8946 .dac_nids = alc883_dac_nids,
a8848bd6
AS
8947 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8948 .channel_mode = alc883_3ST_2ch_modes,
8949 .input_mux = &alc883_capture_source,
a9fd4f3f
TI
8950 .unsol_event = alc_automute_amp_unsol_event,
8951 .init_hook = alc883_mitac_init_hook,
a8848bd6 8952 },
fb97dc67
J
8953 [ALC883_FUJITSU_PI2515] = {
8954 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8955 .init_verbs = { alc883_init_verbs,
8956 alc883_2ch_fujitsu_pi2515_verbs},
8957 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8958 .dac_nids = alc883_dac_nids,
8959 .dig_out_nid = ALC883_DIGOUT_NID,
8960 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8961 .channel_mode = alc883_3ST_2ch_modes,
8962 .input_mux = &alc883_fujitsu_pi2515_capture_source,
a9fd4f3f
TI
8963 .unsol_event = alc_automute_amp_unsol_event,
8964 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
fb97dc67 8965 },
ef8ef5fb
VP
8966 [ALC888_FUJITSU_XA3530] = {
8967 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8968 .init_verbs = { alc883_init_verbs,
8969 alc888_fujitsu_xa3530_verbs },
8970 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8971 .dac_nids = alc883_dac_nids,
8972 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8973 .adc_nids = alc883_adc_nids_rev,
8974 .capsrc_nids = alc883_capsrc_nids_rev,
8975 .dig_out_nid = ALC883_DIGOUT_NID,
8976 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
8977 .channel_mode = alc888_4ST_8ch_intel_modes,
8978 .num_mux_defs =
8979 ARRAY_SIZE(alc888_2_capture_sources),
8980 .input_mux = alc888_2_capture_sources,
a9fd4f3f
TI
8981 .unsol_event = alc_automute_amp_unsol_event,
8982 .init_hook = alc888_fujitsu_xa3530_init_hook,
ef8ef5fb 8983 },
e2757d5e
KY
8984 [ALC888_LENOVO_SKY] = {
8985 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8986 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8987 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8988 .dac_nids = alc883_dac_nids,
8989 .dig_out_nid = ALC883_DIGOUT_NID,
e2757d5e
KY
8990 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8991 .channel_mode = alc883_sixstack_modes,
8992 .need_dac_fix = 1,
8993 .input_mux = &alc883_lenovo_sky_capture_source,
a9fd4f3f
TI
8994 .unsol_event = alc_automute_amp_unsol_event,
8995 .init_hook = alc888_lenovo_sky_init_hook,
e2757d5e
KY
8996 },
8997 [ALC888_ASUS_M90V] = {
8998 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8999 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9000 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9001 .dac_nids = alc883_dac_nids,
9002 .dig_out_nid = ALC883_DIGOUT_NID,
9003 .dig_in_nid = ALC883_DIGIN_NID,
9004 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9005 .channel_mode = alc883_3ST_6ch_modes,
9006 .need_dac_fix = 1,
9007 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9008 .unsol_event = alc883_mode2_unsol_event,
9009 .init_hook = alc883_mode2_inithook,
9010 },
9011 [ALC888_ASUS_EEE1601] = {
9012 .mixers = { alc883_asus_eee1601_mixer },
f9e336f6 9013 .cap_mixer = alc883_asus_eee1601_cap_mixer,
e2757d5e
KY
9014 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9015 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9016 .dac_nids = alc883_dac_nids,
9017 .dig_out_nid = ALC883_DIGOUT_NID,
9018 .dig_in_nid = ALC883_DIGIN_NID,
9019 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9020 .channel_mode = alc883_3ST_2ch_modes,
9021 .need_dac_fix = 1,
9022 .input_mux = &alc883_asus_eee1601_capture_source,
a9fd4f3f 9023 .unsol_event = alc_sku_unsol_event,
e2757d5e
KY
9024 .init_hook = alc883_eee1601_inithook,
9025 },
3ab90935
WF
9026 [ALC1200_ASUS_P5Q] = {
9027 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9028 .init_verbs = { alc883_init_verbs },
9029 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9030 .dac_nids = alc883_dac_nids,
9031 .dig_out_nid = ALC1200_DIGOUT_NID,
9032 .dig_in_nid = ALC883_DIGIN_NID,
b25c9da1 9033 .slave_dig_outs = alc1200_slave_dig_outs,
3ab90935
WF
9034 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9035 .channel_mode = alc883_sixstack_modes,
9036 .input_mux = &alc883_capture_source,
9037 },
eb4c41d3
TS
9038 [ALC889A_MB31] = {
9039 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9040 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9041 alc880_gpio1_init_verbs },
9042 .adc_nids = alc883_adc_nids,
9043 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9044 .dac_nids = alc883_dac_nids,
9045 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9046 .channel_mode = alc889A_mb31_6ch_modes,
9047 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9048 .input_mux = &alc889A_mb31_capture_source,
9049 .dig_out_nid = ALC883_DIGOUT_NID,
9050 .unsol_event = alc889A_mb31_unsol_event,
9051 .init_hook = alc889A_mb31_automute,
9052 },
3e1647c5
GG
9053 [ALC883_SONY_VAIO_TT] = {
9054 .mixers = { alc883_vaiott_mixer },
9055 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9056 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9057 .dac_nids = alc883_dac_nids,
9058 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9059 .channel_mode = alc883_3ST_2ch_modes,
9060 .input_mux = &alc883_capture_source,
9061 .unsol_event = alc_automute_amp_unsol_event,
9062 .init_hook = alc883_vaiott_init_hook,
9063 },
9c7f852e
TI
9064};
9065
9066
4953550a
TI
9067/*
9068 * Pin config fixes
9069 */
9070enum {
9071 PINFIX_ABIT_AW9D_MAX
9072};
9073
9074static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9075 { 0x15, 0x01080104 }, /* side */
9076 { 0x16, 0x01011012 }, /* rear */
9077 { 0x17, 0x01016011 }, /* clfe */
9078 { }
9079};
9080
9081static const struct alc_pincfg *alc882_pin_fixes[] = {
9082 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
9083};
9084
9085static struct snd_pci_quirk alc882_pinfix_tbl[] = {
9086 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9087 {}
9088};
9089
9c7f852e
TI
9090/*
9091 * BIOS auto configuration
9092 */
4953550a 9093static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
9c7f852e
TI
9094 hda_nid_t nid, int pin_type,
9095 int dac_idx)
9096{
9097 /* set as output */
9098 struct alc_spec *spec = codec->spec;
f12ab1e0
TI
9099 int idx;
9100
f6c7e546 9101 alc_set_pin_output(codec, nid, pin_type);
9c7f852e
TI
9102 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9103 idx = 4;
9104 else
9105 idx = spec->multiout.dac_nids[dac_idx] - 2;
9c7f852e
TI
9106 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9107
9108}
9109
4953550a 9110static void alc882_auto_init_multi_out(struct hda_codec *codec)
9c7f852e
TI
9111{
9112 struct alc_spec *spec = codec->spec;
9113 int i;
9114
9115 for (i = 0; i <= HDA_SIDE; i++) {
f12ab1e0 9116 hda_nid_t nid = spec->autocfg.line_out_pins[i];
baba8ee9 9117 int pin_type = get_pin_type(spec->autocfg.line_out_type);
9c7f852e 9118 if (nid)
4953550a 9119 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
f12ab1e0 9120 i);
9c7f852e
TI
9121 }
9122}
9123
4953550a 9124static void alc882_auto_init_hp_out(struct hda_codec *codec)
9c7f852e
TI
9125{
9126 struct alc_spec *spec = codec->spec;
9127 hda_nid_t pin;
9128
eb06ed8f 9129 pin = spec->autocfg.hp_pins[0];
9c7f852e
TI
9130 if (pin) /* connect to front */
9131 /* use dac 0 */
4953550a 9132 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
f6c7e546
TI
9133 pin = spec->autocfg.speaker_pins[0];
9134 if (pin)
4953550a 9135 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
9c7f852e
TI
9136}
9137
4953550a 9138static void alc882_auto_init_analog_input(struct hda_codec *codec)
9c7f852e
TI
9139{
9140 struct alc_spec *spec = codec->spec;
9141 int i;
9142
9143 for (i = 0; i < AUTO_PIN_LAST; i++) {
9144 hda_nid_t nid = spec->autocfg.input_pins[i];
4953550a
TI
9145 if (!nid)
9146 continue;
0d971c9f 9147 alc_set_input_pin(codec, nid, i);
4953550a
TI
9148 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9149 snd_hda_codec_write(codec, nid, 0,
9150 AC_VERB_SET_AMP_GAIN_MUTE,
9151 AMP_OUT_MUTE);
9152 }
9153}
9154
9155static void alc882_auto_init_input_src(struct hda_codec *codec)
9156{
9157 struct alc_spec *spec = codec->spec;
9158 int c;
9159
9160 for (c = 0; c < spec->num_adc_nids; c++) {
9161 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9162 hda_nid_t nid = spec->capsrc_nids[c];
9163 unsigned int mux_idx;
9164 const struct hda_input_mux *imux;
9165 int conns, mute, idx, item;
9166
9167 conns = snd_hda_get_connections(codec, nid, conn_list,
9168 ARRAY_SIZE(conn_list));
9169 if (conns < 0)
9170 continue;
9171 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9172 imux = &spec->input_mux[mux_idx];
9173 for (idx = 0; idx < conns; idx++) {
9174 /* if the current connection is the selected one,
9175 * unmute it as default - otherwise mute it
9176 */
9177 mute = AMP_IN_MUTE(idx);
9178 for (item = 0; item < imux->num_items; item++) {
9179 if (imux->items[item].index == idx) {
9180 if (spec->cur_mux[c] == item)
9181 mute = AMP_IN_UNMUTE(idx);
9182 break;
9183 }
9184 }
9185 /* check if we have a selector or mixer
9186 * we could check for the widget type instead, but
9187 * just check for Amp-In presence (in case of mixer
9188 * without amp-in there is something wrong, this
9189 * function shouldn't be used or capsrc nid is wrong)
9190 */
9191 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
9c7f852e
TI
9192 snd_hda_codec_write(codec, nid, 0,
9193 AC_VERB_SET_AMP_GAIN_MUTE,
4953550a
TI
9194 mute);
9195 else if (mute != AMP_IN_MUTE(idx))
9196 snd_hda_codec_write(codec, nid, 0,
9197 AC_VERB_SET_CONNECT_SEL,
9198 idx);
9c7f852e
TI
9199 }
9200 }
9201}
9202
4953550a
TI
9203/* add mic boosts if needed */
9204static int alc_auto_add_mic_boost(struct hda_codec *codec)
9205{
9206 struct alc_spec *spec = codec->spec;
9207 int err;
9208 hda_nid_t nid;
9209
9210 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9211 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9212 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9213 "Mic Boost",
9214 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9215 if (err < 0)
9216 return err;
9217 }
9218 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9219 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9220 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9221 "Front Mic Boost",
9222 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9223 if (err < 0)
9224 return err;
9225 }
9226 return 0;
9227}
f511b01c 9228
9c7f852e 9229/* almost identical with ALC880 parser... */
4953550a 9230static int alc882_parse_auto_config(struct hda_codec *codec)
9c7f852e
TI
9231{
9232 struct alc_spec *spec = codec->spec;
4953550a
TI
9233 struct auto_pin_cfg *autocfg = &spec->autocfg;
9234 unsigned int wcap;
61b9b9b1 9235 int i;
4953550a 9236 int err = alc880_parse_auto_config(codec);
9c7f852e
TI
9237
9238 if (err < 0)
9239 return err;
776e184e
TI
9240 else if (!err)
9241 return 0; /* no config found */
9242
9243 err = alc_auto_add_mic_boost(codec);
9244 if (err < 0)
9245 return err;
9246
9247 /* hack - override the init verbs */
9248 spec->init_verbs[0] = alc883_auto_init_verbs;
4953550a
TI
9249 /* if ADC 0x07 is available, initialize it, too */
9250 wcap = get_wcaps(codec, 0x07);
9251 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9252 if (wcap == AC_WID_AUD_IN)
9253 add_verb(spec, alc882_adc1_init_verbs);
776e184e 9254
4953550a
TI
9255 /* digital-mic input pin is excluded in alc880_auto_create..()
9256 * because it's under 0x18
9257 */
9258 if (autocfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9259 autocfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9260 struct hda_input_mux *imux = &spec->private_imux[0];
9261 for (i = 1; i < 3; i++)
9262 memcpy(&spec->private_imux[i],
9263 &spec->private_imux[0],
9264 sizeof(spec->private_imux[0]));
9265 imux->items[imux->num_items].label = "Int DMic";
9266 imux->items[imux->num_items].index = 0x0b;
9267 imux->num_items++;
9268 spec->num_mux_defs = 3;
9269 spec->input_mux = spec->private_imux;
61b9b9b1
HRK
9270 }
9271
776e184e 9272 return 1; /* config found */
9c7f852e
TI
9273}
9274
9275/* additional initialization for auto-configuration model */
4953550a 9276static void alc882_auto_init(struct hda_codec *codec)
9c7f852e 9277{
f6c7e546 9278 struct alc_spec *spec = codec->spec;
4953550a
TI
9279 alc882_auto_init_multi_out(codec);
9280 alc882_auto_init_hp_out(codec);
9281 alc882_auto_init_analog_input(codec);
9282 alc882_auto_init_input_src(codec);
f6c7e546 9283 if (spec->unsol_event)
7fb0d78f 9284 alc_inithook(codec);
9c7f852e
TI
9285}
9286
4953550a 9287static int patch_alc882(struct hda_codec *codec)
9c7f852e
TI
9288{
9289 struct alc_spec *spec;
9290 int err, board_config;
9291
9292 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9293 if (spec == NULL)
9294 return -ENOMEM;
9295
9296 codec->spec = spec;
9297
4953550a
TI
9298 switch (codec->vendor_id) {
9299 case 0x10ec0882:
9300 case 0x10ec0885:
9301 break;
9302 default:
9303 /* ALC883 and variants */
9304 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9305 break;
9306 }
2c3bf9ab 9307
4953550a
TI
9308 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9309 alc882_models,
9310 alc882_cfg_tbl);
9311
9312 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9313 board_config = snd_hda_check_board_codec_sid_config(codec,
9314 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9315
9316 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
9317 printk(KERN_INFO "hda_codec: Unknown model for %s, "
9318 "trying auto-probe from BIOS...\n",
9319 codec->chip_name);
9320 board_config = ALC882_AUTO;
9c7f852e
TI
9321 }
9322
4953550a
TI
9323 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
9324
9325 if (board_config == ALC882_AUTO) {
9c7f852e 9326 /* automatic parse from the BIOS config */
4953550a 9327 err = alc882_parse_auto_config(codec);
9c7f852e
TI
9328 if (err < 0) {
9329 alc_free(codec);
9330 return err;
f12ab1e0 9331 } else if (!err) {
9c7f852e
TI
9332 printk(KERN_INFO
9333 "hda_codec: Cannot set up configuration "
9334 "from BIOS. Using base mode...\n");
4953550a 9335 board_config = ALC882_3ST_DIG;
9c7f852e
TI
9336 }
9337 }
9338
680cd536
KK
9339 err = snd_hda_attach_beep_device(codec, 0x1);
9340 if (err < 0) {
9341 alc_free(codec);
9342 return err;
9343 }
9344
4953550a
TI
9345 if (board_config != ALC882_AUTO)
9346 setup_preset(spec, &alc882_presets[board_config]);
9c7f852e 9347
4953550a
TI
9348 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9349 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9350 /* FIXME: setup DAC5 */
9351 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9352 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9353
9354 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9355 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9356
9357 if (codec->vendor_id == 0x10ec0888)
4a79ba34 9358 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
4953550a
TI
9359
9360 if (!spec->adc_nids && spec->input_mux) {
9361 int i;
9362 spec->num_adc_nids = 0;
9363 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9364 hda_nid_t cap;
9365 hda_nid_t nid = alc882_adc_nids[i];
9366 unsigned int wcap = get_wcaps(codec, nid);
9367 /* get type */
9368 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9369 if (wcap != AC_WID_AUD_IN)
9370 continue;
9371 spec->private_adc_nids[spec->num_adc_nids] = nid;
9372 err = snd_hda_get_connections(codec, nid, &cap, 1);
9373 if (err < 0)
9374 continue;
9375 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9376 spec->num_adc_nids++;
61b9b9b1 9377 }
4953550a
TI
9378 spec->adc_nids = spec->private_adc_nids;
9379 spec->capsrc_nids = spec->private_capsrc_nids;
2f893286
KY
9380 }
9381
4953550a 9382 set_capture_mixer(spec);
45bdd1c1 9383 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
9c7f852e 9384
2134ea4f
TI
9385 spec->vmaster_nid = 0x0c;
9386
9c7f852e 9387 codec->patch_ops = alc_patch_ops;
4953550a
TI
9388 if (board_config == ALC882_AUTO)
9389 spec->init_hook = alc882_auto_init;
cb53c626
TI
9390#ifdef CONFIG_SND_HDA_POWER_SAVE
9391 if (!spec->loopback.amplist)
4953550a 9392 spec->loopback.amplist = alc882_loopbacks;
cb53c626 9393#endif
daead538 9394 codec->proc_widget_hook = print_realtek_coef;
9c7f852e
TI
9395
9396 return 0;
9397}
9398
4953550a 9399
9c7f852e
TI
9400/*
9401 * ALC262 support
9402 */
9403
9404#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9405#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9406
9407#define alc262_dac_nids alc260_dac_nids
9408#define alc262_adc_nids alc882_adc_nids
9409#define alc262_adc_nids_alt alc882_adc_nids_alt
88c71a99
TI
9410#define alc262_capsrc_nids alc882_capsrc_nids
9411#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
9c7f852e
TI
9412
9413#define alc262_modes alc260_modes
9414#define alc262_capture_source alc882_capture_source
9415
4e555fe5
KY
9416static hda_nid_t alc262_dmic_adc_nids[1] = {
9417 /* ADC0 */
9418 0x09
9419};
9420
9421static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9422
9c7f852e
TI
9423static struct snd_kcontrol_new alc262_base_mixer[] = {
9424 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9425 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9426 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9427 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9428 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9429 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
cc69d12d 9432 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9c7f852e
TI
9433 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9434 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
cc69d12d 9435 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9c7f852e
TI
9436 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9437 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9438 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9439 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
9440 { } /* end */
9441};
9442
ce875f07
TI
9443/* update HP, line and mono-out pins according to the master switch */
9444static void alc262_hp_master_update(struct hda_codec *codec)
9445{
9446 struct alc_spec *spec = codec->spec;
9447 int val = spec->master_sw;
9448
9449 /* HP & line-out */
9450 snd_hda_codec_write_cache(codec, 0x1b, 0,
9451 AC_VERB_SET_PIN_WIDGET_CONTROL,
9452 val ? PIN_HP : 0);
9453 snd_hda_codec_write_cache(codec, 0x15, 0,
9454 AC_VERB_SET_PIN_WIDGET_CONTROL,
9455 val ? PIN_HP : 0);
9456 /* mono (speaker) depending on the HP jack sense */
9457 val = val && !spec->jack_present;
9458 snd_hda_codec_write_cache(codec, 0x16, 0,
9459 AC_VERB_SET_PIN_WIDGET_CONTROL,
9460 val ? PIN_OUT : 0);
9461}
9462
9463static void alc262_hp_bpc_automute(struct hda_codec *codec)
9464{
9465 struct alc_spec *spec = codec->spec;
9466 unsigned int presence;
9467 presence = snd_hda_codec_read(codec, 0x1b, 0,
9468 AC_VERB_GET_PIN_SENSE, 0);
9469 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9470 alc262_hp_master_update(codec);
9471}
9472
9473static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9474{
9475 if ((res >> 26) != ALC880_HP_EVENT)
9476 return;
9477 alc262_hp_bpc_automute(codec);
9478}
9479
9480static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9481{
9482 struct alc_spec *spec = codec->spec;
9483 unsigned int presence;
9484 presence = snd_hda_codec_read(codec, 0x15, 0,
9485 AC_VERB_GET_PIN_SENSE, 0);
9486 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9487 alc262_hp_master_update(codec);
9488}
9489
9490static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9491 unsigned int res)
9492{
9493 if ((res >> 26) != ALC880_HP_EVENT)
9494 return;
9495 alc262_hp_wildwest_automute(codec);
9496}
9497
b72519b5 9498#define alc262_hp_master_sw_get alc260_hp_master_sw_get
ce875f07
TI
9499
9500static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9501 struct snd_ctl_elem_value *ucontrol)
9502{
9503 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9504 struct alc_spec *spec = codec->spec;
9505 int val = !!*ucontrol->value.integer.value;
9506
9507 if (val == spec->master_sw)
9508 return 0;
9509 spec->master_sw = val;
9510 alc262_hp_master_update(codec);
9511 return 1;
9512}
9513
b72519b5
TI
9514#define ALC262_HP_MASTER_SWITCH \
9515 { \
9516 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9517 .name = "Master Playback Switch", \
9518 .info = snd_ctl_boolean_mono_info, \
9519 .get = alc262_hp_master_sw_get, \
9520 .put = alc262_hp_master_sw_put, \
9521 }
9522
9c7f852e 9523static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
b72519b5 9524 ALC262_HP_MASTER_SWITCH,
9c7f852e
TI
9525 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9526 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9527 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
ce875f07
TI
9528 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9529 HDA_OUTPUT),
9530 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9531 HDA_OUTPUT),
9c7f852e
TI
9532 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9533 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
cc69d12d 9534 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9c7f852e
TI
9535 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9536 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
cc69d12d 9537 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9c7f852e
TI
9538 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9539 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9540 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9541 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9c7f852e
TI
9542 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9543 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9544 { } /* end */
9545};
9546
cd7509a4 9547static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
b72519b5 9548 ALC262_HP_MASTER_SWITCH,
cd7509a4
KY
9549 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9550 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9551 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9552 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
ce875f07
TI
9553 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9554 HDA_OUTPUT),
9555 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9556 HDA_OUTPUT),
cd7509a4
KY
9557 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9558 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
cc69d12d 9559 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
cd7509a4
KY
9560 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9561 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9562 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9563 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
cd7509a4
KY
9564 { } /* end */
9565};
9566
9567static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9568 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9569 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
cc69d12d 9570 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
cd7509a4
KY
9571 { } /* end */
9572};
9573
66d2a9d6 9574/* mute/unmute internal speaker according to the hp jack and mute state */
a9fd4f3f 9575static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
66d2a9d6
KY
9576{
9577 struct alc_spec *spec = codec->spec;
66d2a9d6 9578
a9fd4f3f
TI
9579 spec->autocfg.hp_pins[0] = 0x15;
9580 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
9581 alc_automute_amp(codec);
66d2a9d6
KY
9582}
9583
66d2a9d6 9584static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
86cd9298
TI
9585 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9586 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
66d2a9d6
KY
9587 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9588 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9589 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9590 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9591 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9592 { } /* end */
9593};
9594
9595static struct hda_verb alc262_hp_t5735_verbs[] = {
9596 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9597 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9598
9599 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9600 { }
9601};
9602
8c427226 9603static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
f2f48e18
TI
9604 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9605 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
86cd9298
TI
9606 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9607 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8c427226
KY
9608 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9609 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9610 { } /* end */
9611};
9612
9613static struct hda_verb alc262_hp_rp5700_verbs[] = {
9614 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9615 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9616 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9617 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9618 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9619 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9620 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9621 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9622 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9623 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9624 {}
9625};
9626
9627static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9628 .num_items = 1,
9629 .items = {
9630 { "Line", 0x1 },
9631 },
9632};
9633
42171c17
TI
9634/* bind hp and internal speaker mute (with plug check) as master switch */
9635static void alc262_hippo_master_update(struct hda_codec *codec)
0724ea2a 9636{
42171c17
TI
9637 struct alc_spec *spec = codec->spec;
9638 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9639 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9640 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9641 unsigned int mute;
0724ea2a 9642
42171c17
TI
9643 /* HP */
9644 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
9645 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
9646 HDA_AMP_MUTE, mute);
9647 /* mute internal speaker per jack sense */
9648 if (spec->jack_present)
9649 mute = HDA_AMP_MUTE;
9650 if (line_nid)
9651 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
9652 HDA_AMP_MUTE, mute);
9653 if (speaker_nid && speaker_nid != line_nid)
9654 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
0724ea2a 9655 HDA_AMP_MUTE, mute);
42171c17
TI
9656}
9657
9658#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
9659
9660static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
9661 struct snd_ctl_elem_value *ucontrol)
9662{
9663 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9664 struct alc_spec *spec = codec->spec;
9665 int val = !!*ucontrol->value.integer.value;
9666
9667 if (val == spec->master_sw)
9668 return 0;
9669 spec->master_sw = val;
9670 alc262_hippo_master_update(codec);
9671 return 1;
9672}
9673
9674#define ALC262_HIPPO_MASTER_SWITCH \
9675 { \
9676 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9677 .name = "Master Playback Switch", \
9678 .info = snd_ctl_boolean_mono_info, \
9679 .get = alc262_hippo_master_sw_get, \
9680 .put = alc262_hippo_master_sw_put, \
0724ea2a 9681 }
42171c17
TI
9682
9683static struct snd_kcontrol_new alc262_hippo_mixer[] = {
9684 ALC262_HIPPO_MASTER_SWITCH,
9685 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9686 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9687 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9688 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9689 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9690 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9691 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9692 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9693 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9694 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9695 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9696 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9697 { } /* end */
9698};
9699
9700static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9701 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9702 ALC262_HIPPO_MASTER_SWITCH,
9703 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9704 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9705 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9706 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9709 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9710 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9711 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9712 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9713 { } /* end */
9714};
9715
9716/* mute/unmute internal speaker according to the hp jack and mute state */
9717static void alc262_hippo_automute(struct hda_codec *codec)
9718{
9719 struct alc_spec *spec = codec->spec;
9720 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9721 unsigned int present;
9722
9723 /* need to execute and sync at first */
9724 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
9725 present = snd_hda_codec_read(codec, hp_nid, 0,
9726 AC_VERB_GET_PIN_SENSE, 0);
9727 spec->jack_present = (present & 0x80000000) != 0;
9728 alc262_hippo_master_update(codec);
0724ea2a 9729}
5b31954e 9730
42171c17
TI
9731static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
9732{
9733 if ((res >> 26) != ALC880_HP_EVENT)
9734 return;
9735 alc262_hippo_automute(codec);
9736}
9737
9738static void alc262_hippo_init_hook(struct hda_codec *codec)
9739{
9740 struct alc_spec *spec = codec->spec;
9741
9742 spec->autocfg.hp_pins[0] = 0x15;
9743 spec->autocfg.speaker_pins[0] = 0x14;
9744 alc262_hippo_automute(codec);
9745}
9746
9747static void alc262_hippo1_init_hook(struct hda_codec *codec)
9748{
9749 struct alc_spec *spec = codec->spec;
9750
9751 spec->autocfg.hp_pins[0] = 0x1b;
9752 spec->autocfg.speaker_pins[0] = 0x14;
9753 alc262_hippo_automute(codec);
9754}
9755
9756
272a527c 9757static struct snd_kcontrol_new alc262_sony_mixer[] = {
0724ea2a 9758 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
42171c17 9759 ALC262_HIPPO_MASTER_SWITCH,
272a527c
KY
9760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9762 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9763 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9764 { } /* end */
9765};
9766
83c34218 9767static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
42171c17
TI
9768 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9769 ALC262_HIPPO_MASTER_SWITCH,
83c34218
KY
9770 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9772 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9773 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9774 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9775 { } /* end */
9776};
272a527c 9777
ba340e82
TV
9778static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9779 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9780 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9781 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9782 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9783 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9784 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9785 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9786 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9787 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9788 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9789 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9790 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9791 { } /* end */
9792};
9793
9794static struct hda_verb alc262_tyan_verbs[] = {
9795 /* Headphone automute */
9796 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9797 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9798 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9799
9800 /* P11 AUX_IN, white 4-pin connector */
9801 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9802 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9803 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9804 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9805
9806 {}
9807};
9808
9809/* unsolicited event for HP jack sensing */
a9fd4f3f 9810static void alc262_tyan_init_hook(struct hda_codec *codec)
ba340e82 9811{
a9fd4f3f 9812 struct alc_spec *spec = codec->spec;
ba340e82 9813
a9fd4f3f
TI
9814 spec->autocfg.hp_pins[0] = 0x1b;
9815 spec->autocfg.speaker_pins[0] = 0x15;
9816 alc_automute_amp(codec);
ba340e82
TV
9817}
9818
ba340e82 9819
9c7f852e
TI
9820#define alc262_capture_mixer alc882_capture_mixer
9821#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9822
9823/*
9824 * generic initialization of ADC, input mixers and output mixers
9825 */
9826static struct hda_verb alc262_init_verbs[] = {
9827 /*
9828 * Unmute ADC0-2 and set the default input to mic-in
9829 */
9830 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9831 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9832 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9833 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9834 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9835 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9836
cb53c626 9837 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
9c7f852e 9838 * mixer widget
f12ab1e0
TI
9839 * Note: PASD motherboards uses the Line In 2 as the input for
9840 * front panel mic (mic 2)
9c7f852e
TI
9841 */
9842 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
cb53c626
TI
9843 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9844 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9845 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9846 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9847 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9c7f852e
TI
9848
9849 /*
df694daa
KY
9850 * Set up output mixers (0x0c - 0x0e)
9851 */
9852 /* set vol=0 to output mixers */
9853 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9854 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9855 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9856 /* set up input amps for analog loopback */
9857 /* Amp Indices: DAC = 0, mixer = 1 */
9858 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9859 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9860 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9861 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9862 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9863 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9864
9865 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9866 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9867 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9868 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9869 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9870 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9871
9872 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9873 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9874 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9875 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9876 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
ea1fb29a 9877
df694daa
KY
9878 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9879 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
ea1fb29a 9880
df694daa
KY
9881 /* FIXME: use matrix-type input source selection */
9882 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9883 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9884 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9885 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9886 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9887 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9888 /* Input mixer2 */
9889 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9890 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9891 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9892 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9893 /* Input mixer3 */
9894 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9895 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9896 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
f12ab1e0 9897 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
df694daa
KY
9898
9899 { }
9900};
1da177e4 9901
4e555fe5
KY
9902static struct hda_verb alc262_eapd_verbs[] = {
9903 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9904 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9905 { }
9906};
9907
ccc656ce
KY
9908static struct hda_verb alc262_hippo_unsol_verbs[] = {
9909 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9910 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9911 {}
9912};
9913
9914static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9915 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9916 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9917 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9918
9919 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9920 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9921 {}
9922};
9923
272a527c
KY
9924static struct hda_verb alc262_sony_unsol_verbs[] = {
9925 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9926 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9927 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9928
9929 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9930 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7b1e8795 9931 {}
272a527c
KY
9932};
9933
4e555fe5
KY
9934static struct hda_input_mux alc262_dmic_capture_source = {
9935 .num_items = 2,
9936 .items = {
9937 { "Int DMic", 0x9 },
9938 { "Mic", 0x0 },
9939 },
9940};
9941
9942static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9943 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9944 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9945 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9946 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9947 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4e555fe5
KY
9948 { } /* end */
9949};
9950
9951static struct hda_verb alc262_toshiba_s06_verbs[] = {
9952 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9953 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9954 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9955 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9956 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9957 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9958 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9959 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9960 {}
9961};
9962
9963static void alc262_dmic_automute(struct hda_codec *codec)
9964{
9965 unsigned int present;
9966
9967 present = snd_hda_codec_read(codec, 0x18, 0,
9968 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9969 snd_hda_codec_write(codec, 0x22, 0,
9970 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9971}
9972
4e555fe5
KY
9973
9974/* unsolicited event for HP jack sensing */
9975static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9976 unsigned int res)
9977{
4e555fe5
KY
9978 if ((res >> 26) == ALC880_MIC_EVENT)
9979 alc262_dmic_automute(codec);
a9fd4f3f
TI
9980 else
9981 alc_sku_unsol_event(codec, res);
4e555fe5
KY
9982}
9983
9984static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9985{
a9fd4f3f
TI
9986 struct alc_spec *spec = codec->spec;
9987
9988 spec->autocfg.hp_pins[0] = 0x15;
9989 spec->autocfg.speaker_pins[0] = 0x14;
9990 alc_automute_pin(codec);
4e555fe5
KY
9991 alc262_dmic_automute(codec);
9992}
9993
e8f9ae2a
PT
9994/*
9995 * nec model
9996 * 0x15 = headphone
9997 * 0x16 = internal speaker
9998 * 0x18 = external mic
9999 */
10000
10001static struct snd_kcontrol_new alc262_nec_mixer[] = {
10002 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10003 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10004
10005 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10006 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10007 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10008
10009 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10010 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10011 { } /* end */
10012};
10013
10014static struct hda_verb alc262_nec_verbs[] = {
10015 /* Unmute Speaker */
10016 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10017
10018 /* Headphone */
10019 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10020 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10021
10022 /* External mic to headphone */
10023 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10024 /* External mic to speaker */
10025 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10026 {}
10027};
10028
834be88d
TI
10029/*
10030 * fujitsu model
5d9fab2d
TV
10031 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10032 * 0x1b = port replicator headphone out
834be88d
TI
10033 */
10034
10035#define ALC_HP_EVENT 0x37
10036
10037static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10038 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10039 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5d9fab2d
TV
10040 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10041 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
834be88d
TI
10042 {}
10043};
10044
0e31daf7
J
10045static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10046 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10047 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10048 {}
10049};
10050
834be88d 10051static struct hda_input_mux alc262_fujitsu_capture_source = {
39d3ed38 10052 .num_items = 3,
834be88d
TI
10053 .items = {
10054 { "Mic", 0x0 },
39d3ed38 10055 { "Int Mic", 0x1 },
834be88d
TI
10056 { "CD", 0x4 },
10057 },
10058};
10059
9c7f852e
TI
10060static struct hda_input_mux alc262_HP_capture_source = {
10061 .num_items = 5,
10062 .items = {
10063 { "Mic", 0x0 },
accbe498 10064 { "Front Mic", 0x1 },
9c7f852e
TI
10065 { "Line", 0x2 },
10066 { "CD", 0x4 },
10067 { "AUX IN", 0x6 },
10068 },
10069};
10070
accbe498 10071static struct hda_input_mux alc262_HP_D7000_capture_source = {
10072 .num_items = 4,
10073 .items = {
10074 { "Mic", 0x0 },
10075 { "Front Mic", 0x2 },
10076 { "Line", 0x1 },
10077 { "CD", 0x4 },
10078 },
10079};
10080
ebc7a406 10081/* mute/unmute internal speaker according to the hp jacks and mute state */
834be88d
TI
10082static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10083{
10084 struct alc_spec *spec = codec->spec;
10085 unsigned int mute;
10086
f12ab1e0 10087 if (force || !spec->sense_updated) {
ebc7a406 10088 unsigned int present;
834be88d
TI
10089 /* need to execute and sync at first */
10090 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
ebc7a406
TI
10091 /* check laptop HP jack */
10092 present = snd_hda_codec_read(codec, 0x14, 0,
10093 AC_VERB_GET_PIN_SENSE, 0);
10094 /* need to execute and sync at first */
10095 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10096 /* check docking HP jack */
10097 present |= snd_hda_codec_read(codec, 0x1b, 0,
10098 AC_VERB_GET_PIN_SENSE, 0);
10099 if (present & AC_PINSENSE_PRESENCE)
10100 spec->jack_present = 1;
10101 else
10102 spec->jack_present = 0;
834be88d
TI
10103 spec->sense_updated = 1;
10104 }
ebc7a406
TI
10105 /* unmute internal speaker only if both HPs are unplugged and
10106 * master switch is on
10107 */
10108 if (spec->jack_present)
10109 mute = HDA_AMP_MUTE;
10110 else
834be88d 10111 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
ebc7a406
TI
10112 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10113 HDA_AMP_MUTE, mute);
834be88d
TI
10114}
10115
10116/* unsolicited event for HP jack sensing */
10117static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10118 unsigned int res)
10119{
10120 if ((res >> 26) != ALC_HP_EVENT)
10121 return;
10122 alc262_fujitsu_automute(codec, 1);
10123}
10124
ebc7a406
TI
10125static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10126{
10127 alc262_fujitsu_automute(codec, 1);
10128}
10129
834be88d 10130/* bind volumes of both NID 0x0c and 0x0d */
cca3b371
TI
10131static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10132 .ops = &snd_hda_bind_vol,
10133 .values = {
10134 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10135 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10136 0
10137 },
10138};
834be88d 10139
0e31daf7
J
10140/* mute/unmute internal speaker according to the hp jack and mute state */
10141static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10142{
10143 struct alc_spec *spec = codec->spec;
10144 unsigned int mute;
10145
10146 if (force || !spec->sense_updated) {
10147 unsigned int present_int_hp;
10148 /* need to execute and sync at first */
10149 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10150 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10151 AC_VERB_GET_PIN_SENSE, 0);
10152 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10153 spec->sense_updated = 1;
10154 }
10155 if (spec->jack_present) {
10156 /* mute internal speaker */
10157 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10158 HDA_AMP_MUTE, HDA_AMP_MUTE);
10159 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10160 HDA_AMP_MUTE, HDA_AMP_MUTE);
10161 } else {
10162 /* unmute internal speaker if necessary */
10163 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10164 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10165 HDA_AMP_MUTE, mute);
10166 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10167 HDA_AMP_MUTE, mute);
10168 }
10169}
10170
10171/* unsolicited event for HP jack sensing */
10172static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10173 unsigned int res)
10174{
10175 if ((res >> 26) != ALC_HP_EVENT)
10176 return;
10177 alc262_lenovo_3000_automute(codec, 1);
10178}
10179
834be88d
TI
10180/* bind hp and internal speaker mute (with plug check) */
10181static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10182 struct snd_ctl_elem_value *ucontrol)
10183{
10184 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10185 long *valp = ucontrol->value.integer.value;
10186 int change;
10187
5d9fab2d
TV
10188 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10189 HDA_AMP_MUTE,
10190 valp ? 0 : HDA_AMP_MUTE);
10191 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10192 HDA_AMP_MUTE,
10193 valp ? 0 : HDA_AMP_MUTE);
10194
82beb8fd
TI
10195 if (change)
10196 alc262_fujitsu_automute(codec, 0);
834be88d
TI
10197 return change;
10198}
10199
10200static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
cca3b371 10201 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
834be88d
TI
10202 {
10203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10204 .name = "Master Playback Switch",
10205 .info = snd_hda_mixer_amp_switch_info,
10206 .get = snd_hda_mixer_amp_switch_get,
10207 .put = alc262_fujitsu_master_sw_put,
10208 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10209 },
10210 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10211 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10212 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10213 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10214 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
39d3ed38
TI
10215 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10216 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10217 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
834be88d
TI
10218 { } /* end */
10219};
10220
0e31daf7
J
10221/* bind hp and internal speaker mute (with plug check) */
10222static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10223 struct snd_ctl_elem_value *ucontrol)
10224{
10225 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10226 long *valp = ucontrol->value.integer.value;
10227 int change;
10228
10229 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10230 HDA_AMP_MUTE,
10231 valp ? 0 : HDA_AMP_MUTE);
10232
10233 if (change)
10234 alc262_lenovo_3000_automute(codec, 0);
10235 return change;
10236}
10237
10238static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10239 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10240 {
10241 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10242 .name = "Master Playback Switch",
10243 .info = snd_hda_mixer_amp_switch_info,
10244 .get = snd_hda_mixer_amp_switch_get,
10245 .put = alc262_lenovo_3000_master_sw_put,
10246 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10247 },
10248 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10249 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10250 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10252 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10253 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10254 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10255 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10256 { } /* end */
10257};
10258
9f99a638
HM
10259static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10260 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
42171c17 10261 ALC262_HIPPO_MASTER_SWITCH,
9f99a638
HM
10262 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10263 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10264 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10265 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10266 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10267 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10268 { } /* end */
10269};
10270
304dcaac
TI
10271/* additional init verbs for Benq laptops */
10272static struct hda_verb alc262_EAPD_verbs[] = {
10273 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10274 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10275 {}
10276};
10277
83c34218
KY
10278static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10279 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10280 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10281
10282 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10283 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10284 {}
10285};
10286
f651b50b
TD
10287/* Samsung Q1 Ultra Vista model setup */
10288static struct snd_kcontrol_new alc262_ultra_mixer[] = {
bb9f76cd
TI
10289 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10290 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
f651b50b
TD
10291 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10292 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10293 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
bb9f76cd 10294 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
f651b50b
TD
10295 { } /* end */
10296};
10297
10298static struct hda_verb alc262_ultra_verbs[] = {
bb9f76cd
TI
10299 /* output mixer */
10300 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10301 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10302 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10303 /* speaker */
10304 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10305 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10306 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10307 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10308 /* HP */
f651b50b 10309 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
bb9f76cd
TI
10310 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10311 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10312 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10313 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10314 /* internal mic */
10315 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10317 /* ADC, choose mic */
10318 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10319 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10320 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10321 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10322 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10323 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10324 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10325 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10326 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10327 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
f651b50b
TD
10328 {}
10329};
10330
f651b50b
TD
10331/* mute/unmute internal speaker according to the hp jack and mute state */
10332static void alc262_ultra_automute(struct hda_codec *codec)
10333{
10334 struct alc_spec *spec = codec->spec;
10335 unsigned int mute;
f651b50b 10336
bb9f76cd
TI
10337 mute = 0;
10338 /* auto-mute only when HP is used as HP */
10339 if (!spec->cur_mux[0]) {
10340 unsigned int present;
10341 /* need to execute and sync at first */
10342 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10343 present = snd_hda_codec_read(codec, 0x15, 0,
10344 AC_VERB_GET_PIN_SENSE, 0);
10345 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10346 if (spec->jack_present)
10347 mute = HDA_AMP_MUTE;
f651b50b 10348 }
bb9f76cd
TI
10349 /* mute/unmute internal speaker */
10350 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10351 HDA_AMP_MUTE, mute);
10352 /* mute/unmute HP */
10353 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10354 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
f651b50b
TD
10355}
10356
10357/* unsolicited event for HP jack sensing */
10358static void alc262_ultra_unsol_event(struct hda_codec *codec,
10359 unsigned int res)
10360{
10361 if ((res >> 26) != ALC880_HP_EVENT)
10362 return;
10363 alc262_ultra_automute(codec);
10364}
10365
bb9f76cd
TI
10366static struct hda_input_mux alc262_ultra_capture_source = {
10367 .num_items = 2,
10368 .items = {
10369 { "Mic", 0x1 },
10370 { "Headphone", 0x7 },
10371 },
10372};
10373
10374static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10375 struct snd_ctl_elem_value *ucontrol)
10376{
10377 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10378 struct alc_spec *spec = codec->spec;
10379 int ret;
10380
54cbc9ab 10381 ret = alc_mux_enum_put(kcontrol, ucontrol);
bb9f76cd
TI
10382 if (!ret)
10383 return 0;
10384 /* reprogram the HP pin as mic or HP according to the input source */
10385 snd_hda_codec_write_cache(codec, 0x15, 0,
10386 AC_VERB_SET_PIN_WIDGET_CONTROL,
10387 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10388 alc262_ultra_automute(codec); /* mute/unmute HP */
10389 return ret;
10390}
10391
10392static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10393 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10394 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10395 {
10396 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10397 .name = "Capture Source",
54cbc9ab
TI
10398 .info = alc_mux_enum_info,
10399 .get = alc_mux_enum_get,
bb9f76cd
TI
10400 .put = alc262_ultra_mux_enum_put,
10401 },
10402 { } /* end */
10403};
10404
df694daa 10405/* add playback controls from the parsed DAC table */
f12ab1e0
TI
10406static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10407 const struct auto_pin_cfg *cfg)
df694daa
KY
10408{
10409 hda_nid_t nid;
10410 int err;
10411
10412 spec->multiout.num_dacs = 1; /* only use one dac */
10413 spec->multiout.dac_nids = spec->private_dac_nids;
10414 spec->multiout.dac_nids[0] = 2;
10415
10416 nid = cfg->line_out_pins[0];
10417 if (nid) {
f12ab1e0
TI
10418 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10419 "Front Playback Volume",
10420 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10421 if (err < 0)
df694daa 10422 return err;
f12ab1e0
TI
10423 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10424 "Front Playback Switch",
10425 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10426 if (err < 0)
df694daa
KY
10427 return err;
10428 }
10429
82bc955f 10430 nid = cfg->speaker_pins[0];
df694daa
KY
10431 if (nid) {
10432 if (nid == 0x16) {
f12ab1e0
TI
10433 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10434 "Speaker Playback Volume",
10435 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10436 HDA_OUTPUT));
10437 if (err < 0)
df694daa 10438 return err;
f12ab1e0
TI
10439 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10440 "Speaker Playback Switch",
10441 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10442 HDA_OUTPUT));
10443 if (err < 0)
df694daa
KY
10444 return err;
10445 } else {
f12ab1e0
TI
10446 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10447 "Speaker Playback Switch",
10448 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10449 HDA_OUTPUT));
10450 if (err < 0)
df694daa
KY
10451 return err;
10452 }
10453 }
eb06ed8f 10454 nid = cfg->hp_pins[0];
df694daa
KY
10455 if (nid) {
10456 /* spec->multiout.hp_nid = 2; */
10457 if (nid == 0x16) {
f12ab1e0
TI
10458 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10459 "Headphone Playback Volume",
10460 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10461 HDA_OUTPUT));
10462 if (err < 0)
df694daa 10463 return err;
f12ab1e0
TI
10464 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10465 "Headphone Playback Switch",
10466 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10467 HDA_OUTPUT));
10468 if (err < 0)
df694daa
KY
10469 return err;
10470 } else {
f12ab1e0
TI
10471 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10472 "Headphone Playback Switch",
10473 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10474 HDA_OUTPUT));
10475 if (err < 0)
df694daa
KY
10476 return err;
10477 }
10478 }
f12ab1e0 10479 return 0;
df694daa
KY
10480}
10481
8c927b4a
TI
10482static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec,
10483 const struct auto_pin_cfg *cfg)
10484{
10485 int err;
10486
10487 err = alc880_auto_create_analog_input_ctls(spec, cfg);
10488 if (err < 0)
10489 return err;
10490 /* digital-mic input pin is excluded in alc880_auto_create..()
10491 * because it's under 0x18
10492 */
10493 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
10494 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
10495 struct hda_input_mux *imux = &spec->private_imux[0];
10496 imux->items[imux->num_items].label = "Int Mic";
10497 imux->items[imux->num_items].index = 0x09;
10498 imux->num_items++;
10499 }
10500 return 0;
10501}
10502
df694daa
KY
10503
10504/*
10505 * generic initialization of ADC, input mixers and output mixers
10506 */
10507static struct hda_verb alc262_volume_init_verbs[] = {
10508 /*
10509 * Unmute ADC0-2 and set the default input to mic-in
10510 */
10511 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10512 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10513 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10514 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10515 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10516 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10517
cb53c626 10518 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
df694daa 10519 * mixer widget
f12ab1e0
TI
10520 * Note: PASD motherboards uses the Line In 2 as the input for
10521 * front panel mic (mic 2)
df694daa
KY
10522 */
10523 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
cb53c626
TI
10524 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10525 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10526 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
df694daa
KY
10529
10530 /*
10531 * Set up output mixers (0x0c - 0x0f)
10532 */
10533 /* set vol=0 to output mixers */
10534 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10535 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10536 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
ea1fb29a 10537
df694daa
KY
10538 /* set up input amps for analog loopback */
10539 /* Amp Indices: DAC = 0, mixer = 1 */
10540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10541 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10542 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10543 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10544 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10545 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10546
10547 /* FIXME: use matrix-type input source selection */
10548 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10549 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10550 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10551 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10552 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10553 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10554 /* Input mixer2 */
10555 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10556 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10557 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10558 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10559 /* Input mixer3 */
10560 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10561 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10562 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10563 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10564
10565 { }
10566};
10567
9c7f852e
TI
10568static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10569 /*
10570 * Unmute ADC0-2 and set the default input to mic-in
10571 */
10572 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10573 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10574 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10575 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10576 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10577 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10578
cb53c626 10579 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
9c7f852e 10580 * mixer widget
f12ab1e0
TI
10581 * Note: PASD motherboards uses the Line In 2 as the input for
10582 * front panel mic (mic 2)
9c7f852e
TI
10583 */
10584 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
cb53c626
TI
10585 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10586 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10587 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10588 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10589 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10590 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10591 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
ea1fb29a 10592
9c7f852e
TI
10593 /*
10594 * Set up output mixers (0x0c - 0x0e)
10595 */
10596 /* set vol=0 to output mixers */
10597 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10598 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10599 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10600
10601 /* set up input amps for analog loopback */
10602 /* Amp Indices: DAC = 0, mixer = 1 */
10603 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10604 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10605 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10606 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10607 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10608 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10609
ce875f07 10610 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9c7f852e
TI
10611 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10612 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10613
10614 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10615 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10616
10617 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10618 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10619
10620 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10621 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10622 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10623 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10624 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10625
0e4835c1 10626 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9c7f852e
TI
10627 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10628 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
0e4835c1 10629 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9c7f852e
TI
10630 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10631 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10632
10633
10634 /* FIXME: use matrix-type input source selection */
0e4835c1
JK
10635 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
10636 /* Input mixer1: only unmute Mic */
9c7f852e 10637 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
0e4835c1
JK
10638 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10639 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10640 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10641 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10642 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10643 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10644 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10645 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
9c7f852e
TI
10646 /* Input mixer2 */
10647 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
0e4835c1
JK
10648 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10649 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10650 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10651 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10652 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10653 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10654 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10655 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
9c7f852e
TI
10656 /* Input mixer3 */
10657 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
0e4835c1
JK
10658 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10659 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10660 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10661 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10662 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10663 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10664 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10665 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
9c7f852e 10666
ce875f07
TI
10667 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10668
9c7f852e
TI
10669 { }
10670};
10671
cd7509a4
KY
10672static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10673 /*
10674 * Unmute ADC0-2 and set the default input to mic-in
10675 */
10676 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10677 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10678 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10679 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10680 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10681 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10682
cb53c626 10683 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
cd7509a4
KY
10684 * mixer widget
10685 * Note: PASD motherboards uses the Line In 2 as the input for front
10686 * panel mic (mic 2)
10687 */
10688 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
cb53c626
TI
10689 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10690 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10691 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10692 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10693 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10694 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10695 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10696 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
cd7509a4
KY
10697 /*
10698 * Set up output mixers (0x0c - 0x0e)
10699 */
10700 /* set vol=0 to output mixers */
10701 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10702 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10703 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10704
10705 /* set up input amps for analog loopback */
10706 /* Amp Indices: DAC = 0, mixer = 1 */
10707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10709 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10710 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10711 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10712 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10713
10714
10715 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10716 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10717 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10718 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10719 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10720 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10721 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10722
10723 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10724 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10725
10726 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10727 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10728
10729 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10730 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10731 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10732 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10733 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10734 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10735
10736 /* FIXME: use matrix-type input source selection */
10737 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10738 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10739 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10740 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10741 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10742 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10743 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10744 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10745 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10746 /* Input mixer2 */
10747 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10748 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10749 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10750 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10751 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10752 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10753 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10754 /* Input mixer3 */
10755 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10756 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10757 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10758 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10759 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10760 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10761 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10762
ce875f07
TI
10763 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10764
cd7509a4
KY
10765 { }
10766};
10767
9f99a638
HM
10768static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10769
10770 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10771 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10772 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10773
10774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10775 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10776 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10777 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10778
10779 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10780 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10781 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10782 {}
10783};
10784
10785
cb53c626
TI
10786#ifdef CONFIG_SND_HDA_POWER_SAVE
10787#define alc262_loopbacks alc880_loopbacks
10788#endif
10789
def319f9 10790/* pcm configuration: identical with ALC880 */
df694daa
KY
10791#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10792#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10793#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10794#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10795
10796/*
10797 * BIOS auto configuration
10798 */
10799static int alc262_parse_auto_config(struct hda_codec *codec)
10800{
10801 struct alc_spec *spec = codec->spec;
10802 int err;
10803 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10804
f12ab1e0
TI
10805 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10806 alc262_ignore);
10807 if (err < 0)
df694daa 10808 return err;
e64f14f4 10809 if (!spec->autocfg.line_outs) {
0852d7a6 10810 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
e64f14f4
TI
10811 spec->multiout.max_channels = 2;
10812 spec->no_analog = 1;
10813 goto dig_only;
10814 }
df694daa 10815 return 0; /* can't find valid BIOS pin config */
e64f14f4 10816 }
f12ab1e0
TI
10817 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10818 if (err < 0)
10819 return err;
10820 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10821 if (err < 0)
df694daa
KY
10822 return err;
10823
10824 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10825
e64f14f4 10826 dig_only:
0852d7a6 10827 if (spec->autocfg.dig_outs) {
df694daa 10828 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
0852d7a6 10829 spec->dig_out_type = spec->autocfg.dig_out_type[0];
e64f14f4 10830 }
df694daa
KY
10831 if (spec->autocfg.dig_in_pin)
10832 spec->dig_in_nid = ALC262_DIGIN_NID;
10833
603c4019 10834 if (spec->kctls.list)
d88897ea 10835 add_mixer(spec, spec->kctls.list);
df694daa 10836
d88897ea 10837 add_verb(spec, alc262_volume_init_verbs);
a1e8d2da 10838 spec->num_mux_defs = 1;
61b9b9b1 10839 spec->input_mux = &spec->private_imux[0];
df694daa 10840
776e184e
TI
10841 err = alc_auto_add_mic_boost(codec);
10842 if (err < 0)
10843 return err;
10844
4a79ba34
TI
10845 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
10846
df694daa
KY
10847 return 1;
10848}
10849
10850#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10851#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10852#define alc262_auto_init_analog_input alc882_auto_init_analog_input
f511b01c 10853#define alc262_auto_init_input_src alc882_auto_init_input_src
df694daa
KY
10854
10855
10856/* init callback for auto-configuration model -- overriding the default init */
ae6b813a 10857static void alc262_auto_init(struct hda_codec *codec)
df694daa 10858{
f6c7e546 10859 struct alc_spec *spec = codec->spec;
df694daa
KY
10860 alc262_auto_init_multi_out(codec);
10861 alc262_auto_init_hp_out(codec);
10862 alc262_auto_init_analog_input(codec);
f511b01c 10863 alc262_auto_init_input_src(codec);
f6c7e546 10864 if (spec->unsol_event)
7fb0d78f 10865 alc_inithook(codec);
df694daa
KY
10866}
10867
10868/*
10869 * configuration and preset
10870 */
f5fcc13c
TI
10871static const char *alc262_models[ALC262_MODEL_LAST] = {
10872 [ALC262_BASIC] = "basic",
10873 [ALC262_HIPPO] = "hippo",
10874 [ALC262_HIPPO_1] = "hippo_1",
10875 [ALC262_FUJITSU] = "fujitsu",
10876 [ALC262_HP_BPC] = "hp-bpc",
cd7509a4 10877 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
61dc35de 10878 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
8c427226 10879 [ALC262_HP_RP5700] = "hp-rp5700",
f5fcc13c 10880 [ALC262_BENQ_ED8] = "benq",
0f40502e
TI
10881 [ALC262_BENQ_T31] = "benq-t31",
10882 [ALC262_SONY_ASSAMD] = "sony-assamd",
2922c9af 10883 [ALC262_TOSHIBA_S06] = "toshiba-s06",
9f99a638 10884 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
f651b50b 10885 [ALC262_ULTRA] = "ultra",
0e31daf7 10886 [ALC262_LENOVO_3000] = "lenovo-3000",
e8f9ae2a 10887 [ALC262_NEC] = "nec",
ba340e82 10888 [ALC262_TYAN] = "tyan",
f5fcc13c
TI
10889 [ALC262_AUTO] = "auto",
10890};
10891
10892static struct snd_pci_quirk alc262_cfg_tbl[] = {
10893 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
e8f9ae2a 10894 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
dea0a509
TI
10895 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10896 ALC262_HP_BPC),
10897 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10898 ALC262_HP_BPC),
53eff7e1
TI
10899 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
10900 ALC262_HP_BPC),
cd7509a4 10901 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
cd7509a4 10902 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
ac3e3741 10903 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
cd7509a4 10904 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
ac3e3741 10905 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
cd7509a4 10906 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
ac3e3741 10907 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
cd7509a4 10908 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
ac3e3741
TI
10909 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10910 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10911 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
66d2a9d6
KY
10912 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10913 ALC262_HP_TC_T5735),
8c427226 10914 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
ac3e3741 10915 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
f5fcc13c 10916 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
5b31954e 10917 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
bd6afe3f 10918 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
376b508f 10919 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
f872a919
TI
10920 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
10921 ALC262_SONY_ASSAMD),
36ca6e13 10922 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
9f99a638 10923 ALC262_TOSHIBA_RX1),
80ffe869 10924 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
ac3e3741 10925 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
3f1eeaed 10926 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
ba340e82 10927 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
dea0a509
TI
10928 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10929 ALC262_ULTRA),
3e420e78 10930 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
0e31daf7 10931 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
ac3e3741
TI
10932 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
10933 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
10934 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
df694daa
KY
10935 {}
10936};
10937
10938static struct alc_config_preset alc262_presets[] = {
10939 [ALC262_BASIC] = {
10940 .mixers = { alc262_base_mixer },
10941 .init_verbs = { alc262_init_verbs },
10942 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10943 .dac_nids = alc262_dac_nids,
10944 .hp_nid = 0x03,
10945 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10946 .channel_mode = alc262_modes,
a3bcba38 10947 .input_mux = &alc262_capture_source,
df694daa 10948 },
ccc656ce 10949 [ALC262_HIPPO] = {
42171c17 10950 .mixers = { alc262_hippo_mixer },
ccc656ce
KY
10951 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10952 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10953 .dac_nids = alc262_dac_nids,
10954 .hp_nid = 0x03,
10955 .dig_out_nid = ALC262_DIGOUT_NID,
10956 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10957 .channel_mode = alc262_modes,
10958 .input_mux = &alc262_capture_source,
10959 .unsol_event = alc262_hippo_unsol_event,
42171c17 10960 .init_hook = alc262_hippo_init_hook,
ccc656ce
KY
10961 },
10962 [ALC262_HIPPO_1] = {
10963 .mixers = { alc262_hippo1_mixer },
10964 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10965 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10966 .dac_nids = alc262_dac_nids,
10967 .hp_nid = 0x02,
10968 .dig_out_nid = ALC262_DIGOUT_NID,
10969 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10970 .channel_mode = alc262_modes,
10971 .input_mux = &alc262_capture_source,
42171c17
TI
10972 .unsol_event = alc262_hippo_unsol_event,
10973 .init_hook = alc262_hippo1_init_hook,
ccc656ce 10974 },
834be88d
TI
10975 [ALC262_FUJITSU] = {
10976 .mixers = { alc262_fujitsu_mixer },
39d3ed38
TI
10977 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10978 alc262_fujitsu_unsol_verbs },
834be88d
TI
10979 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10980 .dac_nids = alc262_dac_nids,
10981 .hp_nid = 0x03,
10982 .dig_out_nid = ALC262_DIGOUT_NID,
10983 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10984 .channel_mode = alc262_modes,
10985 .input_mux = &alc262_fujitsu_capture_source,
ae6b813a 10986 .unsol_event = alc262_fujitsu_unsol_event,
ebc7a406 10987 .init_hook = alc262_fujitsu_init_hook,
834be88d 10988 },
9c7f852e
TI
10989 [ALC262_HP_BPC] = {
10990 .mixers = { alc262_HP_BPC_mixer },
10991 .init_verbs = { alc262_HP_BPC_init_verbs },
10992 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10993 .dac_nids = alc262_dac_nids,
10994 .hp_nid = 0x03,
10995 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10996 .channel_mode = alc262_modes,
10997 .input_mux = &alc262_HP_capture_source,
ce875f07
TI
10998 .unsol_event = alc262_hp_bpc_unsol_event,
10999 .init_hook = alc262_hp_bpc_automute,
f12ab1e0 11000 },
cd7509a4
KY
11001 [ALC262_HP_BPC_D7000_WF] = {
11002 .mixers = { alc262_HP_BPC_WildWest_mixer },
11003 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11004 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11005 .dac_nids = alc262_dac_nids,
11006 .hp_nid = 0x03,
11007 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11008 .channel_mode = alc262_modes,
accbe498 11009 .input_mux = &alc262_HP_D7000_capture_source,
ce875f07
TI
11010 .unsol_event = alc262_hp_wildwest_unsol_event,
11011 .init_hook = alc262_hp_wildwest_automute,
f12ab1e0 11012 },
cd7509a4
KY
11013 [ALC262_HP_BPC_D7000_WL] = {
11014 .mixers = { alc262_HP_BPC_WildWest_mixer,
11015 alc262_HP_BPC_WildWest_option_mixer },
11016 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11017 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11018 .dac_nids = alc262_dac_nids,
11019 .hp_nid = 0x03,
11020 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11021 .channel_mode = alc262_modes,
accbe498 11022 .input_mux = &alc262_HP_D7000_capture_source,
ce875f07
TI
11023 .unsol_event = alc262_hp_wildwest_unsol_event,
11024 .init_hook = alc262_hp_wildwest_automute,
f12ab1e0 11025 },
66d2a9d6
KY
11026 [ALC262_HP_TC_T5735] = {
11027 .mixers = { alc262_hp_t5735_mixer },
11028 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11029 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11030 .dac_nids = alc262_dac_nids,
11031 .hp_nid = 0x03,
11032 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11033 .channel_mode = alc262_modes,
11034 .input_mux = &alc262_capture_source,
a9fd4f3f 11035 .unsol_event = alc_automute_amp_unsol_event,
66d2a9d6 11036 .init_hook = alc262_hp_t5735_init_hook,
8c427226
KY
11037 },
11038 [ALC262_HP_RP5700] = {
11039 .mixers = { alc262_hp_rp5700_mixer },
11040 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11041 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11042 .dac_nids = alc262_dac_nids,
11043 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11044 .channel_mode = alc262_modes,
11045 .input_mux = &alc262_hp_rp5700_capture_source,
66d2a9d6 11046 },
304dcaac
TI
11047 [ALC262_BENQ_ED8] = {
11048 .mixers = { alc262_base_mixer },
11049 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11050 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11051 .dac_nids = alc262_dac_nids,
11052 .hp_nid = 0x03,
11053 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11054 .channel_mode = alc262_modes,
11055 .input_mux = &alc262_capture_source,
f12ab1e0 11056 },
272a527c
KY
11057 [ALC262_SONY_ASSAMD] = {
11058 .mixers = { alc262_sony_mixer },
11059 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11060 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11061 .dac_nids = alc262_dac_nids,
11062 .hp_nid = 0x02,
11063 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11064 .channel_mode = alc262_modes,
11065 .input_mux = &alc262_capture_source,
11066 .unsol_event = alc262_hippo_unsol_event,
42171c17 11067 .init_hook = alc262_hippo_init_hook,
83c34218
KY
11068 },
11069 [ALC262_BENQ_T31] = {
11070 .mixers = { alc262_benq_t31_mixer },
11071 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11072 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11073 .dac_nids = alc262_dac_nids,
11074 .hp_nid = 0x03,
11075 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11076 .channel_mode = alc262_modes,
11077 .input_mux = &alc262_capture_source,
11078 .unsol_event = alc262_hippo_unsol_event,
42171c17 11079 .init_hook = alc262_hippo_init_hook,
ea1fb29a 11080 },
f651b50b 11081 [ALC262_ULTRA] = {
f9e336f6
TI
11082 .mixers = { alc262_ultra_mixer },
11083 .cap_mixer = alc262_ultra_capture_mixer,
bb9f76cd 11084 .init_verbs = { alc262_ultra_verbs },
f651b50b
TD
11085 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11086 .dac_nids = alc262_dac_nids,
f651b50b
TD
11087 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11088 .channel_mode = alc262_modes,
11089 .input_mux = &alc262_ultra_capture_source,
bb9f76cd
TI
11090 .adc_nids = alc262_adc_nids, /* ADC0 */
11091 .capsrc_nids = alc262_capsrc_nids,
11092 .num_adc_nids = 1, /* single ADC */
f651b50b
TD
11093 .unsol_event = alc262_ultra_unsol_event,
11094 .init_hook = alc262_ultra_automute,
11095 },
0e31daf7
J
11096 [ALC262_LENOVO_3000] = {
11097 .mixers = { alc262_lenovo_3000_mixer },
11098 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11099 alc262_lenovo_3000_unsol_verbs },
11100 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11101 .dac_nids = alc262_dac_nids,
11102 .hp_nid = 0x03,
11103 .dig_out_nid = ALC262_DIGOUT_NID,
11104 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11105 .channel_mode = alc262_modes,
11106 .input_mux = &alc262_fujitsu_capture_source,
11107 .unsol_event = alc262_lenovo_3000_unsol_event,
11108 },
e8f9ae2a
PT
11109 [ALC262_NEC] = {
11110 .mixers = { alc262_nec_mixer },
11111 .init_verbs = { alc262_nec_verbs },
11112 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11113 .dac_nids = alc262_dac_nids,
11114 .hp_nid = 0x03,
11115 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11116 .channel_mode = alc262_modes,
11117 .input_mux = &alc262_capture_source,
11118 },
4e555fe5
KY
11119 [ALC262_TOSHIBA_S06] = {
11120 .mixers = { alc262_toshiba_s06_mixer },
11121 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11122 alc262_eapd_verbs },
11123 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11124 .capsrc_nids = alc262_dmic_capsrc_nids,
11125 .dac_nids = alc262_dac_nids,
11126 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
ae14ef68 11127 .num_adc_nids = 1, /* single ADC */
4e555fe5
KY
11128 .dig_out_nid = ALC262_DIGOUT_NID,
11129 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11130 .channel_mode = alc262_modes,
11131 .input_mux = &alc262_dmic_capture_source,
11132 .unsol_event = alc262_toshiba_s06_unsol_event,
11133 .init_hook = alc262_toshiba_s06_init_hook,
11134 },
9f99a638
HM
11135 [ALC262_TOSHIBA_RX1] = {
11136 .mixers = { alc262_toshiba_rx1_mixer },
11137 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11138 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11139 .dac_nids = alc262_dac_nids,
11140 .hp_nid = 0x03,
11141 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11142 .channel_mode = alc262_modes,
11143 .input_mux = &alc262_capture_source,
11144 .unsol_event = alc262_hippo_unsol_event,
42171c17 11145 .init_hook = alc262_hippo_init_hook,
9f99a638 11146 },
ba340e82
TV
11147 [ALC262_TYAN] = {
11148 .mixers = { alc262_tyan_mixer },
11149 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11150 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11151 .dac_nids = alc262_dac_nids,
11152 .hp_nid = 0x02,
11153 .dig_out_nid = ALC262_DIGOUT_NID,
11154 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11155 .channel_mode = alc262_modes,
11156 .input_mux = &alc262_capture_source,
a9fd4f3f
TI
11157 .unsol_event = alc_automute_amp_unsol_event,
11158 .init_hook = alc262_tyan_init_hook,
ba340e82 11159 },
df694daa
KY
11160};
11161
11162static int patch_alc262(struct hda_codec *codec)
11163{
11164 struct alc_spec *spec;
11165 int board_config;
11166 int err;
11167
dc041e0b 11168 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
df694daa
KY
11169 if (spec == NULL)
11170 return -ENOMEM;
11171
11172 codec->spec = spec;
11173#if 0
f12ab1e0
TI
11174 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11175 * under-run
11176 */
df694daa
KY
11177 {
11178 int tmp;
11179 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11180 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11181 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11182 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11183 }
11184#endif
11185
2c3bf9ab
TI
11186 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11187
f5fcc13c
TI
11188 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11189 alc262_models,
11190 alc262_cfg_tbl);
cd7509a4 11191
f5fcc13c 11192 if (board_config < 0) {
6c627f39
TI
11193 printk(KERN_INFO "hda_codec: Unknown model for %s, "
11194 "trying auto-probe from BIOS...\n", codec->chip_name);
df694daa
KY
11195 board_config = ALC262_AUTO;
11196 }
11197
11198 if (board_config == ALC262_AUTO) {
11199 /* automatic parse from the BIOS config */
11200 err = alc262_parse_auto_config(codec);
11201 if (err < 0) {
11202 alc_free(codec);
11203 return err;
f12ab1e0 11204 } else if (!err) {
9c7f852e
TI
11205 printk(KERN_INFO
11206 "hda_codec: Cannot set up configuration "
11207 "from BIOS. Using base mode...\n");
df694daa
KY
11208 board_config = ALC262_BASIC;
11209 }
11210 }
11211
07eba61d
TI
11212 if (!spec->no_analog) {
11213 err = snd_hda_attach_beep_device(codec, 0x1);
11214 if (err < 0) {
11215 alc_free(codec);
11216 return err;
11217 }
680cd536
KK
11218 }
11219
df694daa
KY
11220 if (board_config != ALC262_AUTO)
11221 setup_preset(spec, &alc262_presets[board_config]);
11222
df694daa
KY
11223 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11224 spec->stream_analog_capture = &alc262_pcm_analog_capture;
ea1fb29a 11225
df694daa
KY
11226 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11227 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11228
f12ab1e0 11229 if (!spec->adc_nids && spec->input_mux) {
8c927b4a
TI
11230 int i;
11231 /* check whether the digital-mic has to be supported */
11232 for (i = 0; i < spec->input_mux->num_items; i++) {
11233 if (spec->input_mux->items[i].index >= 9)
11234 break;
11235 }
11236 if (i < spec->input_mux->num_items) {
11237 /* use only ADC0 */
11238 spec->adc_nids = alc262_dmic_adc_nids;
11239 spec->num_adc_nids = 1;
11240 spec->capsrc_nids = alc262_dmic_capsrc_nids;
df694daa 11241 } else {
8c927b4a
TI
11242 /* all analog inputs */
11243 /* check whether NID 0x07 is valid */
11244 unsigned int wcap = get_wcaps(codec, 0x07);
11245
11246 /* get type */
11247 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
11248 if (wcap != AC_WID_AUD_IN) {
11249 spec->adc_nids = alc262_adc_nids_alt;
11250 spec->num_adc_nids =
11251 ARRAY_SIZE(alc262_adc_nids_alt);
11252 spec->capsrc_nids = alc262_capsrc_nids_alt;
11253 } else {
11254 spec->adc_nids = alc262_adc_nids;
11255 spec->num_adc_nids =
11256 ARRAY_SIZE(alc262_adc_nids);
11257 spec->capsrc_nids = alc262_capsrc_nids;
11258 }
df694daa
KY
11259 }
11260 }
e64f14f4 11261 if (!spec->cap_mixer && !spec->no_analog)
f9e336f6 11262 set_capture_mixer(spec);
07eba61d
TI
11263 if (!spec->no_analog)
11264 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
df694daa 11265
2134ea4f
TI
11266 spec->vmaster_nid = 0x0c;
11267
df694daa
KY
11268 codec->patch_ops = alc_patch_ops;
11269 if (board_config == ALC262_AUTO)
ae6b813a 11270 spec->init_hook = alc262_auto_init;
cb53c626
TI
11271#ifdef CONFIG_SND_HDA_POWER_SAVE
11272 if (!spec->loopback.amplist)
11273 spec->loopback.amplist = alc262_loopbacks;
11274#endif
daead538 11275 codec->proc_widget_hook = print_realtek_coef;
ea1fb29a 11276
df694daa
KY
11277 return 0;
11278}
11279
a361d84b
KY
11280/*
11281 * ALC268 channel source setting (2 channel)
11282 */
11283#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11284#define alc268_modes alc260_modes
ea1fb29a 11285
a361d84b
KY
11286static hda_nid_t alc268_dac_nids[2] = {
11287 /* front, hp */
11288 0x02, 0x03
11289};
11290
11291static hda_nid_t alc268_adc_nids[2] = {
11292 /* ADC0-1 */
11293 0x08, 0x07
11294};
11295
11296static hda_nid_t alc268_adc_nids_alt[1] = {
11297 /* ADC0 */
11298 0x08
11299};
11300
e1406348
TI
11301static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11302
a361d84b
KY
11303static struct snd_kcontrol_new alc268_base_mixer[] = {
11304 /* output mixer control */
11305 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11306 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11307 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11308 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
33bf17ab
TI
11309 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11310 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11311 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
a361d84b
KY
11312 { }
11313};
11314
42171c17
TI
11315static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11316 /* output mixer control */
11317 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11318 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11319 ALC262_HIPPO_MASTER_SWITCH,
11320 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11321 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11322 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11323 { }
11324};
11325
aef9d318
TI
11326/* bind Beep switches of both NID 0x0f and 0x10 */
11327static struct hda_bind_ctls alc268_bind_beep_sw = {
11328 .ops = &snd_hda_bind_sw,
11329 .values = {
11330 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11331 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11332 0
11333 },
11334};
11335
11336static struct snd_kcontrol_new alc268_beep_mixer[] = {
11337 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11338 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11339 { }
11340};
11341
d1a991a6
KY
11342static struct hda_verb alc268_eapd_verbs[] = {
11343 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11344 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11345 { }
11346};
11347
d273809e 11348/* Toshiba specific */
d273809e
TI
11349static struct hda_verb alc268_toshiba_verbs[] = {
11350 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11351 { } /* end */
11352};
11353
8ef355da
KY
11354static struct hda_input_mux alc268_acer_lc_capture_source = {
11355 .num_items = 2,
11356 .items = {
11357 { "i-Mic", 0x6 },
11358 { "E-Mic", 0x0 },
11359 },
11360};
11361
d273809e 11362/* Acer specific */
889c4395 11363/* bind volumes of both NID 0x02 and 0x03 */
6bc96857
TI
11364static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11365 .ops = &snd_hda_bind_vol,
11366 .values = {
11367 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11368 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11369 0
11370 },
11371};
11372
889c4395
TI
11373/* mute/unmute internal speaker according to the hp jack and mute state */
11374static void alc268_acer_automute(struct hda_codec *codec, int force)
11375{
11376 struct alc_spec *spec = codec->spec;
11377 unsigned int mute;
11378
11379 if (force || !spec->sense_updated) {
11380 unsigned int present;
11381 present = snd_hda_codec_read(codec, 0x14, 0,
11382 AC_VERB_GET_PIN_SENSE, 0);
11383 spec->jack_present = (present & 0x80000000) != 0;
11384 spec->sense_updated = 1;
11385 }
11386 if (spec->jack_present)
11387 mute = HDA_AMP_MUTE; /* mute internal speaker */
11388 else /* unmute internal speaker if necessary */
11389 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11390 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11391 HDA_AMP_MUTE, mute);
11392}
11393
11394
11395/* bind hp and internal speaker mute (with plug check) */
11396static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11397 struct snd_ctl_elem_value *ucontrol)
11398{
11399 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11400 long *valp = ucontrol->value.integer.value;
11401 int change;
11402
11403 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11404 HDA_AMP_MUTE,
11405 valp[0] ? 0 : HDA_AMP_MUTE);
11406 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11407 HDA_AMP_MUTE,
11408 valp[1] ? 0 : HDA_AMP_MUTE);
11409 if (change)
11410 alc268_acer_automute(codec, 0);
11411 return change;
11412}
d273809e 11413
8ef355da
KY
11414static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11415 /* output mixer control */
11416 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11417 {
11418 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11419 .name = "Master Playback Switch",
11420 .info = snd_hda_mixer_amp_switch_info,
11421 .get = snd_hda_mixer_amp_switch_get,
11422 .put = alc268_acer_master_sw_put,
11423 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11424 },
11425 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11426 { }
11427};
11428
d273809e
TI
11429static struct snd_kcontrol_new alc268_acer_mixer[] = {
11430 /* output mixer control */
11431 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11432 {
11433 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11434 .name = "Master Playback Switch",
11435 .info = snd_hda_mixer_amp_switch_info,
11436 .get = snd_hda_mixer_amp_switch_get,
11437 .put = alc268_acer_master_sw_put,
11438 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11439 },
33bf17ab
TI
11440 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11441 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11442 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
d273809e
TI
11443 { }
11444};
11445
c238b4f4
TI
11446static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11447 /* output mixer control */
11448 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11449 {
11450 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11451 .name = "Master Playback Switch",
11452 .info = snd_hda_mixer_amp_switch_info,
11453 .get = snd_hda_mixer_amp_switch_get,
11454 .put = alc268_acer_master_sw_put,
11455 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11456 },
11457 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11458 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11459 { }
11460};
11461
8ef355da
KY
11462static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11463 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11465 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11466 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11467 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11468 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11469 { }
11470};
11471
d273809e 11472static struct hda_verb alc268_acer_verbs[] = {
0ccb541c
TI
11473 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11474 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
d273809e
TI
11475 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11476 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
0ccb541c
TI
11477 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11478 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
d273809e
TI
11479 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11480 { }
11481};
11482
11483/* unsolicited event for HP jack sensing */
42171c17
TI
11484#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11485#define alc268_toshiba_init_hook alc262_hippo_init_hook
d273809e
TI
11486
11487static void alc268_acer_unsol_event(struct hda_codec *codec,
11488 unsigned int res)
11489{
889c4395 11490 if ((res >> 26) != ALC880_HP_EVENT)
d273809e
TI
11491 return;
11492 alc268_acer_automute(codec, 1);
11493}
11494
889c4395
TI
11495static void alc268_acer_init_hook(struct hda_codec *codec)
11496{
11497 alc268_acer_automute(codec, 1);
11498}
11499
8ef355da
KY
11500/* toggle speaker-output according to the hp-jack state */
11501static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11502{
11503 unsigned int present;
11504 unsigned char bits;
11505
11506 present = snd_hda_codec_read(codec, 0x15, 0,
11507 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11508 bits = present ? AMP_IN_MUTE(0) : 0;
11509 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11510 AMP_IN_MUTE(0), bits);
11511 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11512 AMP_IN_MUTE(0), bits);
11513}
11514
11515
11516static void alc268_acer_mic_automute(struct hda_codec *codec)
11517{
11518 unsigned int present;
11519
11520 present = snd_hda_codec_read(codec, 0x18, 0,
11521 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11522 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11523 present ? 0x0 : 0x6);
11524}
11525
11526static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11527 unsigned int res)
11528{
11529 if ((res >> 26) == ALC880_HP_EVENT)
11530 alc268_aspire_one_speaker_automute(codec);
11531 if ((res >> 26) == ALC880_MIC_EVENT)
11532 alc268_acer_mic_automute(codec);
11533}
11534
11535static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11536{
11537 alc268_aspire_one_speaker_automute(codec);
11538 alc268_acer_mic_automute(codec);
11539}
11540
3866f0b0
TI
11541static struct snd_kcontrol_new alc268_dell_mixer[] = {
11542 /* output mixer control */
11543 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11544 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11545 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11546 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11547 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11548 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11549 { }
11550};
11551
11552static struct hda_verb alc268_dell_verbs[] = {
11553 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11554 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11555 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11556 { }
11557};
11558
11559/* mute/unmute internal speaker according to the hp jack and mute state */
a9fd4f3f 11560static void alc268_dell_init_hook(struct hda_codec *codec)
3866f0b0 11561{
a9fd4f3f 11562 struct alc_spec *spec = codec->spec;
3866f0b0 11563
a9fd4f3f
TI
11564 spec->autocfg.hp_pins[0] = 0x15;
11565 spec->autocfg.speaker_pins[0] = 0x14;
11566 alc_automute_pin(codec);
3866f0b0
TI
11567}
11568
eb5a6621
HRK
11569static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11570 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11571 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11572 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11573 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11574 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11575 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11576 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11577 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11578 { }
11579};
11580
11581static struct hda_verb alc267_quanta_il1_verbs[] = {
11582 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11583 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11584 { }
11585};
11586
eb5a6621
HRK
11587static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11588{
11589 unsigned int present;
11590
11591 present = snd_hda_codec_read(codec, 0x18, 0,
11592 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11593 snd_hda_codec_write(codec, 0x23, 0,
11594 AC_VERB_SET_CONNECT_SEL,
11595 present ? 0x00 : 0x01);
11596}
11597
a9fd4f3f 11598static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
eb5a6621 11599{
a9fd4f3f
TI
11600 struct alc_spec *spec = codec->spec;
11601
11602 spec->autocfg.hp_pins[0] = 0x15;
11603 spec->autocfg.speaker_pins[0] = 0x14;
11604 alc_automute_pin(codec);
eb5a6621
HRK
11605 alc267_quanta_il1_mic_automute(codec);
11606}
11607
11608static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11609 unsigned int res)
11610{
11611 switch (res >> 26) {
eb5a6621
HRK
11612 case ALC880_MIC_EVENT:
11613 alc267_quanta_il1_mic_automute(codec);
11614 break;
a9fd4f3f
TI
11615 default:
11616 alc_sku_unsol_event(codec, res);
11617 break;
eb5a6621
HRK
11618 }
11619}
11620
a361d84b
KY
11621/*
11622 * generic initialization of ADC, input mixers and output mixers
11623 */
11624static struct hda_verb alc268_base_init_verbs[] = {
11625 /* Unmute DAC0-1 and set vol = 0 */
11626 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
a361d84b 11627 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
a361d84b
KY
11628
11629 /*
11630 * Set up output mixers (0x0c - 0x0e)
11631 */
11632 /* set vol=0 to output mixers */
11633 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
a361d84b
KY
11634 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11635
11636 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11637 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11638
11639 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11640 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11641 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11642 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11643 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11644 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11645 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11646 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11647
11648 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11649 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11650 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11651 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
a361d84b 11652 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
aef9d318
TI
11653
11654 /* set PCBEEP vol = 0, mute connections */
11655 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11656 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11657 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
a361d84b 11658
a9b3aa8a 11659 /* Unmute Selector 23h,24h and set the default input to mic-in */
ea1fb29a 11660
a9b3aa8a
JZ
11661 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11662 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11663 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11664 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
a361d84b 11665
a361d84b
KY
11666 { }
11667};
11668
11669/*
11670 * generic initialization of ADC, input mixers and output mixers
11671 */
11672static struct hda_verb alc268_volume_init_verbs[] = {
11673 /* set output DAC */
4cfb91c6
TI
11674 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11675 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
a361d84b
KY
11676
11677 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11678 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11679 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11680 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11681 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11682
a361d84b 11683 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
a361d84b
KY
11684 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11685 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11686
11687 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
a361d84b 11688 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
a361d84b 11689
aef9d318
TI
11690 /* set PCBEEP vol = 0, mute connections */
11691 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11692 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11693 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
a361d84b
KY
11694
11695 { }
11696};
11697
a361d84b
KY
11698static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11699 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11700 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11701 {
11702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11703 /* The multiple "Capture Source" controls confuse alsamixer
11704 * So call somewhat different..
a361d84b
KY
11705 */
11706 /* .name = "Capture Source", */
11707 .name = "Input Source",
11708 .count = 1,
54cbc9ab
TI
11709 .info = alc_mux_enum_info,
11710 .get = alc_mux_enum_get,
11711 .put = alc_mux_enum_put,
a361d84b
KY
11712 },
11713 { } /* end */
11714};
11715
11716static struct snd_kcontrol_new alc268_capture_mixer[] = {
11717 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11718 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11719 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11720 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11721 {
11722 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11723 /* The multiple "Capture Source" controls confuse alsamixer
11724 * So call somewhat different..
a361d84b
KY
11725 */
11726 /* .name = "Capture Source", */
11727 .name = "Input Source",
11728 .count = 2,
54cbc9ab
TI
11729 .info = alc_mux_enum_info,
11730 .get = alc_mux_enum_get,
11731 .put = alc_mux_enum_put,
a361d84b
KY
11732 },
11733 { } /* end */
11734};
11735
11736static struct hda_input_mux alc268_capture_source = {
11737 .num_items = 4,
11738 .items = {
11739 { "Mic", 0x0 },
11740 { "Front Mic", 0x1 },
11741 { "Line", 0x2 },
11742 { "CD", 0x3 },
11743 },
11744};
11745
0ccb541c 11746static struct hda_input_mux alc268_acer_capture_source = {
c238b4f4
TI
11747 .num_items = 3,
11748 .items = {
11749 { "Mic", 0x0 },
11750 { "Internal Mic", 0x1 },
11751 { "Line", 0x2 },
11752 },
11753};
11754
11755static struct hda_input_mux alc268_acer_dmic_capture_source = {
0ccb541c
TI
11756 .num_items = 3,
11757 .items = {
11758 { "Mic", 0x0 },
11759 { "Internal Mic", 0x6 },
11760 { "Line", 0x2 },
11761 },
11762};
11763
86c53bd2
JW
11764#ifdef CONFIG_SND_DEBUG
11765static struct snd_kcontrol_new alc268_test_mixer[] = {
86c53bd2
JW
11766 /* Volume widgets */
11767 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11768 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11769 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11770 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11771 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11772 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11773 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11774 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11775 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11776 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11777 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11778 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11779 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
f0747ee6
TI
11780 /* The below appears problematic on some hardwares */
11781 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
86c53bd2
JW
11782 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11783 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11784 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11785 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11786
11787 /* Modes for retasking pin widgets */
11788 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11789 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11790 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11791 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11792
11793 /* Controls for GPIO pins, assuming they are configured as outputs */
11794 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11795 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11796 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11797 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11798
11799 /* Switches to allow the digital SPDIF output pin to be enabled.
11800 * The ALC268 does not have an SPDIF input.
11801 */
11802 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11803
11804 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11805 * this output to turn on an external amplifier.
11806 */
11807 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11808 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11809
11810 { } /* end */
11811};
11812#endif
11813
a361d84b
KY
11814/* create input playback/capture controls for the given pin */
11815static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11816 const char *ctlname, int idx)
11817{
11818 char name[32];
3f3b7c1a 11819 hda_nid_t dac;
a361d84b
KY
11820 int err;
11821
11822 sprintf(name, "%s Playback Volume", ctlname);
3f3b7c1a
TI
11823 switch (nid) {
11824 case 0x14:
11825 case 0x16:
11826 dac = 0x02;
11827 break;
11828 case 0x15:
11829 dac = 0x03;
11830 break;
11831 default:
11832 return 0;
11833 }
11834 if (spec->multiout.dac_nids[0] != dac &&
11835 spec->multiout.dac_nids[1] != dac) {
a361d84b 11836 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3f3b7c1a 11837 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
a361d84b
KY
11838 HDA_OUTPUT));
11839 if (err < 0)
11840 return err;
3f3b7c1a
TI
11841 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
11842 }
11843
a361d84b 11844 sprintf(name, "%s Playback Switch", ctlname);
3f3b7c1a
TI
11845 if (nid != 0x16)
11846 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
a361d84b 11847 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
3f3b7c1a
TI
11848 else /* mono */
11849 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11850 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
a361d84b
KY
11851 if (err < 0)
11852 return err;
11853 return 0;
11854}
11855
11856/* add playback controls from the parsed DAC table */
11857static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11858 const struct auto_pin_cfg *cfg)
11859{
11860 hda_nid_t nid;
11861 int err;
11862
a361d84b 11863 spec->multiout.dac_nids = spec->private_dac_nids;
a361d84b
KY
11864
11865 nid = cfg->line_out_pins[0];
3f3b7c1a
TI
11866 if (nid) {
11867 const char *name;
11868 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11869 name = "Speaker";
11870 else
11871 name = "Front";
11872 err = alc268_new_analog_output(spec, nid, name, 0);
11873 if (err < 0)
11874 return err;
11875 }
a361d84b
KY
11876
11877 nid = cfg->speaker_pins[0];
11878 if (nid == 0x1d) {
11879 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11880 "Speaker Playback Volume",
11881 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11882 if (err < 0)
11883 return err;
3f3b7c1a
TI
11884 } else {
11885 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
11886 if (err < 0)
11887 return err;
a361d84b
KY
11888 }
11889 nid = cfg->hp_pins[0];
3f3b7c1a
TI
11890 if (nid) {
11891 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
11892 if (err < 0)
11893 return err;
11894 }
a361d84b
KY
11895
11896 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11897 if (nid == 0x16) {
11898 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11899 "Mono Playback Switch",
3f3b7c1a 11900 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
a361d84b
KY
11901 if (err < 0)
11902 return err;
11903 }
ea1fb29a 11904 return 0;
a361d84b
KY
11905}
11906
11907/* create playback/capture controls for input pins */
11908static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11909 const struct auto_pin_cfg *cfg)
11910{
61b9b9b1 11911 struct hda_input_mux *imux = &spec->private_imux[0];
a361d84b
KY
11912 int i, idx1;
11913
11914 for (i = 0; i < AUTO_PIN_LAST; i++) {
11915 switch(cfg->input_pins[i]) {
11916 case 0x18:
11917 idx1 = 0; /* Mic 1 */
11918 break;
11919 case 0x19:
11920 idx1 = 1; /* Mic 2 */
11921 break;
11922 case 0x1a:
11923 idx1 = 2; /* Line In */
11924 break;
ea1fb29a 11925 case 0x1c:
a361d84b
KY
11926 idx1 = 3; /* CD */
11927 break;
7194cae6
TI
11928 case 0x12:
11929 case 0x13:
11930 idx1 = 6; /* digital mics */
11931 break;
a361d84b
KY
11932 default:
11933 continue;
11934 }
11935 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11936 imux->items[imux->num_items].index = idx1;
ea1fb29a 11937 imux->num_items++;
a361d84b
KY
11938 }
11939 return 0;
11940}
11941
11942static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11943{
11944 struct alc_spec *spec = codec->spec;
11945 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11946 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11947 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11948 unsigned int dac_vol1, dac_vol2;
11949
11950 if (speaker_nid) {
11951 snd_hda_codec_write(codec, speaker_nid, 0,
11952 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11953 snd_hda_codec_write(codec, 0x0f, 0,
11954 AC_VERB_SET_AMP_GAIN_MUTE,
11955 AMP_IN_UNMUTE(1));
11956 snd_hda_codec_write(codec, 0x10, 0,
11957 AC_VERB_SET_AMP_GAIN_MUTE,
11958 AMP_IN_UNMUTE(1));
11959 } else {
11960 snd_hda_codec_write(codec, 0x0f, 0,
11961 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11962 snd_hda_codec_write(codec, 0x10, 0,
11963 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11964 }
11965
11966 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
ea1fb29a 11967 if (line_nid == 0x14)
a361d84b
KY
11968 dac_vol2 = AMP_OUT_ZERO;
11969 else if (line_nid == 0x15)
11970 dac_vol1 = AMP_OUT_ZERO;
ea1fb29a 11971 if (hp_nid == 0x14)
a361d84b
KY
11972 dac_vol2 = AMP_OUT_ZERO;
11973 else if (hp_nid == 0x15)
11974 dac_vol1 = AMP_OUT_ZERO;
11975 if (line_nid != 0x16 || hp_nid != 0x16 ||
11976 spec->autocfg.line_out_pins[1] != 0x16 ||
11977 spec->autocfg.line_out_pins[2] != 0x16)
11978 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11979
11980 snd_hda_codec_write(codec, 0x02, 0,
11981 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11982 snd_hda_codec_write(codec, 0x03, 0,
11983 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11984}
11985
def319f9 11986/* pcm configuration: identical with ALC880 */
a361d84b
KY
11987#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11988#define alc268_pcm_analog_capture alc880_pcm_analog_capture
6330079f 11989#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
a361d84b
KY
11990#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11991
11992/*
11993 * BIOS auto configuration
11994 */
11995static int alc268_parse_auto_config(struct hda_codec *codec)
11996{
11997 struct alc_spec *spec = codec->spec;
11998 int err;
11999 static hda_nid_t alc268_ignore[] = { 0 };
12000
12001 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12002 alc268_ignore);
12003 if (err < 0)
12004 return err;
7e0e44d4
TI
12005 if (!spec->autocfg.line_outs) {
12006 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12007 spec->multiout.max_channels = 2;
12008 spec->no_analog = 1;
12009 goto dig_only;
12010 }
a361d84b 12011 return 0; /* can't find valid BIOS pin config */
7e0e44d4 12012 }
a361d84b
KY
12013 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12014 if (err < 0)
12015 return err;
12016 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12017 if (err < 0)
12018 return err;
12019
12020 spec->multiout.max_channels = 2;
12021
7e0e44d4 12022 dig_only:
a361d84b 12023 /* digital only support output */
7e0e44d4 12024 if (spec->autocfg.dig_outs) {
a361d84b 12025 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
7e0e44d4
TI
12026 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12027 }
603c4019 12028 if (spec->kctls.list)
d88897ea 12029 add_mixer(spec, spec->kctls.list);
a361d84b 12030
892981ff 12031 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
d88897ea 12032 add_mixer(spec, alc268_beep_mixer);
aef9d318 12033
d88897ea 12034 add_verb(spec, alc268_volume_init_verbs);
a361d84b 12035 spec->num_mux_defs = 1;
61b9b9b1 12036 spec->input_mux = &spec->private_imux[0];
a361d84b 12037
776e184e
TI
12038 err = alc_auto_add_mic_boost(codec);
12039 if (err < 0)
12040 return err;
12041
1d955ebd
TI
12042 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12043
a361d84b
KY
12044 return 1;
12045}
12046
12047#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12048#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12049#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12050
12051/* init callback for auto-configuration model -- overriding the default init */
12052static void alc268_auto_init(struct hda_codec *codec)
12053{
f6c7e546 12054 struct alc_spec *spec = codec->spec;
a361d84b
KY
12055 alc268_auto_init_multi_out(codec);
12056 alc268_auto_init_hp_out(codec);
12057 alc268_auto_init_mono_speaker_out(codec);
12058 alc268_auto_init_analog_input(codec);
f6c7e546 12059 if (spec->unsol_event)
7fb0d78f 12060 alc_inithook(codec);
a361d84b
KY
12061}
12062
12063/*
12064 * configuration and preset
12065 */
12066static const char *alc268_models[ALC268_MODEL_LAST] = {
eb5a6621 12067 [ALC267_QUANTA_IL1] = "quanta-il1",
a361d84b 12068 [ALC268_3ST] = "3stack",
983f8ae4 12069 [ALC268_TOSHIBA] = "toshiba",
d273809e 12070 [ALC268_ACER] = "acer",
c238b4f4 12071 [ALC268_ACER_DMIC] = "acer-dmic",
8ef355da 12072 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
3866f0b0 12073 [ALC268_DELL] = "dell",
f12462c5 12074 [ALC268_ZEPTO] = "zepto",
86c53bd2
JW
12075#ifdef CONFIG_SND_DEBUG
12076 [ALC268_TEST] = "test",
12077#endif
a361d84b
KY
12078 [ALC268_AUTO] = "auto",
12079};
12080
12081static struct snd_pci_quirk alc268_cfg_tbl[] = {
a0b8f7d8 12082 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
ac3e3741 12083 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
dafc8357 12084 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
ac3e3741 12085 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
29a52c24 12086 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
8ef355da
KY
12087 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12088 ALC268_ACER_ASPIRE_ONE),
3866f0b0 12089 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
57d13927 12090 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
8871e5b9
TI
12091 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12092 ALC268_TOSHIBA),
a361d84b 12093 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8871e5b9
TI
12094 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12095 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12096 ALC268_TOSHIBA),
378bd6a5 12097 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
b875bf3a 12098 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
eb5a6621 12099 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
8871e5b9 12100 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
a361d84b
KY
12101 {}
12102};
12103
12104static struct alc_config_preset alc268_presets[] = {
eb5a6621 12105 [ALC267_QUANTA_IL1] = {
22971e3a 12106 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
eb5a6621
HRK
12107 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12108 alc267_quanta_il1_verbs },
12109 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12110 .dac_nids = alc268_dac_nids,
12111 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12112 .adc_nids = alc268_adc_nids_alt,
12113 .hp_nid = 0x03,
12114 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12115 .channel_mode = alc268_modes,
12116 .input_mux = &alc268_capture_source,
12117 .unsol_event = alc267_quanta_il1_unsol_event,
a9fd4f3f 12118 .init_hook = alc267_quanta_il1_init_hook,
eb5a6621 12119 },
a361d84b 12120 [ALC268_3ST] = {
aef9d318
TI
12121 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12122 alc268_beep_mixer },
a361d84b
KY
12123 .init_verbs = { alc268_base_init_verbs },
12124 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12125 .dac_nids = alc268_dac_nids,
12126 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12127 .adc_nids = alc268_adc_nids_alt,
e1406348 12128 .capsrc_nids = alc268_capsrc_nids,
a361d84b
KY
12129 .hp_nid = 0x03,
12130 .dig_out_nid = ALC268_DIGOUT_NID,
12131 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12132 .channel_mode = alc268_modes,
12133 .input_mux = &alc268_capture_source,
12134 },
d1a991a6 12135 [ALC268_TOSHIBA] = {
42171c17 12136 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
aef9d318 12137 alc268_beep_mixer },
d273809e
TI
12138 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12139 alc268_toshiba_verbs },
d1a991a6
KY
12140 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12141 .dac_nids = alc268_dac_nids,
12142 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12143 .adc_nids = alc268_adc_nids_alt,
e1406348 12144 .capsrc_nids = alc268_capsrc_nids,
d1a991a6
KY
12145 .hp_nid = 0x03,
12146 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12147 .channel_mode = alc268_modes,
12148 .input_mux = &alc268_capture_source,
d273809e 12149 .unsol_event = alc268_toshiba_unsol_event,
42171c17 12150 .init_hook = alc268_toshiba_init_hook,
d273809e
TI
12151 },
12152 [ALC268_ACER] = {
aef9d318
TI
12153 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12154 alc268_beep_mixer },
d273809e
TI
12155 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12156 alc268_acer_verbs },
12157 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12158 .dac_nids = alc268_dac_nids,
12159 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12160 .adc_nids = alc268_adc_nids_alt,
e1406348 12161 .capsrc_nids = alc268_capsrc_nids,
d273809e
TI
12162 .hp_nid = 0x02,
12163 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12164 .channel_mode = alc268_modes,
0ccb541c 12165 .input_mux = &alc268_acer_capture_source,
d273809e 12166 .unsol_event = alc268_acer_unsol_event,
889c4395 12167 .init_hook = alc268_acer_init_hook,
d1a991a6 12168 },
c238b4f4
TI
12169 [ALC268_ACER_DMIC] = {
12170 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12171 alc268_beep_mixer },
12172 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12173 alc268_acer_verbs },
12174 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12175 .dac_nids = alc268_dac_nids,
12176 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12177 .adc_nids = alc268_adc_nids_alt,
12178 .capsrc_nids = alc268_capsrc_nids,
12179 .hp_nid = 0x02,
12180 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12181 .channel_mode = alc268_modes,
12182 .input_mux = &alc268_acer_dmic_capture_source,
12183 .unsol_event = alc268_acer_unsol_event,
12184 .init_hook = alc268_acer_init_hook,
12185 },
8ef355da
KY
12186 [ALC268_ACER_ASPIRE_ONE] = {
12187 .mixers = { alc268_acer_aspire_one_mixer,
22971e3a
TI
12188 alc268_beep_mixer,
12189 alc268_capture_alt_mixer },
8ef355da
KY
12190 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12191 alc268_acer_aspire_one_verbs },
12192 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12193 .dac_nids = alc268_dac_nids,
12194 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12195 .adc_nids = alc268_adc_nids_alt,
12196 .capsrc_nids = alc268_capsrc_nids,
12197 .hp_nid = 0x03,
12198 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12199 .channel_mode = alc268_modes,
12200 .input_mux = &alc268_acer_lc_capture_source,
12201 .unsol_event = alc268_acer_lc_unsol_event,
12202 .init_hook = alc268_acer_lc_init_hook,
12203 },
3866f0b0 12204 [ALC268_DELL] = {
aef9d318 12205 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
3866f0b0
TI
12206 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12207 alc268_dell_verbs },
12208 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12209 .dac_nids = alc268_dac_nids,
12210 .hp_nid = 0x02,
12211 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12212 .channel_mode = alc268_modes,
a9fd4f3f 12213 .unsol_event = alc_sku_unsol_event,
3866f0b0
TI
12214 .init_hook = alc268_dell_init_hook,
12215 .input_mux = &alc268_capture_source,
12216 },
f12462c5 12217 [ALC268_ZEPTO] = {
aef9d318
TI
12218 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12219 alc268_beep_mixer },
f12462c5
MT
12220 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12221 alc268_toshiba_verbs },
12222 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12223 .dac_nids = alc268_dac_nids,
12224 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12225 .adc_nids = alc268_adc_nids_alt,
e1406348 12226 .capsrc_nids = alc268_capsrc_nids,
f12462c5
MT
12227 .hp_nid = 0x03,
12228 .dig_out_nid = ALC268_DIGOUT_NID,
12229 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12230 .channel_mode = alc268_modes,
12231 .input_mux = &alc268_capture_source,
12232 .unsol_event = alc268_toshiba_unsol_event,
42171c17 12233 .init_hook = alc268_toshiba_init_hook
f12462c5 12234 },
86c53bd2
JW
12235#ifdef CONFIG_SND_DEBUG
12236 [ALC268_TEST] = {
12237 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12238 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12239 alc268_volume_init_verbs },
12240 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12241 .dac_nids = alc268_dac_nids,
12242 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12243 .adc_nids = alc268_adc_nids_alt,
e1406348 12244 .capsrc_nids = alc268_capsrc_nids,
86c53bd2
JW
12245 .hp_nid = 0x03,
12246 .dig_out_nid = ALC268_DIGOUT_NID,
12247 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12248 .channel_mode = alc268_modes,
12249 .input_mux = &alc268_capture_source,
12250 },
12251#endif
a361d84b
KY
12252};
12253
12254static int patch_alc268(struct hda_codec *codec)
12255{
12256 struct alc_spec *spec;
12257 int board_config;
22971e3a 12258 int i, has_beep, err;
a361d84b
KY
12259
12260 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12261 if (spec == NULL)
12262 return -ENOMEM;
12263
12264 codec->spec = spec;
12265
12266 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12267 alc268_models,
12268 alc268_cfg_tbl);
12269
12270 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
6c627f39
TI
12271 printk(KERN_INFO "hda_codec: Unknown model for %s, "
12272 "trying auto-probe from BIOS...\n", codec->chip_name);
a361d84b
KY
12273 board_config = ALC268_AUTO;
12274 }
12275
12276 if (board_config == ALC268_AUTO) {
12277 /* automatic parse from the BIOS config */
12278 err = alc268_parse_auto_config(codec);
12279 if (err < 0) {
12280 alc_free(codec);
12281 return err;
12282 } else if (!err) {
12283 printk(KERN_INFO
12284 "hda_codec: Cannot set up configuration "
12285 "from BIOS. Using base mode...\n");
12286 board_config = ALC268_3ST;
12287 }
12288 }
12289
12290 if (board_config != ALC268_AUTO)
12291 setup_preset(spec, &alc268_presets[board_config]);
12292
a361d84b
KY
12293 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12294 spec->stream_analog_capture = &alc268_pcm_analog_capture;
6330079f 12295 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
a361d84b 12296
a361d84b
KY
12297 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12298
22971e3a
TI
12299 has_beep = 0;
12300 for (i = 0; i < spec->num_mixers; i++) {
12301 if (spec->mixers[i] == alc268_beep_mixer) {
12302 has_beep = 1;
12303 break;
12304 }
12305 }
12306
12307 if (has_beep) {
12308 err = snd_hda_attach_beep_device(codec, 0x1);
12309 if (err < 0) {
12310 alc_free(codec);
12311 return err;
12312 }
12313 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12314 /* override the amp caps for beep generator */
12315 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
aef9d318
TI
12316 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12317 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12318 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12319 (0 << AC_AMPCAP_MUTE_SHIFT));
22971e3a 12320 }
aef9d318 12321
7e0e44d4 12322 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
3866f0b0
TI
12323 /* check whether NID 0x07 is valid */
12324 unsigned int wcap = get_wcaps(codec, 0x07);
85860c06 12325 int i;
3866f0b0
TI
12326
12327 /* get type */
12328 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
67ebcb03 12329 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
3866f0b0
TI
12330 spec->adc_nids = alc268_adc_nids_alt;
12331 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
d88897ea 12332 add_mixer(spec, alc268_capture_alt_mixer);
3866f0b0
TI
12333 } else {
12334 spec->adc_nids = alc268_adc_nids;
12335 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
d88897ea 12336 add_mixer(spec, alc268_capture_mixer);
a361d84b 12337 }
e1406348 12338 spec->capsrc_nids = alc268_capsrc_nids;
85860c06
TI
12339 /* set default input source */
12340 for (i = 0; i < spec->num_adc_nids; i++)
12341 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12342 0, AC_VERB_SET_CONNECT_SEL,
12343 spec->input_mux->items[0].index);
a361d84b 12344 }
2134ea4f
TI
12345
12346 spec->vmaster_nid = 0x02;
12347
a361d84b
KY
12348 codec->patch_ops = alc_patch_ops;
12349 if (board_config == ALC268_AUTO)
12350 spec->init_hook = alc268_auto_init;
ea1fb29a 12351
daead538
TI
12352 codec->proc_widget_hook = print_realtek_coef;
12353
a361d84b
KY
12354 return 0;
12355}
12356
f6a92248
KY
12357/*
12358 * ALC269 channel source setting (2 channel)
12359 */
12360#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12361
12362#define alc269_dac_nids alc260_dac_nids
12363
12364static hda_nid_t alc269_adc_nids[1] = {
12365 /* ADC1 */
f53281e6
KY
12366 0x08,
12367};
12368
e01bf509
TI
12369static hda_nid_t alc269_capsrc_nids[1] = {
12370 0x23,
12371};
12372
12373/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12374 * not a mux!
12375 */
12376
f53281e6
KY
12377static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12378 .num_items = 2,
12379 .items = {
12380 { "i-Mic", 0x5 },
12381 { "e-Mic", 0x0 },
12382 },
12383};
12384
12385static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12386 .num_items = 2,
12387 .items = {
12388 { "i-Mic", 0x1 },
12389 { "e-Mic", 0x0 },
12390 },
f6a92248
KY
12391};
12392
12393#define alc269_modes alc260_modes
12394#define alc269_capture_source alc880_lg_lw_capture_source
12395
12396static struct snd_kcontrol_new alc269_base_mixer[] = {
12397 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12398 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12399 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12400 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12401 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12402 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12403 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12404 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12405 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12406 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12407 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12408 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12409 { } /* end */
12410};
12411
60db6b53
KY
12412static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12413 /* output mixer control */
12414 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12415 {
12416 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12417 .name = "Master Playback Switch",
12418 .info = snd_hda_mixer_amp_switch_info,
12419 .get = snd_hda_mixer_amp_switch_get,
12420 .put = alc268_acer_master_sw_put,
12421 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12422 },
12423 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12424 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12425 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12426 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12427 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12428 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
60db6b53
KY
12429 { }
12430};
12431
64154835
TV
12432static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12433 /* output mixer control */
12434 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12435 {
12436 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12437 .name = "Master Playback Switch",
12438 .info = snd_hda_mixer_amp_switch_info,
12439 .get = snd_hda_mixer_amp_switch_get,
12440 .put = alc268_acer_master_sw_put,
12441 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12442 },
12443 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12444 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12445 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12446 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12447 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12448 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12449 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12450 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12451 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
64154835
TV
12452 { }
12453};
12454
f53281e6 12455static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
aa202455 12456 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
508f7110 12457 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
aa202455 12458 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
508f7110 12459 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
f53281e6
KY
12460 { } /* end */
12461};
12462
f53281e6
KY
12463/* capture mixer elements */
12464static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12465 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12466 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
26f5df26
TI
12467 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12468 { } /* end */
12469};
12470
12471/* FSC amilo */
aa202455 12472#define alc269_fujitsu_mixer alc269_eeepc_mixer
f53281e6 12473
60db6b53
KY
12474static struct hda_verb alc269_quanta_fl1_verbs[] = {
12475 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12476 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12477 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12478 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12479 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12480 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12481 { }
12482};
f6a92248 12483
64154835
TV
12484static struct hda_verb alc269_lifebook_verbs[] = {
12485 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12486 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12487 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12488 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12489 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12490 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12491 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12492 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12493 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12494 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12495 { }
12496};
12497
60db6b53
KY
12498/* toggle speaker-output according to the hp-jack state */
12499static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12500{
12501 unsigned int present;
12502 unsigned char bits;
f6a92248 12503
60db6b53
KY
12504 present = snd_hda_codec_read(codec, 0x15, 0,
12505 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12506 bits = present ? AMP_IN_MUTE(0) : 0;
12507 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12508 AMP_IN_MUTE(0), bits);
12509 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12510 AMP_IN_MUTE(0), bits);
f6a92248 12511
60db6b53
KY
12512 snd_hda_codec_write(codec, 0x20, 0,
12513 AC_VERB_SET_COEF_INDEX, 0x0c);
12514 snd_hda_codec_write(codec, 0x20, 0,
12515 AC_VERB_SET_PROC_COEF, 0x680);
f6a92248 12516
60db6b53
KY
12517 snd_hda_codec_write(codec, 0x20, 0,
12518 AC_VERB_SET_COEF_INDEX, 0x0c);
12519 snd_hda_codec_write(codec, 0x20, 0,
12520 AC_VERB_SET_PROC_COEF, 0x480);
12521}
f6a92248 12522
64154835
TV
12523/* toggle speaker-output according to the hp-jacks state */
12524static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12525{
12526 unsigned int present;
12527 unsigned char bits;
12528
12529 /* Check laptop headphone socket */
12530 present = snd_hda_codec_read(codec, 0x15, 0,
12531 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12532
12533 /* Check port replicator headphone socket */
12534 present |= snd_hda_codec_read(codec, 0x1a, 0,
12535 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12536
12537 bits = present ? AMP_IN_MUTE(0) : 0;
12538 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12539 AMP_IN_MUTE(0), bits);
12540 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12541 AMP_IN_MUTE(0), bits);
12542
12543 snd_hda_codec_write(codec, 0x20, 0,
12544 AC_VERB_SET_COEF_INDEX, 0x0c);
12545 snd_hda_codec_write(codec, 0x20, 0,
12546 AC_VERB_SET_PROC_COEF, 0x680);
12547
12548 snd_hda_codec_write(codec, 0x20, 0,
12549 AC_VERB_SET_COEF_INDEX, 0x0c);
12550 snd_hda_codec_write(codec, 0x20, 0,
12551 AC_VERB_SET_PROC_COEF, 0x480);
12552}
12553
60db6b53
KY
12554static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12555{
12556 unsigned int present;
f6a92248 12557
60db6b53
KY
12558 present = snd_hda_codec_read(codec, 0x18, 0,
12559 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12560 snd_hda_codec_write(codec, 0x23, 0,
12561 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12562}
f6a92248 12563
64154835
TV
12564static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12565{
12566 unsigned int present_laptop;
12567 unsigned int present_dock;
12568
12569 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12570 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12571
12572 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12573 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12574
12575 /* Laptop mic port overrides dock mic port, design decision */
12576 if (present_dock)
12577 snd_hda_codec_write(codec, 0x23, 0,
12578 AC_VERB_SET_CONNECT_SEL, 0x3);
12579 if (present_laptop)
12580 snd_hda_codec_write(codec, 0x23, 0,
12581 AC_VERB_SET_CONNECT_SEL, 0x0);
12582 if (!present_dock && !present_laptop)
12583 snd_hda_codec_write(codec, 0x23, 0,
12584 AC_VERB_SET_CONNECT_SEL, 0x1);
12585}
12586
60db6b53
KY
12587static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12588 unsigned int res)
12589{
12590 if ((res >> 26) == ALC880_HP_EVENT)
12591 alc269_quanta_fl1_speaker_automute(codec);
12592 if ((res >> 26) == ALC880_MIC_EVENT)
12593 alc269_quanta_fl1_mic_automute(codec);
12594}
f6a92248 12595
64154835
TV
12596static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12597 unsigned int res)
12598{
12599 if ((res >> 26) == ALC880_HP_EVENT)
12600 alc269_lifebook_speaker_automute(codec);
12601 if ((res >> 26) == ALC880_MIC_EVENT)
12602 alc269_lifebook_mic_autoswitch(codec);
12603}
12604
60db6b53
KY
12605static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12606{
12607 alc269_quanta_fl1_speaker_automute(codec);
12608 alc269_quanta_fl1_mic_automute(codec);
12609}
f6a92248 12610
64154835
TV
12611static void alc269_lifebook_init_hook(struct hda_codec *codec)
12612{
12613 alc269_lifebook_speaker_automute(codec);
12614 alc269_lifebook_mic_autoswitch(codec);
12615}
12616
f53281e6
KY
12617static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12618 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12619 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12620 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12621 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12622 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12623 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12624 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12625 {}
12626};
12627
12628static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12629 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12630 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12631 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12632 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12633 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12634 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12635 {}
12636};
12637
12638/* toggle speaker-output according to the hp-jack state */
12639static void alc269_speaker_automute(struct hda_codec *codec)
12640{
12641 unsigned int present;
60db6b53 12642 unsigned char bits;
f53281e6
KY
12643
12644 present = snd_hda_codec_read(codec, 0x15, 0,
60db6b53 12645 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
f53281e6
KY
12646 bits = present ? AMP_IN_MUTE(0) : 0;
12647 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
60db6b53 12648 AMP_IN_MUTE(0), bits);
f53281e6 12649 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
60db6b53 12650 AMP_IN_MUTE(0), bits);
f53281e6
KY
12651}
12652
12653static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12654{
12655 unsigned int present;
12656
60db6b53
KY
12657 present = snd_hda_codec_read(codec, 0x18, 0,
12658 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12659 snd_hda_codec_write(codec, 0x23, 0,
12660 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
f53281e6
KY
12661}
12662
12663static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12664{
12665 unsigned int present;
12666
60db6b53
KY
12667 present = snd_hda_codec_read(codec, 0x18, 0,
12668 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
f53281e6 12669 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
60db6b53 12670 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
f53281e6 12671 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
60db6b53 12672 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
f53281e6
KY
12673}
12674
12675/* unsolicited event for HP jack sensing */
12676static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
60db6b53 12677 unsigned int res)
f53281e6
KY
12678{
12679 if ((res >> 26) == ALC880_HP_EVENT)
12680 alc269_speaker_automute(codec);
12681
12682 if ((res >> 26) == ALC880_MIC_EVENT)
12683 alc269_eeepc_dmic_automute(codec);
12684}
12685
12686static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12687{
12688 alc269_speaker_automute(codec);
12689 alc269_eeepc_dmic_automute(codec);
12690}
12691
12692/* unsolicited event for HP jack sensing */
12693static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
ea1fb29a 12694 unsigned int res)
f53281e6
KY
12695{
12696 if ((res >> 26) == ALC880_HP_EVENT)
12697 alc269_speaker_automute(codec);
12698
12699 if ((res >> 26) == ALC880_MIC_EVENT)
12700 alc269_eeepc_amic_automute(codec);
12701}
12702
12703static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12704{
12705 alc269_speaker_automute(codec);
12706 alc269_eeepc_amic_automute(codec);
12707}
12708
60db6b53
KY
12709/*
12710 * generic initialization of ADC, input mixers and output mixers
12711 */
12712static struct hda_verb alc269_init_verbs[] = {
12713 /*
12714 * Unmute ADC0 and set the default input to mic-in
12715 */
12716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12717
12718 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12719 * analog-loopback mixer widget
12720 * Note: PASD motherboards uses the Line In 2 as the input for
12721 * front panel mic (mic 2)
12722 */
12723 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12725 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12726 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12727 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12728 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12729
12730 /*
12731 * Set up output mixers (0x0c - 0x0e)
12732 */
12733 /* set vol=0 to output mixers */
12734 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12735 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12736
12737 /* set up input amps for analog loopback */
12738 /* Amp Indices: DAC = 0, mixer = 1 */
12739 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12741 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12742 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12743 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12744 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12745
12746 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12747 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12748 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12749 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12750 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12751 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12752 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12753
12754 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12755 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12756 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12757 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12758 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12759 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12760 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12761
12762 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12763 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12764
12765 /* FIXME: use matrix-type input source selection */
12766 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12767 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12768 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12769 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12770 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12771 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12772
12773 /* set EAPD */
12774 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12775 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12776 { }
12777};
12778
f6a92248
KY
12779/* add playback controls from the parsed DAC table */
12780static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12781 const struct auto_pin_cfg *cfg)
12782{
12783 hda_nid_t nid;
12784 int err;
12785
12786 spec->multiout.num_dacs = 1; /* only use one dac */
12787 spec->multiout.dac_nids = spec->private_dac_nids;
12788 spec->multiout.dac_nids[0] = 2;
12789
12790 nid = cfg->line_out_pins[0];
12791 if (nid) {
12792 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12793 "Front Playback Volume",
12794 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12795 if (err < 0)
12796 return err;
12797 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12798 "Front Playback Switch",
12799 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12800 if (err < 0)
12801 return err;
12802 }
12803
12804 nid = cfg->speaker_pins[0];
12805 if (nid) {
12806 if (!cfg->line_out_pins[0]) {
12807 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12808 "Speaker Playback Volume",
12809 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12810 HDA_OUTPUT));
12811 if (err < 0)
12812 return err;
12813 }
12814 if (nid == 0x16) {
12815 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12816 "Speaker Playback Switch",
12817 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12818 HDA_OUTPUT));
12819 if (err < 0)
12820 return err;
12821 } else {
12822 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12823 "Speaker Playback Switch",
12824 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12825 HDA_OUTPUT));
12826 if (err < 0)
12827 return err;
12828 }
12829 }
12830 nid = cfg->hp_pins[0];
12831 if (nid) {
12832 /* spec->multiout.hp_nid = 2; */
12833 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12834 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12835 "Headphone Playback Volume",
12836 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12837 HDA_OUTPUT));
12838 if (err < 0)
12839 return err;
12840 }
12841 if (nid == 0x16) {
12842 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12843 "Headphone Playback Switch",
12844 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12845 HDA_OUTPUT));
12846 if (err < 0)
12847 return err;
12848 } else {
12849 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12850 "Headphone Playback Switch",
12851 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12852 HDA_OUTPUT));
12853 if (err < 0)
12854 return err;
12855 }
12856 }
12857 return 0;
12858}
12859
8c927b4a
TI
12860#define alc269_auto_create_analog_input_ctls \
12861 alc262_auto_create_analog_input_ctls
f6a92248
KY
12862
12863#ifdef CONFIG_SND_HDA_POWER_SAVE
12864#define alc269_loopbacks alc880_loopbacks
12865#endif
12866
def319f9 12867/* pcm configuration: identical with ALC880 */
f6a92248
KY
12868#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12869#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12870#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12871#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12872
f03d3115
TI
12873static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
12874 .substreams = 1,
12875 .channels_min = 2,
12876 .channels_max = 8,
12877 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12878 /* NID is set in alc_build_pcms */
12879 .ops = {
12880 .open = alc880_playback_pcm_open,
12881 .prepare = alc880_playback_pcm_prepare,
12882 .cleanup = alc880_playback_pcm_cleanup
12883 },
12884};
12885
12886static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
12887 .substreams = 1,
12888 .channels_min = 2,
12889 .channels_max = 2,
12890 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12891 /* NID is set in alc_build_pcms */
12892};
12893
f6a92248
KY
12894/*
12895 * BIOS auto configuration
12896 */
12897static int alc269_parse_auto_config(struct hda_codec *codec)
12898{
12899 struct alc_spec *spec = codec->spec;
cfb9fb55 12900 int err;
f6a92248
KY
12901 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12902
12903 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12904 alc269_ignore);
12905 if (err < 0)
12906 return err;
12907
12908 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12909 if (err < 0)
12910 return err;
12911 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12912 if (err < 0)
12913 return err;
12914
12915 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12916
0852d7a6 12917 if (spec->autocfg.dig_outs)
f6a92248
KY
12918 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12919
603c4019 12920 if (spec->kctls.list)
d88897ea 12921 add_mixer(spec, spec->kctls.list);
f6a92248 12922
d88897ea 12923 add_verb(spec, alc269_init_verbs);
f6a92248 12924 spec->num_mux_defs = 1;
61b9b9b1 12925 spec->input_mux = &spec->private_imux[0];
e01bf509
TI
12926 /* set default input source */
12927 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12928 0, AC_VERB_SET_CONNECT_SEL,
12929 spec->input_mux->items[0].index);
f6a92248
KY
12930
12931 err = alc_auto_add_mic_boost(codec);
12932 if (err < 0)
12933 return err;
12934
7e0e44d4 12935 if (!spec->cap_mixer && !spec->no_analog)
f9e336f6 12936 set_capture_mixer(spec);
f53281e6 12937
1d955ebd
TI
12938 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12939
f6a92248
KY
12940 return 1;
12941}
12942
12943#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12944#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12945#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12946
12947
12948/* init callback for auto-configuration model -- overriding the default init */
12949static void alc269_auto_init(struct hda_codec *codec)
12950{
f6c7e546 12951 struct alc_spec *spec = codec->spec;
f6a92248
KY
12952 alc269_auto_init_multi_out(codec);
12953 alc269_auto_init_hp_out(codec);
12954 alc269_auto_init_analog_input(codec);
f6c7e546 12955 if (spec->unsol_event)
7fb0d78f 12956 alc_inithook(codec);
f6a92248
KY
12957}
12958
12959/*
12960 * configuration and preset
12961 */
12962static const char *alc269_models[ALC269_MODEL_LAST] = {
60db6b53 12963 [ALC269_BASIC] = "basic",
2922c9af
TI
12964 [ALC269_QUANTA_FL1] = "quanta",
12965 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
26f5df26 12966 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
64154835
TV
12967 [ALC269_FUJITSU] = "fujitsu",
12968 [ALC269_LIFEBOOK] = "lifebook"
f6a92248
KY
12969};
12970
12971static struct snd_pci_quirk alc269_cfg_tbl[] = {
60db6b53 12972 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
f53281e6
KY
12973 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12974 ALC269_ASUS_EEEPC_P703),
622e84cd
KY
12975 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
12976 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
12977 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
12978 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
12979 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
12980 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
f53281e6
KY
12981 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12982 ALC269_ASUS_EEEPC_P901),
60db6b53
KY
12983 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12984 ALC269_ASUS_EEEPC_P901),
622e84cd 12985 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
26f5df26 12986 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
64154835 12987 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
f6a92248
KY
12988 {}
12989};
12990
12991static struct alc_config_preset alc269_presets[] = {
12992 [ALC269_BASIC] = {
f9e336f6 12993 .mixers = { alc269_base_mixer },
f6a92248
KY
12994 .init_verbs = { alc269_init_verbs },
12995 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12996 .dac_nids = alc269_dac_nids,
12997 .hp_nid = 0x03,
12998 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12999 .channel_mode = alc269_modes,
13000 .input_mux = &alc269_capture_source,
13001 },
60db6b53
KY
13002 [ALC269_QUANTA_FL1] = {
13003 .mixers = { alc269_quanta_fl1_mixer },
13004 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13005 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13006 .dac_nids = alc269_dac_nids,
13007 .hp_nid = 0x03,
13008 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13009 .channel_mode = alc269_modes,
13010 .input_mux = &alc269_capture_source,
13011 .unsol_event = alc269_quanta_fl1_unsol_event,
13012 .init_hook = alc269_quanta_fl1_init_hook,
13013 },
f53281e6 13014 [ALC269_ASUS_EEEPC_P703] = {
f9e336f6
TI
13015 .mixers = { alc269_eeepc_mixer },
13016 .cap_mixer = alc269_epc_capture_mixer,
f53281e6
KY
13017 .init_verbs = { alc269_init_verbs,
13018 alc269_eeepc_amic_init_verbs },
13019 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13020 .dac_nids = alc269_dac_nids,
13021 .hp_nid = 0x03,
13022 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13023 .channel_mode = alc269_modes,
13024 .input_mux = &alc269_eeepc_amic_capture_source,
13025 .unsol_event = alc269_eeepc_amic_unsol_event,
13026 .init_hook = alc269_eeepc_amic_inithook,
13027 },
13028 [ALC269_ASUS_EEEPC_P901] = {
f9e336f6
TI
13029 .mixers = { alc269_eeepc_mixer },
13030 .cap_mixer = alc269_epc_capture_mixer,
f53281e6
KY
13031 .init_verbs = { alc269_init_verbs,
13032 alc269_eeepc_dmic_init_verbs },
13033 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13034 .dac_nids = alc269_dac_nids,
13035 .hp_nid = 0x03,
13036 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13037 .channel_mode = alc269_modes,
13038 .input_mux = &alc269_eeepc_dmic_capture_source,
13039 .unsol_event = alc269_eeepc_dmic_unsol_event,
13040 .init_hook = alc269_eeepc_dmic_inithook,
13041 },
26f5df26 13042 [ALC269_FUJITSU] = {
45bdd1c1 13043 .mixers = { alc269_fujitsu_mixer },
26f5df26
TI
13044 .cap_mixer = alc269_epc_capture_mixer,
13045 .init_verbs = { alc269_init_verbs,
13046 alc269_eeepc_dmic_init_verbs },
13047 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13048 .dac_nids = alc269_dac_nids,
13049 .hp_nid = 0x03,
13050 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13051 .channel_mode = alc269_modes,
13052 .input_mux = &alc269_eeepc_dmic_capture_source,
13053 .unsol_event = alc269_eeepc_dmic_unsol_event,
13054 .init_hook = alc269_eeepc_dmic_inithook,
13055 },
64154835
TV
13056 [ALC269_LIFEBOOK] = {
13057 .mixers = { alc269_lifebook_mixer },
13058 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13059 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13060 .dac_nids = alc269_dac_nids,
13061 .hp_nid = 0x03,
13062 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13063 .channel_mode = alc269_modes,
13064 .input_mux = &alc269_capture_source,
13065 .unsol_event = alc269_lifebook_unsol_event,
13066 .init_hook = alc269_lifebook_init_hook,
13067 },
f6a92248
KY
13068};
13069
13070static int patch_alc269(struct hda_codec *codec)
13071{
13072 struct alc_spec *spec;
13073 int board_config;
13074 int err;
13075
13076 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13077 if (spec == NULL)
13078 return -ENOMEM;
13079
13080 codec->spec = spec;
13081
2c3bf9ab
TI
13082 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13083
f6a92248
KY
13084 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13085 alc269_models,
13086 alc269_cfg_tbl);
13087
13088 if (board_config < 0) {
6c627f39
TI
13089 printk(KERN_INFO "hda_codec: Unknown model for %s, "
13090 "trying auto-probe from BIOS...\n", codec->chip_name);
f6a92248
KY
13091 board_config = ALC269_AUTO;
13092 }
13093
13094 if (board_config == ALC269_AUTO) {
13095 /* automatic parse from the BIOS config */
13096 err = alc269_parse_auto_config(codec);
13097 if (err < 0) {
13098 alc_free(codec);
13099 return err;
13100 } else if (!err) {
13101 printk(KERN_INFO
13102 "hda_codec: Cannot set up configuration "
13103 "from BIOS. Using base mode...\n");
13104 board_config = ALC269_BASIC;
13105 }
13106 }
13107
680cd536
KK
13108 err = snd_hda_attach_beep_device(codec, 0x1);
13109 if (err < 0) {
13110 alc_free(codec);
13111 return err;
13112 }
13113
f6a92248
KY
13114 if (board_config != ALC269_AUTO)
13115 setup_preset(spec, &alc269_presets[board_config]);
13116
f03d3115
TI
13117 if (codec->subsystem_id == 0x17aa3bf8) {
13118 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13119 * fix the sample rate of analog I/O to 44.1kHz
13120 */
13121 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13122 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13123 } else {
13124 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13125 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13126 }
f6a92248
KY
13127 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13128 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13129
13130 spec->adc_nids = alc269_adc_nids;
13131 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
e01bf509 13132 spec->capsrc_nids = alc269_capsrc_nids;
f9e336f6
TI
13133 if (!spec->cap_mixer)
13134 set_capture_mixer(spec);
45bdd1c1 13135 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
f6a92248
KY
13136
13137 codec->patch_ops = alc_patch_ops;
13138 if (board_config == ALC269_AUTO)
13139 spec->init_hook = alc269_auto_init;
13140#ifdef CONFIG_SND_HDA_POWER_SAVE
13141 if (!spec->loopback.amplist)
13142 spec->loopback.amplist = alc269_loopbacks;
13143#endif
daead538 13144 codec->proc_widget_hook = print_realtek_coef;
f6a92248
KY
13145
13146 return 0;
13147}
13148
df694daa
KY
13149/*
13150 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13151 */
13152
13153/*
13154 * set the path ways for 2 channel output
13155 * need to set the codec line out and mic 1 pin widgets to inputs
13156 */
13157static struct hda_verb alc861_threestack_ch2_init[] = {
13158 /* set pin widget 1Ah (line in) for input */
13159 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
f12ab1e0
TI
13160 /* set pin widget 18h (mic1/2) for input, for mic also enable
13161 * the vref
13162 */
df694daa
KY
13163 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13164
9c7f852e
TI
13165 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13166#if 0
13167 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13168 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13169#endif
df694daa
KY
13170 { } /* end */
13171};
13172/*
13173 * 6ch mode
13174 * need to set the codec line out and mic 1 pin widgets to outputs
13175 */
13176static struct hda_verb alc861_threestack_ch6_init[] = {
13177 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13178 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13179 /* set pin widget 18h (mic1) for output (CLFE)*/
13180 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13181
13182 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
9c7f852e 13183 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
df694daa 13184
9c7f852e
TI
13185 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13186#if 0
13187 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13188 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13189#endif
df694daa
KY
13190 { } /* end */
13191};
13192
13193static struct hda_channel_mode alc861_threestack_modes[2] = {
13194 { 2, alc861_threestack_ch2_init },
13195 { 6, alc861_threestack_ch6_init },
13196};
22309c3e
TI
13197/* Set mic1 as input and unmute the mixer */
13198static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13199 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13200 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13201 { } /* end */
13202};
13203/* Set mic1 as output and mute mixer */
13204static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13205 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13206 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13207 { } /* end */
13208};
13209
13210static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13211 { 2, alc861_uniwill_m31_ch2_init },
13212 { 4, alc861_uniwill_m31_ch4_init },
13213};
df694daa 13214
7cdbff94
MD
13215/* Set mic1 and line-in as input and unmute the mixer */
13216static struct hda_verb alc861_asus_ch2_init[] = {
13217 /* set pin widget 1Ah (line in) for input */
13218 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
f12ab1e0
TI
13219 /* set pin widget 18h (mic1/2) for input, for mic also enable
13220 * the vref
13221 */
7cdbff94
MD
13222 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13223
13224 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13225#if 0
13226 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13227 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13228#endif
13229 { } /* end */
13230};
13231/* Set mic1 nad line-in as output and mute mixer */
13232static struct hda_verb alc861_asus_ch6_init[] = {
13233 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13234 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13235 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13236 /* set pin widget 18h (mic1) for output (CLFE)*/
13237 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13238 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13239 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13240 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13241
13242 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13243#if 0
13244 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13245 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13246#endif
13247 { } /* end */
13248};
13249
13250static struct hda_channel_mode alc861_asus_modes[2] = {
13251 { 2, alc861_asus_ch2_init },
13252 { 6, alc861_asus_ch6_init },
13253};
13254
df694daa
KY
13255/* patch-ALC861 */
13256
13257static struct snd_kcontrol_new alc861_base_mixer[] = {
13258 /* output mixer control */
13259 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13260 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13261 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13262 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13263 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13264
13265 /*Input mixer control */
13266 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13267 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13268 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13269 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13270 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13271 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13272 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13273 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13274 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13275 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
f12ab1e0 13276
df694daa
KY
13277 { } /* end */
13278};
13279
13280static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13281 /* output mixer control */
13282 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13283 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13284 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13285 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13286 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13287
13288 /* Input mixer control */
13289 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13290 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13291 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13292 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13293 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13294 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13295 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13296 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13297 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13298 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
f12ab1e0 13299
df694daa
KY
13300 {
13301 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13302 .name = "Channel Mode",
13303 .info = alc_ch_mode_info,
13304 .get = alc_ch_mode_get,
13305 .put = alc_ch_mode_put,
13306 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13307 },
13308 { } /* end */
a53d1aec
TD
13309};
13310
d1d985f0 13311static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
a53d1aec
TD
13312 /* output mixer control */
13313 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13314 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13315 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
ea1fb29a 13316
a53d1aec 13317 { } /* end */
f12ab1e0 13318};
a53d1aec 13319
22309c3e
TI
13320static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13321 /* output mixer control */
13322 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13323 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13324 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13325 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13326 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13327
13328 /* Input mixer control */
13329 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13330 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13331 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13332 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13333 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13334 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13336 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13337 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13338 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
f12ab1e0 13339
22309c3e
TI
13340 {
13341 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13342 .name = "Channel Mode",
13343 .info = alc_ch_mode_info,
13344 .get = alc_ch_mode_get,
13345 .put = alc_ch_mode_put,
13346 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13347 },
13348 { } /* end */
f12ab1e0 13349};
7cdbff94
MD
13350
13351static struct snd_kcontrol_new alc861_asus_mixer[] = {
13352 /* output mixer control */
13353 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13354 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13355 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13356 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13357 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13358
13359 /* Input mixer control */
13360 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13361 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13362 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13363 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13364 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13365 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13367 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13368 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
f12ab1e0
TI
13369 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13370
7cdbff94
MD
13371 {
13372 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13373 .name = "Channel Mode",
13374 .info = alc_ch_mode_info,
13375 .get = alc_ch_mode_get,
13376 .put = alc_ch_mode_put,
13377 .private_value = ARRAY_SIZE(alc861_asus_modes),
13378 },
13379 { }
56bb0cab
TI
13380};
13381
13382/* additional mixer */
d1d985f0 13383static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
56bb0cab
TI
13384 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13385 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
56bb0cab
TI
13386 { }
13387};
7cdbff94 13388
df694daa
KY
13389/*
13390 * generic initialization of ADC, input mixers and output mixers
13391 */
13392static struct hda_verb alc861_base_init_verbs[] = {
13393 /*
13394 * Unmute ADC0 and set the default input to mic-in
13395 */
13396 /* port-A for surround (rear panel) */
13397 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13398 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13399 /* port-B for mic-in (rear panel) with vref */
13400 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13401 /* port-C for line-in (rear panel) */
13402 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13403 /* port-D for Front */
13404 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13405 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13406 /* port-E for HP out (front panel) */
13407 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13408 /* route front PCM to HP */
9dece1d7 13409 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
df694daa
KY
13410 /* port-F for mic-in (front panel) with vref */
13411 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13412 /* port-G for CLFE (rear panel) */
13413 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13414 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13415 /* port-H for side (rear panel) */
13416 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13417 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13418 /* CD-in */
13419 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13420 /* route front mic to ADC1*/
13421 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13422 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
ea1fb29a 13423
df694daa
KY
13424 /* Unmute DAC0~3 & spdif out*/
13425 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13426 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13427 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13428 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13429 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
ea1fb29a 13430
df694daa
KY
13431 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13432 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13433 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13434 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13435 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
ea1fb29a 13436
df694daa
KY
13437 /* Unmute Stereo Mixer 15 */
13438 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13439 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13440 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
f12ab1e0 13441 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
df694daa
KY
13442
13443 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13444 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13445 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13446 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13447 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13448 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13449 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13450 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
f12ab1e0
TI
13451 /* hp used DAC 3 (Front) */
13452 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
df694daa
KY
13453 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13454
13455 { }
13456};
13457
13458static struct hda_verb alc861_threestack_init_verbs[] = {
13459 /*
13460 * Unmute ADC0 and set the default input to mic-in
13461 */
13462 /* port-A for surround (rear panel) */
13463 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13464 /* port-B for mic-in (rear panel) with vref */
13465 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13466 /* port-C for line-in (rear panel) */
13467 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13468 /* port-D for Front */
13469 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13470 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13471 /* port-E for HP out (front panel) */
13472 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13473 /* route front PCM to HP */
9dece1d7 13474 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
df694daa
KY
13475 /* port-F for mic-in (front panel) with vref */
13476 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13477 /* port-G for CLFE (rear panel) */
13478 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13479 /* port-H for side (rear panel) */
13480 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13481 /* CD-in */
13482 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13483 /* route front mic to ADC1*/
13484 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13485 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13486 /* Unmute DAC0~3 & spdif out*/
13487 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13488 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13489 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13490 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13491 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
ea1fb29a 13492
df694daa
KY
13493 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13494 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13495 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13496 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13497 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
ea1fb29a 13498
df694daa
KY
13499 /* Unmute Stereo Mixer 15 */
13500 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13501 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13502 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
f12ab1e0 13503 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
df694daa
KY
13504
13505 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13506 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13507 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13508 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13509 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13510 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13511 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13512 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
f12ab1e0
TI
13513 /* hp used DAC 3 (Front) */
13514 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
df694daa
KY
13515 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13516 { }
13517};
22309c3e
TI
13518
13519static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13520 /*
13521 * Unmute ADC0 and set the default input to mic-in
13522 */
13523 /* port-A for surround (rear panel) */
13524 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13525 /* port-B for mic-in (rear panel) with vref */
13526 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13527 /* port-C for line-in (rear panel) */
13528 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13529 /* port-D for Front */
13530 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13531 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13532 /* port-E for HP out (front panel) */
f12ab1e0
TI
13533 /* this has to be set to VREF80 */
13534 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
22309c3e 13535 /* route front PCM to HP */
9dece1d7 13536 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
22309c3e
TI
13537 /* port-F for mic-in (front panel) with vref */
13538 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13539 /* port-G for CLFE (rear panel) */
13540 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13541 /* port-H for side (rear panel) */
13542 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13543 /* CD-in */
13544 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13545 /* route front mic to ADC1*/
13546 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13547 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13548 /* Unmute DAC0~3 & spdif out*/
13549 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13550 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13551 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13552 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
ea1fb29a 13554
22309c3e
TI
13555 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13556 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13557 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13558 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13559 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
ea1fb29a 13560
22309c3e
TI
13561 /* Unmute Stereo Mixer 15 */
13562 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13563 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13564 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
f12ab1e0 13565 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
22309c3e
TI
13566
13567 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13568 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13569 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13570 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13571 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13572 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13573 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13574 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
f12ab1e0
TI
13575 /* hp used DAC 3 (Front) */
13576 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
22309c3e
TI
13577 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13578 { }
13579};
13580
7cdbff94
MD
13581static struct hda_verb alc861_asus_init_verbs[] = {
13582 /*
13583 * Unmute ADC0 and set the default input to mic-in
13584 */
f12ab1e0
TI
13585 /* port-A for surround (rear panel)
13586 * according to codec#0 this is the HP jack
13587 */
7cdbff94
MD
13588 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13589 /* route front PCM to HP */
13590 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13591 /* port-B for mic-in (rear panel) with vref */
13592 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13593 /* port-C for line-in (rear panel) */
13594 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13595 /* port-D for Front */
13596 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13597 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13598 /* port-E for HP out (front panel) */
f12ab1e0
TI
13599 /* this has to be set to VREF80 */
13600 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7cdbff94 13601 /* route front PCM to HP */
9dece1d7 13602 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7cdbff94
MD
13603 /* port-F for mic-in (front panel) with vref */
13604 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13605 /* port-G for CLFE (rear panel) */
13606 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13607 /* port-H for side (rear panel) */
13608 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13609 /* CD-in */
13610 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13611 /* route front mic to ADC1*/
13612 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13613 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13614 /* Unmute DAC0~3 & spdif out*/
13615 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13616 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13617 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13618 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13619 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13620 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13621 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13622 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13623 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13624 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
ea1fb29a 13625
7cdbff94
MD
13626 /* Unmute Stereo Mixer 15 */
13627 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13628 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13629 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
f12ab1e0 13630 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7cdbff94
MD
13631
13632 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13633 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13634 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13635 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13636 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13637 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13638 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13639 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
f12ab1e0
TI
13640 /* hp used DAC 3 (Front) */
13641 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7cdbff94
MD
13642 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13643 { }
13644};
13645
56bb0cab
TI
13646/* additional init verbs for ASUS laptops */
13647static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13648 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13649 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13650 { }
13651};
7cdbff94 13652
df694daa
KY
13653/*
13654 * generic initialization of ADC, input mixers and output mixers
13655 */
13656static struct hda_verb alc861_auto_init_verbs[] = {
13657 /*
13658 * Unmute ADC0 and set the default input to mic-in
13659 */
f12ab1e0 13660 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
df694daa 13661 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
ea1fb29a 13662
df694daa
KY
13663 /* Unmute DAC0~3 & spdif out*/
13664 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13665 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13666 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13667 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13668 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
ea1fb29a 13669
df694daa
KY
13670 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13671 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13672 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13673 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13674 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
ea1fb29a 13675
df694daa
KY
13676 /* Unmute Stereo Mixer 15 */
13677 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13678 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13679 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13680 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13681
1c20930a
TI
13682 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13683 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13684 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13685 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13686 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13687 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13688 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13689 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
df694daa
KY
13690
13691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13692 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1c20930a
TI
13693 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13694 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
df694daa
KY
13695 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13696 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1c20930a
TI
13697 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13698 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
df694daa 13699
f12ab1e0 13700 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
df694daa
KY
13701
13702 { }
13703};
13704
a53d1aec
TD
13705static struct hda_verb alc861_toshiba_init_verbs[] = {
13706 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
f12ab1e0 13707
a53d1aec
TD
13708 { }
13709};
13710
13711/* toggle speaker-output according to the hp-jack state */
13712static void alc861_toshiba_automute(struct hda_codec *codec)
13713{
13714 unsigned int present;
13715
13716 present = snd_hda_codec_read(codec, 0x0f, 0,
13717 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
47fd830a
TI
13718 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13719 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13720 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13721 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
a53d1aec
TD
13722}
13723
13724static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13725 unsigned int res)
13726{
a53d1aec
TD
13727 if ((res >> 26) == ALC880_HP_EVENT)
13728 alc861_toshiba_automute(codec);
13729}
13730
def319f9 13731/* pcm configuration: identical with ALC880 */
df694daa
KY
13732#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13733#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13734#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13735#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13736
13737
13738#define ALC861_DIGOUT_NID 0x07
13739
13740static struct hda_channel_mode alc861_8ch_modes[1] = {
13741 { 8, NULL }
13742};
13743
13744static hda_nid_t alc861_dac_nids[4] = {
13745 /* front, surround, clfe, side */
13746 0x03, 0x06, 0x05, 0x04
13747};
13748
9c7f852e
TI
13749static hda_nid_t alc660_dac_nids[3] = {
13750 /* front, clfe, surround */
13751 0x03, 0x05, 0x06
13752};
13753
df694daa
KY
13754static hda_nid_t alc861_adc_nids[1] = {
13755 /* ADC0-2 */
13756 0x08,
13757};
13758
13759static struct hda_input_mux alc861_capture_source = {
13760 .num_items = 5,
13761 .items = {
13762 { "Mic", 0x0 },
13763 { "Front Mic", 0x3 },
13764 { "Line", 0x1 },
13765 { "CD", 0x4 },
13766 { "Mixer", 0x5 },
13767 },
13768};
13769
1c20930a
TI
13770static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
13771{
13772 struct alc_spec *spec = codec->spec;
13773 hda_nid_t mix, srcs[5];
13774 int i, j, num;
13775
13776 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
13777 return 0;
13778 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
13779 if (num < 0)
13780 return 0;
13781 for (i = 0; i < num; i++) {
13782 unsigned int type;
13783 type = (get_wcaps(codec, srcs[i]) & AC_WCAP_TYPE)
13784 >> AC_WCAP_TYPE_SHIFT;
13785 if (type != AC_WID_AUD_OUT)
13786 continue;
13787 for (j = 0; j < spec->multiout.num_dacs; j++)
13788 if (spec->multiout.dac_nids[j] == srcs[i])
13789 break;
13790 if (j >= spec->multiout.num_dacs)
13791 return srcs[i];
13792 }
13793 return 0;
13794}
13795
df694daa 13796/* fill in the dac_nids table from the parsed pin configuration */
1c20930a 13797static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
f12ab1e0 13798 const struct auto_pin_cfg *cfg)
df694daa 13799{
1c20930a 13800 struct alc_spec *spec = codec->spec;
df694daa 13801 int i;
1c20930a 13802 hda_nid_t nid, dac;
df694daa
KY
13803
13804 spec->multiout.dac_nids = spec->private_dac_nids;
13805 for (i = 0; i < cfg->line_outs; i++) {
13806 nid = cfg->line_out_pins[i];
1c20930a
TI
13807 dac = alc861_look_for_dac(codec, nid);
13808 if (!dac)
13809 continue;
13810 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
df694daa 13811 }
df694daa
KY
13812 return 0;
13813}
13814
1c20930a
TI
13815static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
13816 hda_nid_t nid, unsigned int chs)
13817{
13818 char name[32];
13819 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
13820 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
13821 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
13822}
13823
df694daa 13824/* add playback controls from the parsed DAC table */
1c20930a 13825static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
df694daa
KY
13826 const struct auto_pin_cfg *cfg)
13827{
1c20930a 13828 struct alc_spec *spec = codec->spec;
f12ab1e0
TI
13829 static const char *chname[4] = {
13830 "Front", "Surround", NULL /*CLFE*/, "Side"
13831 };
df694daa 13832 hda_nid_t nid;
1c20930a
TI
13833 int i, err;
13834
13835 if (cfg->line_outs == 1) {
13836 const char *pfx = NULL;
13837 if (!cfg->hp_outs)
13838 pfx = "Master";
13839 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13840 pfx = "Speaker";
13841 if (pfx) {
13842 nid = spec->multiout.dac_nids[0];
13843 return alc861_create_out_sw(codec, pfx, nid, 3);
13844 }
13845 }
df694daa
KY
13846
13847 for (i = 0; i < cfg->line_outs; i++) {
13848 nid = spec->multiout.dac_nids[i];
f12ab1e0 13849 if (!nid)
df694daa 13850 continue;
1c20930a 13851 if (i == 2) {
df694daa 13852 /* Center/LFE */
1c20930a 13853 err = alc861_create_out_sw(codec, "Center", nid, 1);
f12ab1e0 13854 if (err < 0)
df694daa 13855 return err;
1c20930a 13856 err = alc861_create_out_sw(codec, "LFE", nid, 2);
f12ab1e0 13857 if (err < 0)
df694daa
KY
13858 return err;
13859 } else {
1c20930a 13860 err = alc861_create_out_sw(codec, chname[i], nid, 3);
f12ab1e0 13861 if (err < 0)
df694daa
KY
13862 return err;
13863 }
13864 }
13865 return 0;
13866}
13867
1c20930a 13868static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
df694daa 13869{
1c20930a 13870 struct alc_spec *spec = codec->spec;
df694daa
KY
13871 int err;
13872 hda_nid_t nid;
13873
f12ab1e0 13874 if (!pin)
df694daa
KY
13875 return 0;
13876
13877 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
1c20930a
TI
13878 nid = alc861_look_for_dac(codec, pin);
13879 if (nid) {
13880 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
13881 if (err < 0)
13882 return err;
13883 spec->multiout.hp_nid = nid;
13884 }
df694daa
KY
13885 }
13886 return 0;
13887}
13888
13889/* create playback/capture controls for input pins */
1c20930a 13890static int alc861_auto_create_analog_input_ctls(struct hda_codec *codec,
f12ab1e0 13891 const struct auto_pin_cfg *cfg)
df694daa 13892{
1c20930a 13893 struct alc_spec *spec = codec->spec;
61b9b9b1 13894 struct hda_input_mux *imux = &spec->private_imux[0];
df694daa
KY
13895 int i, err, idx, idx1;
13896
13897 for (i = 0; i < AUTO_PIN_LAST; i++) {
f12ab1e0 13898 switch (cfg->input_pins[i]) {
df694daa
KY
13899 case 0x0c:
13900 idx1 = 1;
f12ab1e0 13901 idx = 2; /* Line In */
df694daa
KY
13902 break;
13903 case 0x0f:
13904 idx1 = 2;
f12ab1e0 13905 idx = 2; /* Line In */
df694daa
KY
13906 break;
13907 case 0x0d:
13908 idx1 = 0;
f12ab1e0 13909 idx = 1; /* Mic In */
df694daa 13910 break;
f12ab1e0 13911 case 0x10:
df694daa 13912 idx1 = 3;
f12ab1e0 13913 idx = 1; /* Mic In */
df694daa
KY
13914 break;
13915 case 0x11:
13916 idx1 = 4;
f12ab1e0 13917 idx = 0; /* CD */
df694daa
KY
13918 break;
13919 default:
13920 continue;
13921 }
13922
4a471b7d
TI
13923 err = new_analog_input(spec, cfg->input_pins[i],
13924 auto_pin_cfg_labels[i], idx, 0x15);
df694daa
KY
13925 if (err < 0)
13926 return err;
13927
4a471b7d 13928 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
df694daa 13929 imux->items[imux->num_items].index = idx1;
f12ab1e0 13930 imux->num_items++;
df694daa
KY
13931 }
13932 return 0;
13933}
13934
f12ab1e0
TI
13935static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13936 hda_nid_t nid,
1c20930a 13937 int pin_type, hda_nid_t dac)
df694daa 13938{
1c20930a
TI
13939 hda_nid_t mix, srcs[5];
13940 int i, num;
13941
564c5bea
JL
13942 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13943 pin_type);
1c20930a 13944 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
564c5bea 13945 AMP_OUT_UNMUTE);
1c20930a
TI
13946 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
13947 return;
13948 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
13949 if (num < 0)
13950 return;
13951 for (i = 0; i < num; i++) {
13952 unsigned int mute;
13953 if (srcs[i] == dac || srcs[i] == 0x15)
13954 mute = AMP_IN_UNMUTE(i);
13955 else
13956 mute = AMP_IN_MUTE(i);
13957 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13958 mute);
13959 }
df694daa
KY
13960}
13961
13962static void alc861_auto_init_multi_out(struct hda_codec *codec)
13963{
13964 struct alc_spec *spec = codec->spec;
13965 int i;
13966
13967 for (i = 0; i < spec->autocfg.line_outs; i++) {
13968 hda_nid_t nid = spec->autocfg.line_out_pins[i];
baba8ee9 13969 int pin_type = get_pin_type(spec->autocfg.line_out_type);
df694daa 13970 if (nid)
baba8ee9 13971 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
f12ab1e0 13972 spec->multiout.dac_nids[i]);
df694daa
KY
13973 }
13974}
13975
13976static void alc861_auto_init_hp_out(struct hda_codec *codec)
13977{
13978 struct alc_spec *spec = codec->spec;
13979 hda_nid_t pin;
13980
eb06ed8f 13981 pin = spec->autocfg.hp_pins[0];
1c20930a 13982 if (pin)
f12ab1e0 13983 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
1c20930a 13984 spec->multiout.hp_nid);
f6c7e546
TI
13985 pin = spec->autocfg.speaker_pins[0];
13986 if (pin)
1c20930a
TI
13987 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT,
13988 spec->multiout.dac_nids[0]);
df694daa
KY
13989}
13990
13991static void alc861_auto_init_analog_input(struct hda_codec *codec)
13992{
13993 struct alc_spec *spec = codec->spec;
13994 int i;
13995
13996 for (i = 0; i < AUTO_PIN_LAST; i++) {
13997 hda_nid_t nid = spec->autocfg.input_pins[i];
23f0c048
TI
13998 if (nid >= 0x0c && nid <= 0x11)
13999 alc_set_input_pin(codec, nid, i);
df694daa
KY
14000 }
14001}
14002
14003/* parse the BIOS configuration and set up the alc_spec */
f12ab1e0
TI
14004/* return 1 if successful, 0 if the proper config is not found,
14005 * or a negative error code
14006 */
df694daa
KY
14007static int alc861_parse_auto_config(struct hda_codec *codec)
14008{
14009 struct alc_spec *spec = codec->spec;
14010 int err;
14011 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14012
f12ab1e0
TI
14013 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14014 alc861_ignore);
14015 if (err < 0)
df694daa 14016 return err;
f12ab1e0 14017 if (!spec->autocfg.line_outs)
df694daa
KY
14018 return 0; /* can't find valid BIOS pin config */
14019
1c20930a 14020 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
f12ab1e0
TI
14021 if (err < 0)
14022 return err;
1c20930a 14023 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
f12ab1e0
TI
14024 if (err < 0)
14025 return err;
1c20930a 14026 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
f12ab1e0
TI
14027 if (err < 0)
14028 return err;
1c20930a 14029 err = alc861_auto_create_analog_input_ctls(codec, &spec->autocfg);
f12ab1e0 14030 if (err < 0)
df694daa
KY
14031 return err;
14032
14033 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14034
0852d7a6 14035 if (spec->autocfg.dig_outs)
df694daa
KY
14036 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14037
603c4019 14038 if (spec->kctls.list)
d88897ea 14039 add_mixer(spec, spec->kctls.list);
df694daa 14040
d88897ea 14041 add_verb(spec, alc861_auto_init_verbs);
df694daa 14042
a1e8d2da 14043 spec->num_mux_defs = 1;
61b9b9b1 14044 spec->input_mux = &spec->private_imux[0];
df694daa
KY
14045
14046 spec->adc_nids = alc861_adc_nids;
14047 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
f9e336f6 14048 set_capture_mixer(spec);
df694daa 14049
4a79ba34
TI
14050 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14051
df694daa
KY
14052 return 1;
14053}
14054
ae6b813a
TI
14055/* additional initialization for auto-configuration model */
14056static void alc861_auto_init(struct hda_codec *codec)
df694daa 14057{
f6c7e546 14058 struct alc_spec *spec = codec->spec;
df694daa
KY
14059 alc861_auto_init_multi_out(codec);
14060 alc861_auto_init_hp_out(codec);
14061 alc861_auto_init_analog_input(codec);
f6c7e546 14062 if (spec->unsol_event)
7fb0d78f 14063 alc_inithook(codec);
df694daa
KY
14064}
14065
cb53c626
TI
14066#ifdef CONFIG_SND_HDA_POWER_SAVE
14067static struct hda_amp_list alc861_loopbacks[] = {
14068 { 0x15, HDA_INPUT, 0 },
14069 { 0x15, HDA_INPUT, 1 },
14070 { 0x15, HDA_INPUT, 2 },
14071 { 0x15, HDA_INPUT, 3 },
14072 { } /* end */
14073};
14074#endif
14075
df694daa
KY
14076
14077/*
14078 * configuration and preset
14079 */
f5fcc13c
TI
14080static const char *alc861_models[ALC861_MODEL_LAST] = {
14081 [ALC861_3ST] = "3stack",
14082 [ALC660_3ST] = "3stack-660",
14083 [ALC861_3ST_DIG] = "3stack-dig",
14084 [ALC861_6ST_DIG] = "6stack-dig",
14085 [ALC861_UNIWILL_M31] = "uniwill-m31",
14086 [ALC861_TOSHIBA] = "toshiba",
14087 [ALC861_ASUS] = "asus",
14088 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14089 [ALC861_AUTO] = "auto",
14090};
14091
14092static struct snd_pci_quirk alc861_cfg_tbl[] = {
687a47bd 14093 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
f5fcc13c
TI
14094 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14095 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14096 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
ac3e3741 14097 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
83c34218 14098 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
ad5e7737 14099 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
341d4eb0
TI
14100 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14101 * Any other models that need this preset?
14102 */
14103 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
ac3e3741
TI
14104 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14105 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
4147dab6 14106 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
ac3e3741
TI
14107 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14108 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14109 /* FIXME: the below seems conflict */
14110 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
07e038b3 14111 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
f5fcc13c 14112 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
df694daa
KY
14113 {}
14114};
14115
14116static struct alc_config_preset alc861_presets[] = {
14117 [ALC861_3ST] = {
14118 .mixers = { alc861_3ST_mixer },
14119 .init_verbs = { alc861_threestack_init_verbs },
14120 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14121 .dac_nids = alc861_dac_nids,
14122 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14123 .channel_mode = alc861_threestack_modes,
4e195a7b 14124 .need_dac_fix = 1,
df694daa
KY
14125 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14126 .adc_nids = alc861_adc_nids,
14127 .input_mux = &alc861_capture_source,
14128 },
14129 [ALC861_3ST_DIG] = {
14130 .mixers = { alc861_base_mixer },
14131 .init_verbs = { alc861_threestack_init_verbs },
14132 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14133 .dac_nids = alc861_dac_nids,
14134 .dig_out_nid = ALC861_DIGOUT_NID,
14135 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14136 .channel_mode = alc861_threestack_modes,
4e195a7b 14137 .need_dac_fix = 1,
df694daa
KY
14138 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14139 .adc_nids = alc861_adc_nids,
14140 .input_mux = &alc861_capture_source,
14141 },
14142 [ALC861_6ST_DIG] = {
14143 .mixers = { alc861_base_mixer },
14144 .init_verbs = { alc861_base_init_verbs },
14145 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14146 .dac_nids = alc861_dac_nids,
14147 .dig_out_nid = ALC861_DIGOUT_NID,
14148 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14149 .channel_mode = alc861_8ch_modes,
14150 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14151 .adc_nids = alc861_adc_nids,
14152 .input_mux = &alc861_capture_source,
14153 },
9c7f852e
TI
14154 [ALC660_3ST] = {
14155 .mixers = { alc861_3ST_mixer },
14156 .init_verbs = { alc861_threestack_init_verbs },
14157 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14158 .dac_nids = alc660_dac_nids,
14159 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14160 .channel_mode = alc861_threestack_modes,
4e195a7b 14161 .need_dac_fix = 1,
9c7f852e
TI
14162 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14163 .adc_nids = alc861_adc_nids,
14164 .input_mux = &alc861_capture_source,
14165 },
22309c3e
TI
14166 [ALC861_UNIWILL_M31] = {
14167 .mixers = { alc861_uniwill_m31_mixer },
14168 .init_verbs = { alc861_uniwill_m31_init_verbs },
14169 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14170 .dac_nids = alc861_dac_nids,
14171 .dig_out_nid = ALC861_DIGOUT_NID,
14172 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14173 .channel_mode = alc861_uniwill_m31_modes,
14174 .need_dac_fix = 1,
14175 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14176 .adc_nids = alc861_adc_nids,
14177 .input_mux = &alc861_capture_source,
14178 },
a53d1aec
TD
14179 [ALC861_TOSHIBA] = {
14180 .mixers = { alc861_toshiba_mixer },
f12ab1e0
TI
14181 .init_verbs = { alc861_base_init_verbs,
14182 alc861_toshiba_init_verbs },
a53d1aec
TD
14183 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14184 .dac_nids = alc861_dac_nids,
14185 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14186 .channel_mode = alc883_3ST_2ch_modes,
14187 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14188 .adc_nids = alc861_adc_nids,
14189 .input_mux = &alc861_capture_source,
14190 .unsol_event = alc861_toshiba_unsol_event,
14191 .init_hook = alc861_toshiba_automute,
14192 },
7cdbff94
MD
14193 [ALC861_ASUS] = {
14194 .mixers = { alc861_asus_mixer },
14195 .init_verbs = { alc861_asus_init_verbs },
14196 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14197 .dac_nids = alc861_dac_nids,
14198 .dig_out_nid = ALC861_DIGOUT_NID,
14199 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14200 .channel_mode = alc861_asus_modes,
14201 .need_dac_fix = 1,
14202 .hp_nid = 0x06,
14203 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14204 .adc_nids = alc861_adc_nids,
14205 .input_mux = &alc861_capture_source,
14206 },
56bb0cab
TI
14207 [ALC861_ASUS_LAPTOP] = {
14208 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14209 .init_verbs = { alc861_asus_init_verbs,
14210 alc861_asus_laptop_init_verbs },
14211 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14212 .dac_nids = alc861_dac_nids,
14213 .dig_out_nid = ALC861_DIGOUT_NID,
14214 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14215 .channel_mode = alc883_3ST_2ch_modes,
14216 .need_dac_fix = 1,
14217 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14218 .adc_nids = alc861_adc_nids,
14219 .input_mux = &alc861_capture_source,
14220 },
14221};
df694daa
KY
14222
14223
14224static int patch_alc861(struct hda_codec *codec)
14225{
14226 struct alc_spec *spec;
14227 int board_config;
14228 int err;
14229
dc041e0b 14230 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
df694daa
KY
14231 if (spec == NULL)
14232 return -ENOMEM;
14233
f12ab1e0 14234 codec->spec = spec;
df694daa 14235
f5fcc13c
TI
14236 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14237 alc861_models,
14238 alc861_cfg_tbl);
9c7f852e 14239
f5fcc13c 14240 if (board_config < 0) {
6c627f39
TI
14241 printk(KERN_INFO "hda_codec: Unknown model for %s, "
14242 "trying auto-probe from BIOS...\n", codec->chip_name);
df694daa
KY
14243 board_config = ALC861_AUTO;
14244 }
14245
14246 if (board_config == ALC861_AUTO) {
14247 /* automatic parse from the BIOS config */
14248 err = alc861_parse_auto_config(codec);
14249 if (err < 0) {
14250 alc_free(codec);
14251 return err;
f12ab1e0 14252 } else if (!err) {
9c7f852e
TI
14253 printk(KERN_INFO
14254 "hda_codec: Cannot set up configuration "
14255 "from BIOS. Using base mode...\n");
df694daa
KY
14256 board_config = ALC861_3ST_DIG;
14257 }
14258 }
14259
680cd536
KK
14260 err = snd_hda_attach_beep_device(codec, 0x23);
14261 if (err < 0) {
14262 alc_free(codec);
14263 return err;
14264 }
14265
df694daa
KY
14266 if (board_config != ALC861_AUTO)
14267 setup_preset(spec, &alc861_presets[board_config]);
14268
df694daa
KY
14269 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14270 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14271
df694daa
KY
14272 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14273 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14274
45bdd1c1
TI
14275 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14276
2134ea4f
TI
14277 spec->vmaster_nid = 0x03;
14278
df694daa
KY
14279 codec->patch_ops = alc_patch_ops;
14280 if (board_config == ALC861_AUTO)
ae6b813a 14281 spec->init_hook = alc861_auto_init;
cb53c626
TI
14282#ifdef CONFIG_SND_HDA_POWER_SAVE
14283 if (!spec->loopback.amplist)
14284 spec->loopback.amplist = alc861_loopbacks;
14285#endif
daead538 14286 codec->proc_widget_hook = print_realtek_coef;
ea1fb29a 14287
1da177e4
LT
14288 return 0;
14289}
14290
f32610ed
JS
14291/*
14292 * ALC861-VD support
14293 *
14294 * Based on ALC882
14295 *
14296 * In addition, an independent DAC
14297 */
14298#define ALC861VD_DIGOUT_NID 0x06
14299
14300static hda_nid_t alc861vd_dac_nids[4] = {
14301 /* front, surr, clfe, side surr */
14302 0x02, 0x03, 0x04, 0x05
14303};
14304
14305/* dac_nids for ALC660vd are in a different order - according to
14306 * Realtek's driver.
def319f9 14307 * This should probably result in a different mixer for 6stack models
f32610ed
JS
14308 * of ALC660vd codecs, but for now there is only 3stack mixer
14309 * - and it is the same as in 861vd.
14310 * adc_nids in ALC660vd are (is) the same as in 861vd
14311 */
14312static hda_nid_t alc660vd_dac_nids[3] = {
14313 /* front, rear, clfe, rear_surr */
14314 0x02, 0x04, 0x03
14315};
14316
14317static hda_nid_t alc861vd_adc_nids[1] = {
14318 /* ADC0 */
14319 0x09,
14320};
14321
e1406348
TI
14322static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14323
f32610ed
JS
14324/* input MUX */
14325/* FIXME: should be a matrix-type input source selection */
14326static struct hda_input_mux alc861vd_capture_source = {
14327 .num_items = 4,
14328 .items = {
14329 { "Mic", 0x0 },
14330 { "Front Mic", 0x1 },
14331 { "Line", 0x2 },
14332 { "CD", 0x4 },
14333 },
14334};
14335
272a527c 14336static struct hda_input_mux alc861vd_dallas_capture_source = {
b419f346 14337 .num_items = 2,
272a527c 14338 .items = {
b419f346
TD
14339 { "Ext Mic", 0x0 },
14340 { "Int Mic", 0x1 },
272a527c
KY
14341 },
14342};
14343
d1a991a6
KY
14344static struct hda_input_mux alc861vd_hp_capture_source = {
14345 .num_items = 2,
14346 .items = {
14347 { "Front Mic", 0x0 },
14348 { "ATAPI Mic", 0x1 },
14349 },
14350};
14351
f32610ed
JS
14352/*
14353 * 2ch mode
14354 */
14355static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14356 { 2, NULL }
14357};
14358
14359/*
14360 * 6ch mode
14361 */
14362static struct hda_verb alc861vd_6stack_ch6_init[] = {
14363 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14364 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14365 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14366 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14367 { } /* end */
14368};
14369
14370/*
14371 * 8ch mode
14372 */
14373static struct hda_verb alc861vd_6stack_ch8_init[] = {
14374 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14375 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14376 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14377 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14378 { } /* end */
14379};
14380
14381static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14382 { 6, alc861vd_6stack_ch6_init },
14383 { 8, alc861vd_6stack_ch8_init },
14384};
14385
14386static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14387 {
14388 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14389 .name = "Channel Mode",
14390 .info = alc_ch_mode_info,
14391 .get = alc_ch_mode_get,
14392 .put = alc_ch_mode_put,
14393 },
14394 { } /* end */
14395};
14396
f32610ed
JS
14397/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14398 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14399 */
14400static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14401 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14402 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14403
14404 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14405 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14406
14407 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14408 HDA_OUTPUT),
14409 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14410 HDA_OUTPUT),
14411 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14412 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14413
14414 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14415 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14416
14417 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14418
14419 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14420 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14421 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14422
14423 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14424 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14425 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14426
14427 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14428 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14429
14430 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14431 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14432
f32610ed
JS
14433 { } /* end */
14434};
14435
14436static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14437 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14438 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14439
14440 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14441
14442 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14443 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14444 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14445
14446 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14447 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14448 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14449
14450 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14451 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14452
14453 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14454 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14455
f32610ed
JS
14456 { } /* end */
14457};
14458
bdd148a3
KY
14459static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14460 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14461 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14462 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14463
14464 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14465
14466 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14467 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14468 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14469
14470 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14471 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14472 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14473
14474 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14475 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14476
14477 { } /* end */
14478};
14479
b419f346
TD
14480/* Pin assignment: Speaker=0x14, HP = 0x15,
14481 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
272a527c
KY
14482 */
14483static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
b419f346
TD
14484 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14485 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
272a527c
KY
14486 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14487 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
b419f346
TD
14488 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14489 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14490 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14491 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14492 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14493 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
272a527c
KY
14494 { } /* end */
14495};
14496
d1a991a6
KY
14497/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14498 * Front Mic=0x18, ATAPI Mic = 0x19,
14499 */
14500static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14501 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14502 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14503 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14504 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14505 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14506 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14507 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14508 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
ea1fb29a 14509
d1a991a6
KY
14510 { } /* end */
14511};
14512
f32610ed
JS
14513/*
14514 * generic initialization of ADC, input mixers and output mixers
14515 */
14516static struct hda_verb alc861vd_volume_init_verbs[] = {
14517 /*
14518 * Unmute ADC0 and set the default input to mic-in
14519 */
14520 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14521 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14522
14523 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14524 * the analog-loopback mixer widget
14525 */
14526 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
cb53c626
TI
14527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14529 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14530 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14531 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
f32610ed
JS
14532
14533 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
bdd148a3
KY
14534 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14535 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14536 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
f32610ed 14537 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
f32610ed
JS
14538
14539 /*
14540 * Set up output mixers (0x02 - 0x05)
14541 */
14542 /* set vol=0 to output mixers */
14543 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14544 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14545 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14546 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14547
14548 /* set up input amps for analog loopback */
14549 /* Amp Indices: DAC = 0, mixer = 1 */
14550 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14551 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14552 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14553 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14554 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14555 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14556 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14557 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14558
14559 { }
14560};
14561
14562/*
14563 * 3-stack pin configuration:
14564 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14565 */
14566static struct hda_verb alc861vd_3stack_init_verbs[] = {
14567 /*
14568 * Set pin mode and muting
14569 */
14570 /* set front pin widgets 0x14 for output */
14571 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14572 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14573 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14574
14575 /* Mic (rear) pin: input vref at 80% */
14576 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14577 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14578 /* Front Mic pin: input vref at 80% */
14579 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14580 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14581 /* Line In pin: input */
14582 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14583 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14584 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14585 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14586 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14587 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14588 /* CD pin widget for input */
14589 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14590
14591 { }
14592};
14593
14594/*
14595 * 6-stack pin configuration:
14596 */
14597static struct hda_verb alc861vd_6stack_init_verbs[] = {
14598 /*
14599 * Set pin mode and muting
14600 */
14601 /* set front pin widgets 0x14 for output */
14602 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14603 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14604 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14605
14606 /* Rear Pin: output 1 (0x0d) */
14607 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14608 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14609 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14610 /* CLFE Pin: output 2 (0x0e) */
14611 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14612 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14613 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14614 /* Side Pin: output 3 (0x0f) */
14615 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14616 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14617 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14618
14619 /* Mic (rear) pin: input vref at 80% */
14620 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14621 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14622 /* Front Mic pin: input vref at 80% */
14623 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14624 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14625 /* Line In pin: input */
14626 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14627 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14628 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14629 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14630 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14631 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14632 /* CD pin widget for input */
14633 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14634
14635 { }
14636};
14637
bdd148a3
KY
14638static struct hda_verb alc861vd_eapd_verbs[] = {
14639 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14640 { }
14641};
14642
f9423e7a
KY
14643static struct hda_verb alc660vd_eapd_verbs[] = {
14644 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14645 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14646 { }
14647};
14648
bdd148a3
KY
14649static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14650 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14651 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14652 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14653 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
ea1fb29a 14654 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
bdd148a3
KY
14655 {}
14656};
14657
bdd148a3
KY
14658static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14659{
14660 unsigned int present;
14661 unsigned char bits;
14662
14663 present = snd_hda_codec_read(codec, 0x18, 0,
14664 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
47fd830a
TI
14665 bits = present ? HDA_AMP_MUTE : 0;
14666 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14667 HDA_AMP_MUTE, bits);
bdd148a3
KY
14668}
14669
a9fd4f3f 14670static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
bdd148a3 14671{
a9fd4f3f
TI
14672 struct alc_spec *spec = codec->spec;
14673
14674 spec->autocfg.hp_pins[0] = 0x1b;
14675 spec->autocfg.speaker_pins[0] = 0x14;
14676 alc_automute_amp(codec);
bdd148a3
KY
14677 alc861vd_lenovo_mic_automute(codec);
14678}
14679
14680static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14681 unsigned int res)
14682{
14683 switch (res >> 26) {
bdd148a3
KY
14684 case ALC880_MIC_EVENT:
14685 alc861vd_lenovo_mic_automute(codec);
14686 break;
a9fd4f3f
TI
14687 default:
14688 alc_automute_amp_unsol_event(codec, res);
14689 break;
bdd148a3
KY
14690 }
14691}
14692
272a527c
KY
14693static struct hda_verb alc861vd_dallas_verbs[] = {
14694 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14695 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14696 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14697 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14698
14699 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14700 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14701 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14702 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14703 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14704 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14705 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14706 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
ea1fb29a 14707
272a527c
KY
14708 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14709 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14710 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14712 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14713 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14714 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14715 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14716
14717 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14718 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14719 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14720 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14721 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14722 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14723 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14724 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14725
14726 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14727 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14730
14731 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
ea1fb29a 14732 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
272a527c
KY
14733 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14734
14735 { } /* end */
14736};
14737
14738/* toggle speaker-output according to the hp-jack state */
a9fd4f3f 14739static void alc861vd_dallas_init_hook(struct hda_codec *codec)
272a527c 14740{
a9fd4f3f 14741 struct alc_spec *spec = codec->spec;
272a527c 14742
a9fd4f3f
TI
14743 spec->autocfg.hp_pins[0] = 0x15;
14744 spec->autocfg.speaker_pins[0] = 0x14;
14745 alc_automute_amp(codec);
272a527c
KY
14746}
14747
cb53c626
TI
14748#ifdef CONFIG_SND_HDA_POWER_SAVE
14749#define alc861vd_loopbacks alc880_loopbacks
14750#endif
14751
def319f9 14752/* pcm configuration: identical with ALC880 */
f32610ed
JS
14753#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14754#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14755#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14756#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14757
14758/*
14759 * configuration and preset
14760 */
14761static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14762 [ALC660VD_3ST] = "3stack-660",
983f8ae4 14763 [ALC660VD_3ST_DIG] = "3stack-660-digout",
13c94744 14764 [ALC660VD_ASUS_V1S] = "asus-v1s",
f32610ed
JS
14765 [ALC861VD_3ST] = "3stack",
14766 [ALC861VD_3ST_DIG] = "3stack-digout",
14767 [ALC861VD_6ST_DIG] = "6stack-digout",
bdd148a3 14768 [ALC861VD_LENOVO] = "lenovo",
272a527c 14769 [ALC861VD_DALLAS] = "dallas",
983f8ae4 14770 [ALC861VD_HP] = "hp",
f32610ed
JS
14771 [ALC861VD_AUTO] = "auto",
14772};
14773
14774static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
ac3e3741
TI
14775 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14776 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
07e038b3 14777 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
f32610ed 14778 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
13c94744 14779 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
6963f84c 14780 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
f32610ed 14781 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
ac3e3741 14782 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
38baf5ad 14783 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
272a527c 14784 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
542d7c66 14785 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
b419f346 14786 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
39c5d41f 14787 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
dea0a509 14788 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
625dc0bf 14789 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
f32610ed
JS
14790 {}
14791};
14792
14793static struct alc_config_preset alc861vd_presets[] = {
14794 [ALC660VD_3ST] = {
14795 .mixers = { alc861vd_3st_mixer },
14796 .init_verbs = { alc861vd_volume_init_verbs,
14797 alc861vd_3stack_init_verbs },
14798 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14799 .dac_nids = alc660vd_dac_nids,
f32610ed
JS
14800 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14801 .channel_mode = alc861vd_3stack_2ch_modes,
14802 .input_mux = &alc861vd_capture_source,
14803 },
6963f84c
MC
14804 [ALC660VD_3ST_DIG] = {
14805 .mixers = { alc861vd_3st_mixer },
14806 .init_verbs = { alc861vd_volume_init_verbs,
14807 alc861vd_3stack_init_verbs },
14808 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14809 .dac_nids = alc660vd_dac_nids,
14810 .dig_out_nid = ALC861VD_DIGOUT_NID,
6963f84c
MC
14811 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14812 .channel_mode = alc861vd_3stack_2ch_modes,
14813 .input_mux = &alc861vd_capture_source,
14814 },
f32610ed
JS
14815 [ALC861VD_3ST] = {
14816 .mixers = { alc861vd_3st_mixer },
14817 .init_verbs = { alc861vd_volume_init_verbs,
14818 alc861vd_3stack_init_verbs },
14819 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14820 .dac_nids = alc861vd_dac_nids,
14821 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14822 .channel_mode = alc861vd_3stack_2ch_modes,
14823 .input_mux = &alc861vd_capture_source,
14824 },
14825 [ALC861VD_3ST_DIG] = {
14826 .mixers = { alc861vd_3st_mixer },
14827 .init_verbs = { alc861vd_volume_init_verbs,
14828 alc861vd_3stack_init_verbs },
14829 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14830 .dac_nids = alc861vd_dac_nids,
14831 .dig_out_nid = ALC861VD_DIGOUT_NID,
14832 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14833 .channel_mode = alc861vd_3stack_2ch_modes,
14834 .input_mux = &alc861vd_capture_source,
14835 },
14836 [ALC861VD_6ST_DIG] = {
14837 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14838 .init_verbs = { alc861vd_volume_init_verbs,
14839 alc861vd_6stack_init_verbs },
14840 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14841 .dac_nids = alc861vd_dac_nids,
14842 .dig_out_nid = ALC861VD_DIGOUT_NID,
14843 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14844 .channel_mode = alc861vd_6stack_modes,
14845 .input_mux = &alc861vd_capture_source,
14846 },
bdd148a3
KY
14847 [ALC861VD_LENOVO] = {
14848 .mixers = { alc861vd_lenovo_mixer },
14849 .init_verbs = { alc861vd_volume_init_verbs,
14850 alc861vd_3stack_init_verbs,
14851 alc861vd_eapd_verbs,
14852 alc861vd_lenovo_unsol_verbs },
14853 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14854 .dac_nids = alc660vd_dac_nids,
bdd148a3
KY
14855 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14856 .channel_mode = alc861vd_3stack_2ch_modes,
14857 .input_mux = &alc861vd_capture_source,
14858 .unsol_event = alc861vd_lenovo_unsol_event,
a9fd4f3f 14859 .init_hook = alc861vd_lenovo_init_hook,
bdd148a3 14860 },
272a527c
KY
14861 [ALC861VD_DALLAS] = {
14862 .mixers = { alc861vd_dallas_mixer },
14863 .init_verbs = { alc861vd_dallas_verbs },
14864 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14865 .dac_nids = alc861vd_dac_nids,
272a527c
KY
14866 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14867 .channel_mode = alc861vd_3stack_2ch_modes,
14868 .input_mux = &alc861vd_dallas_capture_source,
a9fd4f3f
TI
14869 .unsol_event = alc_automute_amp_unsol_event,
14870 .init_hook = alc861vd_dallas_init_hook,
d1a991a6
KY
14871 },
14872 [ALC861VD_HP] = {
14873 .mixers = { alc861vd_hp_mixer },
14874 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14875 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14876 .dac_nids = alc861vd_dac_nids,
d1a991a6 14877 .dig_out_nid = ALC861VD_DIGOUT_NID,
d1a991a6
KY
14878 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14879 .channel_mode = alc861vd_3stack_2ch_modes,
14880 .input_mux = &alc861vd_hp_capture_source,
a9fd4f3f
TI
14881 .unsol_event = alc_automute_amp_unsol_event,
14882 .init_hook = alc861vd_dallas_init_hook,
ea1fb29a 14883 },
13c94744
TI
14884 [ALC660VD_ASUS_V1S] = {
14885 .mixers = { alc861vd_lenovo_mixer },
14886 .init_verbs = { alc861vd_volume_init_verbs,
14887 alc861vd_3stack_init_verbs,
14888 alc861vd_eapd_verbs,
14889 alc861vd_lenovo_unsol_verbs },
14890 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14891 .dac_nids = alc660vd_dac_nids,
14892 .dig_out_nid = ALC861VD_DIGOUT_NID,
14893 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14894 .channel_mode = alc861vd_3stack_2ch_modes,
14895 .input_mux = &alc861vd_capture_source,
14896 .unsol_event = alc861vd_lenovo_unsol_event,
a9fd4f3f 14897 .init_hook = alc861vd_lenovo_init_hook,
13c94744 14898 },
f32610ed
JS
14899};
14900
14901/*
14902 * BIOS auto configuration
14903 */
14904static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14905 hda_nid_t nid, int pin_type, int dac_idx)
14906{
f6c7e546 14907 alc_set_pin_output(codec, nid, pin_type);
f32610ed
JS
14908}
14909
14910static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14911{
14912 struct alc_spec *spec = codec->spec;
14913 int i;
14914
14915 for (i = 0; i <= HDA_SIDE; i++) {
14916 hda_nid_t nid = spec->autocfg.line_out_pins[i];
baba8ee9 14917 int pin_type = get_pin_type(spec->autocfg.line_out_type);
f32610ed
JS
14918 if (nid)
14919 alc861vd_auto_set_output_and_unmute(codec, nid,
baba8ee9 14920 pin_type, i);
f32610ed
JS
14921 }
14922}
14923
14924
14925static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14926{
14927 struct alc_spec *spec = codec->spec;
14928 hda_nid_t pin;
14929
14930 pin = spec->autocfg.hp_pins[0];
def319f9 14931 if (pin) /* connect to front and use dac 0 */
f32610ed 14932 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
f6c7e546
TI
14933 pin = spec->autocfg.speaker_pins[0];
14934 if (pin)
14935 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
f32610ed
JS
14936}
14937
14938#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14939#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14940
14941static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14942{
14943 struct alc_spec *spec = codec->spec;
14944 int i;
14945
14946 for (i = 0; i < AUTO_PIN_LAST; i++) {
14947 hda_nid_t nid = spec->autocfg.input_pins[i];
14948 if (alc861vd_is_input_pin(nid)) {
23f0c048 14949 alc_set_input_pin(codec, nid, i);
e82c025b
TI
14950 if (nid != ALC861VD_PIN_CD_NID &&
14951 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
f32610ed
JS
14952 snd_hda_codec_write(codec, nid, 0,
14953 AC_VERB_SET_AMP_GAIN_MUTE,
14954 AMP_OUT_MUTE);
14955 }
14956 }
14957}
14958
f511b01c
TI
14959#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14960
f32610ed
JS
14961#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14962#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14963
14964/* add playback controls from the parsed DAC table */
14965/* Based on ALC880 version. But ALC861VD has separate,
14966 * different NIDs for mute/unmute switch and volume control */
14967static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14968 const struct auto_pin_cfg *cfg)
14969{
14970 char name[32];
14971 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14972 hda_nid_t nid_v, nid_s;
14973 int i, err;
14974
14975 for (i = 0; i < cfg->line_outs; i++) {
f12ab1e0 14976 if (!spec->multiout.dac_nids[i])
f32610ed
JS
14977 continue;
14978 nid_v = alc861vd_idx_to_mixer_vol(
14979 alc880_dac_to_idx(
14980 spec->multiout.dac_nids[i]));
14981 nid_s = alc861vd_idx_to_mixer_switch(
14982 alc880_dac_to_idx(
14983 spec->multiout.dac_nids[i]));
14984
14985 if (i == 2) {
14986 /* Center/LFE */
f12ab1e0
TI
14987 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14988 "Center Playback Volume",
14989 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14990 HDA_OUTPUT));
14991 if (err < 0)
f32610ed 14992 return err;
f12ab1e0
TI
14993 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14994 "LFE Playback Volume",
14995 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14996 HDA_OUTPUT));
14997 if (err < 0)
f32610ed 14998 return err;
f12ab1e0
TI
14999 err = add_control(spec, ALC_CTL_BIND_MUTE,
15000 "Center Playback Switch",
15001 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15002 HDA_INPUT));
15003 if (err < 0)
f32610ed 15004 return err;
f12ab1e0
TI
15005 err = add_control(spec, ALC_CTL_BIND_MUTE,
15006 "LFE Playback Switch",
15007 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15008 HDA_INPUT));
15009 if (err < 0)
f32610ed
JS
15010 return err;
15011 } else {
15012 sprintf(name, "%s Playback Volume", chname[i]);
f12ab1e0
TI
15013 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15014 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15015 HDA_OUTPUT));
15016 if (err < 0)
f32610ed
JS
15017 return err;
15018 sprintf(name, "%s Playback Switch", chname[i]);
f12ab1e0 15019 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
bdd148a3 15020 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
f12ab1e0
TI
15021 HDA_INPUT));
15022 if (err < 0)
f32610ed
JS
15023 return err;
15024 }
15025 }
15026 return 0;
15027}
15028
15029/* add playback controls for speaker and HP outputs */
15030/* Based on ALC880 version. But ALC861VD has separate,
15031 * different NIDs for mute/unmute switch and volume control */
15032static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15033 hda_nid_t pin, const char *pfx)
15034{
15035 hda_nid_t nid_v, nid_s;
15036 int err;
15037 char name[32];
15038
f12ab1e0 15039 if (!pin)
f32610ed
JS
15040 return 0;
15041
15042 if (alc880_is_fixed_pin(pin)) {
15043 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15044 /* specify the DAC as the extra output */
f12ab1e0 15045 if (!spec->multiout.hp_nid)
f32610ed
JS
15046 spec->multiout.hp_nid = nid_v;
15047 else
15048 spec->multiout.extra_out_nid[0] = nid_v;
15049 /* control HP volume/switch on the output mixer amp */
15050 nid_v = alc861vd_idx_to_mixer_vol(
15051 alc880_fixed_pin_idx(pin));
15052 nid_s = alc861vd_idx_to_mixer_switch(
15053 alc880_fixed_pin_idx(pin));
15054
15055 sprintf(name, "%s Playback Volume", pfx);
f12ab1e0
TI
15056 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15057 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15058 if (err < 0)
f32610ed
JS
15059 return err;
15060 sprintf(name, "%s Playback Switch", pfx);
f12ab1e0
TI
15061 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15062 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15063 if (err < 0)
f32610ed
JS
15064 return err;
15065 } else if (alc880_is_multi_pin(pin)) {
15066 /* set manual connection */
15067 /* we have only a switch on HP-out PIN */
15068 sprintf(name, "%s Playback Switch", pfx);
f12ab1e0
TI
15069 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15070 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15071 if (err < 0)
f32610ed
JS
15072 return err;
15073 }
15074 return 0;
15075}
15076
15077/* parse the BIOS configuration and set up the alc_spec
15078 * return 1 if successful, 0 if the proper config is not found,
15079 * or a negative error code
15080 * Based on ALC880 version - had to change it to override
15081 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15082static int alc861vd_parse_auto_config(struct hda_codec *codec)
15083{
15084 struct alc_spec *spec = codec->spec;
15085 int err;
15086 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15087
f12ab1e0
TI
15088 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15089 alc861vd_ignore);
15090 if (err < 0)
f32610ed 15091 return err;
f12ab1e0 15092 if (!spec->autocfg.line_outs)
f32610ed
JS
15093 return 0; /* can't find valid BIOS pin config */
15094
f12ab1e0
TI
15095 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15096 if (err < 0)
15097 return err;
15098 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15099 if (err < 0)
15100 return err;
15101 err = alc861vd_auto_create_extra_out(spec,
15102 spec->autocfg.speaker_pins[0],
15103 "Speaker");
15104 if (err < 0)
15105 return err;
15106 err = alc861vd_auto_create_extra_out(spec,
15107 spec->autocfg.hp_pins[0],
15108 "Headphone");
15109 if (err < 0)
15110 return err;
15111 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15112 if (err < 0)
f32610ed
JS
15113 return err;
15114
15115 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15116
0852d7a6 15117 if (spec->autocfg.dig_outs)
f32610ed
JS
15118 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15119
603c4019 15120 if (spec->kctls.list)
d88897ea 15121 add_mixer(spec, spec->kctls.list);
f32610ed 15122
d88897ea 15123 add_verb(spec, alc861vd_volume_init_verbs);
f32610ed
JS
15124
15125 spec->num_mux_defs = 1;
61b9b9b1 15126 spec->input_mux = &spec->private_imux[0];
f32610ed 15127
776e184e
TI
15128 err = alc_auto_add_mic_boost(codec);
15129 if (err < 0)
15130 return err;
15131
4a79ba34
TI
15132 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15133
f32610ed
JS
15134 return 1;
15135}
15136
15137/* additional initialization for auto-configuration model */
15138static void alc861vd_auto_init(struct hda_codec *codec)
15139{
f6c7e546 15140 struct alc_spec *spec = codec->spec;
f32610ed
JS
15141 alc861vd_auto_init_multi_out(codec);
15142 alc861vd_auto_init_hp_out(codec);
15143 alc861vd_auto_init_analog_input(codec);
f511b01c 15144 alc861vd_auto_init_input_src(codec);
f6c7e546 15145 if (spec->unsol_event)
7fb0d78f 15146 alc_inithook(codec);
f32610ed
JS
15147}
15148
15149static int patch_alc861vd(struct hda_codec *codec)
15150{
15151 struct alc_spec *spec;
15152 int err, board_config;
15153
15154 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15155 if (spec == NULL)
15156 return -ENOMEM;
15157
15158 codec->spec = spec;
15159
15160 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15161 alc861vd_models,
15162 alc861vd_cfg_tbl);
15163
15164 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
6c627f39
TI
15165 printk(KERN_INFO "hda_codec: Unknown model for %s, "
15166 "trying auto-probe from BIOS...\n", codec->chip_name);
f32610ed
JS
15167 board_config = ALC861VD_AUTO;
15168 }
15169
15170 if (board_config == ALC861VD_AUTO) {
15171 /* automatic parse from the BIOS config */
15172 err = alc861vd_parse_auto_config(codec);
15173 if (err < 0) {
15174 alc_free(codec);
15175 return err;
f12ab1e0 15176 } else if (!err) {
f32610ed
JS
15177 printk(KERN_INFO
15178 "hda_codec: Cannot set up configuration "
15179 "from BIOS. Using base mode...\n");
15180 board_config = ALC861VD_3ST;
15181 }
15182 }
15183
680cd536
KK
15184 err = snd_hda_attach_beep_device(codec, 0x23);
15185 if (err < 0) {
15186 alc_free(codec);
15187 return err;
15188 }
15189
f32610ed
JS
15190 if (board_config != ALC861VD_AUTO)
15191 setup_preset(spec, &alc861vd_presets[board_config]);
15192
2f893286 15193 if (codec->vendor_id == 0x10ec0660) {
f9423e7a 15194 /* always turn on EAPD */
d88897ea 15195 add_verb(spec, alc660vd_eapd_verbs);
2f893286
KY
15196 }
15197
f32610ed
JS
15198 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15199 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15200
f32610ed
JS
15201 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15202 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15203
15204 spec->adc_nids = alc861vd_adc_nids;
15205 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
e1406348 15206 spec->capsrc_nids = alc861vd_capsrc_nids;
f32610ed 15207
f9e336f6 15208 set_capture_mixer(spec);
45bdd1c1 15209 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
f32610ed 15210
2134ea4f
TI
15211 spec->vmaster_nid = 0x02;
15212
f32610ed
JS
15213 codec->patch_ops = alc_patch_ops;
15214
15215 if (board_config == ALC861VD_AUTO)
15216 spec->init_hook = alc861vd_auto_init;
cb53c626
TI
15217#ifdef CONFIG_SND_HDA_POWER_SAVE
15218 if (!spec->loopback.amplist)
15219 spec->loopback.amplist = alc861vd_loopbacks;
15220#endif
daead538 15221 codec->proc_widget_hook = print_realtek_coef;
f32610ed
JS
15222
15223 return 0;
15224}
15225
bc9f98a9
KY
15226/*
15227 * ALC662 support
15228 *
15229 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15230 * configuration. Each pin widget can choose any input DACs and a mixer.
15231 * Each ADC is connected from a mixer of all inputs. This makes possible
15232 * 6-channel independent captures.
15233 *
15234 * In addition, an independent DAC for the multi-playback (not used in this
15235 * driver yet).
15236 */
15237#define ALC662_DIGOUT_NID 0x06
15238#define ALC662_DIGIN_NID 0x0a
15239
15240static hda_nid_t alc662_dac_nids[4] = {
15241 /* front, rear, clfe, rear_surr */
15242 0x02, 0x03, 0x04
15243};
15244
622e84cd
KY
15245static hda_nid_t alc272_dac_nids[2] = {
15246 0x02, 0x03
15247};
15248
bc9f98a9
KY
15249static hda_nid_t alc662_adc_nids[1] = {
15250 /* ADC1-2 */
15251 0x09,
15252};
e1406348 15253
622e84cd
KY
15254static hda_nid_t alc272_adc_nids[1] = {
15255 /* ADC1-2 */
15256 0x08,
15257};
15258
77a261b7 15259static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
622e84cd
KY
15260static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15261
e1406348 15262
bc9f98a9
KY
15263/* input MUX */
15264/* FIXME: should be a matrix-type input source selection */
bc9f98a9
KY
15265static struct hda_input_mux alc662_capture_source = {
15266 .num_items = 4,
15267 .items = {
15268 { "Mic", 0x0 },
15269 { "Front Mic", 0x1 },
15270 { "Line", 0x2 },
15271 { "CD", 0x4 },
15272 },
15273};
15274
15275static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15276 .num_items = 2,
15277 .items = {
15278 { "Mic", 0x1 },
15279 { "Line", 0x2 },
15280 },
15281};
291702f0
KY
15282
15283static struct hda_input_mux alc662_eeepc_capture_source = {
15284 .num_items = 2,
15285 .items = {
15286 { "i-Mic", 0x1 },
15287 { "e-Mic", 0x0 },
15288 },
15289};
15290
6dda9f4a
KY
15291static struct hda_input_mux alc663_capture_source = {
15292 .num_items = 3,
15293 .items = {
15294 { "Mic", 0x0 },
15295 { "Front Mic", 0x1 },
15296 { "Line", 0x2 },
15297 },
15298};
15299
15300static struct hda_input_mux alc663_m51va_capture_source = {
15301 .num_items = 2,
15302 .items = {
15303 { "Ext-Mic", 0x0 },
15304 { "D-Mic", 0x9 },
15305 },
15306};
15307
9541ba1d
CP
15308#if 1 /* set to 0 for testing other input sources below */
15309static struct hda_input_mux alc272_nc10_capture_source = {
15310 .num_items = 2,
15311 .items = {
15312 { "Autoselect Mic", 0x0 },
15313 { "Internal Mic", 0x1 },
15314 },
15315};
15316#else
15317static struct hda_input_mux alc272_nc10_capture_source = {
15318 .num_items = 16,
15319 .items = {
15320 { "Autoselect Mic", 0x0 },
15321 { "Internal Mic", 0x1 },
15322 { "In-0x02", 0x2 },
15323 { "In-0x03", 0x3 },
15324 { "In-0x04", 0x4 },
15325 { "In-0x05", 0x5 },
15326 { "In-0x06", 0x6 },
15327 { "In-0x07", 0x7 },
15328 { "In-0x08", 0x8 },
15329 { "In-0x09", 0x9 },
15330 { "In-0x0a", 0x0a },
15331 { "In-0x0b", 0x0b },
15332 { "In-0x0c", 0x0c },
15333 { "In-0x0d", 0x0d },
15334 { "In-0x0e", 0x0e },
15335 { "In-0x0f", 0x0f },
15336 },
15337};
15338#endif
15339
bc9f98a9
KY
15340/*
15341 * 2ch mode
15342 */
15343static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15344 { 2, NULL }
15345};
15346
15347/*
15348 * 2ch mode
15349 */
15350static struct hda_verb alc662_3ST_ch2_init[] = {
15351 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15352 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15353 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15354 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15355 { } /* end */
15356};
15357
15358/*
15359 * 6ch mode
15360 */
15361static struct hda_verb alc662_3ST_ch6_init[] = {
15362 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15363 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15364 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15365 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15366 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15367 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15368 { } /* end */
15369};
15370
15371static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15372 { 2, alc662_3ST_ch2_init },
15373 { 6, alc662_3ST_ch6_init },
15374};
15375
15376/*
15377 * 2ch mode
15378 */
15379static struct hda_verb alc662_sixstack_ch6_init[] = {
15380 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15381 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15382 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15383 { } /* end */
15384};
15385
15386/*
15387 * 6ch mode
15388 */
15389static struct hda_verb alc662_sixstack_ch8_init[] = {
15390 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15391 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15392 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15393 { } /* end */
15394};
15395
15396static struct hda_channel_mode alc662_5stack_modes[2] = {
15397 { 2, alc662_sixstack_ch6_init },
15398 { 6, alc662_sixstack_ch8_init },
15399};
15400
15401/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15402 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15403 */
15404
15405static struct snd_kcontrol_new alc662_base_mixer[] = {
15406 /* output mixer control */
15407 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
7055ad8a 15408 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
bc9f98a9 15409 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
7055ad8a 15410 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
bc9f98a9
KY
15411 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15412 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
7055ad8a
HRK
15413 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15414 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
bc9f98a9
KY
15415 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15416
15417 /*Input mixer control */
15418 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15419 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15420 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15421 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15422 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15423 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15424 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15425 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
bc9f98a9
KY
15426 { } /* end */
15427};
15428
15429static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15430 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
7055ad8a 15431 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
bc9f98a9
KY
15432 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15433 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15434 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15435 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15436 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15437 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15438 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15439 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15440 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
bc9f98a9
KY
15441 { } /* end */
15442};
15443
15444static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15445 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
7055ad8a 15446 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
bc9f98a9 15447 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
7055ad8a 15448 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
bc9f98a9
KY
15449 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15450 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
7055ad8a
HRK
15451 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15452 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
bc9f98a9
KY
15453 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15454 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15455 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15456 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15457 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15458 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15459 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15460 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15461 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
bc9f98a9
KY
15462 { } /* end */
15463};
15464
15465static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15466 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15467 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
86cd9298
TI
15468 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15469 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
bc9f98a9
KY
15470 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15471 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15472 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15473 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15474 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
bc9f98a9
KY
15475 { } /* end */
15476};
15477
291702f0 15478static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
42171c17
TI
15479 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15480 ALC262_HIPPO_MASTER_SWITCH,
291702f0
KY
15481
15482 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15483 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15484 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15485
15486 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15487 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15488 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15489 { } /* end */
15490};
15491
8c427226 15492static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
42171c17
TI
15493 ALC262_HIPPO_MASTER_SWITCH,
15494 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
8c427226 15495 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
8c427226
KY
15496 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15497 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
8c427226
KY
15498 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15499 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15500 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15502 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15503 { } /* end */
15504};
15505
f1d4e28b
KY
15506static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15507 .ops = &snd_hda_bind_vol,
15508 .values = {
15509 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15510 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15511 0
15512 },
15513};
15514
15515static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15516 .ops = &snd_hda_bind_sw,
15517 .values = {
15518 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15519 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15520 0
15521 },
15522};
15523
6dda9f4a 15524static struct snd_kcontrol_new alc663_m51va_mixer[] = {
f1d4e28b
KY
15525 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15526 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15527 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15528 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15529 { } /* end */
15530};
15531
15532static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15533 .ops = &snd_hda_bind_sw,
15534 .values = {
15535 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15536 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15537 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15538 0
15539 },
15540};
15541
15542static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15543 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15544 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15546 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15547 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15548 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15549
15550 { } /* end */
15551};
15552
15553static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15554 .ops = &snd_hda_bind_sw,
15555 .values = {
15556 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15557 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15558 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15559 0
15560 },
15561};
15562
15563static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15564 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15565 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15566 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15567 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15568 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15569 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15570 { } /* end */
15571};
15572
15573static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
6dda9f4a
KY
15574 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15575 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
f1d4e28b
KY
15576 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15577 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15578 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15579 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15580 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15581 { } /* end */
15582};
15583
15584static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15585 .ops = &snd_hda_bind_vol,
15586 .values = {
15587 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15588 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15589 0
15590 },
15591};
15592
15593static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15594 .ops = &snd_hda_bind_sw,
15595 .values = {
15596 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15597 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15598 0
15599 },
15600};
15601
15602static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15603 HDA_BIND_VOL("Master Playback Volume",
15604 &alc663_asus_two_bind_master_vol),
15605 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15606 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
6dda9f4a
KY
15607 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15608 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15609 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
f1d4e28b
KY
15610 { } /* end */
15611};
15612
15613static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15614 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15615 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15616 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15617 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15618 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15619 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6dda9f4a
KY
15620 { } /* end */
15621};
15622
15623static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15624 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15625 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15626 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15627 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15628 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15629
15630 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15631 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15632 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15633 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15634 { } /* end */
15635};
15636
15637static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15638 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15639 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15640 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15641
15642 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15643 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15644 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15645 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15646 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15647 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15648 { } /* end */
15649};
15650
bc9f98a9
KY
15651static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15652 {
15653 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15654 .name = "Channel Mode",
15655 .info = alc_ch_mode_info,
15656 .get = alc_ch_mode_get,
15657 .put = alc_ch_mode_put,
15658 },
15659 { } /* end */
15660};
15661
15662static struct hda_verb alc662_init_verbs[] = {
15663 /* ADC: mute amp left and right */
15664 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15665 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15666 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15667
cb53c626
TI
15668 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15669 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15670 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15671 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15672 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
bc9f98a9 15673
b60dd394
KY
15674 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15675 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15676 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15677 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15678 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15679 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
bc9f98a9
KY
15680
15681 /* Front Pin: output 0 (0x0c) */
15682 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15683 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15684
15685 /* Rear Pin: output 1 (0x0d) */
15686 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15687 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15688
15689 /* CLFE Pin: output 2 (0x0e) */
15690 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15691 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15692
15693 /* Mic (rear) pin: input vref at 80% */
15694 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15695 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15696 /* Front Mic pin: input vref at 80% */
15697 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15698 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15699 /* Line In pin: input */
15700 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15701 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15702 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15703 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15704 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15705 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15706 /* CD pin widget for input */
15707 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15708
15709 /* FIXME: use matrix-type input source selection */
15710 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15711 /* Input mixer */
15712 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
291702f0 15713 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6dda9f4a
KY
15714
15715 /* always trun on EAPD */
15716 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15717 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15718
bc9f98a9
KY
15719 { }
15720};
15721
15722static struct hda_verb alc662_sue_init_verbs[] = {
15723 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15724 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
291702f0
KY
15725 {}
15726};
15727
15728static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15729 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15730 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15731 {}
bc9f98a9
KY
15732};
15733
8c427226
KY
15734/* Set Unsolicited Event*/
15735static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15736 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15737 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15738 {}
15739};
15740
bc9f98a9
KY
15741/*
15742 * generic initialization of ADC, input mixers and output mixers
15743 */
15744static struct hda_verb alc662_auto_init_verbs[] = {
15745 /*
15746 * Unmute ADC and set the default input to mic-in
15747 */
15748 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15749 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15750
15751 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15752 * mixer widget
15753 * Note: PASD motherboards uses the Line In 2 as the input for front
15754 * panel mic (mic 2)
15755 */
15756 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
cb53c626
TI
15757 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15758 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15759 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15760 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15761 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
bc9f98a9
KY
15762
15763 /*
15764 * Set up output mixers (0x0c - 0x0f)
15765 */
15766 /* set vol=0 to output mixers */
15767 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15768 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15769 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15770
15771 /* set up input amps for analog loopback */
15772 /* Amp Indices: DAC = 0, mixer = 1 */
b60dd394
KY
15773 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15774 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15775 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15776 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15777 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15778 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
bc9f98a9
KY
15779
15780
15781 /* FIXME: use matrix-type input source selection */
15782 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15783 /* Input mixer */
15784 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
d1a991a6 15785 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
bc9f98a9
KY
15786 { }
15787};
15788
24fb9173
TI
15789/* additional verbs for ALC663 */
15790static struct hda_verb alc663_auto_init_verbs[] = {
15791 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15792 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15793 { }
15794};
15795
6dda9f4a 15796static struct hda_verb alc663_m51va_init_verbs[] = {
f1d4e28b
KY
15797 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15798 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6dda9f4a
KY
15799 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15800 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
f1d4e28b
KY
15801 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15803 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15804 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15805 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15806 {}
15807};
15808
15809static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15810 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15811 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15812 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15813 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15814 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15815 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15816 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15817 {}
15818};
15819
15820static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15821 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15822 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15823 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15824 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15825 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15826 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15827 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15828 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15829 {}
15830};
6dda9f4a 15831
f1d4e28b
KY
15832static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15833 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15834 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15835 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15836 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15837 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15838 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15839 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15840 {}
15841};
6dda9f4a 15842
f1d4e28b
KY
15843static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15844 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15845 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15846 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15847 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15848 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15849 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15850 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15851 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15852 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6dda9f4a
KY
15853 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15854 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
f1d4e28b
KY
15855 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15856 {}
15857};
15858
15859static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15860 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15861 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15862 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15863 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15864 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15865 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15866 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15867 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15868 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15869 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15870 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15871 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6dda9f4a
KY
15872 {}
15873};
15874
15875static struct hda_verb alc663_g71v_init_verbs[] = {
15876 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15877 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15878 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15879
15880 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15881 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15882 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15883
15884 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15885 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15886 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15887 {}
15888};
15889
15890static struct hda_verb alc663_g50v_init_verbs[] = {
15891 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15892 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15893 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15894
15895 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15896 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15897 {}
15898};
15899
f1d4e28b
KY
15900static struct hda_verb alc662_ecs_init_verbs[] = {
15901 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15903 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15904 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15905 {}
15906};
15907
622e84cd
KY
15908static struct hda_verb alc272_dell_zm1_init_verbs[] = {
15909 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15910 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15911 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15912 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15913 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15914 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15915 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15916 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15917 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15918 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15919 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15920 {}
15921};
15922
15923static struct hda_verb alc272_dell_init_verbs[] = {
15924 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15925 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15926 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15927 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15928 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15929 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15930 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15931 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15932 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15933 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15934 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15935 {}
15936};
15937
f1d4e28b
KY
15938static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15939 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15940 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15941 { } /* end */
15942};
15943
622e84cd
KY
15944static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
15945 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
15946 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
15947 { } /* end */
15948};
15949
bc9f98a9
KY
15950static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15951{
15952 unsigned int present;
f12ab1e0 15953 unsigned char bits;
bc9f98a9
KY
15954
15955 present = snd_hda_codec_read(codec, 0x14, 0,
15956 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
47fd830a
TI
15957 bits = present ? HDA_AMP_MUTE : 0;
15958 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15959 HDA_AMP_MUTE, bits);
bc9f98a9
KY
15960}
15961
15962static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15963{
15964 unsigned int present;
f12ab1e0 15965 unsigned char bits;
bc9f98a9
KY
15966
15967 present = snd_hda_codec_read(codec, 0x1b, 0,
15968 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
47fd830a
TI
15969 bits = present ? HDA_AMP_MUTE : 0;
15970 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15971 HDA_AMP_MUTE, bits);
15972 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15973 HDA_AMP_MUTE, bits);
bc9f98a9
KY
15974}
15975
15976static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15977 unsigned int res)
15978{
15979 if ((res >> 26) == ALC880_HP_EVENT)
15980 alc662_lenovo_101e_all_automute(codec);
15981 if ((res >> 26) == ALC880_FRONT_EVENT)
15982 alc662_lenovo_101e_ispeaker_automute(codec);
15983}
15984
291702f0
KY
15985static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15986{
15987 unsigned int present;
15988
15989 present = snd_hda_codec_read(codec, 0x18, 0,
15990 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15991 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15992 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15993 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15994 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15995 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15996 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15997 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15998 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15999}
16000
16001/* unsolicited event for HP jack sensing */
16002static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16003 unsigned int res)
16004{
291702f0
KY
16005 if ((res >> 26) == ALC880_MIC_EVENT)
16006 alc662_eeepc_mic_automute(codec);
42171c17
TI
16007 else
16008 alc262_hippo_unsol_event(codec, res);
291702f0
KY
16009}
16010
16011static void alc662_eeepc_inithook(struct hda_codec *codec)
16012{
42171c17 16013 alc262_hippo1_init_hook(codec);
291702f0
KY
16014 alc662_eeepc_mic_automute(codec);
16015}
16016
8c427226
KY
16017static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16018{
42171c17
TI
16019 struct alc_spec *spec = codec->spec;
16020
16021 spec->autocfg.hp_pins[0] = 0x14;
16022 spec->autocfg.speaker_pins[0] = 0x1b;
16023 alc262_hippo_master_update(codec);
8c427226
KY
16024}
16025
6dda9f4a
KY
16026static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16027{
16028 unsigned int present;
16029 unsigned char bits;
16030
16031 present = snd_hda_codec_read(codec, 0x21, 0,
f1d4e28b
KY
16032 AC_VERB_GET_PIN_SENSE, 0)
16033 & AC_PINSENSE_PRESENCE;
6dda9f4a 16034 bits = present ? HDA_AMP_MUTE : 0;
f1d4e28b
KY
16035 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16036 AMP_IN_MUTE(0), bits);
16037 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16038 AMP_IN_MUTE(0), bits);
16039}
16040
16041static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16042{
16043 unsigned int present;
16044 unsigned char bits;
16045
16046 present = snd_hda_codec_read(codec, 0x21, 0,
16047 AC_VERB_GET_PIN_SENSE, 0)
16048 & AC_PINSENSE_PRESENCE;
16049 bits = present ? HDA_AMP_MUTE : 0;
16050 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16051 AMP_IN_MUTE(0), bits);
16052 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16053 AMP_IN_MUTE(0), bits);
16054 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16055 AMP_IN_MUTE(0), bits);
16056 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16057 AMP_IN_MUTE(0), bits);
16058}
16059
16060static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16061{
16062 unsigned int present;
16063 unsigned char bits;
16064
16065 present = snd_hda_codec_read(codec, 0x15, 0,
16066 AC_VERB_GET_PIN_SENSE, 0)
16067 & AC_PINSENSE_PRESENCE;
16068 bits = present ? HDA_AMP_MUTE : 0;
16069 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16070 AMP_IN_MUTE(0), bits);
16071 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16072 AMP_IN_MUTE(0), bits);
16073 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16074 AMP_IN_MUTE(0), bits);
16075 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16076 AMP_IN_MUTE(0), bits);
16077}
16078
16079static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16080{
16081 unsigned int present;
16082 unsigned char bits;
16083
16084 present = snd_hda_codec_read(codec, 0x1b, 0,
16085 AC_VERB_GET_PIN_SENSE, 0)
16086 & AC_PINSENSE_PRESENCE;
16087 bits = present ? 0 : PIN_OUT;
16088 snd_hda_codec_write(codec, 0x14, 0,
16089 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16090}
16091
16092static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16093{
16094 unsigned int present1, present2;
16095
16096 present1 = snd_hda_codec_read(codec, 0x21, 0,
16097 AC_VERB_GET_PIN_SENSE, 0)
16098 & AC_PINSENSE_PRESENCE;
16099 present2 = snd_hda_codec_read(codec, 0x15, 0,
16100 AC_VERB_GET_PIN_SENSE, 0)
16101 & AC_PINSENSE_PRESENCE;
16102
16103 if (present1 || present2) {
16104 snd_hda_codec_write_cache(codec, 0x14, 0,
16105 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16106 } else {
16107 snd_hda_codec_write_cache(codec, 0x14, 0,
16108 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16109 }
16110}
16111
16112static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16113{
16114 unsigned int present1, present2;
16115
16116 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16117 AC_VERB_GET_PIN_SENSE, 0)
16118 & AC_PINSENSE_PRESENCE;
16119 present2 = snd_hda_codec_read(codec, 0x15, 0,
16120 AC_VERB_GET_PIN_SENSE, 0)
16121 & AC_PINSENSE_PRESENCE;
16122
16123 if (present1 || present2) {
16124 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16125 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16126 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16127 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16128 } else {
16129 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16130 AMP_IN_MUTE(0), 0);
16131 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16132 AMP_IN_MUTE(0), 0);
16133 }
6dda9f4a
KY
16134}
16135
16136static void alc663_m51va_mic_automute(struct hda_codec *codec)
16137{
16138 unsigned int present;
16139
16140 present = snd_hda_codec_read(codec, 0x18, 0,
ea1fb29a
KY
16141 AC_VERB_GET_PIN_SENSE, 0)
16142 & AC_PINSENSE_PRESENCE;
6dda9f4a 16143 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
ea1fb29a 16144 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
6dda9f4a 16145 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
ea1fb29a 16146 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
6dda9f4a 16147 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
ea1fb29a 16148 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
6dda9f4a 16149 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
ea1fb29a 16150 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
6dda9f4a
KY
16151}
16152
16153static void alc663_m51va_unsol_event(struct hda_codec *codec,
16154 unsigned int res)
16155{
16156 switch (res >> 26) {
16157 case ALC880_HP_EVENT:
16158 alc663_m51va_speaker_automute(codec);
16159 break;
16160 case ALC880_MIC_EVENT:
16161 alc663_m51va_mic_automute(codec);
16162 break;
16163 }
16164}
16165
16166static void alc663_m51va_inithook(struct hda_codec *codec)
16167{
16168 alc663_m51va_speaker_automute(codec);
16169 alc663_m51va_mic_automute(codec);
16170}
16171
f1d4e28b
KY
16172/* ***************** Mode1 ******************************/
16173static void alc663_mode1_unsol_event(struct hda_codec *codec,
16174 unsigned int res)
16175{
16176 switch (res >> 26) {
16177 case ALC880_HP_EVENT:
16178 alc663_m51va_speaker_automute(codec);
16179 break;
16180 case ALC880_MIC_EVENT:
16181 alc662_eeepc_mic_automute(codec);
16182 break;
16183 }
16184}
16185
16186static void alc663_mode1_inithook(struct hda_codec *codec)
16187{
16188 alc663_m51va_speaker_automute(codec);
16189 alc662_eeepc_mic_automute(codec);
16190}
16191/* ***************** Mode2 ******************************/
16192static void alc662_mode2_unsol_event(struct hda_codec *codec,
16193 unsigned int res)
16194{
16195 switch (res >> 26) {
16196 case ALC880_HP_EVENT:
16197 alc662_f5z_speaker_automute(codec);
16198 break;
16199 case ALC880_MIC_EVENT:
16200 alc662_eeepc_mic_automute(codec);
16201 break;
16202 }
16203}
16204
16205static void alc662_mode2_inithook(struct hda_codec *codec)
16206{
16207 alc662_f5z_speaker_automute(codec);
16208 alc662_eeepc_mic_automute(codec);
16209}
16210/* ***************** Mode3 ******************************/
16211static void alc663_mode3_unsol_event(struct hda_codec *codec,
16212 unsigned int res)
16213{
16214 switch (res >> 26) {
16215 case ALC880_HP_EVENT:
16216 alc663_two_hp_m1_speaker_automute(codec);
16217 break;
16218 case ALC880_MIC_EVENT:
16219 alc662_eeepc_mic_automute(codec);
16220 break;
16221 }
16222}
16223
16224static void alc663_mode3_inithook(struct hda_codec *codec)
16225{
16226 alc663_two_hp_m1_speaker_automute(codec);
16227 alc662_eeepc_mic_automute(codec);
16228}
16229/* ***************** Mode4 ******************************/
16230static void alc663_mode4_unsol_event(struct hda_codec *codec,
16231 unsigned int res)
16232{
16233 switch (res >> 26) {
16234 case ALC880_HP_EVENT:
16235 alc663_21jd_two_speaker_automute(codec);
16236 break;
16237 case ALC880_MIC_EVENT:
16238 alc662_eeepc_mic_automute(codec);
16239 break;
16240 }
16241}
16242
16243static void alc663_mode4_inithook(struct hda_codec *codec)
16244{
16245 alc663_21jd_two_speaker_automute(codec);
16246 alc662_eeepc_mic_automute(codec);
16247}
16248/* ***************** Mode5 ******************************/
16249static void alc663_mode5_unsol_event(struct hda_codec *codec,
16250 unsigned int res)
16251{
16252 switch (res >> 26) {
16253 case ALC880_HP_EVENT:
16254 alc663_15jd_two_speaker_automute(codec);
16255 break;
16256 case ALC880_MIC_EVENT:
16257 alc662_eeepc_mic_automute(codec);
16258 break;
16259 }
16260}
16261
16262static void alc663_mode5_inithook(struct hda_codec *codec)
16263{
16264 alc663_15jd_two_speaker_automute(codec);
16265 alc662_eeepc_mic_automute(codec);
16266}
16267/* ***************** Mode6 ******************************/
16268static void alc663_mode6_unsol_event(struct hda_codec *codec,
16269 unsigned int res)
16270{
16271 switch (res >> 26) {
16272 case ALC880_HP_EVENT:
16273 alc663_two_hp_m2_speaker_automute(codec);
16274 break;
16275 case ALC880_MIC_EVENT:
16276 alc662_eeepc_mic_automute(codec);
16277 break;
16278 }
16279}
16280
16281static void alc663_mode6_inithook(struct hda_codec *codec)
16282{
16283 alc663_two_hp_m2_speaker_automute(codec);
16284 alc662_eeepc_mic_automute(codec);
16285}
16286
6dda9f4a
KY
16287static void alc663_g71v_hp_automute(struct hda_codec *codec)
16288{
16289 unsigned int present;
16290 unsigned char bits;
16291
16292 present = snd_hda_codec_read(codec, 0x21, 0,
16293 AC_VERB_GET_PIN_SENSE, 0)
16294 & AC_PINSENSE_PRESENCE;
16295 bits = present ? HDA_AMP_MUTE : 0;
16296 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16297 HDA_AMP_MUTE, bits);
16298 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16299 HDA_AMP_MUTE, bits);
16300}
16301
16302static void alc663_g71v_front_automute(struct hda_codec *codec)
16303{
16304 unsigned int present;
16305 unsigned char bits;
16306
16307 present = snd_hda_codec_read(codec, 0x15, 0,
16308 AC_VERB_GET_PIN_SENSE, 0)
16309 & AC_PINSENSE_PRESENCE;
16310 bits = present ? HDA_AMP_MUTE : 0;
16311 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16312 HDA_AMP_MUTE, bits);
16313}
16314
16315static void alc663_g71v_unsol_event(struct hda_codec *codec,
16316 unsigned int res)
16317{
16318 switch (res >> 26) {
16319 case ALC880_HP_EVENT:
16320 alc663_g71v_hp_automute(codec);
16321 break;
16322 case ALC880_FRONT_EVENT:
16323 alc663_g71v_front_automute(codec);
16324 break;
16325 case ALC880_MIC_EVENT:
16326 alc662_eeepc_mic_automute(codec);
16327 break;
16328 }
16329}
16330
16331static void alc663_g71v_inithook(struct hda_codec *codec)
16332{
16333 alc663_g71v_front_automute(codec);
16334 alc663_g71v_hp_automute(codec);
16335 alc662_eeepc_mic_automute(codec);
16336}
16337
16338static void alc663_g50v_unsol_event(struct hda_codec *codec,
16339 unsigned int res)
16340{
16341 switch (res >> 26) {
16342 case ALC880_HP_EVENT:
16343 alc663_m51va_speaker_automute(codec);
16344 break;
16345 case ALC880_MIC_EVENT:
16346 alc662_eeepc_mic_automute(codec);
16347 break;
16348 }
16349}
16350
16351static void alc663_g50v_inithook(struct hda_codec *codec)
16352{
16353 alc663_m51va_speaker_automute(codec);
16354 alc662_eeepc_mic_automute(codec);
16355}
16356
f1d4e28b
KY
16357static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16358 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
42171c17 16359 ALC262_HIPPO_MASTER_SWITCH,
f1d4e28b
KY
16360
16361 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16362 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16363 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16364
16365 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16366 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16367 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16368 { } /* end */
16369};
16370
9541ba1d
CP
16371static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16372 /* Master Playback automatically created from Speaker and Headphone */
16373 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16374 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16375 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16376 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16377
16378 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16379 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16380 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16381
16382 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16383 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16384 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16385 { } /* end */
16386};
16387
cb53c626
TI
16388#ifdef CONFIG_SND_HDA_POWER_SAVE
16389#define alc662_loopbacks alc880_loopbacks
16390#endif
16391
bc9f98a9 16392
def319f9 16393/* pcm configuration: identical with ALC880 */
bc9f98a9
KY
16394#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16395#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16396#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16397#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16398
16399/*
16400 * configuration and preset
16401 */
16402static const char *alc662_models[ALC662_MODEL_LAST] = {
16403 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16404 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16405 [ALC662_3ST_6ch] = "3stack-6ch",
16406 [ALC662_5ST_DIG] = "6stack-dig",
16407 [ALC662_LENOVO_101E] = "lenovo-101e",
b995d76d 16408 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
8c427226 16409 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
f1d4e28b 16410 [ALC662_ECS] = "ecs",
6dda9f4a
KY
16411 [ALC663_ASUS_M51VA] = "m51va",
16412 [ALC663_ASUS_G71V] = "g71v",
16413 [ALC663_ASUS_H13] = "h13",
16414 [ALC663_ASUS_G50V] = "g50v",
f1d4e28b
KY
16415 [ALC663_ASUS_MODE1] = "asus-mode1",
16416 [ALC662_ASUS_MODE2] = "asus-mode2",
16417 [ALC663_ASUS_MODE3] = "asus-mode3",
16418 [ALC663_ASUS_MODE4] = "asus-mode4",
16419 [ALC663_ASUS_MODE5] = "asus-mode5",
16420 [ALC663_ASUS_MODE6] = "asus-mode6",
01f2bd48
TI
16421 [ALC272_DELL] = "dell",
16422 [ALC272_DELL_ZM1] = "dell-zm1",
9541ba1d 16423 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
bc9f98a9
KY
16424 [ALC662_AUTO] = "auto",
16425};
16426
16427static struct snd_pci_quirk alc662_cfg_tbl[] = {
dea0a509 16428 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
622e84cd
KY
16429 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16430 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
f1d4e28b 16431 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
dea0a509
TI
16432 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16433 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
f1d4e28b 16434 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
dea0a509 16435 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
f1d4e28b 16436 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
f1d4e28b 16437 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
dea0a509
TI
16438 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16439 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16440 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16441 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16442 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
622e84cd
KY
16443 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16444 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16445 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
f1d4e28b 16446 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
dea0a509
TI
16447 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16448 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16449 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
622e84cd 16450 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
f1d4e28b 16451 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
dea0a509
TI
16452 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
16453 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
16454 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
f1d4e28b 16455 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
f1d4e28b 16456 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
622e84cd
KY
16457 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16458 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16459 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
dea0a509
TI
16460 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16461 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16462 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
622e84cd 16463 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
dea0a509
TI
16464 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16465 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
622e84cd 16466 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
dea0a509
TI
16467 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
16468 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
16469 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16470 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16471 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
622e84cd 16472 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
dea0a509 16473 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
f1d4e28b 16474 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
dea0a509
TI
16475 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
16476 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
16477 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
16478 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
95fe5f2c
HRK
16479 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16480 ALC662_3ST_6ch_DIG),
9541ba1d 16481 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
cb55974c
HRK
16482 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16483 ALC662_3ST_6ch_DIG),
19c009aa 16484 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
5bd3729f 16485 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
dea0a509 16486 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
238713d4 16487 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
19c009aa 16488 ALC662_3ST_6ch_DIG),
dea0a509
TI
16489 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16490 ALC663_ASUS_H13),
bc9f98a9
KY
16491 {}
16492};
16493
16494static struct alc_config_preset alc662_presets[] = {
16495 [ALC662_3ST_2ch_DIG] = {
f9e336f6 16496 .mixers = { alc662_3ST_2ch_mixer },
bc9f98a9
KY
16497 .init_verbs = { alc662_init_verbs },
16498 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16499 .dac_nids = alc662_dac_nids,
16500 .dig_out_nid = ALC662_DIGOUT_NID,
bc9f98a9
KY
16501 .dig_in_nid = ALC662_DIGIN_NID,
16502 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16503 .channel_mode = alc662_3ST_2ch_modes,
16504 .input_mux = &alc662_capture_source,
16505 },
16506 [ALC662_3ST_6ch_DIG] = {
f9e336f6 16507 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
bc9f98a9
KY
16508 .init_verbs = { alc662_init_verbs },
16509 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16510 .dac_nids = alc662_dac_nids,
16511 .dig_out_nid = ALC662_DIGOUT_NID,
bc9f98a9
KY
16512 .dig_in_nid = ALC662_DIGIN_NID,
16513 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16514 .channel_mode = alc662_3ST_6ch_modes,
16515 .need_dac_fix = 1,
16516 .input_mux = &alc662_capture_source,
f12ab1e0 16517 },
bc9f98a9 16518 [ALC662_3ST_6ch] = {
f9e336f6 16519 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
bc9f98a9
KY
16520 .init_verbs = { alc662_init_verbs },
16521 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16522 .dac_nids = alc662_dac_nids,
bc9f98a9
KY
16523 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16524 .channel_mode = alc662_3ST_6ch_modes,
16525 .need_dac_fix = 1,
16526 .input_mux = &alc662_capture_source,
f12ab1e0 16527 },
bc9f98a9 16528 [ALC662_5ST_DIG] = {
f9e336f6 16529 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
bc9f98a9
KY
16530 .init_verbs = { alc662_init_verbs },
16531 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16532 .dac_nids = alc662_dac_nids,
16533 .dig_out_nid = ALC662_DIGOUT_NID,
bc9f98a9
KY
16534 .dig_in_nid = ALC662_DIGIN_NID,
16535 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16536 .channel_mode = alc662_5stack_modes,
16537 .input_mux = &alc662_capture_source,
16538 },
16539 [ALC662_LENOVO_101E] = {
f9e336f6 16540 .mixers = { alc662_lenovo_101e_mixer },
bc9f98a9
KY
16541 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16542 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16543 .dac_nids = alc662_dac_nids,
bc9f98a9
KY
16544 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16545 .channel_mode = alc662_3ST_2ch_modes,
16546 .input_mux = &alc662_lenovo_101e_capture_source,
16547 .unsol_event = alc662_lenovo_101e_unsol_event,
16548 .init_hook = alc662_lenovo_101e_all_automute,
16549 },
291702f0 16550 [ALC662_ASUS_EEEPC_P701] = {
f9e336f6 16551 .mixers = { alc662_eeepc_p701_mixer },
291702f0
KY
16552 .init_verbs = { alc662_init_verbs,
16553 alc662_eeepc_sue_init_verbs },
16554 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16555 .dac_nids = alc662_dac_nids,
291702f0
KY
16556 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16557 .channel_mode = alc662_3ST_2ch_modes,
16558 .input_mux = &alc662_eeepc_capture_source,
16559 .unsol_event = alc662_eeepc_unsol_event,
16560 .init_hook = alc662_eeepc_inithook,
16561 },
8c427226 16562 [ALC662_ASUS_EEEPC_EP20] = {
f9e336f6 16563 .mixers = { alc662_eeepc_ep20_mixer,
8c427226
KY
16564 alc662_chmode_mixer },
16565 .init_verbs = { alc662_init_verbs,
16566 alc662_eeepc_ep20_sue_init_verbs },
16567 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16568 .dac_nids = alc662_dac_nids,
8c427226
KY
16569 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16570 .channel_mode = alc662_3ST_6ch_modes,
16571 .input_mux = &alc662_lenovo_101e_capture_source,
42171c17 16572 .unsol_event = alc662_eeepc_unsol_event,
8c427226
KY
16573 .init_hook = alc662_eeepc_ep20_inithook,
16574 },
f1d4e28b 16575 [ALC662_ECS] = {
f9e336f6 16576 .mixers = { alc662_ecs_mixer },
f1d4e28b
KY
16577 .init_verbs = { alc662_init_verbs,
16578 alc662_ecs_init_verbs },
16579 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16580 .dac_nids = alc662_dac_nids,
16581 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16582 .channel_mode = alc662_3ST_2ch_modes,
16583 .input_mux = &alc662_eeepc_capture_source,
16584 .unsol_event = alc662_eeepc_unsol_event,
16585 .init_hook = alc662_eeepc_inithook,
16586 },
6dda9f4a 16587 [ALC663_ASUS_M51VA] = {
f9e336f6 16588 .mixers = { alc663_m51va_mixer },
6dda9f4a
KY
16589 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16590 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16591 .dac_nids = alc662_dac_nids,
16592 .dig_out_nid = ALC662_DIGOUT_NID,
16593 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16594 .channel_mode = alc662_3ST_2ch_modes,
16595 .input_mux = &alc663_m51va_capture_source,
16596 .unsol_event = alc663_m51va_unsol_event,
16597 .init_hook = alc663_m51va_inithook,
16598 },
16599 [ALC663_ASUS_G71V] = {
f9e336f6 16600 .mixers = { alc663_g71v_mixer },
6dda9f4a
KY
16601 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16602 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16603 .dac_nids = alc662_dac_nids,
16604 .dig_out_nid = ALC662_DIGOUT_NID,
16605 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16606 .channel_mode = alc662_3ST_2ch_modes,
16607 .input_mux = &alc662_eeepc_capture_source,
16608 .unsol_event = alc663_g71v_unsol_event,
16609 .init_hook = alc663_g71v_inithook,
16610 },
16611 [ALC663_ASUS_H13] = {
f9e336f6 16612 .mixers = { alc663_m51va_mixer },
6dda9f4a
KY
16613 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16614 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16615 .dac_nids = alc662_dac_nids,
16616 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16617 .channel_mode = alc662_3ST_2ch_modes,
16618 .input_mux = &alc663_m51va_capture_source,
16619 .unsol_event = alc663_m51va_unsol_event,
16620 .init_hook = alc663_m51va_inithook,
16621 },
16622 [ALC663_ASUS_G50V] = {
f9e336f6 16623 .mixers = { alc663_g50v_mixer },
6dda9f4a
KY
16624 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16625 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16626 .dac_nids = alc662_dac_nids,
16627 .dig_out_nid = ALC662_DIGOUT_NID,
16628 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16629 .channel_mode = alc662_3ST_6ch_modes,
16630 .input_mux = &alc663_capture_source,
16631 .unsol_event = alc663_g50v_unsol_event,
16632 .init_hook = alc663_g50v_inithook,
16633 },
f1d4e28b 16634 [ALC663_ASUS_MODE1] = {
f9e336f6
TI
16635 .mixers = { alc663_m51va_mixer },
16636 .cap_mixer = alc662_auto_capture_mixer,
f1d4e28b
KY
16637 .init_verbs = { alc662_init_verbs,
16638 alc663_21jd_amic_init_verbs },
16639 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16640 .hp_nid = 0x03,
16641 .dac_nids = alc662_dac_nids,
16642 .dig_out_nid = ALC662_DIGOUT_NID,
16643 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16644 .channel_mode = alc662_3ST_2ch_modes,
16645 .input_mux = &alc662_eeepc_capture_source,
16646 .unsol_event = alc663_mode1_unsol_event,
16647 .init_hook = alc663_mode1_inithook,
16648 },
16649 [ALC662_ASUS_MODE2] = {
f9e336f6
TI
16650 .mixers = { alc662_1bjd_mixer },
16651 .cap_mixer = alc662_auto_capture_mixer,
f1d4e28b
KY
16652 .init_verbs = { alc662_init_verbs,
16653 alc662_1bjd_amic_init_verbs },
16654 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16655 .dac_nids = alc662_dac_nids,
16656 .dig_out_nid = ALC662_DIGOUT_NID,
16657 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16658 .channel_mode = alc662_3ST_2ch_modes,
16659 .input_mux = &alc662_eeepc_capture_source,
16660 .unsol_event = alc662_mode2_unsol_event,
16661 .init_hook = alc662_mode2_inithook,
16662 },
16663 [ALC663_ASUS_MODE3] = {
f9e336f6
TI
16664 .mixers = { alc663_two_hp_m1_mixer },
16665 .cap_mixer = alc662_auto_capture_mixer,
f1d4e28b
KY
16666 .init_verbs = { alc662_init_verbs,
16667 alc663_two_hp_amic_m1_init_verbs },
16668 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16669 .hp_nid = 0x03,
16670 .dac_nids = alc662_dac_nids,
16671 .dig_out_nid = ALC662_DIGOUT_NID,
16672 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16673 .channel_mode = alc662_3ST_2ch_modes,
16674 .input_mux = &alc662_eeepc_capture_source,
16675 .unsol_event = alc663_mode3_unsol_event,
16676 .init_hook = alc663_mode3_inithook,
16677 },
16678 [ALC663_ASUS_MODE4] = {
f9e336f6
TI
16679 .mixers = { alc663_asus_21jd_clfe_mixer },
16680 .cap_mixer = alc662_auto_capture_mixer,
f1d4e28b
KY
16681 .init_verbs = { alc662_init_verbs,
16682 alc663_21jd_amic_init_verbs},
16683 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16684 .hp_nid = 0x03,
16685 .dac_nids = alc662_dac_nids,
16686 .dig_out_nid = ALC662_DIGOUT_NID,
16687 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16688 .channel_mode = alc662_3ST_2ch_modes,
16689 .input_mux = &alc662_eeepc_capture_source,
16690 .unsol_event = alc663_mode4_unsol_event,
16691 .init_hook = alc663_mode4_inithook,
16692 },
16693 [ALC663_ASUS_MODE5] = {
f9e336f6
TI
16694 .mixers = { alc663_asus_15jd_clfe_mixer },
16695 .cap_mixer = alc662_auto_capture_mixer,
f1d4e28b
KY
16696 .init_verbs = { alc662_init_verbs,
16697 alc663_15jd_amic_init_verbs },
16698 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16699 .hp_nid = 0x03,
16700 .dac_nids = alc662_dac_nids,
16701 .dig_out_nid = ALC662_DIGOUT_NID,
16702 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16703 .channel_mode = alc662_3ST_2ch_modes,
16704 .input_mux = &alc662_eeepc_capture_source,
16705 .unsol_event = alc663_mode5_unsol_event,
16706 .init_hook = alc663_mode5_inithook,
16707 },
16708 [ALC663_ASUS_MODE6] = {
f9e336f6
TI
16709 .mixers = { alc663_two_hp_m2_mixer },
16710 .cap_mixer = alc662_auto_capture_mixer,
f1d4e28b
KY
16711 .init_verbs = { alc662_init_verbs,
16712 alc663_two_hp_amic_m2_init_verbs },
16713 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16714 .hp_nid = 0x03,
16715 .dac_nids = alc662_dac_nids,
16716 .dig_out_nid = ALC662_DIGOUT_NID,
16717 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16718 .channel_mode = alc662_3ST_2ch_modes,
16719 .input_mux = &alc662_eeepc_capture_source,
16720 .unsol_event = alc663_mode6_unsol_event,
16721 .init_hook = alc663_mode6_inithook,
16722 },
622e84cd
KY
16723 [ALC272_DELL] = {
16724 .mixers = { alc663_m51va_mixer },
16725 .cap_mixer = alc272_auto_capture_mixer,
16726 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16727 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16728 .dac_nids = alc662_dac_nids,
16729 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16730 .adc_nids = alc272_adc_nids,
16731 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16732 .capsrc_nids = alc272_capsrc_nids,
16733 .channel_mode = alc662_3ST_2ch_modes,
16734 .input_mux = &alc663_m51va_capture_source,
16735 .unsol_event = alc663_m51va_unsol_event,
16736 .init_hook = alc663_m51va_inithook,
16737 },
16738 [ALC272_DELL_ZM1] = {
16739 .mixers = { alc663_m51va_mixer },
16740 .cap_mixer = alc662_auto_capture_mixer,
16741 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16742 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16743 .dac_nids = alc662_dac_nids,
16744 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16745 .adc_nids = alc662_adc_nids,
16746 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
16747 .capsrc_nids = alc662_capsrc_nids,
16748 .channel_mode = alc662_3ST_2ch_modes,
16749 .input_mux = &alc663_m51va_capture_source,
16750 .unsol_event = alc663_m51va_unsol_event,
16751 .init_hook = alc663_m51va_inithook,
16752 },
9541ba1d
CP
16753 [ALC272_SAMSUNG_NC10] = {
16754 .mixers = { alc272_nc10_mixer },
16755 .init_verbs = { alc662_init_verbs,
16756 alc663_21jd_amic_init_verbs },
16757 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16758 .dac_nids = alc272_dac_nids,
16759 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16760 .channel_mode = alc662_3ST_2ch_modes,
16761 .input_mux = &alc272_nc10_capture_source,
16762 .unsol_event = alc663_mode4_unsol_event,
16763 .init_hook = alc663_mode4_inithook,
16764 },
bc9f98a9
KY
16765};
16766
16767
16768/*
16769 * BIOS auto configuration
16770 */
16771
16772/* add playback controls from the parsed DAC table */
16773static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16774 const struct auto_pin_cfg *cfg)
16775{
16776 char name[32];
16777 static const char *chname[4] = {
16778 "Front", "Surround", NULL /*CLFE*/, "Side"
16779 };
16780 hda_nid_t nid;
16781 int i, err;
16782
16783 for (i = 0; i < cfg->line_outs; i++) {
16784 if (!spec->multiout.dac_nids[i])
16785 continue;
b60dd394 16786 nid = alc880_idx_to_dac(i);
bc9f98a9
KY
16787 if (i == 2) {
16788 /* Center/LFE */
16789 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16790 "Center Playback Volume",
f12ab1e0
TI
16791 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16792 HDA_OUTPUT));
bc9f98a9
KY
16793 if (err < 0)
16794 return err;
16795 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16796 "LFE Playback Volume",
f12ab1e0
TI
16797 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16798 HDA_OUTPUT));
bc9f98a9
KY
16799 if (err < 0)
16800 return err;
b69ce01a 16801 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
bc9f98a9 16802 "Center Playback Switch",
b69ce01a 16803 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
f12ab1e0 16804 HDA_INPUT));
bc9f98a9
KY
16805 if (err < 0)
16806 return err;
b69ce01a 16807 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
bc9f98a9 16808 "LFE Playback Switch",
b69ce01a 16809 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
f12ab1e0 16810 HDA_INPUT));
bc9f98a9
KY
16811 if (err < 0)
16812 return err;
16813 } else {
16814 sprintf(name, "%s Playback Volume", chname[i]);
16815 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
f12ab1e0
TI
16816 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16817 HDA_OUTPUT));
bc9f98a9
KY
16818 if (err < 0)
16819 return err;
16820 sprintf(name, "%s Playback Switch", chname[i]);
b69ce01a
HRK
16821 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16822 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16823 3, 0, HDA_INPUT));
bc9f98a9
KY
16824 if (err < 0)
16825 return err;
16826 }
16827 }
16828 return 0;
16829}
16830
16831/* add playback controls for speaker and HP outputs */
16832static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16833 const char *pfx)
16834{
16835 hda_nid_t nid;
16836 int err;
16837 char name[32];
16838
16839 if (!pin)
16840 return 0;
16841
24fb9173
TI
16842 if (pin == 0x17) {
16843 /* ALC663 has a mono output pin on 0x17 */
16844 sprintf(name, "%s Playback Switch", pfx);
16845 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16846 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16847 return err;
16848 }
16849
bc9f98a9
KY
16850 if (alc880_is_fixed_pin(pin)) {
16851 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
939778ae 16852 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
bc9f98a9
KY
16853 /* specify the DAC as the extra output */
16854 if (!spec->multiout.hp_nid)
16855 spec->multiout.hp_nid = nid;
16856 else
16857 spec->multiout.extra_out_nid[0] = nid;
16858 /* control HP volume/switch on the output mixer amp */
16859 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16860 sprintf(name, "%s Playback Volume", pfx);
16861 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16862 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16863 if (err < 0)
16864 return err;
16865 sprintf(name, "%s Playback Switch", pfx);
16866 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16867 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16868 if (err < 0)
16869 return err;
16870 } else if (alc880_is_multi_pin(pin)) {
16871 /* set manual connection */
16872 /* we have only a switch on HP-out PIN */
16873 sprintf(name, "%s Playback Switch", pfx);
16874 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16875 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16876 if (err < 0)
16877 return err;
16878 }
16879 return 0;
16880}
16881
2d864c49
TI
16882/* return the index of the src widget from the connection list of the nid.
16883 * return -1 if not found
16884 */
16885static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
16886 hda_nid_t src)
16887{
16888 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
16889 int i, conns;
16890
16891 conns = snd_hda_get_connections(codec, nid, conn_list,
16892 ARRAY_SIZE(conn_list));
16893 if (conns < 0)
16894 return -1;
16895 for (i = 0; i < conns; i++)
16896 if (conn_list[i] == src)
16897 return i;
16898 return -1;
16899}
16900
16901static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
16902{
1327a32b 16903 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2d864c49
TI
16904 return (pincap & AC_PINCAP_IN) != 0;
16905}
16906
bc9f98a9 16907/* create playback/capture controls for input pins */
2d864c49 16908static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
bc9f98a9
KY
16909 const struct auto_pin_cfg *cfg)
16910{
2d864c49 16911 struct alc_spec *spec = codec->spec;
61b9b9b1 16912 struct hda_input_mux *imux = &spec->private_imux[0];
bc9f98a9
KY
16913 int i, err, idx;
16914
16915 for (i = 0; i < AUTO_PIN_LAST; i++) {
2d864c49
TI
16916 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
16917 idx = alc662_input_pin_idx(codec, 0x0b,
16918 cfg->input_pins[i]);
16919 if (idx >= 0) {
16920 err = new_analog_input(spec, cfg->input_pins[i],
16921 auto_pin_cfg_labels[i],
16922 idx, 0x0b);
16923 if (err < 0)
16924 return err;
16925 }
16926 idx = alc662_input_pin_idx(codec, 0x22,
16927 cfg->input_pins[i]);
16928 if (idx >= 0) {
16929 imux->items[imux->num_items].label =
16930 auto_pin_cfg_labels[i];
16931 imux->items[imux->num_items].index = idx;
16932 imux->num_items++;
16933 }
bc9f98a9
KY
16934 }
16935 }
16936 return 0;
16937}
16938
16939static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16940 hda_nid_t nid, int pin_type,
16941 int dac_idx)
16942{
f6c7e546 16943 alc_set_pin_output(codec, nid, pin_type);
bc9f98a9
KY
16944 /* need the manual connection? */
16945 if (alc880_is_multi_pin(nid)) {
16946 struct alc_spec *spec = codec->spec;
16947 int idx = alc880_multi_pin_idx(nid);
16948 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16949 AC_VERB_SET_CONNECT_SEL,
16950 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16951 }
16952}
16953
16954static void alc662_auto_init_multi_out(struct hda_codec *codec)
16955{
16956 struct alc_spec *spec = codec->spec;
16957 int i;
16958
16959 for (i = 0; i <= HDA_SIDE; i++) {
16960 hda_nid_t nid = spec->autocfg.line_out_pins[i];
baba8ee9 16961 int pin_type = get_pin_type(spec->autocfg.line_out_type);
bc9f98a9 16962 if (nid)
baba8ee9 16963 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
bc9f98a9
KY
16964 i);
16965 }
16966}
16967
16968static void alc662_auto_init_hp_out(struct hda_codec *codec)
16969{
16970 struct alc_spec *spec = codec->spec;
16971 hda_nid_t pin;
16972
16973 pin = spec->autocfg.hp_pins[0];
16974 if (pin) /* connect to front */
16975 /* use dac 0 */
16976 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
f6c7e546
TI
16977 pin = spec->autocfg.speaker_pins[0];
16978 if (pin)
16979 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
bc9f98a9
KY
16980}
16981
bc9f98a9
KY
16982#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16983
16984static void alc662_auto_init_analog_input(struct hda_codec *codec)
16985{
16986 struct alc_spec *spec = codec->spec;
16987 int i;
16988
16989 for (i = 0; i < AUTO_PIN_LAST; i++) {
16990 hda_nid_t nid = spec->autocfg.input_pins[i];
2d864c49 16991 if (alc662_is_input_pin(codec, nid)) {
23f0c048 16992 alc_set_input_pin(codec, nid, i);
52ca15b7 16993 if (nid != ALC662_PIN_CD_NID &&
e82c025b 16994 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
bc9f98a9
KY
16995 snd_hda_codec_write(codec, nid, 0,
16996 AC_VERB_SET_AMP_GAIN_MUTE,
16997 AMP_OUT_MUTE);
16998 }
16999 }
17000}
17001
f511b01c
TI
17002#define alc662_auto_init_input_src alc882_auto_init_input_src
17003
bc9f98a9
KY
17004static int alc662_parse_auto_config(struct hda_codec *codec)
17005{
17006 struct alc_spec *spec = codec->spec;
17007 int err;
17008 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17009
17010 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17011 alc662_ignore);
17012 if (err < 0)
17013 return err;
17014 if (!spec->autocfg.line_outs)
17015 return 0; /* can't find valid BIOS pin config */
17016
f12ab1e0
TI
17017 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17018 if (err < 0)
17019 return err;
17020 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17021 if (err < 0)
17022 return err;
17023 err = alc662_auto_create_extra_out(spec,
17024 spec->autocfg.speaker_pins[0],
17025 "Speaker");
17026 if (err < 0)
17027 return err;
17028 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17029 "Headphone");
17030 if (err < 0)
17031 return err;
2d864c49 17032 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
f12ab1e0 17033 if (err < 0)
bc9f98a9
KY
17034 return err;
17035
17036 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17037
0852d7a6 17038 if (spec->autocfg.dig_outs)
bc9f98a9
KY
17039 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17040
603c4019 17041 if (spec->kctls.list)
d88897ea 17042 add_mixer(spec, spec->kctls.list);
bc9f98a9
KY
17043
17044 spec->num_mux_defs = 1;
61b9b9b1 17045 spec->input_mux = &spec->private_imux[0];
ea1fb29a 17046
d88897ea 17047 add_verb(spec, alc662_auto_init_verbs);
24fb9173 17048 if (codec->vendor_id == 0x10ec0663)
d88897ea 17049 add_verb(spec, alc663_auto_init_verbs);
ee979a14
TI
17050
17051 err = alc_auto_add_mic_boost(codec);
17052 if (err < 0)
17053 return err;
17054
4a79ba34
TI
17055 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17056
8c87286f 17057 return 1;
bc9f98a9
KY
17058}
17059
17060/* additional initialization for auto-configuration model */
17061static void alc662_auto_init(struct hda_codec *codec)
17062{
f6c7e546 17063 struct alc_spec *spec = codec->spec;
bc9f98a9
KY
17064 alc662_auto_init_multi_out(codec);
17065 alc662_auto_init_hp_out(codec);
17066 alc662_auto_init_analog_input(codec);
f511b01c 17067 alc662_auto_init_input_src(codec);
f6c7e546 17068 if (spec->unsol_event)
7fb0d78f 17069 alc_inithook(codec);
bc9f98a9
KY
17070}
17071
17072static int patch_alc662(struct hda_codec *codec)
17073{
17074 struct alc_spec *spec;
17075 int err, board_config;
17076
17077 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17078 if (!spec)
17079 return -ENOMEM;
17080
17081 codec->spec = spec;
17082
2c3bf9ab
TI
17083 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17084
bc9f98a9
KY
17085 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17086 alc662_models,
17087 alc662_cfg_tbl);
17088 if (board_config < 0) {
6c627f39
TI
17089 printk(KERN_INFO "hda_codec: Unknown model for %s, "
17090 "trying auto-probe from BIOS...\n", codec->chip_name);
bc9f98a9
KY
17091 board_config = ALC662_AUTO;
17092 }
17093
17094 if (board_config == ALC662_AUTO) {
17095 /* automatic parse from the BIOS config */
17096 err = alc662_parse_auto_config(codec);
17097 if (err < 0) {
17098 alc_free(codec);
17099 return err;
8c87286f 17100 } else if (!err) {
bc9f98a9
KY
17101 printk(KERN_INFO
17102 "hda_codec: Cannot set up configuration "
17103 "from BIOS. Using base mode...\n");
17104 board_config = ALC662_3ST_2ch_DIG;
17105 }
17106 }
17107
680cd536
KK
17108 err = snd_hda_attach_beep_device(codec, 0x1);
17109 if (err < 0) {
17110 alc_free(codec);
17111 return err;
17112 }
17113
bc9f98a9
KY
17114 if (board_config != ALC662_AUTO)
17115 setup_preset(spec, &alc662_presets[board_config]);
17116
bc9f98a9
KY
17117 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17118 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17119
bc9f98a9
KY
17120 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17121 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17122
e1406348
TI
17123 spec->adc_nids = alc662_adc_nids;
17124 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17125 spec->capsrc_nids = alc662_capsrc_nids;
bc9f98a9 17126
f9e336f6
TI
17127 if (!spec->cap_mixer)
17128 set_capture_mixer(spec);
b9591448
TI
17129 if (codec->vendor_id == 0x10ec0662)
17130 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17131 else
17132 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
f9e336f6 17133
2134ea4f
TI
17134 spec->vmaster_nid = 0x02;
17135
bc9f98a9
KY
17136 codec->patch_ops = alc_patch_ops;
17137 if (board_config == ALC662_AUTO)
17138 spec->init_hook = alc662_auto_init;
cb53c626
TI
17139#ifdef CONFIG_SND_HDA_POWER_SAVE
17140 if (!spec->loopback.amplist)
17141 spec->loopback.amplist = alc662_loopbacks;
17142#endif
daead538 17143 codec->proc_widget_hook = print_realtek_coef;
bc9f98a9
KY
17144
17145 return 0;
17146}
17147
1da177e4
LT
17148/*
17149 * patch entries
17150 */
1289e9e8 17151static struct hda_codec_preset snd_hda_preset_realtek[] = {
1da177e4 17152 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
df694daa 17153 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
f6a92248 17154 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
a361d84b 17155 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
f6a92248 17156 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
01afd41f 17157 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
f32610ed 17158 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
bc9f98a9 17159 .patch = patch_alc861 },
f32610ed
JS
17160 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17161 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17162 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
bc9f98a9 17163 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
4953550a 17164 .patch = patch_alc882 },
bc9f98a9
KY
17165 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17166 .patch = patch_alc662 },
6dda9f4a 17167 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
f32610ed 17168 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
1da177e4 17169 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
4953550a 17170 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
669faba2 17171 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
4953550a 17172 .patch = patch_alc882 },
cb308f97 17173 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
4953550a 17174 .patch = patch_alc882 },
df694daa 17175 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
4953550a 17176 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
4442608d 17177 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
4953550a
TI
17178 .patch = patch_alc882 },
17179 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17180 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
1da177e4
LT
17181 {} /* terminator */
17182};
1289e9e8
TI
17183
17184MODULE_ALIAS("snd-hda-codec-id:10ec*");
17185
17186MODULE_LICENSE("GPL");
17187MODULE_DESCRIPTION("Realtek HD-audio codec");
17188
17189static struct hda_codec_preset_list realtek_list = {
17190 .preset = snd_hda_preset_realtek,
17191 .owner = THIS_MODULE,
17192};
17193
17194static int __init patch_realtek_init(void)
17195{
17196 return snd_hda_add_codec_preset(&realtek_list);
17197}
17198
17199static void __exit patch_realtek_exit(void)
17200{
17201 snd_hda_delete_codec_preset(&realtek_list);
17202}
17203
17204module_init(patch_realtek_init)
17205module_exit(patch_realtek_exit)