]>
Commit | Line | Data |
---|---|---|
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" | |
3c9a3203 | 33 | #include "hda_patch.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 */ | |
41 | enum { | |
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 */ | |
72 | enum { | |
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, | |
7cf51e48 JW |
81 | #ifdef CONFIG_SND_DEBUG |
82 | ALC260_TEST, | |
83 | #endif | |
df694daa | 84 | ALC260_AUTO, |
16ded525 | 85 | ALC260_MODEL_LAST /* last tag */ |
1da177e4 LT |
86 | }; |
87 | ||
df694daa KY |
88 | /* ALC262 models */ |
89 | enum { | |
90 | ALC262_BASIC, | |
ccc656ce KY |
91 | ALC262_HIPPO, |
92 | ALC262_HIPPO_1, | |
834be88d | 93 | ALC262_FUJITSU, |
9c7f852e | 94 | ALC262_HP_BPC, |
cd7509a4 KY |
95 | ALC262_HP_BPC_D7000_WL, |
96 | ALC262_HP_BPC_D7000_WF, | |
66d2a9d6 | 97 | ALC262_HP_TC_T5735, |
8c427226 | 98 | ALC262_HP_RP5700, |
304dcaac | 99 | ALC262_BENQ_ED8, |
272a527c | 100 | ALC262_SONY_ASSAMD, |
83c34218 | 101 | ALC262_BENQ_T31, |
f651b50b | 102 | ALC262_ULTRA, |
0e31daf7 | 103 | ALC262_LENOVO_3000, |
e8f9ae2a | 104 | ALC262_NEC, |
4e555fe5 | 105 | ALC262_TOSHIBA_S06, |
9f99a638 | 106 | ALC262_TOSHIBA_RX1, |
df694daa KY |
107 | ALC262_AUTO, |
108 | ALC262_MODEL_LAST /* last tag */ | |
109 | }; | |
110 | ||
a361d84b KY |
111 | /* ALC268 models */ |
112 | enum { | |
eb5a6621 | 113 | ALC267_QUANTA_IL1, |
a361d84b | 114 | ALC268_3ST, |
d1a991a6 | 115 | ALC268_TOSHIBA, |
d273809e | 116 | ALC268_ACER, |
8ef355da | 117 | ALC268_ACER_ASPIRE_ONE, |
3866f0b0 | 118 | ALC268_DELL, |
f12462c5 | 119 | ALC268_ZEPTO, |
86c53bd2 JW |
120 | #ifdef CONFIG_SND_DEBUG |
121 | ALC268_TEST, | |
122 | #endif | |
a361d84b KY |
123 | ALC268_AUTO, |
124 | ALC268_MODEL_LAST /* last tag */ | |
125 | }; | |
126 | ||
f6a92248 KY |
127 | /* ALC269 models */ |
128 | enum { | |
129 | ALC269_BASIC, | |
60db6b53 | 130 | ALC269_QUANTA_FL1, |
f53281e6 KY |
131 | ALC269_ASUS_EEEPC_P703, |
132 | ALC269_ASUS_EEEPC_P901, | |
f6a92248 KY |
133 | ALC269_AUTO, |
134 | ALC269_MODEL_LAST /* last tag */ | |
135 | }; | |
136 | ||
df694daa KY |
137 | /* ALC861 models */ |
138 | enum { | |
139 | ALC861_3ST, | |
9c7f852e | 140 | ALC660_3ST, |
df694daa KY |
141 | ALC861_3ST_DIG, |
142 | ALC861_6ST_DIG, | |
22309c3e | 143 | ALC861_UNIWILL_M31, |
a53d1aec | 144 | ALC861_TOSHIBA, |
7cdbff94 | 145 | ALC861_ASUS, |
56bb0cab | 146 | ALC861_ASUS_LAPTOP, |
df694daa KY |
147 | ALC861_AUTO, |
148 | ALC861_MODEL_LAST, | |
149 | }; | |
150 | ||
f32610ed JS |
151 | /* ALC861-VD models */ |
152 | enum { | |
153 | ALC660VD_3ST, | |
6963f84c | 154 | ALC660VD_3ST_DIG, |
f32610ed JS |
155 | ALC861VD_3ST, |
156 | ALC861VD_3ST_DIG, | |
157 | ALC861VD_6ST_DIG, | |
bdd148a3 | 158 | ALC861VD_LENOVO, |
272a527c | 159 | ALC861VD_DALLAS, |
d1a991a6 | 160 | ALC861VD_HP, |
f32610ed JS |
161 | ALC861VD_AUTO, |
162 | ALC861VD_MODEL_LAST, | |
163 | }; | |
164 | ||
bc9f98a9 KY |
165 | /* ALC662 models */ |
166 | enum { | |
167 | ALC662_3ST_2ch_DIG, | |
168 | ALC662_3ST_6ch_DIG, | |
169 | ALC662_3ST_6ch, | |
170 | ALC662_5ST_DIG, | |
171 | ALC662_LENOVO_101E, | |
291702f0 | 172 | ALC662_ASUS_EEEPC_P701, |
8c427226 | 173 | ALC662_ASUS_EEEPC_EP20, |
6dda9f4a KY |
174 | ALC663_ASUS_M51VA, |
175 | ALC663_ASUS_G71V, | |
176 | ALC663_ASUS_H13, | |
177 | ALC663_ASUS_G50V, | |
f1d4e28b KY |
178 | ALC662_ECS, |
179 | ALC663_ASUS_MODE1, | |
180 | ALC662_ASUS_MODE2, | |
181 | ALC663_ASUS_MODE3, | |
182 | ALC663_ASUS_MODE4, | |
183 | ALC663_ASUS_MODE5, | |
184 | ALC663_ASUS_MODE6, | |
bc9f98a9 KY |
185 | ALC662_AUTO, |
186 | ALC662_MODEL_LAST, | |
187 | }; | |
188 | ||
df694daa KY |
189 | /* ALC882 models */ |
190 | enum { | |
191 | ALC882_3ST_DIG, | |
192 | ALC882_6ST_DIG, | |
4b146cb0 | 193 | ALC882_ARIMA, |
bdd148a3 | 194 | ALC882_W2JC, |
272a527c KY |
195 | ALC882_TARGA, |
196 | ALC882_ASUS_A7J, | |
914759b7 | 197 | ALC882_ASUS_A7M, |
9102cd1c | 198 | ALC885_MACPRO, |
87350ad0 | 199 | ALC885_MBP3, |
c54728d8 | 200 | ALC885_IMAC24, |
272a527c | 201 | ALC882_AUTO, |
df694daa KY |
202 | ALC882_MODEL_LAST, |
203 | }; | |
204 | ||
9c7f852e TI |
205 | /* ALC883 models */ |
206 | enum { | |
207 | ALC883_3ST_2ch_DIG, | |
208 | ALC883_3ST_6ch_DIG, | |
209 | ALC883_3ST_6ch, | |
210 | ALC883_6ST_DIG, | |
ccc656ce KY |
211 | ALC883_TARGA_DIG, |
212 | ALC883_TARGA_2ch_DIG, | |
bab282b9 | 213 | ALC883_ACER, |
2880a867 | 214 | ALC883_ACER_ASPIRE, |
c07584c8 | 215 | ALC883_MEDION, |
ea1fb29a | 216 | ALC883_MEDION_MD2, |
b373bdeb | 217 | ALC883_LAPTOP_EAPD, |
bc9f98a9 | 218 | ALC883_LENOVO_101E_2ch, |
272a527c | 219 | ALC883_LENOVO_NB0763, |
189609ae | 220 | ALC888_LENOVO_MS7195_DIG, |
e2757d5e | 221 | ALC888_LENOVO_SKY, |
ea1fb29a | 222 | ALC883_HAIER_W66, |
4723c022 | 223 | ALC888_3ST_HP, |
5795b9e6 | 224 | ALC888_6ST_DELL, |
a8848bd6 | 225 | ALC883_MITAC, |
0c4cc443 | 226 | ALC883_CLEVO_M720, |
fb97dc67 | 227 | ALC883_FUJITSU_PI2515, |
17bba1b7 | 228 | ALC883_3ST_6ch_INTEL, |
e2757d5e KY |
229 | ALC888_ASUS_M90V, |
230 | ALC888_ASUS_EEE1601, | |
9c7f852e TI |
231 | ALC883_AUTO, |
232 | ALC883_MODEL_LAST, | |
233 | }; | |
234 | ||
df694daa KY |
235 | /* for GPIO Poll */ |
236 | #define GPIO_MASK 0x03 | |
237 | ||
1da177e4 LT |
238 | struct alc_spec { |
239 | /* codec parameterization */ | |
df694daa | 240 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
1da177e4 | 241 | unsigned int num_mixers; |
f9e336f6 | 242 | struct snd_kcontrol_new *cap_mixer; /* capture mixer */ |
1da177e4 | 243 | |
df694daa | 244 | const struct hda_verb *init_verbs[5]; /* initialization verbs |
9c7f852e TI |
245 | * don't forget NULL |
246 | * termination! | |
e9edcee0 TI |
247 | */ |
248 | unsigned int num_init_verbs; | |
1da177e4 | 249 | |
16ded525 | 250 | char *stream_name_analog; /* analog PCM stream */ |
1da177e4 LT |
251 | struct hda_pcm_stream *stream_analog_playback; |
252 | struct hda_pcm_stream *stream_analog_capture; | |
6330079f TI |
253 | struct hda_pcm_stream *stream_analog_alt_playback; |
254 | struct hda_pcm_stream *stream_analog_alt_capture; | |
1da177e4 | 255 | |
f12ab1e0 | 256 | char *stream_name_digital; /* digital PCM stream */ |
1da177e4 LT |
257 | struct hda_pcm_stream *stream_digital_playback; |
258 | struct hda_pcm_stream *stream_digital_capture; | |
259 | ||
260 | /* playback */ | |
16ded525 TI |
261 | struct hda_multi_out multiout; /* playback set-up |
262 | * max_channels, dacs must be set | |
263 | * dig_out_nid and hp_nid are optional | |
264 | */ | |
6330079f | 265 | hda_nid_t alt_dac_nid; |
1da177e4 LT |
266 | |
267 | /* capture */ | |
268 | unsigned int num_adc_nids; | |
269 | hda_nid_t *adc_nids; | |
e1406348 | 270 | hda_nid_t *capsrc_nids; |
16ded525 | 271 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
54cbc9ab | 272 | unsigned char is_mix_capture; /* matrix-style capture (non-mux) */ |
1da177e4 LT |
273 | |
274 | /* capture source */ | |
a1e8d2da | 275 | unsigned int num_mux_defs; |
1da177e4 LT |
276 | const struct hda_input_mux *input_mux; |
277 | unsigned int cur_mux[3]; | |
278 | ||
279 | /* channel model */ | |
d2a6d7dc | 280 | const struct hda_channel_mode *channel_mode; |
1da177e4 | 281 | int num_channel_mode; |
4e195a7b | 282 | int need_dac_fix; |
1da177e4 LT |
283 | |
284 | /* PCM information */ | |
4c5186ed | 285 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
41e41f1f | 286 | |
e9edcee0 TI |
287 | /* dynamic controls, init_verbs and input_mux */ |
288 | struct auto_pin_cfg autocfg; | |
603c4019 | 289 | struct snd_array kctls; |
e9edcee0 | 290 | struct hda_input_mux private_imux; |
41923e44 | 291 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
834be88d | 292 | |
ae6b813a TI |
293 | /* hooks */ |
294 | void (*init_hook)(struct hda_codec *codec); | |
295 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); | |
296 | ||
834be88d TI |
297 | /* for pin sensing */ |
298 | unsigned int sense_updated: 1; | |
299 | unsigned int jack_present: 1; | |
bec15c3a | 300 | unsigned int master_sw: 1; |
cb53c626 | 301 | |
2134ea4f TI |
302 | /* for virtual master */ |
303 | hda_nid_t vmaster_nid; | |
cb53c626 TI |
304 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
305 | struct hda_loopback_check loopback; | |
306 | #endif | |
2c3bf9ab TI |
307 | |
308 | /* for PLL fix */ | |
309 | hda_nid_t pll_nid; | |
310 | unsigned int pll_coef_idx, pll_coef_bit; | |
e044c39a TI |
311 | |
312 | #ifdef SND_HDA_NEEDS_RESUME | |
313 | #define ALC_MAX_PINS 16 | |
314 | unsigned int num_pins; | |
315 | hda_nid_t pin_nids[ALC_MAX_PINS]; | |
316 | unsigned int pin_cfgs[ALC_MAX_PINS]; | |
317 | #endif | |
df694daa KY |
318 | }; |
319 | ||
320 | /* | |
321 | * configuration template - to be copied to the spec instance | |
322 | */ | |
323 | struct alc_config_preset { | |
9c7f852e TI |
324 | struct snd_kcontrol_new *mixers[5]; /* should be identical size |
325 | * with spec | |
326 | */ | |
f9e336f6 | 327 | struct snd_kcontrol_new *cap_mixer; /* capture mixer */ |
df694daa KY |
328 | const struct hda_verb *init_verbs[5]; |
329 | unsigned int num_dacs; | |
330 | hda_nid_t *dac_nids; | |
331 | hda_nid_t dig_out_nid; /* optional */ | |
332 | hda_nid_t hp_nid; /* optional */ | |
333 | unsigned int num_adc_nids; | |
334 | hda_nid_t *adc_nids; | |
e1406348 | 335 | hda_nid_t *capsrc_nids; |
df694daa KY |
336 | hda_nid_t dig_in_nid; |
337 | unsigned int num_channel_mode; | |
338 | const struct hda_channel_mode *channel_mode; | |
4e195a7b | 339 | int need_dac_fix; |
a1e8d2da | 340 | unsigned int num_mux_defs; |
df694daa | 341 | const struct hda_input_mux *input_mux; |
ae6b813a TI |
342 | void (*unsol_event)(struct hda_codec *, unsigned int); |
343 | void (*init_hook)(struct hda_codec *); | |
cb53c626 TI |
344 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
345 | struct hda_amp_list *loopbacks; | |
346 | #endif | |
1da177e4 LT |
347 | }; |
348 | ||
1da177e4 LT |
349 | |
350 | /* | |
351 | * input MUX handling | |
352 | */ | |
9c7f852e TI |
353 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
354 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
355 | { |
356 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
357 | struct alc_spec *spec = codec->spec; | |
a1e8d2da JW |
358 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
359 | if (mux_idx >= spec->num_mux_defs) | |
360 | mux_idx = 0; | |
361 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); | |
1da177e4 LT |
362 | } |
363 | ||
9c7f852e TI |
364 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
365 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
366 | { |
367 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
368 | struct alc_spec *spec = codec->spec; | |
369 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
370 | ||
371 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | |
372 | return 0; | |
373 | } | |
374 | ||
9c7f852e TI |
375 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
376 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
377 | { |
378 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
379 | struct alc_spec *spec = codec->spec; | |
54cbc9ab | 380 | const struct hda_input_mux *imux = spec->input_mux; |
1da177e4 | 381 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
e1406348 TI |
382 | hda_nid_t nid = spec->capsrc_nids ? |
383 | spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx]; | |
1da177e4 | 384 | |
54cbc9ab TI |
385 | if (spec->is_mix_capture) { |
386 | /* Matrix-mixer style (e.g. ALC882) */ | |
387 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | |
388 | unsigned int i, idx; | |
389 | ||
390 | idx = ucontrol->value.enumerated.item[0]; | |
391 | if (idx >= imux->num_items) | |
392 | idx = imux->num_items - 1; | |
393 | if (*cur_val == idx) | |
394 | return 0; | |
395 | for (i = 0; i < imux->num_items; i++) { | |
396 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; | |
397 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, | |
398 | imux->items[i].index, | |
399 | HDA_AMP_MUTE, v); | |
400 | } | |
401 | *cur_val = idx; | |
402 | return 1; | |
403 | } else { | |
404 | /* MUX style (e.g. ALC880) */ | |
405 | unsigned int mux_idx; | |
406 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; | |
407 | return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], | |
408 | ucontrol, nid, | |
409 | &spec->cur_mux[adc_idx]); | |
410 | } | |
411 | } | |
e9edcee0 | 412 | |
1da177e4 LT |
413 | /* |
414 | * channel mode setting | |
415 | */ | |
9c7f852e TI |
416 | static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, |
417 | struct snd_ctl_elem_info *uinfo) | |
1da177e4 LT |
418 | { |
419 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
420 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc TI |
421 | return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, |
422 | spec->num_channel_mode); | |
1da177e4 LT |
423 | } |
424 | ||
9c7f852e TI |
425 | static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, |
426 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
427 | { |
428 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
429 | struct alc_spec *spec = codec->spec; | |
d2a6d7dc | 430 | return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, |
9c7f852e TI |
431 | spec->num_channel_mode, |
432 | spec->multiout.max_channels); | |
1da177e4 LT |
433 | } |
434 | ||
9c7f852e TI |
435 | static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, |
436 | struct snd_ctl_elem_value *ucontrol) | |
1da177e4 LT |
437 | { |
438 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
439 | struct alc_spec *spec = codec->spec; | |
4e195a7b TI |
440 | int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, |
441 | spec->num_channel_mode, | |
442 | &spec->multiout.max_channels); | |
bd2033f2 | 443 | if (err >= 0 && spec->need_dac_fix) |
4e195a7b TI |
444 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
445 | return err; | |
1da177e4 LT |
446 | } |
447 | ||
a9430dd8 | 448 | /* |
4c5186ed | 449 | * Control the mode of pin widget settings via the mixer. "pc" is used |
ea1fb29a | 450 | * instead of "%" to avoid consequences of accidently treating the % as |
4c5186ed JW |
451 | * being part of a format specifier. Maximum allowed length of a value is |
452 | * 63 characters plus NULL terminator. | |
7cf51e48 JW |
453 | * |
454 | * Note: some retasking pin complexes seem to ignore requests for input | |
455 | * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these | |
456 | * are requested. Therefore order this list so that this behaviour will not | |
457 | * cause problems when mixer clients move through the enum sequentially. | |
a1e8d2da JW |
458 | * NIDs 0x0f and 0x10 have been observed to have this behaviour as of |
459 | * March 2006. | |
4c5186ed JW |
460 | */ |
461 | static char *alc_pin_mode_names[] = { | |
7cf51e48 JW |
462 | "Mic 50pc bias", "Mic 80pc bias", |
463 | "Line in", "Line out", "Headphone out", | |
4c5186ed JW |
464 | }; |
465 | static unsigned char alc_pin_mode_values[] = { | |
7cf51e48 | 466 | PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP, |
4c5186ed JW |
467 | }; |
468 | /* The control can present all 5 options, or it can limit the options based | |
a1e8d2da JW |
469 | * in the pin being assumed to be exclusively an input or an output pin. In |
470 | * addition, "input" pins may or may not process the mic bias option | |
471 | * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to | |
472 | * accept requests for bias as of chip versions up to March 2006) and/or | |
473 | * wiring in the computer. | |
a9430dd8 | 474 | */ |
a1e8d2da JW |
475 | #define ALC_PIN_DIR_IN 0x00 |
476 | #define ALC_PIN_DIR_OUT 0x01 | |
477 | #define ALC_PIN_DIR_INOUT 0x02 | |
478 | #define ALC_PIN_DIR_IN_NOMICBIAS 0x03 | |
479 | #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04 | |
4c5186ed | 480 | |
ea1fb29a | 481 | /* Info about the pin modes supported by the different pin direction modes. |
4c5186ed JW |
482 | * For each direction the minimum and maximum values are given. |
483 | */ | |
a1e8d2da | 484 | static signed char alc_pin_mode_dir_info[5][2] = { |
4c5186ed JW |
485 | { 0, 2 }, /* ALC_PIN_DIR_IN */ |
486 | { 3, 4 }, /* ALC_PIN_DIR_OUT */ | |
487 | { 0, 4 }, /* ALC_PIN_DIR_INOUT */ | |
a1e8d2da JW |
488 | { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */ |
489 | { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */ | |
4c5186ed JW |
490 | }; |
491 | #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0]) | |
492 | #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1]) | |
493 | #define alc_pin_mode_n_items(_dir) \ | |
494 | (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1) | |
495 | ||
9c7f852e TI |
496 | static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, |
497 | struct snd_ctl_elem_info *uinfo) | |
a9430dd8 | 498 | { |
4c5186ed JW |
499 | unsigned int item_num = uinfo->value.enumerated.item; |
500 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; | |
501 | ||
502 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
a9430dd8 | 503 | uinfo->count = 1; |
4c5186ed JW |
504 | uinfo->value.enumerated.items = alc_pin_mode_n_items(dir); |
505 | ||
506 | if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir)) | |
507 | item_num = alc_pin_mode_min(dir); | |
508 | strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]); | |
a9430dd8 JW |
509 | return 0; |
510 | } | |
511 | ||
9c7f852e TI |
512 | static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, |
513 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 514 | { |
4c5186ed | 515 | unsigned int i; |
a9430dd8 JW |
516 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
517 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed | 518 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
a9430dd8 | 519 | long *valp = ucontrol->value.integer.value; |
9c7f852e TI |
520 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
521 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
522 | 0x00); | |
a9430dd8 | 523 | |
4c5186ed JW |
524 | /* Find enumerated value for current pinctl setting */ |
525 | i = alc_pin_mode_min(dir); | |
9c7f852e | 526 | while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) |
4c5186ed | 527 | i++; |
9c7f852e | 528 | *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); |
a9430dd8 JW |
529 | return 0; |
530 | } | |
531 | ||
9c7f852e TI |
532 | static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, |
533 | struct snd_ctl_elem_value *ucontrol) | |
a9430dd8 | 534 | { |
4c5186ed | 535 | signed int change; |
a9430dd8 JW |
536 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
537 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
4c5186ed JW |
538 | unsigned char dir = (kcontrol->private_value >> 16) & 0xff; |
539 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
540 | unsigned int pinctl = snd_hda_codec_read(codec, nid, 0, |
541 | AC_VERB_GET_PIN_WIDGET_CONTROL, | |
542 | 0x00); | |
a9430dd8 | 543 | |
f12ab1e0 | 544 | if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) |
4c5186ed JW |
545 | val = alc_pin_mode_min(dir); |
546 | ||
547 | change = pinctl != alc_pin_mode_values[val]; | |
cdcd9268 JW |
548 | if (change) { |
549 | /* Set pin mode to that requested */ | |
82beb8fd TI |
550 | snd_hda_codec_write_cache(codec, nid, 0, |
551 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
552 | alc_pin_mode_values[val]); | |
cdcd9268 | 553 | |
ea1fb29a | 554 | /* Also enable the retasking pin's input/output as required |
cdcd9268 JW |
555 | * for the requested pin mode. Enum values of 2 or less are |
556 | * input modes. | |
557 | * | |
558 | * Dynamically switching the input/output buffers probably | |
a1e8d2da JW |
559 | * reduces noise slightly (particularly on input) so we'll |
560 | * do it. However, having both input and output buffers | |
561 | * enabled simultaneously doesn't seem to be problematic if | |
562 | * this turns out to be necessary in the future. | |
cdcd9268 JW |
563 | */ |
564 | if (val <= 2) { | |
47fd830a TI |
565 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
566 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
567 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, | |
568 | HDA_AMP_MUTE, 0); | |
cdcd9268 | 569 | } else { |
47fd830a TI |
570 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, |
571 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
572 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
573 | HDA_AMP_MUTE, 0); | |
cdcd9268 JW |
574 | } |
575 | } | |
a9430dd8 JW |
576 | return change; |
577 | } | |
578 | ||
4c5186ed | 579 | #define ALC_PIN_MODE(xname, nid, dir) \ |
a9430dd8 | 580 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
4c5186ed JW |
581 | .info = alc_pin_mode_info, \ |
582 | .get = alc_pin_mode_get, \ | |
583 | .put = alc_pin_mode_put, \ | |
584 | .private_value = nid | (dir<<16) } | |
df694daa | 585 | |
5c8f858d JW |
586 | /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged |
587 | * together using a mask with more than one bit set. This control is | |
588 | * currently used only by the ALC260 test model. At this stage they are not | |
589 | * needed for any "production" models. | |
590 | */ | |
591 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 592 | #define alc_gpio_data_info snd_ctl_boolean_mono_info |
f12ab1e0 | 593 | |
9c7f852e TI |
594 | static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, |
595 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
596 | { |
597 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
598 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
599 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
600 | long *valp = ucontrol->value.integer.value; | |
9c7f852e TI |
601 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
602 | AC_VERB_GET_GPIO_DATA, 0x00); | |
5c8f858d JW |
603 | |
604 | *valp = (val & mask) != 0; | |
605 | return 0; | |
606 | } | |
9c7f852e TI |
607 | static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, |
608 | struct snd_ctl_elem_value *ucontrol) | |
5c8f858d JW |
609 | { |
610 | signed int change; | |
611 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
612 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
613 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
614 | long val = *ucontrol->value.integer.value; | |
9c7f852e TI |
615 | unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0, |
616 | AC_VERB_GET_GPIO_DATA, | |
617 | 0x00); | |
5c8f858d JW |
618 | |
619 | /* Set/unset the masked GPIO bit(s) as needed */ | |
9c7f852e TI |
620 | change = (val == 0 ? 0 : mask) != (gpio_data & mask); |
621 | if (val == 0) | |
5c8f858d JW |
622 | gpio_data &= ~mask; |
623 | else | |
624 | gpio_data |= mask; | |
82beb8fd TI |
625 | snd_hda_codec_write_cache(codec, nid, 0, |
626 | AC_VERB_SET_GPIO_DATA, gpio_data); | |
5c8f858d JW |
627 | |
628 | return change; | |
629 | } | |
630 | #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ | |
631 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
632 | .info = alc_gpio_data_info, \ | |
633 | .get = alc_gpio_data_get, \ | |
634 | .put = alc_gpio_data_put, \ | |
635 | .private_value = nid | (mask<<16) } | |
636 | #endif /* CONFIG_SND_DEBUG */ | |
637 | ||
92621f13 JW |
638 | /* A switch control to allow the enabling of the digital IO pins on the |
639 | * ALC260. This is incredibly simplistic; the intention of this control is | |
640 | * to provide something in the test model allowing digital outputs to be | |
641 | * identified if present. If models are found which can utilise these | |
642 | * outputs a more complete mixer control can be devised for those models if | |
643 | * necessary. | |
644 | */ | |
645 | #ifdef CONFIG_SND_DEBUG | |
a5ce8890 | 646 | #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info |
f12ab1e0 | 647 | |
9c7f852e TI |
648 | static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, |
649 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
650 | { |
651 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
652 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
653 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
654 | long *valp = ucontrol->value.integer.value; | |
9c7f852e | 655 | unsigned int val = snd_hda_codec_read(codec, nid, 0, |
3982d17e | 656 | AC_VERB_GET_DIGI_CONVERT_1, 0x00); |
92621f13 JW |
657 | |
658 | *valp = (val & mask) != 0; | |
659 | return 0; | |
660 | } | |
9c7f852e TI |
661 | static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, |
662 | struct snd_ctl_elem_value *ucontrol) | |
92621f13 JW |
663 | { |
664 | signed int change; | |
665 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
666 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
667 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
668 | long val = *ucontrol->value.integer.value; | |
9c7f852e | 669 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, |
3982d17e | 670 | AC_VERB_GET_DIGI_CONVERT_1, |
9c7f852e | 671 | 0x00); |
92621f13 JW |
672 | |
673 | /* Set/unset the masked control bit(s) as needed */ | |
9c7f852e | 674 | change = (val == 0 ? 0 : mask) != (ctrl_data & mask); |
92621f13 JW |
675 | if (val==0) |
676 | ctrl_data &= ~mask; | |
677 | else | |
678 | ctrl_data |= mask; | |
82beb8fd TI |
679 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, |
680 | ctrl_data); | |
92621f13 JW |
681 | |
682 | return change; | |
683 | } | |
684 | #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ | |
685 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
686 | .info = alc_spdif_ctrl_info, \ | |
687 | .get = alc_spdif_ctrl_get, \ | |
688 | .put = alc_spdif_ctrl_put, \ | |
689 | .private_value = nid | (mask<<16) } | |
690 | #endif /* CONFIG_SND_DEBUG */ | |
691 | ||
f8225f6d JW |
692 | /* A switch control to allow the enabling EAPD digital outputs on the ALC26x. |
693 | * Again, this is only used in the ALC26x test models to help identify when | |
694 | * the EAPD line must be asserted for features to work. | |
695 | */ | |
696 | #ifdef CONFIG_SND_DEBUG | |
697 | #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info | |
698 | ||
699 | static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol, | |
700 | struct snd_ctl_elem_value *ucontrol) | |
701 | { | |
702 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
703 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
704 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
705 | long *valp = ucontrol->value.integer.value; | |
706 | unsigned int val = snd_hda_codec_read(codec, nid, 0, | |
707 | AC_VERB_GET_EAPD_BTLENABLE, 0x00); | |
708 | ||
709 | *valp = (val & mask) != 0; | |
710 | return 0; | |
711 | } | |
712 | ||
713 | static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol, | |
714 | struct snd_ctl_elem_value *ucontrol) | |
715 | { | |
716 | int change; | |
717 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
718 | hda_nid_t nid = kcontrol->private_value & 0xffff; | |
719 | unsigned char mask = (kcontrol->private_value >> 16) & 0xff; | |
720 | long val = *ucontrol->value.integer.value; | |
721 | unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0, | |
722 | AC_VERB_GET_EAPD_BTLENABLE, | |
723 | 0x00); | |
724 | ||
725 | /* Set/unset the masked control bit(s) as needed */ | |
726 | change = (!val ? 0 : mask) != (ctrl_data & mask); | |
727 | if (!val) | |
728 | ctrl_data &= ~mask; | |
729 | else | |
730 | ctrl_data |= mask; | |
731 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, | |
732 | ctrl_data); | |
733 | ||
734 | return change; | |
735 | } | |
736 | ||
737 | #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \ | |
738 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | |
739 | .info = alc_eapd_ctrl_info, \ | |
740 | .get = alc_eapd_ctrl_get, \ | |
741 | .put = alc_eapd_ctrl_put, \ | |
742 | .private_value = nid | (mask<<16) } | |
743 | #endif /* CONFIG_SND_DEBUG */ | |
744 | ||
d88897ea TI |
745 | /* |
746 | */ | |
747 | static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix) | |
748 | { | |
749 | if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) | |
750 | return; | |
751 | spec->mixers[spec->num_mixers++] = mix; | |
752 | } | |
753 | ||
754 | static void add_verb(struct alc_spec *spec, const struct hda_verb *verb) | |
755 | { | |
756 | if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs))) | |
757 | return; | |
758 | spec->init_verbs[spec->num_init_verbs++] = verb; | |
759 | } | |
760 | ||
df694daa KY |
761 | /* |
762 | * set up from the preset table | |
763 | */ | |
9c7f852e TI |
764 | static void setup_preset(struct alc_spec *spec, |
765 | const struct alc_config_preset *preset) | |
df694daa KY |
766 | { |
767 | int i; | |
768 | ||
769 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) | |
d88897ea | 770 | add_mixer(spec, preset->mixers[i]); |
f9e336f6 | 771 | spec->cap_mixer = preset->cap_mixer; |
9c7f852e TI |
772 | for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; |
773 | i++) | |
d88897ea | 774 | add_verb(spec, preset->init_verbs[i]); |
ea1fb29a | 775 | |
df694daa KY |
776 | spec->channel_mode = preset->channel_mode; |
777 | spec->num_channel_mode = preset->num_channel_mode; | |
4e195a7b | 778 | spec->need_dac_fix = preset->need_dac_fix; |
df694daa KY |
779 | |
780 | spec->multiout.max_channels = spec->channel_mode[0].channels; | |
781 | ||
782 | spec->multiout.num_dacs = preset->num_dacs; | |
783 | spec->multiout.dac_nids = preset->dac_nids; | |
784 | spec->multiout.dig_out_nid = preset->dig_out_nid; | |
785 | spec->multiout.hp_nid = preset->hp_nid; | |
ea1fb29a | 786 | |
a1e8d2da | 787 | spec->num_mux_defs = preset->num_mux_defs; |
f12ab1e0 | 788 | if (!spec->num_mux_defs) |
a1e8d2da | 789 | spec->num_mux_defs = 1; |
df694daa KY |
790 | spec->input_mux = preset->input_mux; |
791 | ||
792 | spec->num_adc_nids = preset->num_adc_nids; | |
793 | spec->adc_nids = preset->adc_nids; | |
e1406348 | 794 | spec->capsrc_nids = preset->capsrc_nids; |
df694daa | 795 | spec->dig_in_nid = preset->dig_in_nid; |
ae6b813a TI |
796 | |
797 | spec->unsol_event = preset->unsol_event; | |
798 | spec->init_hook = preset->init_hook; | |
cb53c626 TI |
799 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
800 | spec->loopback.amplist = preset->loopbacks; | |
801 | #endif | |
df694daa KY |
802 | } |
803 | ||
bc9f98a9 KY |
804 | /* Enable GPIO mask and set output */ |
805 | static struct hda_verb alc_gpio1_init_verbs[] = { | |
806 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
807 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
808 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
809 | { } | |
810 | }; | |
811 | ||
812 | static struct hda_verb alc_gpio2_init_verbs[] = { | |
813 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, | |
814 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, | |
815 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, | |
816 | { } | |
817 | }; | |
818 | ||
bdd148a3 KY |
819 | static struct hda_verb alc_gpio3_init_verbs[] = { |
820 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
821 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
822 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
823 | { } | |
824 | }; | |
825 | ||
2c3bf9ab TI |
826 | /* |
827 | * Fix hardware PLL issue | |
828 | * On some codecs, the analog PLL gating control must be off while | |
829 | * the default value is 1. | |
830 | */ | |
831 | static void alc_fix_pll(struct hda_codec *codec) | |
832 | { | |
833 | struct alc_spec *spec = codec->spec; | |
834 | unsigned int val; | |
835 | ||
836 | if (!spec->pll_nid) | |
837 | return; | |
838 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, | |
839 | spec->pll_coef_idx); | |
840 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, | |
841 | AC_VERB_GET_PROC_COEF, 0); | |
842 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, | |
843 | spec->pll_coef_idx); | |
844 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, | |
845 | val & ~(1 << spec->pll_coef_bit)); | |
846 | } | |
847 | ||
848 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, | |
849 | unsigned int coef_idx, unsigned int coef_bit) | |
850 | { | |
851 | struct alc_spec *spec = codec->spec; | |
852 | spec->pll_nid = nid; | |
853 | spec->pll_coef_idx = coef_idx; | |
854 | spec->pll_coef_bit = coef_bit; | |
855 | alc_fix_pll(codec); | |
856 | } | |
857 | ||
c9b58006 KY |
858 | static void alc_sku_automute(struct hda_codec *codec) |
859 | { | |
860 | struct alc_spec *spec = codec->spec; | |
c9b58006 KY |
861 | unsigned int present; |
862 | unsigned int hp_nid = spec->autocfg.hp_pins[0]; | |
863 | unsigned int sp_nid = spec->autocfg.speaker_pins[0]; | |
864 | ||
865 | /* need to execute and sync at first */ | |
866 | snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0); | |
867 | present = snd_hda_codec_read(codec, hp_nid, 0, | |
868 | AC_VERB_GET_PIN_SENSE, 0); | |
869 | spec->jack_present = (present & 0x80000000) != 0; | |
f6c7e546 TI |
870 | snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
871 | spec->jack_present ? 0 : PIN_OUT); | |
c9b58006 KY |
872 | } |
873 | ||
4605b718 | 874 | #if 0 /* it's broken in some acses -- temporarily disabled */ |
7fb0d78f KY |
875 | static void alc_mic_automute(struct hda_codec *codec) |
876 | { | |
877 | struct alc_spec *spec = codec->spec; | |
878 | unsigned int present; | |
879 | unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | |
880 | unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | |
881 | unsigned int mix_nid = spec->capsrc_nids[0]; | |
882 | unsigned int capsrc_idx_mic, capsrc_idx_fmic; | |
883 | ||
884 | capsrc_idx_mic = mic_nid - 0x18; | |
885 | capsrc_idx_fmic = fmic_nid - 0x18; | |
886 | present = snd_hda_codec_read(codec, mic_nid, 0, | |
887 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
888 | snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
889 | 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80)); | |
890 | snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
891 | 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0)); | |
892 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic, | |
893 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
894 | } | |
4605b718 TI |
895 | #else |
896 | #define alc_mic_automute(codec) /* NOP */ | |
897 | #endif /* disabled */ | |
7fb0d78f | 898 | |
c9b58006 KY |
899 | /* unsolicited event for HP jack sensing */ |
900 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) | |
901 | { | |
902 | if (codec->vendor_id == 0x10ec0880) | |
903 | res >>= 28; | |
904 | else | |
905 | res >>= 26; | |
7fb0d78f KY |
906 | if (res == ALC880_HP_EVENT) |
907 | alc_sku_automute(codec); | |
c9b58006 | 908 | |
7fb0d78f KY |
909 | if (res == ALC880_MIC_EVENT) |
910 | alc_mic_automute(codec); | |
911 | } | |
912 | ||
913 | static void alc_inithook(struct hda_codec *codec) | |
914 | { | |
c9b58006 | 915 | alc_sku_automute(codec); |
7fb0d78f | 916 | alc_mic_automute(codec); |
c9b58006 KY |
917 | } |
918 | ||
f9423e7a KY |
919 | /* additional initialization for ALC888 variants */ |
920 | static void alc888_coef_init(struct hda_codec *codec) | |
921 | { | |
922 | unsigned int tmp; | |
923 | ||
924 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); | |
925 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
926 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); | |
927 | if ((tmp & 0xf0) == 2) | |
928 | /* alc888S-VC */ | |
929 | snd_hda_codec_read(codec, 0x20, 0, | |
930 | AC_VERB_SET_PROC_COEF, 0x830); | |
931 | else | |
932 | /* alc888-VB */ | |
933 | snd_hda_codec_read(codec, 0x20, 0, | |
934 | AC_VERB_SET_PROC_COEF, 0x3030); | |
935 | } | |
936 | ||
bc9f98a9 KY |
937 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
938 | * 31 ~ 16 : Manufacture ID | |
939 | * 15 ~ 8 : SKU ID | |
940 | * 7 ~ 0 : Assembly ID | |
941 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 | |
942 | */ | |
943 | static void alc_subsystem_id(struct hda_codec *codec, | |
944 | unsigned int porta, unsigned int porte, | |
945 | unsigned int portd) | |
946 | { | |
c9b58006 KY |
947 | unsigned int ass, tmp, i; |
948 | unsigned nid; | |
949 | struct alc_spec *spec = codec->spec; | |
bc9f98a9 | 950 | |
c9b58006 KY |
951 | ass = codec->subsystem_id & 0xffff; |
952 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) | |
953 | goto do_sku; | |
954 | ||
ea1fb29a | 955 | /* |
c9b58006 KY |
956 | * 31~30 : port conetcivity |
957 | * 29~21 : reserve | |
958 | * 20 : PCBEEP input | |
959 | * 19~16 : Check sum (15:1) | |
960 | * 15~1 : Custom | |
961 | * 0 : override | |
962 | */ | |
963 | nid = 0x1d; | |
964 | if (codec->vendor_id == 0x10ec0260) | |
965 | nid = 0x17; | |
966 | ass = snd_hda_codec_read(codec, nid, 0, | |
967 | AC_VERB_GET_CONFIG_DEFAULT, 0); | |
968 | if (!(ass & 1) && !(ass & 0x100000)) | |
969 | return; | |
970 | if ((ass >> 30) != 1) /* no physical connection */ | |
bc9f98a9 KY |
971 | return; |
972 | ||
c9b58006 KY |
973 | /* check sum */ |
974 | tmp = 0; | |
975 | for (i = 1; i < 16; i++) { | |
8c427226 | 976 | if ((ass >> i) & 1) |
c9b58006 KY |
977 | tmp++; |
978 | } | |
979 | if (((ass >> 16) & 0xf) != tmp) | |
980 | return; | |
981 | do_sku: | |
982 | /* | |
983 | * 0 : override | |
984 | * 1 : Swap Jack | |
985 | * 2 : 0 --> Desktop, 1 --> Laptop | |
986 | * 3~5 : External Amplifier control | |
987 | * 7~6 : Reserved | |
988 | */ | |
bc9f98a9 KY |
989 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
990 | switch (tmp) { | |
991 | case 1: | |
992 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); | |
993 | break; | |
994 | case 3: | |
995 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); | |
996 | break; | |
bdd148a3 KY |
997 | case 7: |
998 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); | |
999 | break; | |
c9b58006 | 1000 | case 5: /* set EAPD output high */ |
bdd148a3 | 1001 | switch (codec->vendor_id) { |
c9b58006 KY |
1002 | case 0x10ec0260: |
1003 | snd_hda_codec_write(codec, 0x0f, 0, | |
1004 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
1005 | snd_hda_codec_write(codec, 0x10, 0, | |
1006 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
1007 | break; | |
1008 | case 0x10ec0262: | |
bdd148a3 KY |
1009 | case 0x10ec0267: |
1010 | case 0x10ec0268: | |
c9b58006 | 1011 | case 0x10ec0269: |
f9423e7a KY |
1012 | case 0x10ec0660: |
1013 | case 0x10ec0662: | |
1014 | case 0x10ec0663: | |
c9b58006 | 1015 | case 0x10ec0862: |
20a3a05d | 1016 | case 0x10ec0889: |
bdd148a3 KY |
1017 | snd_hda_codec_write(codec, 0x14, 0, |
1018 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
1019 | snd_hda_codec_write(codec, 0x15, 0, | |
1020 | AC_VERB_SET_EAPD_BTLENABLE, 2); | |
c9b58006 | 1021 | break; |
bdd148a3 | 1022 | } |
c9b58006 KY |
1023 | switch (codec->vendor_id) { |
1024 | case 0x10ec0260: | |
1025 | snd_hda_codec_write(codec, 0x1a, 0, | |
1026 | AC_VERB_SET_COEF_INDEX, 7); | |
1027 | tmp = snd_hda_codec_read(codec, 0x1a, 0, | |
1028 | AC_VERB_GET_PROC_COEF, 0); | |
1029 | snd_hda_codec_write(codec, 0x1a, 0, | |
1030 | AC_VERB_SET_COEF_INDEX, 7); | |
1031 | snd_hda_codec_write(codec, 0x1a, 0, | |
1032 | AC_VERB_SET_PROC_COEF, | |
1033 | tmp | 0x2010); | |
1034 | break; | |
1035 | case 0x10ec0262: | |
1036 | case 0x10ec0880: | |
1037 | case 0x10ec0882: | |
1038 | case 0x10ec0883: | |
1039 | case 0x10ec0885: | |
20a3a05d | 1040 | case 0x10ec0889: |
c9b58006 KY |
1041 | snd_hda_codec_write(codec, 0x20, 0, |
1042 | AC_VERB_SET_COEF_INDEX, 7); | |
1043 | tmp = snd_hda_codec_read(codec, 0x20, 0, | |
1044 | AC_VERB_GET_PROC_COEF, 0); | |
1045 | snd_hda_codec_write(codec, 0x20, 0, | |
ea1fb29a | 1046 | AC_VERB_SET_COEF_INDEX, 7); |
c9b58006 KY |
1047 | snd_hda_codec_write(codec, 0x20, 0, |
1048 | AC_VERB_SET_PROC_COEF, | |
1049 | tmp | 0x2010); | |
1050 | break; | |
f9423e7a | 1051 | case 0x10ec0888: |
1082c748 | 1052 | /*alc888_coef_init(codec);*/ /* called in alc_init() */ |
f9423e7a | 1053 | break; |
c9b58006 KY |
1054 | case 0x10ec0267: |
1055 | case 0x10ec0268: | |
1056 | snd_hda_codec_write(codec, 0x20, 0, | |
1057 | AC_VERB_SET_COEF_INDEX, 7); | |
1058 | tmp = snd_hda_codec_read(codec, 0x20, 0, | |
1059 | AC_VERB_GET_PROC_COEF, 0); | |
1060 | snd_hda_codec_write(codec, 0x20, 0, | |
ea1fb29a | 1061 | AC_VERB_SET_COEF_INDEX, 7); |
c9b58006 KY |
1062 | snd_hda_codec_write(codec, 0x20, 0, |
1063 | AC_VERB_SET_PROC_COEF, | |
1064 | tmp | 0x3000); | |
1065 | break; | |
bc9f98a9 | 1066 | } |
c9b58006 | 1067 | default: |
bc9f98a9 KY |
1068 | break; |
1069 | } | |
ea1fb29a | 1070 | |
8c427226 | 1071 | /* is laptop or Desktop and enable the function "Mute internal speaker |
c9b58006 KY |
1072 | * when the external headphone out jack is plugged" |
1073 | */ | |
8c427226 | 1074 | if (!(ass & 0x8000)) |
c9b58006 KY |
1075 | return; |
1076 | /* | |
1077 | * 10~8 : Jack location | |
1078 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered | |
1079 | * 14~13: Resvered | |
1080 | * 15 : 1 --> enable the function "Mute internal speaker | |
1081 | * when the external headphone out jack is plugged" | |
1082 | */ | |
1083 | if (!spec->autocfg.speaker_pins[0]) { | |
8c427226 | 1084 | if (spec->autocfg.line_out_pins[0]) |
c9b58006 | 1085 | spec->autocfg.speaker_pins[0] = |
8c427226 | 1086 | spec->autocfg.line_out_pins[0]; |
c9b58006 KY |
1087 | else |
1088 | return; | |
1089 | } | |
1090 | ||
1091 | if (!spec->autocfg.hp_pins[0]) { | |
1092 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ | |
1093 | if (tmp == 0) | |
1094 | spec->autocfg.hp_pins[0] = porta; | |
1095 | else if (tmp == 1) | |
1096 | spec->autocfg.hp_pins[0] = porte; | |
1097 | else if (tmp == 2) | |
1098 | spec->autocfg.hp_pins[0] = portd; | |
1099 | else | |
1100 | return; | |
1101 | } | |
7fb0d78f KY |
1102 | if (spec->autocfg.hp_pins[0]) |
1103 | snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0, | |
1104 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
1105 | AC_USRSP_EN | ALC880_HP_EVENT); | |
c9b58006 | 1106 | |
4605b718 | 1107 | #if 0 /* it's broken in some acses -- temporarily disabled */ |
7fb0d78f KY |
1108 | if (spec->autocfg.input_pins[AUTO_PIN_MIC] && |
1109 | spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]) | |
1110 | snd_hda_codec_write(codec, | |
1111 | spec->autocfg.input_pins[AUTO_PIN_MIC], 0, | |
1112 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
1113 | AC_USRSP_EN | ALC880_MIC_EVENT); | |
4605b718 | 1114 | #endif /* disabled */ |
ea1fb29a | 1115 | |
c9b58006 | 1116 | spec->unsol_event = alc_sku_unsol_event; |
bc9f98a9 KY |
1117 | } |
1118 | ||
f95474ec TI |
1119 | /* |
1120 | * Fix-up pin default configurations | |
1121 | */ | |
1122 | ||
1123 | struct alc_pincfg { | |
1124 | hda_nid_t nid; | |
1125 | u32 val; | |
1126 | }; | |
1127 | ||
1128 | static void alc_fix_pincfg(struct hda_codec *codec, | |
1129 | const struct snd_pci_quirk *quirk, | |
1130 | const struct alc_pincfg **pinfix) | |
1131 | { | |
1132 | const struct alc_pincfg *cfg; | |
1133 | ||
1134 | quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); | |
1135 | if (!quirk) | |
1136 | return; | |
1137 | ||
1138 | cfg = pinfix[quirk->value]; | |
1139 | for (; cfg->nid; cfg++) { | |
1140 | int i; | |
1141 | u32 val = cfg->val; | |
1142 | for (i = 0; i < 4; i++) { | |
1143 | snd_hda_codec_write(codec, cfg->nid, 0, | |
1144 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i, | |
1145 | val & 0xff); | |
1146 | val >>= 8; | |
1147 | } | |
1148 | } | |
1149 | } | |
1150 | ||
1da177e4 | 1151 | /* |
e9edcee0 TI |
1152 | * ALC880 3-stack model |
1153 | * | |
1154 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) | |
9c7f852e TI |
1155 | * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, |
1156 | * F-Mic = 0x1b, HP = 0x19 | |
1da177e4 LT |
1157 | */ |
1158 | ||
e9edcee0 TI |
1159 | static hda_nid_t alc880_dac_nids[4] = { |
1160 | /* front, rear, clfe, rear_surr */ | |
1161 | 0x02, 0x05, 0x04, 0x03 | |
1162 | }; | |
1163 | ||
1164 | static hda_nid_t alc880_adc_nids[3] = { | |
1165 | /* ADC0-2 */ | |
1166 | 0x07, 0x08, 0x09, | |
1167 | }; | |
1168 | ||
1169 | /* The datasheet says the node 0x07 is connected from inputs, | |
1170 | * but it shows zero connection in the real implementation on some devices. | |
df694daa | 1171 | * Note: this is a 915GAV bug, fixed on 915GLV |
1da177e4 | 1172 | */ |
e9edcee0 TI |
1173 | static hda_nid_t alc880_adc_nids_alt[2] = { |
1174 | /* ADC1-2 */ | |
1175 | 0x08, 0x09, | |
1176 | }; | |
1177 | ||
1178 | #define ALC880_DIGOUT_NID 0x06 | |
1179 | #define ALC880_DIGIN_NID 0x0a | |
1180 | ||
1181 | static struct hda_input_mux alc880_capture_source = { | |
1182 | .num_items = 4, | |
1183 | .items = { | |
1184 | { "Mic", 0x0 }, | |
1185 | { "Front Mic", 0x3 }, | |
1186 | { "Line", 0x2 }, | |
1187 | { "CD", 0x4 }, | |
1188 | }, | |
1189 | }; | |
1190 | ||
1191 | /* channel source setting (2/6 channel selection for 3-stack) */ | |
1192 | /* 2ch mode */ | |
1193 | static struct hda_verb alc880_threestack_ch2_init[] = { | |
1194 | /* set line-in to input, mute it */ | |
1195 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1196 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1197 | /* set mic-in to input vref 80%, mute it */ | |
1198 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
1199 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
1200 | { } /* end */ | |
1201 | }; | |
1202 | ||
1203 | /* 6ch mode */ | |
1204 | static struct hda_verb alc880_threestack_ch6_init[] = { | |
1205 | /* set line-in to output, unmute it */ | |
1206 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1207 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1208 | /* set mic-in to output, unmute it */ | |
1209 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1210 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1211 | { } /* end */ | |
1212 | }; | |
1213 | ||
d2a6d7dc | 1214 | static struct hda_channel_mode alc880_threestack_modes[2] = { |
e9edcee0 TI |
1215 | { 2, alc880_threestack_ch2_init }, |
1216 | { 6, alc880_threestack_ch6_init }, | |
1217 | }; | |
1218 | ||
c8b6bf9b | 1219 | static struct snd_kcontrol_new alc880_three_stack_mixer[] = { |
05acb863 | 1220 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1221 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 1222 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 1223 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), |
05acb863 TI |
1224 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1225 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1226 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1227 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1da177e4 LT |
1228 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1229 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1230 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1231 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1232 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1233 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1234 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
1235 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
1236 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1237 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
e9edcee0 TI |
1238 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), |
1239 | { | |
1240 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1241 | .name = "Channel Mode", | |
df694daa KY |
1242 | .info = alc_ch_mode_info, |
1243 | .get = alc_ch_mode_get, | |
1244 | .put = alc_ch_mode_put, | |
e9edcee0 TI |
1245 | }, |
1246 | { } /* end */ | |
1247 | }; | |
1248 | ||
1249 | /* capture mixer elements */ | |
f9e336f6 TI |
1250 | static int alc_cap_vol_info(struct snd_kcontrol *kcontrol, |
1251 | struct snd_ctl_elem_info *uinfo) | |
1252 | { | |
1253 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1254 | struct alc_spec *spec = codec->spec; | |
1255 | int err; | |
1da177e4 | 1256 | |
f9e336f6 TI |
1257 | mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ |
1258 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, | |
1259 | HDA_INPUT); | |
1260 | err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); | |
1261 | mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */ | |
1262 | return err; | |
1263 | } | |
1264 | ||
1265 | static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, | |
1266 | unsigned int size, unsigned int __user *tlv) | |
1267 | { | |
1268 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1269 | struct alc_spec *spec = codec->spec; | |
1270 | int err; | |
1da177e4 | 1271 | |
f9e336f6 TI |
1272 | mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ |
1273 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, | |
1274 | HDA_INPUT); | |
1275 | err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); | |
1276 | mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */ | |
1277 | return err; | |
1278 | } | |
1279 | ||
1280 | typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol, | |
1281 | struct snd_ctl_elem_value *ucontrol); | |
1282 | ||
1283 | static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol, | |
1284 | struct snd_ctl_elem_value *ucontrol, | |
1285 | getput_call_t func) | |
1286 | { | |
1287 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
1288 | struct alc_spec *spec = codec->spec; | |
1289 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
1290 | int err; | |
1291 | ||
1292 | mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ | |
1293 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx], | |
1294 | 3, 0, HDA_INPUT); | |
1295 | err = func(kcontrol, ucontrol); | |
1296 | mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */ | |
1297 | return err; | |
1298 | } | |
1299 | ||
1300 | static int alc_cap_vol_get(struct snd_kcontrol *kcontrol, | |
1301 | struct snd_ctl_elem_value *ucontrol) | |
1302 | { | |
1303 | return alc_cap_getput_caller(kcontrol, ucontrol, | |
1304 | snd_hda_mixer_amp_volume_get); | |
1305 | } | |
1306 | ||
1307 | static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, | |
1308 | struct snd_ctl_elem_value *ucontrol) | |
1309 | { | |
1310 | return alc_cap_getput_caller(kcontrol, ucontrol, | |
1311 | snd_hda_mixer_amp_volume_put); | |
1312 | } | |
1313 | ||
1314 | /* capture mixer elements */ | |
1315 | #define alc_cap_sw_info snd_ctl_boolean_stereo_info | |
1316 | ||
1317 | static int alc_cap_sw_get(struct snd_kcontrol *kcontrol, | |
1318 | struct snd_ctl_elem_value *ucontrol) | |
1319 | { | |
1320 | return alc_cap_getput_caller(kcontrol, ucontrol, | |
1321 | snd_hda_mixer_amp_switch_get); | |
1322 | } | |
1323 | ||
1324 | static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, | |
1325 | struct snd_ctl_elem_value *ucontrol) | |
1326 | { | |
1327 | return alc_cap_getput_caller(kcontrol, ucontrol, | |
1328 | snd_hda_mixer_amp_switch_put); | |
1329 | } | |
1330 | ||
1331 | #define DEFINE_CAPMIX(num) \ | |
1332 | static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \ | |
1333 | { \ | |
1334 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
1335 | .name = "Capture Switch", \ | |
1336 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ | |
1337 | .count = num, \ | |
1338 | .info = alc_cap_sw_info, \ | |
1339 | .get = alc_cap_sw_get, \ | |
1340 | .put = alc_cap_sw_put, \ | |
1341 | }, \ | |
1342 | { \ | |
1343 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
1344 | .name = "Capture Volume", \ | |
1345 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \ | |
1346 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | |
1347 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \ | |
1348 | .count = num, \ | |
1349 | .info = alc_cap_vol_info, \ | |
1350 | .get = alc_cap_vol_get, \ | |
1351 | .put = alc_cap_vol_put, \ | |
1352 | .tlv = { .c = alc_cap_vol_tlv }, \ | |
1353 | }, \ | |
3c3e9892 TI |
1354 | { \ |
1355 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
1356 | /* .name = "Capture Source", */ \ | |
1357 | .name = "Input Source", \ | |
1358 | .count = num, \ | |
1359 | .info = alc_mux_enum_info, \ | |
1360 | .get = alc_mux_enum_get, \ | |
1361 | .put = alc_mux_enum_put, \ | |
1362 | }, \ | |
f9e336f6 TI |
1363 | { } /* end */ \ |
1364 | } | |
1365 | ||
1366 | /* up to three ADCs */ | |
1367 | DEFINE_CAPMIX(1); | |
1368 | DEFINE_CAPMIX(2); | |
1369 | DEFINE_CAPMIX(3); | |
e9edcee0 TI |
1370 | |
1371 | ||
1372 | /* | |
1373 | * ALC880 5-stack model | |
1374 | * | |
9c7f852e TI |
1375 | * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), |
1376 | * Side = 0x02 (0xd) | |
e9edcee0 TI |
1377 | * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 |
1378 | * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 | |
1379 | */ | |
1380 | ||
1381 | /* additional mixers to alc880_three_stack_mixer */ | |
c8b6bf9b | 1382 | static struct snd_kcontrol_new alc880_five_stack_mixer[] = { |
e9edcee0 | 1383 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1384 | HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), |
1da177e4 LT |
1385 | { } /* end */ |
1386 | }; | |
1387 | ||
e9edcee0 TI |
1388 | /* channel source setting (6/8 channel selection for 5-stack) */ |
1389 | /* 6ch mode */ | |
1390 | static struct hda_verb alc880_fivestack_ch6_init[] = { | |
1391 | /* set line-in to input, mute it */ | |
1392 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
1393 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
dfc0ff62 TI |
1394 | { } /* end */ |
1395 | }; | |
1396 | ||
e9edcee0 TI |
1397 | /* 8ch mode */ |
1398 | static struct hda_verb alc880_fivestack_ch8_init[] = { | |
1399 | /* set line-in to output, unmute it */ | |
1400 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
1401 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
1402 | { } /* end */ | |
1403 | }; | |
1404 | ||
d2a6d7dc | 1405 | static struct hda_channel_mode alc880_fivestack_modes[2] = { |
e9edcee0 TI |
1406 | { 6, alc880_fivestack_ch6_init }, |
1407 | { 8, alc880_fivestack_ch8_init }, | |
1408 | }; | |
1409 | ||
1410 | ||
1411 | /* | |
1412 | * ALC880 6-stack model | |
1413 | * | |
9c7f852e TI |
1414 | * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), |
1415 | * Side = 0x05 (0x0f) | |
e9edcee0 TI |
1416 | * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, |
1417 | * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b | |
1418 | */ | |
1419 | ||
1420 | static hda_nid_t alc880_6st_dac_nids[4] = { | |
1421 | /* front, rear, clfe, rear_surr */ | |
1422 | 0x02, 0x03, 0x04, 0x05 | |
f12ab1e0 | 1423 | }; |
e9edcee0 TI |
1424 | |
1425 | static struct hda_input_mux alc880_6stack_capture_source = { | |
1426 | .num_items = 4, | |
1427 | .items = { | |
1428 | { "Mic", 0x0 }, | |
1429 | { "Front Mic", 0x1 }, | |
1430 | { "Line", 0x2 }, | |
1431 | { "CD", 0x4 }, | |
1432 | }, | |
1433 | }; | |
1434 | ||
1435 | /* fixed 8-channels */ | |
d2a6d7dc | 1436 | static struct hda_channel_mode alc880_sixstack_modes[1] = { |
e9edcee0 TI |
1437 | { 8, NULL }, |
1438 | }; | |
1439 | ||
c8b6bf9b | 1440 | static struct snd_kcontrol_new alc880_six_stack_mixer[] = { |
16ded525 | 1441 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1442 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1443 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1444 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1445 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1446 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1447 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1448 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 | 1449 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 1450 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
16ded525 TI |
1451 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1452 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1453 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1454 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1455 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1456 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1457 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1458 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1459 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1460 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
16ded525 TI |
1461 | { |
1462 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1463 | .name = "Channel Mode", | |
df694daa KY |
1464 | .info = alc_ch_mode_info, |
1465 | .get = alc_ch_mode_get, | |
1466 | .put = alc_ch_mode_put, | |
16ded525 TI |
1467 | }, |
1468 | { } /* end */ | |
1469 | }; | |
1470 | ||
e9edcee0 TI |
1471 | |
1472 | /* | |
1473 | * ALC880 W810 model | |
1474 | * | |
1475 | * W810 has rear IO for: | |
1476 | * Front (DAC 02) | |
1477 | * Surround (DAC 03) | |
1478 | * Center/LFE (DAC 04) | |
1479 | * Digital out (06) | |
1480 | * | |
1481 | * The system also has a pair of internal speakers, and a headphone jack. | |
1482 | * These are both connected to Line2 on the codec, hence to DAC 02. | |
ea1fb29a | 1483 | * |
e9edcee0 TI |
1484 | * There is a variable resistor to control the speaker or headphone |
1485 | * volume. This is a hardware-only device without a software API. | |
1486 | * | |
1487 | * Plugging headphones in will disable the internal speakers. This is | |
1488 | * implemented in hardware, not via the driver using jack sense. In | |
1489 | * a similar fashion, plugging into the rear socket marked "front" will | |
1490 | * disable both the speakers and headphones. | |
1491 | * | |
1492 | * For input, there's a microphone jack, and an "audio in" jack. | |
1493 | * These may not do anything useful with this driver yet, because I | |
1494 | * haven't setup any initialization verbs for these yet... | |
1495 | */ | |
1496 | ||
1497 | static hda_nid_t alc880_w810_dac_nids[3] = { | |
1498 | /* front, rear/surround, clfe */ | |
1499 | 0x02, 0x03, 0x04 | |
16ded525 TI |
1500 | }; |
1501 | ||
e9edcee0 | 1502 | /* fixed 6 channels */ |
d2a6d7dc | 1503 | static struct hda_channel_mode alc880_w810_modes[1] = { |
e9edcee0 TI |
1504 | { 6, NULL } |
1505 | }; | |
1506 | ||
1507 | /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ | |
c8b6bf9b | 1508 | static struct snd_kcontrol_new alc880_w810_base_mixer[] = { |
16ded525 | 1509 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1510 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1511 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1512 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1513 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1514 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1515 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1516 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
e9edcee0 TI |
1517 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
1518 | { } /* end */ | |
1519 | }; | |
1520 | ||
1521 | ||
1522 | /* | |
1523 | * Z710V model | |
1524 | * | |
1525 | * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) | |
9c7f852e TI |
1526 | * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), |
1527 | * Line = 0x1a | |
e9edcee0 TI |
1528 | */ |
1529 | ||
1530 | static hda_nid_t alc880_z71v_dac_nids[1] = { | |
1531 | 0x02 | |
1532 | }; | |
1533 | #define ALC880_Z71V_HP_DAC 0x03 | |
1534 | ||
1535 | /* fixed 2 channels */ | |
d2a6d7dc | 1536 | static struct hda_channel_mode alc880_2_jack_modes[1] = { |
e9edcee0 TI |
1537 | { 2, NULL } |
1538 | }; | |
1539 | ||
c8b6bf9b | 1540 | static struct snd_kcontrol_new alc880_z71v_mixer[] = { |
e9edcee0 | 1541 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1542 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
e9edcee0 | 1543 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1544 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1545 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1546 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
16ded525 TI |
1547 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1548 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1549 | { } /* end */ |
1550 | }; | |
1551 | ||
e9edcee0 | 1552 | |
e9edcee0 TI |
1553 | /* |
1554 | * ALC880 F1734 model | |
1555 | * | |
1556 | * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) | |
1557 | * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 | |
1558 | */ | |
1559 | ||
1560 | static hda_nid_t alc880_f1734_dac_nids[1] = { | |
1561 | 0x03 | |
1562 | }; | |
1563 | #define ALC880_F1734_HP_DAC 0x02 | |
1564 | ||
c8b6bf9b | 1565 | static struct snd_kcontrol_new alc880_f1734_mixer[] = { |
e9edcee0 | 1566 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1567 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), |
2134ea4f TI |
1568 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
1569 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
e9edcee0 TI |
1570 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1571 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
937b4160 TI |
1572 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
1573 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
e9edcee0 TI |
1574 | { } /* end */ |
1575 | }; | |
1576 | ||
937b4160 TI |
1577 | static struct hda_input_mux alc880_f1734_capture_source = { |
1578 | .num_items = 2, | |
1579 | .items = { | |
1580 | { "Mic", 0x1 }, | |
1581 | { "CD", 0x4 }, | |
1582 | }, | |
1583 | }; | |
1584 | ||
e9edcee0 | 1585 | |
e9edcee0 TI |
1586 | /* |
1587 | * ALC880 ASUS model | |
1588 | * | |
1589 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1590 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1591 | * Mic = 0x18, Line = 0x1a | |
1592 | */ | |
1593 | ||
1594 | #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ | |
1595 | #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ | |
1596 | ||
c8b6bf9b | 1597 | static struct snd_kcontrol_new alc880_asus_mixer[] = { |
16ded525 | 1598 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 1599 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
16ded525 | 1600 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 1601 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
16ded525 TI |
1602 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1603 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
1604 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
1605 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
16ded525 TI |
1606 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
1607 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1608 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1609 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
16ded525 TI |
1610 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1611 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
16ded525 TI |
1612 | { |
1613 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1614 | .name = "Channel Mode", | |
df694daa KY |
1615 | .info = alc_ch_mode_info, |
1616 | .get = alc_ch_mode_get, | |
1617 | .put = alc_ch_mode_put, | |
16ded525 TI |
1618 | }, |
1619 | { } /* end */ | |
1620 | }; | |
e9edcee0 | 1621 | |
e9edcee0 TI |
1622 | /* |
1623 | * ALC880 ASUS W1V model | |
1624 | * | |
1625 | * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) | |
1626 | * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, | |
1627 | * Mic = 0x18, Line = 0x1a, Line2 = 0x1b | |
1628 | */ | |
1629 | ||
1630 | /* additional mixers to alc880_asus_mixer */ | |
c8b6bf9b | 1631 | static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { |
e9edcee0 TI |
1632 | HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), |
1633 | HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
1634 | { } /* end */ | |
1635 | }; | |
1636 | ||
3c10a9d9 | 1637 | /* additional mixers to alc880_asus_mixer */ |
c8b6bf9b | 1638 | static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { |
3c10a9d9 TI |
1639 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), |
1640 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1641 | { } /* end */ | |
1642 | }; | |
e9edcee0 | 1643 | |
df694daa KY |
1644 | /* TCL S700 */ |
1645 | static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { | |
1646 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1647 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
1648 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
1649 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), | |
1650 | HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), | |
1651 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), | |
1652 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), | |
1653 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
1654 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
df694daa KY |
1655 | { } /* end */ |
1656 | }; | |
1657 | ||
ccc656ce KY |
1658 | /* Uniwill */ |
1659 | static struct snd_kcontrol_new alc880_uniwill_mixer[] = { | |
2134ea4f TI |
1660 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1661 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1662 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1663 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
ccc656ce KY |
1664 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
1665 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
1666 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
1667 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
1668 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1669 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1670 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
1671 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
1672 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1673 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1674 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1675 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1676 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
1677 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1678 | { | |
1679 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1680 | .name = "Channel Mode", | |
1681 | .info = alc_ch_mode_info, | |
1682 | .get = alc_ch_mode_get, | |
1683 | .put = alc_ch_mode_put, | |
1684 | }, | |
1685 | { } /* end */ | |
1686 | }; | |
1687 | ||
2cf9f0fc TD |
1688 | static struct snd_kcontrol_new alc880_fujitsu_mixer[] = { |
1689 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
1690 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1691 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1692 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
1693 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
1694 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
1695 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
1696 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1697 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
1698 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
1699 | { } /* end */ | |
1700 | }; | |
1701 | ||
ccc656ce | 1702 | static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = { |
2134ea4f TI |
1703 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
1704 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
1705 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
1706 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
ccc656ce KY |
1707 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
1708 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
1709 | { } /* end */ | |
1710 | }; | |
1711 | ||
2134ea4f TI |
1712 | /* |
1713 | * virtual master controls | |
1714 | */ | |
1715 | ||
1716 | /* | |
1717 | * slave controls for virtual master | |
1718 | */ | |
1719 | static const char *alc_slave_vols[] = { | |
1720 | "Front Playback Volume", | |
1721 | "Surround Playback Volume", | |
1722 | "Center Playback Volume", | |
1723 | "LFE Playback Volume", | |
1724 | "Side Playback Volume", | |
1725 | "Headphone Playback Volume", | |
1726 | "Speaker Playback Volume", | |
1727 | "Mono Playback Volume", | |
2134ea4f TI |
1728 | "Line-Out Playback Volume", |
1729 | NULL, | |
1730 | }; | |
1731 | ||
1732 | static const char *alc_slave_sws[] = { | |
1733 | "Front Playback Switch", | |
1734 | "Surround Playback Switch", | |
1735 | "Center Playback Switch", | |
1736 | "LFE Playback Switch", | |
1737 | "Side Playback Switch", | |
1738 | "Headphone Playback Switch", | |
1739 | "Speaker Playback Switch", | |
1740 | "Mono Playback Switch", | |
edb54a55 | 1741 | "IEC958 Playback Switch", |
2134ea4f TI |
1742 | NULL, |
1743 | }; | |
1744 | ||
1da177e4 | 1745 | /* |
e9edcee0 | 1746 | * build control elements |
1da177e4 | 1747 | */ |
603c4019 TI |
1748 | |
1749 | static void alc_free_kctls(struct hda_codec *codec); | |
1750 | ||
1da177e4 LT |
1751 | static int alc_build_controls(struct hda_codec *codec) |
1752 | { | |
1753 | struct alc_spec *spec = codec->spec; | |
1754 | int err; | |
1755 | int i; | |
1756 | ||
1757 | for (i = 0; i < spec->num_mixers; i++) { | |
1758 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | |
1759 | if (err < 0) | |
1760 | return err; | |
1761 | } | |
f9e336f6 TI |
1762 | if (spec->cap_mixer) { |
1763 | err = snd_hda_add_new_ctls(codec, spec->cap_mixer); | |
1764 | if (err < 0) | |
1765 | return err; | |
1766 | } | |
1da177e4 | 1767 | if (spec->multiout.dig_out_nid) { |
9c7f852e TI |
1768 | err = snd_hda_create_spdif_out_ctls(codec, |
1769 | spec->multiout.dig_out_nid); | |
1da177e4 LT |
1770 | if (err < 0) |
1771 | return err; | |
9a08160b TI |
1772 | err = snd_hda_create_spdif_share_sw(codec, |
1773 | &spec->multiout); | |
1774 | if (err < 0) | |
1775 | return err; | |
1776 | spec->multiout.share_spdif = 1; | |
1da177e4 LT |
1777 | } |
1778 | if (spec->dig_in_nid) { | |
1779 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); | |
1780 | if (err < 0) | |
1781 | return err; | |
1782 | } | |
2134ea4f TI |
1783 | |
1784 | /* if we have no master control, let's create it */ | |
1785 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { | |
1c82ed1b | 1786 | unsigned int vmaster_tlv[4]; |
2134ea4f | 1787 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
1c82ed1b | 1788 | HDA_OUTPUT, vmaster_tlv); |
2134ea4f | 1789 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
1c82ed1b | 1790 | vmaster_tlv, alc_slave_vols); |
2134ea4f TI |
1791 | if (err < 0) |
1792 | return err; | |
1793 | } | |
1794 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { | |
1795 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", | |
1796 | NULL, alc_slave_sws); | |
1797 | if (err < 0) | |
1798 | return err; | |
1799 | } | |
1800 | ||
603c4019 | 1801 | alc_free_kctls(codec); /* no longer needed */ |
1da177e4 LT |
1802 | return 0; |
1803 | } | |
1804 | ||
e9edcee0 | 1805 | |
1da177e4 LT |
1806 | /* |
1807 | * initialize the codec volumes, etc | |
1808 | */ | |
1809 | ||
e9edcee0 TI |
1810 | /* |
1811 | * generic initialization of ADC, input mixers and output mixers | |
1812 | */ | |
1813 | static struct hda_verb alc880_volume_init_verbs[] = { | |
1814 | /* | |
1815 | * Unmute ADC0-2 and set the default input to mic-in | |
1816 | */ | |
71fe7b82 | 1817 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1818 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 1819 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1820 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
71fe7b82 | 1821 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 1822 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 | 1823 | |
e9edcee0 TI |
1824 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
1825 | * mixer widget | |
9c7f852e TI |
1826 | * Note: PASD motherboards uses the Line In 2 as the input for front |
1827 | * panel mic (mic 2) | |
1da177e4 | 1828 | */ |
e9edcee0 | 1829 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ |
cb53c626 TI |
1830 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1831 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1832 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
1833 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
1834 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1835 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
1836 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
1da177e4 | 1837 | |
e9edcee0 TI |
1838 | /* |
1839 | * Set up output mixers (0x0c - 0x0f) | |
1da177e4 | 1840 | */ |
e9edcee0 TI |
1841 | /* set vol=0 to output mixers */ |
1842 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1843 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1844 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1845 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
1846 | /* set up input amps for analog loopback */ | |
1847 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
05acb863 TI |
1848 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1849 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1850 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1851 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1852 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1853 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
05acb863 TI |
1854 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
1855 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
1856 | |
1857 | { } | |
1858 | }; | |
1859 | ||
e9edcee0 TI |
1860 | /* |
1861 | * 3-stack pin configuration: | |
1862 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
1863 | */ | |
1864 | static struct hda_verb alc880_pin_3stack_init_verbs[] = { | |
1865 | /* | |
1866 | * preset connection lists of input pins | |
1867 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1868 | */ | |
1869 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
1870 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1871 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
1872 | ||
1873 | /* | |
1874 | * Set pin mode and muting | |
1875 | */ | |
1876 | /* set front pin widgets 0x14 for output */ | |
05acb863 | 1877 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1878 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1879 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1880 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1881 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1882 | /* Mic2 (as headphone out) for HP output */ | |
1883 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1884 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1da177e4 | 1885 | /* Line In pin widget for input */ |
05acb863 | 1886 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
1887 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1888 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1889 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1890 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1da177e4 | 1891 | /* CD pin widget for input */ |
05acb863 | 1892 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 1893 | |
e9edcee0 TI |
1894 | { } |
1895 | }; | |
1da177e4 | 1896 | |
e9edcee0 TI |
1897 | /* |
1898 | * 5-stack pin configuration: | |
1899 | * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, | |
1900 | * line-in/side = 0x1a, f-mic = 0x1b | |
1901 | */ | |
1902 | static struct hda_verb alc880_pin_5stack_init_verbs[] = { | |
1903 | /* | |
1904 | * preset connection lists of input pins | |
1905 | * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround | |
1da177e4 | 1906 | */ |
e9edcee0 TI |
1907 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
1908 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ | |
1da177e4 | 1909 | |
e9edcee0 TI |
1910 | /* |
1911 | * Set pin mode and muting | |
1da177e4 | 1912 | */ |
e9edcee0 TI |
1913 | /* set pin widgets 0x14-0x17 for output */ |
1914 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1915 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1916 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1917 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
1918 | /* unmute pins for output (no gain on this amp) */ | |
1919 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1920 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1921 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1922 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1923 | ||
1924 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
1925 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1926 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1927 | /* Mic2 (as headphone out) for HP output */ | |
1928 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
1929 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
1930 | /* Line In pin widget for input */ | |
1931 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1932 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1933 | /* Line2 (as front mic) pin widget for input and vref at 80% */ | |
1934 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
1935 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
1936 | /* CD pin widget for input */ | |
1937 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
1da177e4 LT |
1938 | |
1939 | { } | |
1940 | }; | |
1941 | ||
e9edcee0 TI |
1942 | /* |
1943 | * W810 pin configuration: | |
1944 | * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b | |
1945 | */ | |
1946 | static struct hda_verb alc880_pin_w810_init_verbs[] = { | |
1947 | /* hphone/speaker input selector: front DAC */ | |
1948 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
1da177e4 | 1949 | |
05acb863 | 1950 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1951 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1952 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1953 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1954 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1955 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 1956 | |
e9edcee0 | 1957 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
05acb863 | 1958 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
1da177e4 | 1959 | |
1da177e4 LT |
1960 | { } |
1961 | }; | |
1962 | ||
e9edcee0 TI |
1963 | /* |
1964 | * Z71V pin configuration: | |
1965 | * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) | |
1966 | */ | |
1967 | static struct hda_verb alc880_pin_z71v_init_verbs[] = { | |
05acb863 | 1968 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1969 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
05acb863 | 1970 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 1971 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
dfc0ff62 | 1972 | |
16ded525 | 1973 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1974 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 | 1975 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1976 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16ded525 TI |
1977 | |
1978 | { } | |
1979 | }; | |
1980 | ||
e9edcee0 TI |
1981 | /* |
1982 | * 6-stack pin configuration: | |
9c7f852e TI |
1983 | * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, |
1984 | * f-mic = 0x19, line = 0x1a, HP = 0x1b | |
e9edcee0 TI |
1985 | */ |
1986 | static struct hda_verb alc880_pin_6stack_init_verbs[] = { | |
1987 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
1988 | ||
16ded525 | 1989 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1990 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1991 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1992 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1993 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 1994 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 1995 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
1996 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1997 | ||
16ded525 | 1998 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 1999 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2000 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 | 2001 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2002 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 | 2003 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2004 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
e9edcee0 | 2005 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2006 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
ea1fb29a | 2007 | |
e9edcee0 TI |
2008 | { } |
2009 | }; | |
2010 | ||
ccc656ce KY |
2011 | /* |
2012 | * Uniwill pin configuration: | |
2013 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19, | |
2014 | * line = 0x1a | |
2015 | */ | |
2016 | static struct hda_verb alc880_uniwill_init_verbs[] = { | |
2017 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2018 | ||
2019 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2020 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2021 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2022 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2023 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2024 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2025 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2026 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2027 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2028 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2029 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2030 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2031 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2032 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2033 | ||
2034 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2035 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2036 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2037 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2038 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2039 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2040 | /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */ | |
2041 | /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ | |
2042 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2043 | ||
2044 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
2045 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
2046 | ||
2047 | { } | |
2048 | }; | |
2049 | ||
2050 | /* | |
2051 | * Uniwill P53 | |
ea1fb29a | 2052 | * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, |
ccc656ce KY |
2053 | */ |
2054 | static struct hda_verb alc880_uniwill_p53_init_verbs[] = { | |
2055 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2056 | ||
2057 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2058 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2059 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2060 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2061 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2062 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2063 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2064 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2065 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2066 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2067 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
2068 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
2069 | ||
2070 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2071 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2072 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2073 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2074 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2075 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2076 | ||
2077 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
2078 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT}, | |
2079 | ||
2080 | { } | |
2081 | }; | |
2082 | ||
2cf9f0fc TD |
2083 | static struct hda_verb alc880_beep_init_verbs[] = { |
2084 | { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) }, | |
2085 | { } | |
2086 | }; | |
2087 | ||
ccc656ce | 2088 | /* toggle speaker-output according to the hp-jack state */ |
458a4fab | 2089 | static void alc880_uniwill_hp_automute(struct hda_codec *codec) |
ccc656ce KY |
2090 | { |
2091 | unsigned int present; | |
f12ab1e0 | 2092 | unsigned char bits; |
ccc656ce KY |
2093 | |
2094 | present = snd_hda_codec_read(codec, 0x14, 0, | |
2095 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2096 | bits = present ? HDA_AMP_MUTE : 0; |
2097 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
2098 | HDA_AMP_MUTE, bits); | |
2099 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
2100 | HDA_AMP_MUTE, bits); | |
458a4fab TI |
2101 | } |
2102 | ||
2103 | /* auto-toggle front mic */ | |
2104 | static void alc880_uniwill_mic_automute(struct hda_codec *codec) | |
2105 | { | |
2106 | unsigned int present; | |
2107 | unsigned char bits; | |
ccc656ce KY |
2108 | |
2109 | present = snd_hda_codec_read(codec, 0x18, 0, | |
2110 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2111 | bits = present ? HDA_AMP_MUTE : 0; |
2112 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | |
458a4fab TI |
2113 | } |
2114 | ||
2115 | static void alc880_uniwill_automute(struct hda_codec *codec) | |
2116 | { | |
2117 | alc880_uniwill_hp_automute(codec); | |
2118 | alc880_uniwill_mic_automute(codec); | |
ccc656ce KY |
2119 | } |
2120 | ||
2121 | static void alc880_uniwill_unsol_event(struct hda_codec *codec, | |
2122 | unsigned int res) | |
2123 | { | |
2124 | /* Looks like the unsol event is incompatible with the standard | |
2125 | * definition. 4bit tag is placed at 28 bit! | |
2126 | */ | |
458a4fab TI |
2127 | switch (res >> 28) { |
2128 | case ALC880_HP_EVENT: | |
2129 | alc880_uniwill_hp_automute(codec); | |
2130 | break; | |
2131 | case ALC880_MIC_EVENT: | |
2132 | alc880_uniwill_mic_automute(codec); | |
2133 | break; | |
2134 | } | |
ccc656ce KY |
2135 | } |
2136 | ||
2137 | static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) | |
2138 | { | |
2139 | unsigned int present; | |
f12ab1e0 | 2140 | unsigned char bits; |
ccc656ce KY |
2141 | |
2142 | present = snd_hda_codec_read(codec, 0x14, 0, | |
2143 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a | 2144 | bits = present ? HDA_AMP_MUTE : 0; |
64654c2f | 2145 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits); |
ccc656ce KY |
2146 | } |
2147 | ||
2148 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) | |
2149 | { | |
2150 | unsigned int present; | |
ea1fb29a | 2151 | |
ccc656ce | 2152 | present = snd_hda_codec_read(codec, 0x21, 0, |
47fd830a TI |
2153 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
2154 | present &= HDA_AMP_VOLMASK; | |
2155 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, | |
2156 | HDA_AMP_VOLMASK, present); | |
2157 | snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0, | |
2158 | HDA_AMP_VOLMASK, present); | |
ccc656ce | 2159 | } |
47fd830a | 2160 | |
ccc656ce KY |
2161 | static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec, |
2162 | unsigned int res) | |
2163 | { | |
2164 | /* Looks like the unsol event is incompatible with the standard | |
2165 | * definition. 4bit tag is placed at 28 bit! | |
2166 | */ | |
2167 | if ((res >> 28) == ALC880_HP_EVENT) | |
2168 | alc880_uniwill_p53_hp_automute(codec); | |
f12ab1e0 | 2169 | if ((res >> 28) == ALC880_DCVOL_EVENT) |
ccc656ce KY |
2170 | alc880_uniwill_p53_dcvol_automute(codec); |
2171 | } | |
2172 | ||
e9edcee0 TI |
2173 | /* |
2174 | * F1734 pin configuration: | |
2175 | * HP = 0x14, speaker-out = 0x15, mic = 0x18 | |
2176 | */ | |
2177 | static struct hda_verb alc880_pin_f1734_init_verbs[] = { | |
ee7a9c7c | 2178 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x01}, |
16ded525 TI |
2179 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
2180 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2181 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2182 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2183 | ||
e9edcee0 | 2184 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
16ded525 | 2185 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
e9edcee0 | 2186 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
16ded525 | 2187 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2188 | |
e9edcee0 TI |
2189 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
2190 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
ee7a9c7c | 2191 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, |
e9edcee0 | 2192 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
16ded525 | 2193 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2194 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2195 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2196 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2197 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
dfc0ff62 | 2198 | |
937b4160 TI |
2199 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, |
2200 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT}, | |
2201 | ||
dfc0ff62 TI |
2202 | { } |
2203 | }; | |
2204 | ||
e9edcee0 TI |
2205 | /* |
2206 | * ASUS pin configuration: | |
2207 | * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a | |
2208 | */ | |
2209 | static struct hda_verb alc880_pin_asus_init_verbs[] = { | |
16ded525 TI |
2210 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, |
2211 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2212 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2213 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2214 | ||
2215 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
e9edcee0 | 2216 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2217 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2218 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2219 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2220 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2221 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 TI |
2222 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
2223 | ||
2224 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2225 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2226 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2227 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2228 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2229 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
16ded525 | 2230 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
e9edcee0 | 2231 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
16ded525 | 2232 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
ea1fb29a | 2233 | |
e9edcee0 TI |
2234 | { } |
2235 | }; | |
16ded525 | 2236 | |
e9edcee0 | 2237 | /* Enable GPIO mask and set output */ |
bc9f98a9 KY |
2238 | #define alc880_gpio1_init_verbs alc_gpio1_init_verbs |
2239 | #define alc880_gpio2_init_verbs alc_gpio2_init_verbs | |
df694daa KY |
2240 | |
2241 | /* Clevo m520g init */ | |
2242 | static struct hda_verb alc880_pin_clevo_init_verbs[] = { | |
2243 | /* headphone output */ | |
2244 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2245 | /* line-out */ | |
2246 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2247 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2248 | /* Line-in */ | |
2249 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2250 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2251 | /* CD */ | |
2252 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2253 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2254 | /* Mic1 (rear panel) */ | |
2255 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2256 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2257 | /* Mic2 (front panel) */ | |
2258 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2259 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2260 | /* headphone */ | |
2261 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2262 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2263 | /* change to EAPD mode */ | |
2264 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2265 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2266 | ||
2267 | { } | |
16ded525 TI |
2268 | }; |
2269 | ||
df694daa | 2270 | static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { |
4b146cb0 TI |
2271 | /* change to EAPD mode */ |
2272 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2273 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2274 | ||
df694daa KY |
2275 | /* Headphone output */ |
2276 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2277 | /* Front output*/ | |
2278 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2279 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
2280 | ||
2281 | /* Line In pin widget for input */ | |
2282 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2283 | /* CD pin widget for input */ | |
2284 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2285 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2286 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2287 | ||
2288 | /* change to EAPD mode */ | |
2289 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2290 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
2291 | ||
2292 | { } | |
2293 | }; | |
16ded525 | 2294 | |
e9edcee0 | 2295 | /* |
ae6b813a TI |
2296 | * LG m1 express dual |
2297 | * | |
2298 | * Pin assignment: | |
2299 | * Rear Line-In/Out (blue): 0x14 | |
2300 | * Build-in Mic-In: 0x15 | |
2301 | * Speaker-out: 0x17 | |
2302 | * HP-Out (green): 0x1b | |
2303 | * Mic-In/Out (red): 0x19 | |
2304 | * SPDIF-Out: 0x1e | |
2305 | */ | |
2306 | ||
2307 | /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */ | |
2308 | static hda_nid_t alc880_lg_dac_nids[3] = { | |
2309 | 0x05, 0x02, 0x03 | |
2310 | }; | |
2311 | ||
2312 | /* seems analog CD is not working */ | |
2313 | static struct hda_input_mux alc880_lg_capture_source = { | |
2314 | .num_items = 3, | |
2315 | .items = { | |
2316 | { "Mic", 0x1 }, | |
2317 | { "Line", 0x5 }, | |
2318 | { "Internal Mic", 0x6 }, | |
2319 | }, | |
2320 | }; | |
2321 | ||
2322 | /* 2,4,6 channel modes */ | |
2323 | static struct hda_verb alc880_lg_ch2_init[] = { | |
2324 | /* set line-in and mic-in to input */ | |
2325 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
2326 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
2327 | { } | |
2328 | }; | |
2329 | ||
2330 | static struct hda_verb alc880_lg_ch4_init[] = { | |
2331 | /* set line-in to out and mic-in to input */ | |
2332 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2333 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
2334 | { } | |
2335 | }; | |
2336 | ||
2337 | static struct hda_verb alc880_lg_ch6_init[] = { | |
2338 | /* set line-in and mic-in to output */ | |
2339 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2340 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | |
2341 | { } | |
2342 | }; | |
2343 | ||
2344 | static struct hda_channel_mode alc880_lg_ch_modes[3] = { | |
2345 | { 2, alc880_lg_ch2_init }, | |
2346 | { 4, alc880_lg_ch4_init }, | |
2347 | { 6, alc880_lg_ch6_init }, | |
2348 | }; | |
2349 | ||
2350 | static struct snd_kcontrol_new alc880_lg_mixer[] = { | |
2134ea4f TI |
2351 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
2352 | HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT), | |
ae6b813a TI |
2353 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2354 | HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT), | |
2355 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), | |
2356 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
2357 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
2358 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
2359 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2360 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2361 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
2362 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
2363 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT), | |
2364 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT), | |
2365 | { | |
2366 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2367 | .name = "Channel Mode", | |
2368 | .info = alc_ch_mode_info, | |
2369 | .get = alc_ch_mode_get, | |
2370 | .put = alc_ch_mode_put, | |
2371 | }, | |
2372 | { } /* end */ | |
2373 | }; | |
2374 | ||
2375 | static struct hda_verb alc880_lg_init_verbs[] = { | |
2376 | /* set capture source to mic-in */ | |
2377 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2378 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2379 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2380 | /* mute all amp mixer inputs */ | |
2381 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, | |
cb53c626 TI |
2382 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, |
2383 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
ae6b813a TI |
2384 | /* line-in to input */ |
2385 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2386 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2387 | /* built-in mic */ | |
2388 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2389 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2390 | /* speaker-out */ | |
2391 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2392 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2393 | /* mic-in to input */ | |
2394 | {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
2395 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2396 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2397 | /* HP-out */ | |
2398 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
2399 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2400 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2401 | /* jack sense */ | |
2402 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
2403 | { } | |
2404 | }; | |
2405 | ||
2406 | /* toggle speaker-output according to the hp-jack state */ | |
2407 | static void alc880_lg_automute(struct hda_codec *codec) | |
2408 | { | |
2409 | unsigned int present; | |
f12ab1e0 | 2410 | unsigned char bits; |
ae6b813a TI |
2411 | |
2412 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
2413 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2414 | bits = present ? HDA_AMP_MUTE : 0; |
2415 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
2416 | HDA_AMP_MUTE, bits); | |
ae6b813a TI |
2417 | } |
2418 | ||
2419 | static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) | |
2420 | { | |
2421 | /* Looks like the unsol event is incompatible with the standard | |
2422 | * definition. 4bit tag is placed at 28 bit! | |
2423 | */ | |
2424 | if ((res >> 28) == 0x01) | |
2425 | alc880_lg_automute(codec); | |
2426 | } | |
2427 | ||
d681518a TI |
2428 | /* |
2429 | * LG LW20 | |
2430 | * | |
2431 | * Pin assignment: | |
2432 | * Speaker-out: 0x14 | |
2433 | * Mic-In: 0x18 | |
e4f41da9 CM |
2434 | * Built-in Mic-In: 0x19 |
2435 | * Line-In: 0x1b | |
2436 | * HP-Out: 0x1a | |
d681518a TI |
2437 | * SPDIF-Out: 0x1e |
2438 | */ | |
2439 | ||
d681518a | 2440 | static struct hda_input_mux alc880_lg_lw_capture_source = { |
e4f41da9 | 2441 | .num_items = 3, |
d681518a TI |
2442 | .items = { |
2443 | { "Mic", 0x0 }, | |
2444 | { "Internal Mic", 0x1 }, | |
e4f41da9 | 2445 | { "Line In", 0x2 }, |
d681518a TI |
2446 | }, |
2447 | }; | |
2448 | ||
0a8c5da3 CM |
2449 | #define alc880_lg_lw_modes alc880_threestack_modes |
2450 | ||
d681518a | 2451 | static struct snd_kcontrol_new alc880_lg_lw_mixer[] = { |
0a8c5da3 CM |
2452 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
2453 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
2454 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
2455 | HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), | |
2456 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
2457 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
2458 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
2459 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
2460 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
2461 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d681518a TI |
2462 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
2463 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2464 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
2465 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
0a8c5da3 CM |
2466 | { |
2467 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2468 | .name = "Channel Mode", | |
2469 | .info = alc_ch_mode_info, | |
2470 | .get = alc_ch_mode_get, | |
2471 | .put = alc_ch_mode_put, | |
2472 | }, | |
d681518a TI |
2473 | { } /* end */ |
2474 | }; | |
2475 | ||
2476 | static struct hda_verb alc880_lg_lw_init_verbs[] = { | |
0a8c5da3 CM |
2477 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
2478 | {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
2479 | {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ | |
2480 | ||
d681518a TI |
2481 | /* set capture source to mic-in */ |
2482 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2483 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
2484 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
cb53c626 | 2485 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, |
d681518a TI |
2486 | /* speaker-out */ |
2487 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2488 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2489 | /* HP-out */ | |
d681518a TI |
2490 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
2491 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2492 | /* mic-in to input */ | |
2493 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2494 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2495 | /* built-in mic */ | |
2496 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2497 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2498 | /* jack sense */ | |
2499 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1}, | |
2500 | { } | |
2501 | }; | |
2502 | ||
2503 | /* toggle speaker-output according to the hp-jack state */ | |
2504 | static void alc880_lg_lw_automute(struct hda_codec *codec) | |
2505 | { | |
2506 | unsigned int present; | |
f12ab1e0 | 2507 | unsigned char bits; |
d681518a TI |
2508 | |
2509 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
2510 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
2511 | bits = present ? HDA_AMP_MUTE : 0; |
2512 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
2513 | HDA_AMP_MUTE, bits); | |
d681518a TI |
2514 | } |
2515 | ||
2516 | static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) | |
2517 | { | |
2518 | /* Looks like the unsol event is incompatible with the standard | |
2519 | * definition. 4bit tag is placed at 28 bit! | |
2520 | */ | |
2521 | if ((res >> 28) == 0x01) | |
2522 | alc880_lg_lw_automute(codec); | |
2523 | } | |
2524 | ||
df99cd33 TI |
2525 | static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { |
2526 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
2527 | HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), | |
2528 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
2529 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2530 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
2531 | HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
2532 | { } /* end */ | |
2533 | }; | |
2534 | ||
2535 | static struct hda_input_mux alc880_medion_rim_capture_source = { | |
2536 | .num_items = 2, | |
2537 | .items = { | |
2538 | { "Mic", 0x0 }, | |
2539 | { "Internal Mic", 0x1 }, | |
2540 | }, | |
2541 | }; | |
2542 | ||
2543 | static struct hda_verb alc880_medion_rim_init_verbs[] = { | |
2544 | {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
2545 | ||
2546 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2547 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2548 | ||
2549 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
2550 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2551 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2552 | /* Mic2 (as headphone out) for HP output */ | |
2553 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
2554 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
2555 | /* Internal Speaker */ | |
2556 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2557 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2558 | ||
2559 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
2560 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, | |
2561 | ||
2562 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
2563 | { } | |
2564 | }; | |
2565 | ||
2566 | /* toggle speaker-output according to the hp-jack state */ | |
2567 | static void alc880_medion_rim_automute(struct hda_codec *codec) | |
2568 | { | |
2569 | unsigned int present; | |
2570 | unsigned char bits; | |
2571 | ||
2572 | present = snd_hda_codec_read(codec, 0x14, 0, | |
2573 | AC_VERB_GET_PIN_SENSE, 0) | |
2574 | & AC_PINSENSE_PRESENCE; | |
2575 | bits = present ? HDA_AMP_MUTE : 0; | |
2576 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
2577 | HDA_AMP_MUTE, bits); | |
2578 | if (present) | |
2579 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); | |
2580 | else | |
2581 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2); | |
2582 | } | |
2583 | ||
2584 | static void alc880_medion_rim_unsol_event(struct hda_codec *codec, | |
2585 | unsigned int res) | |
2586 | { | |
2587 | /* Looks like the unsol event is incompatible with the standard | |
2588 | * definition. 4bit tag is placed at 28 bit! | |
2589 | */ | |
2590 | if ((res >> 28) == ALC880_HP_EVENT) | |
2591 | alc880_medion_rim_automute(codec); | |
2592 | } | |
2593 | ||
cb53c626 TI |
2594 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2595 | static struct hda_amp_list alc880_loopbacks[] = { | |
2596 | { 0x0b, HDA_INPUT, 0 }, | |
2597 | { 0x0b, HDA_INPUT, 1 }, | |
2598 | { 0x0b, HDA_INPUT, 2 }, | |
2599 | { 0x0b, HDA_INPUT, 3 }, | |
2600 | { 0x0b, HDA_INPUT, 4 }, | |
2601 | { } /* end */ | |
2602 | }; | |
2603 | ||
2604 | static struct hda_amp_list alc880_lg_loopbacks[] = { | |
2605 | { 0x0b, HDA_INPUT, 1 }, | |
2606 | { 0x0b, HDA_INPUT, 6 }, | |
2607 | { 0x0b, HDA_INPUT, 7 }, | |
2608 | { } /* end */ | |
2609 | }; | |
2610 | #endif | |
2611 | ||
ae6b813a TI |
2612 | /* |
2613 | * Common callbacks | |
e9edcee0 TI |
2614 | */ |
2615 | ||
1da177e4 LT |
2616 | static int alc_init(struct hda_codec *codec) |
2617 | { | |
2618 | struct alc_spec *spec = codec->spec; | |
e9edcee0 TI |
2619 | unsigned int i; |
2620 | ||
2c3bf9ab | 2621 | alc_fix_pll(codec); |
1082c748 TI |
2622 | if (codec->vendor_id == 0x10ec0888) |
2623 | alc888_coef_init(codec); | |
2c3bf9ab | 2624 | |
e9edcee0 TI |
2625 | for (i = 0; i < spec->num_init_verbs; i++) |
2626 | snd_hda_sequence_write(codec, spec->init_verbs[i]); | |
ae6b813a TI |
2627 | |
2628 | if (spec->init_hook) | |
2629 | spec->init_hook(codec); | |
2630 | ||
1da177e4 LT |
2631 | return 0; |
2632 | } | |
2633 | ||
ae6b813a TI |
2634 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
2635 | { | |
2636 | struct alc_spec *spec = codec->spec; | |
2637 | ||
2638 | if (spec->unsol_event) | |
2639 | spec->unsol_event(codec, res); | |
2640 | } | |
2641 | ||
cb53c626 TI |
2642 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2643 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) | |
2644 | { | |
2645 | struct alc_spec *spec = codec->spec; | |
2646 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); | |
2647 | } | |
2648 | #endif | |
2649 | ||
1da177e4 LT |
2650 | /* |
2651 | * Analog playback callbacks | |
2652 | */ | |
2653 | static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2654 | struct hda_codec *codec, | |
c8b6bf9b | 2655 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2656 | { |
2657 | struct alc_spec *spec = codec->spec; | |
9a08160b TI |
2658 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
2659 | hinfo); | |
1da177e4 LT |
2660 | } |
2661 | ||
2662 | static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |
2663 | struct hda_codec *codec, | |
2664 | unsigned int stream_tag, | |
2665 | unsigned int format, | |
c8b6bf9b | 2666 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2667 | { |
2668 | struct alc_spec *spec = codec->spec; | |
9c7f852e TI |
2669 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
2670 | stream_tag, format, substream); | |
1da177e4 LT |
2671 | } |
2672 | ||
2673 | static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
2674 | struct hda_codec *codec, | |
c8b6bf9b | 2675 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2676 | { |
2677 | struct alc_spec *spec = codec->spec; | |
2678 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | |
2679 | } | |
2680 | ||
2681 | /* | |
2682 | * Digital out | |
2683 | */ | |
2684 | static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2685 | struct hda_codec *codec, | |
c8b6bf9b | 2686 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2687 | { |
2688 | struct alc_spec *spec = codec->spec; | |
2689 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | |
2690 | } | |
2691 | ||
6b97eb45 TI |
2692 | static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
2693 | struct hda_codec *codec, | |
2694 | unsigned int stream_tag, | |
2695 | unsigned int format, | |
2696 | struct snd_pcm_substream *substream) | |
2697 | { | |
2698 | struct alc_spec *spec = codec->spec; | |
2699 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, | |
2700 | stream_tag, format, substream); | |
2701 | } | |
2702 | ||
1da177e4 LT |
2703 | static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
2704 | struct hda_codec *codec, | |
c8b6bf9b | 2705 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2706 | { |
2707 | struct alc_spec *spec = codec->spec; | |
2708 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | |
2709 | } | |
2710 | ||
2711 | /* | |
2712 | * Analog capture | |
2713 | */ | |
6330079f | 2714 | static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
1da177e4 LT |
2715 | struct hda_codec *codec, |
2716 | unsigned int stream_tag, | |
2717 | unsigned int format, | |
c8b6bf9b | 2718 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2719 | { |
2720 | struct alc_spec *spec = codec->spec; | |
2721 | ||
6330079f | 2722 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
1da177e4 LT |
2723 | stream_tag, 0, format); |
2724 | return 0; | |
2725 | } | |
2726 | ||
6330079f | 2727 | static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
1da177e4 | 2728 | struct hda_codec *codec, |
c8b6bf9b | 2729 | struct snd_pcm_substream *substream) |
1da177e4 LT |
2730 | { |
2731 | struct alc_spec *spec = codec->spec; | |
2732 | ||
888afa15 TI |
2733 | snd_hda_codec_cleanup_stream(codec, |
2734 | spec->adc_nids[substream->number + 1]); | |
1da177e4 LT |
2735 | return 0; |
2736 | } | |
2737 | ||
2738 | ||
2739 | /* | |
2740 | */ | |
2741 | static struct hda_pcm_stream alc880_pcm_analog_playback = { | |
2742 | .substreams = 1, | |
2743 | .channels_min = 2, | |
2744 | .channels_max = 8, | |
e9edcee0 | 2745 | /* NID is set in alc_build_pcms */ |
1da177e4 LT |
2746 | .ops = { |
2747 | .open = alc880_playback_pcm_open, | |
2748 | .prepare = alc880_playback_pcm_prepare, | |
2749 | .cleanup = alc880_playback_pcm_cleanup | |
2750 | }, | |
2751 | }; | |
2752 | ||
2753 | static struct hda_pcm_stream alc880_pcm_analog_capture = { | |
6330079f TI |
2754 | .substreams = 1, |
2755 | .channels_min = 2, | |
2756 | .channels_max = 2, | |
2757 | /* NID is set in alc_build_pcms */ | |
2758 | }; | |
2759 | ||
2760 | static struct hda_pcm_stream alc880_pcm_analog_alt_playback = { | |
2761 | .substreams = 1, | |
2762 | .channels_min = 2, | |
2763 | .channels_max = 2, | |
2764 | /* NID is set in alc_build_pcms */ | |
2765 | }; | |
2766 | ||
2767 | static struct hda_pcm_stream alc880_pcm_analog_alt_capture = { | |
2768 | .substreams = 2, /* can be overridden */ | |
1da177e4 LT |
2769 | .channels_min = 2, |
2770 | .channels_max = 2, | |
e9edcee0 | 2771 | /* NID is set in alc_build_pcms */ |
1da177e4 | 2772 | .ops = { |
6330079f TI |
2773 | .prepare = alc880_alt_capture_pcm_prepare, |
2774 | .cleanup = alc880_alt_capture_pcm_cleanup | |
1da177e4 LT |
2775 | }, |
2776 | }; | |
2777 | ||
2778 | static struct hda_pcm_stream alc880_pcm_digital_playback = { | |
2779 | .substreams = 1, | |
2780 | .channels_min = 2, | |
2781 | .channels_max = 2, | |
2782 | /* NID is set in alc_build_pcms */ | |
2783 | .ops = { | |
2784 | .open = alc880_dig_playback_pcm_open, | |
6b97eb45 TI |
2785 | .close = alc880_dig_playback_pcm_close, |
2786 | .prepare = alc880_dig_playback_pcm_prepare | |
1da177e4 LT |
2787 | }, |
2788 | }; | |
2789 | ||
2790 | static struct hda_pcm_stream alc880_pcm_digital_capture = { | |
2791 | .substreams = 1, | |
2792 | .channels_min = 2, | |
2793 | .channels_max = 2, | |
2794 | /* NID is set in alc_build_pcms */ | |
2795 | }; | |
2796 | ||
4c5186ed | 2797 | /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
6330079f | 2798 | static struct hda_pcm_stream alc_pcm_null_stream = { |
4c5186ed JW |
2799 | .substreams = 0, |
2800 | .channels_min = 0, | |
2801 | .channels_max = 0, | |
2802 | }; | |
2803 | ||
1da177e4 LT |
2804 | static int alc_build_pcms(struct hda_codec *codec) |
2805 | { | |
2806 | struct alc_spec *spec = codec->spec; | |
2807 | struct hda_pcm *info = spec->pcm_rec; | |
2808 | int i; | |
2809 | ||
2810 | codec->num_pcms = 1; | |
2811 | codec->pcm_info = info; | |
2812 | ||
2813 | info->name = spec->stream_name_analog; | |
4a471b7d | 2814 | if (spec->stream_analog_playback) { |
da3cec35 TI |
2815 | if (snd_BUG_ON(!spec->multiout.dac_nids)) |
2816 | return -EINVAL; | |
4a471b7d TI |
2817 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); |
2818 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; | |
2819 | } | |
2820 | if (spec->stream_analog_capture) { | |
da3cec35 TI |
2821 | if (snd_BUG_ON(!spec->adc_nids)) |
2822 | return -EINVAL; | |
4a471b7d TI |
2823 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); |
2824 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; | |
2825 | } | |
2826 | ||
2827 | if (spec->channel_mode) { | |
2828 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; | |
2829 | for (i = 0; i < spec->num_channel_mode; i++) { | |
2830 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { | |
2831 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; | |
2832 | } | |
1da177e4 LT |
2833 | } |
2834 | } | |
2835 | ||
e08a007d | 2836 | /* SPDIF for stream index #1 */ |
1da177e4 | 2837 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
e08a007d | 2838 | codec->num_pcms = 2; |
c06134d7 | 2839 | info = spec->pcm_rec + 1; |
1da177e4 | 2840 | info->name = spec->stream_name_digital; |
7ba72ba1 | 2841 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
4a471b7d TI |
2842 | if (spec->multiout.dig_out_nid && |
2843 | spec->stream_digital_playback) { | |
1da177e4 LT |
2844 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); |
2845 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; | |
2846 | } | |
4a471b7d TI |
2847 | if (spec->dig_in_nid && |
2848 | spec->stream_digital_capture) { | |
1da177e4 LT |
2849 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); |
2850 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; | |
2851 | } | |
963f803f TI |
2852 | /* FIXME: do we need this for all Realtek codec models? */ |
2853 | codec->spdif_status_reset = 1; | |
1da177e4 LT |
2854 | } |
2855 | ||
e08a007d TI |
2856 | /* If the use of more than one ADC is requested for the current |
2857 | * model, configure a second analog capture-only PCM. | |
2858 | */ | |
2859 | /* Additional Analaog capture for index #2 */ | |
6330079f TI |
2860 | if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) || |
2861 | (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) { | |
e08a007d | 2862 | codec->num_pcms = 3; |
c06134d7 | 2863 | info = spec->pcm_rec + 2; |
e08a007d | 2864 | info->name = spec->stream_name_analog; |
6330079f TI |
2865 | if (spec->alt_dac_nid) { |
2866 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = | |
2867 | *spec->stream_analog_alt_playback; | |
2868 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = | |
2869 | spec->alt_dac_nid; | |
2870 | } else { | |
2871 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = | |
2872 | alc_pcm_null_stream; | |
2873 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; | |
2874 | } | |
2875 | if (spec->num_adc_nids > 1) { | |
2876 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
2877 | *spec->stream_analog_alt_capture; | |
2878 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = | |
2879 | spec->adc_nids[1]; | |
2880 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = | |
2881 | spec->num_adc_nids - 1; | |
2882 | } else { | |
2883 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | |
2884 | alc_pcm_null_stream; | |
2885 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; | |
e08a007d TI |
2886 | } |
2887 | } | |
2888 | ||
1da177e4 LT |
2889 | return 0; |
2890 | } | |
2891 | ||
603c4019 TI |
2892 | static void alc_free_kctls(struct hda_codec *codec) |
2893 | { | |
2894 | struct alc_spec *spec = codec->spec; | |
2895 | ||
2896 | if (spec->kctls.list) { | |
2897 | struct snd_kcontrol_new *kctl = spec->kctls.list; | |
2898 | int i; | |
2899 | for (i = 0; i < spec->kctls.used; i++) | |
2900 | kfree(kctl[i].name); | |
2901 | } | |
2902 | snd_array_free(&spec->kctls); | |
2903 | } | |
2904 | ||
1da177e4 LT |
2905 | static void alc_free(struct hda_codec *codec) |
2906 | { | |
e9edcee0 | 2907 | struct alc_spec *spec = codec->spec; |
e9edcee0 | 2908 | |
f12ab1e0 | 2909 | if (!spec) |
e9edcee0 TI |
2910 | return; |
2911 | ||
603c4019 | 2912 | alc_free_kctls(codec); |
e9edcee0 | 2913 | kfree(spec); |
7943a8ab | 2914 | codec->spec = NULL; /* to be sure */ |
1da177e4 LT |
2915 | } |
2916 | ||
e044c39a TI |
2917 | #ifdef SND_HDA_NEEDS_RESUME |
2918 | static void store_pin_configs(struct hda_codec *codec) | |
2919 | { | |
2920 | struct alc_spec *spec = codec->spec; | |
2921 | hda_nid_t nid, end_nid; | |
2922 | ||
2923 | end_nid = codec->start_nid + codec->num_nodes; | |
2924 | for (nid = codec->start_nid; nid < end_nid; nid++) { | |
2925 | unsigned int wid_caps = get_wcaps(codec, nid); | |
2926 | unsigned int wid_type = | |
2927 | (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
2928 | if (wid_type != AC_WID_PIN) | |
2929 | continue; | |
2930 | if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids)) | |
2931 | break; | |
2932 | spec->pin_nids[spec->num_pins] = nid; | |
2933 | spec->pin_cfgs[spec->num_pins] = | |
2934 | snd_hda_codec_read(codec, nid, 0, | |
2935 | AC_VERB_GET_CONFIG_DEFAULT, 0); | |
2936 | spec->num_pins++; | |
2937 | } | |
2938 | } | |
2939 | ||
2940 | static void resume_pin_configs(struct hda_codec *codec) | |
2941 | { | |
2942 | struct alc_spec *spec = codec->spec; | |
2943 | int i; | |
2944 | ||
2945 | for (i = 0; i < spec->num_pins; i++) { | |
2946 | hda_nid_t pin_nid = spec->pin_nids[i]; | |
2947 | unsigned int pin_config = spec->pin_cfgs[i]; | |
2948 | snd_hda_codec_write(codec, pin_nid, 0, | |
2949 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0, | |
2950 | pin_config & 0x000000ff); | |
2951 | snd_hda_codec_write(codec, pin_nid, 0, | |
2952 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, | |
2953 | (pin_config & 0x0000ff00) >> 8); | |
2954 | snd_hda_codec_write(codec, pin_nid, 0, | |
2955 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, | |
2956 | (pin_config & 0x00ff0000) >> 16); | |
2957 | snd_hda_codec_write(codec, pin_nid, 0, | |
2958 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, | |
2959 | pin_config >> 24); | |
2960 | } | |
2961 | } | |
2962 | ||
2963 | static int alc_resume(struct hda_codec *codec) | |
2964 | { | |
2965 | resume_pin_configs(codec); | |
2966 | codec->patch_ops.init(codec); | |
2967 | snd_hda_codec_resume_amp(codec); | |
2968 | snd_hda_codec_resume_cache(codec); | |
2969 | return 0; | |
2970 | } | |
2971 | #else | |
2972 | #define store_pin_configs(codec) | |
2973 | #endif | |
2974 | ||
1da177e4 LT |
2975 | /* |
2976 | */ | |
2977 | static struct hda_codec_ops alc_patch_ops = { | |
2978 | .build_controls = alc_build_controls, | |
2979 | .build_pcms = alc_build_pcms, | |
2980 | .init = alc_init, | |
2981 | .free = alc_free, | |
ae6b813a | 2982 | .unsol_event = alc_unsol_event, |
e044c39a TI |
2983 | #ifdef SND_HDA_NEEDS_RESUME |
2984 | .resume = alc_resume, | |
2985 | #endif | |
cb53c626 TI |
2986 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2987 | .check_power_status = alc_check_power_status, | |
2988 | #endif | |
1da177e4 LT |
2989 | }; |
2990 | ||
2fa522be TI |
2991 | |
2992 | /* | |
2993 | * Test configuration for debugging | |
2994 | * | |
2995 | * Almost all inputs/outputs are enabled. I/O pins can be configured via | |
2996 | * enum controls. | |
2997 | */ | |
2998 | #ifdef CONFIG_SND_DEBUG | |
2999 | static hda_nid_t alc880_test_dac_nids[4] = { | |
3000 | 0x02, 0x03, 0x04, 0x05 | |
3001 | }; | |
3002 | ||
3003 | static struct hda_input_mux alc880_test_capture_source = { | |
ae6b813a | 3004 | .num_items = 7, |
2fa522be TI |
3005 | .items = { |
3006 | { "In-1", 0x0 }, | |
3007 | { "In-2", 0x1 }, | |
3008 | { "In-3", 0x2 }, | |
3009 | { "In-4", 0x3 }, | |
3010 | { "CD", 0x4 }, | |
ae6b813a TI |
3011 | { "Front", 0x5 }, |
3012 | { "Surround", 0x6 }, | |
2fa522be TI |
3013 | }, |
3014 | }; | |
3015 | ||
d2a6d7dc | 3016 | static struct hda_channel_mode alc880_test_modes[4] = { |
2fa522be | 3017 | { 2, NULL }, |
fd2c326d | 3018 | { 4, NULL }, |
2fa522be | 3019 | { 6, NULL }, |
fd2c326d | 3020 | { 8, NULL }, |
2fa522be TI |
3021 | }; |
3022 | ||
9c7f852e TI |
3023 | static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, |
3024 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
3025 | { |
3026 | static char *texts[] = { | |
3027 | "N/A", "Line Out", "HP Out", | |
3028 | "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" | |
3029 | }; | |
3030 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
3031 | uinfo->count = 1; | |
3032 | uinfo->value.enumerated.items = 8; | |
3033 | if (uinfo->value.enumerated.item >= 8) | |
3034 | uinfo->value.enumerated.item = 7; | |
3035 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
3036 | return 0; | |
3037 | } | |
3038 | ||
9c7f852e TI |
3039 | static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, |
3040 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
3041 | { |
3042 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3043 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
3044 | unsigned int pin_ctl, item = 0; | |
3045 | ||
3046 | pin_ctl = snd_hda_codec_read(codec, nid, 0, | |
3047 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
3048 | if (pin_ctl & AC_PINCTL_OUT_EN) { | |
3049 | if (pin_ctl & AC_PINCTL_HP_EN) | |
3050 | item = 2; | |
3051 | else | |
3052 | item = 1; | |
3053 | } else if (pin_ctl & AC_PINCTL_IN_EN) { | |
3054 | switch (pin_ctl & AC_PINCTL_VREFEN) { | |
3055 | case AC_PINCTL_VREF_HIZ: item = 3; break; | |
3056 | case AC_PINCTL_VREF_50: item = 4; break; | |
3057 | case AC_PINCTL_VREF_GRD: item = 5; break; | |
3058 | case AC_PINCTL_VREF_80: item = 6; break; | |
3059 | case AC_PINCTL_VREF_100: item = 7; break; | |
3060 | } | |
3061 | } | |
3062 | ucontrol->value.enumerated.item[0] = item; | |
3063 | return 0; | |
3064 | } | |
3065 | ||
9c7f852e TI |
3066 | static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, |
3067 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
3068 | { |
3069 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3070 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
3071 | static unsigned int ctls[] = { | |
3072 | 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, | |
3073 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, | |
3074 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, | |
3075 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, | |
3076 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, | |
3077 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, | |
3078 | }; | |
3079 | unsigned int old_ctl, new_ctl; | |
3080 | ||
3081 | old_ctl = snd_hda_codec_read(codec, nid, 0, | |
3082 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
3083 | new_ctl = ctls[ucontrol->value.enumerated.item[0]]; | |
3084 | if (old_ctl != new_ctl) { | |
82beb8fd TI |
3085 | int val; |
3086 | snd_hda_codec_write_cache(codec, nid, 0, | |
3087 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3088 | new_ctl); | |
47fd830a TI |
3089 | val = ucontrol->value.enumerated.item[0] >= 3 ? |
3090 | HDA_AMP_MUTE : 0; | |
3091 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | |
3092 | HDA_AMP_MUTE, val); | |
2fa522be TI |
3093 | return 1; |
3094 | } | |
3095 | return 0; | |
3096 | } | |
3097 | ||
9c7f852e TI |
3098 | static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, |
3099 | struct snd_ctl_elem_info *uinfo) | |
2fa522be TI |
3100 | { |
3101 | static char *texts[] = { | |
3102 | "Front", "Surround", "CLFE", "Side" | |
3103 | }; | |
3104 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | |
3105 | uinfo->count = 1; | |
3106 | uinfo->value.enumerated.items = 4; | |
3107 | if (uinfo->value.enumerated.item >= 4) | |
3108 | uinfo->value.enumerated.item = 3; | |
3109 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); | |
3110 | return 0; | |
3111 | } | |
3112 | ||
9c7f852e TI |
3113 | static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, |
3114 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
3115 | { |
3116 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3117 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
3118 | unsigned int sel; | |
3119 | ||
3120 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); | |
3121 | ucontrol->value.enumerated.item[0] = sel & 3; | |
3122 | return 0; | |
3123 | } | |
3124 | ||
9c7f852e TI |
3125 | static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, |
3126 | struct snd_ctl_elem_value *ucontrol) | |
2fa522be TI |
3127 | { |
3128 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3129 | hda_nid_t nid = (hda_nid_t)kcontrol->private_value; | |
3130 | unsigned int sel; | |
3131 | ||
3132 | sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; | |
3133 | if (ucontrol->value.enumerated.item[0] != sel) { | |
3134 | sel = ucontrol->value.enumerated.item[0] & 3; | |
82beb8fd TI |
3135 | snd_hda_codec_write_cache(codec, nid, 0, |
3136 | AC_VERB_SET_CONNECT_SEL, sel); | |
2fa522be TI |
3137 | return 1; |
3138 | } | |
3139 | return 0; | |
3140 | } | |
3141 | ||
3142 | #define PIN_CTL_TEST(xname,nid) { \ | |
3143 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
3144 | .name = xname, \ | |
3145 | .info = alc_test_pin_ctl_info, \ | |
3146 | .get = alc_test_pin_ctl_get, \ | |
3147 | .put = alc_test_pin_ctl_put, \ | |
3148 | .private_value = nid \ | |
3149 | } | |
3150 | ||
3151 | #define PIN_SRC_TEST(xname,nid) { \ | |
3152 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
3153 | .name = xname, \ | |
3154 | .info = alc_test_pin_src_info, \ | |
3155 | .get = alc_test_pin_src_get, \ | |
3156 | .put = alc_test_pin_src_put, \ | |
3157 | .private_value = nid \ | |
3158 | } | |
3159 | ||
c8b6bf9b | 3160 | static struct snd_kcontrol_new alc880_test_mixer[] = { |
05acb863 TI |
3161 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
3162 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
3163 | HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
3164 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
985be54b TI |
3165 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
3166 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
3167 | HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), | |
3168 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
2fa522be TI |
3169 | PIN_CTL_TEST("Front Pin Mode", 0x14), |
3170 | PIN_CTL_TEST("Surround Pin Mode", 0x15), | |
3171 | PIN_CTL_TEST("CLFE Pin Mode", 0x16), | |
3172 | PIN_CTL_TEST("Side Pin Mode", 0x17), | |
3173 | PIN_CTL_TEST("In-1 Pin Mode", 0x18), | |
3174 | PIN_CTL_TEST("In-2 Pin Mode", 0x19), | |
3175 | PIN_CTL_TEST("In-3 Pin Mode", 0x1a), | |
3176 | PIN_CTL_TEST("In-4 Pin Mode", 0x1b), | |
3177 | PIN_SRC_TEST("In-1 Pin Source", 0x18), | |
3178 | PIN_SRC_TEST("In-2 Pin Source", 0x19), | |
3179 | PIN_SRC_TEST("In-3 Pin Source", 0x1a), | |
3180 | PIN_SRC_TEST("In-4 Pin Source", 0x1b), | |
3181 | HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
3182 | HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
3183 | HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
3184 | HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
3185 | HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), | |
3186 | HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), | |
3187 | HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), | |
3188 | HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), | |
3189 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), | |
3190 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
2fa522be TI |
3191 | { |
3192 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
3193 | .name = "Channel Mode", | |
df694daa KY |
3194 | .info = alc_ch_mode_info, |
3195 | .get = alc_ch_mode_get, | |
3196 | .put = alc_ch_mode_put, | |
2fa522be TI |
3197 | }, |
3198 | { } /* end */ | |
3199 | }; | |
3200 | ||
3201 | static struct hda_verb alc880_test_init_verbs[] = { | |
3202 | /* Unmute inputs of 0x0c - 0x0f */ | |
05acb863 TI |
3203 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
3204 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
3205 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3206 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
3207 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3208 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
3209 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
3210 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
2fa522be | 3211 | /* Vol output for 0x0c-0x0f */ |
05acb863 TI |
3212 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
3213 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3214 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
3215 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
2fa522be | 3216 | /* Set output pins 0x14-0x17 */ |
05acb863 TI |
3217 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
3218 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
3219 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
3220 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
2fa522be | 3221 | /* Unmute output pins 0x14-0x17 */ |
05acb863 TI |
3222 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
3223 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3224 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
3225 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
2fa522be | 3226 | /* Set input pins 0x18-0x1c */ |
16ded525 TI |
3227 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
3228 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
05acb863 TI |
3229 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
3230 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
3231 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2fa522be | 3232 | /* Mute input pins 0x18-0x1b */ |
05acb863 TI |
3233 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
3234 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
3235 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
3236 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
71fe7b82 | 3237 | /* ADC set up */ |
05acb863 | 3238 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 3239 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 3240 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 3241 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 | 3242 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
71fe7b82 | 3243 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
3244 | /* Analog input/passthru */ |
3245 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
3246 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
3247 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
3248 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
3249 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
2fa522be TI |
3250 | { } |
3251 | }; | |
3252 | #endif | |
3253 | ||
1da177e4 LT |
3254 | /* |
3255 | */ | |
3256 | ||
f5fcc13c TI |
3257 | static const char *alc880_models[ALC880_MODEL_LAST] = { |
3258 | [ALC880_3ST] = "3stack", | |
3259 | [ALC880_TCL_S700] = "tcl", | |
3260 | [ALC880_3ST_DIG] = "3stack-digout", | |
3261 | [ALC880_CLEVO] = "clevo", | |
3262 | [ALC880_5ST] = "5stack", | |
3263 | [ALC880_5ST_DIG] = "5stack-digout", | |
3264 | [ALC880_W810] = "w810", | |
3265 | [ALC880_Z71V] = "z71v", | |
3266 | [ALC880_6ST] = "6stack", | |
3267 | [ALC880_6ST_DIG] = "6stack-digout", | |
3268 | [ALC880_ASUS] = "asus", | |
3269 | [ALC880_ASUS_W1V] = "asus-w1v", | |
3270 | [ALC880_ASUS_DIG] = "asus-dig", | |
3271 | [ALC880_ASUS_DIG2] = "asus-dig2", | |
3272 | [ALC880_UNIWILL_DIG] = "uniwill", | |
2cf9f0fc TD |
3273 | [ALC880_UNIWILL_P53] = "uniwill-p53", |
3274 | [ALC880_FUJITSU] = "fujitsu", | |
f5fcc13c TI |
3275 | [ALC880_F1734] = "F1734", |
3276 | [ALC880_LG] = "lg", | |
3277 | [ALC880_LG_LW] = "lg-lw", | |
df99cd33 | 3278 | [ALC880_MEDION_RIM] = "medion", |
2fa522be | 3279 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 3280 | [ALC880_TEST] = "test", |
2fa522be | 3281 | #endif |
f5fcc13c TI |
3282 | [ALC880_AUTO] = "auto", |
3283 | }; | |
3284 | ||
3285 | static struct snd_pci_quirk alc880_cfg_tbl[] = { | |
ac3e3741 | 3286 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810), |
f5fcc13c TI |
3287 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG), |
3288 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST), | |
3289 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG), | |
3290 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG), | |
3291 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG), | |
3292 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG), | |
3293 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG), | |
3294 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST), | |
f5fcc13c TI |
3295 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG), |
3296 | SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST), | |
f5fcc13c TI |
3297 | SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V), |
3298 | SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG), | |
3299 | SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG), | |
3300 | SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG), | |
3301 | SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG), | |
3302 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG), | |
3303 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V), | |
3304 | /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */ | |
3305 | SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG), | |
3306 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG), | |
186c3117 | 3307 | SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG), |
f5fcc13c TI |
3308 | SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), |
3309 | SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), | |
3310 | SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), | |
ac3e3741 | 3311 | SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */ |
f5fcc13c | 3312 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST), |
ac3e3741 TI |
3313 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST), |
3314 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST), | |
f5fcc13c TI |
3315 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST), |
3316 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST), | |
f5fcc13c TI |
3317 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG), |
3318 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG), | |
3319 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG), | |
3320 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG), | |
ac3e3741 TI |
3321 | SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO), |
3322 | SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO), | |
f5fcc13c | 3323 | SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2), |
ac3e3741 | 3324 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG), |
f5fcc13c | 3325 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG), |
ac3e3741 | 3326 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734), |
f5fcc13c TI |
3327 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), |
3328 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), | |
ac3e3741 | 3329 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810), |
df99cd33 | 3330 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM), |
ac3e3741 | 3331 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG), |
f5fcc13c | 3332 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), |
f5fcc13c | 3333 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), |
1d11604e | 3334 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU), |
ac3e3741 | 3335 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL), |
2cf9f0fc | 3336 | SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU), |
ac3e3741 | 3337 | SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW), |
f5fcc13c TI |
3338 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG), |
3339 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG), | |
f5fcc13c | 3340 | SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW), |
ac3e3741 TI |
3341 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700), |
3342 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */ | |
3343 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG), | |
3344 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG), | |
f5fcc13c TI |
3345 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG), |
3346 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG), | |
ac3e3741 | 3347 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG), |
f5fcc13c | 3348 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG), |
ac3e3741 TI |
3349 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG), |
3350 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG), | |
f5fcc13c TI |
3351 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG), |
3352 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG), | |
3353 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG), | |
ac3e3741 TI |
3354 | SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */ |
3355 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG), | |
3356 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG), | |
1da177e4 LT |
3357 | {} |
3358 | }; | |
3359 | ||
16ded525 | 3360 | /* |
df694daa | 3361 | * ALC880 codec presets |
16ded525 | 3362 | */ |
16ded525 TI |
3363 | static struct alc_config_preset alc880_presets[] = { |
3364 | [ALC880_3ST] = { | |
e9edcee0 | 3365 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
3366 | .init_verbs = { alc880_volume_init_verbs, |
3367 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 3368 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 | 3369 | .dac_nids = alc880_dac_nids, |
16ded525 TI |
3370 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
3371 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3372 | .need_dac_fix = 1, |
16ded525 TI |
3373 | .input_mux = &alc880_capture_source, |
3374 | }, | |
3375 | [ALC880_3ST_DIG] = { | |
e9edcee0 | 3376 | .mixers = { alc880_three_stack_mixer }, |
f12ab1e0 TI |
3377 | .init_verbs = { alc880_volume_init_verbs, |
3378 | alc880_pin_3stack_init_verbs }, | |
16ded525 | 3379 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
16ded525 TI |
3380 | .dac_nids = alc880_dac_nids, |
3381 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3382 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), |
3383 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3384 | .need_dac_fix = 1, |
16ded525 TI |
3385 | .input_mux = &alc880_capture_source, |
3386 | }, | |
df694daa KY |
3387 | [ALC880_TCL_S700] = { |
3388 | .mixers = { alc880_tcl_s700_mixer }, | |
3389 | .init_verbs = { alc880_volume_init_verbs, | |
3390 | alc880_pin_tcl_S700_init_verbs, | |
3391 | alc880_gpio2_init_verbs }, | |
3392 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3393 | .dac_nids = alc880_dac_nids, | |
f9e336f6 TI |
3394 | .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */ |
3395 | .num_adc_nids = 1, /* single ADC */ | |
df694daa KY |
3396 | .hp_nid = 0x03, |
3397 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3398 | .channel_mode = alc880_2_jack_modes, | |
3399 | .input_mux = &alc880_capture_source, | |
3400 | }, | |
16ded525 | 3401 | [ALC880_5ST] = { |
f12ab1e0 TI |
3402 | .mixers = { alc880_three_stack_mixer, |
3403 | alc880_five_stack_mixer}, | |
3404 | .init_verbs = { alc880_volume_init_verbs, | |
3405 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
3406 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
3407 | .dac_nids = alc880_dac_nids, | |
16ded525 TI |
3408 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
3409 | .channel_mode = alc880_fivestack_modes, | |
3410 | .input_mux = &alc880_capture_source, | |
3411 | }, | |
3412 | [ALC880_5ST_DIG] = { | |
f12ab1e0 TI |
3413 | .mixers = { alc880_three_stack_mixer, |
3414 | alc880_five_stack_mixer }, | |
3415 | .init_verbs = { alc880_volume_init_verbs, | |
3416 | alc880_pin_5stack_init_verbs }, | |
16ded525 TI |
3417 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
3418 | .dac_nids = alc880_dac_nids, | |
3419 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3420 | .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), |
3421 | .channel_mode = alc880_fivestack_modes, | |
3422 | .input_mux = &alc880_capture_source, | |
3423 | }, | |
b6482d48 TI |
3424 | [ALC880_6ST] = { |
3425 | .mixers = { alc880_six_stack_mixer }, | |
f12ab1e0 TI |
3426 | .init_verbs = { alc880_volume_init_verbs, |
3427 | alc880_pin_6stack_init_verbs }, | |
b6482d48 TI |
3428 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
3429 | .dac_nids = alc880_6st_dac_nids, | |
3430 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), | |
3431 | .channel_mode = alc880_sixstack_modes, | |
3432 | .input_mux = &alc880_6stack_capture_source, | |
3433 | }, | |
16ded525 | 3434 | [ALC880_6ST_DIG] = { |
e9edcee0 | 3435 | .mixers = { alc880_six_stack_mixer }, |
f12ab1e0 TI |
3436 | .init_verbs = { alc880_volume_init_verbs, |
3437 | alc880_pin_6stack_init_verbs }, | |
16ded525 TI |
3438 | .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), |
3439 | .dac_nids = alc880_6st_dac_nids, | |
3440 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3441 | .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), |
3442 | .channel_mode = alc880_sixstack_modes, | |
3443 | .input_mux = &alc880_6stack_capture_source, | |
3444 | }, | |
3445 | [ALC880_W810] = { | |
e9edcee0 | 3446 | .mixers = { alc880_w810_base_mixer }, |
f12ab1e0 TI |
3447 | .init_verbs = { alc880_volume_init_verbs, |
3448 | alc880_pin_w810_init_verbs, | |
b0af0de5 | 3449 | alc880_gpio2_init_verbs }, |
16ded525 TI |
3450 | .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), |
3451 | .dac_nids = alc880_w810_dac_nids, | |
3452 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3453 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), |
3454 | .channel_mode = alc880_w810_modes, | |
3455 | .input_mux = &alc880_capture_source, | |
3456 | }, | |
3457 | [ALC880_Z71V] = { | |
e9edcee0 | 3458 | .mixers = { alc880_z71v_mixer }, |
f12ab1e0 TI |
3459 | .init_verbs = { alc880_volume_init_verbs, |
3460 | alc880_pin_z71v_init_verbs }, | |
16ded525 TI |
3461 | .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), |
3462 | .dac_nids = alc880_z71v_dac_nids, | |
3463 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3464 | .hp_nid = 0x03, | |
e9edcee0 TI |
3465 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
3466 | .channel_mode = alc880_2_jack_modes, | |
16ded525 TI |
3467 | .input_mux = &alc880_capture_source, |
3468 | }, | |
3469 | [ALC880_F1734] = { | |
e9edcee0 | 3470 | .mixers = { alc880_f1734_mixer }, |
f12ab1e0 TI |
3471 | .init_verbs = { alc880_volume_init_verbs, |
3472 | alc880_pin_f1734_init_verbs }, | |
e9edcee0 TI |
3473 | .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), |
3474 | .dac_nids = alc880_f1734_dac_nids, | |
3475 | .hp_nid = 0x02, | |
3476 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3477 | .channel_mode = alc880_2_jack_modes, | |
937b4160 TI |
3478 | .input_mux = &alc880_f1734_capture_source, |
3479 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3480 | .init_hook = alc880_uniwill_p53_hp_automute, | |
16ded525 TI |
3481 | }, |
3482 | [ALC880_ASUS] = { | |
e9edcee0 | 3483 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
3484 | .init_verbs = { alc880_volume_init_verbs, |
3485 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3486 | alc880_gpio1_init_verbs }, |
3487 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3488 | .dac_nids = alc880_asus_dac_nids, | |
3489 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
3490 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3491 | .need_dac_fix = 1, |
16ded525 TI |
3492 | .input_mux = &alc880_capture_source, |
3493 | }, | |
3494 | [ALC880_ASUS_DIG] = { | |
e9edcee0 | 3495 | .mixers = { alc880_asus_mixer }, |
f12ab1e0 TI |
3496 | .init_verbs = { alc880_volume_init_verbs, |
3497 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3498 | alc880_gpio1_init_verbs }, |
3499 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3500 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3501 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3502 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3503 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3504 | .need_dac_fix = 1, |
16ded525 TI |
3505 | .input_mux = &alc880_capture_source, |
3506 | }, | |
df694daa KY |
3507 | [ALC880_ASUS_DIG2] = { |
3508 | .mixers = { alc880_asus_mixer }, | |
f12ab1e0 TI |
3509 | .init_verbs = { alc880_volume_init_verbs, |
3510 | alc880_pin_asus_init_verbs, | |
df694daa KY |
3511 | alc880_gpio2_init_verbs }, /* use GPIO2 */ |
3512 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3513 | .dac_nids = alc880_asus_dac_nids, | |
3514 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3515 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), | |
3516 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3517 | .need_dac_fix = 1, |
df694daa KY |
3518 | .input_mux = &alc880_capture_source, |
3519 | }, | |
16ded525 | 3520 | [ALC880_ASUS_W1V] = { |
e9edcee0 | 3521 | .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, |
f12ab1e0 TI |
3522 | .init_verbs = { alc880_volume_init_verbs, |
3523 | alc880_pin_asus_init_verbs, | |
e9edcee0 TI |
3524 | alc880_gpio1_init_verbs }, |
3525 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3526 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3527 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3528 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3529 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3530 | .need_dac_fix = 1, |
16ded525 TI |
3531 | .input_mux = &alc880_capture_source, |
3532 | }, | |
3533 | [ALC880_UNIWILL_DIG] = { | |
3c10a9d9 | 3534 | .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, |
ccc656ce KY |
3535 | .init_verbs = { alc880_volume_init_verbs, |
3536 | alc880_pin_asus_init_verbs }, | |
e9edcee0 TI |
3537 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), |
3538 | .dac_nids = alc880_asus_dac_nids, | |
16ded525 | 3539 | .dig_out_nid = ALC880_DIGOUT_NID, |
e9edcee0 TI |
3540 | .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), |
3541 | .channel_mode = alc880_asus_modes, | |
4e195a7b | 3542 | .need_dac_fix = 1, |
16ded525 TI |
3543 | .input_mux = &alc880_capture_source, |
3544 | }, | |
ccc656ce KY |
3545 | [ALC880_UNIWILL] = { |
3546 | .mixers = { alc880_uniwill_mixer }, | |
3547 | .init_verbs = { alc880_volume_init_verbs, | |
3548 | alc880_uniwill_init_verbs }, | |
3549 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3550 | .dac_nids = alc880_asus_dac_nids, | |
3551 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3552 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
3553 | .channel_mode = alc880_threestack_modes, | |
3554 | .need_dac_fix = 1, | |
3555 | .input_mux = &alc880_capture_source, | |
3556 | .unsol_event = alc880_uniwill_unsol_event, | |
3557 | .init_hook = alc880_uniwill_automute, | |
3558 | }, | |
3559 | [ALC880_UNIWILL_P53] = { | |
3560 | .mixers = { alc880_uniwill_p53_mixer }, | |
3561 | .init_verbs = { alc880_volume_init_verbs, | |
3562 | alc880_uniwill_p53_init_verbs }, | |
3563 | .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), | |
3564 | .dac_nids = alc880_asus_dac_nids, | |
3565 | .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), | |
2cf9f0fc TD |
3566 | .channel_mode = alc880_threestack_modes, |
3567 | .input_mux = &alc880_capture_source, | |
3568 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3569 | .init_hook = alc880_uniwill_p53_hp_automute, | |
3570 | }, | |
3571 | [ALC880_FUJITSU] = { | |
f12ab1e0 | 3572 | .mixers = { alc880_fujitsu_mixer, |
2cf9f0fc TD |
3573 | alc880_pcbeep_mixer, }, |
3574 | .init_verbs = { alc880_volume_init_verbs, | |
3575 | alc880_uniwill_p53_init_verbs, | |
3576 | alc880_beep_init_verbs }, | |
3577 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3578 | .dac_nids = alc880_dac_nids, | |
d53d7d9e | 3579 | .dig_out_nid = ALC880_DIGOUT_NID, |
2cf9f0fc TD |
3580 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), |
3581 | .channel_mode = alc880_2_jack_modes, | |
ccc656ce KY |
3582 | .input_mux = &alc880_capture_source, |
3583 | .unsol_event = alc880_uniwill_p53_unsol_event, | |
3584 | .init_hook = alc880_uniwill_p53_hp_automute, | |
3585 | }, | |
df694daa KY |
3586 | [ALC880_CLEVO] = { |
3587 | .mixers = { alc880_three_stack_mixer }, | |
3588 | .init_verbs = { alc880_volume_init_verbs, | |
3589 | alc880_pin_clevo_init_verbs }, | |
3590 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3591 | .dac_nids = alc880_dac_nids, | |
3592 | .hp_nid = 0x03, | |
3593 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
3594 | .channel_mode = alc880_threestack_modes, | |
4e195a7b | 3595 | .need_dac_fix = 1, |
df694daa KY |
3596 | .input_mux = &alc880_capture_source, |
3597 | }, | |
ae6b813a TI |
3598 | [ALC880_LG] = { |
3599 | .mixers = { alc880_lg_mixer }, | |
3600 | .init_verbs = { alc880_volume_init_verbs, | |
3601 | alc880_lg_init_verbs }, | |
3602 | .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids), | |
3603 | .dac_nids = alc880_lg_dac_nids, | |
3604 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3605 | .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes), | |
3606 | .channel_mode = alc880_lg_ch_modes, | |
4e195a7b | 3607 | .need_dac_fix = 1, |
ae6b813a TI |
3608 | .input_mux = &alc880_lg_capture_source, |
3609 | .unsol_event = alc880_lg_unsol_event, | |
3610 | .init_hook = alc880_lg_automute, | |
cb53c626 TI |
3611 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3612 | .loopbacks = alc880_lg_loopbacks, | |
3613 | #endif | |
ae6b813a | 3614 | }, |
d681518a TI |
3615 | [ALC880_LG_LW] = { |
3616 | .mixers = { alc880_lg_lw_mixer }, | |
3617 | .init_verbs = { alc880_volume_init_verbs, | |
3618 | alc880_lg_lw_init_verbs }, | |
0a8c5da3 | 3619 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), |
d681518a TI |
3620 | .dac_nids = alc880_dac_nids, |
3621 | .dig_out_nid = ALC880_DIGOUT_NID, | |
0a8c5da3 CM |
3622 | .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes), |
3623 | .channel_mode = alc880_lg_lw_modes, | |
d681518a TI |
3624 | .input_mux = &alc880_lg_lw_capture_source, |
3625 | .unsol_event = alc880_lg_lw_unsol_event, | |
3626 | .init_hook = alc880_lg_lw_automute, | |
3627 | }, | |
df99cd33 TI |
3628 | [ALC880_MEDION_RIM] = { |
3629 | .mixers = { alc880_medion_rim_mixer }, | |
3630 | .init_verbs = { alc880_volume_init_verbs, | |
3631 | alc880_medion_rim_init_verbs, | |
3632 | alc_gpio2_init_verbs }, | |
3633 | .num_dacs = ARRAY_SIZE(alc880_dac_nids), | |
3634 | .dac_nids = alc880_dac_nids, | |
3635 | .dig_out_nid = ALC880_DIGOUT_NID, | |
3636 | .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), | |
3637 | .channel_mode = alc880_2_jack_modes, | |
3638 | .input_mux = &alc880_medion_rim_capture_source, | |
3639 | .unsol_event = alc880_medion_rim_unsol_event, | |
3640 | .init_hook = alc880_medion_rim_automute, | |
3641 | }, | |
16ded525 TI |
3642 | #ifdef CONFIG_SND_DEBUG |
3643 | [ALC880_TEST] = { | |
e9edcee0 TI |
3644 | .mixers = { alc880_test_mixer }, |
3645 | .init_verbs = { alc880_test_init_verbs }, | |
16ded525 TI |
3646 | .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), |
3647 | .dac_nids = alc880_test_dac_nids, | |
3648 | .dig_out_nid = ALC880_DIGOUT_NID, | |
16ded525 TI |
3649 | .num_channel_mode = ARRAY_SIZE(alc880_test_modes), |
3650 | .channel_mode = alc880_test_modes, | |
3651 | .input_mux = &alc880_test_capture_source, | |
3652 | }, | |
3653 | #endif | |
3654 | }; | |
3655 | ||
e9edcee0 TI |
3656 | /* |
3657 | * Automatic parse of I/O pins from the BIOS configuration | |
3658 | */ | |
3659 | ||
e9edcee0 TI |
3660 | enum { |
3661 | ALC_CTL_WIDGET_VOL, | |
3662 | ALC_CTL_WIDGET_MUTE, | |
3663 | ALC_CTL_BIND_MUTE, | |
3664 | }; | |
c8b6bf9b | 3665 | static struct snd_kcontrol_new alc880_control_templates[] = { |
e9edcee0 TI |
3666 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
3667 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | |
985be54b | 3668 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
e9edcee0 TI |
3669 | }; |
3670 | ||
3671 | /* add dynamic controls */ | |
f12ab1e0 TI |
3672 | static int add_control(struct alc_spec *spec, int type, const char *name, |
3673 | unsigned long val) | |
e9edcee0 | 3674 | { |
c8b6bf9b | 3675 | struct snd_kcontrol_new *knew; |
e9edcee0 | 3676 | |
603c4019 TI |
3677 | snd_array_init(&spec->kctls, sizeof(*knew), 32); |
3678 | knew = snd_array_new(&spec->kctls); | |
3679 | if (!knew) | |
3680 | return -ENOMEM; | |
e9edcee0 | 3681 | *knew = alc880_control_templates[type]; |
543537bd | 3682 | knew->name = kstrdup(name, GFP_KERNEL); |
f12ab1e0 | 3683 | if (!knew->name) |
e9edcee0 TI |
3684 | return -ENOMEM; |
3685 | knew->private_value = val; | |
e9edcee0 TI |
3686 | return 0; |
3687 | } | |
3688 | ||
3689 | #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) | |
3690 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | |
3691 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | |
3692 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) | |
3693 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) | |
3694 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) | |
3695 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) | |
3696 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) | |
3697 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) | |
3698 | #define alc880_idx_to_selector(nid) ((nid) + 0x10) | |
3699 | #define ALC880_PIN_CD_NID 0x1c | |
3700 | ||
3701 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
3702 | static int alc880_auto_fill_dac_nids(struct alc_spec *spec, |
3703 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
3704 | { |
3705 | hda_nid_t nid; | |
3706 | int assigned[4]; | |
3707 | int i, j; | |
3708 | ||
3709 | memset(assigned, 0, sizeof(assigned)); | |
b0af0de5 | 3710 | spec->multiout.dac_nids = spec->private_dac_nids; |
e9edcee0 TI |
3711 | |
3712 | /* check the pins hardwired to audio widget */ | |
3713 | for (i = 0; i < cfg->line_outs; i++) { | |
3714 | nid = cfg->line_out_pins[i]; | |
3715 | if (alc880_is_fixed_pin(nid)) { | |
3716 | int idx = alc880_fixed_pin_idx(nid); | |
5014f193 | 3717 | spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); |
e9edcee0 TI |
3718 | assigned[idx] = 1; |
3719 | } | |
3720 | } | |
3721 | /* left pins can be connect to any audio widget */ | |
3722 | for (i = 0; i < cfg->line_outs; i++) { | |
3723 | nid = cfg->line_out_pins[i]; | |
3724 | if (alc880_is_fixed_pin(nid)) | |
3725 | continue; | |
3726 | /* search for an empty channel */ | |
3727 | for (j = 0; j < cfg->line_outs; j++) { | |
f12ab1e0 TI |
3728 | if (!assigned[j]) { |
3729 | spec->multiout.dac_nids[i] = | |
3730 | alc880_idx_to_dac(j); | |
e9edcee0 TI |
3731 | assigned[j] = 1; |
3732 | break; | |
3733 | } | |
3734 | } | |
3735 | } | |
3736 | spec->multiout.num_dacs = cfg->line_outs; | |
3737 | return 0; | |
3738 | } | |
3739 | ||
3740 | /* add playback controls from the parsed DAC table */ | |
df694daa KY |
3741 | static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, |
3742 | const struct auto_pin_cfg *cfg) | |
e9edcee0 TI |
3743 | { |
3744 | char name[32]; | |
f12ab1e0 TI |
3745 | static const char *chname[4] = { |
3746 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
3747 | }; | |
e9edcee0 TI |
3748 | hda_nid_t nid; |
3749 | int i, err; | |
3750 | ||
3751 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 3752 | if (!spec->multiout.dac_nids[i]) |
e9edcee0 TI |
3753 | continue; |
3754 | nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); | |
3755 | if (i == 2) { | |
3756 | /* Center/LFE */ | |
f12ab1e0 TI |
3757 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
3758 | "Center Playback Volume", | |
3759 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
3760 | HDA_OUTPUT)); | |
3761 | if (err < 0) | |
e9edcee0 | 3762 | return err; |
f12ab1e0 TI |
3763 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
3764 | "LFE Playback Volume", | |
3765 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
3766 | HDA_OUTPUT)); | |
3767 | if (err < 0) | |
e9edcee0 | 3768 | return err; |
f12ab1e0 TI |
3769 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
3770 | "Center Playback Switch", | |
3771 | HDA_COMPOSE_AMP_VAL(nid, 1, 2, | |
3772 | HDA_INPUT)); | |
3773 | if (err < 0) | |
e9edcee0 | 3774 | return err; |
f12ab1e0 TI |
3775 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
3776 | "LFE Playback Switch", | |
3777 | HDA_COMPOSE_AMP_VAL(nid, 2, 2, | |
3778 | HDA_INPUT)); | |
3779 | if (err < 0) | |
e9edcee0 TI |
3780 | return err; |
3781 | } else { | |
3782 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
3783 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3784 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
3785 | HDA_OUTPUT)); | |
3786 | if (err < 0) | |
e9edcee0 TI |
3787 | return err; |
3788 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 TI |
3789 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
3790 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, | |
3791 | HDA_INPUT)); | |
3792 | if (err < 0) | |
e9edcee0 TI |
3793 | return err; |
3794 | } | |
3795 | } | |
e9edcee0 TI |
3796 | return 0; |
3797 | } | |
3798 | ||
8d88bc3d TI |
3799 | /* add playback controls for speaker and HP outputs */ |
3800 | static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
3801 | const char *pfx) | |
e9edcee0 TI |
3802 | { |
3803 | hda_nid_t nid; | |
3804 | int err; | |
8d88bc3d | 3805 | char name[32]; |
e9edcee0 | 3806 | |
f12ab1e0 | 3807 | if (!pin) |
e9edcee0 TI |
3808 | return 0; |
3809 | ||
3810 | if (alc880_is_fixed_pin(pin)) { | |
3811 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
82bc955f | 3812 | /* specify the DAC as the extra output */ |
f12ab1e0 | 3813 | if (!spec->multiout.hp_nid) |
e9edcee0 | 3814 | spec->multiout.hp_nid = nid; |
82bc955f TI |
3815 | else |
3816 | spec->multiout.extra_out_nid[0] = nid; | |
e9edcee0 TI |
3817 | /* control HP volume/switch on the output mixer amp */ |
3818 | nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); | |
8d88bc3d | 3819 | sprintf(name, "%s Playback Volume", pfx); |
f12ab1e0 TI |
3820 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3821 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
3822 | if (err < 0) | |
e9edcee0 | 3823 | return err; |
8d88bc3d | 3824 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
3825 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
3826 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
3827 | if (err < 0) | |
e9edcee0 TI |
3828 | return err; |
3829 | } else if (alc880_is_multi_pin(pin)) { | |
3830 | /* set manual connection */ | |
e9edcee0 | 3831 | /* we have only a switch on HP-out PIN */ |
8d88bc3d | 3832 | sprintf(name, "%s Playback Switch", pfx); |
f12ab1e0 TI |
3833 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
3834 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
3835 | if (err < 0) | |
e9edcee0 TI |
3836 | return err; |
3837 | } | |
3838 | return 0; | |
3839 | } | |
3840 | ||
3841 | /* create input playback/capture controls for the given pin */ | |
f12ab1e0 TI |
3842 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, |
3843 | const char *ctlname, | |
df694daa | 3844 | int idx, hda_nid_t mix_nid) |
e9edcee0 TI |
3845 | { |
3846 | char name[32]; | |
df694daa | 3847 | int err; |
e9edcee0 TI |
3848 | |
3849 | sprintf(name, "%s Playback Volume", ctlname); | |
f12ab1e0 TI |
3850 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
3851 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
3852 | if (err < 0) | |
e9edcee0 TI |
3853 | return err; |
3854 | sprintf(name, "%s Playback Switch", ctlname); | |
f12ab1e0 TI |
3855 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
3856 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); | |
3857 | if (err < 0) | |
e9edcee0 TI |
3858 | return err; |
3859 | return 0; | |
3860 | } | |
3861 | ||
3862 | /* create playback/capture controls for input pins */ | |
df694daa KY |
3863 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, |
3864 | const struct auto_pin_cfg *cfg) | |
e9edcee0 | 3865 | { |
e9edcee0 | 3866 | struct hda_input_mux *imux = &spec->private_imux; |
df694daa | 3867 | int i, err, idx; |
e9edcee0 TI |
3868 | |
3869 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3870 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
df694daa | 3871 | idx = alc880_input_pin_idx(cfg->input_pins[i]); |
4a471b7d TI |
3872 | err = new_analog_input(spec, cfg->input_pins[i], |
3873 | auto_pin_cfg_labels[i], | |
df694daa | 3874 | idx, 0x0b); |
e9edcee0 TI |
3875 | if (err < 0) |
3876 | return err; | |
f12ab1e0 TI |
3877 | imux->items[imux->num_items].label = |
3878 | auto_pin_cfg_labels[i]; | |
3879 | imux->items[imux->num_items].index = | |
3880 | alc880_input_pin_idx(cfg->input_pins[i]); | |
e9edcee0 TI |
3881 | imux->num_items++; |
3882 | } | |
3883 | } | |
3884 | return 0; | |
3885 | } | |
3886 | ||
f6c7e546 TI |
3887 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, |
3888 | unsigned int pin_type) | |
3889 | { | |
3890 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3891 | pin_type); | |
3892 | /* unmute pin */ | |
d260cdf6 TI |
3893 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
3894 | AMP_OUT_UNMUTE); | |
f6c7e546 TI |
3895 | } |
3896 | ||
df694daa KY |
3897 | static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, |
3898 | hda_nid_t nid, int pin_type, | |
e9edcee0 TI |
3899 | int dac_idx) |
3900 | { | |
f6c7e546 | 3901 | alc_set_pin_output(codec, nid, pin_type); |
e9edcee0 TI |
3902 | /* need the manual connection? */ |
3903 | if (alc880_is_multi_pin(nid)) { | |
3904 | struct alc_spec *spec = codec->spec; | |
3905 | int idx = alc880_multi_pin_idx(nid); | |
3906 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
3907 | AC_VERB_SET_CONNECT_SEL, | |
3908 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
3909 | } | |
3910 | } | |
3911 | ||
baba8ee9 TI |
3912 | static int get_pin_type(int line_out_type) |
3913 | { | |
3914 | if (line_out_type == AUTO_PIN_HP_OUT) | |
3915 | return PIN_HP; | |
3916 | else | |
3917 | return PIN_OUT; | |
3918 | } | |
3919 | ||
e9edcee0 TI |
3920 | static void alc880_auto_init_multi_out(struct hda_codec *codec) |
3921 | { | |
3922 | struct alc_spec *spec = codec->spec; | |
3923 | int i; | |
ea1fb29a | 3924 | |
bc9f98a9 | 3925 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
e9edcee0 TI |
3926 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
3927 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 TI |
3928 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
3929 | alc880_auto_set_output_and_unmute(codec, nid, pin_type, i); | |
e9edcee0 TI |
3930 | } |
3931 | } | |
3932 | ||
8d88bc3d | 3933 | static void alc880_auto_init_extra_out(struct hda_codec *codec) |
e9edcee0 TI |
3934 | { |
3935 | struct alc_spec *spec = codec->spec; | |
3936 | hda_nid_t pin; | |
3937 | ||
82bc955f | 3938 | pin = spec->autocfg.speaker_pins[0]; |
8d88bc3d TI |
3939 | if (pin) /* connect to front */ |
3940 | alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
eb06ed8f | 3941 | pin = spec->autocfg.hp_pins[0]; |
e9edcee0 TI |
3942 | if (pin) /* connect to front */ |
3943 | alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
3944 | } | |
3945 | ||
3946 | static void alc880_auto_init_analog_input(struct hda_codec *codec) | |
3947 | { | |
3948 | struct alc_spec *spec = codec->spec; | |
3949 | int i; | |
3950 | ||
3951 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
3952 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
3953 | if (alc880_is_input_pin(nid)) { | |
f12ab1e0 TI |
3954 | snd_hda_codec_write(codec, nid, 0, |
3955 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
3956 | i <= AUTO_PIN_FRONT_MIC ? | |
3957 | PIN_VREF80 : PIN_IN); | |
e9edcee0 | 3958 | if (nid != ALC880_PIN_CD_NID) |
f12ab1e0 TI |
3959 | snd_hda_codec_write(codec, nid, 0, |
3960 | AC_VERB_SET_AMP_GAIN_MUTE, | |
e9edcee0 TI |
3961 | AMP_OUT_MUTE); |
3962 | } | |
3963 | } | |
3964 | } | |
3965 | ||
3966 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
3967 | /* return 1 if successful, 0 if the proper config is not found, |
3968 | * or a negative error code | |
3969 | */ | |
e9edcee0 TI |
3970 | static int alc880_parse_auto_config(struct hda_codec *codec) |
3971 | { | |
3972 | struct alc_spec *spec = codec->spec; | |
3973 | int err; | |
df694daa | 3974 | static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
e9edcee0 | 3975 | |
f12ab1e0 TI |
3976 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
3977 | alc880_ignore); | |
3978 | if (err < 0) | |
e9edcee0 | 3979 | return err; |
f12ab1e0 | 3980 | if (!spec->autocfg.line_outs) |
e9edcee0 | 3981 | return 0; /* can't find valid BIOS pin config */ |
df694daa | 3982 | |
f12ab1e0 TI |
3983 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
3984 | if (err < 0) | |
3985 | return err; | |
3986 | err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
3987 | if (err < 0) | |
3988 | return err; | |
3989 | err = alc880_auto_create_extra_out(spec, | |
3990 | spec->autocfg.speaker_pins[0], | |
3991 | "Speaker"); | |
3992 | if (err < 0) | |
3993 | return err; | |
3994 | err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
3995 | "Headphone"); | |
3996 | if (err < 0) | |
3997 | return err; | |
3998 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
3999 | if (err < 0) | |
e9edcee0 TI |
4000 | return err; |
4001 | ||
4002 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
4003 | ||
4004 | if (spec->autocfg.dig_out_pin) | |
4005 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
4006 | if (spec->autocfg.dig_in_pin) | |
4007 | spec->dig_in_nid = ALC880_DIGIN_NID; | |
4008 | ||
603c4019 | 4009 | if (spec->kctls.list) |
d88897ea | 4010 | add_mixer(spec, spec->kctls.list); |
e9edcee0 | 4011 | |
d88897ea | 4012 | add_verb(spec, alc880_volume_init_verbs); |
e9edcee0 | 4013 | |
a1e8d2da | 4014 | spec->num_mux_defs = 1; |
e9edcee0 TI |
4015 | spec->input_mux = &spec->private_imux; |
4016 | ||
e044c39a | 4017 | store_pin_configs(codec); |
e9edcee0 TI |
4018 | return 1; |
4019 | } | |
4020 | ||
ae6b813a TI |
4021 | /* additional initialization for auto-configuration model */ |
4022 | static void alc880_auto_init(struct hda_codec *codec) | |
e9edcee0 | 4023 | { |
f6c7e546 | 4024 | struct alc_spec *spec = codec->spec; |
e9edcee0 | 4025 | alc880_auto_init_multi_out(codec); |
8d88bc3d | 4026 | alc880_auto_init_extra_out(codec); |
e9edcee0 | 4027 | alc880_auto_init_analog_input(codec); |
f6c7e546 | 4028 | if (spec->unsol_event) |
7fb0d78f | 4029 | alc_inithook(codec); |
e9edcee0 TI |
4030 | } |
4031 | ||
4032 | /* | |
4033 | * OK, here we have finally the patch for ALC880 | |
4034 | */ | |
4035 | ||
f9e336f6 TI |
4036 | static void set_capture_mixer(struct alc_spec *spec) |
4037 | { | |
4038 | static struct snd_kcontrol_new *caps[3] = { | |
4039 | alc_capture_mixer1, | |
4040 | alc_capture_mixer2, | |
4041 | alc_capture_mixer3, | |
4042 | }; | |
4043 | if (spec->num_adc_nids > 0 && spec->num_adc_nids < 3) | |
4044 | spec->cap_mixer = caps[spec->num_adc_nids - 1]; | |
4045 | } | |
4046 | ||
1da177e4 LT |
4047 | static int patch_alc880(struct hda_codec *codec) |
4048 | { | |
4049 | struct alc_spec *spec; | |
4050 | int board_config; | |
df694daa | 4051 | int err; |
1da177e4 | 4052 | |
e560d8d8 | 4053 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
4054 | if (spec == NULL) |
4055 | return -ENOMEM; | |
4056 | ||
4057 | codec->spec = spec; | |
4058 | ||
f5fcc13c TI |
4059 | board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST, |
4060 | alc880_models, | |
4061 | alc880_cfg_tbl); | |
4062 | if (board_config < 0) { | |
9c7f852e TI |
4063 | printk(KERN_INFO "hda_codec: Unknown model for ALC880, " |
4064 | "trying auto-probe from BIOS...\n"); | |
e9edcee0 | 4065 | board_config = ALC880_AUTO; |
1da177e4 | 4066 | } |
1da177e4 | 4067 | |
e9edcee0 TI |
4068 | if (board_config == ALC880_AUTO) { |
4069 | /* automatic parse from the BIOS config */ | |
4070 | err = alc880_parse_auto_config(codec); | |
4071 | if (err < 0) { | |
4072 | alc_free(codec); | |
4073 | return err; | |
f12ab1e0 | 4074 | } else if (!err) { |
9c7f852e TI |
4075 | printk(KERN_INFO |
4076 | "hda_codec: Cannot set up configuration " | |
4077 | "from BIOS. Using 3-stack mode...\n"); | |
e9edcee0 TI |
4078 | board_config = ALC880_3ST; |
4079 | } | |
1da177e4 LT |
4080 | } |
4081 | ||
df694daa KY |
4082 | if (board_config != ALC880_AUTO) |
4083 | setup_preset(spec, &alc880_presets[board_config]); | |
1da177e4 LT |
4084 | |
4085 | spec->stream_name_analog = "ALC880 Analog"; | |
4086 | spec->stream_analog_playback = &alc880_pcm_analog_playback; | |
4087 | spec->stream_analog_capture = &alc880_pcm_analog_capture; | |
6330079f | 4088 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; |
1da177e4 LT |
4089 | |
4090 | spec->stream_name_digital = "ALC880 Digital"; | |
4091 | spec->stream_digital_playback = &alc880_pcm_digital_playback; | |
4092 | spec->stream_digital_capture = &alc880_pcm_digital_capture; | |
4093 | ||
f12ab1e0 | 4094 | if (!spec->adc_nids && spec->input_mux) { |
e9edcee0 | 4095 | /* check whether NID 0x07 is valid */ |
54d17403 | 4096 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); |
f12ab1e0 TI |
4097 | /* get type */ |
4098 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
e9edcee0 TI |
4099 | if (wcap != AC_WID_AUD_IN) { |
4100 | spec->adc_nids = alc880_adc_nids_alt; | |
4101 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); | |
e9edcee0 TI |
4102 | } else { |
4103 | spec->adc_nids = alc880_adc_nids; | |
4104 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); | |
e9edcee0 TI |
4105 | } |
4106 | } | |
f9e336f6 | 4107 | set_capture_mixer(spec); |
1da177e4 | 4108 | |
2134ea4f TI |
4109 | spec->vmaster_nid = 0x0c; |
4110 | ||
1da177e4 | 4111 | codec->patch_ops = alc_patch_ops; |
e9edcee0 | 4112 | if (board_config == ALC880_AUTO) |
ae6b813a | 4113 | spec->init_hook = alc880_auto_init; |
cb53c626 TI |
4114 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
4115 | if (!spec->loopback.amplist) | |
4116 | spec->loopback.amplist = alc880_loopbacks; | |
4117 | #endif | |
1da177e4 LT |
4118 | |
4119 | return 0; | |
4120 | } | |
4121 | ||
e9edcee0 | 4122 | |
1da177e4 LT |
4123 | /* |
4124 | * ALC260 support | |
4125 | */ | |
4126 | ||
e9edcee0 TI |
4127 | static hda_nid_t alc260_dac_nids[1] = { |
4128 | /* front */ | |
4129 | 0x02, | |
4130 | }; | |
4131 | ||
4132 | static hda_nid_t alc260_adc_nids[1] = { | |
4133 | /* ADC0 */ | |
4134 | 0x04, | |
4135 | }; | |
4136 | ||
df694daa | 4137 | static hda_nid_t alc260_adc_nids_alt[1] = { |
e9edcee0 TI |
4138 | /* ADC1 */ |
4139 | 0x05, | |
4140 | }; | |
4141 | ||
d57fdac0 JW |
4142 | /* NIDs used when simultaneous access to both ADCs makes sense. Note that |
4143 | * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC. | |
4144 | */ | |
4145 | static hda_nid_t alc260_dual_adc_nids[2] = { | |
4c5186ed JW |
4146 | /* ADC0, ADC1 */ |
4147 | 0x04, 0x05 | |
4148 | }; | |
4149 | ||
e9edcee0 TI |
4150 | #define ALC260_DIGOUT_NID 0x03 |
4151 | #define ALC260_DIGIN_NID 0x06 | |
4152 | ||
4153 | static struct hda_input_mux alc260_capture_source = { | |
4154 | .num_items = 4, | |
4155 | .items = { | |
4156 | { "Mic", 0x0 }, | |
4157 | { "Front Mic", 0x1 }, | |
4158 | { "Line", 0x2 }, | |
4159 | { "CD", 0x4 }, | |
4160 | }, | |
4161 | }; | |
4162 | ||
17e7aec6 | 4163 | /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack, |
a1e8d2da JW |
4164 | * headphone jack and the internal CD lines since these are the only pins at |
4165 | * which audio can appear. For flexibility, also allow the option of | |
4166 | * recording the mixer output on the second ADC (ADC0 doesn't have a | |
4167 | * connection to the mixer output). | |
a9430dd8 | 4168 | */ |
a1e8d2da JW |
4169 | static struct hda_input_mux alc260_fujitsu_capture_sources[2] = { |
4170 | { | |
4171 | .num_items = 3, | |
4172 | .items = { | |
4173 | { "Mic/Line", 0x0 }, | |
4174 | { "CD", 0x4 }, | |
4175 | { "Headphone", 0x2 }, | |
4176 | }, | |
a9430dd8 | 4177 | }, |
a1e8d2da JW |
4178 | { |
4179 | .num_items = 4, | |
4180 | .items = { | |
4181 | { "Mic/Line", 0x0 }, | |
4182 | { "CD", 0x4 }, | |
4183 | { "Headphone", 0x2 }, | |
4184 | { "Mixer", 0x5 }, | |
4185 | }, | |
4186 | }, | |
4187 | ||
a9430dd8 JW |
4188 | }; |
4189 | ||
a1e8d2da JW |
4190 | /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to |
4191 | * the Fujitsu S702x, but jacks are marked differently. | |
0bfc90e9 | 4192 | */ |
a1e8d2da JW |
4193 | static struct hda_input_mux alc260_acer_capture_sources[2] = { |
4194 | { | |
4195 | .num_items = 4, | |
4196 | .items = { | |
4197 | { "Mic", 0x0 }, | |
4198 | { "Line", 0x2 }, | |
4199 | { "CD", 0x4 }, | |
4200 | { "Headphone", 0x5 }, | |
4201 | }, | |
4202 | }, | |
4203 | { | |
4204 | .num_items = 5, | |
4205 | .items = { | |
4206 | { "Mic", 0x0 }, | |
4207 | { "Line", 0x2 }, | |
4208 | { "CD", 0x4 }, | |
4209 | { "Headphone", 0x6 }, | |
4210 | { "Mixer", 0x5 }, | |
4211 | }, | |
0bfc90e9 JW |
4212 | }, |
4213 | }; | |
1da177e4 LT |
4214 | /* |
4215 | * This is just place-holder, so there's something for alc_build_pcms to look | |
4216 | * at when it calculates the maximum number of channels. ALC260 has no mixer | |
4217 | * element which allows changing the channel mode, so the verb list is | |
4218 | * never used. | |
4219 | */ | |
d2a6d7dc | 4220 | static struct hda_channel_mode alc260_modes[1] = { |
1da177e4 LT |
4221 | { 2, NULL }, |
4222 | }; | |
4223 | ||
df694daa KY |
4224 | |
4225 | /* Mixer combinations | |
4226 | * | |
4227 | * basic: base_output + input + pc_beep + capture | |
4228 | * HP: base_output + input + capture_alt | |
4229 | * HP_3013: hp_3013 + input + capture | |
4230 | * fujitsu: fujitsu + capture | |
0bfc90e9 | 4231 | * acer: acer + capture |
df694daa KY |
4232 | */ |
4233 | ||
4234 | static struct snd_kcontrol_new alc260_base_output_mixer[] = { | |
05acb863 | 4235 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 4236 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), |
05acb863 | 4237 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
985be54b | 4238 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), |
05acb863 | 4239 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
985be54b | 4240 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), |
1da177e4 | 4241 | { } /* end */ |
f12ab1e0 | 4242 | }; |
1da177e4 | 4243 | |
df694daa | 4244 | static struct snd_kcontrol_new alc260_input_mixer[] = { |
16ded525 TI |
4245 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4246 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4247 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4248 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4249 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4250 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4251 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), | |
4252 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), | |
df694daa KY |
4253 | { } /* end */ |
4254 | }; | |
4255 | ||
4256 | static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { | |
4257 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4258 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4259 | { } /* end */ | |
4260 | }; | |
4261 | ||
bec15c3a TI |
4262 | /* update HP, line and mono out pins according to the master switch */ |
4263 | static void alc260_hp_master_update(struct hda_codec *codec, | |
4264 | hda_nid_t hp, hda_nid_t line, | |
4265 | hda_nid_t mono) | |
4266 | { | |
4267 | struct alc_spec *spec = codec->spec; | |
4268 | unsigned int val = spec->master_sw ? PIN_HP : 0; | |
4269 | /* change HP and line-out pins */ | |
4270 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4271 | val); | |
4272 | snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4273 | val); | |
4274 | /* mono (speaker) depending on the HP jack sense */ | |
4275 | val = (val && !spec->jack_present) ? PIN_OUT : 0; | |
4276 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4277 | val); | |
4278 | } | |
4279 | ||
4280 | static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol, | |
4281 | struct snd_ctl_elem_value *ucontrol) | |
4282 | { | |
4283 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4284 | struct alc_spec *spec = codec->spec; | |
4285 | *ucontrol->value.integer.value = spec->master_sw; | |
4286 | return 0; | |
4287 | } | |
4288 | ||
4289 | static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
4290 | struct snd_ctl_elem_value *ucontrol) | |
4291 | { | |
4292 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
4293 | struct alc_spec *spec = codec->spec; | |
4294 | int val = !!*ucontrol->value.integer.value; | |
4295 | hda_nid_t hp, line, mono; | |
4296 | ||
4297 | if (val == spec->master_sw) | |
4298 | return 0; | |
4299 | spec->master_sw = val; | |
4300 | hp = (kcontrol->private_value >> 16) & 0xff; | |
4301 | line = (kcontrol->private_value >> 8) & 0xff; | |
4302 | mono = kcontrol->private_value & 0xff; | |
4303 | alc260_hp_master_update(codec, hp, line, mono); | |
4304 | return 1; | |
4305 | } | |
4306 | ||
4307 | static struct snd_kcontrol_new alc260_hp_output_mixer[] = { | |
4308 | { | |
4309 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4310 | .name = "Master Playback Switch", | |
4311 | .info = snd_ctl_boolean_mono_info, | |
4312 | .get = alc260_hp_master_sw_get, | |
4313 | .put = alc260_hp_master_sw_put, | |
4314 | .private_value = (0x0f << 16) | (0x10 << 8) | 0x11 | |
4315 | }, | |
4316 | HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4317 | HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), | |
4318 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
4319 | HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), | |
4320 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, | |
4321 | HDA_OUTPUT), | |
4322 | HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
4323 | { } /* end */ | |
4324 | }; | |
4325 | ||
4326 | static struct hda_verb alc260_hp_unsol_verbs[] = { | |
4327 | {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4328 | {}, | |
4329 | }; | |
4330 | ||
4331 | static void alc260_hp_automute(struct hda_codec *codec) | |
4332 | { | |
4333 | struct alc_spec *spec = codec->spec; | |
4334 | unsigned int present; | |
4335 | ||
4336 | present = snd_hda_codec_read(codec, 0x10, 0, | |
4337 | AC_VERB_GET_PIN_SENSE, 0); | |
4338 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
4339 | alc260_hp_master_update(codec, 0x0f, 0x10, 0x11); | |
4340 | } | |
4341 | ||
4342 | static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res) | |
4343 | { | |
4344 | if ((res >> 26) == ALC880_HP_EVENT) | |
4345 | alc260_hp_automute(codec); | |
4346 | } | |
4347 | ||
df694daa | 4348 | static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { |
bec15c3a TI |
4349 | { |
4350 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
4351 | .name = "Master Playback Switch", | |
4352 | .info = snd_ctl_boolean_mono_info, | |
4353 | .get = alc260_hp_master_sw_get, | |
4354 | .put = alc260_hp_master_sw_put, | |
4355 | .private_value = (0x10 << 16) | (0x15 << 8) | 0x11 | |
4356 | }, | |
df694daa KY |
4357 | HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
4358 | HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
4359 | HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), | |
4360 | HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), | |
4361 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4362 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
86cd9298 TI |
4363 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), |
4364 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), | |
16ded525 TI |
4365 | { } /* end */ |
4366 | }; | |
4367 | ||
3f878308 KY |
4368 | static struct hda_bind_ctls alc260_dc7600_bind_master_vol = { |
4369 | .ops = &snd_hda_bind_vol, | |
4370 | .values = { | |
4371 | HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT), | |
4372 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT), | |
4373 | HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT), | |
4374 | 0 | |
4375 | }, | |
4376 | }; | |
4377 | ||
4378 | static struct hda_bind_ctls alc260_dc7600_bind_switch = { | |
4379 | .ops = &snd_hda_bind_sw, | |
4380 | .values = { | |
4381 | HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT), | |
4382 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
4383 | 0 | |
4384 | }, | |
4385 | }; | |
4386 | ||
4387 | static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = { | |
4388 | HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol), | |
4389 | HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch), | |
4390 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT), | |
4391 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT), | |
4392 | { } /* end */ | |
4393 | }; | |
4394 | ||
bec15c3a TI |
4395 | static struct hda_verb alc260_hp_3013_unsol_verbs[] = { |
4396 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4397 | {}, | |
4398 | }; | |
4399 | ||
4400 | static void alc260_hp_3013_automute(struct hda_codec *codec) | |
4401 | { | |
4402 | struct alc_spec *spec = codec->spec; | |
4403 | unsigned int present; | |
4404 | ||
4405 | present = snd_hda_codec_read(codec, 0x15, 0, | |
4406 | AC_VERB_GET_PIN_SENSE, 0); | |
4407 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
4408 | alc260_hp_master_update(codec, 0x10, 0x15, 0x11); | |
4409 | } | |
4410 | ||
4411 | static void alc260_hp_3013_unsol_event(struct hda_codec *codec, | |
4412 | unsigned int res) | |
4413 | { | |
4414 | if ((res >> 26) == ALC880_HP_EVENT) | |
4415 | alc260_hp_3013_automute(codec); | |
4416 | } | |
4417 | ||
3f878308 KY |
4418 | static void alc260_hp_3012_automute(struct hda_codec *codec) |
4419 | { | |
4420 | unsigned int present, bits; | |
4421 | ||
4422 | present = snd_hda_codec_read(codec, 0x10, 0, | |
4423 | AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE; | |
4424 | ||
4425 | bits = present ? 0 : PIN_OUT; | |
4426 | snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4427 | bits); | |
4428 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4429 | bits); | |
4430 | snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4431 | bits); | |
4432 | } | |
4433 | ||
4434 | static void alc260_hp_3012_unsol_event(struct hda_codec *codec, | |
4435 | unsigned int res) | |
4436 | { | |
4437 | if ((res >> 26) == ALC880_HP_EVENT) | |
4438 | alc260_hp_3012_automute(codec); | |
4439 | } | |
4440 | ||
4441 | /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12, | |
a1e8d2da JW |
4442 | * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10. |
4443 | */ | |
c8b6bf9b | 4444 | static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { |
a9430dd8 | 4445 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), |
985be54b | 4446 | HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), |
4c5186ed | 4447 | ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT), |
a9430dd8 JW |
4448 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4449 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4450 | HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4451 | HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4c5186ed | 4452 | ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), |
a9430dd8 JW |
4453 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), |
4454 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
31bffaa9 TI |
4455 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), |
4456 | HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT), | |
df694daa KY |
4457 | { } /* end */ |
4458 | }; | |
4459 | ||
a1e8d2da JW |
4460 | /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current |
4461 | * versions of the ALC260 don't act on requests to enable mic bias from NID | |
4462 | * 0x0f (used to drive the headphone jack in these laptops). The ALC260 | |
4463 | * datasheet doesn't mention this restriction. At this stage it's not clear | |
4464 | * whether this behaviour is intentional or is a hardware bug in chip | |
4465 | * revisions available in early 2006. Therefore for now allow the | |
4466 | * "Headphone Jack Mode" control to span all choices, but if it turns out | |
4467 | * that the lack of mic bias for this NID is intentional we could change the | |
4468 | * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
4469 | * | |
4470 | * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006 | |
4471 | * don't appear to make the mic bias available from the "line" jack, even | |
4472 | * though the NID used for this jack (0x14) can supply it. The theory is | |
4473 | * that perhaps Acer have included blocking capacitors between the ALC260 | |
4474 | * and the output jack. If this turns out to be the case for all such | |
4475 | * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT | |
4476 | * to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
bd869485 JW |
4477 | * |
4478 | * The C20x Tablet series have a mono internal speaker which is controlled | |
4479 | * via the chip's Mono sum widget and pin complex, so include the necessary | |
4480 | * controls for such models. On models without a "mono speaker" the control | |
4481 | * won't do anything. | |
a1e8d2da | 4482 | */ |
0bfc90e9 JW |
4483 | static struct snd_kcontrol_new alc260_acer_mixer[] = { |
4484 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4485 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT), | |
a1e8d2da | 4486 | ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT), |
31bffaa9 | 4487 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, |
bd869485 | 4488 | HDA_OUTPUT), |
31bffaa9 | 4489 | HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, |
bd869485 | 4490 | HDA_INPUT), |
0bfc90e9 JW |
4491 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), |
4492 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4493 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4494 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4495 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4496 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4497 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4498 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4499 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4500 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4501 | { } /* end */ | |
4502 | }; | |
4503 | ||
bc9f98a9 KY |
4504 | /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12, |
4505 | * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17. | |
4506 | */ | |
4507 | static struct snd_kcontrol_new alc260_will_mixer[] = { | |
4508 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4509 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
4510 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4511 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4512 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4513 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4514 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4515 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4516 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
4517 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
4518 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
4519 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
4520 | { } /* end */ | |
4521 | }; | |
4522 | ||
4523 | /* Replacer 672V ALC260 pin usage: Mic jack = 0x12, | |
4524 | * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f. | |
4525 | */ | |
4526 | static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = { | |
4527 | HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4528 | HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT), | |
4529 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), | |
4530 | HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), | |
4531 | ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN), | |
4532 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT), | |
4533 | HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT), | |
4534 | HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), | |
4535 | HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), | |
4536 | ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), | |
4537 | { } /* end */ | |
4538 | }; | |
4539 | ||
df694daa KY |
4540 | /* |
4541 | * initialization verbs | |
4542 | */ | |
1da177e4 LT |
4543 | static struct hda_verb alc260_init_verbs[] = { |
4544 | /* Line In pin widget for input */ | |
05acb863 | 4545 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 4546 | /* CD pin widget for input */ |
05acb863 | 4547 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 | 4548 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ |
16ded525 | 4549 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 4550 | /* Mic2 (front panel) pin widget for input and vref at 80% */ |
16ded525 | 4551 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1da177e4 | 4552 | /* LINE-2 is used for line-out in rear */ |
05acb863 | 4553 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 4554 | /* select line-out */ |
fd56f2db | 4555 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 | 4556 | /* LINE-OUT pin */ |
05acb863 | 4557 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
1da177e4 | 4558 | /* enable HP */ |
05acb863 | 4559 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
1da177e4 | 4560 | /* enable Mono */ |
05acb863 TI |
4561 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
4562 | /* mute capture amp left and right */ | |
16ded525 | 4563 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
1da177e4 LT |
4564 | /* set connection select to line in (default select for this ADC) */ |
4565 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
16ded525 TI |
4566 | /* mute capture amp left and right */ |
4567 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4568 | /* set connection select to line in (default select for this ADC) */ | |
4569 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
05acb863 TI |
4570 | /* set vol=0 Line-Out mixer amp left and right */ |
4571 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4572 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4573 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4574 | /* set vol=0 HP mixer amp left and right */ | |
4575 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4576 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4577 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4578 | /* set vol=0 Mono mixer amp left and right */ | |
4579 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4580 | /* unmute pin widget amp left and right (no gain on this amp) */ | |
4581 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4582 | /* unmute LINE-2 out pin */ | |
4583 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
f12ab1e0 TI |
4584 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4585 | * Line In 2 = 0x03 | |
4586 | */ | |
cb53c626 TI |
4587 | /* mute analog inputs */ |
4588 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4589 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4590 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4591 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4592 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 4593 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
05acb863 TI |
4594 | /* mute Front out path */ |
4595 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4596 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4597 | /* mute Headphone out path */ | |
4598 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4599 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4600 | /* mute Mono out path */ | |
4601 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4602 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 LT |
4603 | { } |
4604 | }; | |
4605 | ||
474167d6 | 4606 | #if 0 /* should be identical with alc260_init_verbs? */ |
df694daa KY |
4607 | static struct hda_verb alc260_hp_init_verbs[] = { |
4608 | /* Headphone and output */ | |
4609 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
4610 | /* mono output */ | |
4611 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4612 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
4613 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4614 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
4615 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4616 | /* Line In pin widget for input */ | |
4617 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4618 | /* Line-2 pin widget for output */ | |
4619 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4620 | /* CD pin widget for input */ | |
4621 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4622 | /* unmute amp left and right */ | |
4623 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
4624 | /* set connection select to line in (default select for this ADC) */ | |
4625 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
4626 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
4627 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4628 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4629 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4630 | /* unmute HP mixer amp left and right (volume = 0) */ | |
4631 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4632 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4633 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
4634 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4635 | * Line In 2 = 0x03 | |
4636 | */ | |
cb53c626 TI |
4637 | /* mute analog inputs */ |
4638 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4639 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4640 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4641 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4642 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4643 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
4644 | /* Unmute Front out path */ | |
4645 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4646 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4647 | /* Unmute Headphone out path */ | |
4648 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4649 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4650 | /* Unmute Mono out path */ | |
4651 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4652 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4653 | { } | |
4654 | }; | |
474167d6 | 4655 | #endif |
df694daa KY |
4656 | |
4657 | static struct hda_verb alc260_hp_3013_init_verbs[] = { | |
4658 | /* Line out and output */ | |
4659 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4660 | /* mono output */ | |
4661 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
4662 | /* Mic1 (rear panel) pin widget for input and vref at 80% */ | |
4663 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4664 | /* Mic2 (front panel) pin widget for input and vref at 80% */ | |
4665 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
4666 | /* Line In pin widget for input */ | |
4667 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4668 | /* Headphone pin widget for output */ | |
4669 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
4670 | /* CD pin widget for input */ | |
4671 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
4672 | /* unmute amp left and right */ | |
4673 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, | |
4674 | /* set connection select to line in (default select for this ADC) */ | |
4675 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
4676 | /* unmute Line-Out mixer amp left and right (volume = 0) */ | |
4677 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4678 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4679 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
4680 | /* unmute HP mixer amp left and right (volume = 0) */ | |
4681 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
4682 | /* mute pin widget amp left and right (no gain on this amp) */ | |
4683 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
f12ab1e0 TI |
4684 | /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & |
4685 | * Line In 2 = 0x03 | |
4686 | */ | |
cb53c626 TI |
4687 | /* mute analog inputs */ |
4688 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4689 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4690 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
4691 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
4692 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
4693 | /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ |
4694 | /* Unmute Front out path */ | |
4695 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4696 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4697 | /* Unmute Headphone out path */ | |
4698 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4699 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4700 | /* Unmute Mono out path */ | |
4701 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
4702 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
4703 | { } | |
4704 | }; | |
4705 | ||
a9430dd8 | 4706 | /* Initialisation sequence for ALC260 as configured in Fujitsu S702x |
a1e8d2da JW |
4707 | * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD |
4708 | * audio = 0x16, internal speaker = 0x10. | |
a9430dd8 JW |
4709 | */ |
4710 | static struct hda_verb alc260_fujitsu_init_verbs[] = { | |
4711 | /* Disable all GPIOs */ | |
4712 | {0x01, AC_VERB_SET_GPIO_MASK, 0}, | |
4713 | /* Internal speaker is connected to headphone pin */ | |
4714 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4715 | /* Headphone/Line-out jack connects to Line1 pin; make it an output */ | |
4716 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
f7ace40d JW |
4717 | /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ |
4718 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
4719 | /* Ensure all other unused pins are disabled and muted. */ | |
4720 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4721 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a9430dd8 | 4722 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d | 4723 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
a9430dd8 | 4724 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
f7ace40d JW |
4725 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
4726 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4727 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4728 | ||
4729 | /* Disable digital (SPDIF) pins */ | |
4730 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4731 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
a9430dd8 | 4732 | |
ea1fb29a | 4733 | /* Ensure Line1 pin widget takes its input from the OUT1 sum bus |
f7ace40d JW |
4734 | * when acting as an output. |
4735 | */ | |
4736 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4c5186ed | 4737 | |
f7ace40d | 4738 | /* Start with output sum widgets muted and their output gains at min */ |
8b33a5aa TI |
4739 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
4740 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4741 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4742 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4743 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4744 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4745 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4746 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4747 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
a9430dd8 | 4748 | |
f7ace40d JW |
4749 | /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ |
4750 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
4751 | /* Unmute Line1 pin widget output buffer since it starts as an output. | |
4752 | * If the pin mode is changed by the user the pin mode control will | |
4753 | * take care of enabling the pin's input/output buffers as needed. | |
4754 | * Therefore there's no need to enable the input buffer at this | |
4755 | * stage. | |
cdcd9268 | 4756 | */ |
f7ace40d | 4757 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
ea1fb29a | 4758 | /* Unmute input buffer of pin widget used for Line-in (no equiv |
cdcd9268 JW |
4759 | * mixer ctrl) |
4760 | */ | |
f7ace40d JW |
4761 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
4762 | ||
4763 | /* Mute capture amp left and right */ | |
4764 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
ea1fb29a | 4765 | /* Set ADC connection select to match default mixer setting - line |
f7ace40d JW |
4766 | * in (on mic1 pin) |
4767 | */ | |
4768 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4769 | ||
4770 | /* Do the same for the second ADC: mute capture input amp and | |
4771 | * set ADC connection to line in (on mic1 pin) | |
4772 | */ | |
4773 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4774 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4775 | ||
4776 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4777 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4778 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4779 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4780 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4781 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4782 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4783 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4784 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4a471b7d TI |
4785 | |
4786 | { } | |
a9430dd8 JW |
4787 | }; |
4788 | ||
0bfc90e9 JW |
4789 | /* Initialisation sequence for ALC260 as configured in Acer TravelMate and |
4790 | * similar laptops (adapted from Fujitsu init verbs). | |
4791 | */ | |
4792 | static struct hda_verb alc260_acer_init_verbs[] = { | |
4793 | /* On TravelMate laptops, GPIO 0 enables the internal speaker and | |
4794 | * the headphone jack. Turn this on and rely on the standard mute | |
4795 | * methods whenever the user wants to turn these outputs off. | |
4796 | */ | |
4797 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
4798 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
4799 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, | |
4800 | /* Internal speaker/Headphone jack is connected to Line-out pin */ | |
4801 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4802 | /* Internal microphone/Mic jack is connected to Mic1 pin */ | |
4803 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
4804 | /* Line In jack is connected to Line1 pin */ | |
4805 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
bd869485 JW |
4806 | /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */ |
4807 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
0bfc90e9 JW |
4808 | /* Ensure all other unused pins are disabled and muted. */ |
4809 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4810 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
0bfc90e9 JW |
4811 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
4812 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4813 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | |
4814 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4815 | /* Disable digital (SPDIF) pins */ | |
4816 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4817 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
4818 | ||
ea1fb29a | 4819 | /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum |
0bfc90e9 JW |
4820 | * bus when acting as outputs. |
4821 | */ | |
4822 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
4823 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
4824 | ||
4825 | /* Start with output sum widgets muted and their output gains at min */ | |
4826 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4827 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4828 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4829 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4830 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4831 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4832 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4833 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
4834 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
4835 | ||
f12ab1e0 TI |
4836 | /* Unmute Line-out pin widget amp left and right |
4837 | * (no equiv mixer ctrl) | |
4838 | */ | |
0bfc90e9 | 4839 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
bd869485 JW |
4840 | /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ |
4841 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
0bfc90e9 JW |
4842 | /* Unmute Mic1 and Line1 pin widget input buffers since they start as |
4843 | * inputs. If the pin mode is changed by the user the pin mode control | |
4844 | * will take care of enabling the pin's input/output buffers as needed. | |
4845 | * Therefore there's no need to enable the input buffer at this | |
4846 | * stage. | |
4847 | */ | |
4848 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4849 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
4850 | ||
4851 | /* Mute capture amp left and right */ | |
4852 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
4853 | /* Set ADC connection select to match default mixer setting - mic | |
4854 | * (on mic1 pin) | |
4855 | */ | |
4856 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4857 | ||
4858 | /* Do similar with the second ADC: mute capture input amp and | |
a1e8d2da | 4859 | * set ADC connection to mic to match ALSA's default state. |
0bfc90e9 JW |
4860 | */ |
4861 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
a1e8d2da | 4862 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, |
0bfc90e9 JW |
4863 | |
4864 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
4865 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
4866 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
4867 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
4868 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
4869 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
4870 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
4871 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
4872 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
4873 | ||
4874 | { } | |
4875 | }; | |
4876 | ||
bc9f98a9 KY |
4877 | static struct hda_verb alc260_will_verbs[] = { |
4878 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4879 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4880 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
4881 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
4882 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
4883 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3040}, | |
4884 | {} | |
4885 | }; | |
4886 | ||
4887 | static struct hda_verb alc260_replacer_672v_verbs[] = { | |
4888 | {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
4889 | {0x1a, AC_VERB_SET_COEF_INDEX, 0x07}, | |
4890 | {0x1a, AC_VERB_SET_PROC_COEF, 0x3050}, | |
4891 | ||
4892 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, | |
4893 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, | |
4894 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
4895 | ||
4896 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4897 | {} | |
4898 | }; | |
4899 | ||
4900 | /* toggle speaker-output according to the hp-jack state */ | |
4901 | static void alc260_replacer_672v_automute(struct hda_codec *codec) | |
4902 | { | |
4903 | unsigned int present; | |
4904 | ||
4905 | /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */ | |
4906 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
4907 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
4908 | if (present) { | |
82beb8fd TI |
4909 | snd_hda_codec_write_cache(codec, 0x01, 0, |
4910 | AC_VERB_SET_GPIO_DATA, 1); | |
4911 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
4912 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4913 | PIN_HP); | |
bc9f98a9 | 4914 | } else { |
82beb8fd TI |
4915 | snd_hda_codec_write_cache(codec, 0x01, 0, |
4916 | AC_VERB_SET_GPIO_DATA, 0); | |
4917 | snd_hda_codec_write_cache(codec, 0x0f, 0, | |
4918 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4919 | PIN_OUT); | |
bc9f98a9 KY |
4920 | } |
4921 | } | |
4922 | ||
4923 | static void alc260_replacer_672v_unsol_event(struct hda_codec *codec, | |
4924 | unsigned int res) | |
4925 | { | |
4926 | if ((res >> 26) == ALC880_HP_EVENT) | |
4927 | alc260_replacer_672v_automute(codec); | |
4928 | } | |
4929 | ||
3f878308 KY |
4930 | static struct hda_verb alc260_hp_dc7600_verbs[] = { |
4931 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
4932 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
4933 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4934 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
4935 | {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4936 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
4937 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
4938 | {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4939 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4940 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
4941 | {} | |
4942 | }; | |
4943 | ||
7cf51e48 JW |
4944 | /* Test configuration for debugging, modelled after the ALC880 test |
4945 | * configuration. | |
4946 | */ | |
4947 | #ifdef CONFIG_SND_DEBUG | |
4948 | static hda_nid_t alc260_test_dac_nids[1] = { | |
4949 | 0x02, | |
4950 | }; | |
4951 | static hda_nid_t alc260_test_adc_nids[2] = { | |
4952 | 0x04, 0x05, | |
4953 | }; | |
a1e8d2da | 4954 | /* For testing the ALC260, each input MUX needs its own definition since |
ea1fb29a | 4955 | * the signal assignments are different. This assumes that the first ADC |
a1e8d2da | 4956 | * is NID 0x04. |
17e7aec6 | 4957 | */ |
a1e8d2da JW |
4958 | static struct hda_input_mux alc260_test_capture_sources[2] = { |
4959 | { | |
4960 | .num_items = 7, | |
4961 | .items = { | |
4962 | { "MIC1 pin", 0x0 }, | |
4963 | { "MIC2 pin", 0x1 }, | |
4964 | { "LINE1 pin", 0x2 }, | |
4965 | { "LINE2 pin", 0x3 }, | |
4966 | { "CD pin", 0x4 }, | |
4967 | { "LINE-OUT pin", 0x5 }, | |
4968 | { "HP-OUT pin", 0x6 }, | |
4969 | }, | |
4970 | }, | |
4971 | { | |
4972 | .num_items = 8, | |
4973 | .items = { | |
4974 | { "MIC1 pin", 0x0 }, | |
4975 | { "MIC2 pin", 0x1 }, | |
4976 | { "LINE1 pin", 0x2 }, | |
4977 | { "LINE2 pin", 0x3 }, | |
4978 | { "CD pin", 0x4 }, | |
4979 | { "Mixer", 0x5 }, | |
4980 | { "LINE-OUT pin", 0x6 }, | |
4981 | { "HP-OUT pin", 0x7 }, | |
4982 | }, | |
7cf51e48 JW |
4983 | }, |
4984 | }; | |
4985 | static struct snd_kcontrol_new alc260_test_mixer[] = { | |
4986 | /* Output driver widgets */ | |
4987 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), | |
4988 | HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), | |
4989 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT), | |
4990 | HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT), | |
4991 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT), | |
4992 | HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT), | |
4993 | ||
a1e8d2da JW |
4994 | /* Modes for retasking pin widgets |
4995 | * Note: the ALC260 doesn't seem to act on requests to enable mic | |
4996 | * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't | |
4997 | * mention this restriction. At this stage it's not clear whether | |
4998 | * this behaviour is intentional or is a hardware bug in chip | |
4999 | * revisions available at least up until early 2006. Therefore for | |
5000 | * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all | |
5001 | * choices, but if it turns out that the lack of mic bias for these | |
5002 | * NIDs is intentional we could change their modes from | |
5003 | * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS. | |
5004 | */ | |
7cf51e48 JW |
5005 | ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT), |
5006 | ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT), | |
5007 | ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
5008 | ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
5009 | ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT), | |
5010 | ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT), | |
5011 | ||
5012 | /* Loopback mixer controls */ | |
5013 | HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT), | |
5014 | HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT), | |
5015 | HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT), | |
5016 | HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT), | |
5017 | HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT), | |
5018 | HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT), | |
5019 | HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT), | |
5020 | HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), | |
5021 | HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), | |
5022 | HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), | |
5023 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), | |
5024 | HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), | |
5025 | HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), | |
5026 | HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), | |
5027 | HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), | |
5028 | HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT), | |
5c8f858d JW |
5029 | |
5030 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
5031 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
5032 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
5033 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
5034 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
5035 | ||
92621f13 JW |
5036 | /* Switches to allow the digital IO pins to be enabled. The datasheet |
5037 | * is ambigious as to which NID is which; testing on laptops which | |
ea1fb29a | 5038 | * make this output available should provide clarification. |
92621f13 JW |
5039 | */ |
5040 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01), | |
5041 | ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01), | |
5042 | ||
f8225f6d JW |
5043 | /* A switch allowing EAPD to be enabled. Some laptops seem to use |
5044 | * this output to turn on an external amplifier. | |
5045 | */ | |
5046 | ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), | |
5047 | ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), | |
5048 | ||
7cf51e48 JW |
5049 | { } /* end */ |
5050 | }; | |
5051 | static struct hda_verb alc260_test_init_verbs[] = { | |
5c8f858d JW |
5052 | /* Enable all GPIOs as outputs with an initial value of 0 */ |
5053 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f}, | |
5054 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, | |
5055 | {0x01, AC_VERB_SET_GPIO_MASK, 0x0f}, | |
5056 | ||
7cf51e48 JW |
5057 | /* Enable retasking pins as output, initially without power amp */ |
5058 | {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5059 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5060 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5061 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5062 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5063 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5064 | ||
92621f13 JW |
5065 | /* Disable digital (SPDIF) pins initially, but users can enable |
5066 | * them via a mixer switch. In the case of SPDIF-out, this initverb | |
5067 | * payload also sets the generation to 0, output to be in "consumer" | |
5068 | * PCM format, copyright asserted, no pre-emphasis and no validity | |
5069 | * control. | |
5070 | */ | |
7cf51e48 JW |
5071 | {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, |
5072 | {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, | |
5073 | ||
ea1fb29a | 5074 | /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the |
7cf51e48 JW |
5075 | * OUT1 sum bus when acting as an output. |
5076 | */ | |
5077 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0}, | |
5078 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0}, | |
5079 | {0x0d, AC_VERB_SET_CONNECT_SEL, 0}, | |
5080 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0}, | |
5081 | ||
5082 | /* Start with output sum widgets muted and their output gains at min */ | |
5083 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5084 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5085 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5086 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5087 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5088 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5089 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5090 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5091 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5092 | ||
cdcd9268 JW |
5093 | /* Unmute retasking pin widget output buffers since the default |
5094 | * state appears to be output. As the pin mode is changed by the | |
5095 | * user the pin mode control will take care of enabling the pin's | |
5096 | * input/output buffers as needed. | |
5097 | */ | |
7cf51e48 JW |
5098 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
5099 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5100 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5101 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5102 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5103 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5104 | /* Also unmute the mono-out pin widget */ | |
5105 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5106 | ||
7cf51e48 JW |
5107 | /* Mute capture amp left and right */ |
5108 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
f7ace40d JW |
5109 | /* Set ADC connection select to match default mixer setting (mic1 |
5110 | * pin) | |
7cf51e48 JW |
5111 | */ |
5112 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5113 | ||
5114 | /* Do the same for the second ADC: mute capture input amp and | |
f7ace40d | 5115 | * set ADC connection to mic1 pin |
7cf51e48 JW |
5116 | */ |
5117 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5118 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5119 | ||
5120 | /* Mute all inputs to mixer widget (even unconnected ones) */ | |
5121 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ | |
5122 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ | |
5123 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ | |
5124 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ | |
5125 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ | |
5126 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ | |
5127 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ | |
5128 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ | |
5129 | ||
5130 | { } | |
5131 | }; | |
5132 | #endif | |
5133 | ||
6330079f TI |
5134 | #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback |
5135 | #define alc260_pcm_analog_capture alc880_pcm_analog_capture | |
1da177e4 | 5136 | |
a3bcba38 TI |
5137 | #define alc260_pcm_digital_playback alc880_pcm_digital_playback |
5138 | #define alc260_pcm_digital_capture alc880_pcm_digital_capture | |
5139 | ||
df694daa KY |
5140 | /* |
5141 | * for BIOS auto-configuration | |
5142 | */ | |
16ded525 | 5143 | |
df694daa | 5144 | static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, |
863b4518 | 5145 | const char *pfx, int *vol_bits) |
df694daa KY |
5146 | { |
5147 | hda_nid_t nid_vol; | |
5148 | unsigned long vol_val, sw_val; | |
5149 | char name[32]; | |
5150 | int err; | |
5151 | ||
5152 | if (nid >= 0x0f && nid < 0x11) { | |
5153 | nid_vol = nid - 0x7; | |
5154 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
5155 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
5156 | } else if (nid == 0x11) { | |
5157 | nid_vol = nid - 0x7; | |
5158 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); | |
5159 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | |
5160 | } else if (nid >= 0x12 && nid <= 0x15) { | |
5161 | nid_vol = 0x08; | |
5162 | vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); | |
5163 | sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | |
5164 | } else | |
5165 | return 0; /* N/A */ | |
ea1fb29a | 5166 | |
863b4518 TI |
5167 | if (!(*vol_bits & (1 << nid_vol))) { |
5168 | /* first control for the volume widget */ | |
5169 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | |
5170 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val); | |
5171 | if (err < 0) | |
5172 | return err; | |
5173 | *vol_bits |= (1 << nid_vol); | |
5174 | } | |
df694daa | 5175 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); |
f12ab1e0 TI |
5176 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val); |
5177 | if (err < 0) | |
df694daa KY |
5178 | return err; |
5179 | return 1; | |
5180 | } | |
5181 | ||
5182 | /* add playback controls from the parsed DAC table */ | |
5183 | static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, | |
5184 | const struct auto_pin_cfg *cfg) | |
5185 | { | |
5186 | hda_nid_t nid; | |
5187 | int err; | |
863b4518 | 5188 | int vols = 0; |
df694daa KY |
5189 | |
5190 | spec->multiout.num_dacs = 1; | |
5191 | spec->multiout.dac_nids = spec->private_dac_nids; | |
5192 | spec->multiout.dac_nids[0] = 0x02; | |
5193 | ||
5194 | nid = cfg->line_out_pins[0]; | |
5195 | if (nid) { | |
863b4518 | 5196 | err = alc260_add_playback_controls(spec, nid, "Front", &vols); |
df694daa KY |
5197 | if (err < 0) |
5198 | return err; | |
5199 | } | |
5200 | ||
82bc955f | 5201 | nid = cfg->speaker_pins[0]; |
df694daa | 5202 | if (nid) { |
863b4518 | 5203 | err = alc260_add_playback_controls(spec, nid, "Speaker", &vols); |
df694daa KY |
5204 | if (err < 0) |
5205 | return err; | |
5206 | } | |
5207 | ||
eb06ed8f | 5208 | nid = cfg->hp_pins[0]; |
df694daa | 5209 | if (nid) { |
863b4518 TI |
5210 | err = alc260_add_playback_controls(spec, nid, "Headphone", |
5211 | &vols); | |
df694daa KY |
5212 | if (err < 0) |
5213 | return err; | |
5214 | } | |
f12ab1e0 | 5215 | return 0; |
df694daa KY |
5216 | } |
5217 | ||
5218 | /* create playback/capture controls for input pins */ | |
5219 | static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, | |
5220 | const struct auto_pin_cfg *cfg) | |
5221 | { | |
df694daa KY |
5222 | struct hda_input_mux *imux = &spec->private_imux; |
5223 | int i, err, idx; | |
5224 | ||
5225 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
5226 | if (cfg->input_pins[i] >= 0x12) { | |
5227 | idx = cfg->input_pins[i] - 0x12; | |
4a471b7d | 5228 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
5229 | auto_pin_cfg_labels[i], idx, |
5230 | 0x07); | |
df694daa KY |
5231 | if (err < 0) |
5232 | return err; | |
f12ab1e0 TI |
5233 | imux->items[imux->num_items].label = |
5234 | auto_pin_cfg_labels[i]; | |
df694daa KY |
5235 | imux->items[imux->num_items].index = idx; |
5236 | imux->num_items++; | |
5237 | } | |
f12ab1e0 | 5238 | if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){ |
df694daa | 5239 | idx = cfg->input_pins[i] - 0x09; |
4a471b7d | 5240 | err = new_analog_input(spec, cfg->input_pins[i], |
f12ab1e0 TI |
5241 | auto_pin_cfg_labels[i], idx, |
5242 | 0x07); | |
df694daa KY |
5243 | if (err < 0) |
5244 | return err; | |
f12ab1e0 TI |
5245 | imux->items[imux->num_items].label = |
5246 | auto_pin_cfg_labels[i]; | |
df694daa KY |
5247 | imux->items[imux->num_items].index = idx; |
5248 | imux->num_items++; | |
5249 | } | |
5250 | } | |
5251 | return 0; | |
5252 | } | |
5253 | ||
5254 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, | |
5255 | hda_nid_t nid, int pin_type, | |
5256 | int sel_idx) | |
5257 | { | |
f6c7e546 | 5258 | alc_set_pin_output(codec, nid, pin_type); |
df694daa KY |
5259 | /* need the manual connection? */ |
5260 | if (nid >= 0x12) { | |
5261 | int idx = nid - 0x12; | |
5262 | snd_hda_codec_write(codec, idx + 0x0b, 0, | |
5263 | AC_VERB_SET_CONNECT_SEL, sel_idx); | |
df694daa KY |
5264 | } |
5265 | } | |
5266 | ||
5267 | static void alc260_auto_init_multi_out(struct hda_codec *codec) | |
5268 | { | |
5269 | struct alc_spec *spec = codec->spec; | |
5270 | hda_nid_t nid; | |
5271 | ||
bc9f98a9 | 5272 | alc_subsystem_id(codec, 0x10, 0x15, 0x0f); |
f12ab1e0 | 5273 | nid = spec->autocfg.line_out_pins[0]; |
baba8ee9 TI |
5274 | if (nid) { |
5275 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | |
5276 | alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0); | |
5277 | } | |
ea1fb29a | 5278 | |
82bc955f | 5279 | nid = spec->autocfg.speaker_pins[0]; |
df694daa KY |
5280 | if (nid) |
5281 | alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); | |
5282 | ||
eb06ed8f | 5283 | nid = spec->autocfg.hp_pins[0]; |
df694daa | 5284 | if (nid) |
baba8ee9 | 5285 | alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0); |
f12ab1e0 | 5286 | } |
df694daa KY |
5287 | |
5288 | #define ALC260_PIN_CD_NID 0x16 | |
5289 | static void alc260_auto_init_analog_input(struct hda_codec *codec) | |
5290 | { | |
5291 | struct alc_spec *spec = codec->spec; | |
5292 | int i; | |
5293 | ||
5294 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
5295 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
5296 | if (nid >= 0x12) { | |
f12ab1e0 TI |
5297 | snd_hda_codec_write(codec, nid, 0, |
5298 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
5299 | i <= AUTO_PIN_FRONT_MIC ? | |
5300 | PIN_VREF80 : PIN_IN); | |
df694daa | 5301 | if (nid != ALC260_PIN_CD_NID) |
f12ab1e0 TI |
5302 | snd_hda_codec_write(codec, nid, 0, |
5303 | AC_VERB_SET_AMP_GAIN_MUTE, | |
df694daa KY |
5304 | AMP_OUT_MUTE); |
5305 | } | |
5306 | } | |
5307 | } | |
5308 | ||
5309 | /* | |
5310 | * generic initialization of ADC, input mixers and output mixers | |
5311 | */ | |
5312 | static struct hda_verb alc260_volume_init_verbs[] = { | |
5313 | /* | |
5314 | * Unmute ADC0-1 and set the default input to mic-in | |
5315 | */ | |
5316 | {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5317 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5318 | {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5319 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
ea1fb29a | 5320 | |
df694daa KY |
5321 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
5322 | * mixer widget | |
f12ab1e0 TI |
5323 | * Note: PASD motherboards uses the Line In 2 as the input for |
5324 | * front panel mic (mic 2) | |
df694daa KY |
5325 | */ |
5326 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
5327 | /* mute analog inputs */ |
5328 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5329 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5330 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5331 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5332 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
5333 | |
5334 | /* | |
5335 | * Set up output mixers (0x08 - 0x0a) | |
5336 | */ | |
5337 | /* set vol=0 to output mixers */ | |
5338 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5339 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5340 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5341 | /* set up input amps for analog loopback */ | |
5342 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
5343 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5344 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5345 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5346 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5347 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5348 | {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 5349 | |
df694daa KY |
5350 | { } |
5351 | }; | |
5352 | ||
5353 | static int alc260_parse_auto_config(struct hda_codec *codec) | |
5354 | { | |
5355 | struct alc_spec *spec = codec->spec; | |
df694daa KY |
5356 | int err; |
5357 | static hda_nid_t alc260_ignore[] = { 0x17, 0 }; | |
5358 | ||
f12ab1e0 TI |
5359 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
5360 | alc260_ignore); | |
5361 | if (err < 0) | |
df694daa | 5362 | return err; |
f12ab1e0 TI |
5363 | err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg); |
5364 | if (err < 0) | |
4a471b7d | 5365 | return err; |
603c4019 | 5366 | if (!spec->kctls.list) |
df694daa | 5367 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
5368 | err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); |
5369 | if (err < 0) | |
df694daa KY |
5370 | return err; |
5371 | ||
5372 | spec->multiout.max_channels = 2; | |
5373 | ||
5374 | if (spec->autocfg.dig_out_pin) | |
5375 | spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; | |
603c4019 | 5376 | if (spec->kctls.list) |
d88897ea | 5377 | add_mixer(spec, spec->kctls.list); |
df694daa | 5378 | |
d88897ea | 5379 | add_verb(spec, alc260_volume_init_verbs); |
df694daa | 5380 | |
a1e8d2da | 5381 | spec->num_mux_defs = 1; |
df694daa KY |
5382 | spec->input_mux = &spec->private_imux; |
5383 | ||
e044c39a | 5384 | store_pin_configs(codec); |
df694daa KY |
5385 | return 1; |
5386 | } | |
5387 | ||
ae6b813a TI |
5388 | /* additional initialization for auto-configuration model */ |
5389 | static void alc260_auto_init(struct hda_codec *codec) | |
df694daa | 5390 | { |
f6c7e546 | 5391 | struct alc_spec *spec = codec->spec; |
df694daa KY |
5392 | alc260_auto_init_multi_out(codec); |
5393 | alc260_auto_init_analog_input(codec); | |
f6c7e546 | 5394 | if (spec->unsol_event) |
7fb0d78f | 5395 | alc_inithook(codec); |
df694daa KY |
5396 | } |
5397 | ||
cb53c626 TI |
5398 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5399 | static struct hda_amp_list alc260_loopbacks[] = { | |
5400 | { 0x07, HDA_INPUT, 0 }, | |
5401 | { 0x07, HDA_INPUT, 1 }, | |
5402 | { 0x07, HDA_INPUT, 2 }, | |
5403 | { 0x07, HDA_INPUT, 3 }, | |
5404 | { 0x07, HDA_INPUT, 4 }, | |
5405 | { } /* end */ | |
5406 | }; | |
5407 | #endif | |
5408 | ||
df694daa KY |
5409 | /* |
5410 | * ALC260 configurations | |
5411 | */ | |
f5fcc13c TI |
5412 | static const char *alc260_models[ALC260_MODEL_LAST] = { |
5413 | [ALC260_BASIC] = "basic", | |
5414 | [ALC260_HP] = "hp", | |
5415 | [ALC260_HP_3013] = "hp-3013", | |
2922c9af | 5416 | [ALC260_HP_DC7600] = "hp-dc7600", |
f5fcc13c TI |
5417 | [ALC260_FUJITSU_S702X] = "fujitsu", |
5418 | [ALC260_ACER] = "acer", | |
bc9f98a9 KY |
5419 | [ALC260_WILL] = "will", |
5420 | [ALC260_REPLACER_672V] = "replacer", | |
7cf51e48 | 5421 | #ifdef CONFIG_SND_DEBUG |
f5fcc13c | 5422 | [ALC260_TEST] = "test", |
7cf51e48 | 5423 | #endif |
f5fcc13c TI |
5424 | [ALC260_AUTO] = "auto", |
5425 | }; | |
5426 | ||
5427 | static struct snd_pci_quirk alc260_cfg_tbl[] = { | |
bd869485 | 5428 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), |
f5fcc13c | 5429 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), |
9720b718 | 5430 | SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), |
a8a5d067 | 5431 | SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013), |
f5fcc13c | 5432 | SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), |
34ec8a0a | 5433 | SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013), |
3f878308 | 5434 | SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600), |
f5fcc13c TI |
5435 | SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013), |
5436 | SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP), | |
5437 | SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP), | |
5438 | SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP), | |
5439 | SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC), | |
5440 | SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC), | |
5441 | SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), | |
5442 | SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), | |
5443 | SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), | |
bc9f98a9 | 5444 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V), |
ac3e3741 | 5445 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL), |
df694daa KY |
5446 | {} |
5447 | }; | |
5448 | ||
5449 | static struct alc_config_preset alc260_presets[] = { | |
5450 | [ALC260_BASIC] = { | |
5451 | .mixers = { alc260_base_output_mixer, | |
5452 | alc260_input_mixer, | |
f9e336f6 | 5453 | alc260_pc_beep_mixer }, |
df694daa KY |
5454 | .init_verbs = { alc260_init_verbs }, |
5455 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5456 | .dac_nids = alc260_dac_nids, | |
f9e336f6 | 5457 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
df694daa KY |
5458 | .adc_nids = alc260_adc_nids, |
5459 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5460 | .channel_mode = alc260_modes, | |
5461 | .input_mux = &alc260_capture_source, | |
5462 | }, | |
5463 | [ALC260_HP] = { | |
bec15c3a | 5464 | .mixers = { alc260_hp_output_mixer, |
f9e336f6 | 5465 | alc260_input_mixer }, |
bec15c3a TI |
5466 | .init_verbs = { alc260_init_verbs, |
5467 | alc260_hp_unsol_verbs }, | |
df694daa KY |
5468 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
5469 | .dac_nids = alc260_dac_nids, | |
f9e336f6 TI |
5470 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt), |
5471 | .adc_nids = alc260_adc_nids_alt, | |
df694daa KY |
5472 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5473 | .channel_mode = alc260_modes, | |
5474 | .input_mux = &alc260_capture_source, | |
bec15c3a TI |
5475 | .unsol_event = alc260_hp_unsol_event, |
5476 | .init_hook = alc260_hp_automute, | |
df694daa | 5477 | }, |
3f878308 KY |
5478 | [ALC260_HP_DC7600] = { |
5479 | .mixers = { alc260_hp_dc7600_mixer, | |
f9e336f6 | 5480 | alc260_input_mixer }, |
3f878308 KY |
5481 | .init_verbs = { alc260_init_verbs, |
5482 | alc260_hp_dc7600_verbs }, | |
5483 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5484 | .dac_nids = alc260_dac_nids, | |
f9e336f6 TI |
5485 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt), |
5486 | .adc_nids = alc260_adc_nids_alt, | |
3f878308 KY |
5487 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5488 | .channel_mode = alc260_modes, | |
5489 | .input_mux = &alc260_capture_source, | |
5490 | .unsol_event = alc260_hp_3012_unsol_event, | |
5491 | .init_hook = alc260_hp_3012_automute, | |
5492 | }, | |
df694daa KY |
5493 | [ALC260_HP_3013] = { |
5494 | .mixers = { alc260_hp_3013_mixer, | |
f9e336f6 | 5495 | alc260_input_mixer }, |
bec15c3a TI |
5496 | .init_verbs = { alc260_hp_3013_init_verbs, |
5497 | alc260_hp_3013_unsol_verbs }, | |
df694daa KY |
5498 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), |
5499 | .dac_nids = alc260_dac_nids, | |
f9e336f6 TI |
5500 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt), |
5501 | .adc_nids = alc260_adc_nids_alt, | |
df694daa KY |
5502 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5503 | .channel_mode = alc260_modes, | |
5504 | .input_mux = &alc260_capture_source, | |
bec15c3a TI |
5505 | .unsol_event = alc260_hp_3013_unsol_event, |
5506 | .init_hook = alc260_hp_3013_automute, | |
df694daa KY |
5507 | }, |
5508 | [ALC260_FUJITSU_S702X] = { | |
f9e336f6 | 5509 | .mixers = { alc260_fujitsu_mixer }, |
df694daa KY |
5510 | .init_verbs = { alc260_fujitsu_init_verbs }, |
5511 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5512 | .dac_nids = alc260_dac_nids, | |
d57fdac0 JW |
5513 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), |
5514 | .adc_nids = alc260_dual_adc_nids, | |
df694daa KY |
5515 | .num_channel_mode = ARRAY_SIZE(alc260_modes), |
5516 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5517 | .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources), |
5518 | .input_mux = alc260_fujitsu_capture_sources, | |
df694daa | 5519 | }, |
0bfc90e9 | 5520 | [ALC260_ACER] = { |
f9e336f6 | 5521 | .mixers = { alc260_acer_mixer }, |
0bfc90e9 JW |
5522 | .init_verbs = { alc260_acer_init_verbs }, |
5523 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5524 | .dac_nids = alc260_dac_nids, | |
5525 | .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids), | |
5526 | .adc_nids = alc260_dual_adc_nids, | |
5527 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5528 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5529 | .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), |
5530 | .input_mux = alc260_acer_capture_sources, | |
0bfc90e9 | 5531 | }, |
bc9f98a9 | 5532 | [ALC260_WILL] = { |
f9e336f6 | 5533 | .mixers = { alc260_will_mixer }, |
bc9f98a9 KY |
5534 | .init_verbs = { alc260_init_verbs, alc260_will_verbs }, |
5535 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5536 | .dac_nids = alc260_dac_nids, | |
5537 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
5538 | .adc_nids = alc260_adc_nids, | |
5539 | .dig_out_nid = ALC260_DIGOUT_NID, | |
5540 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5541 | .channel_mode = alc260_modes, | |
5542 | .input_mux = &alc260_capture_source, | |
5543 | }, | |
5544 | [ALC260_REPLACER_672V] = { | |
f9e336f6 | 5545 | .mixers = { alc260_replacer_672v_mixer }, |
bc9f98a9 KY |
5546 | .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs }, |
5547 | .num_dacs = ARRAY_SIZE(alc260_dac_nids), | |
5548 | .dac_nids = alc260_dac_nids, | |
5549 | .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), | |
5550 | .adc_nids = alc260_adc_nids, | |
5551 | .dig_out_nid = ALC260_DIGOUT_NID, | |
5552 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5553 | .channel_mode = alc260_modes, | |
5554 | .input_mux = &alc260_capture_source, | |
5555 | .unsol_event = alc260_replacer_672v_unsol_event, | |
5556 | .init_hook = alc260_replacer_672v_automute, | |
5557 | }, | |
7cf51e48 JW |
5558 | #ifdef CONFIG_SND_DEBUG |
5559 | [ALC260_TEST] = { | |
f9e336f6 | 5560 | .mixers = { alc260_test_mixer }, |
7cf51e48 JW |
5561 | .init_verbs = { alc260_test_init_verbs }, |
5562 | .num_dacs = ARRAY_SIZE(alc260_test_dac_nids), | |
5563 | .dac_nids = alc260_test_dac_nids, | |
5564 | .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids), | |
5565 | .adc_nids = alc260_test_adc_nids, | |
5566 | .num_channel_mode = ARRAY_SIZE(alc260_modes), | |
5567 | .channel_mode = alc260_modes, | |
a1e8d2da JW |
5568 | .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources), |
5569 | .input_mux = alc260_test_capture_sources, | |
7cf51e48 JW |
5570 | }, |
5571 | #endif | |
df694daa KY |
5572 | }; |
5573 | ||
5574 | static int patch_alc260(struct hda_codec *codec) | |
1da177e4 LT |
5575 | { |
5576 | struct alc_spec *spec; | |
df694daa | 5577 | int err, board_config; |
1da177e4 | 5578 | |
e560d8d8 | 5579 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1da177e4 LT |
5580 | if (spec == NULL) |
5581 | return -ENOMEM; | |
5582 | ||
5583 | codec->spec = spec; | |
5584 | ||
f5fcc13c TI |
5585 | board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST, |
5586 | alc260_models, | |
5587 | alc260_cfg_tbl); | |
5588 | if (board_config < 0) { | |
9c7f852e TI |
5589 | snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, " |
5590 | "trying auto-probe from BIOS...\n"); | |
df694daa | 5591 | board_config = ALC260_AUTO; |
16ded525 | 5592 | } |
1da177e4 | 5593 | |
df694daa KY |
5594 | if (board_config == ALC260_AUTO) { |
5595 | /* automatic parse from the BIOS config */ | |
5596 | err = alc260_parse_auto_config(codec); | |
5597 | if (err < 0) { | |
5598 | alc_free(codec); | |
5599 | return err; | |
f12ab1e0 | 5600 | } else if (!err) { |
9c7f852e TI |
5601 | printk(KERN_INFO |
5602 | "hda_codec: Cannot set up configuration " | |
5603 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
5604 | board_config = ALC260_BASIC; |
5605 | } | |
a9430dd8 | 5606 | } |
e9edcee0 | 5607 | |
df694daa KY |
5608 | if (board_config != ALC260_AUTO) |
5609 | setup_preset(spec, &alc260_presets[board_config]); | |
1da177e4 LT |
5610 | |
5611 | spec->stream_name_analog = "ALC260 Analog"; | |
5612 | spec->stream_analog_playback = &alc260_pcm_analog_playback; | |
5613 | spec->stream_analog_capture = &alc260_pcm_analog_capture; | |
5614 | ||
a3bcba38 TI |
5615 | spec->stream_name_digital = "ALC260 Digital"; |
5616 | spec->stream_digital_playback = &alc260_pcm_digital_playback; | |
5617 | spec->stream_digital_capture = &alc260_pcm_digital_capture; | |
5618 | ||
f9e336f6 TI |
5619 | set_capture_mixer(spec); |
5620 | ||
2134ea4f TI |
5621 | spec->vmaster_nid = 0x08; |
5622 | ||
1da177e4 | 5623 | codec->patch_ops = alc_patch_ops; |
df694daa | 5624 | if (board_config == ALC260_AUTO) |
ae6b813a | 5625 | spec->init_hook = alc260_auto_init; |
cb53c626 TI |
5626 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5627 | if (!spec->loopback.amplist) | |
5628 | spec->loopback.amplist = alc260_loopbacks; | |
5629 | #endif | |
1da177e4 LT |
5630 | |
5631 | return 0; | |
5632 | } | |
5633 | ||
e9edcee0 | 5634 | |
1da177e4 LT |
5635 | /* |
5636 | * ALC882 support | |
5637 | * | |
5638 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible | |
5639 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
5640 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
5641 | * 6-channel independent captures. | |
5642 | * | |
5643 | * In addition, an independent DAC for the multi-playback (not used in this | |
5644 | * driver yet). | |
5645 | */ | |
df694daa KY |
5646 | #define ALC882_DIGOUT_NID 0x06 |
5647 | #define ALC882_DIGIN_NID 0x0a | |
1da177e4 | 5648 | |
d2a6d7dc | 5649 | static struct hda_channel_mode alc882_ch_modes[1] = { |
1da177e4 LT |
5650 | { 8, NULL } |
5651 | }; | |
5652 | ||
5653 | static hda_nid_t alc882_dac_nids[4] = { | |
5654 | /* front, rear, clfe, rear_surr */ | |
5655 | 0x02, 0x03, 0x04, 0x05 | |
5656 | }; | |
5657 | ||
df694daa KY |
5658 | /* identical with ALC880 */ |
5659 | #define alc882_adc_nids alc880_adc_nids | |
5660 | #define alc882_adc_nids_alt alc880_adc_nids_alt | |
1da177e4 | 5661 | |
e1406348 TI |
5662 | static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 }; |
5663 | static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 }; | |
5664 | ||
1da177e4 LT |
5665 | /* input MUX */ |
5666 | /* FIXME: should be a matrix-type input source selection */ | |
5667 | ||
5668 | static struct hda_input_mux alc882_capture_source = { | |
5669 | .num_items = 4, | |
5670 | .items = { | |
5671 | { "Mic", 0x0 }, | |
5672 | { "Front Mic", 0x1 }, | |
5673 | { "Line", 0x2 }, | |
5674 | { "CD", 0x4 }, | |
5675 | }, | |
5676 | }; | |
272a527c KY |
5677 | /* |
5678 | * 2ch mode | |
5679 | */ | |
5680 | static struct hda_verb alc882_3ST_ch2_init[] = { | |
5681 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
5682 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5683 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
5684 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
5685 | { } /* end */ | |
5686 | }; | |
5687 | ||
5688 | /* | |
5689 | * 6ch mode | |
5690 | */ | |
5691 | static struct hda_verb alc882_3ST_ch6_init[] = { | |
5692 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5693 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5694 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
5695 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5696 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
5697 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
5698 | { } /* end */ | |
5699 | }; | |
5700 | ||
5701 | static struct hda_channel_mode alc882_3ST_6ch_modes[2] = { | |
5702 | { 2, alc882_3ST_ch2_init }, | |
5703 | { 6, alc882_3ST_ch6_init }, | |
5704 | }; | |
5705 | ||
df694daa KY |
5706 | /* |
5707 | * 6ch mode | |
5708 | */ | |
5709 | static struct hda_verb alc882_sixstack_ch6_init[] = { | |
5710 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
5711 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5712 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5713 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5714 | { } /* end */ | |
5715 | }; | |
5716 | ||
5717 | /* | |
5718 | * 8ch mode | |
5719 | */ | |
5720 | static struct hda_verb alc882_sixstack_ch8_init[] = { | |
5721 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5722 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5723 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5724 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5725 | { } /* end */ | |
5726 | }; | |
5727 | ||
5728 | static struct hda_channel_mode alc882_sixstack_modes[2] = { | |
5729 | { 6, alc882_sixstack_ch6_init }, | |
5730 | { 8, alc882_sixstack_ch8_init }, | |
5731 | }; | |
5732 | ||
87350ad0 TI |
5733 | /* |
5734 | * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic | |
5735 | */ | |
5736 | ||
5737 | /* | |
5738 | * 2ch mode | |
5739 | */ | |
5740 | static struct hda_verb alc885_mbp_ch2_init[] = { | |
5741 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
5742 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5743 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5744 | { } /* end */ | |
5745 | }; | |
5746 | ||
5747 | /* | |
5748 | * 6ch mode | |
5749 | */ | |
5750 | static struct hda_verb alc885_mbp_ch6_init[] = { | |
5751 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
5752 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5753 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
5754 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
5755 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
5756 | { } /* end */ | |
5757 | }; | |
5758 | ||
5759 | static struct hda_channel_mode alc885_mbp_6ch_modes[2] = { | |
5760 | { 2, alc885_mbp_ch2_init }, | |
5761 | { 6, alc885_mbp_ch6_init }, | |
5762 | }; | |
5763 | ||
5764 | ||
1da177e4 LT |
5765 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
5766 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
5767 | */ | |
c8b6bf9b | 5768 | static struct snd_kcontrol_new alc882_base_mixer[] = { |
05acb863 | 5769 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
985be54b | 5770 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
05acb863 | 5771 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
985be54b | 5772 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
05acb863 TI |
5773 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
5774 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
985be54b TI |
5775 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
5776 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
05acb863 | 5777 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
985be54b | 5778 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), |
1da177e4 LT |
5779 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
5780 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5781 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5782 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5783 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5784 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 5785 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
1da177e4 LT |
5786 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
5787 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 5788 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
1da177e4 LT |
5789 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
5790 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5791 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
1da177e4 LT |
5792 | { } /* end */ |
5793 | }; | |
5794 | ||
87350ad0 | 5795 | static struct snd_kcontrol_new alc885_mbp3_mixer[] = { |
2134ea4f TI |
5796 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), |
5797 | HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT), | |
5798 | HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT), | |
5799 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT), | |
5800 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5801 | HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
87350ad0 TI |
5802 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), |
5803 | HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT), | |
2134ea4f | 5804 | HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT), |
87350ad0 TI |
5805 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT), |
5806 | { } /* end */ | |
5807 | }; | |
bdd148a3 KY |
5808 | static struct snd_kcontrol_new alc882_w2jc_mixer[] = { |
5809 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5810 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5811 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5812 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5813 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5814 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5815 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5816 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
5817 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
5818 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5819 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5820 | { } /* end */ | |
5821 | }; | |
5822 | ||
272a527c KY |
5823 | static struct snd_kcontrol_new alc882_targa_mixer[] = { |
5824 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5825 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5826 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
5827 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5828 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5829 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5830 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5831 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5832 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
96fe7cc8 | 5833 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
272a527c KY |
5834 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
5835 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
96fe7cc8 | 5836 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
272a527c KY |
5837 | { } /* end */ |
5838 | }; | |
5839 | ||
5840 | /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ??? | |
5841 | * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c | |
5842 | */ | |
5843 | static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = { | |
5844 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5845 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
5846 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
5847 | HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT), | |
5848 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5849 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5850 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5851 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5852 | HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT), | |
5853 | HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT), | |
5854 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5855 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
96fe7cc8 | 5856 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
272a527c KY |
5857 | { } /* end */ |
5858 | }; | |
5859 | ||
914759b7 TI |
5860 | static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = { |
5861 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5862 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5863 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
5864 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
5865 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
5866 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5867 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5868 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
5869 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
5870 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
5871 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
5872 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
5873 | { } /* end */ | |
5874 | }; | |
5875 | ||
df694daa KY |
5876 | static struct snd_kcontrol_new alc882_chmode_mixer[] = { |
5877 | { | |
5878 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
5879 | .name = "Channel Mode", | |
5880 | .info = alc_ch_mode_info, | |
5881 | .get = alc_ch_mode_get, | |
5882 | .put = alc_ch_mode_put, | |
5883 | }, | |
5884 | { } /* end */ | |
5885 | }; | |
5886 | ||
1da177e4 LT |
5887 | static struct hda_verb alc882_init_verbs[] = { |
5888 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
05acb863 TI |
5889 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5890 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5891 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5892 | /* Rear mixer */ |
05acb863 TI |
5893 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5894 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5895 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5896 | /* CLFE mixer */ |
05acb863 TI |
5897 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5898 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5899 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5900 | /* Side mixer */ |
05acb863 TI |
5901 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
5902 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5903 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
1da177e4 | 5904 | |
e9edcee0 | 5905 | /* Front Pin: output 0 (0x0c) */ |
05acb863 | 5906 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5907 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5908 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
e9edcee0 | 5909 | /* Rear Pin: output 1 (0x0d) */ |
05acb863 | 5910 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5911 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5912 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
e9edcee0 | 5913 | /* CLFE Pin: output 2 (0x0e) */ |
05acb863 | 5914 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5915 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5916 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, |
e9edcee0 | 5917 | /* Side Pin: output 3 (0x0f) */ |
05acb863 | 5918 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
05acb863 | 5919 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
1da177e4 | 5920 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, |
e9edcee0 | 5921 | /* Mic (rear) pin: input vref at 80% */ |
16ded525 | 5922 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
5923 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5924 | /* Front Mic pin: input vref at 80% */ | |
16ded525 | 5925 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
e9edcee0 TI |
5926 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5927 | /* Line In pin: input */ | |
05acb863 | 5928 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
e9edcee0 TI |
5929 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
5930 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
5931 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5932 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5933 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
1da177e4 | 5934 | /* CD pin widget for input */ |
05acb863 | 5935 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1da177e4 LT |
5936 | |
5937 | /* FIXME: use matrix-type input source selection */ | |
5938 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
5939 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
05acb863 TI |
5940 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5941 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5942 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5943 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 5944 | /* Input mixer2 */ |
05acb863 TI |
5945 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5946 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5947 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5948 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
1da177e4 | 5949 | /* Input mixer3 */ |
05acb863 TI |
5950 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
5951 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
5952 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
5953 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
5954 | /* ADC1: mute amp left and right */ | |
5955 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5956 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
5957 | /* ADC2: mute amp left and right */ |
5958 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5959 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
05acb863 TI |
5960 | /* ADC3: mute amp left and right */ |
5961 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
71fe7b82 | 5962 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
1da177e4 LT |
5963 | |
5964 | { } | |
5965 | }; | |
5966 | ||
4b146cb0 TI |
5967 | static struct hda_verb alc882_eapd_verbs[] = { |
5968 | /* change to EAPD mode */ | |
5969 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
b373bdeb | 5970 | {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, |
f12ab1e0 | 5971 | { } |
4b146cb0 TI |
5972 | }; |
5973 | ||
9102cd1c TD |
5974 | /* Mac Pro test */ |
5975 | static struct snd_kcontrol_new alc882_macpro_mixer[] = { | |
5976 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
5977 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
5978 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT), | |
5979 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
5980 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
5981 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
5982 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
5983 | { } /* end */ | |
5984 | }; | |
5985 | ||
5986 | static struct hda_verb alc882_macpro_init_verbs[] = { | |
5987 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
5988 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
5989 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
5990 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
5991 | /* Front Pin: output 0 (0x0c) */ | |
5992 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
5993 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
5994 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
5995 | /* Front Mic pin: input vref at 80% */ | |
5996 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
5997 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
5998 | /* Speaker: output */ | |
5999 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6000 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6001 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04}, | |
6002 | /* Headphone output (output 0 - 0x0c) */ | |
6003 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6004 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6005 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6006 | ||
6007 | /* FIXME: use matrix-type input source selection */ | |
6008 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6009 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
6010 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6011 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6012 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6013 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6014 | /* Input mixer2 */ | |
6015 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6016 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6017 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6018 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6019 | /* Input mixer3 */ | |
6020 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6021 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6022 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6023 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6024 | /* ADC1: mute amp left and right */ | |
6025 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6026 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6027 | /* ADC2: mute amp left and right */ | |
6028 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6029 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6030 | /* ADC3: mute amp left and right */ | |
6031 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6032 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6033 | ||
6034 | { } | |
6035 | }; | |
f12ab1e0 | 6036 | |
87350ad0 TI |
6037 | /* Macbook Pro rev3 */ |
6038 | static struct hda_verb alc885_mbp3_init_verbs[] = { | |
6039 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
6040 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6041 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6042 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6043 | /* Rear mixer */ | |
6044 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6045 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6046 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6047 | /* Front Pin: output 0 (0x0c) */ | |
6048 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6049 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6050 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6051 | /* HP Pin: output 0 (0x0d) */ | |
6052 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, | |
6053 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6054 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6055 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6056 | /* Mic (rear) pin: input vref at 80% */ | |
6057 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6058 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6059 | /* Front Mic pin: input vref at 80% */ | |
6060 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6061 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6062 | /* Line In pin: use output 1 when in LineOut mode */ | |
6063 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
6064 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6065 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
6066 | ||
6067 | /* FIXME: use matrix-type input source selection */ | |
6068 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6069 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
6070 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6071 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6072 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6073 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6074 | /* Input mixer2 */ | |
6075 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6076 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6077 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6078 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6079 | /* Input mixer3 */ | |
6080 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6081 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6082 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6083 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
6084 | /* ADC1: mute amp left and right */ | |
6085 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6086 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6087 | /* ADC2: mute amp left and right */ | |
6088 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6089 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6090 | /* ADC3: mute amp left and right */ | |
6091 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
6092 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6093 | ||
6094 | { } | |
6095 | }; | |
6096 | ||
c54728d8 NF |
6097 | /* iMac 24 mixer. */ |
6098 | static struct snd_kcontrol_new alc885_imac24_mixer[] = { | |
6099 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | |
6100 | HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT), | |
6101 | { } /* end */ | |
6102 | }; | |
6103 | ||
6104 | /* iMac 24 init verbs. */ | |
6105 | static struct hda_verb alc885_imac24_init_verbs[] = { | |
6106 | /* Internal speakers: output 0 (0x0c) */ | |
6107 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6108 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6109 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6110 | /* Internal speakers: output 0 (0x0c) */ | |
6111 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6112 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6113 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6114 | /* Headphone: output 0 (0x0c) */ | |
6115 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6116 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
6117 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6118 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6119 | /* Front Mic: input vref at 80% */ | |
6120 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
6121 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
6122 | { } | |
6123 | }; | |
6124 | ||
6125 | /* Toggle speaker-output according to the hp-jack state */ | |
6126 | static void alc885_imac24_automute(struct hda_codec *codec) | |
6127 | { | |
6128 | unsigned int present; | |
6129 | ||
6130 | present = snd_hda_codec_read(codec, 0x14, 0, | |
6131 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6132 | snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0, |
6133 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
6134 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
6135 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
c54728d8 NF |
6136 | } |
6137 | ||
6138 | /* Processes unsolicited events. */ | |
6139 | static void alc885_imac24_unsol_event(struct hda_codec *codec, | |
6140 | unsigned int res) | |
6141 | { | |
6142 | /* Headphone insertion or removal. */ | |
6143 | if ((res >> 26) == ALC880_HP_EVENT) | |
6144 | alc885_imac24_automute(codec); | |
6145 | } | |
6146 | ||
87350ad0 TI |
6147 | static void alc885_mbp3_automute(struct hda_codec *codec) |
6148 | { | |
6149 | unsigned int present; | |
6150 | ||
6151 | present = snd_hda_codec_read(codec, 0x15, 0, | |
6152 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
6153 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
6154 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
6155 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
6156 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
6157 | ||
6158 | } | |
6159 | static void alc885_mbp3_unsol_event(struct hda_codec *codec, | |
6160 | unsigned int res) | |
6161 | { | |
6162 | /* Headphone insertion or removal. */ | |
6163 | if ((res >> 26) == ALC880_HP_EVENT) | |
6164 | alc885_mbp3_automute(codec); | |
6165 | } | |
6166 | ||
6167 | ||
272a527c KY |
6168 | static struct hda_verb alc882_targa_verbs[] = { |
6169 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6170 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6171 | ||
6172 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6173 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 6174 | |
272a527c KY |
6175 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ |
6176 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6177 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6178 | ||
6179 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
6180 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | |
6181 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
6182 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
6183 | { } /* end */ | |
6184 | }; | |
6185 | ||
6186 | /* toggle speaker-output according to the hp-jack state */ | |
6187 | static void alc882_targa_automute(struct hda_codec *codec) | |
6188 | { | |
6189 | unsigned int present; | |
ea1fb29a | 6190 | |
272a527c KY |
6191 | present = snd_hda_codec_read(codec, 0x14, 0, |
6192 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
6193 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, |
6194 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
82beb8fd TI |
6195 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
6196 | present ? 1 : 3); | |
272a527c KY |
6197 | } |
6198 | ||
6199 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) | |
6200 | { | |
6201 | /* Looks like the unsol event is incompatible with the standard | |
6202 | * definition. 4bit tag is placed at 26 bit! | |
6203 | */ | |
6204 | if (((res >> 26) == ALC880_HP_EVENT)) { | |
6205 | alc882_targa_automute(codec); | |
6206 | } | |
6207 | } | |
6208 | ||
6209 | static struct hda_verb alc882_asus_a7j_verbs[] = { | |
6210 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6211 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6212 | ||
6213 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6214 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6215 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 6216 | |
272a527c KY |
6217 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ |
6218 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6219 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
6220 | ||
6221 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
6222 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6223 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6224 | { } /* end */ | |
6225 | }; | |
6226 | ||
914759b7 TI |
6227 | static struct hda_verb alc882_asus_a7m_verbs[] = { |
6228 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6229 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6230 | ||
6231 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
6232 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
6233 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 6234 | |
914759b7 TI |
6235 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ |
6236 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6237 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */ | |
6238 | ||
6239 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ | |
6240 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
6241 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
6242 | { } /* end */ | |
6243 | }; | |
6244 | ||
9102cd1c TD |
6245 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
6246 | { | |
6247 | unsigned int gpiostate, gpiomask, gpiodir; | |
6248 | ||
6249 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, | |
6250 | AC_VERB_GET_GPIO_DATA, 0); | |
6251 | ||
6252 | if (!muted) | |
6253 | gpiostate |= (1 << pin); | |
6254 | else | |
6255 | gpiostate &= ~(1 << pin); | |
6256 | ||
6257 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, | |
6258 | AC_VERB_GET_GPIO_MASK, 0); | |
6259 | gpiomask |= (1 << pin); | |
6260 | ||
6261 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, | |
6262 | AC_VERB_GET_GPIO_DIRECTION, 0); | |
6263 | gpiodir |= (1 << pin); | |
6264 | ||
6265 | ||
6266 | snd_hda_codec_write(codec, codec->afg, 0, | |
6267 | AC_VERB_SET_GPIO_MASK, gpiomask); | |
6268 | snd_hda_codec_write(codec, codec->afg, 0, | |
6269 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); | |
6270 | ||
6271 | msleep(1); | |
6272 | ||
6273 | snd_hda_codec_write(codec, codec->afg, 0, | |
6274 | AC_VERB_SET_GPIO_DATA, gpiostate); | |
6275 | } | |
6276 | ||
7debbe51 TI |
6277 | /* set up GPIO at initialization */ |
6278 | static void alc885_macpro_init_hook(struct hda_codec *codec) | |
6279 | { | |
6280 | alc882_gpio_mute(codec, 0, 0); | |
6281 | alc882_gpio_mute(codec, 1, 0); | |
6282 | } | |
6283 | ||
6284 | /* set up GPIO and update auto-muting at initialization */ | |
6285 | static void alc885_imac24_init_hook(struct hda_codec *codec) | |
6286 | { | |
6287 | alc885_macpro_init_hook(codec); | |
6288 | alc885_imac24_automute(codec); | |
6289 | } | |
6290 | ||
df694daa KY |
6291 | /* |
6292 | * generic initialization of ADC, input mixers and output mixers | |
6293 | */ | |
6294 | static struct hda_verb alc882_auto_init_verbs[] = { | |
6295 | /* | |
6296 | * Unmute ADC0-2 and set the default input to mic-in | |
6297 | */ | |
6298 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6299 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6300 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6301 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6302 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
6303 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
1da177e4 | 6304 | |
cb53c626 | 6305 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 6306 | * mixer widget |
f12ab1e0 TI |
6307 | * Note: PASD motherboards uses the Line In 2 as the input for |
6308 | * front panel mic (mic 2) | |
df694daa KY |
6309 | */ |
6310 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
6311 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
6312 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
6313 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
6314 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
6315 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
e9edcee0 | 6316 | |
df694daa KY |
6317 | /* |
6318 | * Set up output mixers (0x0c - 0x0f) | |
6319 | */ | |
6320 | /* set vol=0 to output mixers */ | |
6321 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6322 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6323 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6324 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
6325 | /* set up input amps for analog loopback */ | |
6326 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
6327 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6328 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6329 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6330 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6331 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6332 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6333 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6334 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6335 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
6336 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6337 | ||
6338 | /* FIXME: use matrix-type input source selection */ | |
6339 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
6340 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
6341 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6342 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6343 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6344 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6345 | /* Input mixer2 */ | |
6346 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6347 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6348 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6349 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6350 | /* Input mixer3 */ | |
6351 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
6352 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
6353 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
6354 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
6355 | ||
6356 | { } | |
6357 | }; | |
6358 | ||
cb53c626 TI |
6359 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
6360 | #define alc882_loopbacks alc880_loopbacks | |
6361 | #endif | |
6362 | ||
df694daa KY |
6363 | /* pcm configuration: identiacal with ALC880 */ |
6364 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback | |
6365 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture | |
6366 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback | |
6367 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture | |
6368 | ||
6369 | /* | |
6370 | * configuration and preset | |
6371 | */ | |
f5fcc13c TI |
6372 | static const char *alc882_models[ALC882_MODEL_LAST] = { |
6373 | [ALC882_3ST_DIG] = "3stack-dig", | |
6374 | [ALC882_6ST_DIG] = "6stack-dig", | |
6375 | [ALC882_ARIMA] = "arima", | |
bdd148a3 | 6376 | [ALC882_W2JC] = "w2jc", |
0438a00e TI |
6377 | [ALC882_TARGA] = "targa", |
6378 | [ALC882_ASUS_A7J] = "asus-a7j", | |
6379 | [ALC882_ASUS_A7M] = "asus-a7m", | |
9102cd1c | 6380 | [ALC885_MACPRO] = "macpro", |
87350ad0 | 6381 | [ALC885_MBP3] = "mbp3", |
c54728d8 | 6382 | [ALC885_IMAC24] = "imac24", |
f5fcc13c TI |
6383 | [ALC882_AUTO] = "auto", |
6384 | }; | |
6385 | ||
6386 | static struct snd_pci_quirk alc882_cfg_tbl[] = { | |
6387 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), | |
272a527c | 6388 | SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J), |
ac8842a0 | 6389 | SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J), |
914759b7 | 6390 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M), |
ac3e3741 | 6391 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC), |
c5d9f1cd | 6392 | SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG), |
7b9470d8 | 6393 | SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), |
ac3e3741 | 6394 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), |
4444704c | 6395 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG), |
ac3e3741 TI |
6396 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ |
6397 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), | |
6398 | SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), | |
df694daa KY |
6399 | {} |
6400 | }; | |
6401 | ||
6402 | static struct alc_config_preset alc882_presets[] = { | |
6403 | [ALC882_3ST_DIG] = { | |
6404 | .mixers = { alc882_base_mixer }, | |
6405 | .init_verbs = { alc882_init_verbs }, | |
6406 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6407 | .dac_nids = alc882_dac_nids, | |
6408 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
6409 | .dig_in_nid = ALC882_DIGIN_NID, |
6410 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6411 | .channel_mode = alc882_ch_modes, | |
4e195a7b | 6412 | .need_dac_fix = 1, |
df694daa KY |
6413 | .input_mux = &alc882_capture_source, |
6414 | }, | |
6415 | [ALC882_6ST_DIG] = { | |
6416 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
6417 | .init_verbs = { alc882_init_verbs }, | |
6418 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6419 | .dac_nids = alc882_dac_nids, | |
6420 | .dig_out_nid = ALC882_DIGOUT_NID, | |
df694daa KY |
6421 | .dig_in_nid = ALC882_DIGIN_NID, |
6422 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
6423 | .channel_mode = alc882_sixstack_modes, | |
6424 | .input_mux = &alc882_capture_source, | |
6425 | }, | |
4b146cb0 TI |
6426 | [ALC882_ARIMA] = { |
6427 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | |
6428 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs }, | |
6429 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6430 | .dac_nids = alc882_dac_nids, | |
6431 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | |
6432 | .channel_mode = alc882_sixstack_modes, | |
6433 | .input_mux = &alc882_capture_source, | |
6434 | }, | |
bdd148a3 KY |
6435 | [ALC882_W2JC] = { |
6436 | .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer }, | |
6437 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
6438 | alc880_gpio1_init_verbs }, | |
6439 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6440 | .dac_nids = alc882_dac_nids, | |
6441 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
6442 | .channel_mode = alc880_threestack_modes, | |
6443 | .need_dac_fix = 1, | |
6444 | .input_mux = &alc882_capture_source, | |
6445 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6446 | }, | |
87350ad0 TI |
6447 | [ALC885_MBP3] = { |
6448 | .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, | |
6449 | .init_verbs = { alc885_mbp3_init_verbs, | |
6450 | alc880_gpio1_init_verbs }, | |
6451 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6452 | .dac_nids = alc882_dac_nids, | |
6453 | .channel_mode = alc885_mbp_6ch_modes, | |
6454 | .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes), | |
6455 | .input_mux = &alc882_capture_source, | |
6456 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6457 | .dig_in_nid = ALC882_DIGIN_NID, | |
6458 | .unsol_event = alc885_mbp3_unsol_event, | |
6459 | .init_hook = alc885_mbp3_automute, | |
6460 | }, | |
9102cd1c TD |
6461 | [ALC885_MACPRO] = { |
6462 | .mixers = { alc882_macpro_mixer }, | |
6463 | .init_verbs = { alc882_macpro_init_verbs }, | |
6464 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6465 | .dac_nids = alc882_dac_nids, | |
6466 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6467 | .dig_in_nid = ALC882_DIGIN_NID, | |
6468 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6469 | .channel_mode = alc882_ch_modes, | |
6470 | .input_mux = &alc882_capture_source, | |
7debbe51 | 6471 | .init_hook = alc885_macpro_init_hook, |
9102cd1c | 6472 | }, |
c54728d8 NF |
6473 | [ALC885_IMAC24] = { |
6474 | .mixers = { alc885_imac24_mixer }, | |
6475 | .init_verbs = { alc885_imac24_init_verbs }, | |
6476 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6477 | .dac_nids = alc882_dac_nids, | |
6478 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6479 | .dig_in_nid = ALC882_DIGIN_NID, | |
6480 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | |
6481 | .channel_mode = alc882_ch_modes, | |
6482 | .input_mux = &alc882_capture_source, | |
6483 | .unsol_event = alc885_imac24_unsol_event, | |
7debbe51 | 6484 | .init_hook = alc885_imac24_init_hook, |
c54728d8 | 6485 | }, |
272a527c | 6486 | [ALC882_TARGA] = { |
f9e336f6 | 6487 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer }, |
272a527c KY |
6488 | .init_verbs = { alc882_init_verbs, alc882_targa_verbs}, |
6489 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6490 | .dac_nids = alc882_dac_nids, | |
6491 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6492 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
6493 | .adc_nids = alc882_adc_nids, | |
e1406348 | 6494 | .capsrc_nids = alc882_capsrc_nids, |
272a527c KY |
6495 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), |
6496 | .channel_mode = alc882_3ST_6ch_modes, | |
6497 | .need_dac_fix = 1, | |
6498 | .input_mux = &alc882_capture_source, | |
6499 | .unsol_event = alc882_targa_unsol_event, | |
6500 | .init_hook = alc882_targa_automute, | |
6501 | }, | |
6502 | [ALC882_ASUS_A7J] = { | |
f9e336f6 | 6503 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer }, |
272a527c KY |
6504 | .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs}, |
6505 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6506 | .dac_nids = alc882_dac_nids, | |
6507 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6508 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | |
6509 | .adc_nids = alc882_adc_nids, | |
e1406348 | 6510 | .capsrc_nids = alc882_capsrc_nids, |
272a527c KY |
6511 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), |
6512 | .channel_mode = alc882_3ST_6ch_modes, | |
6513 | .need_dac_fix = 1, | |
6514 | .input_mux = &alc882_capture_source, | |
ea1fb29a | 6515 | }, |
914759b7 TI |
6516 | [ALC882_ASUS_A7M] = { |
6517 | .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer }, | |
6518 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | |
6519 | alc880_gpio1_init_verbs, | |
6520 | alc882_asus_a7m_verbs }, | |
6521 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | |
6522 | .dac_nids = alc882_dac_nids, | |
6523 | .dig_out_nid = ALC882_DIGOUT_NID, | |
6524 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | |
6525 | .channel_mode = alc880_threestack_modes, | |
6526 | .need_dac_fix = 1, | |
6527 | .input_mux = &alc882_capture_source, | |
ea1fb29a | 6528 | }, |
df694daa KY |
6529 | }; |
6530 | ||
6531 | ||
f95474ec TI |
6532 | /* |
6533 | * Pin config fixes | |
6534 | */ | |
ea1fb29a | 6535 | enum { |
f95474ec TI |
6536 | PINFIX_ABIT_AW9D_MAX |
6537 | }; | |
6538 | ||
6539 | static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { | |
6540 | { 0x15, 0x01080104 }, /* side */ | |
6541 | { 0x16, 0x01011012 }, /* rear */ | |
6542 | { 0x17, 0x01016011 }, /* clfe */ | |
6543 | { } | |
6544 | }; | |
6545 | ||
6546 | static const struct alc_pincfg *alc882_pin_fixes[] = { | |
6547 | [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix, | |
6548 | }; | |
6549 | ||
6550 | static struct snd_pci_quirk alc882_pinfix_tbl[] = { | |
6551 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), | |
6552 | {} | |
6553 | }; | |
6554 | ||
df694daa KY |
6555 | /* |
6556 | * BIOS auto configuration | |
6557 | */ | |
6558 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, | |
6559 | hda_nid_t nid, int pin_type, | |
6560 | int dac_idx) | |
6561 | { | |
6562 | /* set as output */ | |
6563 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
6564 | int idx; |
6565 | ||
f6c7e546 | 6566 | alc_set_pin_output(codec, nid, pin_type); |
df694daa KY |
6567 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
6568 | idx = 4; | |
6569 | else | |
6570 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
df694daa KY |
6571 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
6572 | ||
6573 | } | |
6574 | ||
6575 | static void alc882_auto_init_multi_out(struct hda_codec *codec) | |
6576 | { | |
6577 | struct alc_spec *spec = codec->spec; | |
6578 | int i; | |
6579 | ||
bc9f98a9 | 6580 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
df694daa | 6581 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 6582 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 6583 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 6584 | if (nid) |
baba8ee9 | 6585 | alc882_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 6586 | i); |
df694daa KY |
6587 | } |
6588 | } | |
6589 | ||
6590 | static void alc882_auto_init_hp_out(struct hda_codec *codec) | |
6591 | { | |
6592 | struct alc_spec *spec = codec->spec; | |
6593 | hda_nid_t pin; | |
6594 | ||
eb06ed8f | 6595 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 6596 | if (pin) /* connect to front */ |
f12ab1e0 TI |
6597 | /* use dac 0 */ |
6598 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
6599 | pin = spec->autocfg.speaker_pins[0]; |
6600 | if (pin) | |
6601 | alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
df694daa KY |
6602 | } |
6603 | ||
6604 | #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) | |
6605 | #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID | |
6606 | ||
6607 | static void alc882_auto_init_analog_input(struct hda_codec *codec) | |
6608 | { | |
6609 | struct alc_spec *spec = codec->spec; | |
6610 | int i; | |
6611 | ||
6612 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
6613 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
7194cae6 TI |
6614 | unsigned int vref; |
6615 | if (!nid) | |
6616 | continue; | |
6617 | vref = PIN_IN; | |
6618 | if (1 /*i <= AUTO_PIN_FRONT_MIC*/) { | |
531240ff KY |
6619 | unsigned int pincap; |
6620 | pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | |
6621 | if ((pincap >> AC_PINCAP_VREF_SHIFT) & | |
7194cae6 TI |
6622 | AC_PINCAP_VREF_80) |
6623 | vref = PIN_VREF80; | |
df694daa | 6624 | } |
7194cae6 TI |
6625 | snd_hda_codec_write(codec, nid, 0, |
6626 | AC_VERB_SET_PIN_WIDGET_CONTROL, vref); | |
6627 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) | |
6628 | snd_hda_codec_write(codec, nid, 0, | |
6629 | AC_VERB_SET_AMP_GAIN_MUTE, | |
6630 | AMP_OUT_MUTE); | |
df694daa KY |
6631 | } |
6632 | } | |
6633 | ||
f511b01c TI |
6634 | static void alc882_auto_init_input_src(struct hda_codec *codec) |
6635 | { | |
6636 | struct alc_spec *spec = codec->spec; | |
6637 | const struct hda_input_mux *imux = spec->input_mux; | |
6638 | int c; | |
6639 | ||
6640 | for (c = 0; c < spec->num_adc_nids; c++) { | |
6641 | hda_nid_t conn_list[HDA_MAX_NUM_INPUTS]; | |
6642 | hda_nid_t nid = spec->capsrc_nids[c]; | |
6643 | int conns, mute, idx, item; | |
6644 | ||
6645 | conns = snd_hda_get_connections(codec, nid, conn_list, | |
6646 | ARRAY_SIZE(conn_list)); | |
6647 | if (conns < 0) | |
6648 | continue; | |
6649 | for (idx = 0; idx < conns; idx++) { | |
6650 | /* if the current connection is the selected one, | |
6651 | * unmute it as default - otherwise mute it | |
6652 | */ | |
6653 | mute = AMP_IN_MUTE(idx); | |
6654 | for (item = 0; item < imux->num_items; item++) { | |
6655 | if (imux->items[item].index == idx) { | |
6656 | if (spec->cur_mux[c] == item) | |
6657 | mute = AMP_IN_UNMUTE(idx); | |
6658 | break; | |
6659 | } | |
6660 | } | |
6661 | snd_hda_codec_write(codec, nid, 0, | |
6662 | AC_VERB_SET_AMP_GAIN_MUTE, mute); | |
6663 | } | |
6664 | } | |
6665 | } | |
6666 | ||
776e184e TI |
6667 | /* add mic boosts if needed */ |
6668 | static int alc_auto_add_mic_boost(struct hda_codec *codec) | |
6669 | { | |
6670 | struct alc_spec *spec = codec->spec; | |
6671 | int err; | |
6672 | hda_nid_t nid; | |
6673 | ||
6674 | nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | |
ce22e03e | 6675 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { |
776e184e TI |
6676 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
6677 | "Mic Boost", | |
6678 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
6679 | if (err < 0) | |
6680 | return err; | |
6681 | } | |
6682 | nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | |
ce22e03e | 6683 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { |
776e184e TI |
6684 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
6685 | "Front Mic Boost", | |
6686 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
6687 | if (err < 0) | |
6688 | return err; | |
6689 | } | |
6690 | return 0; | |
6691 | } | |
6692 | ||
df694daa KY |
6693 | /* almost identical with ALC880 parser... */ |
6694 | static int alc882_parse_auto_config(struct hda_codec *codec) | |
6695 | { | |
6696 | struct alc_spec *spec = codec->spec; | |
6697 | int err = alc880_parse_auto_config(codec); | |
6698 | ||
6699 | if (err < 0) | |
6700 | return err; | |
776e184e TI |
6701 | else if (!err) |
6702 | return 0; /* no config found */ | |
6703 | ||
6704 | err = alc_auto_add_mic_boost(codec); | |
6705 | if (err < 0) | |
6706 | return err; | |
6707 | ||
6708 | /* hack - override the init verbs */ | |
6709 | spec->init_verbs[0] = alc882_auto_init_verbs; | |
6710 | ||
6711 | return 1; /* config found */ | |
df694daa KY |
6712 | } |
6713 | ||
ae6b813a TI |
6714 | /* additional initialization for auto-configuration model */ |
6715 | static void alc882_auto_init(struct hda_codec *codec) | |
df694daa | 6716 | { |
f6c7e546 | 6717 | struct alc_spec *spec = codec->spec; |
df694daa KY |
6718 | alc882_auto_init_multi_out(codec); |
6719 | alc882_auto_init_hp_out(codec); | |
6720 | alc882_auto_init_analog_input(codec); | |
f511b01c | 6721 | alc882_auto_init_input_src(codec); |
f6c7e546 | 6722 | if (spec->unsol_event) |
7fb0d78f | 6723 | alc_inithook(codec); |
df694daa KY |
6724 | } |
6725 | ||
7943a8ab TI |
6726 | static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */ |
6727 | ||
df694daa KY |
6728 | static int patch_alc882(struct hda_codec *codec) |
6729 | { | |
6730 | struct alc_spec *spec; | |
6731 | int err, board_config; | |
6732 | ||
6733 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
6734 | if (spec == NULL) | |
6735 | return -ENOMEM; | |
6736 | ||
6737 | codec->spec = spec; | |
6738 | ||
f5fcc13c TI |
6739 | board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, |
6740 | alc882_models, | |
6741 | alc882_cfg_tbl); | |
df694daa KY |
6742 | |
6743 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { | |
081d17c4 TD |
6744 | /* Pick up systems that don't supply PCI SSID */ |
6745 | switch (codec->subsystem_id) { | |
6746 | case 0x106b0c00: /* Mac Pro */ | |
6747 | board_config = ALC885_MACPRO; | |
6748 | break; | |
c54728d8 | 6749 | case 0x106b1000: /* iMac 24 */ |
f3911c5a | 6750 | case 0x106b2800: /* AppleTV */ |
c54728d8 NF |
6751 | board_config = ALC885_IMAC24; |
6752 | break; | |
c7e0757a | 6753 | case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */ |
9c95c43d | 6754 | case 0x106b00a4: /* MacbookPro4,1 */ |
87350ad0 | 6755 | case 0x106b2c00: /* Macbook Pro rev3 */ |
c7e0757a | 6756 | case 0x106b3600: /* Macbook 3.1 */ |
87350ad0 TI |
6757 | board_config = ALC885_MBP3; |
6758 | break; | |
081d17c4 | 6759 | default: |
7943a8ab | 6760 | /* ALC889A is handled better as ALC888-compatible */ |
669faba2 CM |
6761 | if (codec->revision_id == 0x100101 || |
6762 | codec->revision_id == 0x100103) { | |
7943a8ab TI |
6763 | alc_free(codec); |
6764 | return patch_alc883(codec); | |
6765 | } | |
081d17c4 TD |
6766 | printk(KERN_INFO "hda_codec: Unknown model for ALC882, " |
6767 | "trying auto-probe from BIOS...\n"); | |
6768 | board_config = ALC882_AUTO; | |
6769 | } | |
df694daa KY |
6770 | } |
6771 | ||
f95474ec TI |
6772 | alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes); |
6773 | ||
df694daa KY |
6774 | if (board_config == ALC882_AUTO) { |
6775 | /* automatic parse from the BIOS config */ | |
6776 | err = alc882_parse_auto_config(codec); | |
6777 | if (err < 0) { | |
6778 | alc_free(codec); | |
6779 | return err; | |
f12ab1e0 | 6780 | } else if (!err) { |
9c7f852e TI |
6781 | printk(KERN_INFO |
6782 | "hda_codec: Cannot set up configuration " | |
6783 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
6784 | board_config = ALC882_3ST_DIG; |
6785 | } | |
6786 | } | |
6787 | ||
6788 | if (board_config != ALC882_AUTO) | |
6789 | setup_preset(spec, &alc882_presets[board_config]); | |
1da177e4 | 6790 | |
2f893286 KY |
6791 | if (codec->vendor_id == 0x10ec0885) { |
6792 | spec->stream_name_analog = "ALC885 Analog"; | |
6793 | spec->stream_name_digital = "ALC885 Digital"; | |
6794 | } else { | |
6795 | spec->stream_name_analog = "ALC882 Analog"; | |
6796 | spec->stream_name_digital = "ALC882 Digital"; | |
6797 | } | |
6798 | ||
df694daa KY |
6799 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
6800 | spec->stream_analog_capture = &alc882_pcm_analog_capture; | |
6330079f TI |
6801 | /* FIXME: setup DAC5 */ |
6802 | /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/ | |
6803 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; | |
1da177e4 | 6804 | |
df694daa KY |
6805 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
6806 | spec->stream_digital_capture = &alc882_pcm_digital_capture; | |
1da177e4 | 6807 | |
54cbc9ab | 6808 | spec->is_mix_capture = 1; /* matrix-style capture */ |
f12ab1e0 | 6809 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 6810 | /* check whether NID 0x07 is valid */ |
4a471b7d | 6811 | unsigned int wcap = get_wcaps(codec, 0x07); |
f12ab1e0 TI |
6812 | /* get type */ |
6813 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
6814 | if (wcap != AC_WID_AUD_IN) { |
6815 | spec->adc_nids = alc882_adc_nids_alt; | |
6816 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); | |
e1406348 | 6817 | spec->capsrc_nids = alc882_capsrc_nids_alt; |
df694daa KY |
6818 | } else { |
6819 | spec->adc_nids = alc882_adc_nids; | |
6820 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); | |
e1406348 | 6821 | spec->capsrc_nids = alc882_capsrc_nids; |
df694daa KY |
6822 | } |
6823 | } | |
f9e336f6 | 6824 | set_capture_mixer(spec); |
1da177e4 | 6825 | |
2134ea4f TI |
6826 | spec->vmaster_nid = 0x0c; |
6827 | ||
1da177e4 | 6828 | codec->patch_ops = alc_patch_ops; |
df694daa | 6829 | if (board_config == ALC882_AUTO) |
ae6b813a | 6830 | spec->init_hook = alc882_auto_init; |
cb53c626 TI |
6831 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
6832 | if (!spec->loopback.amplist) | |
6833 | spec->loopback.amplist = alc882_loopbacks; | |
6834 | #endif | |
df694daa KY |
6835 | |
6836 | return 0; | |
6837 | } | |
6838 | ||
6839 | /* | |
9c7f852e TI |
6840 | * ALC883 support |
6841 | * | |
6842 | * ALC883 is almost identical with ALC880 but has cleaner and more flexible | |
6843 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
6844 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
6845 | * 6-channel independent captures. | |
6846 | * | |
6847 | * In addition, an independent DAC for the multi-playback (not used in this | |
6848 | * driver yet). | |
df694daa | 6849 | */ |
9c7f852e TI |
6850 | #define ALC883_DIGOUT_NID 0x06 |
6851 | #define ALC883_DIGIN_NID 0x0a | |
df694daa | 6852 | |
9c7f852e TI |
6853 | static hda_nid_t alc883_dac_nids[4] = { |
6854 | /* front, rear, clfe, rear_surr */ | |
f32a19e3 | 6855 | 0x02, 0x03, 0x04, 0x05 |
9c7f852e | 6856 | }; |
df694daa | 6857 | |
9c7f852e TI |
6858 | static hda_nid_t alc883_adc_nids[2] = { |
6859 | /* ADC1-2 */ | |
6860 | 0x08, 0x09, | |
6861 | }; | |
f12ab1e0 | 6862 | |
f9e336f6 TI |
6863 | static hda_nid_t alc883_adc_nids_alt[1] = { |
6864 | /* ADC1 */ | |
6865 | 0x08, | |
6866 | }; | |
6867 | ||
e1406348 TI |
6868 | static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 }; |
6869 | ||
9c7f852e TI |
6870 | /* input MUX */ |
6871 | /* FIXME: should be a matrix-type input source selection */ | |
df694daa | 6872 | |
9c7f852e TI |
6873 | static struct hda_input_mux alc883_capture_source = { |
6874 | .num_items = 4, | |
6875 | .items = { | |
6876 | { "Mic", 0x0 }, | |
6877 | { "Front Mic", 0x1 }, | |
6878 | { "Line", 0x2 }, | |
6879 | { "CD", 0x4 }, | |
6880 | }, | |
6881 | }; | |
bc9f98a9 | 6882 | |
17bba1b7 J |
6883 | static struct hda_input_mux alc883_3stack_6ch_intel = { |
6884 | .num_items = 4, | |
6885 | .items = { | |
6886 | { "Mic", 0x1 }, | |
6887 | { "Front Mic", 0x0 }, | |
6888 | { "Line", 0x2 }, | |
6889 | { "CD", 0x4 }, | |
6890 | }, | |
6891 | }; | |
6892 | ||
bc9f98a9 KY |
6893 | static struct hda_input_mux alc883_lenovo_101e_capture_source = { |
6894 | .num_items = 2, | |
6895 | .items = { | |
6896 | { "Mic", 0x1 }, | |
6897 | { "Line", 0x2 }, | |
6898 | }, | |
6899 | }; | |
6900 | ||
272a527c KY |
6901 | static struct hda_input_mux alc883_lenovo_nb0763_capture_source = { |
6902 | .num_items = 4, | |
6903 | .items = { | |
6904 | { "Mic", 0x0 }, | |
6905 | { "iMic", 0x1 }, | |
6906 | { "Line", 0x2 }, | |
6907 | { "CD", 0x4 }, | |
6908 | }, | |
6909 | }; | |
6910 | ||
fb97dc67 J |
6911 | static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = { |
6912 | .num_items = 2, | |
6913 | .items = { | |
6914 | { "Mic", 0x0 }, | |
6915 | { "Int Mic", 0x1 }, | |
6916 | }, | |
6917 | }; | |
6918 | ||
e2757d5e KY |
6919 | static struct hda_input_mux alc883_lenovo_sky_capture_source = { |
6920 | .num_items = 3, | |
6921 | .items = { | |
6922 | { "Mic", 0x0 }, | |
6923 | { "Front Mic", 0x1 }, | |
6924 | { "Line", 0x4 }, | |
6925 | }, | |
6926 | }; | |
6927 | ||
6928 | static struct hda_input_mux alc883_asus_eee1601_capture_source = { | |
6929 | .num_items = 2, | |
6930 | .items = { | |
6931 | { "Mic", 0x0 }, | |
6932 | { "Line", 0x2 }, | |
6933 | }, | |
6934 | }; | |
6935 | ||
9c7f852e TI |
6936 | /* |
6937 | * 2ch mode | |
6938 | */ | |
6939 | static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { | |
6940 | { 2, NULL } | |
6941 | }; | |
6942 | ||
6943 | /* | |
6944 | * 2ch mode | |
6945 | */ | |
6946 | static struct hda_verb alc883_3ST_ch2_init[] = { | |
6947 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
6948 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6949 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
6950 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6951 | { } /* end */ | |
6952 | }; | |
6953 | ||
b201131c TD |
6954 | /* |
6955 | * 4ch mode | |
6956 | */ | |
6957 | static struct hda_verb alc883_3ST_ch4_init[] = { | |
6958 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
6959 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6960 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6961 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6962 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6963 | { } /* end */ | |
6964 | }; | |
6965 | ||
9c7f852e TI |
6966 | /* |
6967 | * 6ch mode | |
6968 | */ | |
6969 | static struct hda_verb alc883_3ST_ch6_init[] = { | |
6970 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6971 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6972 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
6973 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
6974 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
6975 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
6976 | { } /* end */ | |
6977 | }; | |
6978 | ||
b201131c | 6979 | static struct hda_channel_mode alc883_3ST_6ch_modes[3] = { |
9c7f852e | 6980 | { 2, alc883_3ST_ch2_init }, |
b201131c | 6981 | { 4, alc883_3ST_ch4_init }, |
9c7f852e TI |
6982 | { 6, alc883_3ST_ch6_init }, |
6983 | }; | |
6984 | ||
17bba1b7 J |
6985 | /* |
6986 | * 2ch mode | |
6987 | */ | |
6988 | static struct hda_verb alc883_3ST_ch2_intel_init[] = { | |
6989 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
6990 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6991 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
6992 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
6993 | { } /* end */ | |
6994 | }; | |
6995 | ||
6996 | /* | |
6997 | * 4ch mode | |
6998 | */ | |
6999 | static struct hda_verb alc883_3ST_ch4_intel_init[] = { | |
7000 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
7001 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7002 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7003 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7004 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
7005 | { } /* end */ | |
7006 | }; | |
7007 | ||
7008 | /* | |
7009 | * 6ch mode | |
7010 | */ | |
7011 | static struct hda_verb alc883_3ST_ch6_intel_init[] = { | |
7012 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7013 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7014 | { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
7015 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7016 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7017 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
7018 | { } /* end */ | |
7019 | }; | |
7020 | ||
7021 | static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = { | |
7022 | { 2, alc883_3ST_ch2_intel_init }, | |
7023 | { 4, alc883_3ST_ch4_intel_init }, | |
7024 | { 6, alc883_3ST_ch6_intel_init }, | |
7025 | }; | |
7026 | ||
9c7f852e TI |
7027 | /* |
7028 | * 6ch mode | |
7029 | */ | |
7030 | static struct hda_verb alc883_sixstack_ch6_init[] = { | |
7031 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
7032 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7033 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7034 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7035 | { } /* end */ | |
7036 | }; | |
7037 | ||
7038 | /* | |
7039 | * 8ch mode | |
7040 | */ | |
7041 | static struct hda_verb alc883_sixstack_ch8_init[] = { | |
7042 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7043 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7044 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7045 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7046 | { } /* end */ | |
7047 | }; | |
7048 | ||
7049 | static struct hda_channel_mode alc883_sixstack_modes[2] = { | |
7050 | { 6, alc883_sixstack_ch6_init }, | |
7051 | { 8, alc883_sixstack_ch8_init }, | |
7052 | }; | |
7053 | ||
b373bdeb AN |
7054 | static struct hda_verb alc883_medion_eapd_verbs[] = { |
7055 | /* eanable EAPD on medion laptop */ | |
7056 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
7057 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
7058 | { } | |
7059 | }; | |
7060 | ||
9c7f852e TI |
7061 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
7062 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
7063 | */ | |
7064 | ||
7065 | static struct snd_kcontrol_new alc883_base_mixer[] = { | |
df694daa | 7066 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9c7f852e TI |
7067 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
7068 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7069 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7070 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7071 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7072 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7073 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7074 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
7075 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
7076 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
df694daa KY |
7077 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
7078 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7079 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7080 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7081 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7082 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
df694daa | 7083 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
9c7f852e | 7084 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
32360416 | 7085 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
7086 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
7087 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7088 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
df694daa | 7089 | { } /* end */ |
834be88d TI |
7090 | }; |
7091 | ||
a8848bd6 AS |
7092 | static struct snd_kcontrol_new alc883_mitac_mixer[] = { |
7093 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7094 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7095 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7096 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7097 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7098 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7099 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7100 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7101 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7102 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7103 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7104 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
7105 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
a8848bd6 AS |
7106 | { } /* end */ |
7107 | }; | |
7108 | ||
0c4cc443 | 7109 | static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = { |
368c7a95 J |
7110 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
7111 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
7112 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7113 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
7114 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7115 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7116 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7117 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7118 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
7119 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
368c7a95 J |
7120 | { } /* end */ |
7121 | }; | |
7122 | ||
fb97dc67 J |
7123 | static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = { |
7124 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7125 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), | |
7126 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7127 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
7128 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7129 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7130 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7131 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7132 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
7133 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
fb97dc67 J |
7134 | { } /* end */ |
7135 | }; | |
7136 | ||
9c7f852e TI |
7137 | static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = { |
7138 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7139 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7140 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7141 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7142 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7143 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7144 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7145 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7146 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
7147 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7148 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 7149 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
7150 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
7151 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7152 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
9c7f852e TI |
7153 | { } /* end */ |
7154 | }; | |
df694daa | 7155 | |
9c7f852e TI |
7156 | static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = { |
7157 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7158 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7159 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7160 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7161 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7162 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7163 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7164 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7165 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7166 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7167 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7168 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7169 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7170 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7171 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
7172 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7173 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 7174 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
7175 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
7176 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7177 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
9c7f852e TI |
7178 | { } /* end */ |
7179 | }; | |
7180 | ||
17bba1b7 J |
7181 | static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = { |
7182 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7183 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7184 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7185 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7186 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, | |
7187 | HDA_OUTPUT), | |
7188 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7189 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7190 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7191 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7192 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7193 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7194 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7195 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7196 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7197 | HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), | |
7198 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
7199 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7200 | HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT), | |
7201 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7202 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7203 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
17bba1b7 J |
7204 | { } /* end */ |
7205 | }; | |
7206 | ||
d1d985f0 | 7207 | static struct snd_kcontrol_new alc883_fivestack_mixer[] = { |
c07584c8 | 7208 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
0701e064 | 7209 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
c07584c8 | 7210 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
0701e064 | 7211 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), |
c07584c8 TD |
7212 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), |
7213 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
0701e064 TI |
7214 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), |
7215 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
c07584c8 TD |
7216 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
7217 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7218 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7219 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7220 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7221 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7222 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
c07584c8 TD |
7223 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
7224 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
32360416 | 7225 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
c07584c8 TD |
7226 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), |
7227 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
7228 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
c07584c8 TD |
7229 | { } /* end */ |
7230 | }; | |
7231 | ||
ccc656ce KY |
7232 | static struct snd_kcontrol_new alc883_tagra_mixer[] = { |
7233 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7234 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7235 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7236 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
7237 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
7238 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
7239 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
7240 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
7241 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
7242 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7243 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7244 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7245 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7246 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7247 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce | 7248 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
ccc656ce | 7249 | { } /* end */ |
f12ab1e0 | 7250 | }; |
ccc656ce KY |
7251 | |
7252 | static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { | |
7253 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7254 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7255 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7256 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7257 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7258 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
32360416 | 7259 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce | 7260 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), |
4383fae0 J |
7261 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), |
7262 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
7263 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
ccc656ce | 7264 | { } /* end */ |
f12ab1e0 | 7265 | }; |
ccc656ce | 7266 | |
bc9f98a9 KY |
7267 | static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = { |
7268 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7269 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
86cd9298 TI |
7270 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
7271 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT), | |
bc9f98a9 KY |
7272 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
7273 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7274 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7275 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
bc9f98a9 | 7276 | { } /* end */ |
f12ab1e0 | 7277 | }; |
bc9f98a9 | 7278 | |
272a527c KY |
7279 | static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = { |
7280 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7281 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), | |
7282 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7283 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7284 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7285 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7286 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7287 | HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7288 | HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
272a527c KY |
7289 | { } /* end */ |
7290 | }; | |
7291 | ||
7292 | static struct snd_kcontrol_new alc883_medion_md2_mixer[] = { | |
7293 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7294 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7295 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
7296 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7297 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7298 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7299 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7300 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7301 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
272a527c | 7302 | { } /* end */ |
ea1fb29a | 7303 | }; |
272a527c | 7304 | |
2880a867 | 7305 | static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = { |
d1a991a6 KY |
7306 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
7307 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
2880a867 | 7308 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
2880a867 TD |
7309 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
7310 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
d1a991a6 KY |
7311 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
7312 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7313 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2880a867 | 7314 | { } /* end */ |
d1a991a6 | 7315 | }; |
2880a867 | 7316 | |
e2757d5e KY |
7317 | static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = { |
7318 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7319 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7320 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT), | |
7321 | HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT), | |
7322 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", | |
7323 | 0x0d, 1, 0x0, HDA_OUTPUT), | |
7324 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT), | |
7325 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT), | |
7326 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT), | |
7327 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | |
7328 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
7329 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
7330 | HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT), | |
7331 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
7332 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
7333 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7334 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7335 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7336 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7337 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
7338 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
7339 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
7340 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
e2757d5e KY |
7341 | { } /* end */ |
7342 | }; | |
7343 | ||
7344 | static struct hda_bind_ctls alc883_bind_cap_vol = { | |
7345 | .ops = &snd_hda_bind_vol, | |
7346 | .values = { | |
7347 | HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT), | |
7348 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), | |
7349 | 0 | |
7350 | }, | |
7351 | }; | |
7352 | ||
7353 | static struct hda_bind_ctls alc883_bind_cap_switch = { | |
7354 | .ops = &snd_hda_bind_sw, | |
7355 | .values = { | |
7356 | HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT), | |
7357 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), | |
7358 | 0 | |
7359 | }, | |
7360 | }; | |
7361 | ||
7362 | static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = { | |
7363 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
7364 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
7365 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
7366 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
7367 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
7368 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
7369 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
7370 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
f9e336f6 TI |
7371 | { } /* end */ |
7372 | }; | |
7373 | ||
7374 | static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = { | |
e2757d5e KY |
7375 | HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol), |
7376 | HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch), | |
7377 | { | |
7378 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7379 | /* .name = "Capture Source", */ | |
7380 | .name = "Input Source", | |
7381 | .count = 1, | |
54cbc9ab TI |
7382 | .info = alc_mux_enum_info, |
7383 | .get = alc_mux_enum_get, | |
7384 | .put = alc_mux_enum_put, | |
e2757d5e KY |
7385 | }, |
7386 | { } /* end */ | |
7387 | }; | |
7388 | ||
9c7f852e TI |
7389 | static struct snd_kcontrol_new alc883_chmode_mixer[] = { |
7390 | { | |
7391 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
7392 | .name = "Channel Mode", | |
7393 | .info = alc_ch_mode_info, | |
7394 | .get = alc_ch_mode_get, | |
7395 | .put = alc_ch_mode_put, | |
7396 | }, | |
7397 | { } /* end */ | |
7398 | }; | |
7399 | ||
7400 | static struct hda_verb alc883_init_verbs[] = { | |
7401 | /* ADC1: mute amp left and right */ | |
e2757d5e | 7402 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
df694daa | 7403 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
7404 | /* ADC2: mute amp left and right */ |
7405 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
df694daa | 7406 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9c7f852e TI |
7407 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
7408 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7409 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7410 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7411 | /* Rear mixer */ | |
7412 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7413 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7414 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7415 | /* CLFE mixer */ | |
7416 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7417 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7418 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7419 | /* Side mixer */ | |
7420 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
7421 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7422 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
df694daa | 7423 | |
cb53c626 TI |
7424 | /* mute analog input loopbacks */ |
7425 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
7426 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7427 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7428 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
7429 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa | 7430 | |
9c7f852e TI |
7431 | /* Front Pin: output 0 (0x0c) */ |
7432 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7433 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7434 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7435 | /* Rear Pin: output 1 (0x0d) */ | |
7436 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7437 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7438 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7439 | /* CLFE Pin: output 2 (0x0e) */ | |
7440 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7441 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7442 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
7443 | /* Side Pin: output 3 (0x0f) */ | |
7444 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7445 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7446 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
7447 | /* Mic (rear) pin: input vref at 80% */ | |
7448 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
7449 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7450 | /* Front Mic pin: input vref at 80% */ | |
7451 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
7452 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7453 | /* Line In pin: input */ | |
7454 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
7455 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
7456 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
7457 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7458 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7459 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7460 | /* CD pin widget for input */ | |
7461 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
7462 | ||
7463 | /* FIXME: use matrix-type input source selection */ | |
7464 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
7465 | /* Input mixer2 */ | |
7466 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
e2757d5e KY |
7467 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
7468 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7469 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
7470 | /* Input mixer3 */ |
7471 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
e2757d5e KY |
7472 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
7473 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7474 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
7475 | { } |
7476 | }; | |
7477 | ||
a8848bd6 AS |
7478 | /* toggle speaker-output according to the hp-jack state */ |
7479 | static void alc883_mitac_hp_automute(struct hda_codec *codec) | |
7480 | { | |
7481 | unsigned int present; | |
7482 | ||
7483 | present = snd_hda_codec_read(codec, 0x15, 0, | |
7484 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7485 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7486 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7487 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
7488 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7489 | } | |
7490 | ||
7491 | /* auto-toggle front mic */ | |
7492 | /* | |
7493 | static void alc883_mitac_mic_automute(struct hda_codec *codec) | |
7494 | { | |
7495 | unsigned int present; | |
7496 | unsigned char bits; | |
7497 | ||
7498 | present = snd_hda_codec_read(codec, 0x18, 0, | |
7499 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7500 | bits = present ? HDA_AMP_MUTE : 0; | |
7501 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | |
7502 | } | |
7503 | */ | |
7504 | ||
7505 | static void alc883_mitac_automute(struct hda_codec *codec) | |
7506 | { | |
7507 | alc883_mitac_hp_automute(codec); | |
7508 | /* alc883_mitac_mic_automute(codec); */ | |
7509 | } | |
7510 | ||
7511 | static void alc883_mitac_unsol_event(struct hda_codec *codec, | |
7512 | unsigned int res) | |
7513 | { | |
7514 | switch (res >> 26) { | |
7515 | case ALC880_HP_EVENT: | |
7516 | alc883_mitac_hp_automute(codec); | |
7517 | break; | |
7518 | case ALC880_MIC_EVENT: | |
7519 | /* alc883_mitac_mic_automute(codec); */ | |
7520 | break; | |
7521 | } | |
7522 | } | |
7523 | ||
7524 | static struct hda_verb alc883_mitac_verbs[] = { | |
7525 | /* HP */ | |
7526 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7527 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7528 | /* Subwoofer */ | |
7529 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
7530 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7531 | ||
7532 | /* enable unsolicited event */ | |
7533 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7534 | /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */ | |
7535 | ||
7536 | { } /* end */ | |
7537 | }; | |
7538 | ||
0c4cc443 | 7539 | static struct hda_verb alc883_clevo_m720_verbs[] = { |
368c7a95 J |
7540 | /* HP */ |
7541 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7542 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7543 | /* Int speaker */ | |
7544 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7545 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7546 | ||
7547 | /* enable unsolicited event */ | |
7548 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
0c4cc443 | 7549 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, |
368c7a95 J |
7550 | |
7551 | { } /* end */ | |
7552 | }; | |
7553 | ||
fb97dc67 J |
7554 | static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = { |
7555 | /* HP */ | |
7556 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7557 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7558 | /* Subwoofer */ | |
7559 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
7560 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7561 | ||
7562 | /* enable unsolicited event */ | |
7563 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7564 | ||
7565 | { } /* end */ | |
7566 | }; | |
7567 | ||
ccc656ce KY |
7568 | static struct hda_verb alc883_tagra_verbs[] = { |
7569 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7570 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7571 | ||
7572 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7573 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
ea1fb29a | 7574 | |
ccc656ce KY |
7575 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ |
7576 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */ | |
7577 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | |
7578 | ||
7579 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
f12ab1e0 TI |
7580 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
7581 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | |
7582 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | |
ccc656ce KY |
7583 | |
7584 | { } /* end */ | |
7585 | }; | |
7586 | ||
bc9f98a9 KY |
7587 | static struct hda_verb alc883_lenovo_101e_verbs[] = { |
7588 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7589 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN}, | |
7590 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN}, | |
7591 | { } /* end */ | |
7592 | }; | |
7593 | ||
272a527c KY |
7594 | static struct hda_verb alc883_lenovo_nb0763_verbs[] = { |
7595 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7596 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7597 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7598 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7599 | { } /* end */ | |
7600 | }; | |
7601 | ||
7602 | static struct hda_verb alc888_lenovo_ms7195_verbs[] = { | |
7603 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7604 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7605 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7606 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN}, | |
7607 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7608 | { } /* end */ | |
7609 | }; | |
7610 | ||
189609ae KY |
7611 | static struct hda_verb alc883_haier_w66_verbs[] = { |
7612 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7613 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7614 | ||
7615 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7616 | ||
7617 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7618 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7619 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7620 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7621 | { } /* end */ | |
7622 | }; | |
7623 | ||
e2757d5e KY |
7624 | static struct hda_verb alc888_lenovo_sky_verbs[] = { |
7625 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7626 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7627 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7628 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7629 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7630 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
7631 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7632 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7633 | { } /* end */ | |
7634 | }; | |
7635 | ||
4723c022 | 7636 | static struct hda_verb alc888_3st_hp_verbs[] = { |
8341de60 | 7637 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ |
f32a19e3 HRK |
7638 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */ |
7639 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */ | |
8341de60 CM |
7640 | { } |
7641 | }; | |
7642 | ||
5795b9e6 | 7643 | static struct hda_verb alc888_6st_dell_verbs[] = { |
5795b9e6 CM |
7644 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
7645 | { } | |
7646 | }; | |
7647 | ||
4723c022 | 7648 | static struct hda_verb alc888_3st_hp_2ch_init[] = { |
8341de60 CM |
7649 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, |
7650 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7651 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
7652 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
7653 | { } | |
7654 | }; | |
7655 | ||
4723c022 | 7656 | static struct hda_verb alc888_3st_hp_6ch_init[] = { |
8341de60 CM |
7657 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
7658 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7659 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
7660 | { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
7661 | { } | |
7662 | }; | |
7663 | ||
4723c022 CM |
7664 | static struct hda_channel_mode alc888_3st_hp_modes[2] = { |
7665 | { 2, alc888_3st_hp_2ch_init }, | |
7666 | { 6, alc888_3st_hp_6ch_init }, | |
8341de60 CM |
7667 | }; |
7668 | ||
272a527c KY |
7669 | /* toggle front-jack and RCA according to the hp-jack state */ |
7670 | static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec) | |
7671 | { | |
7672 | unsigned int present; | |
ea1fb29a | 7673 | |
272a527c KY |
7674 | present = snd_hda_codec_read(codec, 0x1b, 0, |
7675 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7676 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
7677 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7678 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7679 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
7680 | } |
7681 | ||
7682 | /* toggle RCA according to the front-jack state */ | |
7683 | static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec) | |
7684 | { | |
7685 | unsigned int present; | |
ea1fb29a | 7686 | |
272a527c KY |
7687 | present = snd_hda_codec_read(codec, 0x14, 0, |
7688 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7689 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
7690 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c | 7691 | } |
47fd830a | 7692 | |
272a527c KY |
7693 | static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec, |
7694 | unsigned int res) | |
7695 | { | |
7696 | if ((res >> 26) == ALC880_HP_EVENT) | |
7697 | alc888_lenovo_ms7195_front_automute(codec); | |
7698 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
7699 | alc888_lenovo_ms7195_rca_automute(codec); | |
7700 | } | |
7701 | ||
7702 | static struct hda_verb alc883_medion_md2_verbs[] = { | |
7703 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7704 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
7705 | ||
7706 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7707 | ||
7708 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
7709 | { } /* end */ | |
7710 | }; | |
7711 | ||
7712 | /* toggle speaker-output according to the hp-jack state */ | |
7713 | static void alc883_medion_md2_automute(struct hda_codec *codec) | |
7714 | { | |
7715 | unsigned int present; | |
ea1fb29a | 7716 | |
272a527c KY |
7717 | present = snd_hda_codec_read(codec, 0x14, 0, |
7718 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7719 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
7720 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
7721 | } |
7722 | ||
7723 | static void alc883_medion_md2_unsol_event(struct hda_codec *codec, | |
7724 | unsigned int res) | |
7725 | { | |
7726 | if ((res >> 26) == ALC880_HP_EVENT) | |
7727 | alc883_medion_md2_automute(codec); | |
7728 | } | |
7729 | ||
ccc656ce KY |
7730 | /* toggle speaker-output according to the hp-jack state */ |
7731 | static void alc883_tagra_automute(struct hda_codec *codec) | |
7732 | { | |
7733 | unsigned int present; | |
f12ab1e0 | 7734 | unsigned char bits; |
ccc656ce KY |
7735 | |
7736 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7737 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7738 | bits = present ? HDA_AMP_MUTE : 0; |
7739 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
7740 | HDA_AMP_MUTE, bits); | |
82beb8fd TI |
7741 | snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA, |
7742 | present ? 1 : 3); | |
ccc656ce KY |
7743 | } |
7744 | ||
7745 | static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) | |
7746 | { | |
7747 | if ((res >> 26) == ALC880_HP_EVENT) | |
7748 | alc883_tagra_automute(codec); | |
7749 | } | |
7750 | ||
368c7a95 | 7751 | /* toggle speaker-output according to the hp-jack state */ |
0c4cc443 | 7752 | static void alc883_clevo_m720_hp_automute(struct hda_codec *codec) |
368c7a95 J |
7753 | { |
7754 | unsigned int present; | |
7755 | unsigned char bits; | |
7756 | ||
7757 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) | |
7758 | & AC_PINSENSE_PRESENCE; | |
7759 | bits = present ? HDA_AMP_MUTE : 0; | |
7760 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7761 | HDA_AMP_MUTE, bits); | |
7762 | } | |
7763 | ||
0c4cc443 HRK |
7764 | static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) |
7765 | { | |
7766 | unsigned int present; | |
7767 | ||
7768 | present = snd_hda_codec_read(codec, 0x18, 0, | |
7769 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7770 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | |
7771 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7772 | } | |
7773 | ||
7774 | static void alc883_clevo_m720_automute(struct hda_codec *codec) | |
7775 | { | |
7776 | alc883_clevo_m720_hp_automute(codec); | |
7777 | alc883_clevo_m720_mic_automute(codec); | |
7778 | } | |
7779 | ||
7780 | static void alc883_clevo_m720_unsol_event(struct hda_codec *codec, | |
368c7a95 J |
7781 | unsigned int res) |
7782 | { | |
0c4cc443 HRK |
7783 | switch (res >> 26) { |
7784 | case ALC880_HP_EVENT: | |
7785 | alc883_clevo_m720_hp_automute(codec); | |
7786 | break; | |
7787 | case ALC880_MIC_EVENT: | |
7788 | alc883_clevo_m720_mic_automute(codec); | |
7789 | break; | |
7790 | } | |
368c7a95 J |
7791 | } |
7792 | ||
fb97dc67 J |
7793 | /* toggle speaker-output according to the hp-jack state */ |
7794 | static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec) | |
7795 | { | |
7796 | unsigned int present; | |
7797 | unsigned char bits; | |
7798 | ||
7799 | present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) | |
7800 | & AC_PINSENSE_PRESENCE; | |
7801 | bits = present ? HDA_AMP_MUTE : 0; | |
7802 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7803 | HDA_AMP_MUTE, bits); | |
7804 | } | |
7805 | ||
7806 | static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec, | |
7807 | unsigned int res) | |
7808 | { | |
7809 | if ((res >> 26) == ALC880_HP_EVENT) | |
7810 | alc883_2ch_fujitsu_pi2515_automute(codec); | |
7811 | } | |
7812 | ||
189609ae KY |
7813 | static void alc883_haier_w66_automute(struct hda_codec *codec) |
7814 | { | |
7815 | unsigned int present; | |
7816 | unsigned char bits; | |
7817 | ||
7818 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
7819 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7820 | bits = present ? 0x80 : 0; | |
7821 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7822 | 0x80, bits); | |
7823 | } | |
7824 | ||
7825 | static void alc883_haier_w66_unsol_event(struct hda_codec *codec, | |
7826 | unsigned int res) | |
7827 | { | |
7828 | if ((res >> 26) == ALC880_HP_EVENT) | |
7829 | alc883_haier_w66_automute(codec); | |
7830 | } | |
7831 | ||
bc9f98a9 KY |
7832 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
7833 | { | |
7834 | unsigned int present; | |
f12ab1e0 | 7835 | unsigned char bits; |
bc9f98a9 KY |
7836 | |
7837 | present = snd_hda_codec_read(codec, 0x14, 0, | |
7838 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7839 | bits = present ? HDA_AMP_MUTE : 0; |
7840 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7841 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
7842 | } |
7843 | ||
7844 | static void alc883_lenovo_101e_all_automute(struct hda_codec *codec) | |
7845 | { | |
7846 | unsigned int present; | |
f12ab1e0 | 7847 | unsigned char bits; |
bc9f98a9 KY |
7848 | |
7849 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
7850 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
7851 | bits = present ? HDA_AMP_MUTE : 0; |
7852 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7853 | HDA_AMP_MUTE, bits); | |
7854 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7855 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
7856 | } |
7857 | ||
7858 | static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, | |
7859 | unsigned int res) | |
7860 | { | |
7861 | if ((res >> 26) == ALC880_HP_EVENT) | |
7862 | alc883_lenovo_101e_all_automute(codec); | |
7863 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
7864 | alc883_lenovo_101e_ispeaker_automute(codec); | |
7865 | } | |
7866 | ||
676a9b53 TI |
7867 | /* toggle speaker-output according to the hp-jack state */ |
7868 | static void alc883_acer_aspire_automute(struct hda_codec *codec) | |
7869 | { | |
7870 | unsigned int present; | |
ea1fb29a | 7871 | |
676a9b53 TI |
7872 | present = snd_hda_codec_read(codec, 0x14, 0, |
7873 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7874 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7875 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7876 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
7877 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7878 | } | |
7879 | ||
7880 | static void alc883_acer_aspire_unsol_event(struct hda_codec *codec, | |
7881 | unsigned int res) | |
7882 | { | |
7883 | if ((res >> 26) == ALC880_HP_EVENT) | |
7884 | alc883_acer_aspire_automute(codec); | |
7885 | } | |
7886 | ||
d1a991a6 KY |
7887 | static struct hda_verb alc883_acer_eapd_verbs[] = { |
7888 | /* HP Pin: output 0 (0x0c) */ | |
7889 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7890 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
7891 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7892 | /* Front Pin: output 0 (0x0c) */ | |
676a9b53 TI |
7893 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
7894 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
d1a991a6 | 7895 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
d1a991a6 KY |
7896 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, |
7897 | /* eanable EAPD on medion laptop */ | |
7898 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
7899 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
676a9b53 TI |
7900 | /* enable unsolicited event */ |
7901 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
d1a991a6 KY |
7902 | { } |
7903 | }; | |
7904 | ||
5795b9e6 CM |
7905 | static void alc888_6st_dell_front_automute(struct hda_codec *codec) |
7906 | { | |
7907 | unsigned int present; | |
ea1fb29a | 7908 | |
5795b9e6 CM |
7909 | present = snd_hda_codec_read(codec, 0x1b, 0, |
7910 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
7911 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7912 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7913 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7914 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7915 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
7916 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7917 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
7918 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
7919 | } | |
7920 | ||
7921 | static void alc888_6st_dell_unsol_event(struct hda_codec *codec, | |
7922 | unsigned int res) | |
7923 | { | |
7924 | switch (res >> 26) { | |
7925 | case ALC880_HP_EVENT: | |
7926 | printk("hp_event\n"); | |
7927 | alc888_6st_dell_front_automute(codec); | |
7928 | break; | |
7929 | } | |
7930 | } | |
7931 | ||
e2757d5e KY |
7932 | static void alc888_lenovo_sky_front_automute(struct hda_codec *codec) |
7933 | { | |
7934 | unsigned int mute; | |
7935 | unsigned int present; | |
7936 | ||
7937 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
7938 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
7939 | AC_VERB_GET_PIN_SENSE, 0); | |
7940 | present = (present & 0x80000000) != 0; | |
7941 | if (present) { | |
7942 | /* mute internal speaker */ | |
7943 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7944 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
7945 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7946 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
7947 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
7948 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
7949 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
7950 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
7951 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
7952 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
7953 | } else { | |
7954 | /* unmute internal speaker if necessary */ | |
7955 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
7956 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
7957 | HDA_AMP_MUTE, mute); | |
7958 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
7959 | HDA_AMP_MUTE, mute); | |
7960 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
7961 | HDA_AMP_MUTE, mute); | |
7962 | snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0, | |
7963 | HDA_AMP_MUTE, mute); | |
7964 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | |
7965 | HDA_AMP_MUTE, mute); | |
7966 | } | |
7967 | } | |
7968 | ||
7969 | static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec, | |
7970 | unsigned int res) | |
7971 | { | |
7972 | if ((res >> 26) == ALC880_HP_EVENT) | |
7973 | alc888_lenovo_sky_front_automute(codec); | |
7974 | } | |
7975 | ||
9c7f852e TI |
7976 | /* |
7977 | * generic initialization of ADC, input mixers and output mixers | |
7978 | */ | |
7979 | static struct hda_verb alc883_auto_init_verbs[] = { | |
7980 | /* | |
7981 | * Unmute ADC0-2 and set the default input to mic-in | |
7982 | */ | |
7983 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7984 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7985 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
7986 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
7987 | ||
cb53c626 | 7988 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 7989 | * mixer widget |
f12ab1e0 TI |
7990 | * Note: PASD motherboards uses the Line In 2 as the input for |
7991 | * front panel mic (mic 2) | |
9c7f852e TI |
7992 | */ |
7993 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
7994 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
7995 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
7996 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
7997 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
7998 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
7999 | |
8000 | /* | |
8001 | * Set up output mixers (0x0c - 0x0f) | |
8002 | */ | |
8003 | /* set vol=0 to output mixers */ | |
8004 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8005 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8006 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8007 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
8008 | /* set up input amps for analog loopback */ | |
8009 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
8010 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8011 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8012 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8013 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8014 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8015 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8016 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8017 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8018 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8019 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8020 | ||
8021 | /* FIXME: use matrix-type input source selection */ | |
8022 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
8023 | /* Input mixer1 */ | |
8024 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8025 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8026 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 8027 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
9c7f852e TI |
8028 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
8029 | /* Input mixer2 */ | |
8030 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8031 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8032 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 8033 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ |
e3cde64a | 8034 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
9c7f852e TI |
8035 | |
8036 | { } | |
8037 | }; | |
8038 | ||
e2757d5e KY |
8039 | static struct hda_verb alc888_asus_m90v_verbs[] = { |
8040 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8041 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8042 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
8043 | /* enable unsolicited event */ | |
8044 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
8045 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, | |
8046 | { } /* end */ | |
8047 | }; | |
8048 | ||
8049 | static void alc883_nb_mic_automute(struct hda_codec *codec) | |
8050 | { | |
8051 | unsigned int present; | |
8052 | ||
8053 | present = snd_hda_codec_read(codec, 0x18, 0, | |
8054 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
8055 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
8056 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
8057 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
8058 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
8059 | } | |
8060 | ||
8061 | static void alc883_M90V_speaker_automute(struct hda_codec *codec) | |
8062 | { | |
8063 | unsigned int present; | |
8064 | unsigned char bits; | |
8065 | ||
8066 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
8067 | AC_VERB_GET_PIN_SENSE, 0) | |
8068 | & AC_PINSENSE_PRESENCE; | |
8069 | bits = present ? 0 : PIN_OUT; | |
8070 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8071 | bits); | |
8072 | snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8073 | bits); | |
8074 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8075 | bits); | |
8076 | } | |
8077 | ||
8078 | static void alc883_mode2_unsol_event(struct hda_codec *codec, | |
8079 | unsigned int res) | |
8080 | { | |
8081 | switch (res >> 26) { | |
8082 | case ALC880_HP_EVENT: | |
8083 | alc883_M90V_speaker_automute(codec); | |
8084 | break; | |
8085 | case ALC880_MIC_EVENT: | |
8086 | alc883_nb_mic_automute(codec); | |
8087 | break; | |
8088 | } | |
8089 | } | |
8090 | ||
8091 | static void alc883_mode2_inithook(struct hda_codec *codec) | |
8092 | { | |
8093 | alc883_M90V_speaker_automute(codec); | |
8094 | alc883_nb_mic_automute(codec); | |
8095 | } | |
8096 | ||
8097 | static struct hda_verb alc888_asus_eee1601_verbs[] = { | |
8098 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8099 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8100 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
8101 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
8102 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
8103 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0b}, | |
8104 | {0x20, AC_VERB_SET_PROC_COEF, 0x0838}, | |
8105 | /* enable unsolicited event */ | |
8106 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
8107 | { } /* end */ | |
8108 | }; | |
8109 | ||
8110 | static void alc883_eee1601_speaker_automute(struct hda_codec *codec) | |
8111 | { | |
8112 | unsigned int present; | |
8113 | unsigned char bits; | |
8114 | ||
8115 | present = snd_hda_codec_read(codec, 0x14, 0, | |
8116 | AC_VERB_GET_PIN_SENSE, 0) | |
8117 | & AC_PINSENSE_PRESENCE; | |
8118 | bits = present ? 0 : PIN_OUT; | |
8119 | snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8120 | bits); | |
8121 | } | |
8122 | ||
8123 | static void alc883_eee1601_unsol_event(struct hda_codec *codec, | |
8124 | unsigned int res) | |
8125 | { | |
8126 | switch (res >> 26) { | |
8127 | case ALC880_HP_EVENT: | |
8128 | alc883_eee1601_speaker_automute(codec); | |
8129 | break; | |
8130 | } | |
8131 | } | |
8132 | ||
8133 | static void alc883_eee1601_inithook(struct hda_codec *codec) | |
8134 | { | |
8135 | alc883_eee1601_speaker_automute(codec); | |
8136 | } | |
8137 | ||
cb53c626 TI |
8138 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
8139 | #define alc883_loopbacks alc880_loopbacks | |
8140 | #endif | |
8141 | ||
9c7f852e TI |
8142 | /* pcm configuration: identiacal with ALC880 */ |
8143 | #define alc883_pcm_analog_playback alc880_pcm_analog_playback | |
8144 | #define alc883_pcm_analog_capture alc880_pcm_analog_capture | |
6330079f | 8145 | #define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture |
9c7f852e TI |
8146 | #define alc883_pcm_digital_playback alc880_pcm_digital_playback |
8147 | #define alc883_pcm_digital_capture alc880_pcm_digital_capture | |
8148 | ||
8149 | /* | |
8150 | * configuration and preset | |
8151 | */ | |
f5fcc13c TI |
8152 | static const char *alc883_models[ALC883_MODEL_LAST] = { |
8153 | [ALC883_3ST_2ch_DIG] = "3stack-dig", | |
8154 | [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", | |
8155 | [ALC883_3ST_6ch] = "3stack-6ch", | |
8156 | [ALC883_6ST_DIG] = "6stack-dig", | |
8157 | [ALC883_TARGA_DIG] = "targa-dig", | |
8158 | [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", | |
f5fcc13c | 8159 | [ALC883_ACER] = "acer", |
2880a867 | 8160 | [ALC883_ACER_ASPIRE] = "acer-aspire", |
f5fcc13c | 8161 | [ALC883_MEDION] = "medion", |
272a527c | 8162 | [ALC883_MEDION_MD2] = "medion-md2", |
f5fcc13c | 8163 | [ALC883_LAPTOP_EAPD] = "laptop-eapd", |
bc9f98a9 | 8164 | [ALC883_LENOVO_101E_2ch] = "lenovo-101e", |
272a527c KY |
8165 | [ALC883_LENOVO_NB0763] = "lenovo-nb0763", |
8166 | [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig", | |
e2757d5e | 8167 | [ALC888_LENOVO_SKY] = "lenovo-sky", |
189609ae | 8168 | [ALC883_HAIER_W66] = "haier-w66", |
4723c022 | 8169 | [ALC888_3ST_HP] = "3stack-hp", |
5795b9e6 | 8170 | [ALC888_6ST_DELL] = "6stack-dell", |
a8848bd6 | 8171 | [ALC883_MITAC] = "mitac", |
0c4cc443 | 8172 | [ALC883_CLEVO_M720] = "clevo-m720", |
fb97dc67 | 8173 | [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515", |
17bba1b7 | 8174 | [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", |
f5fcc13c TI |
8175 | [ALC883_AUTO] = "auto", |
8176 | }; | |
8177 | ||
8178 | static struct snd_pci_quirk alc883_cfg_tbl[] = { | |
8179 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), | |
ac3e3741 TI |
8180 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), |
8181 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE), | |
8182 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE), | |
0b18cb18 | 8183 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE), |
ac3e3741 | 8184 | SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */ |
5795b9e6 | 8185 | SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), |
febe3375 | 8186 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), |
ac3e3741 TI |
8187 | SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), |
8188 | SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), | |
5d85f8d0 | 8189 | SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), |
a01c30cb | 8190 | SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), |
ac3e3741 | 8191 | SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), |
e2757d5e | 8192 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), |
97ec710c | 8193 | SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), |
f5fcc13c | 8194 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), |
ac3e3741 TI |
8195 | SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), |
8196 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), | |
e2757d5e | 8197 | SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL), |
ac3e3741 | 8198 | SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), |
57b14f24 | 8199 | SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), |
6f3bf657 | 8200 | SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), |
bba8dee7 | 8201 | SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 8202 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), |
4383fae0 | 8203 | SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG), |
dd146a60 | 8204 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), |
82808236 | 8205 | SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), |
f5fcc13c | 8206 | SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 8207 | SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG), |
f5fcc13c TI |
8208 | SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG), |
8209 | SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), | |
ac3e3741 | 8210 | SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), |
64ca1c29 | 8211 | SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), |
f5fcc13c TI |
8212 | SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), |
8213 | SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), | |
8214 | SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), | |
ac3e3741 TI |
8215 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), |
8216 | SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), | |
8217 | SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG), | |
86d34b7e | 8218 | SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG), |
ac3e3741 TI |
8219 | SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), |
8220 | SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), | |
f5fcc13c | 8221 | SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), |
ac3e3741 | 8222 | SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), |
0c4cc443 HRK |
8223 | SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), |
8224 | SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), | |
ac3e3741 | 8225 | SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), |
e60623b4 | 8226 | SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), |
f5fcc13c | 8227 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), |
fb97dc67 | 8228 | SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515), |
272a527c | 8229 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), |
272a527c | 8230 | SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), |
ac3e3741 TI |
8231 | SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763), |
8232 | SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763), | |
e2757d5e | 8233 | SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY), |
272a527c | 8234 | SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2), |
0b167bf4 | 8235 | SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG), |
189609ae | 8236 | SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), |
17bba1b7 J |
8237 | SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), |
8238 | SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), | |
ac3e3741 | 8239 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), |
9c7f852e TI |
8240 | {} |
8241 | }; | |
8242 | ||
8243 | static struct alc_config_preset alc883_presets[] = { | |
8244 | [ALC883_3ST_2ch_DIG] = { | |
8245 | .mixers = { alc883_3ST_2ch_mixer }, | |
8246 | .init_verbs = { alc883_init_verbs }, | |
8247 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8248 | .dac_nids = alc883_dac_nids, | |
8249 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
8250 | .dig_in_nid = ALC883_DIGIN_NID, |
8251 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8252 | .channel_mode = alc883_3ST_2ch_modes, | |
8253 | .input_mux = &alc883_capture_source, | |
8254 | }, | |
8255 | [ALC883_3ST_6ch_DIG] = { | |
8256 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8257 | .init_verbs = { alc883_init_verbs }, | |
8258 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8259 | .dac_nids = alc883_dac_nids, | |
8260 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
8261 | .dig_in_nid = ALC883_DIGIN_NID, |
8262 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
8263 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 8264 | .need_dac_fix = 1, |
9c7f852e | 8265 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 8266 | }, |
9c7f852e TI |
8267 | [ALC883_3ST_6ch] = { |
8268 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8269 | .init_verbs = { alc883_init_verbs }, | |
8270 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8271 | .dac_nids = alc883_dac_nids, | |
9c7f852e TI |
8272 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
8273 | .channel_mode = alc883_3ST_6ch_modes, | |
4e195a7b | 8274 | .need_dac_fix = 1, |
9c7f852e | 8275 | .input_mux = &alc883_capture_source, |
f12ab1e0 | 8276 | }, |
17bba1b7 J |
8277 | [ALC883_3ST_6ch_INTEL] = { |
8278 | .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer }, | |
8279 | .init_verbs = { alc883_init_verbs }, | |
8280 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8281 | .dac_nids = alc883_dac_nids, | |
8282 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8283 | .dig_in_nid = ALC883_DIGIN_NID, | |
8284 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes), | |
8285 | .channel_mode = alc883_3ST_6ch_intel_modes, | |
8286 | .need_dac_fix = 1, | |
8287 | .input_mux = &alc883_3stack_6ch_intel, | |
8288 | }, | |
9c7f852e TI |
8289 | [ALC883_6ST_DIG] = { |
8290 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | |
8291 | .init_verbs = { alc883_init_verbs }, | |
8292 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8293 | .dac_nids = alc883_dac_nids, | |
8294 | .dig_out_nid = ALC883_DIGOUT_NID, | |
9c7f852e TI |
8295 | .dig_in_nid = ALC883_DIGIN_NID, |
8296 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
8297 | .channel_mode = alc883_sixstack_modes, | |
8298 | .input_mux = &alc883_capture_source, | |
8299 | }, | |
ccc656ce KY |
8300 | [ALC883_TARGA_DIG] = { |
8301 | .mixers = { alc883_tagra_mixer, alc883_chmode_mixer }, | |
8302 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
8303 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8304 | .dac_nids = alc883_dac_nids, | |
8305 | .dig_out_nid = ALC883_DIGOUT_NID, | |
ccc656ce KY |
8306 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
8307 | .channel_mode = alc883_3ST_6ch_modes, | |
8308 | .need_dac_fix = 1, | |
8309 | .input_mux = &alc883_capture_source, | |
8310 | .unsol_event = alc883_tagra_unsol_event, | |
8311 | .init_hook = alc883_tagra_automute, | |
8312 | }, | |
8313 | [ALC883_TARGA_2ch_DIG] = { | |
8314 | .mixers = { alc883_tagra_2ch_mixer}, | |
8315 | .init_verbs = { alc883_init_verbs, alc883_tagra_verbs}, | |
8316 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8317 | .dac_nids = alc883_dac_nids, | |
f9e336f6 TI |
8318 | .adc_nids = alc883_adc_nids_alt, |
8319 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | |
ccc656ce | 8320 | .dig_out_nid = ALC883_DIGOUT_NID, |
ccc656ce KY |
8321 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8322 | .channel_mode = alc883_3ST_2ch_modes, | |
8323 | .input_mux = &alc883_capture_source, | |
8324 | .unsol_event = alc883_tagra_unsol_event, | |
8325 | .init_hook = alc883_tagra_automute, | |
8326 | }, | |
bab282b9 | 8327 | [ALC883_ACER] = { |
676a9b53 | 8328 | .mixers = { alc883_base_mixer }, |
bab282b9 VA |
8329 | /* On TravelMate laptops, GPIO 0 enables the internal speaker |
8330 | * and the headphone jack. Turn this on and rely on the | |
8331 | * standard mute methods whenever the user wants to turn | |
8332 | * these outputs off. | |
8333 | */ | |
8334 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs }, | |
8335 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8336 | .dac_nids = alc883_dac_nids, | |
bab282b9 VA |
8337 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8338 | .channel_mode = alc883_3ST_2ch_modes, | |
8339 | .input_mux = &alc883_capture_source, | |
8340 | }, | |
2880a867 | 8341 | [ALC883_ACER_ASPIRE] = { |
676a9b53 | 8342 | .mixers = { alc883_acer_aspire_mixer }, |
d1a991a6 | 8343 | .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs }, |
2880a867 TD |
8344 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8345 | .dac_nids = alc883_dac_nids, | |
8346 | .dig_out_nid = ALC883_DIGOUT_NID, | |
2880a867 TD |
8347 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8348 | .channel_mode = alc883_3ST_2ch_modes, | |
8349 | .input_mux = &alc883_capture_source, | |
676a9b53 TI |
8350 | .unsol_event = alc883_acer_aspire_unsol_event, |
8351 | .init_hook = alc883_acer_aspire_automute, | |
d1a991a6 | 8352 | }, |
c07584c8 TD |
8353 | [ALC883_MEDION] = { |
8354 | .mixers = { alc883_fivestack_mixer, | |
8355 | alc883_chmode_mixer }, | |
8356 | .init_verbs = { alc883_init_verbs, | |
b373bdeb | 8357 | alc883_medion_eapd_verbs }, |
c07584c8 TD |
8358 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8359 | .dac_nids = alc883_dac_nids, | |
f9e336f6 TI |
8360 | .adc_nids = alc883_adc_nids_alt, |
8361 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | |
c07584c8 TD |
8362 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), |
8363 | .channel_mode = alc883_sixstack_modes, | |
8364 | .input_mux = &alc883_capture_source, | |
b373bdeb | 8365 | }, |
272a527c KY |
8366 | [ALC883_MEDION_MD2] = { |
8367 | .mixers = { alc883_medion_md2_mixer}, | |
8368 | .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs}, | |
8369 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8370 | .dac_nids = alc883_dac_nids, | |
8371 | .dig_out_nid = ALC883_DIGOUT_NID, | |
272a527c KY |
8372 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8373 | .channel_mode = alc883_3ST_2ch_modes, | |
8374 | .input_mux = &alc883_capture_source, | |
8375 | .unsol_event = alc883_medion_md2_unsol_event, | |
8376 | .init_hook = alc883_medion_md2_automute, | |
ea1fb29a | 8377 | }, |
b373bdeb | 8378 | [ALC883_LAPTOP_EAPD] = { |
676a9b53 | 8379 | .mixers = { alc883_base_mixer }, |
b373bdeb AN |
8380 | .init_verbs = { alc883_init_verbs, alc882_eapd_verbs }, |
8381 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8382 | .dac_nids = alc883_dac_nids, | |
b373bdeb AN |
8383 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8384 | .channel_mode = alc883_3ST_2ch_modes, | |
8385 | .input_mux = &alc883_capture_source, | |
8386 | }, | |
0c4cc443 HRK |
8387 | [ALC883_CLEVO_M720] = { |
8388 | .mixers = { alc883_clevo_m720_mixer }, | |
8389 | .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs }, | |
368c7a95 J |
8390 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8391 | .dac_nids = alc883_dac_nids, | |
8392 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8393 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8394 | .channel_mode = alc883_3ST_2ch_modes, | |
8395 | .input_mux = &alc883_capture_source, | |
0c4cc443 HRK |
8396 | .unsol_event = alc883_clevo_m720_unsol_event, |
8397 | .init_hook = alc883_clevo_m720_automute, | |
368c7a95 | 8398 | }, |
bc9f98a9 KY |
8399 | [ALC883_LENOVO_101E_2ch] = { |
8400 | .mixers = { alc883_lenovo_101e_2ch_mixer}, | |
8401 | .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs}, | |
8402 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8403 | .dac_nids = alc883_dac_nids, | |
f9e336f6 TI |
8404 | .adc_nids = alc883_adc_nids_alt, |
8405 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt), | |
bc9f98a9 KY |
8406 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8407 | .channel_mode = alc883_3ST_2ch_modes, | |
8408 | .input_mux = &alc883_lenovo_101e_capture_source, | |
8409 | .unsol_event = alc883_lenovo_101e_unsol_event, | |
8410 | .init_hook = alc883_lenovo_101e_all_automute, | |
8411 | }, | |
272a527c KY |
8412 | [ALC883_LENOVO_NB0763] = { |
8413 | .mixers = { alc883_lenovo_nb0763_mixer }, | |
8414 | .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs}, | |
8415 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8416 | .dac_nids = alc883_dac_nids, | |
272a527c KY |
8417 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8418 | .channel_mode = alc883_3ST_2ch_modes, | |
8419 | .need_dac_fix = 1, | |
8420 | .input_mux = &alc883_lenovo_nb0763_capture_source, | |
8421 | .unsol_event = alc883_medion_md2_unsol_event, | |
8422 | .init_hook = alc883_medion_md2_automute, | |
8423 | }, | |
8424 | [ALC888_LENOVO_MS7195_DIG] = { | |
8425 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8426 | .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs}, | |
8427 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8428 | .dac_nids = alc883_dac_nids, | |
8429 | .dig_out_nid = ALC883_DIGOUT_NID, | |
272a527c KY |
8430 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
8431 | .channel_mode = alc883_3ST_6ch_modes, | |
8432 | .need_dac_fix = 1, | |
8433 | .input_mux = &alc883_capture_source, | |
8434 | .unsol_event = alc883_lenovo_ms7195_unsol_event, | |
8435 | .init_hook = alc888_lenovo_ms7195_front_automute, | |
189609ae KY |
8436 | }, |
8437 | [ALC883_HAIER_W66] = { | |
8438 | .mixers = { alc883_tagra_2ch_mixer}, | |
8439 | .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs}, | |
8440 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8441 | .dac_nids = alc883_dac_nids, | |
8442 | .dig_out_nid = ALC883_DIGOUT_NID, | |
189609ae KY |
8443 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8444 | .channel_mode = alc883_3ST_2ch_modes, | |
8445 | .input_mux = &alc883_capture_source, | |
8446 | .unsol_event = alc883_haier_w66_unsol_event, | |
8447 | .init_hook = alc883_haier_w66_automute, | |
eea6419e | 8448 | }, |
4723c022 | 8449 | [ALC888_3ST_HP] = { |
eea6419e | 8450 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
4723c022 | 8451 | .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs }, |
8341de60 CM |
8452 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
8453 | .dac_nids = alc883_dac_nids, | |
4723c022 CM |
8454 | .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes), |
8455 | .channel_mode = alc888_3st_hp_modes, | |
8341de60 CM |
8456 | .need_dac_fix = 1, |
8457 | .input_mux = &alc883_capture_source, | |
8458 | }, | |
5795b9e6 | 8459 | [ALC888_6ST_DELL] = { |
f24dbdc6 | 8460 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, |
5795b9e6 CM |
8461 | .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs }, |
8462 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8463 | .dac_nids = alc883_dac_nids, | |
8464 | .dig_out_nid = ALC883_DIGOUT_NID, | |
5795b9e6 CM |
8465 | .dig_in_nid = ALC883_DIGIN_NID, |
8466 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), | |
8467 | .channel_mode = alc883_sixstack_modes, | |
8468 | .input_mux = &alc883_capture_source, | |
8469 | .unsol_event = alc888_6st_dell_unsol_event, | |
8470 | .init_hook = alc888_6st_dell_front_automute, | |
8471 | }, | |
a8848bd6 AS |
8472 | [ALC883_MITAC] = { |
8473 | .mixers = { alc883_mitac_mixer }, | |
8474 | .init_verbs = { alc883_init_verbs, alc883_mitac_verbs }, | |
8475 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8476 | .dac_nids = alc883_dac_nids, | |
a8848bd6 AS |
8477 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), |
8478 | .channel_mode = alc883_3ST_2ch_modes, | |
8479 | .input_mux = &alc883_capture_source, | |
8480 | .unsol_event = alc883_mitac_unsol_event, | |
8481 | .init_hook = alc883_mitac_automute, | |
8482 | }, | |
fb97dc67 J |
8483 | [ALC883_FUJITSU_PI2515] = { |
8484 | .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, | |
8485 | .init_verbs = { alc883_init_verbs, | |
8486 | alc883_2ch_fujitsu_pi2515_verbs}, | |
8487 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8488 | .dac_nids = alc883_dac_nids, | |
8489 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8490 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8491 | .channel_mode = alc883_3ST_2ch_modes, | |
8492 | .input_mux = &alc883_fujitsu_pi2515_capture_source, | |
8493 | .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event, | |
8494 | .init_hook = alc883_2ch_fujitsu_pi2515_automute, | |
8495 | }, | |
e2757d5e KY |
8496 | [ALC888_LENOVO_SKY] = { |
8497 | .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, | |
8498 | .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs}, | |
8499 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8500 | .dac_nids = alc883_dac_nids, | |
8501 | .dig_out_nid = ALC883_DIGOUT_NID, | |
e2757d5e KY |
8502 | .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), |
8503 | .channel_mode = alc883_sixstack_modes, | |
8504 | .need_dac_fix = 1, | |
8505 | .input_mux = &alc883_lenovo_sky_capture_source, | |
8506 | .unsol_event = alc883_lenovo_sky_unsol_event, | |
8507 | .init_hook = alc888_lenovo_sky_front_automute, | |
8508 | }, | |
8509 | [ALC888_ASUS_M90V] = { | |
8510 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | |
8511 | .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs }, | |
8512 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8513 | .dac_nids = alc883_dac_nids, | |
8514 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8515 | .dig_in_nid = ALC883_DIGIN_NID, | |
8516 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | |
8517 | .channel_mode = alc883_3ST_6ch_modes, | |
8518 | .need_dac_fix = 1, | |
8519 | .input_mux = &alc883_fujitsu_pi2515_capture_source, | |
8520 | .unsol_event = alc883_mode2_unsol_event, | |
8521 | .init_hook = alc883_mode2_inithook, | |
8522 | }, | |
8523 | [ALC888_ASUS_EEE1601] = { | |
8524 | .mixers = { alc883_asus_eee1601_mixer }, | |
f9e336f6 | 8525 | .cap_mixer = alc883_asus_eee1601_cap_mixer, |
e2757d5e KY |
8526 | .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs }, |
8527 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | |
8528 | .dac_nids = alc883_dac_nids, | |
8529 | .dig_out_nid = ALC883_DIGOUT_NID, | |
8530 | .dig_in_nid = ALC883_DIGIN_NID, | |
8531 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
8532 | .channel_mode = alc883_3ST_2ch_modes, | |
8533 | .need_dac_fix = 1, | |
8534 | .input_mux = &alc883_asus_eee1601_capture_source, | |
8535 | .unsol_event = alc883_eee1601_unsol_event, | |
8536 | .init_hook = alc883_eee1601_inithook, | |
8537 | }, | |
9c7f852e TI |
8538 | }; |
8539 | ||
8540 | ||
8541 | /* | |
8542 | * BIOS auto configuration | |
8543 | */ | |
8544 | static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, | |
8545 | hda_nid_t nid, int pin_type, | |
8546 | int dac_idx) | |
8547 | { | |
8548 | /* set as output */ | |
8549 | struct alc_spec *spec = codec->spec; | |
f12ab1e0 TI |
8550 | int idx; |
8551 | ||
f6c7e546 | 8552 | alc_set_pin_output(codec, nid, pin_type); |
9c7f852e TI |
8553 | if (spec->multiout.dac_nids[dac_idx] == 0x25) |
8554 | idx = 4; | |
8555 | else | |
8556 | idx = spec->multiout.dac_nids[dac_idx] - 2; | |
9c7f852e TI |
8557 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
8558 | ||
8559 | } | |
8560 | ||
8561 | static void alc883_auto_init_multi_out(struct hda_codec *codec) | |
8562 | { | |
8563 | struct alc_spec *spec = codec->spec; | |
8564 | int i; | |
8565 | ||
bc9f98a9 | 8566 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
9c7f852e | 8567 | for (i = 0; i <= HDA_SIDE; i++) { |
f12ab1e0 | 8568 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
baba8ee9 | 8569 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
9c7f852e | 8570 | if (nid) |
baba8ee9 | 8571 | alc883_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 8572 | i); |
9c7f852e TI |
8573 | } |
8574 | } | |
8575 | ||
8576 | static void alc883_auto_init_hp_out(struct hda_codec *codec) | |
8577 | { | |
8578 | struct alc_spec *spec = codec->spec; | |
8579 | hda_nid_t pin; | |
8580 | ||
eb06ed8f | 8581 | pin = spec->autocfg.hp_pins[0]; |
9c7f852e TI |
8582 | if (pin) /* connect to front */ |
8583 | /* use dac 0 */ | |
8584 | alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
8585 | pin = spec->autocfg.speaker_pins[0]; |
8586 | if (pin) | |
8587 | alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
9c7f852e TI |
8588 | } |
8589 | ||
8590 | #define alc883_is_input_pin(nid) alc880_is_input_pin(nid) | |
8591 | #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID | |
8592 | ||
8593 | static void alc883_auto_init_analog_input(struct hda_codec *codec) | |
8594 | { | |
8595 | struct alc_spec *spec = codec->spec; | |
8596 | int i; | |
8597 | ||
8598 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
8599 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
8600 | if (alc883_is_input_pin(nid)) { | |
8601 | snd_hda_codec_write(codec, nid, 0, | |
8602 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8603 | (i <= AUTO_PIN_FRONT_MIC ? | |
8604 | PIN_VREF80 : PIN_IN)); | |
8605 | if (nid != ALC883_PIN_CD_NID) | |
8606 | snd_hda_codec_write(codec, nid, 0, | |
8607 | AC_VERB_SET_AMP_GAIN_MUTE, | |
8608 | AMP_OUT_MUTE); | |
8609 | } | |
8610 | } | |
8611 | } | |
8612 | ||
f511b01c TI |
8613 | #define alc883_auto_init_input_src alc882_auto_init_input_src |
8614 | ||
9c7f852e TI |
8615 | /* almost identical with ALC880 parser... */ |
8616 | static int alc883_parse_auto_config(struct hda_codec *codec) | |
8617 | { | |
8618 | struct alc_spec *spec = codec->spec; | |
8619 | int err = alc880_parse_auto_config(codec); | |
8620 | ||
8621 | if (err < 0) | |
8622 | return err; | |
776e184e TI |
8623 | else if (!err) |
8624 | return 0; /* no config found */ | |
8625 | ||
8626 | err = alc_auto_add_mic_boost(codec); | |
8627 | if (err < 0) | |
8628 | return err; | |
8629 | ||
8630 | /* hack - override the init verbs */ | |
8631 | spec->init_verbs[0] = alc883_auto_init_verbs; | |
776e184e TI |
8632 | |
8633 | return 1; /* config found */ | |
9c7f852e TI |
8634 | } |
8635 | ||
8636 | /* additional initialization for auto-configuration model */ | |
8637 | static void alc883_auto_init(struct hda_codec *codec) | |
8638 | { | |
f6c7e546 | 8639 | struct alc_spec *spec = codec->spec; |
9c7f852e TI |
8640 | alc883_auto_init_multi_out(codec); |
8641 | alc883_auto_init_hp_out(codec); | |
8642 | alc883_auto_init_analog_input(codec); | |
f511b01c | 8643 | alc883_auto_init_input_src(codec); |
f6c7e546 | 8644 | if (spec->unsol_event) |
7fb0d78f | 8645 | alc_inithook(codec); |
9c7f852e TI |
8646 | } |
8647 | ||
8648 | static int patch_alc883(struct hda_codec *codec) | |
8649 | { | |
8650 | struct alc_spec *spec; | |
8651 | int err, board_config; | |
8652 | ||
8653 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
8654 | if (spec == NULL) | |
8655 | return -ENOMEM; | |
8656 | ||
8657 | codec->spec = spec; | |
8658 | ||
2c3bf9ab TI |
8659 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
8660 | ||
f5fcc13c TI |
8661 | board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, |
8662 | alc883_models, | |
8663 | alc883_cfg_tbl); | |
8664 | if (board_config < 0) { | |
9c7f852e TI |
8665 | printk(KERN_INFO "hda_codec: Unknown model for ALC883, " |
8666 | "trying auto-probe from BIOS...\n"); | |
8667 | board_config = ALC883_AUTO; | |
8668 | } | |
8669 | ||
8670 | if (board_config == ALC883_AUTO) { | |
8671 | /* automatic parse from the BIOS config */ | |
8672 | err = alc883_parse_auto_config(codec); | |
8673 | if (err < 0) { | |
8674 | alc_free(codec); | |
8675 | return err; | |
f12ab1e0 | 8676 | } else if (!err) { |
9c7f852e TI |
8677 | printk(KERN_INFO |
8678 | "hda_codec: Cannot set up configuration " | |
8679 | "from BIOS. Using base mode...\n"); | |
8680 | board_config = ALC883_3ST_2ch_DIG; | |
8681 | } | |
8682 | } | |
8683 | ||
8684 | if (board_config != ALC883_AUTO) | |
8685 | setup_preset(spec, &alc883_presets[board_config]); | |
8686 | ||
2f893286 KY |
8687 | switch (codec->vendor_id) { |
8688 | case 0x10ec0888: | |
4442608d KY |
8689 | if (codec->revision_id == 0x100101) { |
8690 | spec->stream_name_analog = "ALC1200 Analog"; | |
8691 | spec->stream_name_digital = "ALC1200 Digital"; | |
8692 | } else { | |
8693 | spec->stream_name_analog = "ALC888 Analog"; | |
8694 | spec->stream_name_digital = "ALC888 Digital"; | |
8695 | } | |
2f893286 KY |
8696 | break; |
8697 | case 0x10ec0889: | |
8698 | spec->stream_name_analog = "ALC889 Analog"; | |
8699 | spec->stream_name_digital = "ALC889 Digital"; | |
8700 | break; | |
8701 | default: | |
8702 | spec->stream_name_analog = "ALC883 Analog"; | |
8703 | spec->stream_name_digital = "ALC883 Digital"; | |
8704 | break; | |
8705 | } | |
8706 | ||
9c7f852e TI |
8707 | spec->stream_analog_playback = &alc883_pcm_analog_playback; |
8708 | spec->stream_analog_capture = &alc883_pcm_analog_capture; | |
6330079f | 8709 | spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture; |
9c7f852e | 8710 | |
9c7f852e TI |
8711 | spec->stream_digital_playback = &alc883_pcm_digital_playback; |
8712 | spec->stream_digital_capture = &alc883_pcm_digital_capture; | |
8713 | ||
f9e336f6 TI |
8714 | if (!spec->num_adc_nids) { |
8715 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); | |
8716 | spec->adc_nids = alc883_adc_nids; | |
8717 | } | |
8718 | if (!spec->capsrc_nids) | |
8719 | spec->capsrc_nids = alc883_capsrc_nids; | |
54cbc9ab | 8720 | spec->is_mix_capture = 1; /* matrix-style capture */ |
f9e336f6 TI |
8721 | if (!spec->cap_mixer) |
8722 | set_capture_mixer(spec); | |
9c7f852e | 8723 | |
2134ea4f TI |
8724 | spec->vmaster_nid = 0x0c; |
8725 | ||
9c7f852e TI |
8726 | codec->patch_ops = alc_patch_ops; |
8727 | if (board_config == ALC883_AUTO) | |
8728 | spec->init_hook = alc883_auto_init; | |
f9423e7a | 8729 | |
cb53c626 TI |
8730 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
8731 | if (!spec->loopback.amplist) | |
8732 | spec->loopback.amplist = alc883_loopbacks; | |
8733 | #endif | |
9c7f852e TI |
8734 | |
8735 | return 0; | |
8736 | } | |
8737 | ||
8738 | /* | |
8739 | * ALC262 support | |
8740 | */ | |
8741 | ||
8742 | #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID | |
8743 | #define ALC262_DIGIN_NID ALC880_DIGIN_NID | |
8744 | ||
8745 | #define alc262_dac_nids alc260_dac_nids | |
8746 | #define alc262_adc_nids alc882_adc_nids | |
8747 | #define alc262_adc_nids_alt alc882_adc_nids_alt | |
88c71a99 TI |
8748 | #define alc262_capsrc_nids alc882_capsrc_nids |
8749 | #define alc262_capsrc_nids_alt alc882_capsrc_nids_alt | |
9c7f852e TI |
8750 | |
8751 | #define alc262_modes alc260_modes | |
8752 | #define alc262_capture_source alc882_capture_source | |
8753 | ||
4e555fe5 KY |
8754 | static hda_nid_t alc262_dmic_adc_nids[1] = { |
8755 | /* ADC0 */ | |
8756 | 0x09 | |
8757 | }; | |
8758 | ||
8759 | static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 }; | |
8760 | ||
9c7f852e TI |
8761 | static struct snd_kcontrol_new alc262_base_mixer[] = { |
8762 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
8763 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8764 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8765 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8766 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
8767 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
8768 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8769 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 8770 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
8771 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
8772 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 8773 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e | 8774 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
31bffaa9 | 8775 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */ |
9c7f852e TI |
8776 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), |
8777 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
8778 | HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | |
8779 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
8780 | { } /* end */ | |
8781 | }; | |
8782 | ||
ccc656ce KY |
8783 | static struct snd_kcontrol_new alc262_hippo1_mixer[] = { |
8784 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
8785 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8786 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8787 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8788 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
8789 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
8790 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8791 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 8792 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
ccc656ce KY |
8793 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
8794 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 8795 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
ccc656ce | 8796 | /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), |
31bffaa9 | 8797 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */ |
ccc656ce KY |
8798 | /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ |
8799 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
8800 | { } /* end */ | |
8801 | }; | |
8802 | ||
ce875f07 TI |
8803 | /* update HP, line and mono-out pins according to the master switch */ |
8804 | static void alc262_hp_master_update(struct hda_codec *codec) | |
8805 | { | |
8806 | struct alc_spec *spec = codec->spec; | |
8807 | int val = spec->master_sw; | |
8808 | ||
8809 | /* HP & line-out */ | |
8810 | snd_hda_codec_write_cache(codec, 0x1b, 0, | |
8811 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8812 | val ? PIN_HP : 0); | |
8813 | snd_hda_codec_write_cache(codec, 0x15, 0, | |
8814 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8815 | val ? PIN_HP : 0); | |
8816 | /* mono (speaker) depending on the HP jack sense */ | |
8817 | val = val && !spec->jack_present; | |
8818 | snd_hda_codec_write_cache(codec, 0x16, 0, | |
8819 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
8820 | val ? PIN_OUT : 0); | |
8821 | } | |
8822 | ||
8823 | static void alc262_hp_bpc_automute(struct hda_codec *codec) | |
8824 | { | |
8825 | struct alc_spec *spec = codec->spec; | |
8826 | unsigned int presence; | |
8827 | presence = snd_hda_codec_read(codec, 0x1b, 0, | |
8828 | AC_VERB_GET_PIN_SENSE, 0); | |
8829 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | |
8830 | alc262_hp_master_update(codec); | |
8831 | } | |
8832 | ||
8833 | static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res) | |
8834 | { | |
8835 | if ((res >> 26) != ALC880_HP_EVENT) | |
8836 | return; | |
8837 | alc262_hp_bpc_automute(codec); | |
8838 | } | |
8839 | ||
8840 | static void alc262_hp_wildwest_automute(struct hda_codec *codec) | |
8841 | { | |
8842 | struct alc_spec *spec = codec->spec; | |
8843 | unsigned int presence; | |
8844 | presence = snd_hda_codec_read(codec, 0x15, 0, | |
8845 | AC_VERB_GET_PIN_SENSE, 0); | |
8846 | spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE); | |
8847 | alc262_hp_master_update(codec); | |
8848 | } | |
8849 | ||
8850 | static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec, | |
8851 | unsigned int res) | |
8852 | { | |
8853 | if ((res >> 26) != ALC880_HP_EVENT) | |
8854 | return; | |
8855 | alc262_hp_wildwest_automute(codec); | |
8856 | } | |
8857 | ||
8858 | static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol, | |
8859 | struct snd_ctl_elem_value *ucontrol) | |
8860 | { | |
8861 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
8862 | struct alc_spec *spec = codec->spec; | |
8863 | *ucontrol->value.integer.value = spec->master_sw; | |
8864 | return 0; | |
8865 | } | |
8866 | ||
8867 | static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |
8868 | struct snd_ctl_elem_value *ucontrol) | |
8869 | { | |
8870 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
8871 | struct alc_spec *spec = codec->spec; | |
8872 | int val = !!*ucontrol->value.integer.value; | |
8873 | ||
8874 | if (val == spec->master_sw) | |
8875 | return 0; | |
8876 | spec->master_sw = val; | |
8877 | alc262_hp_master_update(codec); | |
8878 | return 1; | |
8879 | } | |
8880 | ||
9c7f852e | 8881 | static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { |
ce875f07 TI |
8882 | { |
8883 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8884 | .name = "Master Playback Switch", | |
8885 | .info = snd_ctl_boolean_mono_info, | |
8886 | .get = alc262_hp_master_sw_get, | |
8887 | .put = alc262_hp_master_sw_put, | |
8888 | }, | |
9c7f852e TI |
8889 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
8890 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
8891 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
ce875f07 TI |
8892 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, |
8893 | HDA_OUTPUT), | |
8894 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, | |
8895 | HDA_OUTPUT), | |
9c7f852e TI |
8896 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
8897 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 8898 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9c7f852e TI |
8899 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
8900 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
cc69d12d | 8901 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), |
9c7f852e TI |
8902 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
8903 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
8904 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8905 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8906 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
8907 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
8908 | HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT), | |
8909 | HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT), | |
8910 | { } /* end */ | |
8911 | }; | |
8912 | ||
cd7509a4 | 8913 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = { |
ce875f07 TI |
8914 | { |
8915 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
8916 | .name = "Master Playback Switch", | |
8917 | .info = snd_ctl_boolean_mono_info, | |
8918 | .get = alc262_hp_master_sw_get, | |
8919 | .put = alc262_hp_master_sw_put, | |
8920 | }, | |
cd7509a4 KY |
8921 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
8922 | HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
8923 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
8924 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
ce875f07 TI |
8925 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0, |
8926 | HDA_OUTPUT), | |
8927 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0, | |
8928 | HDA_OUTPUT), | |
cd7509a4 KY |
8929 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT), |
8930 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
cc69d12d | 8931 | HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT), |
cd7509a4 KY |
8932 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
8933 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
8934 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
8935 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
8936 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
8937 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
8938 | { } /* end */ | |
8939 | }; | |
8940 | ||
8941 | static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { | |
8942 | HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8943 | HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
cc69d12d | 8944 | HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT), |
cd7509a4 KY |
8945 | { } /* end */ |
8946 | }; | |
8947 | ||
66d2a9d6 KY |
8948 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
8949 | static void alc262_hp_t5735_automute(struct hda_codec *codec, int force) | |
8950 | { | |
8951 | struct alc_spec *spec = codec->spec; | |
66d2a9d6 KY |
8952 | |
8953 | if (force || !spec->sense_updated) { | |
8954 | unsigned int present; | |
8955 | present = snd_hda_codec_read(codec, 0x15, 0, | |
8956 | AC_VERB_GET_PIN_SENSE, 0); | |
4bb26130 | 8957 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; |
66d2a9d6 KY |
8958 | spec->sense_updated = 1; |
8959 | } | |
4bb26130 TI |
8960 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE, |
8961 | spec->jack_present ? HDA_AMP_MUTE : 0); | |
66d2a9d6 KY |
8962 | } |
8963 | ||
8964 | static void alc262_hp_t5735_unsol_event(struct hda_codec *codec, | |
8965 | unsigned int res) | |
8966 | { | |
8967 | if ((res >> 26) != ALC880_HP_EVENT) | |
8968 | return; | |
8969 | alc262_hp_t5735_automute(codec, 1); | |
8970 | } | |
8971 | ||
8972 | static void alc262_hp_t5735_init_hook(struct hda_codec *codec) | |
8973 | { | |
8974 | alc262_hp_t5735_automute(codec, 1); | |
8975 | } | |
8976 | ||
8977 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { | |
86cd9298 TI |
8978 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
8979 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
66d2a9d6 KY |
8980 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), |
8981 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
8982 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
8983 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
8984 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
8985 | { } /* end */ | |
8986 | }; | |
8987 | ||
8988 | static struct hda_verb alc262_hp_t5735_verbs[] = { | |
8989 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
8990 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
8991 | ||
8992 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
8993 | { } | |
8994 | }; | |
8995 | ||
8c427226 | 8996 | static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = { |
f2f48e18 TI |
8997 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
8998 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
86cd9298 TI |
8999 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT), |
9000 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT), | |
8c427226 KY |
9001 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9002 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9003 | { } /* end */ | |
9004 | }; | |
9005 | ||
9006 | static struct hda_verb alc262_hp_rp5700_verbs[] = { | |
9007 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9008 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9009 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9010 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9011 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
9012 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9013 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
9014 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
9015 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, | |
9016 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))}, | |
9017 | {} | |
9018 | }; | |
9019 | ||
9020 | static struct hda_input_mux alc262_hp_rp5700_capture_source = { | |
9021 | .num_items = 1, | |
9022 | .items = { | |
9023 | { "Line", 0x1 }, | |
9024 | }, | |
9025 | }; | |
9026 | ||
0724ea2a TI |
9027 | /* bind hp and internal speaker mute (with plug check) */ |
9028 | static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol, | |
9029 | struct snd_ctl_elem_value *ucontrol) | |
9030 | { | |
9031 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9032 | long *valp = ucontrol->value.integer.value; | |
9033 | int change; | |
9034 | ||
9035 | /* change hp mute */ | |
9036 | change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, | |
9037 | HDA_AMP_MUTE, | |
9038 | valp[0] ? 0 : HDA_AMP_MUTE); | |
9039 | change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, | |
9040 | HDA_AMP_MUTE, | |
9041 | valp[1] ? 0 : HDA_AMP_MUTE); | |
9042 | if (change) { | |
9043 | /* change speaker according to HP jack state */ | |
9044 | struct alc_spec *spec = codec->spec; | |
9045 | unsigned int mute; | |
9046 | if (spec->jack_present) | |
9047 | mute = HDA_AMP_MUTE; | |
9048 | else | |
9049 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, | |
9050 | HDA_OUTPUT, 0); | |
9051 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9052 | HDA_AMP_MUTE, mute); | |
9053 | } | |
9054 | return change; | |
9055 | } | |
5b31954e | 9056 | |
272a527c | 9057 | static struct snd_kcontrol_new alc262_sony_mixer[] = { |
0724ea2a TI |
9058 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9059 | { | |
9060 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9061 | .name = "Master Playback Switch", | |
9062 | .info = snd_hda_mixer_amp_switch_info, | |
9063 | .get = snd_hda_mixer_amp_switch_get, | |
9064 | .put = alc262_sony_master_sw_put, | |
9065 | .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
9066 | }, | |
272a527c KY |
9067 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
9068 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9069 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
9070 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9071 | { } /* end */ | |
9072 | }; | |
9073 | ||
83c34218 KY |
9074 | static struct snd_kcontrol_new alc262_benq_t31_mixer[] = { |
9075 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
9076 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9077 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9078 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9079 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9080 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
9081 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9082 | { } /* end */ | |
9083 | }; | |
272a527c | 9084 | |
9c7f852e TI |
9085 | #define alc262_capture_mixer alc882_capture_mixer |
9086 | #define alc262_capture_alt_mixer alc882_capture_alt_mixer | |
9087 | ||
9088 | /* | |
9089 | * generic initialization of ADC, input mixers and output mixers | |
9090 | */ | |
9091 | static struct hda_verb alc262_init_verbs[] = { | |
9092 | /* | |
9093 | * Unmute ADC0-2 and set the default input to mic-in | |
9094 | */ | |
9095 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9096 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9097 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9098 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9099 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9100 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9101 | ||
cb53c626 | 9102 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 9103 | * mixer widget |
f12ab1e0 TI |
9104 | * Note: PASD motherboards uses the Line In 2 as the input for |
9105 | * front panel mic (mic 2) | |
9c7f852e TI |
9106 | */ |
9107 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
9108 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
9109 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9110 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
9111 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
9112 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9c7f852e TI |
9113 | |
9114 | /* | |
df694daa KY |
9115 | * Set up output mixers (0x0c - 0x0e) |
9116 | */ | |
9117 | /* set vol=0 to output mixers */ | |
9118 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9119 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9120 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9121 | /* set up input amps for analog loopback */ | |
9122 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
9123 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9124 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9125 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9126 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9127 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9128 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9129 | ||
9130 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
9131 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
9132 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
9133 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9134 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9135 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9136 | ||
9137 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9138 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9139 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9140 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9141 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
ea1fb29a | 9142 | |
df694daa KY |
9143 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
9144 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
ea1fb29a | 9145 | |
df694daa KY |
9146 | /* FIXME: use matrix-type input source selection */ |
9147 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
9148 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
9149 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9150 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9151 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9152 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9153 | /* Input mixer2 */ | |
9154 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9155 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9156 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9157 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9158 | /* Input mixer3 */ | |
9159 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9160 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9161 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
f12ab1e0 | 9162 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, |
df694daa KY |
9163 | |
9164 | { } | |
9165 | }; | |
1da177e4 | 9166 | |
4e555fe5 KY |
9167 | static struct hda_verb alc262_eapd_verbs[] = { |
9168 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
9169 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
9170 | { } | |
9171 | }; | |
9172 | ||
ccc656ce KY |
9173 | static struct hda_verb alc262_hippo_unsol_verbs[] = { |
9174 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9175 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9176 | {} | |
9177 | }; | |
9178 | ||
9179 | static struct hda_verb alc262_hippo1_unsol_verbs[] = { | |
9180 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
9181 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9182 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, | |
9183 | ||
9184 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9185 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9186 | {} | |
9187 | }; | |
9188 | ||
272a527c KY |
9189 | static struct hda_verb alc262_sony_unsol_verbs[] = { |
9190 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
9191 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9192 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic | |
9193 | ||
9194 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9195 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
7b1e8795 | 9196 | {} |
272a527c KY |
9197 | }; |
9198 | ||
4e555fe5 KY |
9199 | static struct hda_input_mux alc262_dmic_capture_source = { |
9200 | .num_items = 2, | |
9201 | .items = { | |
9202 | { "Int DMic", 0x9 }, | |
9203 | { "Mic", 0x0 }, | |
9204 | }, | |
9205 | }; | |
9206 | ||
9207 | static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = { | |
9208 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | |
9209 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
9210 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9211 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9212 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
4e555fe5 KY |
9213 | { } /* end */ |
9214 | }; | |
9215 | ||
9216 | static struct hda_verb alc262_toshiba_s06_verbs[] = { | |
9217 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
9218 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9219 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9220 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9221 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x09}, | |
9222 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9223 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
9224 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9225 | {} | |
9226 | }; | |
9227 | ||
9228 | static void alc262_dmic_automute(struct hda_codec *codec) | |
9229 | { | |
9230 | unsigned int present; | |
9231 | ||
9232 | present = snd_hda_codec_read(codec, 0x18, 0, | |
9233 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
9234 | snd_hda_codec_write(codec, 0x22, 0, | |
9235 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09); | |
9236 | } | |
9237 | ||
9238 | /* toggle speaker-output according to the hp-jack state */ | |
9239 | static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec) | |
9240 | { | |
9241 | unsigned int present; | |
9242 | unsigned char bits; | |
9243 | ||
9244 | present = snd_hda_codec_read(codec, 0x15, 0, | |
9245 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
9246 | bits = present ? 0 : PIN_OUT; | |
9247 | snd_hda_codec_write(codec, 0x14, 0, | |
9248 | AC_VERB_SET_PIN_WIDGET_CONTROL, bits); | |
9249 | } | |
9250 | ||
9251 | ||
9252 | ||
9253 | /* unsolicited event for HP jack sensing */ | |
9254 | static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec, | |
9255 | unsigned int res) | |
9256 | { | |
9257 | if ((res >> 26) == ALC880_HP_EVENT) | |
9258 | alc262_toshiba_s06_speaker_automute(codec); | |
9259 | if ((res >> 26) == ALC880_MIC_EVENT) | |
9260 | alc262_dmic_automute(codec); | |
9261 | ||
9262 | } | |
9263 | ||
9264 | static void alc262_toshiba_s06_init_hook(struct hda_codec *codec) | |
9265 | { | |
9266 | alc262_toshiba_s06_speaker_automute(codec); | |
9267 | alc262_dmic_automute(codec); | |
9268 | } | |
9269 | ||
ccc656ce | 9270 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
5b31954e | 9271 | static void alc262_hippo_automute(struct hda_codec *codec) |
ccc656ce KY |
9272 | { |
9273 | struct alc_spec *spec = codec->spec; | |
9274 | unsigned int mute; | |
5b31954e | 9275 | unsigned int present; |
ccc656ce | 9276 | |
5b31954e TI |
9277 | /* need to execute and sync at first */ |
9278 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9279 | present = snd_hda_codec_read(codec, 0x15, 0, | |
9280 | AC_VERB_GET_PIN_SENSE, 0); | |
9281 | spec->jack_present = (present & 0x80000000) != 0; | |
ccc656ce KY |
9282 | if (spec->jack_present) { |
9283 | /* mute internal speaker */ | |
47fd830a TI |
9284 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9285 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
9286 | } else { |
9287 | /* unmute internal speaker if necessary */ | |
9288 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
9289 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9290 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
9291 | } |
9292 | } | |
9293 | ||
9294 | /* unsolicited event for HP jack sensing */ | |
9295 | static void alc262_hippo_unsol_event(struct hda_codec *codec, | |
9296 | unsigned int res) | |
9297 | { | |
9298 | if ((res >> 26) != ALC880_HP_EVENT) | |
9299 | return; | |
5b31954e | 9300 | alc262_hippo_automute(codec); |
ccc656ce KY |
9301 | } |
9302 | ||
5b31954e | 9303 | static void alc262_hippo1_automute(struct hda_codec *codec) |
ccc656ce | 9304 | { |
ccc656ce | 9305 | unsigned int mute; |
5b31954e | 9306 | unsigned int present; |
ccc656ce | 9307 | |
5b31954e TI |
9308 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); |
9309 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
9310 | AC_VERB_GET_PIN_SENSE, 0); | |
9311 | present = (present & 0x80000000) != 0; | |
9312 | if (present) { | |
ccc656ce | 9313 | /* mute internal speaker */ |
47fd830a TI |
9314 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9315 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
ccc656ce KY |
9316 | } else { |
9317 | /* unmute internal speaker if necessary */ | |
9318 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
47fd830a TI |
9319 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9320 | HDA_AMP_MUTE, mute); | |
ccc656ce KY |
9321 | } |
9322 | } | |
9323 | ||
9324 | /* unsolicited event for HP jack sensing */ | |
9325 | static void alc262_hippo1_unsol_event(struct hda_codec *codec, | |
9326 | unsigned int res) | |
9327 | { | |
9328 | if ((res >> 26) != ALC880_HP_EVENT) | |
9329 | return; | |
5b31954e | 9330 | alc262_hippo1_automute(codec); |
ccc656ce KY |
9331 | } |
9332 | ||
e8f9ae2a PT |
9333 | /* |
9334 | * nec model | |
9335 | * 0x15 = headphone | |
9336 | * 0x16 = internal speaker | |
9337 | * 0x18 = external mic | |
9338 | */ | |
9339 | ||
9340 | static struct snd_kcontrol_new alc262_nec_mixer[] = { | |
9341 | HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | |
9342 | HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT), | |
9343 | ||
9344 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9345 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9346 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9347 | ||
9348 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | |
9349 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
9350 | { } /* end */ | |
9351 | }; | |
9352 | ||
9353 | static struct hda_verb alc262_nec_verbs[] = { | |
9354 | /* Unmute Speaker */ | |
9355 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
9356 | ||
9357 | /* Headphone */ | |
9358 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9359 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9360 | ||
9361 | /* External mic to headphone */ | |
9362 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9363 | /* External mic to speaker */ | |
9364 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9365 | {} | |
9366 | }; | |
9367 | ||
834be88d TI |
9368 | /* |
9369 | * fujitsu model | |
5d9fab2d TV |
9370 | * 0x14 = headphone/spdif-out, 0x15 = internal speaker, |
9371 | * 0x1b = port replicator headphone out | |
834be88d TI |
9372 | */ |
9373 | ||
9374 | #define ALC_HP_EVENT 0x37 | |
9375 | ||
9376 | static struct hda_verb alc262_fujitsu_unsol_verbs[] = { | |
9377 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
9378 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
5d9fab2d TV |
9379 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, |
9380 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
834be88d TI |
9381 | {} |
9382 | }; | |
9383 | ||
0e31daf7 J |
9384 | static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = { |
9385 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT}, | |
9386 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
9387 | {} | |
9388 | }; | |
9389 | ||
834be88d | 9390 | static struct hda_input_mux alc262_fujitsu_capture_source = { |
39d3ed38 | 9391 | .num_items = 3, |
834be88d TI |
9392 | .items = { |
9393 | { "Mic", 0x0 }, | |
39d3ed38 | 9394 | { "Int Mic", 0x1 }, |
834be88d TI |
9395 | { "CD", 0x4 }, |
9396 | }, | |
9397 | }; | |
9398 | ||
9c7f852e TI |
9399 | static struct hda_input_mux alc262_HP_capture_source = { |
9400 | .num_items = 5, | |
9401 | .items = { | |
9402 | { "Mic", 0x0 }, | |
accbe498 | 9403 | { "Front Mic", 0x1 }, |
9c7f852e TI |
9404 | { "Line", 0x2 }, |
9405 | { "CD", 0x4 }, | |
9406 | { "AUX IN", 0x6 }, | |
9407 | }, | |
9408 | }; | |
9409 | ||
accbe498 | 9410 | static struct hda_input_mux alc262_HP_D7000_capture_source = { |
9411 | .num_items = 4, | |
9412 | .items = { | |
9413 | { "Mic", 0x0 }, | |
9414 | { "Front Mic", 0x2 }, | |
9415 | { "Line", 0x1 }, | |
9416 | { "CD", 0x4 }, | |
9417 | }, | |
9418 | }; | |
9419 | ||
ebc7a406 | 9420 | /* mute/unmute internal speaker according to the hp jacks and mute state */ |
834be88d TI |
9421 | static void alc262_fujitsu_automute(struct hda_codec *codec, int force) |
9422 | { | |
9423 | struct alc_spec *spec = codec->spec; | |
9424 | unsigned int mute; | |
9425 | ||
f12ab1e0 | 9426 | if (force || !spec->sense_updated) { |
ebc7a406 | 9427 | unsigned int present; |
834be88d TI |
9428 | /* need to execute and sync at first */ |
9429 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
ebc7a406 TI |
9430 | /* check laptop HP jack */ |
9431 | present = snd_hda_codec_read(codec, 0x14, 0, | |
9432 | AC_VERB_GET_PIN_SENSE, 0); | |
9433 | /* need to execute and sync at first */ | |
9434 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9435 | /* check docking HP jack */ | |
9436 | present |= snd_hda_codec_read(codec, 0x1b, 0, | |
9437 | AC_VERB_GET_PIN_SENSE, 0); | |
9438 | if (present & AC_PINSENSE_PRESENCE) | |
9439 | spec->jack_present = 1; | |
9440 | else | |
9441 | spec->jack_present = 0; | |
834be88d TI |
9442 | spec->sense_updated = 1; |
9443 | } | |
ebc7a406 TI |
9444 | /* unmute internal speaker only if both HPs are unplugged and |
9445 | * master switch is on | |
9446 | */ | |
9447 | if (spec->jack_present) | |
9448 | mute = HDA_AMP_MUTE; | |
9449 | else | |
834be88d | 9450 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); |
ebc7a406 TI |
9451 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
9452 | HDA_AMP_MUTE, mute); | |
834be88d TI |
9453 | } |
9454 | ||
9455 | /* unsolicited event for HP jack sensing */ | |
9456 | static void alc262_fujitsu_unsol_event(struct hda_codec *codec, | |
9457 | unsigned int res) | |
9458 | { | |
9459 | if ((res >> 26) != ALC_HP_EVENT) | |
9460 | return; | |
9461 | alc262_fujitsu_automute(codec, 1); | |
9462 | } | |
9463 | ||
ebc7a406 TI |
9464 | static void alc262_fujitsu_init_hook(struct hda_codec *codec) |
9465 | { | |
9466 | alc262_fujitsu_automute(codec, 1); | |
9467 | } | |
9468 | ||
834be88d | 9469 | /* bind volumes of both NID 0x0c and 0x0d */ |
cca3b371 TI |
9470 | static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = { |
9471 | .ops = &snd_hda_bind_vol, | |
9472 | .values = { | |
9473 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT), | |
9474 | HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT), | |
9475 | 0 | |
9476 | }, | |
9477 | }; | |
834be88d | 9478 | |
0e31daf7 J |
9479 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9480 | static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force) | |
9481 | { | |
9482 | struct alc_spec *spec = codec->spec; | |
9483 | unsigned int mute; | |
9484 | ||
9485 | if (force || !spec->sense_updated) { | |
9486 | unsigned int present_int_hp; | |
9487 | /* need to execute and sync at first */ | |
9488 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9489 | present_int_hp = snd_hda_codec_read(codec, 0x1b, 0, | |
9490 | AC_VERB_GET_PIN_SENSE, 0); | |
9491 | spec->jack_present = (present_int_hp & 0x80000000) != 0; | |
9492 | spec->sense_updated = 1; | |
9493 | } | |
9494 | if (spec->jack_present) { | |
9495 | /* mute internal speaker */ | |
9496 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9497 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
9498 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
9499 | HDA_AMP_MUTE, HDA_AMP_MUTE); | |
9500 | } else { | |
9501 | /* unmute internal speaker if necessary */ | |
9502 | mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0); | |
9503 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9504 | HDA_AMP_MUTE, mute); | |
9505 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | |
9506 | HDA_AMP_MUTE, mute); | |
9507 | } | |
9508 | } | |
9509 | ||
9510 | /* unsolicited event for HP jack sensing */ | |
9511 | static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec, | |
9512 | unsigned int res) | |
9513 | { | |
9514 | if ((res >> 26) != ALC_HP_EVENT) | |
9515 | return; | |
9516 | alc262_lenovo_3000_automute(codec, 1); | |
9517 | } | |
9518 | ||
834be88d TI |
9519 | /* bind hp and internal speaker mute (with plug check) */ |
9520 | static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, | |
9521 | struct snd_ctl_elem_value *ucontrol) | |
9522 | { | |
9523 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9524 | long *valp = ucontrol->value.integer.value; | |
9525 | int change; | |
9526 | ||
5d9fab2d TV |
9527 | change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
9528 | HDA_AMP_MUTE, | |
9529 | valp ? 0 : HDA_AMP_MUTE); | |
9530 | change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
9531 | HDA_AMP_MUTE, | |
9532 | valp ? 0 : HDA_AMP_MUTE); | |
9533 | ||
82beb8fd TI |
9534 | if (change) |
9535 | alc262_fujitsu_automute(codec, 0); | |
834be88d TI |
9536 | return change; |
9537 | } | |
9538 | ||
9539 | static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { | |
cca3b371 | 9540 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), |
834be88d TI |
9541 | { |
9542 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9543 | .name = "Master Playback Switch", | |
9544 | .info = snd_hda_mixer_amp_switch_info, | |
9545 | .get = snd_hda_mixer_amp_switch_get, | |
9546 | .put = alc262_fujitsu_master_sw_put, | |
9547 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
9548 | }, | |
9549 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9550 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
06a9c30c TV |
9551 | HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT), |
9552 | HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT), | |
834be88d TI |
9553 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
9554 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9555 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
39d3ed38 TI |
9556 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), |
9557 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
9558 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
834be88d TI |
9559 | { } /* end */ |
9560 | }; | |
9561 | ||
0e31daf7 J |
9562 | /* bind hp and internal speaker mute (with plug check) */ |
9563 | static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol, | |
9564 | struct snd_ctl_elem_value *ucontrol) | |
9565 | { | |
9566 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9567 | long *valp = ucontrol->value.integer.value; | |
9568 | int change; | |
9569 | ||
9570 | change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
9571 | HDA_AMP_MUTE, | |
9572 | valp ? 0 : HDA_AMP_MUTE); | |
9573 | ||
9574 | if (change) | |
9575 | alc262_lenovo_3000_automute(codec, 0); | |
9576 | return change; | |
9577 | } | |
9578 | ||
9579 | static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = { | |
9580 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), | |
9581 | { | |
9582 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9583 | .name = "Master Playback Switch", | |
9584 | .info = snd_hda_mixer_amp_switch_info, | |
9585 | .get = snd_hda_mixer_amp_switch_get, | |
9586 | .put = alc262_lenovo_3000_master_sw_put, | |
9587 | .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | |
9588 | }, | |
9589 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
9590 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
9591 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9592 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9593 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9594 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
9595 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
9596 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
9597 | { } /* end */ | |
9598 | }; | |
9599 | ||
9f99a638 HM |
9600 | static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = { |
9601 | HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol), | |
9602 | { | |
9603 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9604 | .name = "Master Playback Switch", | |
9605 | .info = snd_hda_mixer_amp_switch_info, | |
9606 | .get = snd_hda_mixer_amp_switch_get, | |
9607 | .put = alc262_sony_master_sw_put, | |
9608 | .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
9609 | }, | |
9610 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
9611 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
9612 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
9613 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
9614 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9615 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
9616 | { } /* end */ | |
9617 | }; | |
9618 | ||
304dcaac TI |
9619 | /* additional init verbs for Benq laptops */ |
9620 | static struct hda_verb alc262_EAPD_verbs[] = { | |
9621 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
9622 | {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, | |
9623 | {} | |
9624 | }; | |
9625 | ||
83c34218 KY |
9626 | static struct hda_verb alc262_benq_t31_EAPD_verbs[] = { |
9627 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9628 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9629 | ||
9630 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | |
9631 | {0x20, AC_VERB_SET_PROC_COEF, 0x3050}, | |
9632 | {} | |
9633 | }; | |
9634 | ||
f651b50b TD |
9635 | /* Samsung Q1 Ultra Vista model setup */ |
9636 | static struct snd_kcontrol_new alc262_ultra_mixer[] = { | |
bb9f76cd TI |
9637 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
9638 | HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), | |
f651b50b TD |
9639 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), |
9640 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
9641 | HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT), | |
bb9f76cd | 9642 | HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT), |
f651b50b TD |
9643 | { } /* end */ |
9644 | }; | |
9645 | ||
9646 | static struct hda_verb alc262_ultra_verbs[] = { | |
bb9f76cd TI |
9647 | /* output mixer */ |
9648 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9649 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9650 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9651 | /* speaker */ | |
9652 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
9653 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
9654 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9655 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9656 | /* HP */ | |
f651b50b | 9657 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
bb9f76cd TI |
9658 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
9659 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9660 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9661 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
9662 | /* internal mic */ | |
9663 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
9664 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9665 | /* ADC, choose mic */ | |
9666 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9667 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
9668 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9669 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
9670 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
9671 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9672 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
9673 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
9674 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
9675 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)}, | |
f651b50b TD |
9676 | {} |
9677 | }; | |
9678 | ||
f651b50b TD |
9679 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9680 | static void alc262_ultra_automute(struct hda_codec *codec) | |
9681 | { | |
9682 | struct alc_spec *spec = codec->spec; | |
9683 | unsigned int mute; | |
f651b50b | 9684 | |
bb9f76cd TI |
9685 | mute = 0; |
9686 | /* auto-mute only when HP is used as HP */ | |
9687 | if (!spec->cur_mux[0]) { | |
9688 | unsigned int present; | |
9689 | /* need to execute and sync at first */ | |
9690 | snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); | |
9691 | present = snd_hda_codec_read(codec, 0x15, 0, | |
9692 | AC_VERB_GET_PIN_SENSE, 0); | |
9693 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | |
9694 | if (spec->jack_present) | |
9695 | mute = HDA_AMP_MUTE; | |
f651b50b | 9696 | } |
bb9f76cd TI |
9697 | /* mute/unmute internal speaker */ |
9698 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
9699 | HDA_AMP_MUTE, mute); | |
9700 | /* mute/unmute HP */ | |
9701 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
9702 | HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE); | |
f651b50b TD |
9703 | } |
9704 | ||
9705 | /* unsolicited event for HP jack sensing */ | |
9706 | static void alc262_ultra_unsol_event(struct hda_codec *codec, | |
9707 | unsigned int res) | |
9708 | { | |
9709 | if ((res >> 26) != ALC880_HP_EVENT) | |
9710 | return; | |
9711 | alc262_ultra_automute(codec); | |
9712 | } | |
9713 | ||
bb9f76cd TI |
9714 | static struct hda_input_mux alc262_ultra_capture_source = { |
9715 | .num_items = 2, | |
9716 | .items = { | |
9717 | { "Mic", 0x1 }, | |
9718 | { "Headphone", 0x7 }, | |
9719 | }, | |
9720 | }; | |
9721 | ||
9722 | static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol, | |
9723 | struct snd_ctl_elem_value *ucontrol) | |
9724 | { | |
9725 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
9726 | struct alc_spec *spec = codec->spec; | |
9727 | int ret; | |
9728 | ||
54cbc9ab | 9729 | ret = alc_mux_enum_put(kcontrol, ucontrol); |
bb9f76cd TI |
9730 | if (!ret) |
9731 | return 0; | |
9732 | /* reprogram the HP pin as mic or HP according to the input source */ | |
9733 | snd_hda_codec_write_cache(codec, 0x15, 0, | |
9734 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
9735 | spec->cur_mux[0] ? PIN_VREF80 : PIN_HP); | |
9736 | alc262_ultra_automute(codec); /* mute/unmute HP */ | |
9737 | return ret; | |
9738 | } | |
9739 | ||
9740 | static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = { | |
9741 | HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), | |
9742 | HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), | |
9743 | { | |
9744 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
9745 | .name = "Capture Source", | |
54cbc9ab TI |
9746 | .info = alc_mux_enum_info, |
9747 | .get = alc_mux_enum_get, | |
bb9f76cd TI |
9748 | .put = alc262_ultra_mux_enum_put, |
9749 | }, | |
9750 | { } /* end */ | |
9751 | }; | |
9752 | ||
df694daa | 9753 | /* add playback controls from the parsed DAC table */ |
f12ab1e0 TI |
9754 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, |
9755 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
9756 | { |
9757 | hda_nid_t nid; | |
9758 | int err; | |
9759 | ||
9760 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
9761 | spec->multiout.dac_nids = spec->private_dac_nids; | |
9762 | spec->multiout.dac_nids[0] = 2; | |
9763 | ||
9764 | nid = cfg->line_out_pins[0]; | |
9765 | if (nid) { | |
f12ab1e0 TI |
9766 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
9767 | "Front Playback Volume", | |
9768 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); | |
9769 | if (err < 0) | |
df694daa | 9770 | return err; |
f12ab1e0 TI |
9771 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
9772 | "Front Playback Switch", | |
9773 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
9774 | if (err < 0) | |
df694daa KY |
9775 | return err; |
9776 | } | |
9777 | ||
82bc955f | 9778 | nid = cfg->speaker_pins[0]; |
df694daa KY |
9779 | if (nid) { |
9780 | if (nid == 0x16) { | |
f12ab1e0 TI |
9781 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
9782 | "Speaker Playback Volume", | |
9783 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
9784 | HDA_OUTPUT)); | |
9785 | if (err < 0) | |
df694daa | 9786 | return err; |
f12ab1e0 TI |
9787 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
9788 | "Speaker Playback Switch", | |
9789 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
9790 | HDA_OUTPUT)); | |
9791 | if (err < 0) | |
df694daa KY |
9792 | return err; |
9793 | } else { | |
f12ab1e0 TI |
9794 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
9795 | "Speaker Playback Switch", | |
9796 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
9797 | HDA_OUTPUT)); | |
9798 | if (err < 0) | |
df694daa KY |
9799 | return err; |
9800 | } | |
9801 | } | |
eb06ed8f | 9802 | nid = cfg->hp_pins[0]; |
df694daa KY |
9803 | if (nid) { |
9804 | /* spec->multiout.hp_nid = 2; */ | |
9805 | if (nid == 0x16) { | |
f12ab1e0 TI |
9806 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
9807 | "Headphone Playback Volume", | |
9808 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | |
9809 | HDA_OUTPUT)); | |
9810 | if (err < 0) | |
df694daa | 9811 | return err; |
f12ab1e0 TI |
9812 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
9813 | "Headphone Playback Switch", | |
9814 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
9815 | HDA_OUTPUT)); | |
9816 | if (err < 0) | |
df694daa KY |
9817 | return err; |
9818 | } else { | |
f12ab1e0 TI |
9819 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
9820 | "Headphone Playback Switch", | |
9821 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
9822 | HDA_OUTPUT)); | |
9823 | if (err < 0) | |
df694daa KY |
9824 | return err; |
9825 | } | |
9826 | } | |
f12ab1e0 | 9827 | return 0; |
df694daa KY |
9828 | } |
9829 | ||
9830 | /* identical with ALC880 */ | |
f12ab1e0 TI |
9831 | #define alc262_auto_create_analog_input_ctls \ |
9832 | alc880_auto_create_analog_input_ctls | |
df694daa KY |
9833 | |
9834 | /* | |
9835 | * generic initialization of ADC, input mixers and output mixers | |
9836 | */ | |
9837 | static struct hda_verb alc262_volume_init_verbs[] = { | |
9838 | /* | |
9839 | * Unmute ADC0-2 and set the default input to mic-in | |
9840 | */ | |
9841 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9842 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9843 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9844 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9845 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9846 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9847 | ||
cb53c626 | 9848 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
df694daa | 9849 | * mixer widget |
f12ab1e0 TI |
9850 | * Note: PASD motherboards uses the Line In 2 as the input for |
9851 | * front panel mic (mic 2) | |
df694daa KY |
9852 | */ |
9853 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
9854 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
9855 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9856 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
9857 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
9858 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
df694daa KY |
9859 | |
9860 | /* | |
9861 | * Set up output mixers (0x0c - 0x0f) | |
9862 | */ | |
9863 | /* set vol=0 to output mixers */ | |
9864 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9865 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9866 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
ea1fb29a | 9867 | |
df694daa KY |
9868 | /* set up input amps for analog loopback */ |
9869 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
9870 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9871 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9872 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9873 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9874 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9875 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9876 | ||
9877 | /* FIXME: use matrix-type input source selection */ | |
9878 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
9879 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
9880 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9881 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9882 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9883 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9884 | /* Input mixer2 */ | |
9885 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9886 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9887 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9888 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9889 | /* Input mixer3 */ | |
9890 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9891 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | |
9892 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | |
9893 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | |
9894 | ||
9895 | { } | |
9896 | }; | |
9897 | ||
9c7f852e TI |
9898 | static struct hda_verb alc262_HP_BPC_init_verbs[] = { |
9899 | /* | |
9900 | * Unmute ADC0-2 and set the default input to mic-in | |
9901 | */ | |
9902 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9903 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9904 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9905 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9906 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9907 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9908 | ||
cb53c626 | 9909 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
9c7f852e | 9910 | * mixer widget |
f12ab1e0 TI |
9911 | * Note: PASD motherboards uses the Line In 2 as the input for |
9912 | * front panel mic (mic 2) | |
9c7f852e TI |
9913 | */ |
9914 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
9915 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
9916 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
9917 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
9918 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
9919 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
9920 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
9921 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
ea1fb29a | 9922 | |
9c7f852e TI |
9923 | /* |
9924 | * Set up output mixers (0x0c - 0x0e) | |
9925 | */ | |
9926 | /* set vol=0 to output mixers */ | |
9927 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9928 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9929 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
9930 | ||
9931 | /* set up input amps for analog loopback */ | |
9932 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
9933 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9934 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9935 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9936 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9937 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9938 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
9939 | ||
ce875f07 | 9940 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
9c7f852e TI |
9941 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
9942 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
9943 | ||
9944 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
9945 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
9946 | ||
9947 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9948 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9949 | ||
9950 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9951 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9952 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
9953 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9954 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
9955 | ||
9956 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
9957 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9958 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9959 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
9960 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9961 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
9962 | ||
9963 | ||
9964 | /* FIXME: use matrix-type input source selection */ | |
9965 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
9966 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
9967 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9968 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
9969 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
9970 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
9971 | /* Input mixer2 */ | |
9972 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9973 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
9974 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
9975 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
9976 | /* Input mixer3 */ | |
9977 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
9978 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
9979 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
9980 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
9981 | ||
ce875f07 TI |
9982 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
9983 | ||
9c7f852e TI |
9984 | { } |
9985 | }; | |
9986 | ||
cd7509a4 KY |
9987 | static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = { |
9988 | /* | |
9989 | * Unmute ADC0-2 and set the default input to mic-in | |
9990 | */ | |
9991 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9992 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9993 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9994 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9995 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
9996 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
9997 | ||
cb53c626 | 9998 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
cd7509a4 KY |
9999 | * mixer widget |
10000 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
10001 | * panel mic (mic 2) | |
10002 | */ | |
10003 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
10004 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
10005 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10006 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
10007 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
10008 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
10009 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
10010 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, | |
10011 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, | |
cd7509a4 KY |
10012 | /* |
10013 | * Set up output mixers (0x0c - 0x0e) | |
10014 | */ | |
10015 | /* set vol=0 to output mixers */ | |
10016 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10017 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10018 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10019 | ||
10020 | /* set up input amps for analog loopback */ | |
10021 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
10022 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10023 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10024 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10025 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10026 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10027 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10028 | ||
10029 | ||
10030 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */ | |
10031 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */ | |
10032 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */ | |
10033 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */ | |
10034 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ | |
10035 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */ | |
10036 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */ | |
10037 | ||
10038 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10039 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10040 | ||
10041 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10042 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
10043 | ||
10044 | /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */ | |
10045 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10046 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10047 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, | |
10048 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10049 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 }, | |
10050 | ||
10051 | /* FIXME: use matrix-type input source selection */ | |
10052 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
10053 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
10054 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/ | |
10055 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/ | |
10056 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/ | |
10057 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/ | |
10058 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/ | |
10059 | /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
10060 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/ | |
10061 | /* Input mixer2 */ | |
10062 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10063 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
10064 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10065 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10066 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10067 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
10068 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
10069 | /* Input mixer3 */ | |
10070 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | |
10071 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, | |
10072 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, | |
10073 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, | |
10074 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, | |
10075 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */ | |
10076 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, | |
10077 | ||
ce875f07 TI |
10078 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
10079 | ||
cd7509a4 KY |
10080 | { } |
10081 | }; | |
10082 | ||
9f99a638 HM |
10083 | static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = { |
10084 | ||
10085 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */ | |
10086 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
10087 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
10088 | ||
10089 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */ | |
10090 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */ | |
10091 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) }, | |
10092 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) }, | |
10093 | ||
10094 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */ | |
10095 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10096 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
10097 | {} | |
10098 | }; | |
10099 | ||
10100 | ||
cb53c626 TI |
10101 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
10102 | #define alc262_loopbacks alc880_loopbacks | |
10103 | #endif | |
10104 | ||
df694daa KY |
10105 | /* pcm configuration: identiacal with ALC880 */ |
10106 | #define alc262_pcm_analog_playback alc880_pcm_analog_playback | |
10107 | #define alc262_pcm_analog_capture alc880_pcm_analog_capture | |
10108 | #define alc262_pcm_digital_playback alc880_pcm_digital_playback | |
10109 | #define alc262_pcm_digital_capture alc880_pcm_digital_capture | |
10110 | ||
10111 | /* | |
10112 | * BIOS auto configuration | |
10113 | */ | |
10114 | static int alc262_parse_auto_config(struct hda_codec *codec) | |
10115 | { | |
10116 | struct alc_spec *spec = codec->spec; | |
10117 | int err; | |
10118 | static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; | |
10119 | ||
f12ab1e0 TI |
10120 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
10121 | alc262_ignore); | |
10122 | if (err < 0) | |
df694daa | 10123 | return err; |
f12ab1e0 | 10124 | if (!spec->autocfg.line_outs) |
df694daa | 10125 | return 0; /* can't find valid BIOS pin config */ |
f12ab1e0 TI |
10126 | err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); |
10127 | if (err < 0) | |
10128 | return err; | |
10129 | err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
10130 | if (err < 0) | |
df694daa KY |
10131 | return err; |
10132 | ||
10133 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
10134 | ||
10135 | if (spec->autocfg.dig_out_pin) | |
10136 | spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; | |
10137 | if (spec->autocfg.dig_in_pin) | |
10138 | spec->dig_in_nid = ALC262_DIGIN_NID; | |
10139 | ||
603c4019 | 10140 | if (spec->kctls.list) |
d88897ea | 10141 | add_mixer(spec, spec->kctls.list); |
df694daa | 10142 | |
d88897ea | 10143 | add_verb(spec, alc262_volume_init_verbs); |
a1e8d2da | 10144 | spec->num_mux_defs = 1; |
df694daa KY |
10145 | spec->input_mux = &spec->private_imux; |
10146 | ||
776e184e TI |
10147 | err = alc_auto_add_mic_boost(codec); |
10148 | if (err < 0) | |
10149 | return err; | |
10150 | ||
e044c39a | 10151 | store_pin_configs(codec); |
df694daa KY |
10152 | return 1; |
10153 | } | |
10154 | ||
10155 | #define alc262_auto_init_multi_out alc882_auto_init_multi_out | |
10156 | #define alc262_auto_init_hp_out alc882_auto_init_hp_out | |
10157 | #define alc262_auto_init_analog_input alc882_auto_init_analog_input | |
f511b01c | 10158 | #define alc262_auto_init_input_src alc882_auto_init_input_src |
df694daa KY |
10159 | |
10160 | ||
10161 | /* init callback for auto-configuration model -- overriding the default init */ | |
ae6b813a | 10162 | static void alc262_auto_init(struct hda_codec *codec) |
df694daa | 10163 | { |
f6c7e546 | 10164 | struct alc_spec *spec = codec->spec; |
df694daa KY |
10165 | alc262_auto_init_multi_out(codec); |
10166 | alc262_auto_init_hp_out(codec); | |
10167 | alc262_auto_init_analog_input(codec); | |
f511b01c | 10168 | alc262_auto_init_input_src(codec); |
f6c7e546 | 10169 | if (spec->unsol_event) |
7fb0d78f | 10170 | alc_inithook(codec); |
df694daa KY |
10171 | } |
10172 | ||
10173 | /* | |
10174 | * configuration and preset | |
10175 | */ | |
f5fcc13c TI |
10176 | static const char *alc262_models[ALC262_MODEL_LAST] = { |
10177 | [ALC262_BASIC] = "basic", | |
10178 | [ALC262_HIPPO] = "hippo", | |
10179 | [ALC262_HIPPO_1] = "hippo_1", | |
10180 | [ALC262_FUJITSU] = "fujitsu", | |
10181 | [ALC262_HP_BPC] = "hp-bpc", | |
cd7509a4 | 10182 | [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000", |
61dc35de | 10183 | [ALC262_HP_TC_T5735] = "hp-tc-t5735", |
8c427226 | 10184 | [ALC262_HP_RP5700] = "hp-rp5700", |
f5fcc13c | 10185 | [ALC262_BENQ_ED8] = "benq", |
0f40502e TI |
10186 | [ALC262_BENQ_T31] = "benq-t31", |
10187 | [ALC262_SONY_ASSAMD] = "sony-assamd", | |
2922c9af | 10188 | [ALC262_TOSHIBA_S06] = "toshiba-s06", |
9f99a638 | 10189 | [ALC262_TOSHIBA_RX1] = "toshiba-rx1", |
f651b50b | 10190 | [ALC262_ULTRA] = "ultra", |
0e31daf7 | 10191 | [ALC262_LENOVO_3000] = "lenovo-3000", |
e8f9ae2a | 10192 | [ALC262_NEC] = "nec", |
f5fcc13c TI |
10193 | [ALC262_AUTO] = "auto", |
10194 | }; | |
10195 | ||
10196 | static struct snd_pci_quirk alc262_cfg_tbl[] = { | |
10197 | SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), | |
e8f9ae2a | 10198 | SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC), |
f5fcc13c | 10199 | SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), |
7d87de2d | 10200 | SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC), |
ac3e3741 TI |
10201 | SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC), |
10202 | SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC), | |
7d87de2d | 10203 | SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC), |
b98f9334 | 10204 | SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC), |
b98f9334 | 10205 | SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC), |
b98f9334 | 10206 | SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC), |
cd7509a4 | 10207 | SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10208 | SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 10209 | SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10210 | SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 10211 | SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10212 | SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 | 10213 | SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL), |
cd7509a4 | 10214 | SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF), |
ac3e3741 TI |
10215 | SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC), |
10216 | SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC), | |
10217 | SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC), | |
66d2a9d6 KY |
10218 | SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735", |
10219 | ALC262_HP_TC_T5735), | |
8c427226 | 10220 | SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700), |
ac3e3741 | 10221 | SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
f5fcc13c | 10222 | SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), |
5b31954e | 10223 | SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
272a527c | 10224 | SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
ac3e3741 | 10225 | SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), |
36ca6e13 | 10226 | SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", |
9f99a638 | 10227 | ALC262_TOSHIBA_RX1), |
80ffe869 | 10228 | SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06), |
ac3e3741 | 10229 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), |
3f1eeaed | 10230 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU), |
f651b50b | 10231 | SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA), |
bb9f76cd | 10232 | SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA), |
0e31daf7 | 10233 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000), |
ac3e3741 TI |
10234 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), |
10235 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31), | |
10236 | SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1), | |
df694daa KY |
10237 | {} |
10238 | }; | |
10239 | ||
10240 | static struct alc_config_preset alc262_presets[] = { | |
10241 | [ALC262_BASIC] = { | |
10242 | .mixers = { alc262_base_mixer }, | |
10243 | .init_verbs = { alc262_init_verbs }, | |
10244 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10245 | .dac_nids = alc262_dac_nids, | |
10246 | .hp_nid = 0x03, | |
10247 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10248 | .channel_mode = alc262_modes, | |
a3bcba38 | 10249 | .input_mux = &alc262_capture_source, |
df694daa | 10250 | }, |
ccc656ce KY |
10251 | [ALC262_HIPPO] = { |
10252 | .mixers = { alc262_base_mixer }, | |
10253 | .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, | |
10254 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10255 | .dac_nids = alc262_dac_nids, | |
10256 | .hp_nid = 0x03, | |
10257 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10258 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10259 | .channel_mode = alc262_modes, | |
10260 | .input_mux = &alc262_capture_source, | |
10261 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 10262 | .init_hook = alc262_hippo_automute, |
ccc656ce KY |
10263 | }, |
10264 | [ALC262_HIPPO_1] = { | |
10265 | .mixers = { alc262_hippo1_mixer }, | |
10266 | .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs}, | |
10267 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10268 | .dac_nids = alc262_dac_nids, | |
10269 | .hp_nid = 0x02, | |
10270 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10271 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10272 | .channel_mode = alc262_modes, | |
10273 | .input_mux = &alc262_capture_source, | |
10274 | .unsol_event = alc262_hippo1_unsol_event, | |
5b31954e | 10275 | .init_hook = alc262_hippo1_automute, |
ccc656ce | 10276 | }, |
834be88d TI |
10277 | [ALC262_FUJITSU] = { |
10278 | .mixers = { alc262_fujitsu_mixer }, | |
39d3ed38 TI |
10279 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, |
10280 | alc262_fujitsu_unsol_verbs }, | |
834be88d TI |
10281 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
10282 | .dac_nids = alc262_dac_nids, | |
10283 | .hp_nid = 0x03, | |
10284 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10285 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10286 | .channel_mode = alc262_modes, | |
10287 | .input_mux = &alc262_fujitsu_capture_source, | |
ae6b813a | 10288 | .unsol_event = alc262_fujitsu_unsol_event, |
ebc7a406 | 10289 | .init_hook = alc262_fujitsu_init_hook, |
834be88d | 10290 | }, |
9c7f852e TI |
10291 | [ALC262_HP_BPC] = { |
10292 | .mixers = { alc262_HP_BPC_mixer }, | |
10293 | .init_verbs = { alc262_HP_BPC_init_verbs }, | |
10294 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10295 | .dac_nids = alc262_dac_nids, | |
10296 | .hp_nid = 0x03, | |
10297 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10298 | .channel_mode = alc262_modes, | |
10299 | .input_mux = &alc262_HP_capture_source, | |
ce875f07 TI |
10300 | .unsol_event = alc262_hp_bpc_unsol_event, |
10301 | .init_hook = alc262_hp_bpc_automute, | |
f12ab1e0 | 10302 | }, |
cd7509a4 KY |
10303 | [ALC262_HP_BPC_D7000_WF] = { |
10304 | .mixers = { alc262_HP_BPC_WildWest_mixer }, | |
10305 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
10306 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10307 | .dac_nids = alc262_dac_nids, | |
10308 | .hp_nid = 0x03, | |
10309 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10310 | .channel_mode = alc262_modes, | |
accbe498 | 10311 | .input_mux = &alc262_HP_D7000_capture_source, |
ce875f07 TI |
10312 | .unsol_event = alc262_hp_wildwest_unsol_event, |
10313 | .init_hook = alc262_hp_wildwest_automute, | |
f12ab1e0 | 10314 | }, |
cd7509a4 KY |
10315 | [ALC262_HP_BPC_D7000_WL] = { |
10316 | .mixers = { alc262_HP_BPC_WildWest_mixer, | |
10317 | alc262_HP_BPC_WildWest_option_mixer }, | |
10318 | .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, | |
10319 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10320 | .dac_nids = alc262_dac_nids, | |
10321 | .hp_nid = 0x03, | |
10322 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10323 | .channel_mode = alc262_modes, | |
accbe498 | 10324 | .input_mux = &alc262_HP_D7000_capture_source, |
ce875f07 TI |
10325 | .unsol_event = alc262_hp_wildwest_unsol_event, |
10326 | .init_hook = alc262_hp_wildwest_automute, | |
f12ab1e0 | 10327 | }, |
66d2a9d6 KY |
10328 | [ALC262_HP_TC_T5735] = { |
10329 | .mixers = { alc262_hp_t5735_mixer }, | |
10330 | .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs }, | |
10331 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10332 | .dac_nids = alc262_dac_nids, | |
10333 | .hp_nid = 0x03, | |
10334 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10335 | .channel_mode = alc262_modes, | |
10336 | .input_mux = &alc262_capture_source, | |
10337 | .unsol_event = alc262_hp_t5735_unsol_event, | |
10338 | .init_hook = alc262_hp_t5735_init_hook, | |
8c427226 KY |
10339 | }, |
10340 | [ALC262_HP_RP5700] = { | |
10341 | .mixers = { alc262_hp_rp5700_mixer }, | |
10342 | .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs }, | |
10343 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10344 | .dac_nids = alc262_dac_nids, | |
10345 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10346 | .channel_mode = alc262_modes, | |
10347 | .input_mux = &alc262_hp_rp5700_capture_source, | |
66d2a9d6 | 10348 | }, |
304dcaac TI |
10349 | [ALC262_BENQ_ED8] = { |
10350 | .mixers = { alc262_base_mixer }, | |
10351 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, | |
10352 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10353 | .dac_nids = alc262_dac_nids, | |
10354 | .hp_nid = 0x03, | |
10355 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10356 | .channel_mode = alc262_modes, | |
10357 | .input_mux = &alc262_capture_source, | |
f12ab1e0 | 10358 | }, |
272a527c KY |
10359 | [ALC262_SONY_ASSAMD] = { |
10360 | .mixers = { alc262_sony_mixer }, | |
10361 | .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs}, | |
10362 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10363 | .dac_nids = alc262_dac_nids, | |
10364 | .hp_nid = 0x02, | |
10365 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10366 | .channel_mode = alc262_modes, | |
10367 | .input_mux = &alc262_capture_source, | |
10368 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 10369 | .init_hook = alc262_hippo_automute, |
83c34218 KY |
10370 | }, |
10371 | [ALC262_BENQ_T31] = { | |
10372 | .mixers = { alc262_benq_t31_mixer }, | |
10373 | .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs }, | |
10374 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10375 | .dac_nids = alc262_dac_nids, | |
10376 | .hp_nid = 0x03, | |
10377 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10378 | .channel_mode = alc262_modes, | |
10379 | .input_mux = &alc262_capture_source, | |
10380 | .unsol_event = alc262_hippo_unsol_event, | |
5b31954e | 10381 | .init_hook = alc262_hippo_automute, |
ea1fb29a | 10382 | }, |
f651b50b | 10383 | [ALC262_ULTRA] = { |
f9e336f6 TI |
10384 | .mixers = { alc262_ultra_mixer }, |
10385 | .cap_mixer = alc262_ultra_capture_mixer, | |
bb9f76cd | 10386 | .init_verbs = { alc262_ultra_verbs }, |
f651b50b TD |
10387 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
10388 | .dac_nids = alc262_dac_nids, | |
f651b50b TD |
10389 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
10390 | .channel_mode = alc262_modes, | |
10391 | .input_mux = &alc262_ultra_capture_source, | |
bb9f76cd TI |
10392 | .adc_nids = alc262_adc_nids, /* ADC0 */ |
10393 | .capsrc_nids = alc262_capsrc_nids, | |
10394 | .num_adc_nids = 1, /* single ADC */ | |
f651b50b TD |
10395 | .unsol_event = alc262_ultra_unsol_event, |
10396 | .init_hook = alc262_ultra_automute, | |
10397 | }, | |
0e31daf7 J |
10398 | [ALC262_LENOVO_3000] = { |
10399 | .mixers = { alc262_lenovo_3000_mixer }, | |
10400 | .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs, | |
10401 | alc262_lenovo_3000_unsol_verbs }, | |
10402 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10403 | .dac_nids = alc262_dac_nids, | |
10404 | .hp_nid = 0x03, | |
10405 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10406 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10407 | .channel_mode = alc262_modes, | |
10408 | .input_mux = &alc262_fujitsu_capture_source, | |
10409 | .unsol_event = alc262_lenovo_3000_unsol_event, | |
10410 | }, | |
e8f9ae2a PT |
10411 | [ALC262_NEC] = { |
10412 | .mixers = { alc262_nec_mixer }, | |
10413 | .init_verbs = { alc262_nec_verbs }, | |
10414 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10415 | .dac_nids = alc262_dac_nids, | |
10416 | .hp_nid = 0x03, | |
10417 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10418 | .channel_mode = alc262_modes, | |
10419 | .input_mux = &alc262_capture_source, | |
10420 | }, | |
4e555fe5 KY |
10421 | [ALC262_TOSHIBA_S06] = { |
10422 | .mixers = { alc262_toshiba_s06_mixer }, | |
10423 | .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs, | |
10424 | alc262_eapd_verbs }, | |
10425 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10426 | .capsrc_nids = alc262_dmic_capsrc_nids, | |
10427 | .dac_nids = alc262_dac_nids, | |
10428 | .adc_nids = alc262_dmic_adc_nids, /* ADC0 */ | |
10429 | .dig_out_nid = ALC262_DIGOUT_NID, | |
10430 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10431 | .channel_mode = alc262_modes, | |
10432 | .input_mux = &alc262_dmic_capture_source, | |
10433 | .unsol_event = alc262_toshiba_s06_unsol_event, | |
10434 | .init_hook = alc262_toshiba_s06_init_hook, | |
10435 | }, | |
9f99a638 HM |
10436 | [ALC262_TOSHIBA_RX1] = { |
10437 | .mixers = { alc262_toshiba_rx1_mixer }, | |
10438 | .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs }, | |
10439 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | |
10440 | .dac_nids = alc262_dac_nids, | |
10441 | .hp_nid = 0x03, | |
10442 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | |
10443 | .channel_mode = alc262_modes, | |
10444 | .input_mux = &alc262_capture_source, | |
10445 | .unsol_event = alc262_hippo_unsol_event, | |
10446 | .init_hook = alc262_hippo_automute, | |
10447 | }, | |
df694daa KY |
10448 | }; |
10449 | ||
10450 | static int patch_alc262(struct hda_codec *codec) | |
10451 | { | |
10452 | struct alc_spec *spec; | |
10453 | int board_config; | |
10454 | int err; | |
10455 | ||
dc041e0b | 10456 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
10457 | if (spec == NULL) |
10458 | return -ENOMEM; | |
10459 | ||
10460 | codec->spec = spec; | |
10461 | #if 0 | |
f12ab1e0 TI |
10462 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
10463 | * under-run | |
10464 | */ | |
df694daa KY |
10465 | { |
10466 | int tmp; | |
10467 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
10468 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | |
10469 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); | |
10470 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); | |
10471 | } | |
10472 | #endif | |
10473 | ||
2c3bf9ab TI |
10474 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
10475 | ||
f5fcc13c TI |
10476 | board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST, |
10477 | alc262_models, | |
10478 | alc262_cfg_tbl); | |
cd7509a4 | 10479 | |
f5fcc13c | 10480 | if (board_config < 0) { |
9c7f852e TI |
10481 | printk(KERN_INFO "hda_codec: Unknown model for ALC262, " |
10482 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
10483 | board_config = ALC262_AUTO; |
10484 | } | |
10485 | ||
10486 | if (board_config == ALC262_AUTO) { | |
10487 | /* automatic parse from the BIOS config */ | |
10488 | err = alc262_parse_auto_config(codec); | |
10489 | if (err < 0) { | |
10490 | alc_free(codec); | |
10491 | return err; | |
f12ab1e0 | 10492 | } else if (!err) { |
9c7f852e TI |
10493 | printk(KERN_INFO |
10494 | "hda_codec: Cannot set up configuration " | |
10495 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
10496 | board_config = ALC262_BASIC; |
10497 | } | |
10498 | } | |
10499 | ||
10500 | if (board_config != ALC262_AUTO) | |
10501 | setup_preset(spec, &alc262_presets[board_config]); | |
10502 | ||
10503 | spec->stream_name_analog = "ALC262 Analog"; | |
10504 | spec->stream_analog_playback = &alc262_pcm_analog_playback; | |
10505 | spec->stream_analog_capture = &alc262_pcm_analog_capture; | |
ea1fb29a | 10506 | |
df694daa KY |
10507 | spec->stream_name_digital = "ALC262 Digital"; |
10508 | spec->stream_digital_playback = &alc262_pcm_digital_playback; | |
10509 | spec->stream_digital_capture = &alc262_pcm_digital_capture; | |
10510 | ||
54cbc9ab | 10511 | spec->is_mix_capture = 1; |
f12ab1e0 | 10512 | if (!spec->adc_nids && spec->input_mux) { |
df694daa | 10513 | /* check whether NID 0x07 is valid */ |
4a471b7d TI |
10514 | unsigned int wcap = get_wcaps(codec, 0x07); |
10515 | ||
f12ab1e0 TI |
10516 | /* get type */ |
10517 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
df694daa KY |
10518 | if (wcap != AC_WID_AUD_IN) { |
10519 | spec->adc_nids = alc262_adc_nids_alt; | |
10520 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); | |
88c71a99 | 10521 | spec->capsrc_nids = alc262_capsrc_nids_alt; |
df694daa KY |
10522 | } else { |
10523 | spec->adc_nids = alc262_adc_nids; | |
10524 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); | |
88c71a99 | 10525 | spec->capsrc_nids = alc262_capsrc_nids; |
df694daa KY |
10526 | } |
10527 | } | |
f9e336f6 TI |
10528 | if (!spec->cap_mixer) |
10529 | set_capture_mixer(spec); | |
df694daa | 10530 | |
2134ea4f TI |
10531 | spec->vmaster_nid = 0x0c; |
10532 | ||
df694daa KY |
10533 | codec->patch_ops = alc_patch_ops; |
10534 | if (board_config == ALC262_AUTO) | |
ae6b813a | 10535 | spec->init_hook = alc262_auto_init; |
cb53c626 TI |
10536 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
10537 | if (!spec->loopback.amplist) | |
10538 | spec->loopback.amplist = alc262_loopbacks; | |
10539 | #endif | |
ea1fb29a | 10540 | |
df694daa KY |
10541 | return 0; |
10542 | } | |
10543 | ||
a361d84b KY |
10544 | /* |
10545 | * ALC268 channel source setting (2 channel) | |
10546 | */ | |
10547 | #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID | |
10548 | #define alc268_modes alc260_modes | |
ea1fb29a | 10549 | |
a361d84b KY |
10550 | static hda_nid_t alc268_dac_nids[2] = { |
10551 | /* front, hp */ | |
10552 | 0x02, 0x03 | |
10553 | }; | |
10554 | ||
10555 | static hda_nid_t alc268_adc_nids[2] = { | |
10556 | /* ADC0-1 */ | |
10557 | 0x08, 0x07 | |
10558 | }; | |
10559 | ||
10560 | static hda_nid_t alc268_adc_nids_alt[1] = { | |
10561 | /* ADC0 */ | |
10562 | 0x08 | |
10563 | }; | |
10564 | ||
e1406348 TI |
10565 | static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 }; |
10566 | ||
a361d84b KY |
10567 | static struct snd_kcontrol_new alc268_base_mixer[] = { |
10568 | /* output mixer control */ | |
10569 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
10570 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
10571 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
10572 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
33bf17ab TI |
10573 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
10574 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
10575 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
a361d84b KY |
10576 | { } |
10577 | }; | |
10578 | ||
aef9d318 TI |
10579 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
10580 | static struct hda_bind_ctls alc268_bind_beep_sw = { | |
10581 | .ops = &snd_hda_bind_sw, | |
10582 | .values = { | |
10583 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), | |
10584 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), | |
10585 | 0 | |
10586 | }, | |
10587 | }; | |
10588 | ||
10589 | static struct snd_kcontrol_new alc268_beep_mixer[] = { | |
10590 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), | |
10591 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), | |
10592 | { } | |
10593 | }; | |
10594 | ||
d1a991a6 KY |
10595 | static struct hda_verb alc268_eapd_verbs[] = { |
10596 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
10597 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
10598 | { } | |
10599 | }; | |
10600 | ||
d273809e TI |
10601 | /* Toshiba specific */ |
10602 | #define alc268_toshiba_automute alc262_hippo_automute | |
10603 | ||
10604 | static struct hda_verb alc268_toshiba_verbs[] = { | |
10605 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
10606 | { } /* end */ | |
10607 | }; | |
10608 | ||
8ef355da KY |
10609 | static struct hda_input_mux alc268_acer_lc_capture_source = { |
10610 | .num_items = 2, | |
10611 | .items = { | |
10612 | { "i-Mic", 0x6 }, | |
10613 | { "E-Mic", 0x0 }, | |
10614 | }, | |
10615 | }; | |
10616 | ||
d273809e | 10617 | /* Acer specific */ |
889c4395 | 10618 | /* bind volumes of both NID 0x02 and 0x03 */ |
6bc96857 TI |
10619 | static struct hda_bind_ctls alc268_acer_bind_master_vol = { |
10620 | .ops = &snd_hda_bind_vol, | |
10621 | .values = { | |
10622 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
10623 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
10624 | 0 | |
10625 | }, | |
10626 | }; | |
10627 | ||
889c4395 TI |
10628 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
10629 | static void alc268_acer_automute(struct hda_codec *codec, int force) | |
10630 | { | |
10631 | struct alc_spec *spec = codec->spec; | |
10632 | unsigned int mute; | |
10633 | ||
10634 | if (force || !spec->sense_updated) { | |
10635 | unsigned int present; | |
10636 | present = snd_hda_codec_read(codec, 0x14, 0, | |
10637 | AC_VERB_GET_PIN_SENSE, 0); | |
10638 | spec->jack_present = (present & 0x80000000) != 0; | |
10639 | spec->sense_updated = 1; | |
10640 | } | |
10641 | if (spec->jack_present) | |
10642 | mute = HDA_AMP_MUTE; /* mute internal speaker */ | |
10643 | else /* unmute internal speaker if necessary */ | |
10644 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
10645 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
10646 | HDA_AMP_MUTE, mute); | |
10647 | } | |
10648 | ||
10649 | ||
10650 | /* bind hp and internal speaker mute (with plug check) */ | |
10651 | static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol, | |
10652 | struct snd_ctl_elem_value *ucontrol) | |
10653 | { | |
10654 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
10655 | long *valp = ucontrol->value.integer.value; | |
10656 | int change; | |
10657 | ||
10658 | change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | |
10659 | HDA_AMP_MUTE, | |
10660 | valp[0] ? 0 : HDA_AMP_MUTE); | |
10661 | change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | |
10662 | HDA_AMP_MUTE, | |
10663 | valp[1] ? 0 : HDA_AMP_MUTE); | |
10664 | if (change) | |
10665 | alc268_acer_automute(codec, 0); | |
10666 | return change; | |
10667 | } | |
d273809e | 10668 | |
8ef355da KY |
10669 | static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = { |
10670 | /* output mixer control */ | |
10671 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
10672 | { | |
10673 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10674 | .name = "Master Playback Switch", | |
10675 | .info = snd_hda_mixer_amp_switch_info, | |
10676 | .get = snd_hda_mixer_amp_switch_get, | |
10677 | .put = alc268_acer_master_sw_put, | |
10678 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
10679 | }, | |
10680 | HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT), | |
10681 | { } | |
10682 | }; | |
10683 | ||
d273809e TI |
10684 | static struct snd_kcontrol_new alc268_acer_mixer[] = { |
10685 | /* output mixer control */ | |
10686 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
10687 | { | |
10688 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10689 | .name = "Master Playback Switch", | |
10690 | .info = snd_hda_mixer_amp_switch_info, | |
10691 | .get = snd_hda_mixer_amp_switch_get, | |
10692 | .put = alc268_acer_master_sw_put, | |
10693 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
10694 | }, | |
33bf17ab TI |
10695 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
10696 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
10697 | HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT), | |
d273809e TI |
10698 | { } |
10699 | }; | |
10700 | ||
8ef355da KY |
10701 | static struct hda_verb alc268_acer_aspire_one_verbs[] = { |
10702 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
10703 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
10704 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
10705 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
10706 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x06}, | |
10707 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017}, | |
10708 | { } | |
10709 | }; | |
10710 | ||
d273809e | 10711 | static struct hda_verb alc268_acer_verbs[] = { |
0ccb541c TI |
10712 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */ |
10713 | {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
d273809e TI |
10714 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
10715 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
0ccb541c TI |
10716 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
10717 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
d273809e TI |
10718 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
10719 | { } | |
10720 | }; | |
10721 | ||
10722 | /* unsolicited event for HP jack sensing */ | |
10723 | static void alc268_toshiba_unsol_event(struct hda_codec *codec, | |
10724 | unsigned int res) | |
10725 | { | |
889c4395 | 10726 | if ((res >> 26) != ALC880_HP_EVENT) |
d273809e TI |
10727 | return; |
10728 | alc268_toshiba_automute(codec); | |
10729 | } | |
10730 | ||
10731 | static void alc268_acer_unsol_event(struct hda_codec *codec, | |
10732 | unsigned int res) | |
10733 | { | |
889c4395 | 10734 | if ((res >> 26) != ALC880_HP_EVENT) |
d273809e TI |
10735 | return; |
10736 | alc268_acer_automute(codec, 1); | |
10737 | } | |
10738 | ||
889c4395 TI |
10739 | static void alc268_acer_init_hook(struct hda_codec *codec) |
10740 | { | |
10741 | alc268_acer_automute(codec, 1); | |
10742 | } | |
10743 | ||
8ef355da KY |
10744 | /* toggle speaker-output according to the hp-jack state */ |
10745 | static void alc268_aspire_one_speaker_automute(struct hda_codec *codec) | |
10746 | { | |
10747 | unsigned int present; | |
10748 | unsigned char bits; | |
10749 | ||
10750 | present = snd_hda_codec_read(codec, 0x15, 0, | |
10751 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
10752 | bits = present ? AMP_IN_MUTE(0) : 0; | |
10753 | snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0, | |
10754 | AMP_IN_MUTE(0), bits); | |
10755 | snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1, | |
10756 | AMP_IN_MUTE(0), bits); | |
10757 | } | |
10758 | ||
10759 | ||
10760 | static void alc268_acer_mic_automute(struct hda_codec *codec) | |
10761 | { | |
10762 | unsigned int present; | |
10763 | ||
10764 | present = snd_hda_codec_read(codec, 0x18, 0, | |
10765 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
10766 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL, | |
10767 | present ? 0x0 : 0x6); | |
10768 | } | |
10769 | ||
10770 | static void alc268_acer_lc_unsol_event(struct hda_codec *codec, | |
10771 | unsigned int res) | |
10772 | { | |
10773 | if ((res >> 26) == ALC880_HP_EVENT) | |
10774 | alc268_aspire_one_speaker_automute(codec); | |
10775 | if ((res >> 26) == ALC880_MIC_EVENT) | |
10776 | alc268_acer_mic_automute(codec); | |
10777 | } | |
10778 | ||
10779 | static void alc268_acer_lc_init_hook(struct hda_codec *codec) | |
10780 | { | |
10781 | alc268_aspire_one_speaker_automute(codec); | |
10782 | alc268_acer_mic_automute(codec); | |
10783 | } | |
10784 | ||
3866f0b0 TI |
10785 | static struct snd_kcontrol_new alc268_dell_mixer[] = { |
10786 | /* output mixer control */ | |
10787 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
10788 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
10789 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
10790 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
10791 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
10792 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
10793 | { } | |
10794 | }; | |
10795 | ||
10796 | static struct hda_verb alc268_dell_verbs[] = { | |
10797 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
10798 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
10799 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
10800 | { } | |
10801 | }; | |
10802 | ||
10803 | /* mute/unmute internal speaker according to the hp jack and mute state */ | |
10804 | static void alc268_dell_automute(struct hda_codec *codec) | |
10805 | { | |
10806 | unsigned int present; | |
10807 | unsigned int mute; | |
10808 | ||
10809 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0); | |
10810 | if (present & 0x80000000) | |
10811 | mute = HDA_AMP_MUTE; | |
10812 | else | |
10813 | mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0); | |
10814 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
10815 | HDA_AMP_MUTE, mute); | |
10816 | } | |
10817 | ||
10818 | static void alc268_dell_unsol_event(struct hda_codec *codec, | |
10819 | unsigned int res) | |
10820 | { | |
10821 | if ((res >> 26) != ALC880_HP_EVENT) | |
10822 | return; | |
10823 | alc268_dell_automute(codec); | |
10824 | } | |
10825 | ||
10826 | #define alc268_dell_init_hook alc268_dell_automute | |
10827 | ||
eb5a6621 HRK |
10828 | static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { |
10829 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
10830 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
10831 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT), | |
10832 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
10833 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
10834 | HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT), | |
10835 | HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT), | |
10836 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
10837 | { } | |
10838 | }; | |
10839 | ||
10840 | static struct hda_verb alc267_quanta_il1_verbs[] = { | |
10841 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
10842 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, | |
10843 | { } | |
10844 | }; | |
10845 | ||
10846 | static void alc267_quanta_il1_hp_automute(struct hda_codec *codec) | |
10847 | { | |
10848 | unsigned int present; | |
10849 | ||
10850 | present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0) | |
10851 | & AC_PINSENSE_PRESENCE; | |
10852 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | |
10853 | present ? 0 : PIN_OUT); | |
10854 | } | |
10855 | ||
10856 | static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) | |
10857 | { | |
10858 | unsigned int present; | |
10859 | ||
10860 | present = snd_hda_codec_read(codec, 0x18, 0, | |
10861 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
10862 | snd_hda_codec_write(codec, 0x23, 0, | |
10863 | AC_VERB_SET_CONNECT_SEL, | |
10864 | present ? 0x00 : 0x01); | |
10865 | } | |
10866 | ||
10867 | static void alc267_quanta_il1_automute(struct hda_codec *codec) | |
10868 | { | |
10869 | alc267_quanta_il1_hp_automute(codec); | |
10870 | alc267_quanta_il1_mic_automute(codec); | |
10871 | } | |
10872 | ||
10873 | static void alc267_quanta_il1_unsol_event(struct hda_codec *codec, | |
10874 | unsigned int res) | |
10875 | { | |
10876 | switch (res >> 26) { | |
10877 | case ALC880_HP_EVENT: | |
10878 | alc267_quanta_il1_hp_automute(codec); | |
10879 | break; | |
10880 | case ALC880_MIC_EVENT: | |
10881 | alc267_quanta_il1_mic_automute(codec); | |
10882 | break; | |
10883 | } | |
10884 | } | |
10885 | ||
a361d84b KY |
10886 | /* |
10887 | * generic initialization of ADC, input mixers and output mixers | |
10888 | */ | |
10889 | static struct hda_verb alc268_base_init_verbs[] = { | |
10890 | /* Unmute DAC0-1 and set vol = 0 */ | |
10891 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10892 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10893 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10894 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10895 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10896 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10897 | ||
10898 | /* | |
10899 | * Set up output mixers (0x0c - 0x0e) | |
10900 | */ | |
10901 | /* set vol=0 to output mixers */ | |
10902 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10903 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10904 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10905 | {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10906 | ||
10907 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10908 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10909 | ||
10910 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
10911 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | |
10912 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, | |
10913 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10914 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10915 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10916 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10917 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10918 | ||
10919 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10920 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10921 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10922 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10923 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10924 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10925 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
aef9d318 TI |
10926 | |
10927 | /* set PCBEEP vol = 0, mute connections */ | |
10928 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10929 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10930 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
a361d84b | 10931 | |
a9b3aa8a | 10932 | /* Unmute Selector 23h,24h and set the default input to mic-in */ |
ea1fb29a | 10933 | |
a9b3aa8a JZ |
10934 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x00}, |
10935 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
10936 | {0x24, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
10937 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
a361d84b | 10938 | |
a361d84b KY |
10939 | { } |
10940 | }; | |
10941 | ||
10942 | /* | |
10943 | * generic initialization of ADC, input mixers and output mixers | |
10944 | */ | |
10945 | static struct hda_verb alc268_volume_init_verbs[] = { | |
10946 | /* set output DAC */ | |
10947 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10948 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10949 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10950 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10951 | ||
10952 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10953 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, | |
10954 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10955 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10956 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, | |
10957 | ||
10958 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
10959 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10960 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
10961 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10962 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10963 | ||
10964 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10965 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10966 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10967 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
10968 | ||
aef9d318 TI |
10969 | /* set PCBEEP vol = 0, mute connections */ |
10970 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
10971 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
10972 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
a361d84b KY |
10973 | |
10974 | { } | |
10975 | }; | |
10976 | ||
a361d84b KY |
10977 | static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { |
10978 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
10979 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
10980 | { | |
10981 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
10982 | /* The multiple "Capture Source" controls confuse alsamixer | |
10983 | * So call somewhat different.. | |
a361d84b KY |
10984 | */ |
10985 | /* .name = "Capture Source", */ | |
10986 | .name = "Input Source", | |
10987 | .count = 1, | |
54cbc9ab TI |
10988 | .info = alc_mux_enum_info, |
10989 | .get = alc_mux_enum_get, | |
10990 | .put = alc_mux_enum_put, | |
a361d84b KY |
10991 | }, |
10992 | { } /* end */ | |
10993 | }; | |
10994 | ||
10995 | static struct snd_kcontrol_new alc268_capture_mixer[] = { | |
10996 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | |
10997 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | |
10998 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), | |
10999 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), | |
11000 | { | |
11001 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11002 | /* The multiple "Capture Source" controls confuse alsamixer | |
11003 | * So call somewhat different.. | |
a361d84b KY |
11004 | */ |
11005 | /* .name = "Capture Source", */ | |
11006 | .name = "Input Source", | |
11007 | .count = 2, | |
54cbc9ab TI |
11008 | .info = alc_mux_enum_info, |
11009 | .get = alc_mux_enum_get, | |
11010 | .put = alc_mux_enum_put, | |
a361d84b KY |
11011 | }, |
11012 | { } /* end */ | |
11013 | }; | |
11014 | ||
11015 | static struct hda_input_mux alc268_capture_source = { | |
11016 | .num_items = 4, | |
11017 | .items = { | |
11018 | { "Mic", 0x0 }, | |
11019 | { "Front Mic", 0x1 }, | |
11020 | { "Line", 0x2 }, | |
11021 | { "CD", 0x3 }, | |
11022 | }, | |
11023 | }; | |
11024 | ||
0ccb541c TI |
11025 | static struct hda_input_mux alc268_acer_capture_source = { |
11026 | .num_items = 3, | |
11027 | .items = { | |
11028 | { "Mic", 0x0 }, | |
11029 | { "Internal Mic", 0x6 }, | |
11030 | { "Line", 0x2 }, | |
11031 | }, | |
11032 | }; | |
11033 | ||
86c53bd2 JW |
11034 | #ifdef CONFIG_SND_DEBUG |
11035 | static struct snd_kcontrol_new alc268_test_mixer[] = { | |
86c53bd2 JW |
11036 | /* Volume widgets */ |
11037 | HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11038 | HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
11039 | HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
11040 | HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT), | |
11041 | HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT), | |
11042 | HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT), | |
11043 | HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT), | |
11044 | HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT), | |
11045 | HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT), | |
11046 | HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT), | |
11047 | HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT), | |
11048 | HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT), | |
11049 | HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT), | |
f0747ee6 TI |
11050 | /* The below appears problematic on some hardwares */ |
11051 | /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/ | |
86c53bd2 JW |
11052 | HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT), |
11053 | HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT), | |
11054 | HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT), | |
11055 | HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT), | |
11056 | ||
11057 | /* Modes for retasking pin widgets */ | |
11058 | ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT), | |
11059 | ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT), | |
11060 | ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT), | |
11061 | ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT), | |
11062 | ||
11063 | /* Controls for GPIO pins, assuming they are configured as outputs */ | |
11064 | ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01), | |
11065 | ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02), | |
11066 | ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04), | |
11067 | ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08), | |
11068 | ||
11069 | /* Switches to allow the digital SPDIF output pin to be enabled. | |
11070 | * The ALC268 does not have an SPDIF input. | |
11071 | */ | |
11072 | ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01), | |
11073 | ||
11074 | /* A switch allowing EAPD to be enabled. Some laptops seem to use | |
11075 | * this output to turn on an external amplifier. | |
11076 | */ | |
11077 | ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02), | |
11078 | ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02), | |
11079 | ||
11080 | { } /* end */ | |
11081 | }; | |
11082 | #endif | |
11083 | ||
a361d84b KY |
11084 | /* create input playback/capture controls for the given pin */ |
11085 | static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |
11086 | const char *ctlname, int idx) | |
11087 | { | |
11088 | char name[32]; | |
11089 | int err; | |
11090 | ||
11091 | sprintf(name, "%s Playback Volume", ctlname); | |
11092 | if (nid == 0x14) { | |
11093 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
11094 | HDA_COMPOSE_AMP_VAL(0x02, 3, idx, | |
11095 | HDA_OUTPUT)); | |
11096 | if (err < 0) | |
11097 | return err; | |
11098 | } else if (nid == 0x15) { | |
11099 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
11100 | HDA_COMPOSE_AMP_VAL(0x03, 3, idx, | |
11101 | HDA_OUTPUT)); | |
11102 | if (err < 0) | |
11103 | return err; | |
11104 | } else | |
11105 | return -1; | |
11106 | sprintf(name, "%s Playback Switch", ctlname); | |
11107 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
11108 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); | |
11109 | if (err < 0) | |
11110 | return err; | |
11111 | return 0; | |
11112 | } | |
11113 | ||
11114 | /* add playback controls from the parsed DAC table */ | |
11115 | static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |
11116 | const struct auto_pin_cfg *cfg) | |
11117 | { | |
11118 | hda_nid_t nid; | |
11119 | int err; | |
11120 | ||
11121 | spec->multiout.num_dacs = 2; /* only use one dac */ | |
11122 | spec->multiout.dac_nids = spec->private_dac_nids; | |
11123 | spec->multiout.dac_nids[0] = 2; | |
11124 | spec->multiout.dac_nids[1] = 3; | |
11125 | ||
11126 | nid = cfg->line_out_pins[0]; | |
11127 | if (nid) | |
ea1fb29a | 11128 | alc268_new_analog_output(spec, nid, "Front", 0); |
a361d84b KY |
11129 | |
11130 | nid = cfg->speaker_pins[0]; | |
11131 | if (nid == 0x1d) { | |
11132 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
11133 | "Speaker Playback Volume", | |
11134 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | |
11135 | if (err < 0) | |
11136 | return err; | |
11137 | } | |
11138 | nid = cfg->hp_pins[0]; | |
11139 | if (nid) | |
11140 | alc268_new_analog_output(spec, nid, "Headphone", 0); | |
11141 | ||
11142 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; | |
11143 | if (nid == 0x16) { | |
11144 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
11145 | "Mono Playback Switch", | |
11146 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT)); | |
11147 | if (err < 0) | |
11148 | return err; | |
11149 | } | |
ea1fb29a | 11150 | return 0; |
a361d84b KY |
11151 | } |
11152 | ||
11153 | /* create playback/capture controls for input pins */ | |
11154 | static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, | |
11155 | const struct auto_pin_cfg *cfg) | |
11156 | { | |
11157 | struct hda_input_mux *imux = &spec->private_imux; | |
11158 | int i, idx1; | |
11159 | ||
11160 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
11161 | switch(cfg->input_pins[i]) { | |
11162 | case 0x18: | |
11163 | idx1 = 0; /* Mic 1 */ | |
11164 | break; | |
11165 | case 0x19: | |
11166 | idx1 = 1; /* Mic 2 */ | |
11167 | break; | |
11168 | case 0x1a: | |
11169 | idx1 = 2; /* Line In */ | |
11170 | break; | |
ea1fb29a | 11171 | case 0x1c: |
a361d84b KY |
11172 | idx1 = 3; /* CD */ |
11173 | break; | |
7194cae6 TI |
11174 | case 0x12: |
11175 | case 0x13: | |
11176 | idx1 = 6; /* digital mics */ | |
11177 | break; | |
a361d84b KY |
11178 | default: |
11179 | continue; | |
11180 | } | |
11181 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | |
11182 | imux->items[imux->num_items].index = idx1; | |
ea1fb29a | 11183 | imux->num_items++; |
a361d84b KY |
11184 | } |
11185 | return 0; | |
11186 | } | |
11187 | ||
11188 | static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) | |
11189 | { | |
11190 | struct alc_spec *spec = codec->spec; | |
11191 | hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0]; | |
11192 | hda_nid_t hp_nid = spec->autocfg.hp_pins[0]; | |
11193 | hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; | |
11194 | unsigned int dac_vol1, dac_vol2; | |
11195 | ||
11196 | if (speaker_nid) { | |
11197 | snd_hda_codec_write(codec, speaker_nid, 0, | |
11198 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
11199 | snd_hda_codec_write(codec, 0x0f, 0, | |
11200 | AC_VERB_SET_AMP_GAIN_MUTE, | |
11201 | AMP_IN_UNMUTE(1)); | |
11202 | snd_hda_codec_write(codec, 0x10, 0, | |
11203 | AC_VERB_SET_AMP_GAIN_MUTE, | |
11204 | AMP_IN_UNMUTE(1)); | |
11205 | } else { | |
11206 | snd_hda_codec_write(codec, 0x0f, 0, | |
11207 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
11208 | snd_hda_codec_write(codec, 0x10, 0, | |
11209 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | |
11210 | } | |
11211 | ||
11212 | dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */ | |
ea1fb29a | 11213 | if (line_nid == 0x14) |
a361d84b KY |
11214 | dac_vol2 = AMP_OUT_ZERO; |
11215 | else if (line_nid == 0x15) | |
11216 | dac_vol1 = AMP_OUT_ZERO; | |
ea1fb29a | 11217 | if (hp_nid == 0x14) |
a361d84b KY |
11218 | dac_vol2 = AMP_OUT_ZERO; |
11219 | else if (hp_nid == 0x15) | |
11220 | dac_vol1 = AMP_OUT_ZERO; | |
11221 | if (line_nid != 0x16 || hp_nid != 0x16 || | |
11222 | spec->autocfg.line_out_pins[1] != 0x16 || | |
11223 | spec->autocfg.line_out_pins[2] != 0x16) | |
11224 | dac_vol1 = dac_vol2 = AMP_OUT_ZERO; | |
11225 | ||
11226 | snd_hda_codec_write(codec, 0x02, 0, | |
11227 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1); | |
11228 | snd_hda_codec_write(codec, 0x03, 0, | |
11229 | AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2); | |
11230 | } | |
11231 | ||
11232 | /* pcm configuration: identiacal with ALC880 */ | |
11233 | #define alc268_pcm_analog_playback alc880_pcm_analog_playback | |
11234 | #define alc268_pcm_analog_capture alc880_pcm_analog_capture | |
6330079f | 11235 | #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture |
a361d84b KY |
11236 | #define alc268_pcm_digital_playback alc880_pcm_digital_playback |
11237 | ||
11238 | /* | |
11239 | * BIOS auto configuration | |
11240 | */ | |
11241 | static int alc268_parse_auto_config(struct hda_codec *codec) | |
11242 | { | |
11243 | struct alc_spec *spec = codec->spec; | |
11244 | int err; | |
11245 | static hda_nid_t alc268_ignore[] = { 0 }; | |
11246 | ||
11247 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
11248 | alc268_ignore); | |
11249 | if (err < 0) | |
11250 | return err; | |
11251 | if (!spec->autocfg.line_outs) | |
11252 | return 0; /* can't find valid BIOS pin config */ | |
11253 | ||
11254 | err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
11255 | if (err < 0) | |
11256 | return err; | |
11257 | err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
11258 | if (err < 0) | |
11259 | return err; | |
11260 | ||
11261 | spec->multiout.max_channels = 2; | |
11262 | ||
11263 | /* digital only support output */ | |
11264 | if (spec->autocfg.dig_out_pin) | |
11265 | spec->multiout.dig_out_nid = ALC268_DIGOUT_NID; | |
11266 | ||
603c4019 | 11267 | if (spec->kctls.list) |
d88897ea | 11268 | add_mixer(spec, spec->kctls.list); |
a361d84b | 11269 | |
aef9d318 | 11270 | if (spec->autocfg.speaker_pins[0] != 0x1d) |
d88897ea | 11271 | add_mixer(spec, alc268_beep_mixer); |
aef9d318 | 11272 | |
d88897ea | 11273 | add_verb(spec, alc268_volume_init_verbs); |
a361d84b KY |
11274 | spec->num_mux_defs = 1; |
11275 | spec->input_mux = &spec->private_imux; | |
11276 | ||
776e184e TI |
11277 | err = alc_auto_add_mic_boost(codec); |
11278 | if (err < 0) | |
11279 | return err; | |
11280 | ||
e044c39a | 11281 | store_pin_configs(codec); |
a361d84b KY |
11282 | return 1; |
11283 | } | |
11284 | ||
11285 | #define alc268_auto_init_multi_out alc882_auto_init_multi_out | |
11286 | #define alc268_auto_init_hp_out alc882_auto_init_hp_out | |
11287 | #define alc268_auto_init_analog_input alc882_auto_init_analog_input | |
11288 | ||
11289 | /* init callback for auto-configuration model -- overriding the default init */ | |
11290 | static void alc268_auto_init(struct hda_codec *codec) | |
11291 | { | |
f6c7e546 | 11292 | struct alc_spec *spec = codec->spec; |
a361d84b KY |
11293 | alc268_auto_init_multi_out(codec); |
11294 | alc268_auto_init_hp_out(codec); | |
11295 | alc268_auto_init_mono_speaker_out(codec); | |
11296 | alc268_auto_init_analog_input(codec); | |
f6c7e546 | 11297 | if (spec->unsol_event) |
7fb0d78f | 11298 | alc_inithook(codec); |
a361d84b KY |
11299 | } |
11300 | ||
11301 | /* | |
11302 | * configuration and preset | |
11303 | */ | |
11304 | static const char *alc268_models[ALC268_MODEL_LAST] = { | |
eb5a6621 | 11305 | [ALC267_QUANTA_IL1] = "quanta-il1", |
a361d84b | 11306 | [ALC268_3ST] = "3stack", |
983f8ae4 | 11307 | [ALC268_TOSHIBA] = "toshiba", |
d273809e | 11308 | [ALC268_ACER] = "acer", |
8ef355da | 11309 | [ALC268_ACER_ASPIRE_ONE] = "acer-aspire", |
3866f0b0 | 11310 | [ALC268_DELL] = "dell", |
f12462c5 | 11311 | [ALC268_ZEPTO] = "zepto", |
86c53bd2 JW |
11312 | #ifdef CONFIG_SND_DEBUG |
11313 | [ALC268_TEST] = "test", | |
11314 | #endif | |
a361d84b KY |
11315 | [ALC268_AUTO] = "auto", |
11316 | }; | |
11317 | ||
11318 | static struct snd_pci_quirk alc268_cfg_tbl[] = { | |
a0b8f7d8 | 11319 | SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER), |
ac3e3741 | 11320 | SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER), |
dafc8357 | 11321 | SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER), |
ac3e3741 | 11322 | SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER), |
29a52c24 | 11323 | SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER), |
8ef355da KY |
11324 | SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One", |
11325 | ALC268_ACER_ASPIRE_ONE), | |
3866f0b0 | 11326 | SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), |
ac3e3741 | 11327 | SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA), |
a361d84b | 11328 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), |
d1a991a6 | 11329 | SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), |
8e7f00f9 | 11330 | SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA), |
2346d0cd | 11331 | SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA), |
378bd6a5 | 11332 | SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), |
b875bf3a | 11333 | SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), |
eb5a6621 | 11334 | SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), |
f12462c5 | 11335 | SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), |
a361d84b KY |
11336 | {} |
11337 | }; | |
11338 | ||
11339 | static struct alc_config_preset alc268_presets[] = { | |
eb5a6621 HRK |
11340 | [ALC267_QUANTA_IL1] = { |
11341 | .mixers = { alc267_quanta_il1_mixer }, | |
11342 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
11343 | alc267_quanta_il1_verbs }, | |
11344 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11345 | .dac_nids = alc268_dac_nids, | |
11346 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11347 | .adc_nids = alc268_adc_nids_alt, | |
11348 | .hp_nid = 0x03, | |
11349 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11350 | .channel_mode = alc268_modes, | |
11351 | .input_mux = &alc268_capture_source, | |
11352 | .unsol_event = alc267_quanta_il1_unsol_event, | |
11353 | .init_hook = alc267_quanta_il1_automute, | |
11354 | }, | |
a361d84b | 11355 | [ALC268_3ST] = { |
aef9d318 TI |
11356 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
11357 | alc268_beep_mixer }, | |
a361d84b KY |
11358 | .init_verbs = { alc268_base_init_verbs }, |
11359 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11360 | .dac_nids = alc268_dac_nids, | |
11361 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11362 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11363 | .capsrc_nids = alc268_capsrc_nids, |
a361d84b KY |
11364 | .hp_nid = 0x03, |
11365 | .dig_out_nid = ALC268_DIGOUT_NID, | |
11366 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11367 | .channel_mode = alc268_modes, | |
11368 | .input_mux = &alc268_capture_source, | |
11369 | }, | |
d1a991a6 | 11370 | [ALC268_TOSHIBA] = { |
aef9d318 TI |
11371 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
11372 | alc268_beep_mixer }, | |
d273809e TI |
11373 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11374 | alc268_toshiba_verbs }, | |
d1a991a6 KY |
11375 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), |
11376 | .dac_nids = alc268_dac_nids, | |
11377 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11378 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11379 | .capsrc_nids = alc268_capsrc_nids, |
d1a991a6 KY |
11380 | .hp_nid = 0x03, |
11381 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11382 | .channel_mode = alc268_modes, | |
11383 | .input_mux = &alc268_capture_source, | |
d273809e TI |
11384 | .unsol_event = alc268_toshiba_unsol_event, |
11385 | .init_hook = alc268_toshiba_automute, | |
11386 | }, | |
11387 | [ALC268_ACER] = { | |
aef9d318 TI |
11388 | .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer, |
11389 | alc268_beep_mixer }, | |
d273809e TI |
11390 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11391 | alc268_acer_verbs }, | |
11392 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11393 | .dac_nids = alc268_dac_nids, | |
11394 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11395 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11396 | .capsrc_nids = alc268_capsrc_nids, |
d273809e TI |
11397 | .hp_nid = 0x02, |
11398 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11399 | .channel_mode = alc268_modes, | |
0ccb541c | 11400 | .input_mux = &alc268_acer_capture_source, |
d273809e | 11401 | .unsol_event = alc268_acer_unsol_event, |
889c4395 | 11402 | .init_hook = alc268_acer_init_hook, |
d1a991a6 | 11403 | }, |
8ef355da KY |
11404 | [ALC268_ACER_ASPIRE_ONE] = { |
11405 | .mixers = { alc268_acer_aspire_one_mixer, | |
11406 | alc268_capture_alt_mixer }, | |
11407 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
11408 | alc268_acer_aspire_one_verbs }, | |
11409 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11410 | .dac_nids = alc268_dac_nids, | |
11411 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11412 | .adc_nids = alc268_adc_nids_alt, | |
11413 | .capsrc_nids = alc268_capsrc_nids, | |
11414 | .hp_nid = 0x03, | |
11415 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11416 | .channel_mode = alc268_modes, | |
11417 | .input_mux = &alc268_acer_lc_capture_source, | |
11418 | .unsol_event = alc268_acer_lc_unsol_event, | |
11419 | .init_hook = alc268_acer_lc_init_hook, | |
11420 | }, | |
3866f0b0 | 11421 | [ALC268_DELL] = { |
aef9d318 | 11422 | .mixers = { alc268_dell_mixer, alc268_beep_mixer }, |
3866f0b0 TI |
11423 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11424 | alc268_dell_verbs }, | |
11425 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11426 | .dac_nids = alc268_dac_nids, | |
11427 | .hp_nid = 0x02, | |
11428 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11429 | .channel_mode = alc268_modes, | |
11430 | .unsol_event = alc268_dell_unsol_event, | |
11431 | .init_hook = alc268_dell_init_hook, | |
11432 | .input_mux = &alc268_capture_source, | |
11433 | }, | |
f12462c5 | 11434 | [ALC268_ZEPTO] = { |
aef9d318 TI |
11435 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
11436 | alc268_beep_mixer }, | |
f12462c5 MT |
11437 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
11438 | alc268_toshiba_verbs }, | |
11439 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11440 | .dac_nids = alc268_dac_nids, | |
11441 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11442 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11443 | .capsrc_nids = alc268_capsrc_nids, |
f12462c5 MT |
11444 | .hp_nid = 0x03, |
11445 | .dig_out_nid = ALC268_DIGOUT_NID, | |
11446 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11447 | .channel_mode = alc268_modes, | |
11448 | .input_mux = &alc268_capture_source, | |
11449 | .unsol_event = alc268_toshiba_unsol_event, | |
11450 | .init_hook = alc268_toshiba_automute | |
11451 | }, | |
86c53bd2 JW |
11452 | #ifdef CONFIG_SND_DEBUG |
11453 | [ALC268_TEST] = { | |
11454 | .mixers = { alc268_test_mixer, alc268_capture_mixer }, | |
11455 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | |
11456 | alc268_volume_init_verbs }, | |
11457 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | |
11458 | .dac_nids = alc268_dac_nids, | |
11459 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | |
11460 | .adc_nids = alc268_adc_nids_alt, | |
e1406348 | 11461 | .capsrc_nids = alc268_capsrc_nids, |
86c53bd2 JW |
11462 | .hp_nid = 0x03, |
11463 | .dig_out_nid = ALC268_DIGOUT_NID, | |
11464 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | |
11465 | .channel_mode = alc268_modes, | |
11466 | .input_mux = &alc268_capture_source, | |
11467 | }, | |
11468 | #endif | |
a361d84b KY |
11469 | }; |
11470 | ||
11471 | static int patch_alc268(struct hda_codec *codec) | |
11472 | { | |
11473 | struct alc_spec *spec; | |
11474 | int board_config; | |
11475 | int err; | |
11476 | ||
11477 | spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); | |
11478 | if (spec == NULL) | |
11479 | return -ENOMEM; | |
11480 | ||
11481 | codec->spec = spec; | |
11482 | ||
11483 | board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST, | |
11484 | alc268_models, | |
11485 | alc268_cfg_tbl); | |
11486 | ||
11487 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { | |
11488 | printk(KERN_INFO "hda_codec: Unknown model for ALC268, " | |
11489 | "trying auto-probe from BIOS...\n"); | |
11490 | board_config = ALC268_AUTO; | |
11491 | } | |
11492 | ||
11493 | if (board_config == ALC268_AUTO) { | |
11494 | /* automatic parse from the BIOS config */ | |
11495 | err = alc268_parse_auto_config(codec); | |
11496 | if (err < 0) { | |
11497 | alc_free(codec); | |
11498 | return err; | |
11499 | } else if (!err) { | |
11500 | printk(KERN_INFO | |
11501 | "hda_codec: Cannot set up configuration " | |
11502 | "from BIOS. Using base mode...\n"); | |
11503 | board_config = ALC268_3ST; | |
11504 | } | |
11505 | } | |
11506 | ||
11507 | if (board_config != ALC268_AUTO) | |
11508 | setup_preset(spec, &alc268_presets[board_config]); | |
11509 | ||
2f893286 KY |
11510 | if (codec->vendor_id == 0x10ec0267) { |
11511 | spec->stream_name_analog = "ALC267 Analog"; | |
11512 | spec->stream_name_digital = "ALC267 Digital"; | |
11513 | } else { | |
11514 | spec->stream_name_analog = "ALC268 Analog"; | |
11515 | spec->stream_name_digital = "ALC268 Digital"; | |
11516 | } | |
11517 | ||
a361d84b KY |
11518 | spec->stream_analog_playback = &alc268_pcm_analog_playback; |
11519 | spec->stream_analog_capture = &alc268_pcm_analog_capture; | |
6330079f | 11520 | spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture; |
a361d84b | 11521 | |
a361d84b KY |
11522 | spec->stream_digital_playback = &alc268_pcm_digital_playback; |
11523 | ||
aef9d318 TI |
11524 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
11525 | /* override the amp caps for beep generator */ | |
11526 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, | |
11527 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | | |
11528 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
11529 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
11530 | (0 << AC_AMPCAP_MUTE_SHIFT)); | |
11531 | ||
3866f0b0 TI |
11532 | if (!spec->adc_nids && spec->input_mux) { |
11533 | /* check whether NID 0x07 is valid */ | |
11534 | unsigned int wcap = get_wcaps(codec, 0x07); | |
85860c06 | 11535 | int i; |
3866f0b0 TI |
11536 | |
11537 | /* get type */ | |
11538 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
67ebcb03 | 11539 | if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { |
3866f0b0 TI |
11540 | spec->adc_nids = alc268_adc_nids_alt; |
11541 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); | |
d88897ea | 11542 | add_mixer(spec, alc268_capture_alt_mixer); |
3866f0b0 TI |
11543 | } else { |
11544 | spec->adc_nids = alc268_adc_nids; | |
11545 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids); | |
d88897ea | 11546 | add_mixer(spec, alc268_capture_mixer); |
a361d84b | 11547 | } |
e1406348 | 11548 | spec->capsrc_nids = alc268_capsrc_nids; |
85860c06 TI |
11549 | /* set default input source */ |
11550 | for (i = 0; i < spec->num_adc_nids; i++) | |
11551 | snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i], | |
11552 | 0, AC_VERB_SET_CONNECT_SEL, | |
11553 | spec->input_mux->items[0].index); | |
a361d84b | 11554 | } |
2134ea4f TI |
11555 | |
11556 | spec->vmaster_nid = 0x02; | |
11557 | ||
a361d84b KY |
11558 | codec->patch_ops = alc_patch_ops; |
11559 | if (board_config == ALC268_AUTO) | |
11560 | spec->init_hook = alc268_auto_init; | |
ea1fb29a | 11561 | |
a361d84b KY |
11562 | return 0; |
11563 | } | |
11564 | ||
f6a92248 KY |
11565 | /* |
11566 | * ALC269 channel source setting (2 channel) | |
11567 | */ | |
11568 | #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID | |
11569 | ||
11570 | #define alc269_dac_nids alc260_dac_nids | |
11571 | ||
11572 | static hda_nid_t alc269_adc_nids[1] = { | |
11573 | /* ADC1 */ | |
f53281e6 KY |
11574 | 0x08, |
11575 | }; | |
11576 | ||
e01bf509 TI |
11577 | static hda_nid_t alc269_capsrc_nids[1] = { |
11578 | 0x23, | |
11579 | }; | |
11580 | ||
11581 | /* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24), | |
11582 | * not a mux! | |
11583 | */ | |
11584 | ||
f53281e6 KY |
11585 | static struct hda_input_mux alc269_eeepc_dmic_capture_source = { |
11586 | .num_items = 2, | |
11587 | .items = { | |
11588 | { "i-Mic", 0x5 }, | |
11589 | { "e-Mic", 0x0 }, | |
11590 | }, | |
11591 | }; | |
11592 | ||
11593 | static struct hda_input_mux alc269_eeepc_amic_capture_source = { | |
11594 | .num_items = 2, | |
11595 | .items = { | |
11596 | { "i-Mic", 0x1 }, | |
11597 | { "e-Mic", 0x0 }, | |
11598 | }, | |
f6a92248 KY |
11599 | }; |
11600 | ||
11601 | #define alc269_modes alc260_modes | |
11602 | #define alc269_capture_source alc880_lg_lw_capture_source | |
11603 | ||
11604 | static struct snd_kcontrol_new alc269_base_mixer[] = { | |
11605 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
11606 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
11607 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
11608 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
11609 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
11610 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
2005af24 TI |
11611 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT), |
11612 | HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
f6a92248 KY |
11613 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
11614 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
11615 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
11616 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
11617 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
11618 | HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), | |
11619 | { } /* end */ | |
11620 | }; | |
11621 | ||
60db6b53 KY |
11622 | static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = { |
11623 | /* output mixer control */ | |
11624 | HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol), | |
11625 | { | |
11626 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
11627 | .name = "Master Playback Switch", | |
11628 | .info = snd_hda_mixer_amp_switch_info, | |
11629 | .get = snd_hda_mixer_amp_switch_get, | |
11630 | .put = alc268_acer_master_sw_put, | |
11631 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
11632 | }, | |
11633 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
11634 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
11635 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
11636 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), | |
11637 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), | |
11638 | HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), | |
11639 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
11640 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
11641 | { } | |
11642 | }; | |
11643 | ||
f53281e6 KY |
11644 | /* bind volumes of both NID 0x0c and 0x0d */ |
11645 | static struct hda_bind_ctls alc269_epc_bind_vol = { | |
11646 | .ops = &snd_hda_bind_vol, | |
11647 | .values = { | |
11648 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
11649 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
11650 | 0 | |
11651 | }, | |
11652 | }; | |
11653 | ||
11654 | static struct snd_kcontrol_new alc269_eeepc_mixer[] = { | |
11655 | HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
11656 | HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol), | |
11657 | HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
11658 | { } /* end */ | |
11659 | }; | |
11660 | ||
f53281e6 KY |
11661 | /* capture mixer elements */ |
11662 | static struct snd_kcontrol_new alc269_epc_capture_mixer[] = { | |
11663 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | |
11664 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | |
11665 | { } /* end */ | |
11666 | }; | |
11667 | ||
2005af24 TI |
11668 | /* beep control */ |
11669 | static struct snd_kcontrol_new alc269_beep_mixer[] = { | |
11670 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT), | |
11671 | HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT), | |
11672 | { } /* end */ | |
11673 | }; | |
11674 | ||
60db6b53 KY |
11675 | static struct hda_verb alc269_quanta_fl1_verbs[] = { |
11676 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
11677 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11678 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
11679 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | |
11680 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
11681 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11682 | { } | |
11683 | }; | |
f6a92248 | 11684 | |
60db6b53 KY |
11685 | /* toggle speaker-output according to the hp-jack state */ |
11686 | static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec) | |
11687 | { | |
11688 | unsigned int present; | |
11689 | unsigned char bits; | |
f6a92248 | 11690 | |
60db6b53 KY |
11691 | present = snd_hda_codec_read(codec, 0x15, 0, |
11692 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
11693 | bits = present ? AMP_IN_MUTE(0) : 0; | |
11694 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
11695 | AMP_IN_MUTE(0), bits); | |
11696 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
11697 | AMP_IN_MUTE(0), bits); | |
f6a92248 | 11698 | |
60db6b53 KY |
11699 | snd_hda_codec_write(codec, 0x20, 0, |
11700 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
11701 | snd_hda_codec_write(codec, 0x20, 0, | |
11702 | AC_VERB_SET_PROC_COEF, 0x680); | |
f6a92248 | 11703 | |
60db6b53 KY |
11704 | snd_hda_codec_write(codec, 0x20, 0, |
11705 | AC_VERB_SET_COEF_INDEX, 0x0c); | |
11706 | snd_hda_codec_write(codec, 0x20, 0, | |
11707 | AC_VERB_SET_PROC_COEF, 0x480); | |
11708 | } | |
f6a92248 | 11709 | |
60db6b53 KY |
11710 | static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec) |
11711 | { | |
11712 | unsigned int present; | |
f6a92248 | 11713 | |
60db6b53 KY |
11714 | present = snd_hda_codec_read(codec, 0x18, 0, |
11715 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
11716 | snd_hda_codec_write(codec, 0x23, 0, | |
11717 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1); | |
11718 | } | |
f6a92248 | 11719 | |
60db6b53 KY |
11720 | static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec, |
11721 | unsigned int res) | |
11722 | { | |
11723 | if ((res >> 26) == ALC880_HP_EVENT) | |
11724 | alc269_quanta_fl1_speaker_automute(codec); | |
11725 | if ((res >> 26) == ALC880_MIC_EVENT) | |
11726 | alc269_quanta_fl1_mic_automute(codec); | |
11727 | } | |
f6a92248 | 11728 | |
60db6b53 KY |
11729 | static void alc269_quanta_fl1_init_hook(struct hda_codec *codec) |
11730 | { | |
11731 | alc269_quanta_fl1_speaker_automute(codec); | |
11732 | alc269_quanta_fl1_mic_automute(codec); | |
11733 | } | |
f6a92248 | 11734 | |
f53281e6 KY |
11735 | static struct hda_verb alc269_eeepc_dmic_init_verbs[] = { |
11736 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
11737 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x05}, | |
11738 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, | |
11739 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))}, | |
11740 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11741 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
11742 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
11743 | {} | |
11744 | }; | |
11745 | ||
11746 | static struct hda_verb alc269_eeepc_amic_init_verbs[] = { | |
11747 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
11748 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
11749 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, | |
11750 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))}, | |
11751 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
11752 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
11753 | {} | |
11754 | }; | |
11755 | ||
11756 | /* toggle speaker-output according to the hp-jack state */ | |
11757 | static void alc269_speaker_automute(struct hda_codec *codec) | |
11758 | { | |
11759 | unsigned int present; | |
60db6b53 | 11760 | unsigned char bits; |
f53281e6 KY |
11761 | |
11762 | present = snd_hda_codec_read(codec, 0x15, 0, | |
60db6b53 | 11763 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; |
f53281e6 KY |
11764 | bits = present ? AMP_IN_MUTE(0) : 0; |
11765 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
60db6b53 | 11766 | AMP_IN_MUTE(0), bits); |
f53281e6 | 11767 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, |
60db6b53 | 11768 | AMP_IN_MUTE(0), bits); |
f53281e6 KY |
11769 | } |
11770 | ||
11771 | static void alc269_eeepc_dmic_automute(struct hda_codec *codec) | |
11772 | { | |
11773 | unsigned int present; | |
11774 | ||
60db6b53 KY |
11775 | present = snd_hda_codec_read(codec, 0x18, 0, |
11776 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
11777 | snd_hda_codec_write(codec, 0x23, 0, | |
11778 | AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5)); | |
f53281e6 KY |
11779 | } |
11780 | ||
11781 | static void alc269_eeepc_amic_automute(struct hda_codec *codec) | |
11782 | { | |
11783 | unsigned int present; | |
11784 | ||
60db6b53 KY |
11785 | present = snd_hda_codec_read(codec, 0x18, 0, |
11786 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
f53281e6 | 11787 | snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
60db6b53 | 11788 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); |
f53281e6 | 11789 | snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
60db6b53 | 11790 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); |
f53281e6 KY |
11791 | } |
11792 | ||
11793 | /* unsolicited event for HP jack sensing */ | |
11794 | static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec, | |
60db6b53 | 11795 | unsigned int res) |
f53281e6 KY |
11796 | { |
11797 | if ((res >> 26) == ALC880_HP_EVENT) | |
11798 | alc269_speaker_automute(codec); | |
11799 | ||
11800 | if ((res >> 26) == ALC880_MIC_EVENT) | |
11801 | alc269_eeepc_dmic_automute(codec); | |
11802 | } | |
11803 | ||
11804 | static void alc269_eeepc_dmic_inithook(struct hda_codec *codec) | |
11805 | { | |
11806 | alc269_speaker_automute(codec); | |
11807 | alc269_eeepc_dmic_automute(codec); | |
11808 | } | |
11809 | ||
11810 | /* unsolicited event for HP jack sensing */ | |
11811 | static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec, | |
ea1fb29a | 11812 | unsigned int res) |
f53281e6 KY |
11813 | { |
11814 | if ((res >> 26) == ALC880_HP_EVENT) | |
11815 | alc269_speaker_automute(codec); | |
11816 | ||
11817 | if ((res >> 26) == ALC880_MIC_EVENT) | |
11818 | alc269_eeepc_amic_automute(codec); | |
11819 | } | |
11820 | ||
11821 | static void alc269_eeepc_amic_inithook(struct hda_codec *codec) | |
11822 | { | |
11823 | alc269_speaker_automute(codec); | |
11824 | alc269_eeepc_amic_automute(codec); | |
11825 | } | |
11826 | ||
60db6b53 KY |
11827 | /* |
11828 | * generic initialization of ADC, input mixers and output mixers | |
11829 | */ | |
11830 | static struct hda_verb alc269_init_verbs[] = { | |
11831 | /* | |
11832 | * Unmute ADC0 and set the default input to mic-in | |
11833 | */ | |
11834 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11835 | ||
11836 | /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the | |
11837 | * analog-loopback mixer widget | |
11838 | * Note: PASD motherboards uses the Line In 2 as the input for | |
11839 | * front panel mic (mic 2) | |
11840 | */ | |
11841 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
11842 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
11843 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
11844 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
11845 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
11846 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
11847 | ||
11848 | /* | |
11849 | * Set up output mixers (0x0c - 0x0e) | |
11850 | */ | |
11851 | /* set vol=0 to output mixers */ | |
11852 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11853 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
11854 | ||
11855 | /* set up input amps for analog loopback */ | |
11856 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
11857 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11858 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11859 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11860 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11861 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
11862 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11863 | ||
11864 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11865 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
11866 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
11867 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
11868 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
11869 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11870 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
11871 | ||
11872 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11873 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
11874 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11875 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11876 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11877 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11878 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
11879 | ||
11880 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11881 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
11882 | ||
11883 | /* FIXME: use matrix-type input source selection */ | |
11884 | /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */ | |
11885 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | |
11886 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
11887 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
11888 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
11889 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
11890 | ||
11891 | /* set EAPD */ | |
11892 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
11893 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
11894 | { } | |
11895 | }; | |
11896 | ||
f6a92248 KY |
11897 | /* add playback controls from the parsed DAC table */ |
11898 | static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec, | |
11899 | const struct auto_pin_cfg *cfg) | |
11900 | { | |
11901 | hda_nid_t nid; | |
11902 | int err; | |
11903 | ||
11904 | spec->multiout.num_dacs = 1; /* only use one dac */ | |
11905 | spec->multiout.dac_nids = spec->private_dac_nids; | |
11906 | spec->multiout.dac_nids[0] = 2; | |
11907 | ||
11908 | nid = cfg->line_out_pins[0]; | |
11909 | if (nid) { | |
11910 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
11911 | "Front Playback Volume", | |
11912 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT)); | |
11913 | if (err < 0) | |
11914 | return err; | |
11915 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
11916 | "Front Playback Switch", | |
11917 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
11918 | if (err < 0) | |
11919 | return err; | |
11920 | } | |
11921 | ||
11922 | nid = cfg->speaker_pins[0]; | |
11923 | if (nid) { | |
11924 | if (!cfg->line_out_pins[0]) { | |
11925 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
11926 | "Speaker Playback Volume", | |
11927 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | |
11928 | HDA_OUTPUT)); | |
11929 | if (err < 0) | |
11930 | return err; | |
11931 | } | |
11932 | if (nid == 0x16) { | |
11933 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
11934 | "Speaker Playback Switch", | |
11935 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
11936 | HDA_OUTPUT)); | |
11937 | if (err < 0) | |
11938 | return err; | |
11939 | } else { | |
11940 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
11941 | "Speaker Playback Switch", | |
11942 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
11943 | HDA_OUTPUT)); | |
11944 | if (err < 0) | |
11945 | return err; | |
11946 | } | |
11947 | } | |
11948 | nid = cfg->hp_pins[0]; | |
11949 | if (nid) { | |
11950 | /* spec->multiout.hp_nid = 2; */ | |
11951 | if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) { | |
11952 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
11953 | "Headphone Playback Volume", | |
11954 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | |
11955 | HDA_OUTPUT)); | |
11956 | if (err < 0) | |
11957 | return err; | |
11958 | } | |
11959 | if (nid == 0x16) { | |
11960 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
11961 | "Headphone Playback Switch", | |
11962 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
11963 | HDA_OUTPUT)); | |
11964 | if (err < 0) | |
11965 | return err; | |
11966 | } else { | |
11967 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | |
11968 | "Headphone Playback Switch", | |
11969 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
11970 | HDA_OUTPUT)); | |
11971 | if (err < 0) | |
11972 | return err; | |
11973 | } | |
11974 | } | |
11975 | return 0; | |
11976 | } | |
11977 | ||
ee956e09 TI |
11978 | static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec, |
11979 | const struct auto_pin_cfg *cfg) | |
11980 | { | |
11981 | int err; | |
11982 | ||
11983 | err = alc880_auto_create_analog_input_ctls(spec, cfg); | |
11984 | if (err < 0) | |
11985 | return err; | |
11986 | /* digital-mic input pin is excluded in alc880_auto_create..() | |
11987 | * because it's under 0x18 | |
11988 | */ | |
11989 | if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 || | |
11990 | cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { | |
11991 | struct hda_input_mux *imux = &spec->private_imux; | |
11992 | imux->items[imux->num_items].label = "Int Mic"; | |
11993 | imux->items[imux->num_items].index = 0x05; | |
11994 | imux->num_items++; | |
11995 | } | |
11996 | return 0; | |
11997 | } | |
f6a92248 KY |
11998 | |
11999 | #ifdef CONFIG_SND_HDA_POWER_SAVE | |
12000 | #define alc269_loopbacks alc880_loopbacks | |
12001 | #endif | |
12002 | ||
12003 | /* pcm configuration: identiacal with ALC880 */ | |
12004 | #define alc269_pcm_analog_playback alc880_pcm_analog_playback | |
12005 | #define alc269_pcm_analog_capture alc880_pcm_analog_capture | |
12006 | #define alc269_pcm_digital_playback alc880_pcm_digital_playback | |
12007 | #define alc269_pcm_digital_capture alc880_pcm_digital_capture | |
12008 | ||
12009 | /* | |
12010 | * BIOS auto configuration | |
12011 | */ | |
12012 | static int alc269_parse_auto_config(struct hda_codec *codec) | |
12013 | { | |
12014 | struct alc_spec *spec = codec->spec; | |
2005af24 | 12015 | int i, err; |
f6a92248 KY |
12016 | static hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
12017 | ||
12018 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
12019 | alc269_ignore); | |
12020 | if (err < 0) | |
12021 | return err; | |
12022 | ||
12023 | err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
12024 | if (err < 0) | |
12025 | return err; | |
12026 | err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
12027 | if (err < 0) | |
12028 | return err; | |
12029 | ||
12030 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
12031 | ||
12032 | if (spec->autocfg.dig_out_pin) | |
12033 | spec->multiout.dig_out_nid = ALC269_DIGOUT_NID; | |
12034 | ||
603c4019 | 12035 | if (spec->kctls.list) |
d88897ea | 12036 | add_mixer(spec, spec->kctls.list); |
f6a92248 | 12037 | |
2005af24 TI |
12038 | /* create a beep mixer control if the pin 0x1d isn't assigned */ |
12039 | for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++) | |
12040 | if (spec->autocfg.input_pins[i] == 0x1d) | |
12041 | break; | |
12042 | if (i >= ARRAY_SIZE(spec->autocfg.input_pins)) | |
d88897ea | 12043 | add_mixer(spec, alc269_beep_mixer); |
2005af24 | 12044 | |
d88897ea | 12045 | add_verb(spec, alc269_init_verbs); |
f6a92248 KY |
12046 | spec->num_mux_defs = 1; |
12047 | spec->input_mux = &spec->private_imux; | |
e01bf509 TI |
12048 | /* set default input source */ |
12049 | snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0], | |
12050 | 0, AC_VERB_SET_CONNECT_SEL, | |
12051 | spec->input_mux->items[0].index); | |
f6a92248 KY |
12052 | |
12053 | err = alc_auto_add_mic_boost(codec); | |
12054 | if (err < 0) | |
12055 | return err; | |
12056 | ||
f9e336f6 TI |
12057 | if (!spec->cap_mixer) |
12058 | set_capture_mixer(spec); | |
f53281e6 | 12059 | |
e044c39a | 12060 | store_pin_configs(codec); |
f6a92248 KY |
12061 | return 1; |
12062 | } | |
12063 | ||
12064 | #define alc269_auto_init_multi_out alc882_auto_init_multi_out | |
12065 | #define alc269_auto_init_hp_out alc882_auto_init_hp_out | |
12066 | #define alc269_auto_init_analog_input alc882_auto_init_analog_input | |
12067 | ||
12068 | ||
12069 | /* init callback for auto-configuration model -- overriding the default init */ | |
12070 | static void alc269_auto_init(struct hda_codec *codec) | |
12071 | { | |
f6c7e546 | 12072 | struct alc_spec *spec = codec->spec; |
f6a92248 KY |
12073 | alc269_auto_init_multi_out(codec); |
12074 | alc269_auto_init_hp_out(codec); | |
12075 | alc269_auto_init_analog_input(codec); | |
f6c7e546 | 12076 | if (spec->unsol_event) |
7fb0d78f | 12077 | alc_inithook(codec); |
f6a92248 KY |
12078 | } |
12079 | ||
12080 | /* | |
12081 | * configuration and preset | |
12082 | */ | |
12083 | static const char *alc269_models[ALC269_MODEL_LAST] = { | |
60db6b53 | 12084 | [ALC269_BASIC] = "basic", |
2922c9af TI |
12085 | [ALC269_QUANTA_FL1] = "quanta", |
12086 | [ALC269_ASUS_EEEPC_P703] = "eeepc-p703", | |
12087 | [ALC269_ASUS_EEEPC_P901] = "eeepc-p901" | |
f6a92248 KY |
12088 | }; |
12089 | ||
12090 | static struct snd_pci_quirk alc269_cfg_tbl[] = { | |
60db6b53 | 12091 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1), |
f53281e6 KY |
12092 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
12093 | ALC269_ASUS_EEEPC_P703), | |
12094 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901", | |
12095 | ALC269_ASUS_EEEPC_P901), | |
60db6b53 KY |
12096 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101", |
12097 | ALC269_ASUS_EEEPC_P901), | |
f6a92248 KY |
12098 | {} |
12099 | }; | |
12100 | ||
12101 | static struct alc_config_preset alc269_presets[] = { | |
12102 | [ALC269_BASIC] = { | |
f9e336f6 | 12103 | .mixers = { alc269_base_mixer }, |
f6a92248 KY |
12104 | .init_verbs = { alc269_init_verbs }, |
12105 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12106 | .dac_nids = alc269_dac_nids, | |
12107 | .hp_nid = 0x03, | |
12108 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12109 | .channel_mode = alc269_modes, | |
12110 | .input_mux = &alc269_capture_source, | |
12111 | }, | |
60db6b53 KY |
12112 | [ALC269_QUANTA_FL1] = { |
12113 | .mixers = { alc269_quanta_fl1_mixer }, | |
12114 | .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs }, | |
12115 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12116 | .dac_nids = alc269_dac_nids, | |
12117 | .hp_nid = 0x03, | |
12118 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12119 | .channel_mode = alc269_modes, | |
12120 | .input_mux = &alc269_capture_source, | |
12121 | .unsol_event = alc269_quanta_fl1_unsol_event, | |
12122 | .init_hook = alc269_quanta_fl1_init_hook, | |
12123 | }, | |
f53281e6 | 12124 | [ALC269_ASUS_EEEPC_P703] = { |
f9e336f6 TI |
12125 | .mixers = { alc269_eeepc_mixer }, |
12126 | .cap_mixer = alc269_epc_capture_mixer, | |
f53281e6 KY |
12127 | .init_verbs = { alc269_init_verbs, |
12128 | alc269_eeepc_amic_init_verbs }, | |
12129 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12130 | .dac_nids = alc269_dac_nids, | |
12131 | .hp_nid = 0x03, | |
12132 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12133 | .channel_mode = alc269_modes, | |
12134 | .input_mux = &alc269_eeepc_amic_capture_source, | |
12135 | .unsol_event = alc269_eeepc_amic_unsol_event, | |
12136 | .init_hook = alc269_eeepc_amic_inithook, | |
12137 | }, | |
12138 | [ALC269_ASUS_EEEPC_P901] = { | |
f9e336f6 TI |
12139 | .mixers = { alc269_eeepc_mixer }, |
12140 | .cap_mixer = alc269_epc_capture_mixer, | |
f53281e6 KY |
12141 | .init_verbs = { alc269_init_verbs, |
12142 | alc269_eeepc_dmic_init_verbs }, | |
12143 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | |
12144 | .dac_nids = alc269_dac_nids, | |
12145 | .hp_nid = 0x03, | |
12146 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | |
12147 | .channel_mode = alc269_modes, | |
12148 | .input_mux = &alc269_eeepc_dmic_capture_source, | |
12149 | .unsol_event = alc269_eeepc_dmic_unsol_event, | |
12150 | .init_hook = alc269_eeepc_dmic_inithook, | |
12151 | }, | |
f6a92248 KY |
12152 | }; |
12153 | ||
12154 | static int patch_alc269(struct hda_codec *codec) | |
12155 | { | |
12156 | struct alc_spec *spec; | |
12157 | int board_config; | |
12158 | int err; | |
12159 | ||
12160 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
12161 | if (spec == NULL) | |
12162 | return -ENOMEM; | |
12163 | ||
12164 | codec->spec = spec; | |
12165 | ||
2c3bf9ab TI |
12166 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
12167 | ||
f6a92248 KY |
12168 | board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, |
12169 | alc269_models, | |
12170 | alc269_cfg_tbl); | |
12171 | ||
12172 | if (board_config < 0) { | |
12173 | printk(KERN_INFO "hda_codec: Unknown model for ALC269, " | |
12174 | "trying auto-probe from BIOS...\n"); | |
12175 | board_config = ALC269_AUTO; | |
12176 | } | |
12177 | ||
12178 | if (board_config == ALC269_AUTO) { | |
12179 | /* automatic parse from the BIOS config */ | |
12180 | err = alc269_parse_auto_config(codec); | |
12181 | if (err < 0) { | |
12182 | alc_free(codec); | |
12183 | return err; | |
12184 | } else if (!err) { | |
12185 | printk(KERN_INFO | |
12186 | "hda_codec: Cannot set up configuration " | |
12187 | "from BIOS. Using base mode...\n"); | |
12188 | board_config = ALC269_BASIC; | |
12189 | } | |
12190 | } | |
12191 | ||
12192 | if (board_config != ALC269_AUTO) | |
12193 | setup_preset(spec, &alc269_presets[board_config]); | |
12194 | ||
12195 | spec->stream_name_analog = "ALC269 Analog"; | |
12196 | spec->stream_analog_playback = &alc269_pcm_analog_playback; | |
12197 | spec->stream_analog_capture = &alc269_pcm_analog_capture; | |
12198 | ||
12199 | spec->stream_name_digital = "ALC269 Digital"; | |
12200 | spec->stream_digital_playback = &alc269_pcm_digital_playback; | |
12201 | spec->stream_digital_capture = &alc269_pcm_digital_capture; | |
12202 | ||
12203 | spec->adc_nids = alc269_adc_nids; | |
12204 | spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); | |
e01bf509 | 12205 | spec->capsrc_nids = alc269_capsrc_nids; |
f9e336f6 TI |
12206 | if (!spec->cap_mixer) |
12207 | set_capture_mixer(spec); | |
f6a92248 KY |
12208 | |
12209 | codec->patch_ops = alc_patch_ops; | |
12210 | if (board_config == ALC269_AUTO) | |
12211 | spec->init_hook = alc269_auto_init; | |
12212 | #ifdef CONFIG_SND_HDA_POWER_SAVE | |
12213 | if (!spec->loopback.amplist) | |
12214 | spec->loopback.amplist = alc269_loopbacks; | |
12215 | #endif | |
12216 | ||
12217 | return 0; | |
12218 | } | |
12219 | ||
df694daa KY |
12220 | /* |
12221 | * ALC861 channel source setting (2/6 channel selection for 3-stack) | |
12222 | */ | |
12223 | ||
12224 | /* | |
12225 | * set the path ways for 2 channel output | |
12226 | * need to set the codec line out and mic 1 pin widgets to inputs | |
12227 | */ | |
12228 | static struct hda_verb alc861_threestack_ch2_init[] = { | |
12229 | /* set pin widget 1Ah (line in) for input */ | |
12230 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
12231 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
12232 | * the vref | |
12233 | */ | |
df694daa KY |
12234 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
12235 | ||
9c7f852e TI |
12236 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, |
12237 | #if 0 | |
12238 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
12239 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
12240 | #endif | |
df694daa KY |
12241 | { } /* end */ |
12242 | }; | |
12243 | /* | |
12244 | * 6ch mode | |
12245 | * need to set the codec line out and mic 1 pin widgets to outputs | |
12246 | */ | |
12247 | static struct hda_verb alc861_threestack_ch6_init[] = { | |
12248 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
12249 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12250 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
12251 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12252 | ||
12253 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
9c7f852e | 12254 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa | 12255 | |
9c7f852e TI |
12256 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, |
12257 | #if 0 | |
12258 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
12259 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
12260 | #endif | |
df694daa KY |
12261 | { } /* end */ |
12262 | }; | |
12263 | ||
12264 | static struct hda_channel_mode alc861_threestack_modes[2] = { | |
12265 | { 2, alc861_threestack_ch2_init }, | |
12266 | { 6, alc861_threestack_ch6_init }, | |
12267 | }; | |
22309c3e TI |
12268 | /* Set mic1 as input and unmute the mixer */ |
12269 | static struct hda_verb alc861_uniwill_m31_ch2_init[] = { | |
12270 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12271 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
12272 | { } /* end */ | |
12273 | }; | |
12274 | /* Set mic1 as output and mute mixer */ | |
12275 | static struct hda_verb alc861_uniwill_m31_ch4_init[] = { | |
12276 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12277 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
12278 | { } /* end */ | |
12279 | }; | |
12280 | ||
12281 | static struct hda_channel_mode alc861_uniwill_m31_modes[2] = { | |
12282 | { 2, alc861_uniwill_m31_ch2_init }, | |
12283 | { 4, alc861_uniwill_m31_ch4_init }, | |
12284 | }; | |
df694daa | 12285 | |
7cdbff94 MD |
12286 | /* Set mic1 and line-in as input and unmute the mixer */ |
12287 | static struct hda_verb alc861_asus_ch2_init[] = { | |
12288 | /* set pin widget 1Ah (line in) for input */ | |
12289 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
f12ab1e0 TI |
12290 | /* set pin widget 18h (mic1/2) for input, for mic also enable |
12291 | * the vref | |
12292 | */ | |
7cdbff94 MD |
12293 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, |
12294 | ||
12295 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, | |
12296 | #if 0 | |
12297 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/ | |
12298 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/ | |
12299 | #endif | |
12300 | { } /* end */ | |
12301 | }; | |
12302 | /* Set mic1 nad line-in as output and mute mixer */ | |
12303 | static struct hda_verb alc861_asus_ch6_init[] = { | |
12304 | /* set pin widget 1Ah (line in) for output (Back Surround)*/ | |
12305 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12306 | /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
12307 | /* set pin widget 18h (mic1) for output (CLFE)*/ | |
12308 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12309 | /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */ | |
12310 | { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12311 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12312 | ||
12313 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, | |
12314 | #if 0 | |
12315 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/ | |
12316 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/ | |
12317 | #endif | |
12318 | { } /* end */ | |
12319 | }; | |
12320 | ||
12321 | static struct hda_channel_mode alc861_asus_modes[2] = { | |
12322 | { 2, alc861_asus_ch2_init }, | |
12323 | { 6, alc861_asus_ch6_init }, | |
12324 | }; | |
12325 | ||
df694daa KY |
12326 | /* patch-ALC861 */ |
12327 | ||
12328 | static struct snd_kcontrol_new alc861_base_mixer[] = { | |
12329 | /* output mixer control */ | |
12330 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12331 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
12332 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
12333 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
12334 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
12335 | ||
12336 | /*Input mixer control */ | |
12337 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
12338 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
12339 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
12340 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12341 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
12342 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
12343 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12344 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
12345 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
12346 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 12347 | |
df694daa KY |
12348 | { } /* end */ |
12349 | }; | |
12350 | ||
12351 | static struct snd_kcontrol_new alc861_3ST_mixer[] = { | |
12352 | /* output mixer control */ | |
12353 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12354 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
12355 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
12356 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
12357 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
12358 | ||
12359 | /* Input mixer control */ | |
12360 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
12361 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
12362 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
12363 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12364 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
12365 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
12366 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12367 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
12368 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
12369 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 12370 | |
df694daa KY |
12371 | { |
12372 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12373 | .name = "Channel Mode", | |
12374 | .info = alc_ch_mode_info, | |
12375 | .get = alc_ch_mode_get, | |
12376 | .put = alc_ch_mode_put, | |
12377 | .private_value = ARRAY_SIZE(alc861_threestack_modes), | |
12378 | }, | |
12379 | { } /* end */ | |
a53d1aec TD |
12380 | }; |
12381 | ||
d1d985f0 | 12382 | static struct snd_kcontrol_new alc861_toshiba_mixer[] = { |
a53d1aec TD |
12383 | /* output mixer control */ |
12384 | HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12385 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12386 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
ea1fb29a | 12387 | |
a53d1aec | 12388 | { } /* end */ |
f12ab1e0 | 12389 | }; |
a53d1aec | 12390 | |
22309c3e TI |
12391 | static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { |
12392 | /* output mixer control */ | |
12393 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12394 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
12395 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
12396 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
12397 | /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ | |
12398 | ||
12399 | /* Input mixer control */ | |
12400 | /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
12401 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ | |
12402 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
12403 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12404 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
12405 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
12406 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12407 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
12408 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
12409 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), | |
f12ab1e0 | 12410 | |
22309c3e TI |
12411 | { |
12412 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12413 | .name = "Channel Mode", | |
12414 | .info = alc_ch_mode_info, | |
12415 | .get = alc_ch_mode_get, | |
12416 | .put = alc_ch_mode_put, | |
12417 | .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
12418 | }, | |
12419 | { } /* end */ | |
f12ab1e0 | 12420 | }; |
7cdbff94 MD |
12421 | |
12422 | static struct snd_kcontrol_new alc861_asus_mixer[] = { | |
12423 | /* output mixer control */ | |
12424 | HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), | |
12425 | HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), | |
12426 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), | |
12427 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), | |
12428 | HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), | |
12429 | ||
12430 | /* Input mixer control */ | |
12431 | HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), | |
12432 | HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
12433 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), | |
12434 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12435 | HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), | |
12436 | HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), | |
12437 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), | |
12438 | HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), | |
12439 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), | |
f12ab1e0 TI |
12440 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), |
12441 | ||
7cdbff94 MD |
12442 | { |
12443 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
12444 | .name = "Channel Mode", | |
12445 | .info = alc_ch_mode_info, | |
12446 | .get = alc_ch_mode_get, | |
12447 | .put = alc_ch_mode_put, | |
12448 | .private_value = ARRAY_SIZE(alc861_asus_modes), | |
12449 | }, | |
12450 | { } | |
56bb0cab TI |
12451 | }; |
12452 | ||
12453 | /* additional mixer */ | |
d1d985f0 | 12454 | static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = { |
56bb0cab TI |
12455 | HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), |
12456 | HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), | |
12457 | HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT), | |
12458 | HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT), | |
12459 | { } | |
12460 | }; | |
7cdbff94 | 12461 | |
df694daa KY |
12462 | /* |
12463 | * generic initialization of ADC, input mixers and output mixers | |
12464 | */ | |
12465 | static struct hda_verb alc861_base_init_verbs[] = { | |
12466 | /* | |
12467 | * Unmute ADC0 and set the default input to mic-in | |
12468 | */ | |
12469 | /* port-A for surround (rear panel) */ | |
12470 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12471 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12472 | /* port-B for mic-in (rear panel) with vref */ | |
12473 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12474 | /* port-C for line-in (rear panel) */ | |
12475 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12476 | /* port-D for Front */ | |
12477 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12478 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12479 | /* port-E for HP out (front panel) */ | |
12480 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
12481 | /* route front PCM to HP */ | |
9dece1d7 | 12482 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
12483 | /* port-F for mic-in (front panel) with vref */ |
12484 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12485 | /* port-G for CLFE (rear panel) */ | |
12486 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12487 | { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12488 | /* port-H for side (rear panel) */ | |
12489 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12490 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12491 | /* CD-in */ | |
12492 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12493 | /* route front mic to ADC1*/ | |
12494 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12495 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
ea1fb29a | 12496 | |
df694daa KY |
12497 | /* Unmute DAC0~3 & spdif out*/ |
12498 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12499 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12500 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12501 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12502 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 12503 | |
df694daa KY |
12504 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
12505 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12506 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12507 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12508 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 12509 | |
df694daa KY |
12510 | /* Unmute Stereo Mixer 15 */ |
12511 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12512 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12513 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 12514 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
12515 | |
12516 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12517 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12518 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12519 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12520 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12521 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12522 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12523 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
12524 | /* hp used DAC 3 (Front) */ |
12525 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
12526 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
12527 | ||
12528 | { } | |
12529 | }; | |
12530 | ||
12531 | static struct hda_verb alc861_threestack_init_verbs[] = { | |
12532 | /* | |
12533 | * Unmute ADC0 and set the default input to mic-in | |
12534 | */ | |
12535 | /* port-A for surround (rear panel) */ | |
12536 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
12537 | /* port-B for mic-in (rear panel) with vref */ | |
12538 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12539 | /* port-C for line-in (rear panel) */ | |
12540 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12541 | /* port-D for Front */ | |
12542 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12543 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12544 | /* port-E for HP out (front panel) */ | |
12545 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, | |
12546 | /* route front PCM to HP */ | |
9dece1d7 | 12547 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
df694daa KY |
12548 | /* port-F for mic-in (front panel) with vref */ |
12549 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12550 | /* port-G for CLFE (rear panel) */ | |
12551 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
12552 | /* port-H for side (rear panel) */ | |
12553 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
12554 | /* CD-in */ | |
12555 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12556 | /* route front mic to ADC1*/ | |
12557 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12558 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12559 | /* Unmute DAC0~3 & spdif out*/ | |
12560 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12561 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12562 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12563 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12564 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 12565 | |
df694daa KY |
12566 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
12567 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12568 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12569 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12570 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 12571 | |
df694daa KY |
12572 | /* Unmute Stereo Mixer 15 */ |
12573 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12574 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12575 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 12576 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
df694daa KY |
12577 | |
12578 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12579 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12580 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12581 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12582 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12583 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12584 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12585 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
12586 | /* hp used DAC 3 (Front) */ |
12587 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
12588 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
12589 | { } | |
12590 | }; | |
22309c3e TI |
12591 | |
12592 | static struct hda_verb alc861_uniwill_m31_init_verbs[] = { | |
12593 | /* | |
12594 | * Unmute ADC0 and set the default input to mic-in | |
12595 | */ | |
12596 | /* port-A for surround (rear panel) */ | |
12597 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
12598 | /* port-B for mic-in (rear panel) with vref */ | |
12599 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12600 | /* port-C for line-in (rear panel) */ | |
12601 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12602 | /* port-D for Front */ | |
12603 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12604 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12605 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
12606 | /* this has to be set to VREF80 */ |
12607 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
22309c3e | 12608 | /* route front PCM to HP */ |
9dece1d7 | 12609 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
22309c3e TI |
12610 | /* port-F for mic-in (front panel) with vref */ |
12611 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12612 | /* port-G for CLFE (rear panel) */ | |
12613 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
12614 | /* port-H for side (rear panel) */ | |
12615 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
12616 | /* CD-in */ | |
12617 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12618 | /* route front mic to ADC1*/ | |
12619 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12620 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12621 | /* Unmute DAC0~3 & spdif out*/ | |
12622 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12623 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12624 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12625 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12626 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 12627 | |
22309c3e TI |
12628 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
12629 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12630 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12631 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12632 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 12633 | |
22309c3e TI |
12634 | /* Unmute Stereo Mixer 15 */ |
12635 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12636 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12637 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 12638 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
22309c3e TI |
12639 | |
12640 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12641 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12642 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12643 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12644 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12645 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12646 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12647 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
12648 | /* hp used DAC 3 (Front) */ |
12649 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
22309c3e TI |
12650 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
12651 | { } | |
12652 | }; | |
12653 | ||
7cdbff94 MD |
12654 | static struct hda_verb alc861_asus_init_verbs[] = { |
12655 | /* | |
12656 | * Unmute ADC0 and set the default input to mic-in | |
12657 | */ | |
f12ab1e0 TI |
12658 | /* port-A for surround (rear panel) |
12659 | * according to codec#0 this is the HP jack | |
12660 | */ | |
7cdbff94 MD |
12661 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ |
12662 | /* route front PCM to HP */ | |
12663 | { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
12664 | /* port-B for mic-in (rear panel) with vref */ | |
12665 | { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12666 | /* port-C for line-in (rear panel) */ | |
12667 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12668 | /* port-D for Front */ | |
12669 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12670 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, | |
12671 | /* port-E for HP out (front panel) */ | |
f12ab1e0 TI |
12672 | /* this has to be set to VREF80 */ |
12673 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
7cdbff94 | 12674 | /* route front PCM to HP */ |
9dece1d7 | 12675 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
7cdbff94 MD |
12676 | /* port-F for mic-in (front panel) with vref */ |
12677 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, | |
12678 | /* port-G for CLFE (rear panel) */ | |
12679 | { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12680 | /* port-H for side (rear panel) */ | |
12681 | { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, | |
12682 | /* CD-in */ | |
12683 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, | |
12684 | /* route front mic to ADC1*/ | |
12685 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
12686 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12687 | /* Unmute DAC0~3 & spdif out*/ | |
12688 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12689 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12690 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12691 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12692 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
12693 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ | |
12694 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12695 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12696 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12697 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 12698 | |
7cdbff94 MD |
12699 | /* Unmute Stereo Mixer 15 */ |
12700 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12701 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12702 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f12ab1e0 | 12703 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */ |
7cdbff94 MD |
12704 | |
12705 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12706 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12707 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12708 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12709 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12710 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12711 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12712 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
f12ab1e0 TI |
12713 | /* hp used DAC 3 (Front) */ |
12714 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
7cdbff94 MD |
12715 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
12716 | { } | |
12717 | }; | |
12718 | ||
56bb0cab TI |
12719 | /* additional init verbs for ASUS laptops */ |
12720 | static struct hda_verb alc861_asus_laptop_init_verbs[] = { | |
12721 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */ | |
12722 | { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */ | |
12723 | { } | |
12724 | }; | |
7cdbff94 | 12725 | |
df694daa KY |
12726 | /* |
12727 | * generic initialization of ADC, input mixers and output mixers | |
12728 | */ | |
12729 | static struct hda_verb alc861_auto_init_verbs[] = { | |
12730 | /* | |
12731 | * Unmute ADC0 and set the default input to mic-in | |
12732 | */ | |
f12ab1e0 | 12733 | /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */ |
df694daa | 12734 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
ea1fb29a | 12735 | |
df694daa KY |
12736 | /* Unmute DAC0~3 & spdif out*/ |
12737 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12738 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12739 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12740 | {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
12741 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
ea1fb29a | 12742 | |
df694daa KY |
12743 | /* Unmute Mixer 14 (mic) 1c (Line in)*/ |
12744 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12745 | {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12746 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12747 | {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
ea1fb29a | 12748 | |
df694daa KY |
12749 | /* Unmute Stereo Mixer 15 */ |
12750 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12751 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12752 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
12753 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, | |
12754 | ||
12755 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12756 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12757 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12758 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12759 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12760 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12761 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
12762 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
12763 | ||
12764 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
12765 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
12766 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
12767 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa KY |
12768 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
12769 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
f12ab1e0 TI |
12770 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
12771 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | |
df694daa | 12772 | |
f12ab1e0 | 12773 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ |
df694daa KY |
12774 | |
12775 | { } | |
12776 | }; | |
12777 | ||
a53d1aec TD |
12778 | static struct hda_verb alc861_toshiba_init_verbs[] = { |
12779 | {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
f12ab1e0 | 12780 | |
a53d1aec TD |
12781 | { } |
12782 | }; | |
12783 | ||
12784 | /* toggle speaker-output according to the hp-jack state */ | |
12785 | static void alc861_toshiba_automute(struct hda_codec *codec) | |
12786 | { | |
12787 | unsigned int present; | |
12788 | ||
12789 | present = snd_hda_codec_read(codec, 0x0f, 0, | |
12790 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
12791 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0, |
12792 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
12793 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3, | |
12794 | HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE); | |
a53d1aec TD |
12795 | } |
12796 | ||
12797 | static void alc861_toshiba_unsol_event(struct hda_codec *codec, | |
12798 | unsigned int res) | |
12799 | { | |
a53d1aec TD |
12800 | if ((res >> 26) == ALC880_HP_EVENT) |
12801 | alc861_toshiba_automute(codec); | |
12802 | } | |
12803 | ||
df694daa KY |
12804 | /* pcm configuration: identiacal with ALC880 */ |
12805 | #define alc861_pcm_analog_playback alc880_pcm_analog_playback | |
12806 | #define alc861_pcm_analog_capture alc880_pcm_analog_capture | |
12807 | #define alc861_pcm_digital_playback alc880_pcm_digital_playback | |
12808 | #define alc861_pcm_digital_capture alc880_pcm_digital_capture | |
12809 | ||
12810 | ||
12811 | #define ALC861_DIGOUT_NID 0x07 | |
12812 | ||
12813 | static struct hda_channel_mode alc861_8ch_modes[1] = { | |
12814 | { 8, NULL } | |
12815 | }; | |
12816 | ||
12817 | static hda_nid_t alc861_dac_nids[4] = { | |
12818 | /* front, surround, clfe, side */ | |
12819 | 0x03, 0x06, 0x05, 0x04 | |
12820 | }; | |
12821 | ||
9c7f852e TI |
12822 | static hda_nid_t alc660_dac_nids[3] = { |
12823 | /* front, clfe, surround */ | |
12824 | 0x03, 0x05, 0x06 | |
12825 | }; | |
12826 | ||
df694daa KY |
12827 | static hda_nid_t alc861_adc_nids[1] = { |
12828 | /* ADC0-2 */ | |
12829 | 0x08, | |
12830 | }; | |
12831 | ||
12832 | static struct hda_input_mux alc861_capture_source = { | |
12833 | .num_items = 5, | |
12834 | .items = { | |
12835 | { "Mic", 0x0 }, | |
12836 | { "Front Mic", 0x3 }, | |
12837 | { "Line", 0x1 }, | |
12838 | { "CD", 0x4 }, | |
12839 | { "Mixer", 0x5 }, | |
12840 | }, | |
12841 | }; | |
12842 | ||
12843 | /* fill in the dac_nids table from the parsed pin configuration */ | |
f12ab1e0 TI |
12844 | static int alc861_auto_fill_dac_nids(struct alc_spec *spec, |
12845 | const struct auto_pin_cfg *cfg) | |
df694daa KY |
12846 | { |
12847 | int i; | |
12848 | hda_nid_t nid; | |
12849 | ||
12850 | spec->multiout.dac_nids = spec->private_dac_nids; | |
12851 | for (i = 0; i < cfg->line_outs; i++) { | |
12852 | nid = cfg->line_out_pins[i]; | |
12853 | if (nid) { | |
12854 | if (i >= ARRAY_SIZE(alc861_dac_nids)) | |
12855 | continue; | |
12856 | spec->multiout.dac_nids[i] = alc861_dac_nids[i]; | |
12857 | } | |
12858 | } | |
12859 | spec->multiout.num_dacs = cfg->line_outs; | |
12860 | return 0; | |
12861 | } | |
12862 | ||
12863 | /* add playback controls from the parsed DAC table */ | |
12864 | static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, | |
12865 | const struct auto_pin_cfg *cfg) | |
12866 | { | |
12867 | char name[32]; | |
f12ab1e0 TI |
12868 | static const char *chname[4] = { |
12869 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
12870 | }; | |
df694daa KY |
12871 | hda_nid_t nid; |
12872 | int i, idx, err; | |
12873 | ||
12874 | for (i = 0; i < cfg->line_outs; i++) { | |
12875 | nid = spec->multiout.dac_nids[i]; | |
f12ab1e0 | 12876 | if (!nid) |
df694daa KY |
12877 | continue; |
12878 | if (nid == 0x05) { | |
12879 | /* Center/LFE */ | |
f12ab1e0 TI |
12880 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
12881 | "Center Playback Switch", | |
12882 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | |
12883 | HDA_OUTPUT)); | |
12884 | if (err < 0) | |
df694daa | 12885 | return err; |
f12ab1e0 TI |
12886 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
12887 | "LFE Playback Switch", | |
12888 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | |
12889 | HDA_OUTPUT)); | |
12890 | if (err < 0) | |
df694daa KY |
12891 | return err; |
12892 | } else { | |
f12ab1e0 TI |
12893 | for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; |
12894 | idx++) | |
df694daa KY |
12895 | if (nid == alc861_dac_nids[idx]) |
12896 | break; | |
12897 | sprintf(name, "%s Playback Switch", chname[idx]); | |
f12ab1e0 TI |
12898 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
12899 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | |
12900 | HDA_OUTPUT)); | |
12901 | if (err < 0) | |
df694daa KY |
12902 | return err; |
12903 | } | |
12904 | } | |
12905 | return 0; | |
12906 | } | |
12907 | ||
12908 | static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) | |
12909 | { | |
12910 | int err; | |
12911 | hda_nid_t nid; | |
12912 | ||
f12ab1e0 | 12913 | if (!pin) |
df694daa KY |
12914 | return 0; |
12915 | ||
12916 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { | |
12917 | nid = 0x03; | |
f12ab1e0 TI |
12918 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
12919 | "Headphone Playback Switch", | |
12920 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
12921 | if (err < 0) | |
df694daa KY |
12922 | return err; |
12923 | spec->multiout.hp_nid = nid; | |
12924 | } | |
12925 | return 0; | |
12926 | } | |
12927 | ||
12928 | /* create playback/capture controls for input pins */ | |
f12ab1e0 TI |
12929 | static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, |
12930 | const struct auto_pin_cfg *cfg) | |
df694daa | 12931 | { |
df694daa KY |
12932 | struct hda_input_mux *imux = &spec->private_imux; |
12933 | int i, err, idx, idx1; | |
12934 | ||
12935 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
f12ab1e0 | 12936 | switch (cfg->input_pins[i]) { |
df694daa KY |
12937 | case 0x0c: |
12938 | idx1 = 1; | |
f12ab1e0 | 12939 | idx = 2; /* Line In */ |
df694daa KY |
12940 | break; |
12941 | case 0x0f: | |
12942 | idx1 = 2; | |
f12ab1e0 | 12943 | idx = 2; /* Line In */ |
df694daa KY |
12944 | break; |
12945 | case 0x0d: | |
12946 | idx1 = 0; | |
f12ab1e0 | 12947 | idx = 1; /* Mic In */ |
df694daa | 12948 | break; |
f12ab1e0 | 12949 | case 0x10: |
df694daa | 12950 | idx1 = 3; |
f12ab1e0 | 12951 | idx = 1; /* Mic In */ |
df694daa KY |
12952 | break; |
12953 | case 0x11: | |
12954 | idx1 = 4; | |
f12ab1e0 | 12955 | idx = 0; /* CD */ |
df694daa KY |
12956 | break; |
12957 | default: | |
12958 | continue; | |
12959 | } | |
12960 | ||
4a471b7d TI |
12961 | err = new_analog_input(spec, cfg->input_pins[i], |
12962 | auto_pin_cfg_labels[i], idx, 0x15); | |
df694daa KY |
12963 | if (err < 0) |
12964 | return err; | |
12965 | ||
4a471b7d | 12966 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
df694daa | 12967 | imux->items[imux->num_items].index = idx1; |
f12ab1e0 | 12968 | imux->num_items++; |
df694daa KY |
12969 | } |
12970 | return 0; | |
12971 | } | |
12972 | ||
f12ab1e0 TI |
12973 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, |
12974 | hda_nid_t nid, | |
df694daa KY |
12975 | int pin_type, int dac_idx) |
12976 | { | |
564c5bea JL |
12977 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
12978 | pin_type); | |
12979 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
12980 | AMP_OUT_UNMUTE); | |
df694daa KY |
12981 | } |
12982 | ||
12983 | static void alc861_auto_init_multi_out(struct hda_codec *codec) | |
12984 | { | |
12985 | struct alc_spec *spec = codec->spec; | |
12986 | int i; | |
12987 | ||
bc9f98a9 | 12988 | alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b); |
df694daa KY |
12989 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
12990 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 12991 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
df694daa | 12992 | if (nid) |
baba8ee9 | 12993 | alc861_auto_set_output_and_unmute(codec, nid, pin_type, |
f12ab1e0 | 12994 | spec->multiout.dac_nids[i]); |
df694daa KY |
12995 | } |
12996 | } | |
12997 | ||
12998 | static void alc861_auto_init_hp_out(struct hda_codec *codec) | |
12999 | { | |
13000 | struct alc_spec *spec = codec->spec; | |
13001 | hda_nid_t pin; | |
13002 | ||
eb06ed8f | 13003 | pin = spec->autocfg.hp_pins[0]; |
df694daa | 13004 | if (pin) /* connect to front */ |
f12ab1e0 TI |
13005 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, |
13006 | spec->multiout.dac_nids[0]); | |
f6c7e546 TI |
13007 | pin = spec->autocfg.speaker_pins[0]; |
13008 | if (pin) | |
13009 | alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
df694daa KY |
13010 | } |
13011 | ||
13012 | static void alc861_auto_init_analog_input(struct hda_codec *codec) | |
13013 | { | |
13014 | struct alc_spec *spec = codec->spec; | |
13015 | int i; | |
13016 | ||
13017 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
13018 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
f12ab1e0 TI |
13019 | if (nid >= 0x0c && nid <= 0x11) { |
13020 | snd_hda_codec_write(codec, nid, 0, | |
13021 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
13022 | i <= AUTO_PIN_FRONT_MIC ? | |
13023 | PIN_VREF80 : PIN_IN); | |
df694daa KY |
13024 | } |
13025 | } | |
13026 | } | |
13027 | ||
13028 | /* parse the BIOS configuration and set up the alc_spec */ | |
f12ab1e0 TI |
13029 | /* return 1 if successful, 0 if the proper config is not found, |
13030 | * or a negative error code | |
13031 | */ | |
df694daa KY |
13032 | static int alc861_parse_auto_config(struct hda_codec *codec) |
13033 | { | |
13034 | struct alc_spec *spec = codec->spec; | |
13035 | int err; | |
13036 | static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; | |
13037 | ||
f12ab1e0 TI |
13038 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
13039 | alc861_ignore); | |
13040 | if (err < 0) | |
df694daa | 13041 | return err; |
f12ab1e0 | 13042 | if (!spec->autocfg.line_outs) |
df694daa KY |
13043 | return 0; /* can't find valid BIOS pin config */ |
13044 | ||
f12ab1e0 TI |
13045 | err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); |
13046 | if (err < 0) | |
13047 | return err; | |
13048 | err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
13049 | if (err < 0) | |
13050 | return err; | |
13051 | err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | |
13052 | if (err < 0) | |
13053 | return err; | |
13054 | err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
13055 | if (err < 0) | |
df694daa KY |
13056 | return err; |
13057 | ||
13058 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
13059 | ||
13060 | if (spec->autocfg.dig_out_pin) | |
13061 | spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; | |
13062 | ||
603c4019 | 13063 | if (spec->kctls.list) |
d88897ea | 13064 | add_mixer(spec, spec->kctls.list); |
df694daa | 13065 | |
d88897ea | 13066 | add_verb(spec, alc861_auto_init_verbs); |
df694daa | 13067 | |
a1e8d2da | 13068 | spec->num_mux_defs = 1; |
df694daa KY |
13069 | spec->input_mux = &spec->private_imux; |
13070 | ||
13071 | spec->adc_nids = alc861_adc_nids; | |
13072 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); | |
f9e336f6 | 13073 | set_capture_mixer(spec); |
df694daa | 13074 | |
e044c39a | 13075 | store_pin_configs(codec); |
df694daa KY |
13076 | return 1; |
13077 | } | |
13078 | ||
ae6b813a TI |
13079 | /* additional initialization for auto-configuration model */ |
13080 | static void alc861_auto_init(struct hda_codec *codec) | |
df694daa | 13081 | { |
f6c7e546 | 13082 | struct alc_spec *spec = codec->spec; |
df694daa KY |
13083 | alc861_auto_init_multi_out(codec); |
13084 | alc861_auto_init_hp_out(codec); | |
13085 | alc861_auto_init_analog_input(codec); | |
f6c7e546 | 13086 | if (spec->unsol_event) |
7fb0d78f | 13087 | alc_inithook(codec); |
df694daa KY |
13088 | } |
13089 | ||
cb53c626 TI |
13090 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
13091 | static struct hda_amp_list alc861_loopbacks[] = { | |
13092 | { 0x15, HDA_INPUT, 0 }, | |
13093 | { 0x15, HDA_INPUT, 1 }, | |
13094 | { 0x15, HDA_INPUT, 2 }, | |
13095 | { 0x15, HDA_INPUT, 3 }, | |
13096 | { } /* end */ | |
13097 | }; | |
13098 | #endif | |
13099 | ||
df694daa KY |
13100 | |
13101 | /* | |
13102 | * configuration and preset | |
13103 | */ | |
f5fcc13c TI |
13104 | static const char *alc861_models[ALC861_MODEL_LAST] = { |
13105 | [ALC861_3ST] = "3stack", | |
13106 | [ALC660_3ST] = "3stack-660", | |
13107 | [ALC861_3ST_DIG] = "3stack-dig", | |
13108 | [ALC861_6ST_DIG] = "6stack-dig", | |
13109 | [ALC861_UNIWILL_M31] = "uniwill-m31", | |
13110 | [ALC861_TOSHIBA] = "toshiba", | |
13111 | [ALC861_ASUS] = "asus", | |
13112 | [ALC861_ASUS_LAPTOP] = "asus-laptop", | |
13113 | [ALC861_AUTO] = "auto", | |
13114 | }; | |
13115 | ||
13116 | static struct snd_pci_quirk alc861_cfg_tbl[] = { | |
687a47bd | 13117 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), |
f5fcc13c TI |
13118 | SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), |
13119 | SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), | |
13120 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), | |
ac3e3741 | 13121 | SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP), |
83c34218 | 13122 | SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG), |
ad5e7737 | 13123 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), |
341d4eb0 TI |
13124 | /* FIXME: the entry below breaks Toshiba A100 (model=auto works!) |
13125 | * Any other models that need this preset? | |
13126 | */ | |
13127 | /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */ | |
ac3e3741 TI |
13128 | SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST), |
13129 | SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST), | |
4147dab6 | 13130 | SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), |
ac3e3741 TI |
13131 | SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), |
13132 | SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP), | |
13133 | /* FIXME: the below seems conflict */ | |
13134 | /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */ | |
07e038b3 | 13135 | SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST), |
f5fcc13c | 13136 | SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), |
df694daa KY |
13137 | {} |
13138 | }; | |
13139 | ||
13140 | static struct alc_config_preset alc861_presets[] = { | |
13141 | [ALC861_3ST] = { | |
13142 | .mixers = { alc861_3ST_mixer }, | |
13143 | .init_verbs = { alc861_threestack_init_verbs }, | |
13144 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13145 | .dac_nids = alc861_dac_nids, | |
13146 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
13147 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 13148 | .need_dac_fix = 1, |
df694daa KY |
13149 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
13150 | .adc_nids = alc861_adc_nids, | |
13151 | .input_mux = &alc861_capture_source, | |
13152 | }, | |
13153 | [ALC861_3ST_DIG] = { | |
13154 | .mixers = { alc861_base_mixer }, | |
13155 | .init_verbs = { alc861_threestack_init_verbs }, | |
13156 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13157 | .dac_nids = alc861_dac_nids, | |
13158 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13159 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
13160 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 13161 | .need_dac_fix = 1, |
df694daa KY |
13162 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
13163 | .adc_nids = alc861_adc_nids, | |
13164 | .input_mux = &alc861_capture_source, | |
13165 | }, | |
13166 | [ALC861_6ST_DIG] = { | |
13167 | .mixers = { alc861_base_mixer }, | |
13168 | .init_verbs = { alc861_base_init_verbs }, | |
13169 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13170 | .dac_nids = alc861_dac_nids, | |
13171 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13172 | .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), | |
13173 | .channel_mode = alc861_8ch_modes, | |
13174 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13175 | .adc_nids = alc861_adc_nids, | |
13176 | .input_mux = &alc861_capture_source, | |
13177 | }, | |
9c7f852e TI |
13178 | [ALC660_3ST] = { |
13179 | .mixers = { alc861_3ST_mixer }, | |
13180 | .init_verbs = { alc861_threestack_init_verbs }, | |
13181 | .num_dacs = ARRAY_SIZE(alc660_dac_nids), | |
13182 | .dac_nids = alc660_dac_nids, | |
13183 | .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), | |
13184 | .channel_mode = alc861_threestack_modes, | |
4e195a7b | 13185 | .need_dac_fix = 1, |
9c7f852e TI |
13186 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), |
13187 | .adc_nids = alc861_adc_nids, | |
13188 | .input_mux = &alc861_capture_source, | |
13189 | }, | |
22309c3e TI |
13190 | [ALC861_UNIWILL_M31] = { |
13191 | .mixers = { alc861_uniwill_m31_mixer }, | |
13192 | .init_verbs = { alc861_uniwill_m31_init_verbs }, | |
13193 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13194 | .dac_nids = alc861_dac_nids, | |
13195 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13196 | .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes), | |
13197 | .channel_mode = alc861_uniwill_m31_modes, | |
13198 | .need_dac_fix = 1, | |
13199 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13200 | .adc_nids = alc861_adc_nids, | |
13201 | .input_mux = &alc861_capture_source, | |
13202 | }, | |
a53d1aec TD |
13203 | [ALC861_TOSHIBA] = { |
13204 | .mixers = { alc861_toshiba_mixer }, | |
f12ab1e0 TI |
13205 | .init_verbs = { alc861_base_init_verbs, |
13206 | alc861_toshiba_init_verbs }, | |
a53d1aec TD |
13207 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), |
13208 | .dac_nids = alc861_dac_nids, | |
13209 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
13210 | .channel_mode = alc883_3ST_2ch_modes, | |
13211 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13212 | .adc_nids = alc861_adc_nids, | |
13213 | .input_mux = &alc861_capture_source, | |
13214 | .unsol_event = alc861_toshiba_unsol_event, | |
13215 | .init_hook = alc861_toshiba_automute, | |
13216 | }, | |
7cdbff94 MD |
13217 | [ALC861_ASUS] = { |
13218 | .mixers = { alc861_asus_mixer }, | |
13219 | .init_verbs = { alc861_asus_init_verbs }, | |
13220 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13221 | .dac_nids = alc861_dac_nids, | |
13222 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13223 | .num_channel_mode = ARRAY_SIZE(alc861_asus_modes), | |
13224 | .channel_mode = alc861_asus_modes, | |
13225 | .need_dac_fix = 1, | |
13226 | .hp_nid = 0x06, | |
13227 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13228 | .adc_nids = alc861_adc_nids, | |
13229 | .input_mux = &alc861_capture_source, | |
13230 | }, | |
56bb0cab TI |
13231 | [ALC861_ASUS_LAPTOP] = { |
13232 | .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer }, | |
13233 | .init_verbs = { alc861_asus_init_verbs, | |
13234 | alc861_asus_laptop_init_verbs }, | |
13235 | .num_dacs = ARRAY_SIZE(alc861_dac_nids), | |
13236 | .dac_nids = alc861_dac_nids, | |
13237 | .dig_out_nid = ALC861_DIGOUT_NID, | |
13238 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), | |
13239 | .channel_mode = alc883_3ST_2ch_modes, | |
13240 | .need_dac_fix = 1, | |
13241 | .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), | |
13242 | .adc_nids = alc861_adc_nids, | |
13243 | .input_mux = &alc861_capture_source, | |
13244 | }, | |
13245 | }; | |
df694daa KY |
13246 | |
13247 | ||
13248 | static int patch_alc861(struct hda_codec *codec) | |
13249 | { | |
13250 | struct alc_spec *spec; | |
13251 | int board_config; | |
13252 | int err; | |
13253 | ||
dc041e0b | 13254 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
df694daa KY |
13255 | if (spec == NULL) |
13256 | return -ENOMEM; | |
13257 | ||
f12ab1e0 | 13258 | codec->spec = spec; |
df694daa | 13259 | |
f5fcc13c TI |
13260 | board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, |
13261 | alc861_models, | |
13262 | alc861_cfg_tbl); | |
9c7f852e | 13263 | |
f5fcc13c | 13264 | if (board_config < 0) { |
9c7f852e TI |
13265 | printk(KERN_INFO "hda_codec: Unknown model for ALC861, " |
13266 | "trying auto-probe from BIOS...\n"); | |
df694daa KY |
13267 | board_config = ALC861_AUTO; |
13268 | } | |
13269 | ||
13270 | if (board_config == ALC861_AUTO) { | |
13271 | /* automatic parse from the BIOS config */ | |
13272 | err = alc861_parse_auto_config(codec); | |
13273 | if (err < 0) { | |
13274 | alc_free(codec); | |
13275 | return err; | |
f12ab1e0 | 13276 | } else if (!err) { |
9c7f852e TI |
13277 | printk(KERN_INFO |
13278 | "hda_codec: Cannot set up configuration " | |
13279 | "from BIOS. Using base mode...\n"); | |
df694daa KY |
13280 | board_config = ALC861_3ST_DIG; |
13281 | } | |
13282 | } | |
13283 | ||
13284 | if (board_config != ALC861_AUTO) | |
13285 | setup_preset(spec, &alc861_presets[board_config]); | |
13286 | ||
13287 | spec->stream_name_analog = "ALC861 Analog"; | |
13288 | spec->stream_analog_playback = &alc861_pcm_analog_playback; | |
13289 | spec->stream_analog_capture = &alc861_pcm_analog_capture; | |
13290 | ||
13291 | spec->stream_name_digital = "ALC861 Digital"; | |
13292 | spec->stream_digital_playback = &alc861_pcm_digital_playback; | |
13293 | spec->stream_digital_capture = &alc861_pcm_digital_capture; | |
13294 | ||
2134ea4f TI |
13295 | spec->vmaster_nid = 0x03; |
13296 | ||
df694daa KY |
13297 | codec->patch_ops = alc_patch_ops; |
13298 | if (board_config == ALC861_AUTO) | |
ae6b813a | 13299 | spec->init_hook = alc861_auto_init; |
cb53c626 TI |
13300 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
13301 | if (!spec->loopback.amplist) | |
13302 | spec->loopback.amplist = alc861_loopbacks; | |
13303 | #endif | |
ea1fb29a | 13304 | |
1da177e4 LT |
13305 | return 0; |
13306 | } | |
13307 | ||
f32610ed JS |
13308 | /* |
13309 | * ALC861-VD support | |
13310 | * | |
13311 | * Based on ALC882 | |
13312 | * | |
13313 | * In addition, an independent DAC | |
13314 | */ | |
13315 | #define ALC861VD_DIGOUT_NID 0x06 | |
13316 | ||
13317 | static hda_nid_t alc861vd_dac_nids[4] = { | |
13318 | /* front, surr, clfe, side surr */ | |
13319 | 0x02, 0x03, 0x04, 0x05 | |
13320 | }; | |
13321 | ||
13322 | /* dac_nids for ALC660vd are in a different order - according to | |
13323 | * Realtek's driver. | |
13324 | * This should probably tesult in a different mixer for 6stack models | |
13325 | * of ALC660vd codecs, but for now there is only 3stack mixer | |
13326 | * - and it is the same as in 861vd. | |
13327 | * adc_nids in ALC660vd are (is) the same as in 861vd | |
13328 | */ | |
13329 | static hda_nid_t alc660vd_dac_nids[3] = { | |
13330 | /* front, rear, clfe, rear_surr */ | |
13331 | 0x02, 0x04, 0x03 | |
13332 | }; | |
13333 | ||
13334 | static hda_nid_t alc861vd_adc_nids[1] = { | |
13335 | /* ADC0 */ | |
13336 | 0x09, | |
13337 | }; | |
13338 | ||
e1406348 TI |
13339 | static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 }; |
13340 | ||
f32610ed JS |
13341 | /* input MUX */ |
13342 | /* FIXME: should be a matrix-type input source selection */ | |
13343 | static struct hda_input_mux alc861vd_capture_source = { | |
13344 | .num_items = 4, | |
13345 | .items = { | |
13346 | { "Mic", 0x0 }, | |
13347 | { "Front Mic", 0x1 }, | |
13348 | { "Line", 0x2 }, | |
13349 | { "CD", 0x4 }, | |
13350 | }, | |
13351 | }; | |
13352 | ||
272a527c | 13353 | static struct hda_input_mux alc861vd_dallas_capture_source = { |
b419f346 | 13354 | .num_items = 2, |
272a527c | 13355 | .items = { |
b419f346 TD |
13356 | { "Ext Mic", 0x0 }, |
13357 | { "Int Mic", 0x1 }, | |
272a527c KY |
13358 | }, |
13359 | }; | |
13360 | ||
d1a991a6 KY |
13361 | static struct hda_input_mux alc861vd_hp_capture_source = { |
13362 | .num_items = 2, | |
13363 | .items = { | |
13364 | { "Front Mic", 0x0 }, | |
13365 | { "ATAPI Mic", 0x1 }, | |
13366 | }, | |
13367 | }; | |
13368 | ||
f32610ed JS |
13369 | /* |
13370 | * 2ch mode | |
13371 | */ | |
13372 | static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = { | |
13373 | { 2, NULL } | |
13374 | }; | |
13375 | ||
13376 | /* | |
13377 | * 6ch mode | |
13378 | */ | |
13379 | static struct hda_verb alc861vd_6stack_ch6_init[] = { | |
13380 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
13381 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13382 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13383 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13384 | { } /* end */ | |
13385 | }; | |
13386 | ||
13387 | /* | |
13388 | * 8ch mode | |
13389 | */ | |
13390 | static struct hda_verb alc861vd_6stack_ch8_init[] = { | |
13391 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13392 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13393 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13394 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
13395 | { } /* end */ | |
13396 | }; | |
13397 | ||
13398 | static struct hda_channel_mode alc861vd_6stack_modes[2] = { | |
13399 | { 6, alc861vd_6stack_ch6_init }, | |
13400 | { 8, alc861vd_6stack_ch8_init }, | |
13401 | }; | |
13402 | ||
13403 | static struct snd_kcontrol_new alc861vd_chmode_mixer[] = { | |
13404 | { | |
13405 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
13406 | .name = "Channel Mode", | |
13407 | .info = alc_ch_mode_info, | |
13408 | .get = alc_ch_mode_get, | |
13409 | .put = alc_ch_mode_put, | |
13410 | }, | |
13411 | { } /* end */ | |
13412 | }; | |
13413 | ||
f32610ed JS |
13414 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
13415 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
13416 | */ | |
13417 | static struct snd_kcontrol_new alc861vd_6st_mixer[] = { | |
13418 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
13419 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
13420 | ||
13421 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
13422 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | |
13423 | ||
13424 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, | |
13425 | HDA_OUTPUT), | |
13426 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, | |
13427 | HDA_OUTPUT), | |
13428 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | |
13429 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | |
13430 | ||
13431 | HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT), | |
13432 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | |
13433 | ||
13434 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
13435 | ||
13436 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
13437 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13438 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13439 | ||
13440 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
13441 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13442 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13443 | ||
13444 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
13445 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
13446 | ||
13447 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
13448 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
13449 | ||
13450 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
13451 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
13452 | ||
13453 | { } /* end */ | |
13454 | }; | |
13455 | ||
13456 | static struct snd_kcontrol_new alc861vd_3st_mixer[] = { | |
13457 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
13458 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
13459 | ||
13460 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
13461 | ||
13462 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
13463 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13464 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13465 | ||
13466 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
13467 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13468 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13469 | ||
13470 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
13471 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
13472 | ||
13473 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
13474 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
13475 | ||
13476 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
13477 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
13478 | ||
13479 | { } /* end */ | |
13480 | }; | |
13481 | ||
bdd148a3 KY |
13482 | static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = { |
13483 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
13484 | /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/ | |
13485 | HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
13486 | ||
13487 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
13488 | ||
13489 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | |
13490 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13491 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13492 | ||
13493 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | |
13494 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13495 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13496 | ||
13497 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
13498 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
13499 | ||
13500 | { } /* end */ | |
13501 | }; | |
13502 | ||
b419f346 TD |
13503 | /* Pin assignment: Speaker=0x14, HP = 0x15, |
13504 | * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d | |
272a527c KY |
13505 | */ |
13506 | static struct snd_kcontrol_new alc861vd_dallas_mixer[] = { | |
b419f346 TD |
13507 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
13508 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT), | |
272a527c KY |
13509 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
13510 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
b419f346 TD |
13511 | HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT), |
13512 | HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13513 | HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13514 | HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), | |
13515 | HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13516 | HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
13517 | HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT), | |
13518 | HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT), | |
272a527c KY |
13519 | { } /* end */ |
13520 | }; | |
13521 | ||
d1a991a6 KY |
13522 | /* Pin assignment: Speaker=0x14, Line-out = 0x15, |
13523 | * Front Mic=0x18, ATAPI Mic = 0x19, | |
13524 | */ | |
13525 | static struct snd_kcontrol_new alc861vd_hp_mixer[] = { | |
13526 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
13527 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | |
13528 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
13529 | HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), | |
13530 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
13531 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
13532 | HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
13533 | HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
ea1fb29a | 13534 | |
d1a991a6 KY |
13535 | { } /* end */ |
13536 | }; | |
13537 | ||
f32610ed JS |
13538 | /* |
13539 | * generic initialization of ADC, input mixers and output mixers | |
13540 | */ | |
13541 | static struct hda_verb alc861vd_volume_init_verbs[] = { | |
13542 | /* | |
13543 | * Unmute ADC0 and set the default input to mic-in | |
13544 | */ | |
13545 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13546 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13547 | ||
13548 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of | |
13549 | * the analog-loopback mixer widget | |
13550 | */ | |
13551 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
13552 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
13553 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13554 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
13555 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
13556 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
f32610ed JS |
13557 | |
13558 | /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */ | |
bdd148a3 KY |
13559 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
13560 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13561 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
f32610ed | 13562 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
f32610ed JS |
13563 | |
13564 | /* | |
13565 | * Set up output mixers (0x02 - 0x05) | |
13566 | */ | |
13567 | /* set vol=0 to output mixers */ | |
13568 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13569 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13570 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13571 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13572 | ||
13573 | /* set up input amps for analog loopback */ | |
13574 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
13575 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13576 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13577 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13578 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13579 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13580 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13581 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13582 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13583 | ||
13584 | { } | |
13585 | }; | |
13586 | ||
13587 | /* | |
13588 | * 3-stack pin configuration: | |
13589 | * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b | |
13590 | */ | |
13591 | static struct hda_verb alc861vd_3stack_init_verbs[] = { | |
13592 | /* | |
13593 | * Set pin mode and muting | |
13594 | */ | |
13595 | /* set front pin widgets 0x14 for output */ | |
13596 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13597 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13598 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13599 | ||
13600 | /* Mic (rear) pin: input vref at 80% */ | |
13601 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
13602 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13603 | /* Front Mic pin: input vref at 80% */ | |
13604 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
13605 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13606 | /* Line In pin: input */ | |
13607 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13608 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13609 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
13610 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
13611 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13612 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13613 | /* CD pin widget for input */ | |
13614 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13615 | ||
13616 | { } | |
13617 | }; | |
13618 | ||
13619 | /* | |
13620 | * 6-stack pin configuration: | |
13621 | */ | |
13622 | static struct hda_verb alc861vd_6stack_init_verbs[] = { | |
13623 | /* | |
13624 | * Set pin mode and muting | |
13625 | */ | |
13626 | /* set front pin widgets 0x14 for output */ | |
13627 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13628 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13629 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13630 | ||
13631 | /* Rear Pin: output 1 (0x0d) */ | |
13632 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13633 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13634 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
13635 | /* CLFE Pin: output 2 (0x0e) */ | |
13636 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13637 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13638 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | |
13639 | /* Side Pin: output 3 (0x0f) */ | |
13640 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13641 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13642 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
13643 | ||
13644 | /* Mic (rear) pin: input vref at 80% */ | |
13645 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
13646 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13647 | /* Front Mic pin: input vref at 80% */ | |
13648 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
13649 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13650 | /* Line In pin: input */ | |
13651 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13652 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13653 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
13654 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
13655 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13656 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
13657 | /* CD pin widget for input */ | |
13658 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13659 | ||
13660 | { } | |
13661 | }; | |
13662 | ||
bdd148a3 KY |
13663 | static struct hda_verb alc861vd_eapd_verbs[] = { |
13664 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
13665 | { } | |
13666 | }; | |
13667 | ||
f9423e7a KY |
13668 | static struct hda_verb alc660vd_eapd_verbs[] = { |
13669 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
13670 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
13671 | { } | |
13672 | }; | |
13673 | ||
bdd148a3 KY |
13674 | static struct hda_verb alc861vd_lenovo_unsol_verbs[] = { |
13675 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13676 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13677 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, | |
13678 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
ea1fb29a | 13679 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, |
bdd148a3 KY |
13680 | {} |
13681 | }; | |
13682 | ||
13683 | /* toggle speaker-output according to the hp-jack state */ | |
13684 | static void alc861vd_lenovo_hp_automute(struct hda_codec *codec) | |
13685 | { | |
13686 | unsigned int present; | |
13687 | unsigned char bits; | |
13688 | ||
13689 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
13690 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
13691 | bits = present ? HDA_AMP_MUTE : 0; |
13692 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
13693 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
13694 | } |
13695 | ||
13696 | static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | |
13697 | { | |
13698 | unsigned int present; | |
13699 | unsigned char bits; | |
13700 | ||
13701 | present = snd_hda_codec_read(codec, 0x18, 0, | |
13702 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
13703 | bits = present ? HDA_AMP_MUTE : 0; |
13704 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, | |
13705 | HDA_AMP_MUTE, bits); | |
bdd148a3 KY |
13706 | } |
13707 | ||
13708 | static void alc861vd_lenovo_automute(struct hda_codec *codec) | |
13709 | { | |
13710 | alc861vd_lenovo_hp_automute(codec); | |
13711 | alc861vd_lenovo_mic_automute(codec); | |
13712 | } | |
13713 | ||
13714 | static void alc861vd_lenovo_unsol_event(struct hda_codec *codec, | |
13715 | unsigned int res) | |
13716 | { | |
13717 | switch (res >> 26) { | |
13718 | case ALC880_HP_EVENT: | |
13719 | alc861vd_lenovo_hp_automute(codec); | |
13720 | break; | |
13721 | case ALC880_MIC_EVENT: | |
13722 | alc861vd_lenovo_mic_automute(codec); | |
13723 | break; | |
13724 | } | |
13725 | } | |
13726 | ||
272a527c KY |
13727 | static struct hda_verb alc861vd_dallas_verbs[] = { |
13728 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13729 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13730 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13731 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
13732 | ||
13733 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13734 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
13735 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13736 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13737 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13738 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
13739 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
13740 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
ea1fb29a | 13741 | |
272a527c KY |
13742 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
13743 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13744 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13745 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13746 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13747 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13748 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
13749 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
13750 | ||
13751 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
13752 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13753 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50}, | |
13754 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
13755 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13756 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13757 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13758 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
13759 | ||
13760 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
13761 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
13762 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
13763 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
13764 | ||
13765 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
ea1fb29a | 13766 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
272a527c KY |
13767 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, |
13768 | ||
13769 | { } /* end */ | |
13770 | }; | |
13771 | ||
13772 | /* toggle speaker-output according to the hp-jack state */ | |
13773 | static void alc861vd_dallas_automute(struct hda_codec *codec) | |
13774 | { | |
13775 | unsigned int present; | |
13776 | ||
13777 | present = snd_hda_codec_read(codec, 0x15, 0, | |
13778 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
13779 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, |
13780 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | |
272a527c KY |
13781 | } |
13782 | ||
13783 | static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res) | |
13784 | { | |
13785 | if ((res >> 26) == ALC880_HP_EVENT) | |
13786 | alc861vd_dallas_automute(codec); | |
13787 | } | |
13788 | ||
cb53c626 TI |
13789 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
13790 | #define alc861vd_loopbacks alc880_loopbacks | |
13791 | #endif | |
13792 | ||
f32610ed JS |
13793 | /* pcm configuration: identiacal with ALC880 */ |
13794 | #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback | |
13795 | #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture | |
13796 | #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback | |
13797 | #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture | |
13798 | ||
13799 | /* | |
13800 | * configuration and preset | |
13801 | */ | |
13802 | static const char *alc861vd_models[ALC861VD_MODEL_LAST] = { | |
13803 | [ALC660VD_3ST] = "3stack-660", | |
983f8ae4 | 13804 | [ALC660VD_3ST_DIG] = "3stack-660-digout", |
f32610ed JS |
13805 | [ALC861VD_3ST] = "3stack", |
13806 | [ALC861VD_3ST_DIG] = "3stack-digout", | |
13807 | [ALC861VD_6ST_DIG] = "6stack-digout", | |
bdd148a3 | 13808 | [ALC861VD_LENOVO] = "lenovo", |
272a527c | 13809 | [ALC861VD_DALLAS] = "dallas", |
983f8ae4 | 13810 | [ALC861VD_HP] = "hp", |
f32610ed JS |
13811 | [ALC861VD_AUTO] = "auto", |
13812 | }; | |
13813 | ||
13814 | static struct snd_pci_quirk alc861vd_cfg_tbl[] = { | |
ac3e3741 TI |
13815 | SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), |
13816 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP), | |
07e038b3 | 13817 | SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST), |
f32610ed | 13818 | SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), |
2522d735 | 13819 | SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC861VD_LENOVO), |
6963f84c | 13820 | SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG), |
f32610ed | 13821 | SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), |
ac3e3741 | 13822 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), |
38baf5ad | 13823 | /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ |
272a527c | 13824 | SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), |
542d7c66 | 13825 | SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), |
b419f346 | 13826 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS), |
39c5d41f | 13827 | SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), |
ac3e3741 TI |
13828 | SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO), |
13829 | SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO), | |
be321a89 | 13830 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO), |
625dc0bf | 13831 | SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG), |
f32610ed JS |
13832 | {} |
13833 | }; | |
13834 | ||
13835 | static struct alc_config_preset alc861vd_presets[] = { | |
13836 | [ALC660VD_3ST] = { | |
13837 | .mixers = { alc861vd_3st_mixer }, | |
13838 | .init_verbs = { alc861vd_volume_init_verbs, | |
13839 | alc861vd_3stack_init_verbs }, | |
13840 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
13841 | .dac_nids = alc660vd_dac_nids, | |
f32610ed JS |
13842 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
13843 | .channel_mode = alc861vd_3stack_2ch_modes, | |
13844 | .input_mux = &alc861vd_capture_source, | |
13845 | }, | |
6963f84c MC |
13846 | [ALC660VD_3ST_DIG] = { |
13847 | .mixers = { alc861vd_3st_mixer }, | |
13848 | .init_verbs = { alc861vd_volume_init_verbs, | |
13849 | alc861vd_3stack_init_verbs }, | |
13850 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
13851 | .dac_nids = alc660vd_dac_nids, | |
13852 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
6963f84c MC |
13853 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
13854 | .channel_mode = alc861vd_3stack_2ch_modes, | |
13855 | .input_mux = &alc861vd_capture_source, | |
13856 | }, | |
f32610ed JS |
13857 | [ALC861VD_3ST] = { |
13858 | .mixers = { alc861vd_3st_mixer }, | |
13859 | .init_verbs = { alc861vd_volume_init_verbs, | |
13860 | alc861vd_3stack_init_verbs }, | |
13861 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
13862 | .dac_nids = alc861vd_dac_nids, | |
13863 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
13864 | .channel_mode = alc861vd_3stack_2ch_modes, | |
13865 | .input_mux = &alc861vd_capture_source, | |
13866 | }, | |
13867 | [ALC861VD_3ST_DIG] = { | |
13868 | .mixers = { alc861vd_3st_mixer }, | |
13869 | .init_verbs = { alc861vd_volume_init_verbs, | |
13870 | alc861vd_3stack_init_verbs }, | |
13871 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
13872 | .dac_nids = alc861vd_dac_nids, | |
13873 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
13874 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), | |
13875 | .channel_mode = alc861vd_3stack_2ch_modes, | |
13876 | .input_mux = &alc861vd_capture_source, | |
13877 | }, | |
13878 | [ALC861VD_6ST_DIG] = { | |
13879 | .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer }, | |
13880 | .init_verbs = { alc861vd_volume_init_verbs, | |
13881 | alc861vd_6stack_init_verbs }, | |
13882 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
13883 | .dac_nids = alc861vd_dac_nids, | |
13884 | .dig_out_nid = ALC861VD_DIGOUT_NID, | |
13885 | .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes), | |
13886 | .channel_mode = alc861vd_6stack_modes, | |
13887 | .input_mux = &alc861vd_capture_source, | |
13888 | }, | |
bdd148a3 KY |
13889 | [ALC861VD_LENOVO] = { |
13890 | .mixers = { alc861vd_lenovo_mixer }, | |
13891 | .init_verbs = { alc861vd_volume_init_verbs, | |
13892 | alc861vd_3stack_init_verbs, | |
13893 | alc861vd_eapd_verbs, | |
13894 | alc861vd_lenovo_unsol_verbs }, | |
13895 | .num_dacs = ARRAY_SIZE(alc660vd_dac_nids), | |
13896 | .dac_nids = alc660vd_dac_nids, | |
bdd148a3 KY |
13897 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
13898 | .channel_mode = alc861vd_3stack_2ch_modes, | |
13899 | .input_mux = &alc861vd_capture_source, | |
13900 | .unsol_event = alc861vd_lenovo_unsol_event, | |
13901 | .init_hook = alc861vd_lenovo_automute, | |
13902 | }, | |
272a527c KY |
13903 | [ALC861VD_DALLAS] = { |
13904 | .mixers = { alc861vd_dallas_mixer }, | |
13905 | .init_verbs = { alc861vd_dallas_verbs }, | |
13906 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
13907 | .dac_nids = alc861vd_dac_nids, | |
272a527c KY |
13908 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
13909 | .channel_mode = alc861vd_3stack_2ch_modes, | |
13910 | .input_mux = &alc861vd_dallas_capture_source, | |
13911 | .unsol_event = alc861vd_dallas_unsol_event, | |
13912 | .init_hook = alc861vd_dallas_automute, | |
d1a991a6 KY |
13913 | }, |
13914 | [ALC861VD_HP] = { | |
13915 | .mixers = { alc861vd_hp_mixer }, | |
13916 | .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs }, | |
13917 | .num_dacs = ARRAY_SIZE(alc861vd_dac_nids), | |
13918 | .dac_nids = alc861vd_dac_nids, | |
d1a991a6 | 13919 | .dig_out_nid = ALC861VD_DIGOUT_NID, |
d1a991a6 KY |
13920 | .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes), |
13921 | .channel_mode = alc861vd_3stack_2ch_modes, | |
13922 | .input_mux = &alc861vd_hp_capture_source, | |
13923 | .unsol_event = alc861vd_dallas_unsol_event, | |
13924 | .init_hook = alc861vd_dallas_automute, | |
ea1fb29a | 13925 | }, |
f32610ed JS |
13926 | }; |
13927 | ||
13928 | /* | |
13929 | * BIOS auto configuration | |
13930 | */ | |
13931 | static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, | |
13932 | hda_nid_t nid, int pin_type, int dac_idx) | |
13933 | { | |
f6c7e546 | 13934 | alc_set_pin_output(codec, nid, pin_type); |
f32610ed JS |
13935 | } |
13936 | ||
13937 | static void alc861vd_auto_init_multi_out(struct hda_codec *codec) | |
13938 | { | |
13939 | struct alc_spec *spec = codec->spec; | |
13940 | int i; | |
13941 | ||
bc9f98a9 | 13942 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
f32610ed JS |
13943 | for (i = 0; i <= HDA_SIDE; i++) { |
13944 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 13945 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
f32610ed JS |
13946 | if (nid) |
13947 | alc861vd_auto_set_output_and_unmute(codec, nid, | |
baba8ee9 | 13948 | pin_type, i); |
f32610ed JS |
13949 | } |
13950 | } | |
13951 | ||
13952 | ||
13953 | static void alc861vd_auto_init_hp_out(struct hda_codec *codec) | |
13954 | { | |
13955 | struct alc_spec *spec = codec->spec; | |
13956 | hda_nid_t pin; | |
13957 | ||
13958 | pin = spec->autocfg.hp_pins[0]; | |
13959 | if (pin) /* connect to front and use dac 0 */ | |
13960 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
13961 | pin = spec->autocfg.speaker_pins[0]; |
13962 | if (pin) | |
13963 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
f32610ed JS |
13964 | } |
13965 | ||
13966 | #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid) | |
13967 | #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID | |
13968 | ||
13969 | static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | |
13970 | { | |
13971 | struct alc_spec *spec = codec->spec; | |
13972 | int i; | |
13973 | ||
13974 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
13975 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
13976 | if (alc861vd_is_input_pin(nid)) { | |
13977 | snd_hda_codec_write(codec, nid, 0, | |
13978 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
13979 | i <= AUTO_PIN_FRONT_MIC ? | |
13980 | PIN_VREF80 : PIN_IN); | |
13981 | if (nid != ALC861VD_PIN_CD_NID) | |
13982 | snd_hda_codec_write(codec, nid, 0, | |
13983 | AC_VERB_SET_AMP_GAIN_MUTE, | |
13984 | AMP_OUT_MUTE); | |
13985 | } | |
13986 | } | |
13987 | } | |
13988 | ||
f511b01c TI |
13989 | #define alc861vd_auto_init_input_src alc882_auto_init_input_src |
13990 | ||
f32610ed JS |
13991 | #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02) |
13992 | #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c) | |
13993 | ||
13994 | /* add playback controls from the parsed DAC table */ | |
13995 | /* Based on ALC880 version. But ALC861VD has separate, | |
13996 | * different NIDs for mute/unmute switch and volume control */ | |
13997 | static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |
13998 | const struct auto_pin_cfg *cfg) | |
13999 | { | |
14000 | char name[32]; | |
14001 | static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"}; | |
14002 | hda_nid_t nid_v, nid_s; | |
14003 | int i, err; | |
14004 | ||
14005 | for (i = 0; i < cfg->line_outs; i++) { | |
f12ab1e0 | 14006 | if (!spec->multiout.dac_nids[i]) |
f32610ed JS |
14007 | continue; |
14008 | nid_v = alc861vd_idx_to_mixer_vol( | |
14009 | alc880_dac_to_idx( | |
14010 | spec->multiout.dac_nids[i])); | |
14011 | nid_s = alc861vd_idx_to_mixer_switch( | |
14012 | alc880_dac_to_idx( | |
14013 | spec->multiout.dac_nids[i])); | |
14014 | ||
14015 | if (i == 2) { | |
14016 | /* Center/LFE */ | |
f12ab1e0 TI |
14017 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
14018 | "Center Playback Volume", | |
14019 | HDA_COMPOSE_AMP_VAL(nid_v, 1, 0, | |
14020 | HDA_OUTPUT)); | |
14021 | if (err < 0) | |
f32610ed | 14022 | return err; |
f12ab1e0 TI |
14023 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
14024 | "LFE Playback Volume", | |
14025 | HDA_COMPOSE_AMP_VAL(nid_v, 2, 0, | |
14026 | HDA_OUTPUT)); | |
14027 | if (err < 0) | |
f32610ed | 14028 | return err; |
f12ab1e0 TI |
14029 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
14030 | "Center Playback Switch", | |
14031 | HDA_COMPOSE_AMP_VAL(nid_s, 1, 2, | |
14032 | HDA_INPUT)); | |
14033 | if (err < 0) | |
f32610ed | 14034 | return err; |
f12ab1e0 TI |
14035 | err = add_control(spec, ALC_CTL_BIND_MUTE, |
14036 | "LFE Playback Switch", | |
14037 | HDA_COMPOSE_AMP_VAL(nid_s, 2, 2, | |
14038 | HDA_INPUT)); | |
14039 | if (err < 0) | |
f32610ed JS |
14040 | return err; |
14041 | } else { | |
14042 | sprintf(name, "%s Playback Volume", chname[i]); | |
f12ab1e0 TI |
14043 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
14044 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, | |
14045 | HDA_OUTPUT)); | |
14046 | if (err < 0) | |
f32610ed JS |
14047 | return err; |
14048 | sprintf(name, "%s Playback Switch", chname[i]); | |
f12ab1e0 | 14049 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
bdd148a3 | 14050 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, |
f12ab1e0 TI |
14051 | HDA_INPUT)); |
14052 | if (err < 0) | |
f32610ed JS |
14053 | return err; |
14054 | } | |
14055 | } | |
14056 | return 0; | |
14057 | } | |
14058 | ||
14059 | /* add playback controls for speaker and HP outputs */ | |
14060 | /* Based on ALC880 version. But ALC861VD has separate, | |
14061 | * different NIDs for mute/unmute switch and volume control */ | |
14062 | static int alc861vd_auto_create_extra_out(struct alc_spec *spec, | |
14063 | hda_nid_t pin, const char *pfx) | |
14064 | { | |
14065 | hda_nid_t nid_v, nid_s; | |
14066 | int err; | |
14067 | char name[32]; | |
14068 | ||
f12ab1e0 | 14069 | if (!pin) |
f32610ed JS |
14070 | return 0; |
14071 | ||
14072 | if (alc880_is_fixed_pin(pin)) { | |
14073 | nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
14074 | /* specify the DAC as the extra output */ | |
f12ab1e0 | 14075 | if (!spec->multiout.hp_nid) |
f32610ed JS |
14076 | spec->multiout.hp_nid = nid_v; |
14077 | else | |
14078 | spec->multiout.extra_out_nid[0] = nid_v; | |
14079 | /* control HP volume/switch on the output mixer amp */ | |
14080 | nid_v = alc861vd_idx_to_mixer_vol( | |
14081 | alc880_fixed_pin_idx(pin)); | |
14082 | nid_s = alc861vd_idx_to_mixer_switch( | |
14083 | alc880_fixed_pin_idx(pin)); | |
14084 | ||
14085 | sprintf(name, "%s Playback Volume", pfx); | |
f12ab1e0 TI |
14086 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
14087 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT)); | |
14088 | if (err < 0) | |
f32610ed JS |
14089 | return err; |
14090 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
14091 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
14092 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT)); | |
14093 | if (err < 0) | |
f32610ed JS |
14094 | return err; |
14095 | } else if (alc880_is_multi_pin(pin)) { | |
14096 | /* set manual connection */ | |
14097 | /* we have only a switch on HP-out PIN */ | |
14098 | sprintf(name, "%s Playback Switch", pfx); | |
f12ab1e0 TI |
14099 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
14100 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
14101 | if (err < 0) | |
f32610ed JS |
14102 | return err; |
14103 | } | |
14104 | return 0; | |
14105 | } | |
14106 | ||
14107 | /* parse the BIOS configuration and set up the alc_spec | |
14108 | * return 1 if successful, 0 if the proper config is not found, | |
14109 | * or a negative error code | |
14110 | * Based on ALC880 version - had to change it to override | |
14111 | * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */ | |
14112 | static int alc861vd_parse_auto_config(struct hda_codec *codec) | |
14113 | { | |
14114 | struct alc_spec *spec = codec->spec; | |
14115 | int err; | |
14116 | static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; | |
14117 | ||
f12ab1e0 TI |
14118 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
14119 | alc861vd_ignore); | |
14120 | if (err < 0) | |
f32610ed | 14121 | return err; |
f12ab1e0 | 14122 | if (!spec->autocfg.line_outs) |
f32610ed JS |
14123 | return 0; /* can't find valid BIOS pin config */ |
14124 | ||
f12ab1e0 TI |
14125 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
14126 | if (err < 0) | |
14127 | return err; | |
14128 | err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
14129 | if (err < 0) | |
14130 | return err; | |
14131 | err = alc861vd_auto_create_extra_out(spec, | |
14132 | spec->autocfg.speaker_pins[0], | |
14133 | "Speaker"); | |
14134 | if (err < 0) | |
14135 | return err; | |
14136 | err = alc861vd_auto_create_extra_out(spec, | |
14137 | spec->autocfg.hp_pins[0], | |
14138 | "Headphone"); | |
14139 | if (err < 0) | |
14140 | return err; | |
14141 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
14142 | if (err < 0) | |
f32610ed JS |
14143 | return err; |
14144 | ||
14145 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
14146 | ||
14147 | if (spec->autocfg.dig_out_pin) | |
14148 | spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID; | |
14149 | ||
603c4019 | 14150 | if (spec->kctls.list) |
d88897ea | 14151 | add_mixer(spec, spec->kctls.list); |
f32610ed | 14152 | |
d88897ea | 14153 | add_verb(spec, alc861vd_volume_init_verbs); |
f32610ed JS |
14154 | |
14155 | spec->num_mux_defs = 1; | |
14156 | spec->input_mux = &spec->private_imux; | |
14157 | ||
776e184e TI |
14158 | err = alc_auto_add_mic_boost(codec); |
14159 | if (err < 0) | |
14160 | return err; | |
14161 | ||
e044c39a | 14162 | store_pin_configs(codec); |
f32610ed JS |
14163 | return 1; |
14164 | } | |
14165 | ||
14166 | /* additional initialization for auto-configuration model */ | |
14167 | static void alc861vd_auto_init(struct hda_codec *codec) | |
14168 | { | |
f6c7e546 | 14169 | struct alc_spec *spec = codec->spec; |
f32610ed JS |
14170 | alc861vd_auto_init_multi_out(codec); |
14171 | alc861vd_auto_init_hp_out(codec); | |
14172 | alc861vd_auto_init_analog_input(codec); | |
f511b01c | 14173 | alc861vd_auto_init_input_src(codec); |
f6c7e546 | 14174 | if (spec->unsol_event) |
7fb0d78f | 14175 | alc_inithook(codec); |
f32610ed JS |
14176 | } |
14177 | ||
14178 | static int patch_alc861vd(struct hda_codec *codec) | |
14179 | { | |
14180 | struct alc_spec *spec; | |
14181 | int err, board_config; | |
14182 | ||
14183 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
14184 | if (spec == NULL) | |
14185 | return -ENOMEM; | |
14186 | ||
14187 | codec->spec = spec; | |
14188 | ||
14189 | board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST, | |
14190 | alc861vd_models, | |
14191 | alc861vd_cfg_tbl); | |
14192 | ||
14193 | if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { | |
14194 | printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/" | |
14195 | "ALC861VD, trying auto-probe from BIOS...\n"); | |
14196 | board_config = ALC861VD_AUTO; | |
14197 | } | |
14198 | ||
14199 | if (board_config == ALC861VD_AUTO) { | |
14200 | /* automatic parse from the BIOS config */ | |
14201 | err = alc861vd_parse_auto_config(codec); | |
14202 | if (err < 0) { | |
14203 | alc_free(codec); | |
14204 | return err; | |
f12ab1e0 | 14205 | } else if (!err) { |
f32610ed JS |
14206 | printk(KERN_INFO |
14207 | "hda_codec: Cannot set up configuration " | |
14208 | "from BIOS. Using base mode...\n"); | |
14209 | board_config = ALC861VD_3ST; | |
14210 | } | |
14211 | } | |
14212 | ||
14213 | if (board_config != ALC861VD_AUTO) | |
14214 | setup_preset(spec, &alc861vd_presets[board_config]); | |
14215 | ||
2f893286 KY |
14216 | if (codec->vendor_id == 0x10ec0660) { |
14217 | spec->stream_name_analog = "ALC660-VD Analog"; | |
14218 | spec->stream_name_digital = "ALC660-VD Digital"; | |
f9423e7a | 14219 | /* always turn on EAPD */ |
d88897ea | 14220 | add_verb(spec, alc660vd_eapd_verbs); |
2f893286 KY |
14221 | } else { |
14222 | spec->stream_name_analog = "ALC861VD Analog"; | |
14223 | spec->stream_name_digital = "ALC861VD Digital"; | |
14224 | } | |
14225 | ||
f32610ed JS |
14226 | spec->stream_analog_playback = &alc861vd_pcm_analog_playback; |
14227 | spec->stream_analog_capture = &alc861vd_pcm_analog_capture; | |
14228 | ||
f32610ed JS |
14229 | spec->stream_digital_playback = &alc861vd_pcm_digital_playback; |
14230 | spec->stream_digital_capture = &alc861vd_pcm_digital_capture; | |
14231 | ||
14232 | spec->adc_nids = alc861vd_adc_nids; | |
14233 | spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); | |
e1406348 | 14234 | spec->capsrc_nids = alc861vd_capsrc_nids; |
54cbc9ab | 14235 | spec->is_mix_capture = 1; |
f32610ed | 14236 | |
f9e336f6 | 14237 | set_capture_mixer(spec); |
f32610ed | 14238 | |
2134ea4f TI |
14239 | spec->vmaster_nid = 0x02; |
14240 | ||
f32610ed JS |
14241 | codec->patch_ops = alc_patch_ops; |
14242 | ||
14243 | if (board_config == ALC861VD_AUTO) | |
14244 | spec->init_hook = alc861vd_auto_init; | |
cb53c626 TI |
14245 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
14246 | if (!spec->loopback.amplist) | |
14247 | spec->loopback.amplist = alc861vd_loopbacks; | |
14248 | #endif | |
f32610ed JS |
14249 | |
14250 | return 0; | |
14251 | } | |
14252 | ||
bc9f98a9 KY |
14253 | /* |
14254 | * ALC662 support | |
14255 | * | |
14256 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible | |
14257 | * configuration. Each pin widget can choose any input DACs and a mixer. | |
14258 | * Each ADC is connected from a mixer of all inputs. This makes possible | |
14259 | * 6-channel independent captures. | |
14260 | * | |
14261 | * In addition, an independent DAC for the multi-playback (not used in this | |
14262 | * driver yet). | |
14263 | */ | |
14264 | #define ALC662_DIGOUT_NID 0x06 | |
14265 | #define ALC662_DIGIN_NID 0x0a | |
14266 | ||
14267 | static hda_nid_t alc662_dac_nids[4] = { | |
14268 | /* front, rear, clfe, rear_surr */ | |
14269 | 0x02, 0x03, 0x04 | |
14270 | }; | |
14271 | ||
14272 | static hda_nid_t alc662_adc_nids[1] = { | |
14273 | /* ADC1-2 */ | |
14274 | 0x09, | |
14275 | }; | |
e1406348 | 14276 | |
77a261b7 | 14277 | static hda_nid_t alc662_capsrc_nids[1] = { 0x22 }; |
e1406348 | 14278 | |
bc9f98a9 KY |
14279 | /* input MUX */ |
14280 | /* FIXME: should be a matrix-type input source selection */ | |
bc9f98a9 KY |
14281 | static struct hda_input_mux alc662_capture_source = { |
14282 | .num_items = 4, | |
14283 | .items = { | |
14284 | { "Mic", 0x0 }, | |
14285 | { "Front Mic", 0x1 }, | |
14286 | { "Line", 0x2 }, | |
14287 | { "CD", 0x4 }, | |
14288 | }, | |
14289 | }; | |
14290 | ||
14291 | static struct hda_input_mux alc662_lenovo_101e_capture_source = { | |
14292 | .num_items = 2, | |
14293 | .items = { | |
14294 | { "Mic", 0x1 }, | |
14295 | { "Line", 0x2 }, | |
14296 | }, | |
14297 | }; | |
291702f0 KY |
14298 | |
14299 | static struct hda_input_mux alc662_eeepc_capture_source = { | |
14300 | .num_items = 2, | |
14301 | .items = { | |
14302 | { "i-Mic", 0x1 }, | |
14303 | { "e-Mic", 0x0 }, | |
14304 | }, | |
14305 | }; | |
14306 | ||
6dda9f4a KY |
14307 | static struct hda_input_mux alc663_capture_source = { |
14308 | .num_items = 3, | |
14309 | .items = { | |
14310 | { "Mic", 0x0 }, | |
14311 | { "Front Mic", 0x1 }, | |
14312 | { "Line", 0x2 }, | |
14313 | }, | |
14314 | }; | |
14315 | ||
14316 | static struct hda_input_mux alc663_m51va_capture_source = { | |
14317 | .num_items = 2, | |
14318 | .items = { | |
14319 | { "Ext-Mic", 0x0 }, | |
14320 | { "D-Mic", 0x9 }, | |
14321 | }, | |
14322 | }; | |
14323 | ||
bc9f98a9 KY |
14324 | /* |
14325 | * 2ch mode | |
14326 | */ | |
14327 | static struct hda_channel_mode alc662_3ST_2ch_modes[1] = { | |
14328 | { 2, NULL } | |
14329 | }; | |
14330 | ||
14331 | /* | |
14332 | * 2ch mode | |
14333 | */ | |
14334 | static struct hda_verb alc662_3ST_ch2_init[] = { | |
14335 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | |
14336 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
14337 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | |
14338 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
14339 | { } /* end */ | |
14340 | }; | |
14341 | ||
14342 | /* | |
14343 | * 6ch mode | |
14344 | */ | |
14345 | static struct hda_verb alc662_3ST_ch6_init[] = { | |
14346 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14347 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
14348 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | |
14349 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14350 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | |
14351 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | |
14352 | { } /* end */ | |
14353 | }; | |
14354 | ||
14355 | static struct hda_channel_mode alc662_3ST_6ch_modes[2] = { | |
14356 | { 2, alc662_3ST_ch2_init }, | |
14357 | { 6, alc662_3ST_ch6_init }, | |
14358 | }; | |
14359 | ||
14360 | /* | |
14361 | * 2ch mode | |
14362 | */ | |
14363 | static struct hda_verb alc662_sixstack_ch6_init[] = { | |
14364 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
14365 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | |
14366 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14367 | { } /* end */ | |
14368 | }; | |
14369 | ||
14370 | /* | |
14371 | * 6ch mode | |
14372 | */ | |
14373 | static struct hda_verb alc662_sixstack_ch8_init[] = { | |
14374 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14375 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14376 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | |
14377 | { } /* end */ | |
14378 | }; | |
14379 | ||
14380 | static struct hda_channel_mode alc662_5stack_modes[2] = { | |
14381 | { 2, alc662_sixstack_ch6_init }, | |
14382 | { 6, alc662_sixstack_ch8_init }, | |
14383 | }; | |
14384 | ||
14385 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | |
14386 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | |
14387 | */ | |
14388 | ||
14389 | static struct snd_kcontrol_new alc662_base_mixer[] = { | |
14390 | /* output mixer control */ | |
14391 | HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), | |
7055ad8a | 14392 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 | 14393 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT), |
7055ad8a | 14394 | HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT), |
bc9f98a9 KY |
14395 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), |
14396 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
7055ad8a HRK |
14397 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT), |
14398 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT), | |
bc9f98a9 KY |
14399 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
14400 | ||
14401 | /*Input mixer control */ | |
14402 | HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT), | |
14403 | HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT), | |
14404 | HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT), | |
14405 | HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT), | |
14406 | HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT), | |
14407 | HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT), | |
14408 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT), | |
14409 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT), | |
bc9f98a9 KY |
14410 | { } /* end */ |
14411 | }; | |
14412 | ||
14413 | static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = { | |
14414 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
7055ad8a | 14415 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 KY |
14416 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
14417 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
14418 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
14419 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
14420 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
14421 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14422 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14423 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14424 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14425 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
14426 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
bc9f98a9 KY |
14427 | { } /* end */ |
14428 | }; | |
14429 | ||
14430 | static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = { | |
14431 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
7055ad8a | 14432 | HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT), |
bc9f98a9 | 14433 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
7055ad8a | 14434 | HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT), |
bc9f98a9 KY |
14435 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), |
14436 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
7055ad8a HRK |
14437 | HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT), |
14438 | HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT), | |
bc9f98a9 KY |
14439 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
14440 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | |
14441 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | |
14442 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
14443 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
14444 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14445 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14446 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14447 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14448 | HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), | |
14449 | HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), | |
bc9f98a9 KY |
14450 | { } /* end */ |
14451 | }; | |
14452 | ||
14453 | static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = { | |
14454 | HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
14455 | HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT), | |
86cd9298 TI |
14456 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
14457 | HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT), | |
bc9f98a9 KY |
14458 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
14459 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
14460 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
14461 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14462 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
bc9f98a9 KY |
14463 | { } /* end */ |
14464 | }; | |
14465 | ||
291702f0 | 14466 | static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = { |
86cd9298 | 14467 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
291702f0 | 14468 | |
b4818494 HRK |
14469 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
14470 | HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | |
291702f0 KY |
14471 | |
14472 | HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT), | |
14473 | HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14474 | HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14475 | ||
14476 | HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT), | |
14477 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14478 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14479 | { } /* end */ | |
14480 | }; | |
14481 | ||
8c427226 | 14482 | static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = { |
31bffaa9 TI |
14483 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
14484 | HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
8c427226 KY |
14485 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
14486 | HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT), | |
14487 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT), | |
14488 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT), | |
14489 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT), | |
14490 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT), | |
86cd9298 | 14491 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
8c427226 KY |
14492 | HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT), |
14493 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
14494 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
14495 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14496 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14497 | { } /* end */ | |
14498 | }; | |
14499 | ||
f1d4e28b KY |
14500 | static struct hda_bind_ctls alc663_asus_bind_master_vol = { |
14501 | .ops = &snd_hda_bind_vol, | |
14502 | .values = { | |
14503 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
14504 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | |
14505 | 0 | |
14506 | }, | |
14507 | }; | |
14508 | ||
14509 | static struct hda_bind_ctls alc663_asus_one_bind_switch = { | |
14510 | .ops = &snd_hda_bind_sw, | |
14511 | .values = { | |
14512 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
14513 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | |
14514 | 0 | |
14515 | }, | |
14516 | }; | |
14517 | ||
6dda9f4a | 14518 | static struct snd_kcontrol_new alc663_m51va_mixer[] = { |
f1d4e28b KY |
14519 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), |
14520 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch), | |
14521 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14522 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14523 | { } /* end */ | |
14524 | }; | |
14525 | ||
14526 | static struct hda_bind_ctls alc663_asus_tree_bind_switch = { | |
14527 | .ops = &snd_hda_bind_sw, | |
14528 | .values = { | |
14529 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
14530 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
14531 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | |
14532 | 0 | |
14533 | }, | |
14534 | }; | |
14535 | ||
14536 | static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = { | |
14537 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), | |
14538 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch), | |
14539 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14540 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14541 | HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14542 | HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14543 | ||
14544 | { } /* end */ | |
14545 | }; | |
14546 | ||
14547 | static struct hda_bind_ctls alc663_asus_four_bind_switch = { | |
14548 | .ops = &snd_hda_bind_sw, | |
14549 | .values = { | |
14550 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
14551 | HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT), | |
14552 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | |
14553 | 0 | |
14554 | }, | |
14555 | }; | |
14556 | ||
14557 | static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = { | |
14558 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), | |
14559 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch), | |
14560 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14561 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14562 | HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14563 | HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14564 | { } /* end */ | |
14565 | }; | |
14566 | ||
14567 | static struct snd_kcontrol_new alc662_1bjd_mixer[] = { | |
6dda9f4a KY |
14568 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
14569 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
f1d4e28b KY |
14570 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), |
14571 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14572 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14573 | HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14574 | HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14575 | { } /* end */ | |
14576 | }; | |
14577 | ||
14578 | static struct hda_bind_ctls alc663_asus_two_bind_master_vol = { | |
14579 | .ops = &snd_hda_bind_vol, | |
14580 | .values = { | |
14581 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | |
14582 | HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT), | |
14583 | 0 | |
14584 | }, | |
14585 | }; | |
14586 | ||
14587 | static struct hda_bind_ctls alc663_asus_two_bind_switch = { | |
14588 | .ops = &snd_hda_bind_sw, | |
14589 | .values = { | |
14590 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | |
14591 | HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT), | |
14592 | 0 | |
14593 | }, | |
14594 | }; | |
14595 | ||
14596 | static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = { | |
14597 | HDA_BIND_VOL("Master Playback Volume", | |
14598 | &alc663_asus_two_bind_master_vol), | |
14599 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch), | |
14600 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
6dda9f4a KY |
14601 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), |
14602 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14603 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
f1d4e28b KY |
14604 | { } /* end */ |
14605 | }; | |
14606 | ||
14607 | static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = { | |
14608 | HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol), | |
14609 | HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch), | |
14610 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
14611 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
14612 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14613 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
6dda9f4a KY |
14614 | { } /* end */ |
14615 | }; | |
14616 | ||
14617 | static struct snd_kcontrol_new alc663_g71v_mixer[] = { | |
14618 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
14619 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
14620 | HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT), | |
14621 | HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), | |
14622 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), | |
14623 | ||
14624 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14625 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14626 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14627 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14628 | { } /* end */ | |
14629 | }; | |
14630 | ||
14631 | static struct snd_kcontrol_new alc663_g50v_mixer[] = { | |
14632 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
14633 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | |
14634 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), | |
14635 | ||
14636 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
14637 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
14638 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
14639 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
14640 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | |
14641 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | |
14642 | { } /* end */ | |
14643 | }; | |
14644 | ||
bc9f98a9 KY |
14645 | static struct snd_kcontrol_new alc662_chmode_mixer[] = { |
14646 | { | |
14647 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
14648 | .name = "Channel Mode", | |
14649 | .info = alc_ch_mode_info, | |
14650 | .get = alc_ch_mode_get, | |
14651 | .put = alc_ch_mode_put, | |
14652 | }, | |
14653 | { } /* end */ | |
14654 | }; | |
14655 | ||
14656 | static struct hda_verb alc662_init_verbs[] = { | |
14657 | /* ADC: mute amp left and right */ | |
14658 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14659 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14660 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | |
14661 | ||
cb53c626 TI |
14662 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14663 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14664 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
14665 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
14666 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 | 14667 | |
b60dd394 KY |
14668 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
14669 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14670 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14671 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14672 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14673 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
bc9f98a9 KY |
14674 | |
14675 | /* Front Pin: output 0 (0x0c) */ | |
14676 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14677 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14678 | ||
14679 | /* Rear Pin: output 1 (0x0d) */ | |
14680 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14681 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14682 | ||
14683 | /* CLFE Pin: output 2 (0x0e) */ | |
14684 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14685 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14686 | ||
14687 | /* Mic (rear) pin: input vref at 80% */ | |
14688 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
14689 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14690 | /* Front Mic pin: input vref at 80% */ | |
14691 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
14692 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14693 | /* Line In pin: input */ | |
14694 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14695 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | |
14696 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | |
14697 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14698 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14699 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14700 | /* CD pin widget for input */ | |
14701 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14702 | ||
14703 | /* FIXME: use matrix-type input source selection */ | |
14704 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
14705 | /* Input mixer */ | |
14706 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14707 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14708 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
14709 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
291702f0 KY |
14710 | |
14711 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14712 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14713 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | |
14714 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | |
6dda9f4a KY |
14715 | |
14716 | /* always trun on EAPD */ | |
14717 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
14718 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | |
14719 | ||
bc9f98a9 KY |
14720 | { } |
14721 | }; | |
14722 | ||
14723 | static struct hda_verb alc662_sue_init_verbs[] = { | |
14724 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | |
14725 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | |
291702f0 KY |
14726 | {} |
14727 | }; | |
14728 | ||
14729 | static struct hda_verb alc662_eeepc_sue_init_verbs[] = { | |
14730 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
14731 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
14732 | {} | |
bc9f98a9 KY |
14733 | }; |
14734 | ||
8c427226 KY |
14735 | /* Set Unsolicited Event*/ |
14736 | static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = { | |
14737 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
14738 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
14739 | {} | |
14740 | }; | |
14741 | ||
bc9f98a9 KY |
14742 | /* |
14743 | * generic initialization of ADC, input mixers and output mixers | |
14744 | */ | |
14745 | static struct hda_verb alc662_auto_init_verbs[] = { | |
14746 | /* | |
14747 | * Unmute ADC and set the default input to mic-in | |
14748 | */ | |
14749 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
14750 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14751 | ||
14752 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | |
14753 | * mixer widget | |
14754 | * Note: PASD motherboards uses the Line In 2 as the input for front | |
14755 | * panel mic (mic 2) | |
14756 | */ | |
14757 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | |
cb53c626 TI |
14758 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14759 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | |
14760 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | |
14761 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | |
14762 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | |
bc9f98a9 KY |
14763 | |
14764 | /* | |
14765 | * Set up output mixers (0x0c - 0x0f) | |
14766 | */ | |
14767 | /* set vol=0 to output mixers */ | |
14768 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14769 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14770 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | |
14771 | ||
14772 | /* set up input amps for analog loopback */ | |
14773 | /* Amp Indices: DAC = 0, mixer = 1 */ | |
b60dd394 KY |
14774 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
14775 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14776 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14777 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14778 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14779 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
bc9f98a9 KY |
14780 | |
14781 | ||
14782 | /* FIXME: use matrix-type input source selection */ | |
14783 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | |
14784 | /* Input mixer */ | |
14785 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
d1a991a6 | 14786 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
bc9f98a9 KY |
14787 | { } |
14788 | }; | |
14789 | ||
24fb9173 TI |
14790 | /* additional verbs for ALC663 */ |
14791 | static struct hda_verb alc663_auto_init_verbs[] = { | |
14792 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
14793 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14794 | { } | |
14795 | }; | |
14796 | ||
6dda9f4a | 14797 | static struct hda_verb alc663_m51va_init_verbs[] = { |
f1d4e28b KY |
14798 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
14799 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
6dda9f4a KY |
14800 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
14801 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
f1d4e28b KY |
14802 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ |
14803 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14804 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)}, | |
14805 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
14806 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
14807 | {} | |
14808 | }; | |
14809 | ||
14810 | static struct hda_verb alc663_21jd_amic_init_verbs[] = { | |
14811 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14812 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14813 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
14814 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14815 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14816 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
14817 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
14818 | {} | |
14819 | }; | |
14820 | ||
14821 | static struct hda_verb alc662_1bjd_amic_init_verbs[] = { | |
14822 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14823 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14824 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14825 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
14826 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14827 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14828 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
14829 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
14830 | {} | |
14831 | }; | |
6dda9f4a | 14832 | |
f1d4e28b KY |
14833 | static struct hda_verb alc663_15jd_amic_init_verbs[] = { |
14834 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14835 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14836 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
14837 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14838 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14839 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
14840 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
14841 | {} | |
14842 | }; | |
6dda9f4a | 14843 | |
f1d4e28b KY |
14844 | static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = { |
14845 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14846 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14847 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14848 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */ | |
14849 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14850 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14851 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */ | |
14852 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14853 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
6dda9f4a KY |
14854 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, |
14855 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
f1d4e28b KY |
14856 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, |
14857 | {} | |
14858 | }; | |
14859 | ||
14860 | static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = { | |
14861 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
14862 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14863 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14864 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
14865 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14866 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14867 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */ | |
14868 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14869 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | |
14870 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
14871 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
14872 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
6dda9f4a KY |
14873 | {} |
14874 | }; | |
14875 | ||
14876 | static struct hda_verb alc663_g71v_init_verbs[] = { | |
14877 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14878 | /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */ | |
14879 | /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */ | |
14880 | ||
14881 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14882 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14883 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
14884 | ||
14885 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | |
14886 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT}, | |
14887 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | |
14888 | {} | |
14889 | }; | |
14890 | ||
14891 | static struct hda_verb alc663_g50v_init_verbs[] = { | |
14892 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | |
14893 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | |
14894 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */ | |
14895 | ||
14896 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
14897 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
14898 | {} | |
14899 | }; | |
14900 | ||
f1d4e28b KY |
14901 | static struct hda_verb alc662_ecs_init_verbs[] = { |
14902 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f}, | |
14903 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | |
14904 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | |
14905 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | |
14906 | {} | |
14907 | }; | |
14908 | ||
f1d4e28b KY |
14909 | static struct snd_kcontrol_new alc662_auto_capture_mixer[] = { |
14910 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | |
14911 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | |
14912 | { } /* end */ | |
14913 | }; | |
14914 | ||
bc9f98a9 KY |
14915 | static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
14916 | { | |
14917 | unsigned int present; | |
f12ab1e0 | 14918 | unsigned char bits; |
bc9f98a9 KY |
14919 | |
14920 | present = snd_hda_codec_read(codec, 0x14, 0, | |
14921 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
14922 | bits = present ? HDA_AMP_MUTE : 0; |
14923 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
14924 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
14925 | } |
14926 | ||
14927 | static void alc662_lenovo_101e_all_automute(struct hda_codec *codec) | |
14928 | { | |
14929 | unsigned int present; | |
f12ab1e0 | 14930 | unsigned char bits; |
bc9f98a9 KY |
14931 | |
14932 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
14933 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
47fd830a TI |
14934 | bits = present ? HDA_AMP_MUTE : 0; |
14935 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
14936 | HDA_AMP_MUTE, bits); | |
14937 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
14938 | HDA_AMP_MUTE, bits); | |
bc9f98a9 KY |
14939 | } |
14940 | ||
14941 | static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec, | |
14942 | unsigned int res) | |
14943 | { | |
14944 | if ((res >> 26) == ALC880_HP_EVENT) | |
14945 | alc662_lenovo_101e_all_automute(codec); | |
14946 | if ((res >> 26) == ALC880_FRONT_EVENT) | |
14947 | alc662_lenovo_101e_ispeaker_automute(codec); | |
14948 | } | |
14949 | ||
291702f0 KY |
14950 | static void alc662_eeepc_mic_automute(struct hda_codec *codec) |
14951 | { | |
14952 | unsigned int present; | |
14953 | ||
14954 | present = snd_hda_codec_read(codec, 0x18, 0, | |
14955 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | |
14956 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
14957 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
14958 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
14959 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | |
14960 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
14961 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
14962 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | |
14963 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | |
14964 | } | |
14965 | ||
14966 | /* unsolicited event for HP jack sensing */ | |
14967 | static void alc662_eeepc_unsol_event(struct hda_codec *codec, | |
14968 | unsigned int res) | |
14969 | { | |
14970 | if ((res >> 26) == ALC880_HP_EVENT) | |
14971 | alc262_hippo1_automute( codec ); | |
14972 | ||
14973 | if ((res >> 26) == ALC880_MIC_EVENT) | |
14974 | alc662_eeepc_mic_automute(codec); | |
14975 | } | |
14976 | ||
14977 | static void alc662_eeepc_inithook(struct hda_codec *codec) | |
14978 | { | |
14979 | alc262_hippo1_automute( codec ); | |
14980 | alc662_eeepc_mic_automute(codec); | |
14981 | } | |
14982 | ||
8c427226 KY |
14983 | static void alc662_eeepc_ep20_automute(struct hda_codec *codec) |
14984 | { | |
14985 | unsigned int mute; | |
14986 | unsigned int present; | |
14987 | ||
14988 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | |
14989 | present = snd_hda_codec_read(codec, 0x14, 0, | |
14990 | AC_VERB_GET_PIN_SENSE, 0); | |
14991 | present = (present & 0x80000000) != 0; | |
14992 | if (present) { | |
14993 | /* mute internal speaker */ | |
14994 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
ea1fb29a | 14995 | HDA_AMP_MUTE, HDA_AMP_MUTE); |
8c427226 KY |
14996 | } else { |
14997 | /* unmute internal speaker if necessary */ | |
14998 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | |
14999 | snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | |
ea1fb29a | 15000 | HDA_AMP_MUTE, mute); |
8c427226 KY |
15001 | } |
15002 | } | |
15003 | ||
15004 | /* unsolicited event for HP jack sensing */ | |
15005 | static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec, | |
15006 | unsigned int res) | |
15007 | { | |
15008 | if ((res >> 26) == ALC880_HP_EVENT) | |
15009 | alc662_eeepc_ep20_automute(codec); | |
15010 | } | |
15011 | ||
15012 | static void alc662_eeepc_ep20_inithook(struct hda_codec *codec) | |
15013 | { | |
15014 | alc662_eeepc_ep20_automute(codec); | |
15015 | } | |
15016 | ||
6dda9f4a KY |
15017 | static void alc663_m51va_speaker_automute(struct hda_codec *codec) |
15018 | { | |
15019 | unsigned int present; | |
15020 | unsigned char bits; | |
15021 | ||
15022 | present = snd_hda_codec_read(codec, 0x21, 0, | |
f1d4e28b KY |
15023 | AC_VERB_GET_PIN_SENSE, 0) |
15024 | & AC_PINSENSE_PRESENCE; | |
6dda9f4a | 15025 | bits = present ? HDA_AMP_MUTE : 0; |
f1d4e28b KY |
15026 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, |
15027 | AMP_IN_MUTE(0), bits); | |
15028 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15029 | AMP_IN_MUTE(0), bits); | |
15030 | } | |
15031 | ||
15032 | static void alc663_21jd_two_speaker_automute(struct hda_codec *codec) | |
15033 | { | |
15034 | unsigned int present; | |
15035 | unsigned char bits; | |
15036 | ||
15037 | present = snd_hda_codec_read(codec, 0x21, 0, | |
15038 | AC_VERB_GET_PIN_SENSE, 0) | |
15039 | & AC_PINSENSE_PRESENCE; | |
15040 | bits = present ? HDA_AMP_MUTE : 0; | |
15041 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15042 | AMP_IN_MUTE(0), bits); | |
15043 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15044 | AMP_IN_MUTE(0), bits); | |
15045 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0, | |
15046 | AMP_IN_MUTE(0), bits); | |
15047 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1, | |
15048 | AMP_IN_MUTE(0), bits); | |
15049 | } | |
15050 | ||
15051 | static void alc663_15jd_two_speaker_automute(struct hda_codec *codec) | |
15052 | { | |
15053 | unsigned int present; | |
15054 | unsigned char bits; | |
15055 | ||
15056 | present = snd_hda_codec_read(codec, 0x15, 0, | |
15057 | AC_VERB_GET_PIN_SENSE, 0) | |
15058 | & AC_PINSENSE_PRESENCE; | |
15059 | bits = present ? HDA_AMP_MUTE : 0; | |
15060 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15061 | AMP_IN_MUTE(0), bits); | |
15062 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15063 | AMP_IN_MUTE(0), bits); | |
15064 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0, | |
15065 | AMP_IN_MUTE(0), bits); | |
15066 | snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1, | |
15067 | AMP_IN_MUTE(0), bits); | |
15068 | } | |
15069 | ||
15070 | static void alc662_f5z_speaker_automute(struct hda_codec *codec) | |
15071 | { | |
15072 | unsigned int present; | |
15073 | unsigned char bits; | |
15074 | ||
15075 | present = snd_hda_codec_read(codec, 0x1b, 0, | |
15076 | AC_VERB_GET_PIN_SENSE, 0) | |
15077 | & AC_PINSENSE_PRESENCE; | |
15078 | bits = present ? 0 : PIN_OUT; | |
15079 | snd_hda_codec_write(codec, 0x14, 0, | |
15080 | AC_VERB_SET_PIN_WIDGET_CONTROL, bits); | |
15081 | } | |
15082 | ||
15083 | static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec) | |
15084 | { | |
15085 | unsigned int present1, present2; | |
15086 | ||
15087 | present1 = snd_hda_codec_read(codec, 0x21, 0, | |
15088 | AC_VERB_GET_PIN_SENSE, 0) | |
15089 | & AC_PINSENSE_PRESENCE; | |
15090 | present2 = snd_hda_codec_read(codec, 0x15, 0, | |
15091 | AC_VERB_GET_PIN_SENSE, 0) | |
15092 | & AC_PINSENSE_PRESENCE; | |
15093 | ||
15094 | if (present1 || present2) { | |
15095 | snd_hda_codec_write_cache(codec, 0x14, 0, | |
15096 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | |
15097 | } else { | |
15098 | snd_hda_codec_write_cache(codec, 0x14, 0, | |
15099 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | |
15100 | } | |
15101 | } | |
15102 | ||
15103 | static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec) | |
15104 | { | |
15105 | unsigned int present1, present2; | |
15106 | ||
15107 | present1 = snd_hda_codec_read(codec, 0x1b, 0, | |
15108 | AC_VERB_GET_PIN_SENSE, 0) | |
15109 | & AC_PINSENSE_PRESENCE; | |
15110 | present2 = snd_hda_codec_read(codec, 0x15, 0, | |
15111 | AC_VERB_GET_PIN_SENSE, 0) | |
15112 | & AC_PINSENSE_PRESENCE; | |
15113 | ||
15114 | if (present1 || present2) { | |
15115 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15116 | AMP_IN_MUTE(0), AMP_IN_MUTE(0)); | |
15117 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15118 | AMP_IN_MUTE(0), AMP_IN_MUTE(0)); | |
15119 | } else { | |
15120 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0, | |
15121 | AMP_IN_MUTE(0), 0); | |
15122 | snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, | |
15123 | AMP_IN_MUTE(0), 0); | |
15124 | } | |
6dda9f4a KY |
15125 | } |
15126 | ||
15127 | static void alc663_m51va_mic_automute(struct hda_codec *codec) | |
15128 | { | |
15129 | unsigned int present; | |
15130 | ||
15131 | present = snd_hda_codec_read(codec, 0x18, 0, | |
ea1fb29a KY |
15132 | AC_VERB_GET_PIN_SENSE, 0) |
15133 | & AC_PINSENSE_PRESENCE; | |
6dda9f4a | 15134 | snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15135 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); |
6dda9f4a | 15136 | snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15137 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); |
6dda9f4a | 15138 | snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15139 | 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); |
6dda9f4a | 15140 | snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
ea1fb29a | 15141 | 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); |
6dda9f4a KY |
15142 | } |
15143 | ||
15144 | static void alc663_m51va_unsol_event(struct hda_codec *codec, | |
15145 | unsigned int res) | |
15146 | { | |
15147 | switch (res >> 26) { | |
15148 | case ALC880_HP_EVENT: | |
15149 | alc663_m51va_speaker_automute(codec); | |
15150 | break; | |
15151 | case ALC880_MIC_EVENT: | |
15152 | alc663_m51va_mic_automute(codec); | |
15153 | break; | |
15154 | } | |
15155 | } | |
15156 | ||
15157 | static void alc663_m51va_inithook(struct hda_codec *codec) | |
15158 | { | |
15159 | alc663_m51va_speaker_automute(codec); | |
15160 | alc663_m51va_mic_automute(codec); | |
15161 | } | |
15162 | ||
f1d4e28b KY |
15163 | /* ***************** Mode1 ******************************/ |
15164 | static void alc663_mode1_unsol_event(struct hda_codec *codec, | |
15165 | unsigned int res) | |
15166 | { | |
15167 | switch (res >> 26) { | |
15168 | case ALC880_HP_EVENT: | |
15169 | alc663_m51va_speaker_automute(codec); | |
15170 | break; | |
15171 | case ALC880_MIC_EVENT: | |
15172 | alc662_eeepc_mic_automute(codec); | |
15173 | break; | |
15174 | } | |
15175 | } | |
15176 | ||
15177 | static void alc663_mode1_inithook(struct hda_codec *codec) | |
15178 | { | |
15179 | alc663_m51va_speaker_automute(codec); | |
15180 | alc662_eeepc_mic_automute(codec); | |
15181 | } | |
15182 | /* ***************** Mode2 ******************************/ | |
15183 | static void alc662_mode2_unsol_event(struct hda_codec *codec, | |
15184 | unsigned int res) | |
15185 | { | |
15186 | switch (res >> 26) { | |
15187 | case ALC880_HP_EVENT: | |
15188 | alc662_f5z_speaker_automute(codec); | |
15189 | break; | |
15190 | case ALC880_MIC_EVENT: | |
15191 | alc662_eeepc_mic_automute(codec); | |
15192 | break; | |
15193 | } | |
15194 | } | |
15195 | ||
15196 | static void alc662_mode2_inithook(struct hda_codec *codec) | |
15197 | { | |
15198 | alc662_f5z_speaker_automute(codec); | |
15199 | alc662_eeepc_mic_automute(codec); | |
15200 | } | |
15201 | /* ***************** Mode3 ******************************/ | |
15202 | static void alc663_mode3_unsol_event(struct hda_codec *codec, | |
15203 | unsigned int res) | |
15204 | { | |
15205 | switch (res >> 26) { | |
15206 | case ALC880_HP_EVENT: | |
15207 | alc663_two_hp_m1_speaker_automute(codec); | |
15208 | break; | |
15209 | case ALC880_MIC_EVENT: | |
15210 | alc662_eeepc_mic_automute(codec); | |
15211 | break; | |
15212 | } | |
15213 | } | |
15214 | ||
15215 | static void alc663_mode3_inithook(struct hda_codec *codec) | |
15216 | { | |
15217 | alc663_two_hp_m1_speaker_automute(codec); | |
15218 | alc662_eeepc_mic_automute(codec); | |
15219 | } | |
15220 | /* ***************** Mode4 ******************************/ | |
15221 | static void alc663_mode4_unsol_event(struct hda_codec *codec, | |
15222 | unsigned int res) | |
15223 | { | |
15224 | switch (res >> 26) { | |
15225 | case ALC880_HP_EVENT: | |
15226 | alc663_21jd_two_speaker_automute(codec); | |
15227 | break; | |
15228 | case ALC880_MIC_EVENT: | |
15229 | alc662_eeepc_mic_automute(codec); | |
15230 | break; | |
15231 | } | |
15232 | } | |
15233 | ||
15234 | static void alc663_mode4_inithook(struct hda_codec *codec) | |
15235 | { | |
15236 | alc663_21jd_two_speaker_automute(codec); | |
15237 | alc662_eeepc_mic_automute(codec); | |
15238 | } | |
15239 | /* ***************** Mode5 ******************************/ | |
15240 | static void alc663_mode5_unsol_event(struct hda_codec *codec, | |
15241 | unsigned int res) | |
15242 | { | |
15243 | switch (res >> 26) { | |
15244 | case ALC880_HP_EVENT: | |
15245 | alc663_15jd_two_speaker_automute(codec); | |
15246 | break; | |
15247 | case ALC880_MIC_EVENT: | |
15248 | alc662_eeepc_mic_automute(codec); | |
15249 | break; | |
15250 | } | |
15251 | } | |
15252 | ||
15253 | static void alc663_mode5_inithook(struct hda_codec *codec) | |
15254 | { | |
15255 | alc663_15jd_two_speaker_automute(codec); | |
15256 | alc662_eeepc_mic_automute(codec); | |
15257 | } | |
15258 | /* ***************** Mode6 ******************************/ | |
15259 | static void alc663_mode6_unsol_event(struct hda_codec *codec, | |
15260 | unsigned int res) | |
15261 | { | |
15262 | switch (res >> 26) { | |
15263 | case ALC880_HP_EVENT: | |
15264 | alc663_two_hp_m2_speaker_automute(codec); | |
15265 | break; | |
15266 | case ALC880_MIC_EVENT: | |
15267 | alc662_eeepc_mic_automute(codec); | |
15268 | break; | |
15269 | } | |
15270 | } | |
15271 | ||
15272 | static void alc663_mode6_inithook(struct hda_codec *codec) | |
15273 | { | |
15274 | alc663_two_hp_m2_speaker_automute(codec); | |
15275 | alc662_eeepc_mic_automute(codec); | |
15276 | } | |
15277 | ||
6dda9f4a KY |
15278 | static void alc663_g71v_hp_automute(struct hda_codec *codec) |
15279 | { | |
15280 | unsigned int present; | |
15281 | unsigned char bits; | |
15282 | ||
15283 | present = snd_hda_codec_read(codec, 0x21, 0, | |
15284 | AC_VERB_GET_PIN_SENSE, 0) | |
15285 | & AC_PINSENSE_PRESENCE; | |
15286 | bits = present ? HDA_AMP_MUTE : 0; | |
15287 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | |
15288 | HDA_AMP_MUTE, bits); | |
15289 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
15290 | HDA_AMP_MUTE, bits); | |
15291 | } | |
15292 | ||
15293 | static void alc663_g71v_front_automute(struct hda_codec *codec) | |
15294 | { | |
15295 | unsigned int present; | |
15296 | unsigned char bits; | |
15297 | ||
15298 | present = snd_hda_codec_read(codec, 0x15, 0, | |
15299 | AC_VERB_GET_PIN_SENSE, 0) | |
15300 | & AC_PINSENSE_PRESENCE; | |
15301 | bits = present ? HDA_AMP_MUTE : 0; | |
15302 | snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | |
15303 | HDA_AMP_MUTE, bits); | |
15304 | } | |
15305 | ||
15306 | static void alc663_g71v_unsol_event(struct hda_codec *codec, | |
15307 | unsigned int res) | |
15308 | { | |
15309 | switch (res >> 26) { | |
15310 | case ALC880_HP_EVENT: | |
15311 | alc663_g71v_hp_automute(codec); | |
15312 | break; | |
15313 | case ALC880_FRONT_EVENT: | |
15314 | alc663_g71v_front_automute(codec); | |
15315 | break; | |
15316 | case ALC880_MIC_EVENT: | |
15317 | alc662_eeepc_mic_automute(codec); | |
15318 | break; | |
15319 | } | |
15320 | } | |
15321 | ||
15322 | static void alc663_g71v_inithook(struct hda_codec *codec) | |
15323 | { | |
15324 | alc663_g71v_front_automute(codec); | |
15325 | alc663_g71v_hp_automute(codec); | |
15326 | alc662_eeepc_mic_automute(codec); | |
15327 | } | |
15328 | ||
15329 | static void alc663_g50v_unsol_event(struct hda_codec *codec, | |
15330 | unsigned int res) | |
15331 | { | |
15332 | switch (res >> 26) { | |
15333 | case ALC880_HP_EVENT: | |
15334 | alc663_m51va_speaker_automute(codec); | |
15335 | break; | |
15336 | case ALC880_MIC_EVENT: | |
15337 | alc662_eeepc_mic_automute(codec); | |
15338 | break; | |
15339 | } | |
15340 | } | |
15341 | ||
15342 | static void alc663_g50v_inithook(struct hda_codec *codec) | |
15343 | { | |
15344 | alc663_m51va_speaker_automute(codec); | |
15345 | alc662_eeepc_mic_automute(codec); | |
15346 | } | |
15347 | ||
f1d4e28b KY |
15348 | /* bind hp and internal speaker mute (with plug check) */ |
15349 | static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol, | |
15350 | struct snd_ctl_elem_value *ucontrol) | |
15351 | { | |
15352 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
15353 | long *valp = ucontrol->value.integer.value; | |
15354 | int change; | |
15355 | ||
15356 | change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, | |
15357 | HDA_AMP_MUTE, | |
15358 | valp[0] ? 0 : HDA_AMP_MUTE); | |
15359 | change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, | |
15360 | HDA_AMP_MUTE, | |
15361 | valp[1] ? 0 : HDA_AMP_MUTE); | |
15362 | if (change) | |
15363 | alc262_hippo1_automute(codec); | |
15364 | return change; | |
15365 | } | |
15366 | ||
15367 | static struct snd_kcontrol_new alc662_ecs_mixer[] = { | |
15368 | HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT), | |
15369 | { | |
15370 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
15371 | .name = "Master Playback Switch", | |
15372 | .info = snd_hda_mixer_amp_switch_info, | |
15373 | .get = snd_hda_mixer_amp_switch_get, | |
15374 | .put = alc662_ecs_master_sw_put, | |
15375 | .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | |
15376 | }, | |
15377 | ||
15378 | HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT), | |
15379 | HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT), | |
15380 | HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT), | |
15381 | ||
15382 | HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT), | |
15383 | HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | |
15384 | HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | |
15385 | { } /* end */ | |
15386 | }; | |
15387 | ||
cb53c626 TI |
15388 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
15389 | #define alc662_loopbacks alc880_loopbacks | |
15390 | #endif | |
15391 | ||
bc9f98a9 KY |
15392 | |
15393 | /* pcm configuration: identiacal with ALC880 */ | |
15394 | #define alc662_pcm_analog_playback alc880_pcm_analog_playback | |
15395 | #define alc662_pcm_analog_capture alc880_pcm_analog_capture | |
15396 | #define alc662_pcm_digital_playback alc880_pcm_digital_playback | |
15397 | #define alc662_pcm_digital_capture alc880_pcm_digital_capture | |
15398 | ||
15399 | /* | |
15400 | * configuration and preset | |
15401 | */ | |
15402 | static const char *alc662_models[ALC662_MODEL_LAST] = { | |
15403 | [ALC662_3ST_2ch_DIG] = "3stack-dig", | |
15404 | [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig", | |
15405 | [ALC662_3ST_6ch] = "3stack-6ch", | |
15406 | [ALC662_5ST_DIG] = "6stack-dig", | |
15407 | [ALC662_LENOVO_101E] = "lenovo-101e", | |
b995d76d | 15408 | [ALC662_ASUS_EEEPC_P701] = "eeepc-p701", |
8c427226 | 15409 | [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20", |
f1d4e28b | 15410 | [ALC662_ECS] = "ecs", |
6dda9f4a KY |
15411 | [ALC663_ASUS_M51VA] = "m51va", |
15412 | [ALC663_ASUS_G71V] = "g71v", | |
15413 | [ALC663_ASUS_H13] = "h13", | |
15414 | [ALC663_ASUS_G50V] = "g50v", | |
f1d4e28b KY |
15415 | [ALC663_ASUS_MODE1] = "asus-mode1", |
15416 | [ALC662_ASUS_MODE2] = "asus-mode2", | |
15417 | [ALC663_ASUS_MODE3] = "asus-mode3", | |
15418 | [ALC663_ASUS_MODE4] = "asus-mode4", | |
15419 | [ALC663_ASUS_MODE5] = "asus-mode5", | |
15420 | [ALC663_ASUS_MODE6] = "asus-mode6", | |
bc9f98a9 KY |
15421 | [ALC662_AUTO] = "auto", |
15422 | }; | |
15423 | ||
15424 | static struct snd_pci_quirk alc662_cfg_tbl[] = { | |
6dda9f4a | 15425 | SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA), |
80ffe869 | 15426 | SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V), |
3da23cac | 15427 | SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG), |
291702f0 | 15428 | SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701), |
8c427226 | 15429 | SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20), |
f1d4e28b KY |
15430 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1), |
15431 | SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1), | |
15432 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1), | |
15433 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1), | |
15434 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1), | |
15435 | SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1), | |
15436 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1), | |
15437 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1), | |
15438 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1), | |
80ffe869 | 15439 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1), |
f1d4e28b KY |
15440 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2), |
15441 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2), | |
15442 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2), | |
15443 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2), | |
15444 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2), | |
15445 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2), | |
15446 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2), | |
15447 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2), | |
15448 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2), | |
15449 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2), | |
15450 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2), | |
15451 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2), | |
15452 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3), | |
15453 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3), | |
15454 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3), | |
15455 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3), | |
15456 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3), | |
15457 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4), | |
15458 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5), | |
15459 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6), | |
15460 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6), | |
15461 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6), | |
95fe5f2c HRK |
15462 | SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K", |
15463 | ALC662_3ST_6ch_DIG), | |
ac3e3741 | 15464 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E), |
f1d4e28b KY |
15465 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS), |
15466 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS), | |
cb55974c HRK |
15467 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L", |
15468 | ALC662_3ST_6ch_DIG), | |
19c009aa | 15469 | SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG), |
238713d4 | 15470 | SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0", |
19c009aa | 15471 | ALC662_3ST_6ch_DIG), |
6dda9f4a KY |
15472 | SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13), |
15473 | SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13), | |
15474 | SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13), | |
bc9f98a9 KY |
15475 | {} |
15476 | }; | |
15477 | ||
15478 | static struct alc_config_preset alc662_presets[] = { | |
15479 | [ALC662_3ST_2ch_DIG] = { | |
f9e336f6 | 15480 | .mixers = { alc662_3ST_2ch_mixer }, |
bc9f98a9 KY |
15481 | .init_verbs = { alc662_init_verbs }, |
15482 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15483 | .dac_nids = alc662_dac_nids, | |
15484 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
15485 | .dig_in_nid = ALC662_DIGIN_NID, |
15486 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15487 | .channel_mode = alc662_3ST_2ch_modes, | |
15488 | .input_mux = &alc662_capture_source, | |
15489 | }, | |
15490 | [ALC662_3ST_6ch_DIG] = { | |
f9e336f6 | 15491 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer }, |
bc9f98a9 KY |
15492 | .init_verbs = { alc662_init_verbs }, |
15493 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15494 | .dac_nids = alc662_dac_nids, | |
15495 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
15496 | .dig_in_nid = ALC662_DIGIN_NID, |
15497 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
15498 | .channel_mode = alc662_3ST_6ch_modes, | |
15499 | .need_dac_fix = 1, | |
15500 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 15501 | }, |
bc9f98a9 | 15502 | [ALC662_3ST_6ch] = { |
f9e336f6 | 15503 | .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer }, |
bc9f98a9 KY |
15504 | .init_verbs = { alc662_init_verbs }, |
15505 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15506 | .dac_nids = alc662_dac_nids, | |
bc9f98a9 KY |
15507 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), |
15508 | .channel_mode = alc662_3ST_6ch_modes, | |
15509 | .need_dac_fix = 1, | |
15510 | .input_mux = &alc662_capture_source, | |
f12ab1e0 | 15511 | }, |
bc9f98a9 | 15512 | [ALC662_5ST_DIG] = { |
f9e336f6 | 15513 | .mixers = { alc662_base_mixer, alc662_chmode_mixer }, |
bc9f98a9 KY |
15514 | .init_verbs = { alc662_init_verbs }, |
15515 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15516 | .dac_nids = alc662_dac_nids, | |
15517 | .dig_out_nid = ALC662_DIGOUT_NID, | |
bc9f98a9 KY |
15518 | .dig_in_nid = ALC662_DIGIN_NID, |
15519 | .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes), | |
15520 | .channel_mode = alc662_5stack_modes, | |
15521 | .input_mux = &alc662_capture_source, | |
15522 | }, | |
15523 | [ALC662_LENOVO_101E] = { | |
f9e336f6 | 15524 | .mixers = { alc662_lenovo_101e_mixer }, |
bc9f98a9 KY |
15525 | .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs }, |
15526 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15527 | .dac_nids = alc662_dac_nids, | |
bc9f98a9 KY |
15528 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
15529 | .channel_mode = alc662_3ST_2ch_modes, | |
15530 | .input_mux = &alc662_lenovo_101e_capture_source, | |
15531 | .unsol_event = alc662_lenovo_101e_unsol_event, | |
15532 | .init_hook = alc662_lenovo_101e_all_automute, | |
15533 | }, | |
291702f0 | 15534 | [ALC662_ASUS_EEEPC_P701] = { |
f9e336f6 | 15535 | .mixers = { alc662_eeepc_p701_mixer }, |
291702f0 KY |
15536 | .init_verbs = { alc662_init_verbs, |
15537 | alc662_eeepc_sue_init_verbs }, | |
15538 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15539 | .dac_nids = alc662_dac_nids, | |
291702f0 KY |
15540 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
15541 | .channel_mode = alc662_3ST_2ch_modes, | |
15542 | .input_mux = &alc662_eeepc_capture_source, | |
15543 | .unsol_event = alc662_eeepc_unsol_event, | |
15544 | .init_hook = alc662_eeepc_inithook, | |
15545 | }, | |
8c427226 | 15546 | [ALC662_ASUS_EEEPC_EP20] = { |
f9e336f6 | 15547 | .mixers = { alc662_eeepc_ep20_mixer, |
8c427226 KY |
15548 | alc662_chmode_mixer }, |
15549 | .init_verbs = { alc662_init_verbs, | |
15550 | alc662_eeepc_ep20_sue_init_verbs }, | |
15551 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15552 | .dac_nids = alc662_dac_nids, | |
8c427226 KY |
15553 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), |
15554 | .channel_mode = alc662_3ST_6ch_modes, | |
15555 | .input_mux = &alc662_lenovo_101e_capture_source, | |
15556 | .unsol_event = alc662_eeepc_ep20_unsol_event, | |
15557 | .init_hook = alc662_eeepc_ep20_inithook, | |
15558 | }, | |
f1d4e28b | 15559 | [ALC662_ECS] = { |
f9e336f6 | 15560 | .mixers = { alc662_ecs_mixer }, |
f1d4e28b KY |
15561 | .init_verbs = { alc662_init_verbs, |
15562 | alc662_ecs_init_verbs }, | |
15563 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15564 | .dac_nids = alc662_dac_nids, | |
15565 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15566 | .channel_mode = alc662_3ST_2ch_modes, | |
15567 | .input_mux = &alc662_eeepc_capture_source, | |
15568 | .unsol_event = alc662_eeepc_unsol_event, | |
15569 | .init_hook = alc662_eeepc_inithook, | |
15570 | }, | |
6dda9f4a | 15571 | [ALC663_ASUS_M51VA] = { |
f9e336f6 | 15572 | .mixers = { alc663_m51va_mixer }, |
6dda9f4a KY |
15573 | .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, |
15574 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15575 | .dac_nids = alc662_dac_nids, | |
15576 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15577 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15578 | .channel_mode = alc662_3ST_2ch_modes, | |
15579 | .input_mux = &alc663_m51va_capture_source, | |
15580 | .unsol_event = alc663_m51va_unsol_event, | |
15581 | .init_hook = alc663_m51va_inithook, | |
15582 | }, | |
15583 | [ALC663_ASUS_G71V] = { | |
f9e336f6 | 15584 | .mixers = { alc663_g71v_mixer }, |
6dda9f4a KY |
15585 | .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs }, |
15586 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15587 | .dac_nids = alc662_dac_nids, | |
15588 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15589 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15590 | .channel_mode = alc662_3ST_2ch_modes, | |
15591 | .input_mux = &alc662_eeepc_capture_source, | |
15592 | .unsol_event = alc663_g71v_unsol_event, | |
15593 | .init_hook = alc663_g71v_inithook, | |
15594 | }, | |
15595 | [ALC663_ASUS_H13] = { | |
f9e336f6 | 15596 | .mixers = { alc663_m51va_mixer }, |
6dda9f4a KY |
15597 | .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs }, |
15598 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15599 | .dac_nids = alc662_dac_nids, | |
15600 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15601 | .channel_mode = alc662_3ST_2ch_modes, | |
15602 | .input_mux = &alc663_m51va_capture_source, | |
15603 | .unsol_event = alc663_m51va_unsol_event, | |
15604 | .init_hook = alc663_m51va_inithook, | |
15605 | }, | |
15606 | [ALC663_ASUS_G50V] = { | |
f9e336f6 | 15607 | .mixers = { alc663_g50v_mixer }, |
6dda9f4a KY |
15608 | .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs }, |
15609 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15610 | .dac_nids = alc662_dac_nids, | |
15611 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15612 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes), | |
15613 | .channel_mode = alc662_3ST_6ch_modes, | |
15614 | .input_mux = &alc663_capture_source, | |
15615 | .unsol_event = alc663_g50v_unsol_event, | |
15616 | .init_hook = alc663_g50v_inithook, | |
15617 | }, | |
f1d4e28b | 15618 | [ALC663_ASUS_MODE1] = { |
f9e336f6 TI |
15619 | .mixers = { alc663_m51va_mixer }, |
15620 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
15621 | .init_verbs = { alc662_init_verbs, |
15622 | alc663_21jd_amic_init_verbs }, | |
15623 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15624 | .hp_nid = 0x03, | |
15625 | .dac_nids = alc662_dac_nids, | |
15626 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15627 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15628 | .channel_mode = alc662_3ST_2ch_modes, | |
15629 | .input_mux = &alc662_eeepc_capture_source, | |
15630 | .unsol_event = alc663_mode1_unsol_event, | |
15631 | .init_hook = alc663_mode1_inithook, | |
15632 | }, | |
15633 | [ALC662_ASUS_MODE2] = { | |
f9e336f6 TI |
15634 | .mixers = { alc662_1bjd_mixer }, |
15635 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
15636 | .init_verbs = { alc662_init_verbs, |
15637 | alc662_1bjd_amic_init_verbs }, | |
15638 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15639 | .dac_nids = alc662_dac_nids, | |
15640 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15641 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15642 | .channel_mode = alc662_3ST_2ch_modes, | |
15643 | .input_mux = &alc662_eeepc_capture_source, | |
15644 | .unsol_event = alc662_mode2_unsol_event, | |
15645 | .init_hook = alc662_mode2_inithook, | |
15646 | }, | |
15647 | [ALC663_ASUS_MODE3] = { | |
f9e336f6 TI |
15648 | .mixers = { alc663_two_hp_m1_mixer }, |
15649 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
15650 | .init_verbs = { alc662_init_verbs, |
15651 | alc663_two_hp_amic_m1_init_verbs }, | |
15652 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15653 | .hp_nid = 0x03, | |
15654 | .dac_nids = alc662_dac_nids, | |
15655 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15656 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15657 | .channel_mode = alc662_3ST_2ch_modes, | |
15658 | .input_mux = &alc662_eeepc_capture_source, | |
15659 | .unsol_event = alc663_mode3_unsol_event, | |
15660 | .init_hook = alc663_mode3_inithook, | |
15661 | }, | |
15662 | [ALC663_ASUS_MODE4] = { | |
f9e336f6 TI |
15663 | .mixers = { alc663_asus_21jd_clfe_mixer }, |
15664 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
15665 | .init_verbs = { alc662_init_verbs, |
15666 | alc663_21jd_amic_init_verbs}, | |
15667 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15668 | .hp_nid = 0x03, | |
15669 | .dac_nids = alc662_dac_nids, | |
15670 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15671 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15672 | .channel_mode = alc662_3ST_2ch_modes, | |
15673 | .input_mux = &alc662_eeepc_capture_source, | |
15674 | .unsol_event = alc663_mode4_unsol_event, | |
15675 | .init_hook = alc663_mode4_inithook, | |
15676 | }, | |
15677 | [ALC663_ASUS_MODE5] = { | |
f9e336f6 TI |
15678 | .mixers = { alc663_asus_15jd_clfe_mixer }, |
15679 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
15680 | .init_verbs = { alc662_init_verbs, |
15681 | alc663_15jd_amic_init_verbs }, | |
15682 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15683 | .hp_nid = 0x03, | |
15684 | .dac_nids = alc662_dac_nids, | |
15685 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15686 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15687 | .channel_mode = alc662_3ST_2ch_modes, | |
15688 | .input_mux = &alc662_eeepc_capture_source, | |
15689 | .unsol_event = alc663_mode5_unsol_event, | |
15690 | .init_hook = alc663_mode5_inithook, | |
15691 | }, | |
15692 | [ALC663_ASUS_MODE6] = { | |
f9e336f6 TI |
15693 | .mixers = { alc663_two_hp_m2_mixer }, |
15694 | .cap_mixer = alc662_auto_capture_mixer, | |
f1d4e28b KY |
15695 | .init_verbs = { alc662_init_verbs, |
15696 | alc663_two_hp_amic_m2_init_verbs }, | |
15697 | .num_dacs = ARRAY_SIZE(alc662_dac_nids), | |
15698 | .hp_nid = 0x03, | |
15699 | .dac_nids = alc662_dac_nids, | |
15700 | .dig_out_nid = ALC662_DIGOUT_NID, | |
15701 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | |
15702 | .channel_mode = alc662_3ST_2ch_modes, | |
15703 | .input_mux = &alc662_eeepc_capture_source, | |
15704 | .unsol_event = alc663_mode6_unsol_event, | |
15705 | .init_hook = alc663_mode6_inithook, | |
15706 | }, | |
bc9f98a9 KY |
15707 | }; |
15708 | ||
15709 | ||
15710 | /* | |
15711 | * BIOS auto configuration | |
15712 | */ | |
15713 | ||
15714 | /* add playback controls from the parsed DAC table */ | |
15715 | static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec, | |
15716 | const struct auto_pin_cfg *cfg) | |
15717 | { | |
15718 | char name[32]; | |
15719 | static const char *chname[4] = { | |
15720 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
15721 | }; | |
15722 | hda_nid_t nid; | |
15723 | int i, err; | |
15724 | ||
15725 | for (i = 0; i < cfg->line_outs; i++) { | |
15726 | if (!spec->multiout.dac_nids[i]) | |
15727 | continue; | |
b60dd394 | 15728 | nid = alc880_idx_to_dac(i); |
bc9f98a9 KY |
15729 | if (i == 2) { |
15730 | /* Center/LFE */ | |
15731 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
15732 | "Center Playback Volume", | |
f12ab1e0 TI |
15733 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, |
15734 | HDA_OUTPUT)); | |
bc9f98a9 KY |
15735 | if (err < 0) |
15736 | return err; | |
15737 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | |
15738 | "LFE Playback Volume", | |
f12ab1e0 TI |
15739 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, |
15740 | HDA_OUTPUT)); | |
bc9f98a9 KY |
15741 | if (err < 0) |
15742 | return err; | |
b69ce01a | 15743 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
bc9f98a9 | 15744 | "Center Playback Switch", |
b69ce01a | 15745 | HDA_COMPOSE_AMP_VAL(0x0e, 1, 0, |
f12ab1e0 | 15746 | HDA_INPUT)); |
bc9f98a9 KY |
15747 | if (err < 0) |
15748 | return err; | |
b69ce01a | 15749 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
bc9f98a9 | 15750 | "LFE Playback Switch", |
b69ce01a | 15751 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, |
f12ab1e0 | 15752 | HDA_INPUT)); |
bc9f98a9 KY |
15753 | if (err < 0) |
15754 | return err; | |
15755 | } else { | |
15756 | sprintf(name, "%s Playback Volume", chname[i]); | |
15757 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
f12ab1e0 TI |
15758 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
15759 | HDA_OUTPUT)); | |
bc9f98a9 KY |
15760 | if (err < 0) |
15761 | return err; | |
15762 | sprintf(name, "%s Playback Switch", chname[i]); | |
b69ce01a HRK |
15763 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
15764 | HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i), | |
15765 | 3, 0, HDA_INPUT)); | |
bc9f98a9 KY |
15766 | if (err < 0) |
15767 | return err; | |
15768 | } | |
15769 | } | |
15770 | return 0; | |
15771 | } | |
15772 | ||
15773 | /* add playback controls for speaker and HP outputs */ | |
15774 | static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |
15775 | const char *pfx) | |
15776 | { | |
15777 | hda_nid_t nid; | |
15778 | int err; | |
15779 | char name[32]; | |
15780 | ||
15781 | if (!pin) | |
15782 | return 0; | |
15783 | ||
24fb9173 TI |
15784 | if (pin == 0x17) { |
15785 | /* ALC663 has a mono output pin on 0x17 */ | |
15786 | sprintf(name, "%s Playback Switch", pfx); | |
15787 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
15788 | HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT)); | |
15789 | return err; | |
15790 | } | |
15791 | ||
bc9f98a9 KY |
15792 | if (alc880_is_fixed_pin(pin)) { |
15793 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
15794 | /* printk("DAC nid=%x\n",nid); */ | |
15795 | /* specify the DAC as the extra output */ | |
15796 | if (!spec->multiout.hp_nid) | |
15797 | spec->multiout.hp_nid = nid; | |
15798 | else | |
15799 | spec->multiout.extra_out_nid[0] = nid; | |
15800 | /* control HP volume/switch on the output mixer amp */ | |
15801 | nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); | |
15802 | sprintf(name, "%s Playback Volume", pfx); | |
15803 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | |
15804 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
15805 | if (err < 0) | |
15806 | return err; | |
15807 | sprintf(name, "%s Playback Switch", pfx); | |
15808 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | |
15809 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); | |
15810 | if (err < 0) | |
15811 | return err; | |
15812 | } else if (alc880_is_multi_pin(pin)) { | |
15813 | /* set manual connection */ | |
15814 | /* we have only a switch on HP-out PIN */ | |
15815 | sprintf(name, "%s Playback Switch", pfx); | |
15816 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | |
15817 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); | |
15818 | if (err < 0) | |
15819 | return err; | |
15820 | } | |
15821 | return 0; | |
15822 | } | |
15823 | ||
15824 | /* create playback/capture controls for input pins */ | |
15825 | static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec, | |
15826 | const struct auto_pin_cfg *cfg) | |
15827 | { | |
15828 | struct hda_input_mux *imux = &spec->private_imux; | |
15829 | int i, err, idx; | |
15830 | ||
15831 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
15832 | if (alc880_is_input_pin(cfg->input_pins[i])) { | |
15833 | idx = alc880_input_pin_idx(cfg->input_pins[i]); | |
15834 | err = new_analog_input(spec, cfg->input_pins[i], | |
15835 | auto_pin_cfg_labels[i], | |
15836 | idx, 0x0b); | |
15837 | if (err < 0) | |
15838 | return err; | |
15839 | imux->items[imux->num_items].label = | |
15840 | auto_pin_cfg_labels[i]; | |
15841 | imux->items[imux->num_items].index = | |
15842 | alc880_input_pin_idx(cfg->input_pins[i]); | |
15843 | imux->num_items++; | |
15844 | } | |
15845 | } | |
15846 | return 0; | |
15847 | } | |
15848 | ||
15849 | static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, | |
15850 | hda_nid_t nid, int pin_type, | |
15851 | int dac_idx) | |
15852 | { | |
f6c7e546 | 15853 | alc_set_pin_output(codec, nid, pin_type); |
bc9f98a9 KY |
15854 | /* need the manual connection? */ |
15855 | if (alc880_is_multi_pin(nid)) { | |
15856 | struct alc_spec *spec = codec->spec; | |
15857 | int idx = alc880_multi_pin_idx(nid); | |
15858 | snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, | |
15859 | AC_VERB_SET_CONNECT_SEL, | |
15860 | alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); | |
15861 | } | |
15862 | } | |
15863 | ||
15864 | static void alc662_auto_init_multi_out(struct hda_codec *codec) | |
15865 | { | |
15866 | struct alc_spec *spec = codec->spec; | |
15867 | int i; | |
15868 | ||
8c427226 | 15869 | alc_subsystem_id(codec, 0x15, 0x1b, 0x14); |
bc9f98a9 KY |
15870 | for (i = 0; i <= HDA_SIDE; i++) { |
15871 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
baba8ee9 | 15872 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
bc9f98a9 | 15873 | if (nid) |
baba8ee9 | 15874 | alc662_auto_set_output_and_unmute(codec, nid, pin_type, |
bc9f98a9 KY |
15875 | i); |
15876 | } | |
15877 | } | |
15878 | ||
15879 | static void alc662_auto_init_hp_out(struct hda_codec *codec) | |
15880 | { | |
15881 | struct alc_spec *spec = codec->spec; | |
15882 | hda_nid_t pin; | |
15883 | ||
15884 | pin = spec->autocfg.hp_pins[0]; | |
15885 | if (pin) /* connect to front */ | |
15886 | /* use dac 0 */ | |
15887 | alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | |
f6c7e546 TI |
15888 | pin = spec->autocfg.speaker_pins[0]; |
15889 | if (pin) | |
15890 | alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | |
bc9f98a9 KY |
15891 | } |
15892 | ||
15893 | #define alc662_is_input_pin(nid) alc880_is_input_pin(nid) | |
15894 | #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID | |
15895 | ||
15896 | static void alc662_auto_init_analog_input(struct hda_codec *codec) | |
15897 | { | |
15898 | struct alc_spec *spec = codec->spec; | |
15899 | int i; | |
15900 | ||
15901 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
15902 | hda_nid_t nid = spec->autocfg.input_pins[i]; | |
15903 | if (alc662_is_input_pin(nid)) { | |
15904 | snd_hda_codec_write(codec, nid, 0, | |
15905 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
15906 | (i <= AUTO_PIN_FRONT_MIC ? | |
15907 | PIN_VREF80 : PIN_IN)); | |
15908 | if (nid != ALC662_PIN_CD_NID) | |
15909 | snd_hda_codec_write(codec, nid, 0, | |
15910 | AC_VERB_SET_AMP_GAIN_MUTE, | |
15911 | AMP_OUT_MUTE); | |
15912 | } | |
15913 | } | |
15914 | } | |
15915 | ||
f511b01c TI |
15916 | #define alc662_auto_init_input_src alc882_auto_init_input_src |
15917 | ||
bc9f98a9 KY |
15918 | static int alc662_parse_auto_config(struct hda_codec *codec) |
15919 | { | |
15920 | struct alc_spec *spec = codec->spec; | |
15921 | int err; | |
15922 | static hda_nid_t alc662_ignore[] = { 0x1d, 0 }; | |
15923 | ||
15924 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | |
15925 | alc662_ignore); | |
15926 | if (err < 0) | |
15927 | return err; | |
15928 | if (!spec->autocfg.line_outs) | |
15929 | return 0; /* can't find valid BIOS pin config */ | |
15930 | ||
f12ab1e0 TI |
15931 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
15932 | if (err < 0) | |
15933 | return err; | |
15934 | err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg); | |
15935 | if (err < 0) | |
15936 | return err; | |
15937 | err = alc662_auto_create_extra_out(spec, | |
15938 | spec->autocfg.speaker_pins[0], | |
15939 | "Speaker"); | |
15940 | if (err < 0) | |
15941 | return err; | |
15942 | err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | |
15943 | "Headphone"); | |
15944 | if (err < 0) | |
15945 | return err; | |
15946 | err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg); | |
15947 | if (err < 0) | |
bc9f98a9 KY |
15948 | return err; |
15949 | ||
15950 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; | |
15951 | ||
15952 | if (spec->autocfg.dig_out_pin) | |
15953 | spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; | |
15954 | ||
603c4019 | 15955 | if (spec->kctls.list) |
d88897ea | 15956 | add_mixer(spec, spec->kctls.list); |
bc9f98a9 KY |
15957 | |
15958 | spec->num_mux_defs = 1; | |
15959 | spec->input_mux = &spec->private_imux; | |
ea1fb29a | 15960 | |
d88897ea | 15961 | add_verb(spec, alc662_auto_init_verbs); |
24fb9173 | 15962 | if (codec->vendor_id == 0x10ec0663) |
d88897ea | 15963 | add_verb(spec, alc663_auto_init_verbs); |
ee979a14 TI |
15964 | |
15965 | err = alc_auto_add_mic_boost(codec); | |
15966 | if (err < 0) | |
15967 | return err; | |
15968 | ||
e044c39a | 15969 | store_pin_configs(codec); |
8c87286f | 15970 | return 1; |
bc9f98a9 KY |
15971 | } |
15972 | ||
15973 | /* additional initialization for auto-configuration model */ | |
15974 | static void alc662_auto_init(struct hda_codec *codec) | |
15975 | { | |
f6c7e546 | 15976 | struct alc_spec *spec = codec->spec; |
bc9f98a9 KY |
15977 | alc662_auto_init_multi_out(codec); |
15978 | alc662_auto_init_hp_out(codec); | |
15979 | alc662_auto_init_analog_input(codec); | |
f511b01c | 15980 | alc662_auto_init_input_src(codec); |
f6c7e546 | 15981 | if (spec->unsol_event) |
7fb0d78f | 15982 | alc_inithook(codec); |
bc9f98a9 KY |
15983 | } |
15984 | ||
15985 | static int patch_alc662(struct hda_codec *codec) | |
15986 | { | |
15987 | struct alc_spec *spec; | |
15988 | int err, board_config; | |
15989 | ||
15990 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
15991 | if (!spec) | |
15992 | return -ENOMEM; | |
15993 | ||
15994 | codec->spec = spec; | |
15995 | ||
2c3bf9ab TI |
15996 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
15997 | ||
bc9f98a9 KY |
15998 | board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, |
15999 | alc662_models, | |
16000 | alc662_cfg_tbl); | |
16001 | if (board_config < 0) { | |
16002 | printk(KERN_INFO "hda_codec: Unknown model for ALC662, " | |
16003 | "trying auto-probe from BIOS...\n"); | |
16004 | board_config = ALC662_AUTO; | |
16005 | } | |
16006 | ||
16007 | if (board_config == ALC662_AUTO) { | |
16008 | /* automatic parse from the BIOS config */ | |
16009 | err = alc662_parse_auto_config(codec); | |
16010 | if (err < 0) { | |
16011 | alc_free(codec); | |
16012 | return err; | |
8c87286f | 16013 | } else if (!err) { |
bc9f98a9 KY |
16014 | printk(KERN_INFO |
16015 | "hda_codec: Cannot set up configuration " | |
16016 | "from BIOS. Using base mode...\n"); | |
16017 | board_config = ALC662_3ST_2ch_DIG; | |
16018 | } | |
16019 | } | |
16020 | ||
16021 | if (board_config != ALC662_AUTO) | |
16022 | setup_preset(spec, &alc662_presets[board_config]); | |
16023 | ||
6dda9f4a KY |
16024 | if (codec->vendor_id == 0x10ec0663) { |
16025 | spec->stream_name_analog = "ALC663 Analog"; | |
16026 | spec->stream_name_digital = "ALC663 Digital"; | |
01afd41f KY |
16027 | } else if (codec->vendor_id == 0x10ec0272) { |
16028 | spec->stream_name_analog = "ALC272 Analog"; | |
16029 | spec->stream_name_digital = "ALC272 Digital"; | |
6dda9f4a KY |
16030 | } else { |
16031 | spec->stream_name_analog = "ALC662 Analog"; | |
16032 | spec->stream_name_digital = "ALC662 Digital"; | |
16033 | } | |
16034 | ||
bc9f98a9 KY |
16035 | spec->stream_analog_playback = &alc662_pcm_analog_playback; |
16036 | spec->stream_analog_capture = &alc662_pcm_analog_capture; | |
16037 | ||
bc9f98a9 KY |
16038 | spec->stream_digital_playback = &alc662_pcm_digital_playback; |
16039 | spec->stream_digital_capture = &alc662_pcm_digital_capture; | |
16040 | ||
e1406348 TI |
16041 | spec->adc_nids = alc662_adc_nids; |
16042 | spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); | |
16043 | spec->capsrc_nids = alc662_capsrc_nids; | |
54cbc9ab | 16044 | spec->is_mix_capture = 1; |
bc9f98a9 | 16045 | |
f9e336f6 TI |
16046 | if (!spec->cap_mixer) |
16047 | set_capture_mixer(spec); | |
16048 | ||
2134ea4f TI |
16049 | spec->vmaster_nid = 0x02; |
16050 | ||
bc9f98a9 KY |
16051 | codec->patch_ops = alc_patch_ops; |
16052 | if (board_config == ALC662_AUTO) | |
16053 | spec->init_hook = alc662_auto_init; | |
cb53c626 TI |
16054 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
16055 | if (!spec->loopback.amplist) | |
16056 | spec->loopback.amplist = alc662_loopbacks; | |
16057 | #endif | |
bc9f98a9 KY |
16058 | |
16059 | return 0; | |
16060 | } | |
16061 | ||
1da177e4 LT |
16062 | /* |
16063 | * patch entries | |
16064 | */ | |
16065 | struct hda_codec_preset snd_hda_preset_realtek[] = { | |
16066 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, | |
df694daa | 16067 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
f6a92248 | 16068 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
a361d84b | 16069 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
f6a92248 | 16070 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
01afd41f | 16071 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
f32610ed | 16072 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
bc9f98a9 | 16073 | .patch = patch_alc861 }, |
f32610ed JS |
16074 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
16075 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, | |
16076 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, | |
bc9f98a9 KY |
16077 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
16078 | .patch = patch_alc883 }, | |
16079 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", | |
16080 | .patch = patch_alc662 }, | |
6dda9f4a | 16081 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
f32610ed | 16082 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
1da177e4 | 16083 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
9c7f852e | 16084 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, |
669faba2 CM |
16085 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
16086 | .patch = patch_alc882 }, /* should be patch_alc883() in future */ | |
cb308f97 | 16087 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
7943a8ab | 16088 | .patch = patch_alc882 }, /* should be patch_alc883() in future */ |
df694daa | 16089 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
a385a529 | 16090 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 }, |
9c7f852e | 16091 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, |
4442608d KY |
16092 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
16093 | .patch = patch_alc883 }, | |
f6a92248 | 16094 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, |
1da177e4 LT |
16095 | {} /* terminator */ |
16096 | }; |