]>
Commit | Line | Data |
---|---|---|
2f2f4251 M |
1 | /* |
2 | * Universal Interface for Intel High Definition Audio Codec | |
3 | * | |
4 | * HD audio interface patch for SigmaTel STAC92xx | |
5 | * | |
6 | * Copyright (c) 2005 Embedded Alley Solutions, Inc. | |
403d1944 | 7 | * Matt Porter <mporter@embeddedalley.com> |
2f2f4251 M |
8 | * |
9 | * Based on patch_cmedia.c and patch_realtek.c | |
10 | * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de> | |
11 | * | |
12 | * This driver is free software; you can redistribute it and/or modify | |
13 | * it under the terms of the GNU General Public License as published by | |
14 | * the Free Software Foundation; either version 2 of the License, or | |
15 | * (at your option) any later version. | |
16 | * | |
17 | * This driver is distributed in the hope that it will be useful, | |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | * GNU General Public License for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU General Public License | |
23 | * along with this program; if not, write to the Free Software | |
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
25 | */ | |
26 | ||
2f2f4251 M |
27 | #include <linux/init.h> |
28 | #include <linux/delay.h> | |
29 | #include <linux/slab.h> | |
30 | #include <linux/pci.h> | |
31 | #include <sound/core.h> | |
c7d4b2fa | 32 | #include <sound/asoundef.h> |
45a6ac16 | 33 | #include <sound/jack.h> |
2f2f4251 M |
34 | #include "hda_codec.h" |
35 | #include "hda_local.h" | |
1cd2224c | 36 | #include "hda_beep.h" |
2f2f4251 | 37 | |
c6e4c666 TI |
38 | enum { |
39 | STAC_VREF_EVENT = 1, | |
40 | STAC_INSERT_EVENT, | |
41 | STAC_PWR_EVENT, | |
42 | STAC_HP_EVENT, | |
43 | }; | |
4e55096e | 44 | |
f5fcc13c TI |
45 | enum { |
46 | STAC_REF, | |
bf277785 | 47 | STAC_9200_OQO, |
dfe495d0 TI |
48 | STAC_9200_DELL_D21, |
49 | STAC_9200_DELL_D22, | |
50 | STAC_9200_DELL_D23, | |
51 | STAC_9200_DELL_M21, | |
52 | STAC_9200_DELL_M22, | |
53 | STAC_9200_DELL_M23, | |
54 | STAC_9200_DELL_M24, | |
55 | STAC_9200_DELL_M25, | |
56 | STAC_9200_DELL_M26, | |
57 | STAC_9200_DELL_M27, | |
58eec423 MCC |
58 | STAC_9200_M4, |
59 | STAC_9200_M4_2, | |
117f257d | 60 | STAC_9200_PANASONIC, |
f5fcc13c TI |
61 | STAC_9200_MODELS |
62 | }; | |
63 | ||
64 | enum { | |
65 | STAC_9205_REF, | |
dfe495d0 | 66 | STAC_9205_DELL_M42, |
ae0a8ed8 TD |
67 | STAC_9205_DELL_M43, |
68 | STAC_9205_DELL_M44, | |
d9a4268e | 69 | STAC_9205_EAPD, |
f5fcc13c TI |
70 | STAC_9205_MODELS |
71 | }; | |
72 | ||
e1f0d669 | 73 | enum { |
9e43f0de | 74 | STAC_92HD73XX_NO_JD, /* no jack-detection */ |
e1f0d669 | 75 | STAC_92HD73XX_REF, |
661cd8fb TI |
76 | STAC_DELL_M6_AMIC, |
77 | STAC_DELL_M6_DMIC, | |
78 | STAC_DELL_M6_BOTH, | |
6b3ab21e | 79 | STAC_DELL_EQ, |
e1f0d669 MR |
80 | STAC_92HD73XX_MODELS |
81 | }; | |
82 | ||
d0513fc6 MR |
83 | enum { |
84 | STAC_92HD83XXX_REF, | |
32ed3f46 | 85 | STAC_92HD83XXX_PWR_REF, |
d0513fc6 MR |
86 | STAC_92HD83XXX_MODELS |
87 | }; | |
88 | ||
e035b841 MR |
89 | enum { |
90 | STAC_92HD71BXX_REF, | |
a7662640 MR |
91 | STAC_DELL_M4_1, |
92 | STAC_DELL_M4_2, | |
3a7abfd2 | 93 | STAC_DELL_M4_3, |
6a14f585 | 94 | STAC_HP_M4, |
1b0652eb | 95 | STAC_HP_DV5, |
e035b841 MR |
96 | STAC_92HD71BXX_MODELS |
97 | }; | |
98 | ||
8e21c34c TD |
99 | enum { |
100 | STAC_925x_REF, | |
9cb36c2a MCC |
101 | STAC_M1, |
102 | STAC_M1_2, | |
103 | STAC_M2, | |
8e21c34c | 104 | STAC_M2_2, |
9cb36c2a MCC |
105 | STAC_M3, |
106 | STAC_M5, | |
107 | STAC_M6, | |
8e21c34c TD |
108 | STAC_925x_MODELS |
109 | }; | |
110 | ||
f5fcc13c TI |
111 | enum { |
112 | STAC_D945_REF, | |
113 | STAC_D945GTP3, | |
114 | STAC_D945GTP5, | |
5d5d3bc3 IZ |
115 | STAC_INTEL_MAC_V1, |
116 | STAC_INTEL_MAC_V2, | |
117 | STAC_INTEL_MAC_V3, | |
118 | STAC_INTEL_MAC_V4, | |
119 | STAC_INTEL_MAC_V5, | |
536319af NB |
120 | STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter |
121 | * is given, one of the above models will be | |
122 | * chosen according to the subsystem id. */ | |
dfe495d0 | 123 | /* for backward compatibility */ |
f5fcc13c | 124 | STAC_MACMINI, |
3fc24d85 | 125 | STAC_MACBOOK, |
6f0778d8 NB |
126 | STAC_MACBOOK_PRO_V1, |
127 | STAC_MACBOOK_PRO_V2, | |
f16928fb | 128 | STAC_IMAC_INTEL, |
0dae0f83 | 129 | STAC_IMAC_INTEL_20, |
8c650087 | 130 | STAC_ECS_202, |
dfe495d0 TI |
131 | STAC_922X_DELL_D81, |
132 | STAC_922X_DELL_D82, | |
133 | STAC_922X_DELL_M81, | |
134 | STAC_922X_DELL_M82, | |
f5fcc13c TI |
135 | STAC_922X_MODELS |
136 | }; | |
137 | ||
138 | enum { | |
e28d8322 | 139 | STAC_D965_REF_NO_JD, /* no jack-detection */ |
f5fcc13c TI |
140 | STAC_D965_REF, |
141 | STAC_D965_3ST, | |
142 | STAC_D965_5ST, | |
4ff076e5 | 143 | STAC_DELL_3ST, |
8e9068b1 | 144 | STAC_DELL_BIOS, |
f5fcc13c TI |
145 | STAC_927X_MODELS |
146 | }; | |
403d1944 | 147 | |
74aeaabc MR |
148 | struct sigmatel_event { |
149 | hda_nid_t nid; | |
c6e4c666 TI |
150 | unsigned char type; |
151 | unsigned char tag; | |
74aeaabc MR |
152 | int data; |
153 | }; | |
154 | ||
155 | struct sigmatel_jack { | |
156 | hda_nid_t nid; | |
157 | int type; | |
158 | struct snd_jack *jack; | |
159 | }; | |
160 | ||
2f2f4251 | 161 | struct sigmatel_spec { |
c8b6bf9b | 162 | struct snd_kcontrol_new *mixers[4]; |
c7d4b2fa M |
163 | unsigned int num_mixers; |
164 | ||
403d1944 | 165 | int board_config; |
c0cea0d0 | 166 | unsigned int eapd_switch: 1; |
c7d4b2fa | 167 | unsigned int surr_switch: 1; |
3cc08dc6 | 168 | unsigned int alt_switch: 1; |
82bc955f | 169 | unsigned int hp_detect: 1; |
00ef50c2 | 170 | unsigned int spdif_mute: 1; |
7c7767eb | 171 | unsigned int check_volume_offset:1; |
c7d4b2fa | 172 | |
4fe5195c | 173 | /* gpio lines */ |
0fc9dec4 | 174 | unsigned int eapd_mask; |
4fe5195c MR |
175 | unsigned int gpio_mask; |
176 | unsigned int gpio_dir; | |
177 | unsigned int gpio_data; | |
178 | unsigned int gpio_mute; | |
179 | ||
8daaaa97 MR |
180 | /* stream */ |
181 | unsigned int stream_delay; | |
182 | ||
4fe5195c | 183 | /* analog loopback */ |
e1f0d669 MR |
184 | unsigned char aloopback_mask; |
185 | unsigned char aloopback_shift; | |
8259980e | 186 | |
a64135a2 MR |
187 | /* power management */ |
188 | unsigned int num_pwrs; | |
d0513fc6 | 189 | unsigned int *pwr_mapping; |
a64135a2 | 190 | hda_nid_t *pwr_nids; |
b76c850f | 191 | hda_nid_t *dac_list; |
a64135a2 | 192 | |
74aeaabc MR |
193 | /* jack detection */ |
194 | struct snd_array jacks; | |
195 | ||
196 | /* events */ | |
197 | struct snd_array events; | |
198 | ||
2f2f4251 | 199 | /* playback */ |
b22b4821 | 200 | struct hda_input_mux *mono_mux; |
89385035 | 201 | struct hda_input_mux *amp_mux; |
b22b4821 | 202 | unsigned int cur_mmux; |
2f2f4251 | 203 | struct hda_multi_out multiout; |
3cc08dc6 | 204 | hda_nid_t dac_nids[5]; |
c21ca4a8 TI |
205 | hda_nid_t hp_dacs[5]; |
206 | hda_nid_t speaker_dacs[5]; | |
2f2f4251 | 207 | |
7c7767eb TI |
208 | int volume_offset; |
209 | ||
2f2f4251 M |
210 | /* capture */ |
211 | hda_nid_t *adc_nids; | |
2f2f4251 | 212 | unsigned int num_adcs; |
dabbed6f M |
213 | hda_nid_t *mux_nids; |
214 | unsigned int num_muxes; | |
8b65727b MP |
215 | hda_nid_t *dmic_nids; |
216 | unsigned int num_dmics; | |
e1f0d669 | 217 | hda_nid_t *dmux_nids; |
1697055e | 218 | unsigned int num_dmuxes; |
d9737751 MR |
219 | hda_nid_t *smux_nids; |
220 | unsigned int num_smuxes; | |
65973632 | 221 | const char **spdif_labels; |
d9737751 | 222 | |
dabbed6f | 223 | hda_nid_t dig_in_nid; |
b22b4821 | 224 | hda_nid_t mono_nid; |
1cd2224c MR |
225 | hda_nid_t anabeep_nid; |
226 | hda_nid_t digbeep_nid; | |
2f2f4251 | 227 | |
2f2f4251 M |
228 | /* pin widgets */ |
229 | hda_nid_t *pin_nids; | |
230 | unsigned int num_pins; | |
2f2f4251 | 231 | unsigned int *pin_configs; |
2f2f4251 M |
232 | |
233 | /* codec specific stuff */ | |
234 | struct hda_verb *init; | |
c8b6bf9b | 235 | struct snd_kcontrol_new *mixer; |
2f2f4251 M |
236 | |
237 | /* capture source */ | |
8b65727b | 238 | struct hda_input_mux *dinput_mux; |
e1f0d669 | 239 | unsigned int cur_dmux[2]; |
c7d4b2fa | 240 | struct hda_input_mux *input_mux; |
3cc08dc6 | 241 | unsigned int cur_mux[3]; |
d9737751 MR |
242 | struct hda_input_mux *sinput_mux; |
243 | unsigned int cur_smux[2]; | |
2a9c7816 MR |
244 | unsigned int cur_amux; |
245 | hda_nid_t *amp_nids; | |
246 | unsigned int num_amps; | |
8daaaa97 | 247 | unsigned int powerdown_adcs; |
2f2f4251 | 248 | |
403d1944 MP |
249 | /* i/o switches */ |
250 | unsigned int io_switch[2]; | |
0fb87bb4 | 251 | unsigned int clfe_swap; |
c21ca4a8 TI |
252 | hda_nid_t line_switch; /* shared line-in for input and output */ |
253 | hda_nid_t mic_switch; /* shared mic-in for input and output */ | |
254 | hda_nid_t hp_switch; /* NID of HP as line-out */ | |
5f10c4a9 | 255 | unsigned int aloopback; |
2f2f4251 | 256 | |
c7d4b2fa M |
257 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
258 | ||
259 | /* dynamic controls and input_mux */ | |
260 | struct auto_pin_cfg autocfg; | |
603c4019 | 261 | struct snd_array kctls; |
8b65727b | 262 | struct hda_input_mux private_dimux; |
c7d4b2fa | 263 | struct hda_input_mux private_imux; |
d9737751 | 264 | struct hda_input_mux private_smux; |
89385035 | 265 | struct hda_input_mux private_amp_mux; |
b22b4821 | 266 | struct hda_input_mux private_mono_mux; |
2f2f4251 M |
267 | }; |
268 | ||
269 | static hda_nid_t stac9200_adc_nids[1] = { | |
270 | 0x03, | |
271 | }; | |
272 | ||
273 | static hda_nid_t stac9200_mux_nids[1] = { | |
274 | 0x0c, | |
275 | }; | |
276 | ||
277 | static hda_nid_t stac9200_dac_nids[1] = { | |
278 | 0x02, | |
279 | }; | |
280 | ||
a64135a2 MR |
281 | static hda_nid_t stac92hd73xx_pwr_nids[8] = { |
282 | 0x0a, 0x0b, 0x0c, 0xd, 0x0e, | |
283 | 0x0f, 0x10, 0x11 | |
284 | }; | |
285 | ||
0ffa9807 MR |
286 | static hda_nid_t stac92hd73xx_slave_dig_outs[2] = { |
287 | 0x26, 0, | |
288 | }; | |
289 | ||
e1f0d669 MR |
290 | static hda_nid_t stac92hd73xx_adc_nids[2] = { |
291 | 0x1a, 0x1b | |
292 | }; | |
293 | ||
2a9c7816 MR |
294 | #define DELL_M6_AMP 2 |
295 | static hda_nid_t stac92hd73xx_amp_nids[3] = { | |
296 | 0x0b, 0x0c, 0x0e | |
89385035 MR |
297 | }; |
298 | ||
e1f0d669 MR |
299 | #define STAC92HD73XX_NUM_DMICS 2 |
300 | static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { | |
301 | 0x13, 0x14, 0 | |
302 | }; | |
303 | ||
304 | #define STAC92HD73_DAC_COUNT 5 | |
e1f0d669 MR |
305 | |
306 | static hda_nid_t stac92hd73xx_mux_nids[4] = { | |
307 | 0x28, 0x29, 0x2a, 0x2b, | |
308 | }; | |
309 | ||
310 | static hda_nid_t stac92hd73xx_dmux_nids[2] = { | |
311 | 0x20, 0x21, | |
312 | }; | |
313 | ||
d9737751 MR |
314 | static hda_nid_t stac92hd73xx_smux_nids[2] = { |
315 | 0x22, 0x23, | |
316 | }; | |
317 | ||
d0513fc6 MR |
318 | #define STAC92HD83XXX_NUM_DMICS 2 |
319 | static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { | |
320 | 0x11, 0x12, 0 | |
321 | }; | |
322 | ||
d0513fc6 | 323 | #define STAC92HD83_DAC_COUNT 3 |
d0513fc6 MR |
324 | |
325 | static hda_nid_t stac92hd83xxx_dmux_nids[2] = { | |
326 | 0x17, 0x18, | |
327 | }; | |
328 | ||
329 | static hda_nid_t stac92hd83xxx_adc_nids[2] = { | |
330 | 0x15, 0x16, | |
331 | }; | |
332 | ||
333 | static hda_nid_t stac92hd83xxx_pwr_nids[4] = { | |
334 | 0xa, 0xb, 0xd, 0xe, | |
335 | }; | |
336 | ||
0ffa9807 MR |
337 | static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = { |
338 | 0x1e, 0, | |
339 | }; | |
340 | ||
d0513fc6 | 341 | static unsigned int stac92hd83xxx_pwr_mapping[4] = { |
87e88a74 | 342 | 0x03, 0x0c, 0x20, 0x40, |
d0513fc6 MR |
343 | }; |
344 | ||
9248f269 | 345 | static hda_nid_t stac92hd83xxx_amp_nids[1] = { |
c15c5060 MR |
346 | 0xc, |
347 | }; | |
348 | ||
a64135a2 MR |
349 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { |
350 | 0x0a, 0x0d, 0x0f | |
351 | }; | |
352 | ||
e035b841 MR |
353 | static hda_nid_t stac92hd71bxx_adc_nids[2] = { |
354 | 0x12, 0x13, | |
355 | }; | |
356 | ||
357 | static hda_nid_t stac92hd71bxx_mux_nids[2] = { | |
358 | 0x1a, 0x1b | |
359 | }; | |
360 | ||
4b33c767 MR |
361 | static hda_nid_t stac92hd71bxx_dmux_nids[2] = { |
362 | 0x1c, 0x1d, | |
e1f0d669 MR |
363 | }; |
364 | ||
d9737751 MR |
365 | static hda_nid_t stac92hd71bxx_smux_nids[2] = { |
366 | 0x24, 0x25, | |
367 | }; | |
368 | ||
e035b841 MR |
369 | #define STAC92HD71BXX_NUM_DMICS 2 |
370 | static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { | |
371 | 0x18, 0x19, 0 | |
372 | }; | |
373 | ||
0ffa9807 MR |
374 | static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = { |
375 | 0x22, 0 | |
376 | }; | |
377 | ||
8e21c34c TD |
378 | static hda_nid_t stac925x_adc_nids[1] = { |
379 | 0x03, | |
380 | }; | |
381 | ||
382 | static hda_nid_t stac925x_mux_nids[1] = { | |
383 | 0x0f, | |
384 | }; | |
385 | ||
386 | static hda_nid_t stac925x_dac_nids[1] = { | |
387 | 0x02, | |
388 | }; | |
389 | ||
f6e9852a TI |
390 | #define STAC925X_NUM_DMICS 1 |
391 | static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = { | |
392 | 0x15, 0 | |
2c11f955 TD |
393 | }; |
394 | ||
1697055e TI |
395 | static hda_nid_t stac925x_dmux_nids[1] = { |
396 | 0x14, | |
397 | }; | |
398 | ||
2f2f4251 M |
399 | static hda_nid_t stac922x_adc_nids[2] = { |
400 | 0x06, 0x07, | |
401 | }; | |
402 | ||
403 | static hda_nid_t stac922x_mux_nids[2] = { | |
404 | 0x12, 0x13, | |
405 | }; | |
406 | ||
3cc08dc6 MP |
407 | static hda_nid_t stac927x_adc_nids[3] = { |
408 | 0x07, 0x08, 0x09 | |
409 | }; | |
410 | ||
411 | static hda_nid_t stac927x_mux_nids[3] = { | |
412 | 0x15, 0x16, 0x17 | |
413 | }; | |
414 | ||
d9737751 MR |
415 | static hda_nid_t stac927x_smux_nids[1] = { |
416 | 0x21, | |
417 | }; | |
418 | ||
b76c850f MR |
419 | static hda_nid_t stac927x_dac_nids[6] = { |
420 | 0x02, 0x03, 0x04, 0x05, 0x06, 0 | |
421 | }; | |
422 | ||
e1f0d669 MR |
423 | static hda_nid_t stac927x_dmux_nids[1] = { |
424 | 0x1b, | |
425 | }; | |
426 | ||
7f16859a MR |
427 | #define STAC927X_NUM_DMICS 2 |
428 | static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { | |
429 | 0x13, 0x14, 0 | |
430 | }; | |
431 | ||
65973632 MR |
432 | static const char *stac927x_spdif_labels[5] = { |
433 | "Digital Playback", "ADAT", "Analog Mux 1", | |
434 | "Analog Mux 2", "Analog Mux 3" | |
435 | }; | |
436 | ||
f3302a59 MP |
437 | static hda_nid_t stac9205_adc_nids[2] = { |
438 | 0x12, 0x13 | |
439 | }; | |
440 | ||
441 | static hda_nid_t stac9205_mux_nids[2] = { | |
442 | 0x19, 0x1a | |
443 | }; | |
444 | ||
e1f0d669 | 445 | static hda_nid_t stac9205_dmux_nids[1] = { |
1697055e | 446 | 0x1d, |
e1f0d669 MR |
447 | }; |
448 | ||
d9737751 MR |
449 | static hda_nid_t stac9205_smux_nids[1] = { |
450 | 0x21, | |
451 | }; | |
452 | ||
f6e9852a TI |
453 | #define STAC9205_NUM_DMICS 2 |
454 | static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { | |
455 | 0x17, 0x18, 0 | |
8b65727b MP |
456 | }; |
457 | ||
c7d4b2fa | 458 | static hda_nid_t stac9200_pin_nids[8] = { |
93ed1503 TD |
459 | 0x08, 0x09, 0x0d, 0x0e, |
460 | 0x0f, 0x10, 0x11, 0x12, | |
2f2f4251 M |
461 | }; |
462 | ||
8e21c34c TD |
463 | static hda_nid_t stac925x_pin_nids[8] = { |
464 | 0x07, 0x08, 0x0a, 0x0b, | |
465 | 0x0c, 0x0d, 0x10, 0x11, | |
466 | }; | |
467 | ||
2f2f4251 M |
468 | static hda_nid_t stac922x_pin_nids[10] = { |
469 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, | |
470 | 0x0f, 0x10, 0x11, 0x15, 0x1b, | |
471 | }; | |
472 | ||
a7662640 | 473 | static hda_nid_t stac92hd73xx_pin_nids[13] = { |
e1f0d669 MR |
474 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
475 | 0x0f, 0x10, 0x11, 0x12, 0x13, | |
d9737751 | 476 | 0x14, 0x22, 0x23 |
e1f0d669 MR |
477 | }; |
478 | ||
d0513fc6 MR |
479 | static hda_nid_t stac92hd83xxx_pin_nids[14] = { |
480 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, | |
481 | 0x0f, 0x10, 0x11, 0x12, 0x13, | |
482 | 0x1d, 0x1e, 0x1f, 0x20 | |
483 | }; | |
0ffa9807 | 484 | static hda_nid_t stac92hd71bxx_pin_nids[11] = { |
e035b841 MR |
485 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
486 | 0x0f, 0x14, 0x18, 0x19, 0x1e, | |
0ffa9807 | 487 | 0x1f, |
e035b841 MR |
488 | }; |
489 | ||
3cc08dc6 MP |
490 | static hda_nid_t stac927x_pin_nids[14] = { |
491 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, | |
492 | 0x0f, 0x10, 0x11, 0x12, 0x13, | |
493 | 0x14, 0x21, 0x22, 0x23, | |
494 | }; | |
495 | ||
f3302a59 MP |
496 | static hda_nid_t stac9205_pin_nids[12] = { |
497 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, | |
498 | 0x0f, 0x14, 0x16, 0x17, 0x18, | |
499 | 0x21, 0x22, | |
f3302a59 MP |
500 | }; |
501 | ||
89385035 MR |
502 | #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info |
503 | ||
504 | static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol, | |
505 | struct snd_ctl_elem_value *ucontrol) | |
506 | { | |
507 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
508 | struct sigmatel_spec *spec = codec->spec; | |
509 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; | |
510 | ||
511 | kcontrol->private_value ^= get_amp_nid(kcontrol); | |
512 | kcontrol->private_value |= nid; | |
513 | ||
514 | return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); | |
515 | } | |
516 | ||
517 | static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol, | |
518 | struct snd_ctl_elem_value *ucontrol) | |
519 | { | |
520 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
521 | struct sigmatel_spec *spec = codec->spec; | |
522 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; | |
523 | ||
524 | kcontrol->private_value ^= get_amp_nid(kcontrol); | |
525 | kcontrol->private_value |= nid; | |
526 | ||
527 | return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); | |
528 | } | |
529 | ||
8b65727b MP |
530 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, |
531 | struct snd_ctl_elem_info *uinfo) | |
532 | { | |
533 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
534 | struct sigmatel_spec *spec = codec->spec; | |
535 | return snd_hda_input_mux_info(spec->dinput_mux, uinfo); | |
536 | } | |
537 | ||
538 | static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol, | |
539 | struct snd_ctl_elem_value *ucontrol) | |
540 | { | |
541 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
542 | struct sigmatel_spec *spec = codec->spec; | |
e1f0d669 | 543 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
8b65727b | 544 | |
e1f0d669 | 545 | ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx]; |
8b65727b MP |
546 | return 0; |
547 | } | |
548 | ||
549 | static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol, | |
550 | struct snd_ctl_elem_value *ucontrol) | |
551 | { | |
552 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
553 | struct sigmatel_spec *spec = codec->spec; | |
e1f0d669 | 554 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
8b65727b MP |
555 | |
556 | return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, | |
e1f0d669 | 557 | spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]); |
8b65727b MP |
558 | } |
559 | ||
d9737751 MR |
560 | static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol, |
561 | struct snd_ctl_elem_info *uinfo) | |
562 | { | |
563 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
564 | struct sigmatel_spec *spec = codec->spec; | |
565 | return snd_hda_input_mux_info(spec->sinput_mux, uinfo); | |
566 | } | |
567 | ||
568 | static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol, | |
569 | struct snd_ctl_elem_value *ucontrol) | |
570 | { | |
571 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
572 | struct sigmatel_spec *spec = codec->spec; | |
573 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
574 | ||
575 | ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx]; | |
576 | return 0; | |
577 | } | |
578 | ||
579 | static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol, | |
580 | struct snd_ctl_elem_value *ucontrol) | |
581 | { | |
582 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
583 | struct sigmatel_spec *spec = codec->spec; | |
00ef50c2 | 584 | struct hda_input_mux *smux = &spec->private_smux; |
d9737751 | 585 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
00ef50c2 MR |
586 | int err, val; |
587 | hda_nid_t nid; | |
d9737751 | 588 | |
00ef50c2 | 589 | err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol, |
d9737751 | 590 | spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]); |
00ef50c2 MR |
591 | if (err < 0) |
592 | return err; | |
593 | ||
594 | if (spec->spdif_mute) { | |
595 | if (smux_idx == 0) | |
596 | nid = spec->multiout.dig_out_nid; | |
597 | else | |
598 | nid = codec->slave_dig_outs[smux_idx - 1]; | |
599 | if (spec->cur_smux[smux_idx] == smux->num_items - 1) | |
c9b46f91 | 600 | val = HDA_AMP_MUTE; |
00ef50c2 | 601 | else |
c9b46f91 | 602 | val = 0; |
00ef50c2 | 603 | /* un/mute SPDIF out */ |
c9b46f91 TI |
604 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
605 | HDA_AMP_MUTE, val); | |
00ef50c2 MR |
606 | } |
607 | return 0; | |
d9737751 MR |
608 | } |
609 | ||
c8b6bf9b | 610 | static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
2f2f4251 M |
611 | { |
612 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
613 | struct sigmatel_spec *spec = codec->spec; | |
c7d4b2fa | 614 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
2f2f4251 M |
615 | } |
616 | ||
c8b6bf9b | 617 | static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
2f2f4251 M |
618 | { |
619 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
620 | struct sigmatel_spec *spec = codec->spec; | |
621 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
622 | ||
623 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | |
624 | return 0; | |
625 | } | |
626 | ||
c8b6bf9b | 627 | static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
2f2f4251 M |
628 | { |
629 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
630 | struct sigmatel_spec *spec = codec->spec; | |
631 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | |
632 | ||
c7d4b2fa | 633 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
2f2f4251 M |
634 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); |
635 | } | |
636 | ||
b22b4821 MR |
637 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, |
638 | struct snd_ctl_elem_info *uinfo) | |
639 | { | |
640 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
641 | struct sigmatel_spec *spec = codec->spec; | |
642 | return snd_hda_input_mux_info(spec->mono_mux, uinfo); | |
643 | } | |
644 | ||
645 | static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol, | |
646 | struct snd_ctl_elem_value *ucontrol) | |
647 | { | |
648 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
649 | struct sigmatel_spec *spec = codec->spec; | |
650 | ||
651 | ucontrol->value.enumerated.item[0] = spec->cur_mmux; | |
652 | return 0; | |
653 | } | |
654 | ||
655 | static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol, | |
656 | struct snd_ctl_elem_value *ucontrol) | |
657 | { | |
658 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
659 | struct sigmatel_spec *spec = codec->spec; | |
660 | ||
661 | return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol, | |
662 | spec->mono_nid, &spec->cur_mmux); | |
663 | } | |
664 | ||
89385035 MR |
665 | static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol, |
666 | struct snd_ctl_elem_info *uinfo) | |
667 | { | |
668 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
669 | struct sigmatel_spec *spec = codec->spec; | |
670 | return snd_hda_input_mux_info(spec->amp_mux, uinfo); | |
671 | } | |
672 | ||
673 | static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol, | |
674 | struct snd_ctl_elem_value *ucontrol) | |
675 | { | |
676 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
677 | struct sigmatel_spec *spec = codec->spec; | |
678 | ||
679 | ucontrol->value.enumerated.item[0] = spec->cur_amux; | |
680 | return 0; | |
681 | } | |
682 | ||
683 | static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol, | |
684 | struct snd_ctl_elem_value *ucontrol) | |
685 | { | |
686 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
687 | struct sigmatel_spec *spec = codec->spec; | |
688 | struct snd_kcontrol *ctl = | |
689 | snd_hda_find_mixer_ctl(codec, "Amp Capture Volume"); | |
690 | if (!ctl) | |
691 | return -EINVAL; | |
692 | ||
693 | snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE | | |
694 | SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); | |
695 | ||
696 | return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol, | |
697 | 0, &spec->cur_amux); | |
698 | } | |
699 | ||
5f10c4a9 ML |
700 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info |
701 | ||
702 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, | |
703 | struct snd_ctl_elem_value *ucontrol) | |
704 | { | |
705 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
e1f0d669 | 706 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
5f10c4a9 ML |
707 | struct sigmatel_spec *spec = codec->spec; |
708 | ||
e1f0d669 MR |
709 | ucontrol->value.integer.value[0] = !!(spec->aloopback & |
710 | (spec->aloopback_mask << idx)); | |
5f10c4a9 ML |
711 | return 0; |
712 | } | |
713 | ||
714 | static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol, | |
715 | struct snd_ctl_elem_value *ucontrol) | |
716 | { | |
717 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
718 | struct sigmatel_spec *spec = codec->spec; | |
e1f0d669 | 719 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
5f10c4a9 | 720 | unsigned int dac_mode; |
e1f0d669 | 721 | unsigned int val, idx_val; |
5f10c4a9 | 722 | |
e1f0d669 MR |
723 | idx_val = spec->aloopback_mask << idx; |
724 | if (ucontrol->value.integer.value[0]) | |
725 | val = spec->aloopback | idx_val; | |
726 | else | |
727 | val = spec->aloopback & ~idx_val; | |
68ea7b2f | 728 | if (spec->aloopback == val) |
5f10c4a9 ML |
729 | return 0; |
730 | ||
68ea7b2f | 731 | spec->aloopback = val; |
5f10c4a9 | 732 | |
e1f0d669 MR |
733 | /* Only return the bits defined by the shift value of the |
734 | * first two bytes of the mask | |
735 | */ | |
5f10c4a9 | 736 | dac_mode = snd_hda_codec_read(codec, codec->afg, 0, |
e1f0d669 MR |
737 | kcontrol->private_value & 0xFFFF, 0x0); |
738 | dac_mode >>= spec->aloopback_shift; | |
5f10c4a9 | 739 | |
e1f0d669 | 740 | if (spec->aloopback & idx_val) { |
5f10c4a9 | 741 | snd_hda_power_up(codec); |
e1f0d669 | 742 | dac_mode |= idx_val; |
5f10c4a9 ML |
743 | } else { |
744 | snd_hda_power_down(codec); | |
e1f0d669 | 745 | dac_mode &= ~idx_val; |
5f10c4a9 ML |
746 | } |
747 | ||
748 | snd_hda_codec_write_cache(codec, codec->afg, 0, | |
749 | kcontrol->private_value >> 16, dac_mode); | |
750 | ||
751 | return 1; | |
752 | } | |
753 | ||
c7d4b2fa | 754 | static struct hda_verb stac9200_core_init[] = { |
2f2f4251 | 755 | /* set dac0mux for dac converter */ |
c7d4b2fa | 756 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
2f2f4251 M |
757 | {} |
758 | }; | |
759 | ||
1194b5b7 TI |
760 | static struct hda_verb stac9200_eapd_init[] = { |
761 | /* set dac0mux for dac converter */ | |
762 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
763 | {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | |
764 | {} | |
765 | }; | |
766 | ||
e1f0d669 MR |
767 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { |
768 | /* set master volume and direct control */ | |
769 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | |
e1f0d669 MR |
770 | /* setup adcs to point to mixer */ |
771 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | |
772 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | |
e1f0d669 MR |
773 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
774 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
775 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
776 | /* setup import muxs */ | |
777 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
778 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
779 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
780 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
781 | {} | |
782 | }; | |
783 | ||
d654a660 MR |
784 | static struct hda_verb dell_eq_core_init[] = { |
785 | /* set master volume to max value without distortion | |
786 | * and direct control */ | |
787 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, | |
d654a660 MR |
788 | /* setup adcs to point to mixer */ |
789 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | |
790 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | |
791 | /* setup import muxs */ | |
792 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
793 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
794 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
795 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
796 | {} | |
797 | }; | |
798 | ||
52fe0f9d | 799 | static struct hda_verb dell_m6_core_init[] = { |
6b3ab21e | 800 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
52fe0f9d MR |
801 | /* setup adcs to point to mixer */ |
802 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | |
803 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | |
804 | /* setup import muxs */ | |
805 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
806 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
807 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
808 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
809 | {} | |
810 | }; | |
811 | ||
e1f0d669 MR |
812 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { |
813 | /* set master volume and direct control */ | |
814 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | |
e1f0d669 MR |
815 | /* setup adcs to point to mixer */ |
816 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | |
817 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | |
e1f0d669 MR |
818 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
819 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
820 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
821 | /* setup import muxs */ | |
822 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
823 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
824 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
825 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
826 | {} | |
827 | }; | |
828 | ||
829 | static struct hda_verb stac92hd73xx_10ch_core_init[] = { | |
830 | /* set master volume and direct control */ | |
831 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | |
e1f0d669 MR |
832 | /* dac3 is connected to import3 mux */ |
833 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, | |
e1f0d669 MR |
834 | /* setup adcs to point to mixer */ |
835 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | |
836 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | |
e1f0d669 MR |
837 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
838 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
839 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | |
840 | /* setup import muxs */ | |
841 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
842 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
843 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
844 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, | |
845 | {} | |
846 | }; | |
847 | ||
d0513fc6 | 848 | static struct hda_verb stac92hd83xxx_core_init[] = { |
d0513fc6 MR |
849 | { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0}, |
850 | { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0}, | |
851 | { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1}, | |
852 | ||
853 | /* power state controls amps */ | |
854 | { 0x01, AC_VERB_SET_EAPD, 1 << 2}, | |
574f3c4f | 855 | {} |
d0513fc6 MR |
856 | }; |
857 | ||
e035b841 | 858 | static struct hda_verb stac92hd71bxx_core_init[] = { |
541eee87 MR |
859 | /* set master volume and direct control */ |
860 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | |
574f3c4f | 861 | {} |
541eee87 MR |
862 | }; |
863 | ||
ca8d33fc | 864 | #define HD_DISABLE_PORTF 1 |
541eee87 | 865 | static struct hda_verb stac92hd71bxx_analog_core_init[] = { |
aafc4412 MR |
866 | /* start of config #1 */ |
867 | ||
868 | /* connect port 0f to audio mixer */ | |
869 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2}, | |
aafc4412 MR |
870 | /* start of config #2 */ |
871 | ||
e035b841 MR |
872 | /* set master volume and direct control */ |
873 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | |
ca8d33fc MR |
874 | {} |
875 | }; | |
876 | ||
877 | static struct hda_verb stac92hd71bxx_unmute_core_init[] = { | |
878 | /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ | |
879 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
e035b841 MR |
880 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
881 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | |
e035b841 MR |
882 | {} |
883 | }; | |
884 | ||
8e21c34c TD |
885 | static struct hda_verb stac925x_core_init[] = { |
886 | /* set dac0mux for dac converter */ | |
887 | { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, | |
c9280d68 TI |
888 | /* mute the master volume */ |
889 | { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | |
8e21c34c TD |
890 | {} |
891 | }; | |
892 | ||
c7d4b2fa | 893 | static struct hda_verb stac922x_core_init[] = { |
2f2f4251 | 894 | /* set master volume and direct control */ |
c7d4b2fa | 895 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
2f2f4251 M |
896 | {} |
897 | }; | |
898 | ||
93ed1503 | 899 | static struct hda_verb d965_core_init[] = { |
19039bd0 | 900 | /* set master volume and direct control */ |
93ed1503 | 901 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
19039bd0 TI |
902 | /* unmute node 0x1b */ |
903 | { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | |
904 | /* select node 0x03 as DAC */ | |
905 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, | |
906 | {} | |
907 | }; | |
908 | ||
3cc08dc6 MP |
909 | static struct hda_verb stac927x_core_init[] = { |
910 | /* set master volume and direct control */ | |
911 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | |
1cd2224c MR |
912 | /* enable analog pc beep path */ |
913 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, | |
3cc08dc6 MP |
914 | {} |
915 | }; | |
916 | ||
f3302a59 MP |
917 | static struct hda_verb stac9205_core_init[] = { |
918 | /* set master volume and direct control */ | |
919 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | |
d0513fc6 MR |
920 | /* enable analog pc beep path */ |
921 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, | |
f3302a59 MP |
922 | {} |
923 | }; | |
924 | ||
b22b4821 MR |
925 | #define STAC_MONO_MUX \ |
926 | { \ | |
927 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
928 | .name = "Mono Mux", \ | |
929 | .count = 1, \ | |
930 | .info = stac92xx_mono_mux_enum_info, \ | |
931 | .get = stac92xx_mono_mux_enum_get, \ | |
932 | .put = stac92xx_mono_mux_enum_put, \ | |
933 | } | |
934 | ||
89385035 MR |
935 | #define STAC_AMP_MUX \ |
936 | { \ | |
937 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
938 | .name = "Amp Selector Capture Switch", \ | |
939 | .count = 1, \ | |
940 | .info = stac92xx_amp_mux_enum_info, \ | |
941 | .get = stac92xx_amp_mux_enum_get, \ | |
942 | .put = stac92xx_amp_mux_enum_put, \ | |
943 | } | |
944 | ||
945 | #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \ | |
946 | { \ | |
947 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
948 | .name = xname, \ | |
949 | .index = 0, \ | |
950 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ | |
951 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | |
952 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ | |
953 | .info = stac92xx_amp_volume_info, \ | |
954 | .get = stac92xx_amp_volume_get, \ | |
955 | .put = stac92xx_amp_volume_put, \ | |
956 | .tlv = { .c = snd_hda_mixer_amp_tlv }, \ | |
957 | .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \ | |
958 | } | |
959 | ||
e1f0d669 | 960 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ |
5f10c4a9 ML |
961 | { \ |
962 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
963 | .name = "Analog Loopback", \ | |
e1f0d669 | 964 | .count = cnt, \ |
5f10c4a9 ML |
965 | .info = stac92xx_aloopback_info, \ |
966 | .get = stac92xx_aloopback_get, \ | |
967 | .put = stac92xx_aloopback_put, \ | |
968 | .private_value = verb_read | (verb_write << 16), \ | |
969 | } | |
970 | ||
c8b6bf9b | 971 | static struct snd_kcontrol_new stac9200_mixer[] = { |
2f2f4251 M |
972 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), |
973 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), | |
2f2f4251 M |
974 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
975 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), | |
2f2f4251 M |
976 | { } /* end */ |
977 | }; | |
978 | ||
2a9c7816 | 979 | #define DELL_M6_MIXER 6 |
e1f0d669 | 980 | static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = { |
2a9c7816 | 981 | /* start of config #1 */ |
e1f0d669 MR |
982 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
983 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), | |
984 | ||
e1f0d669 MR |
985 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
986 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), | |
987 | ||
2a9c7816 MR |
988 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
989 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), | |
990 | ||
991 | /* start of config #2 */ | |
992 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), | |
993 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), | |
994 | ||
e1f0d669 MR |
995 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
996 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), | |
997 | ||
2a9c7816 MR |
998 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), |
999 | ||
1000 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), | |
1001 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), | |
1002 | ||
1003 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), | |
1004 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), | |
1005 | ||
e1f0d669 MR |
1006 | { } /* end */ |
1007 | }; | |
1008 | ||
1009 | static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = { | |
e1f0d669 MR |
1010 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), |
1011 | ||
e1f0d669 MR |
1012 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
1013 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), | |
1014 | ||
1015 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), | |
1016 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), | |
1017 | ||
1018 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), | |
1019 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), | |
1020 | ||
1021 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), | |
1022 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), | |
1023 | ||
1024 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), | |
1025 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), | |
1026 | ||
1027 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), | |
1028 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), | |
1029 | ||
1030 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), | |
1031 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), | |
1032 | { } /* end */ | |
1033 | }; | |
1034 | ||
1035 | static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = { | |
e1f0d669 MR |
1036 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5), |
1037 | ||
e1f0d669 MR |
1038 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
1039 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), | |
1040 | ||
1041 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), | |
1042 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), | |
1043 | ||
1044 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), | |
1045 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), | |
1046 | ||
1047 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), | |
1048 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), | |
1049 | ||
1050 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), | |
1051 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), | |
1052 | ||
1053 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), | |
1054 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), | |
1055 | ||
1056 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), | |
1057 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), | |
1058 | { } /* end */ | |
1059 | }; | |
1060 | ||
d0513fc6 MR |
1061 | |
1062 | static struct snd_kcontrol_new stac92hd83xxx_mixer[] = { | |
1063 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT), | |
1064 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT), | |
1065 | ||
1066 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT), | |
1067 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT), | |
1068 | ||
74b7ff48 MR |
1069 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT), |
1070 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT), | |
d0513fc6 | 1071 | |
74b7ff48 MR |
1072 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT), |
1073 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT), | |
d0513fc6 | 1074 | |
74b7ff48 MR |
1075 | HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT), |
1076 | HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT), | |
d0513fc6 | 1077 | |
74b7ff48 MR |
1078 | HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT), |
1079 | HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT), | |
d0513fc6 MR |
1080 | |
1081 | /* | |
74b7ff48 MR |
1082 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT), |
1083 | HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT), | |
d0513fc6 MR |
1084 | */ |
1085 | { } /* end */ | |
1086 | }; | |
1087 | ||
541eee87 | 1088 | static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { |
4b33c767 | 1089 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2), |
e035b841 | 1090 | |
9b35947f MR |
1091 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
1092 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), | |
9b35947f MR |
1093 | |
1094 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), | |
1095 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), | |
1cd2224c MR |
1096 | /* analog pc-beep replaced with digital beep support */ |
1097 | /* | |
f7c5dda2 MR |
1098 | HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT), |
1099 | HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT), | |
1cd2224c | 1100 | */ |
f7c5dda2 | 1101 | |
687cb98e MR |
1102 | HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT), |
1103 | HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT), | |
4b33c767 | 1104 | |
687cb98e MR |
1105 | HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT), |
1106 | HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT), | |
4b33c767 MR |
1107 | |
1108 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT), | |
1109 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT), | |
1110 | ||
1111 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT), | |
1112 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT), | |
e035b841 MR |
1113 | { } /* end */ |
1114 | }; | |
1115 | ||
541eee87 | 1116 | static struct snd_kcontrol_new stac92hd71bxx_mixer[] = { |
541eee87 MR |
1117 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2), |
1118 | ||
541eee87 MR |
1119 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
1120 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), | |
541eee87 MR |
1121 | |
1122 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), | |
1123 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), | |
541eee87 MR |
1124 | { } /* end */ |
1125 | }; | |
1126 | ||
8e21c34c | 1127 | static struct snd_kcontrol_new stac925x_mixer[] = { |
c9280d68 TI |
1128 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), |
1129 | HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), | |
8e21c34c | 1130 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT), |
587755f1 | 1131 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT), |
8e21c34c TD |
1132 | { } /* end */ |
1133 | }; | |
1134 | ||
9e05b7a3 | 1135 | static struct snd_kcontrol_new stac9205_mixer[] = { |
e1f0d669 | 1136 | STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1), |
9e05b7a3 ML |
1137 | |
1138 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT), | |
1139 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT), | |
9e05b7a3 ML |
1140 | |
1141 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT), | |
1142 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT), | |
2f2f4251 M |
1143 | { } /* end */ |
1144 | }; | |
1145 | ||
19039bd0 | 1146 | /* This needs to be generated dynamically based on sequence */ |
9e05b7a3 | 1147 | static struct snd_kcontrol_new stac922x_mixer[] = { |
9e05b7a3 ML |
1148 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT), |
1149 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT), | |
9e05b7a3 ML |
1150 | |
1151 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT), | |
1152 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT), | |
19039bd0 TI |
1153 | { } /* end */ |
1154 | }; | |
1155 | ||
9e05b7a3 | 1156 | |
d1d985f0 | 1157 | static struct snd_kcontrol_new stac927x_mixer[] = { |
e1f0d669 | 1158 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), |
3cc08dc6 | 1159 | |
9e05b7a3 ML |
1160 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT), |
1161 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT), | |
9e05b7a3 ML |
1162 | |
1163 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT), | |
1164 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT), | |
9e05b7a3 ML |
1165 | |
1166 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT), | |
1167 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT), | |
f3302a59 MP |
1168 | { } /* end */ |
1169 | }; | |
1170 | ||
1697055e TI |
1171 | static struct snd_kcontrol_new stac_dmux_mixer = { |
1172 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
1173 | .name = "Digital Input Source", | |
1174 | /* count set later */ | |
1175 | .info = stac92xx_dmux_enum_info, | |
1176 | .get = stac92xx_dmux_enum_get, | |
1177 | .put = stac92xx_dmux_enum_put, | |
1178 | }; | |
1179 | ||
d9737751 MR |
1180 | static struct snd_kcontrol_new stac_smux_mixer = { |
1181 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
e3487970 | 1182 | .name = "IEC958 Playback Source", |
d9737751 MR |
1183 | /* count set later */ |
1184 | .info = stac92xx_smux_enum_info, | |
1185 | .get = stac92xx_smux_enum_get, | |
1186 | .put = stac92xx_smux_enum_put, | |
1187 | }; | |
1188 | ||
2134ea4f TI |
1189 | static const char *slave_vols[] = { |
1190 | "Front Playback Volume", | |
1191 | "Surround Playback Volume", | |
1192 | "Center Playback Volume", | |
1193 | "LFE Playback Volume", | |
1194 | "Side Playback Volume", | |
1195 | "Headphone Playback Volume", | |
1196 | "Headphone Playback Volume", | |
1197 | "Speaker Playback Volume", | |
1198 | "External Speaker Playback Volume", | |
1199 | "Speaker2 Playback Volume", | |
1200 | NULL | |
1201 | }; | |
1202 | ||
1203 | static const char *slave_sws[] = { | |
1204 | "Front Playback Switch", | |
1205 | "Surround Playback Switch", | |
1206 | "Center Playback Switch", | |
1207 | "LFE Playback Switch", | |
1208 | "Side Playback Switch", | |
1209 | "Headphone Playback Switch", | |
1210 | "Headphone Playback Switch", | |
1211 | "Speaker Playback Switch", | |
1212 | "External Speaker Playback Switch", | |
1213 | "Speaker2 Playback Switch", | |
edb54a55 | 1214 | "IEC958 Playback Switch", |
2134ea4f TI |
1215 | NULL |
1216 | }; | |
1217 | ||
603c4019 | 1218 | static void stac92xx_free_kctls(struct hda_codec *codec); |
e4973e1e | 1219 | static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type); |
603c4019 | 1220 | |
2f2f4251 M |
1221 | static int stac92xx_build_controls(struct hda_codec *codec) |
1222 | { | |
1223 | struct sigmatel_spec *spec = codec->spec; | |
e4973e1e TI |
1224 | struct auto_pin_cfg *cfg = &spec->autocfg; |
1225 | hda_nid_t nid; | |
2f2f4251 | 1226 | int err; |
c7d4b2fa | 1227 | int i; |
2f2f4251 M |
1228 | |
1229 | err = snd_hda_add_new_ctls(codec, spec->mixer); | |
1230 | if (err < 0) | |
1231 | return err; | |
c7d4b2fa M |
1232 | |
1233 | for (i = 0; i < spec->num_mixers; i++) { | |
1234 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | |
1235 | if (err < 0) | |
1236 | return err; | |
1237 | } | |
1697055e TI |
1238 | if (spec->num_dmuxes > 0) { |
1239 | stac_dmux_mixer.count = spec->num_dmuxes; | |
d13bd412 | 1240 | err = snd_hda_ctl_add(codec, |
1697055e TI |
1241 | snd_ctl_new1(&stac_dmux_mixer, codec)); |
1242 | if (err < 0) | |
1243 | return err; | |
1244 | } | |
d9737751 | 1245 | if (spec->num_smuxes > 0) { |
00ef50c2 MR |
1246 | int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid); |
1247 | struct hda_input_mux *smux = &spec->private_smux; | |
1248 | /* check for mute support on SPDIF out */ | |
1249 | if (wcaps & AC_WCAP_OUT_AMP) { | |
1250 | smux->items[smux->num_items].label = "Off"; | |
1251 | smux->items[smux->num_items].index = 0; | |
1252 | smux->num_items++; | |
1253 | spec->spdif_mute = 1; | |
1254 | } | |
d9737751 | 1255 | stac_smux_mixer.count = spec->num_smuxes; |
4f2d23e1 | 1256 | err = snd_hda_ctl_add(codec, |
d9737751 MR |
1257 | snd_ctl_new1(&stac_smux_mixer, codec)); |
1258 | if (err < 0) | |
1259 | return err; | |
1260 | } | |
c7d4b2fa | 1261 | |
dabbed6f M |
1262 | if (spec->multiout.dig_out_nid) { |
1263 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); | |
1264 | if (err < 0) | |
1265 | return err; | |
9a08160b TI |
1266 | err = snd_hda_create_spdif_share_sw(codec, |
1267 | &spec->multiout); | |
1268 | if (err < 0) | |
1269 | return err; | |
1270 | spec->multiout.share_spdif = 1; | |
dabbed6f | 1271 | } |
da74ae3e | 1272 | if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) { |
dabbed6f M |
1273 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
1274 | if (err < 0) | |
1275 | return err; | |
1276 | } | |
2134ea4f TI |
1277 | |
1278 | /* if we have no master control, let's create it */ | |
1279 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { | |
1c82ed1b | 1280 | unsigned int vmaster_tlv[4]; |
2134ea4f | 1281 | snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], |
1c82ed1b | 1282 | HDA_OUTPUT, vmaster_tlv); |
7c7767eb TI |
1283 | /* correct volume offset */ |
1284 | vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset; | |
2134ea4f | 1285 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
1c82ed1b | 1286 | vmaster_tlv, slave_vols); |
2134ea4f TI |
1287 | if (err < 0) |
1288 | return err; | |
1289 | } | |
1290 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { | |
1291 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", | |
1292 | NULL, slave_sws); | |
1293 | if (err < 0) | |
1294 | return err; | |
1295 | } | |
1296 | ||
603c4019 | 1297 | stac92xx_free_kctls(codec); /* no longer needed */ |
e4973e1e TI |
1298 | |
1299 | /* create jack input elements */ | |
1300 | if (spec->hp_detect) { | |
1301 | for (i = 0; i < cfg->hp_outs; i++) { | |
1302 | int type = SND_JACK_HEADPHONE; | |
1303 | nid = cfg->hp_pins[i]; | |
1304 | /* jack detection */ | |
1305 | if (cfg->hp_outs == i) | |
1306 | type |= SND_JACK_LINEOUT; | |
1307 | err = stac92xx_add_jack(codec, nid, type); | |
1308 | if (err < 0) | |
1309 | return err; | |
1310 | } | |
1311 | } | |
1312 | for (i = 0; i < cfg->line_outs; i++) { | |
1313 | err = stac92xx_add_jack(codec, cfg->line_out_pins[i], | |
1314 | SND_JACK_LINEOUT); | |
1315 | if (err < 0) | |
1316 | return err; | |
1317 | } | |
1318 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
1319 | nid = cfg->input_pins[i]; | |
1320 | if (nid) { | |
1321 | err = stac92xx_add_jack(codec, nid, | |
1322 | SND_JACK_MICROPHONE); | |
1323 | if (err < 0) | |
1324 | return err; | |
1325 | } | |
1326 | } | |
1327 | ||
dabbed6f | 1328 | return 0; |
2f2f4251 M |
1329 | } |
1330 | ||
403d1944 | 1331 | static unsigned int ref9200_pin_configs[8] = { |
dabbed6f | 1332 | 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, |
2f2f4251 M |
1333 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
1334 | }; | |
1335 | ||
58eec423 MCC |
1336 | static unsigned int gateway9200_m4_pin_configs[8] = { |
1337 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, | |
1338 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, | |
1339 | }; | |
1340 | static unsigned int gateway9200_m4_2_pin_configs[8] = { | |
1341 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, | |
1342 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, | |
1343 | }; | |
1344 | ||
1345 | /* | |
dfe495d0 TI |
1346 | STAC 9200 pin configs for |
1347 | 102801A8 | |
1348 | 102801DE | |
1349 | 102801E8 | |
1350 | */ | |
1351 | static unsigned int dell9200_d21_pin_configs[8] = { | |
af6c016e TI |
1352 | 0x400001f0, 0x400001f1, 0x02214030, 0x01014010, |
1353 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, | |
dfe495d0 TI |
1354 | }; |
1355 | ||
1356 | /* | |
1357 | STAC 9200 pin configs for | |
1358 | 102801C0 | |
1359 | 102801C1 | |
1360 | */ | |
1361 | static unsigned int dell9200_d22_pin_configs[8] = { | |
af6c016e TI |
1362 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
1363 | 0x01813020, 0x02a19021, 0x90100140, 0x400001f2, | |
dfe495d0 TI |
1364 | }; |
1365 | ||
1366 | /* | |
1367 | STAC 9200 pin configs for | |
1368 | 102801C4 (Dell Dimension E310) | |
1369 | 102801C5 | |
1370 | 102801C7 | |
1371 | 102801D9 | |
1372 | 102801DA | |
1373 | 102801E3 | |
1374 | */ | |
1375 | static unsigned int dell9200_d23_pin_configs[8] = { | |
af6c016e TI |
1376 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
1377 | 0x01813020, 0x01a19021, 0x90100140, 0x400001f2, | |
dfe495d0 TI |
1378 | }; |
1379 | ||
1380 | ||
1381 | /* | |
1382 | STAC 9200-32 pin configs for | |
1383 | 102801B5 (Dell Inspiron 630m) | |
1384 | 102801D8 (Dell Inspiron 640m) | |
1385 | */ | |
1386 | static unsigned int dell9200_m21_pin_configs[8] = { | |
af6c016e TI |
1387 | 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310, |
1388 | 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd, | |
dfe495d0 TI |
1389 | }; |
1390 | ||
1391 | /* | |
1392 | STAC 9200-32 pin configs for | |
1393 | 102801C2 (Dell Latitude D620) | |
1394 | 102801C8 | |
1395 | 102801CC (Dell Latitude D820) | |
1396 | 102801D4 | |
1397 | 102801D6 | |
1398 | */ | |
1399 | static unsigned int dell9200_m22_pin_configs[8] = { | |
af6c016e TI |
1400 | 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310, |
1401 | 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc, | |
dfe495d0 TI |
1402 | }; |
1403 | ||
1404 | /* | |
1405 | STAC 9200-32 pin configs for | |
1406 | 102801CE (Dell XPS M1710) | |
1407 | 102801CF (Dell Precision M90) | |
1408 | */ | |
1409 | static unsigned int dell9200_m23_pin_configs[8] = { | |
1410 | 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310, | |
1411 | 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc, | |
1412 | }; | |
1413 | ||
1414 | /* | |
1415 | STAC 9200-32 pin configs for | |
1416 | 102801C9 | |
1417 | 102801CA | |
1418 | 102801CB (Dell Latitude 120L) | |
1419 | 102801D3 | |
1420 | */ | |
1421 | static unsigned int dell9200_m24_pin_configs[8] = { | |
af6c016e TI |
1422 | 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310, |
1423 | 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe, | |
dfe495d0 TI |
1424 | }; |
1425 | ||
1426 | /* | |
1427 | STAC 9200-32 pin configs for | |
1428 | 102801BD (Dell Inspiron E1505n) | |
1429 | 102801EE | |
1430 | 102801EF | |
1431 | */ | |
1432 | static unsigned int dell9200_m25_pin_configs[8] = { | |
af6c016e TI |
1433 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
1434 | 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd, | |
dfe495d0 TI |
1435 | }; |
1436 | ||
1437 | /* | |
1438 | STAC 9200-32 pin configs for | |
1439 | 102801F5 (Dell Inspiron 1501) | |
1440 | 102801F6 | |
1441 | */ | |
1442 | static unsigned int dell9200_m26_pin_configs[8] = { | |
af6c016e TI |
1443 | 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310, |
1444 | 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe, | |
dfe495d0 TI |
1445 | }; |
1446 | ||
1447 | /* | |
1448 | STAC 9200-32 | |
1449 | 102801CD (Dell Inspiron E1705/9400) | |
1450 | */ | |
1451 | static unsigned int dell9200_m27_pin_configs[8] = { | |
af6c016e TI |
1452 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
1453 | 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc, | |
dfe495d0 TI |
1454 | }; |
1455 | ||
bf277785 TD |
1456 | static unsigned int oqo9200_pin_configs[8] = { |
1457 | 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210, | |
1458 | 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3, | |
1459 | }; | |
1460 | ||
dfe495d0 | 1461 | |
f5fcc13c TI |
1462 | static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = { |
1463 | [STAC_REF] = ref9200_pin_configs, | |
bf277785 | 1464 | [STAC_9200_OQO] = oqo9200_pin_configs, |
dfe495d0 TI |
1465 | [STAC_9200_DELL_D21] = dell9200_d21_pin_configs, |
1466 | [STAC_9200_DELL_D22] = dell9200_d22_pin_configs, | |
1467 | [STAC_9200_DELL_D23] = dell9200_d23_pin_configs, | |
1468 | [STAC_9200_DELL_M21] = dell9200_m21_pin_configs, | |
1469 | [STAC_9200_DELL_M22] = dell9200_m22_pin_configs, | |
1470 | [STAC_9200_DELL_M23] = dell9200_m23_pin_configs, | |
1471 | [STAC_9200_DELL_M24] = dell9200_m24_pin_configs, | |
1472 | [STAC_9200_DELL_M25] = dell9200_m25_pin_configs, | |
1473 | [STAC_9200_DELL_M26] = dell9200_m26_pin_configs, | |
1474 | [STAC_9200_DELL_M27] = dell9200_m27_pin_configs, | |
58eec423 MCC |
1475 | [STAC_9200_M4] = gateway9200_m4_pin_configs, |
1476 | [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs, | |
117f257d | 1477 | [STAC_9200_PANASONIC] = ref9200_pin_configs, |
403d1944 MP |
1478 | }; |
1479 | ||
f5fcc13c TI |
1480 | static const char *stac9200_models[STAC_9200_MODELS] = { |
1481 | [STAC_REF] = "ref", | |
bf277785 | 1482 | [STAC_9200_OQO] = "oqo", |
dfe495d0 TI |
1483 | [STAC_9200_DELL_D21] = "dell-d21", |
1484 | [STAC_9200_DELL_D22] = "dell-d22", | |
1485 | [STAC_9200_DELL_D23] = "dell-d23", | |
1486 | [STAC_9200_DELL_M21] = "dell-m21", | |
1487 | [STAC_9200_DELL_M22] = "dell-m22", | |
1488 | [STAC_9200_DELL_M23] = "dell-m23", | |
1489 | [STAC_9200_DELL_M24] = "dell-m24", | |
1490 | [STAC_9200_DELL_M25] = "dell-m25", | |
1491 | [STAC_9200_DELL_M26] = "dell-m26", | |
1492 | [STAC_9200_DELL_M27] = "dell-m27", | |
58eec423 MCC |
1493 | [STAC_9200_M4] = "gateway-m4", |
1494 | [STAC_9200_M4_2] = "gateway-m4-2", | |
117f257d | 1495 | [STAC_9200_PANASONIC] = "panasonic", |
f5fcc13c TI |
1496 | }; |
1497 | ||
1498 | static struct snd_pci_quirk stac9200_cfg_tbl[] = { | |
1499 | /* SigmaTel reference board */ | |
1500 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | |
1501 | "DFI LanParty", STAC_REF), | |
577aa2c1 MR |
1502 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
1503 | "DFI LanParty", STAC_REF), | |
e7377071 | 1504 | /* Dell laptops have BIOS problem */ |
dfe495d0 TI |
1505 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8, |
1506 | "unknown Dell", STAC_9200_DELL_D21), | |
f5fcc13c | 1507 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5, |
dfe495d0 TI |
1508 | "Dell Inspiron 630m", STAC_9200_DELL_M21), |
1509 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd, | |
1510 | "Dell Inspiron E1505n", STAC_9200_DELL_M25), | |
1511 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0, | |
1512 | "unknown Dell", STAC_9200_DELL_D22), | |
1513 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1, | |
1514 | "unknown Dell", STAC_9200_DELL_D22), | |
f5fcc13c | 1515 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2, |
dfe495d0 TI |
1516 | "Dell Latitude D620", STAC_9200_DELL_M22), |
1517 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5, | |
1518 | "unknown Dell", STAC_9200_DELL_D23), | |
1519 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7, | |
1520 | "unknown Dell", STAC_9200_DELL_D23), | |
1521 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8, | |
1522 | "unknown Dell", STAC_9200_DELL_M22), | |
1523 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9, | |
1524 | "unknown Dell", STAC_9200_DELL_M24), | |
1525 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca, | |
1526 | "unknown Dell", STAC_9200_DELL_M24), | |
f5fcc13c | 1527 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb, |
dfe495d0 | 1528 | "Dell Latitude 120L", STAC_9200_DELL_M24), |
877b866d | 1529 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc, |
dfe495d0 | 1530 | "Dell Latitude D820", STAC_9200_DELL_M22), |
46f02ca3 | 1531 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd, |
dfe495d0 | 1532 | "Dell Inspiron E1705/9400", STAC_9200_DELL_M27), |
46f02ca3 | 1533 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce, |
dfe495d0 | 1534 | "Dell XPS M1710", STAC_9200_DELL_M23), |
f0f96745 | 1535 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, |
dfe495d0 TI |
1536 | "Dell Precision M90", STAC_9200_DELL_M23), |
1537 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3, | |
1538 | "unknown Dell", STAC_9200_DELL_M22), | |
1539 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4, | |
1540 | "unknown Dell", STAC_9200_DELL_M22), | |
8286c53e | 1541 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6, |
dfe495d0 | 1542 | "unknown Dell", STAC_9200_DELL_M22), |
49c605db | 1543 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8, |
dfe495d0 TI |
1544 | "Dell Inspiron 640m", STAC_9200_DELL_M21), |
1545 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9, | |
1546 | "unknown Dell", STAC_9200_DELL_D23), | |
1547 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da, | |
1548 | "unknown Dell", STAC_9200_DELL_D23), | |
1549 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de, | |
1550 | "unknown Dell", STAC_9200_DELL_D21), | |
1551 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3, | |
1552 | "unknown Dell", STAC_9200_DELL_D23), | |
1553 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8, | |
1554 | "unknown Dell", STAC_9200_DELL_D21), | |
1555 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee, | |
1556 | "unknown Dell", STAC_9200_DELL_M25), | |
1557 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef, | |
1558 | "unknown Dell", STAC_9200_DELL_M25), | |
49c605db | 1559 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5, |
dfe495d0 TI |
1560 | "Dell Inspiron 1501", STAC_9200_DELL_M26), |
1561 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6, | |
1562 | "unknown Dell", STAC_9200_DELL_M26), | |
49c605db | 1563 | /* Panasonic */ |
117f257d | 1564 | SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC), |
1194b5b7 | 1565 | /* Gateway machines needs EAPD to be set on resume */ |
58eec423 MCC |
1566 | SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4), |
1567 | SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2), | |
1568 | SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2), | |
bf277785 TD |
1569 | /* OQO Mobile */ |
1570 | SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO), | |
403d1944 MP |
1571 | {} /* terminator */ |
1572 | }; | |
1573 | ||
8e21c34c TD |
1574 | static unsigned int ref925x_pin_configs[8] = { |
1575 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, | |
09a99959 | 1576 | 0x90a70320, 0x02214210, 0x01019020, 0x9033032e, |
8e21c34c TD |
1577 | }; |
1578 | ||
9cb36c2a MCC |
1579 | static unsigned int stac925xM1_pin_configs[8] = { |
1580 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, | |
1581 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, | |
8e21c34c TD |
1582 | }; |
1583 | ||
9cb36c2a MCC |
1584 | static unsigned int stac925xM1_2_pin_configs[8] = { |
1585 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, | |
1586 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, | |
1587 | }; | |
58eec423 | 1588 | |
9cb36c2a MCC |
1589 | static unsigned int stac925xM2_pin_configs[8] = { |
1590 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, | |
1591 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, | |
2c11f955 TD |
1592 | }; |
1593 | ||
8e21c34c | 1594 | static unsigned int stac925xM2_2_pin_configs[8] = { |
58eec423 MCC |
1595 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
1596 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, | |
1597 | }; | |
1598 | ||
9cb36c2a MCC |
1599 | static unsigned int stac925xM3_pin_configs[8] = { |
1600 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, | |
1601 | 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3, | |
1602 | }; | |
58eec423 | 1603 | |
9cb36c2a MCC |
1604 | static unsigned int stac925xM5_pin_configs[8] = { |
1605 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, | |
1606 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, | |
1607 | }; | |
1608 | ||
9cb36c2a MCC |
1609 | static unsigned int stac925xM6_pin_configs[8] = { |
1610 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, | |
1611 | 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320, | |
8e21c34c TD |
1612 | }; |
1613 | ||
1614 | static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = { | |
1615 | [STAC_REF] = ref925x_pin_configs, | |
9cb36c2a MCC |
1616 | [STAC_M1] = stac925xM1_pin_configs, |
1617 | [STAC_M1_2] = stac925xM1_2_pin_configs, | |
1618 | [STAC_M2] = stac925xM2_pin_configs, | |
8e21c34c | 1619 | [STAC_M2_2] = stac925xM2_2_pin_configs, |
9cb36c2a MCC |
1620 | [STAC_M3] = stac925xM3_pin_configs, |
1621 | [STAC_M5] = stac925xM5_pin_configs, | |
1622 | [STAC_M6] = stac925xM6_pin_configs, | |
8e21c34c TD |
1623 | }; |
1624 | ||
1625 | static const char *stac925x_models[STAC_925x_MODELS] = { | |
1626 | [STAC_REF] = "ref", | |
9cb36c2a MCC |
1627 | [STAC_M1] = "m1", |
1628 | [STAC_M1_2] = "m1-2", | |
1629 | [STAC_M2] = "m2", | |
8e21c34c | 1630 | [STAC_M2_2] = "m2-2", |
9cb36c2a MCC |
1631 | [STAC_M3] = "m3", |
1632 | [STAC_M5] = "m5", | |
1633 | [STAC_M6] = "m6", | |
8e21c34c TD |
1634 | }; |
1635 | ||
9cb36c2a | 1636 | static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = { |
58eec423 MCC |
1637 | SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2), |
1638 | SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5), | |
1639 | SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1), | |
1640 | SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2), | |
9cb36c2a | 1641 | SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2), |
9cb36c2a MCC |
1642 | /* Not sure about the brand name for those */ |
1643 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1), | |
1644 | SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3), | |
1645 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6), | |
1646 | SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2), | |
9cb36c2a | 1647 | {} /* terminator */ |
8e21c34c TD |
1648 | }; |
1649 | ||
1650 | static struct snd_pci_quirk stac925x_cfg_tbl[] = { | |
1651 | /* SigmaTel reference board */ | |
1652 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), | |
577aa2c1 | 1653 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF), |
2c11f955 | 1654 | SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), |
9cb36c2a MCC |
1655 | |
1656 | /* Default table for unknown ID */ | |
1657 | SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2), | |
1658 | ||
8e21c34c TD |
1659 | {} /* terminator */ |
1660 | }; | |
1661 | ||
a7662640 | 1662 | static unsigned int ref92hd73xx_pin_configs[13] = { |
e1f0d669 MR |
1663 | 0x02214030, 0x02a19040, 0x01a19020, 0x02214030, |
1664 | 0x0181302e, 0x01014010, 0x01014020, 0x01014030, | |
1665 | 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050, | |
a7662640 MR |
1666 | 0x01452050, |
1667 | }; | |
1668 | ||
1669 | static unsigned int dell_m6_pin_configs[13] = { | |
1670 | 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110, | |
7c2ba97b | 1671 | 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0, |
a7662640 MR |
1672 | 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0, |
1673 | 0x4f0000f0, | |
e1f0d669 MR |
1674 | }; |
1675 | ||
1676 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { | |
a7662640 | 1677 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, |
661cd8fb TI |
1678 | [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, |
1679 | [STAC_DELL_M6_DMIC] = dell_m6_pin_configs, | |
1680 | [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, | |
6b3ab21e | 1681 | [STAC_DELL_EQ] = dell_m6_pin_configs, |
e1f0d669 MR |
1682 | }; |
1683 | ||
1684 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { | |
9e43f0de | 1685 | [STAC_92HD73XX_NO_JD] = "no-jd", |
e1f0d669 | 1686 | [STAC_92HD73XX_REF] = "ref", |
661cd8fb TI |
1687 | [STAC_DELL_M6_AMIC] = "dell-m6-amic", |
1688 | [STAC_DELL_M6_DMIC] = "dell-m6-dmic", | |
1689 | [STAC_DELL_M6_BOTH] = "dell-m6", | |
6b3ab21e | 1690 | [STAC_DELL_EQ] = "dell-eq", |
e1f0d669 MR |
1691 | }; |
1692 | ||
1693 | static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { | |
1694 | /* SigmaTel reference board */ | |
1695 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | |
a7662640 | 1696 | "DFI LanParty", STAC_92HD73XX_REF), |
577aa2c1 MR |
1697 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
1698 | "DFI LanParty", STAC_92HD73XX_REF), | |
a7662640 | 1699 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, |
661cd8fb | 1700 | "Dell Studio 1535", STAC_DELL_M6_DMIC), |
a7662640 | 1701 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, |
661cd8fb | 1702 | "unknown Dell", STAC_DELL_M6_DMIC), |
a7662640 | 1703 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256, |
661cd8fb | 1704 | "unknown Dell", STAC_DELL_M6_BOTH), |
a7662640 | 1705 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257, |
661cd8fb | 1706 | "unknown Dell", STAC_DELL_M6_BOTH), |
a7662640 | 1707 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e, |
661cd8fb | 1708 | "unknown Dell", STAC_DELL_M6_AMIC), |
a7662640 | 1709 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f, |
661cd8fb | 1710 | "unknown Dell", STAC_DELL_M6_AMIC), |
a7662640 | 1711 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271, |
661cd8fb TI |
1712 | "unknown Dell", STAC_DELL_M6_DMIC), |
1713 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272, | |
1714 | "unknown Dell", STAC_DELL_M6_DMIC), | |
b0fc5e04 | 1715 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f, |
661cd8fb | 1716 | "Dell Studio 1537", STAC_DELL_M6_DMIC), |
fa620e97 JS |
1717 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0, |
1718 | "Dell Studio 17", STAC_DELL_M6_DMIC), | |
e1f0d669 MR |
1719 | {} /* terminator */ |
1720 | }; | |
1721 | ||
d0513fc6 MR |
1722 | static unsigned int ref92hd83xxx_pin_configs[14] = { |
1723 | 0x02214030, 0x02211010, 0x02a19020, 0x02170130, | |
1724 | 0x01014050, 0x01819040, 0x01014020, 0x90a3014e, | |
1725 | 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0, | |
1726 | 0x01451160, 0x98560170, | |
1727 | }; | |
1728 | ||
1729 | static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = { | |
1730 | [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, | |
32ed3f46 | 1731 | [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs, |
d0513fc6 MR |
1732 | }; |
1733 | ||
1734 | static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { | |
1735 | [STAC_92HD83XXX_REF] = "ref", | |
32ed3f46 | 1736 | [STAC_92HD83XXX_PWR_REF] = "mic-ref", |
d0513fc6 MR |
1737 | }; |
1738 | ||
1739 | static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { | |
1740 | /* SigmaTel reference board */ | |
1741 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | |
f9d088b2 | 1742 | "DFI LanParty", STAC_92HD83XXX_REF), |
577aa2c1 MR |
1743 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
1744 | "DFI LanParty", STAC_92HD83XXX_REF), | |
574f3c4f | 1745 | {} /* terminator */ |
d0513fc6 MR |
1746 | }; |
1747 | ||
0ffa9807 | 1748 | static unsigned int ref92hd71bxx_pin_configs[11] = { |
e035b841 | 1749 | 0x02214030, 0x02a19040, 0x01a19020, 0x01014010, |
4b33c767 | 1750 | 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0, |
0ffa9807 | 1751 | 0x90a000f0, 0x01452050, 0x01452050, |
e035b841 MR |
1752 | }; |
1753 | ||
0ffa9807 | 1754 | static unsigned int dell_m4_1_pin_configs[11] = { |
a7662640 | 1755 | 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110, |
07bcb316 | 1756 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0, |
0ffa9807 | 1757 | 0x40f000f0, 0x4f0000f0, 0x4f0000f0, |
a7662640 MR |
1758 | }; |
1759 | ||
0ffa9807 | 1760 | static unsigned int dell_m4_2_pin_configs[11] = { |
a7662640 MR |
1761 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
1762 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0, | |
0ffa9807 | 1763 | 0x40f000f0, 0x044413b0, 0x044413b0, |
a7662640 MR |
1764 | }; |
1765 | ||
3a7abfd2 MR |
1766 | static unsigned int dell_m4_3_pin_configs[11] = { |
1767 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, | |
1768 | 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0, | |
1769 | 0x40f000f0, 0x044413b0, 0x044413b0, | |
1770 | }; | |
1771 | ||
e035b841 MR |
1772 | static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { |
1773 | [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs, | |
a7662640 MR |
1774 | [STAC_DELL_M4_1] = dell_m4_1_pin_configs, |
1775 | [STAC_DELL_M4_2] = dell_m4_2_pin_configs, | |
3a7abfd2 | 1776 | [STAC_DELL_M4_3] = dell_m4_3_pin_configs, |
6a14f585 | 1777 | [STAC_HP_M4] = NULL, |
1b0652eb | 1778 | [STAC_HP_DV5] = NULL, |
e035b841 MR |
1779 | }; |
1780 | ||
1781 | static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { | |
1782 | [STAC_92HD71BXX_REF] = "ref", | |
a7662640 MR |
1783 | [STAC_DELL_M4_1] = "dell-m4-1", |
1784 | [STAC_DELL_M4_2] = "dell-m4-2", | |
3a7abfd2 | 1785 | [STAC_DELL_M4_3] = "dell-m4-3", |
6a14f585 | 1786 | [STAC_HP_M4] = "hp-m4", |
1b0652eb | 1787 | [STAC_HP_DV5] = "hp-dv5", |
e035b841 MR |
1788 | }; |
1789 | ||
1790 | static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { | |
1791 | /* SigmaTel reference board */ | |
1792 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | |
1793 | "DFI LanParty", STAC_92HD71BXX_REF), | |
577aa2c1 MR |
1794 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
1795 | "DFI LanParty", STAC_92HD71BXX_REF), | |
80bf2724 TI |
1796 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2, |
1797 | "HP dv5", STAC_HP_M4), | |
1798 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4, | |
1799 | "HP dv7", STAC_HP_M4), | |
e0c0e943 TI |
1800 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f7, |
1801 | "HP dv4", STAC_HP_DV5), | |
69dfaefe TI |
1802 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fc, |
1803 | "HP dv7", STAC_HP_M4), | |
42de55cb TI |
1804 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3600, |
1805 | "HP dv5", STAC_HP_DV5), | |
dafb70ce | 1806 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3603, |
1b0652eb | 1807 | "HP dv5", STAC_HP_DV5), |
9a9e2359 MR |
1808 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, |
1809 | "unknown HP", STAC_HP_M4), | |
a7662640 MR |
1810 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, |
1811 | "unknown Dell", STAC_DELL_M4_1), | |
1812 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, | |
1813 | "unknown Dell", STAC_DELL_M4_1), | |
1814 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250, | |
1815 | "unknown Dell", STAC_DELL_M4_1), | |
1816 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f, | |
1817 | "unknown Dell", STAC_DELL_M4_1), | |
1818 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d, | |
1819 | "unknown Dell", STAC_DELL_M4_1), | |
1820 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251, | |
1821 | "unknown Dell", STAC_DELL_M4_1), | |
1822 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277, | |
1823 | "unknown Dell", STAC_DELL_M4_1), | |
1824 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263, | |
1825 | "unknown Dell", STAC_DELL_M4_2), | |
1826 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265, | |
1827 | "unknown Dell", STAC_DELL_M4_2), | |
1828 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262, | |
1829 | "unknown Dell", STAC_DELL_M4_2), | |
1830 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264, | |
1831 | "unknown Dell", STAC_DELL_M4_2), | |
3a7abfd2 MR |
1832 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa, |
1833 | "unknown Dell", STAC_DELL_M4_3), | |
e035b841 MR |
1834 | {} /* terminator */ |
1835 | }; | |
1836 | ||
403d1944 MP |
1837 | static unsigned int ref922x_pin_configs[10] = { |
1838 | 0x01014010, 0x01016011, 0x01012012, 0x0221401f, | |
1839 | 0x01813122, 0x01011014, 0x01441030, 0x01c41030, | |
2f2f4251 M |
1840 | 0x40000100, 0x40000100, |
1841 | }; | |
1842 | ||
dfe495d0 TI |
1843 | /* |
1844 | STAC 922X pin configs for | |
1845 | 102801A7 | |
1846 | 102801AB | |
1847 | 102801A9 | |
1848 | 102801D1 | |
1849 | 102801D2 | |
1850 | */ | |
1851 | static unsigned int dell_922x_d81_pin_configs[10] = { | |
1852 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, | |
1853 | 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1, | |
1854 | 0x01813122, 0x400001f2, | |
1855 | }; | |
1856 | ||
1857 | /* | |
1858 | STAC 922X pin configs for | |
1859 | 102801AC | |
1860 | 102801D0 | |
1861 | */ | |
1862 | static unsigned int dell_922x_d82_pin_configs[10] = { | |
1863 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, | |
1864 | 0x02a19020, 0x01117011, 0x01451140, 0x400001f0, | |
1865 | 0x01813122, 0x400001f1, | |
1866 | }; | |
1867 | ||
1868 | /* | |
1869 | STAC 922X pin configs for | |
1870 | 102801BF | |
1871 | */ | |
1872 | static unsigned int dell_922x_m81_pin_configs[10] = { | |
1873 | 0x0321101f, 0x01112024, 0x01111222, 0x91174220, | |
1874 | 0x03a11050, 0x01116221, 0x90a70330, 0x01452340, | |
1875 | 0x40C003f1, 0x405003f0, | |
1876 | }; | |
1877 | ||
1878 | /* | |
1879 | STAC 9221 A1 pin configs for | |
1880 | 102801D7 (Dell XPS M1210) | |
1881 | */ | |
1882 | static unsigned int dell_922x_m82_pin_configs[10] = { | |
7f9310c1 JZ |
1883 | 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310, |
1884 | 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2, | |
dfe495d0 TI |
1885 | 0x508003f3, 0x405003f4, |
1886 | }; | |
1887 | ||
403d1944 | 1888 | static unsigned int d945gtp3_pin_configs[10] = { |
869264c4 | 1889 | 0x0221401f, 0x01a19022, 0x01813021, 0x01014010, |
403d1944 MP |
1890 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
1891 | 0x02a19120, 0x40000100, | |
1892 | }; | |
1893 | ||
1894 | static unsigned int d945gtp5_pin_configs[10] = { | |
869264c4 MP |
1895 | 0x0221401f, 0x01011012, 0x01813024, 0x01014010, |
1896 | 0x01a19021, 0x01016011, 0x01452130, 0x40000100, | |
403d1944 MP |
1897 | 0x02a19320, 0x40000100, |
1898 | }; | |
1899 | ||
5d5d3bc3 IZ |
1900 | static unsigned int intel_mac_v1_pin_configs[10] = { |
1901 | 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd, | |
1902 | 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240, | |
1903 | 0x400000fc, 0x400000fb, | |
1904 | }; | |
1905 | ||
1906 | static unsigned int intel_mac_v2_pin_configs[10] = { | |
1907 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, | |
1908 | 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa, | |
1909 | 0x400000fc, 0x400000fb, | |
6f0778d8 NB |
1910 | }; |
1911 | ||
5d5d3bc3 IZ |
1912 | static unsigned int intel_mac_v3_pin_configs[10] = { |
1913 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, | |
1914 | 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240, | |
3fc24d85 TI |
1915 | 0x400000fc, 0x400000fb, |
1916 | }; | |
1917 | ||
5d5d3bc3 IZ |
1918 | static unsigned int intel_mac_v4_pin_configs[10] = { |
1919 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, | |
1920 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, | |
f16928fb SF |
1921 | 0x400000fc, 0x400000fb, |
1922 | }; | |
1923 | ||
5d5d3bc3 IZ |
1924 | static unsigned int intel_mac_v5_pin_configs[10] = { |
1925 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, | |
1926 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, | |
1927 | 0x400000fc, 0x400000fb, | |
0dae0f83 TI |
1928 | }; |
1929 | ||
8c650087 MCC |
1930 | static unsigned int ecs202_pin_configs[10] = { |
1931 | 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010, | |
1932 | 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1, | |
1933 | 0x9037012e, 0x40e000f2, | |
1934 | }; | |
76c08828 | 1935 | |
19039bd0 | 1936 | static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { |
f5fcc13c | 1937 | [STAC_D945_REF] = ref922x_pin_configs, |
19039bd0 TI |
1938 | [STAC_D945GTP3] = d945gtp3_pin_configs, |
1939 | [STAC_D945GTP5] = d945gtp5_pin_configs, | |
5d5d3bc3 IZ |
1940 | [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs, |
1941 | [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs, | |
1942 | [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs, | |
1943 | [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs, | |
1944 | [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs, | |
536319af | 1945 | [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs, |
dfe495d0 | 1946 | /* for backward compatibility */ |
5d5d3bc3 IZ |
1947 | [STAC_MACMINI] = intel_mac_v3_pin_configs, |
1948 | [STAC_MACBOOK] = intel_mac_v5_pin_configs, | |
1949 | [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs, | |
1950 | [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs, | |
1951 | [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs, | |
1952 | [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs, | |
8c650087 | 1953 | [STAC_ECS_202] = ecs202_pin_configs, |
dfe495d0 TI |
1954 | [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs, |
1955 | [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs, | |
1956 | [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs, | |
1957 | [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs, | |
403d1944 MP |
1958 | }; |
1959 | ||
f5fcc13c TI |
1960 | static const char *stac922x_models[STAC_922X_MODELS] = { |
1961 | [STAC_D945_REF] = "ref", | |
1962 | [STAC_D945GTP5] = "5stack", | |
1963 | [STAC_D945GTP3] = "3stack", | |
5d5d3bc3 IZ |
1964 | [STAC_INTEL_MAC_V1] = "intel-mac-v1", |
1965 | [STAC_INTEL_MAC_V2] = "intel-mac-v2", | |
1966 | [STAC_INTEL_MAC_V3] = "intel-mac-v3", | |
1967 | [STAC_INTEL_MAC_V4] = "intel-mac-v4", | |
1968 | [STAC_INTEL_MAC_V5] = "intel-mac-v5", | |
536319af | 1969 | [STAC_INTEL_MAC_AUTO] = "intel-mac-auto", |
dfe495d0 | 1970 | /* for backward compatibility */ |
f5fcc13c | 1971 | [STAC_MACMINI] = "macmini", |
3fc24d85 | 1972 | [STAC_MACBOOK] = "macbook", |
6f0778d8 NB |
1973 | [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1", |
1974 | [STAC_MACBOOK_PRO_V2] = "macbook-pro", | |
f16928fb | 1975 | [STAC_IMAC_INTEL] = "imac-intel", |
0dae0f83 | 1976 | [STAC_IMAC_INTEL_20] = "imac-intel-20", |
8c650087 | 1977 | [STAC_ECS_202] = "ecs202", |
dfe495d0 TI |
1978 | [STAC_922X_DELL_D81] = "dell-d81", |
1979 | [STAC_922X_DELL_D82] = "dell-d82", | |
1980 | [STAC_922X_DELL_M81] = "dell-m81", | |
1981 | [STAC_922X_DELL_M82] = "dell-m82", | |
f5fcc13c TI |
1982 | }; |
1983 | ||
1984 | static struct snd_pci_quirk stac922x_cfg_tbl[] = { | |
1985 | /* SigmaTel reference board */ | |
1986 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | |
1987 | "DFI LanParty", STAC_D945_REF), | |
577aa2c1 MR |
1988 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
1989 | "DFI LanParty", STAC_D945_REF), | |
f5fcc13c TI |
1990 | /* Intel 945G based systems */ |
1991 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, | |
1992 | "Intel D945G", STAC_D945GTP3), | |
1993 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202, | |
1994 | "Intel D945G", STAC_D945GTP3), | |
1995 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606, | |
1996 | "Intel D945G", STAC_D945GTP3), | |
1997 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601, | |
1998 | "Intel D945G", STAC_D945GTP3), | |
1999 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111, | |
2000 | "Intel D945G", STAC_D945GTP3), | |
2001 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115, | |
2002 | "Intel D945G", STAC_D945GTP3), | |
2003 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116, | |
2004 | "Intel D945G", STAC_D945GTP3), | |
2005 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117, | |
2006 | "Intel D945G", STAC_D945GTP3), | |
2007 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118, | |
2008 | "Intel D945G", STAC_D945GTP3), | |
2009 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119, | |
2010 | "Intel D945G", STAC_D945GTP3), | |
2011 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826, | |
2012 | "Intel D945G", STAC_D945GTP3), | |
2013 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049, | |
2014 | "Intel D945G", STAC_D945GTP3), | |
2015 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055, | |
2016 | "Intel D945G", STAC_D945GTP3), | |
2017 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048, | |
2018 | "Intel D945G", STAC_D945GTP3), | |
2019 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110, | |
2020 | "Intel D945G", STAC_D945GTP3), | |
2021 | /* Intel D945G 5-stack systems */ | |
2022 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404, | |
2023 | "Intel D945G", STAC_D945GTP5), | |
2024 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303, | |
2025 | "Intel D945G", STAC_D945GTP5), | |
2026 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013, | |
2027 | "Intel D945G", STAC_D945GTP5), | |
2028 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417, | |
2029 | "Intel D945G", STAC_D945GTP5), | |
2030 | /* Intel 945P based systems */ | |
2031 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b, | |
2032 | "Intel D945P", STAC_D945GTP3), | |
2033 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112, | |
2034 | "Intel D945P", STAC_D945GTP3), | |
2035 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d, | |
2036 | "Intel D945P", STAC_D945GTP3), | |
2037 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909, | |
2038 | "Intel D945P", STAC_D945GTP3), | |
2039 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505, | |
2040 | "Intel D945P", STAC_D945GTP3), | |
2041 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, | |
2042 | "Intel D945P", STAC_D945GTP5), | |
8056d47e TI |
2043 | /* other intel */ |
2044 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204, | |
2045 | "Intel D945", STAC_D945_REF), | |
f5fcc13c | 2046 | /* other systems */ |
536319af | 2047 | /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */ |
f5fcc13c | 2048 | SND_PCI_QUIRK(0x8384, 0x7680, |
536319af | 2049 | "Mac", STAC_INTEL_MAC_AUTO), |
dfe495d0 TI |
2050 | /* Dell systems */ |
2051 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7, | |
2052 | "unknown Dell", STAC_922X_DELL_D81), | |
2053 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9, | |
2054 | "unknown Dell", STAC_922X_DELL_D81), | |
2055 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab, | |
2056 | "unknown Dell", STAC_922X_DELL_D81), | |
2057 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac, | |
2058 | "unknown Dell", STAC_922X_DELL_D82), | |
2059 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf, | |
2060 | "unknown Dell", STAC_922X_DELL_M81), | |
2061 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0, | |
2062 | "unknown Dell", STAC_922X_DELL_D82), | |
2063 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1, | |
2064 | "unknown Dell", STAC_922X_DELL_D81), | |
2065 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2, | |
2066 | "unknown Dell", STAC_922X_DELL_D81), | |
2067 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7, | |
2068 | "Dell XPS M1210", STAC_922X_DELL_M82), | |
8c650087 MCC |
2069 | /* ECS/PC Chips boards */ |
2070 | SND_PCI_QUIRK(0x1019, 0x2144, | |
2071 | "ECS/PC chips", STAC_ECS_202), | |
2072 | SND_PCI_QUIRK(0x1019, 0x2608, | |
2073 | "ECS/PC chips", STAC_ECS_202), | |
2074 | SND_PCI_QUIRK(0x1019, 0x2633, | |
2075 | "ECS/PC chips P17G/1333", STAC_ECS_202), | |
2076 | SND_PCI_QUIRK(0x1019, 0x2811, | |
2077 | "ECS/PC chips", STAC_ECS_202), | |
2078 | SND_PCI_QUIRK(0x1019, 0x2812, | |
2079 | "ECS/PC chips", STAC_ECS_202), | |
2080 | SND_PCI_QUIRK(0x1019, 0x2813, | |
2081 | "ECS/PC chips", STAC_ECS_202), | |
2082 | SND_PCI_QUIRK(0x1019, 0x2814, | |
2083 | "ECS/PC chips", STAC_ECS_202), | |
2084 | SND_PCI_QUIRK(0x1019, 0x2815, | |
2085 | "ECS/PC chips", STAC_ECS_202), | |
2086 | SND_PCI_QUIRK(0x1019, 0x2816, | |
2087 | "ECS/PC chips", STAC_ECS_202), | |
2088 | SND_PCI_QUIRK(0x1019, 0x2817, | |
2089 | "ECS/PC chips", STAC_ECS_202), | |
2090 | SND_PCI_QUIRK(0x1019, 0x2818, | |
2091 | "ECS/PC chips", STAC_ECS_202), | |
2092 | SND_PCI_QUIRK(0x1019, 0x2819, | |
2093 | "ECS/PC chips", STAC_ECS_202), | |
2094 | SND_PCI_QUIRK(0x1019, 0x2820, | |
2095 | "ECS/PC chips", STAC_ECS_202), | |
403d1944 MP |
2096 | {} /* terminator */ |
2097 | }; | |
2098 | ||
3cc08dc6 | 2099 | static unsigned int ref927x_pin_configs[14] = { |
93ed1503 TD |
2100 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
2101 | 0x01a19040, 0x01011012, 0x01016011, 0x0101201f, | |
2102 | 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070, | |
2103 | 0x01c42190, 0x40000100, | |
3cc08dc6 MP |
2104 | }; |
2105 | ||
93ed1503 | 2106 | static unsigned int d965_3st_pin_configs[14] = { |
81d3dbde TD |
2107 | 0x0221401f, 0x02a19120, 0x40000100, 0x01014011, |
2108 | 0x01a19021, 0x01813024, 0x40000100, 0x40000100, | |
2109 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, | |
2110 | 0x40000100, 0x40000100 | |
2111 | }; | |
2112 | ||
93ed1503 TD |
2113 | static unsigned int d965_5st_pin_configs[14] = { |
2114 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, | |
2115 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, | |
2116 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, | |
2117 | 0x40000100, 0x40000100 | |
2118 | }; | |
2119 | ||
4ff076e5 TD |
2120 | static unsigned int dell_3st_pin_configs[14] = { |
2121 | 0x02211230, 0x02a11220, 0x01a19040, 0x01114210, | |
2122 | 0x01111212, 0x01116211, 0x01813050, 0x01112214, | |
8e9068b1 | 2123 | 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb, |
4ff076e5 TD |
2124 | 0x40c003fc, 0x40000100 |
2125 | }; | |
2126 | ||
93ed1503 | 2127 | static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { |
e28d8322 | 2128 | [STAC_D965_REF_NO_JD] = ref927x_pin_configs, |
8e9068b1 MR |
2129 | [STAC_D965_REF] = ref927x_pin_configs, |
2130 | [STAC_D965_3ST] = d965_3st_pin_configs, | |
2131 | [STAC_D965_5ST] = d965_5st_pin_configs, | |
2132 | [STAC_DELL_3ST] = dell_3st_pin_configs, | |
2133 | [STAC_DELL_BIOS] = NULL, | |
3cc08dc6 MP |
2134 | }; |
2135 | ||
f5fcc13c | 2136 | static const char *stac927x_models[STAC_927X_MODELS] = { |
e28d8322 | 2137 | [STAC_D965_REF_NO_JD] = "ref-no-jd", |
8e9068b1 MR |
2138 | [STAC_D965_REF] = "ref", |
2139 | [STAC_D965_3ST] = "3stack", | |
2140 | [STAC_D965_5ST] = "5stack", | |
2141 | [STAC_DELL_3ST] = "dell-3stack", | |
2142 | [STAC_DELL_BIOS] = "dell-bios", | |
f5fcc13c TI |
2143 | }; |
2144 | ||
2145 | static struct snd_pci_quirk stac927x_cfg_tbl[] = { | |
2146 | /* SigmaTel reference board */ | |
2147 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | |
2148 | "DFI LanParty", STAC_D965_REF), | |
577aa2c1 MR |
2149 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
2150 | "DFI LanParty", STAC_D965_REF), | |
81d3dbde | 2151 | /* Intel 946 based systems */ |
f5fcc13c TI |
2152 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), |
2153 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST), | |
93ed1503 | 2154 | /* 965 based 3 stack systems */ |
f5fcc13c TI |
2155 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST), |
2156 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST), | |
2157 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST), | |
2158 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST), | |
2159 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST), | |
2160 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST), | |
2161 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST), | |
2162 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST), | |
2163 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST), | |
2164 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST), | |
2165 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST), | |
2166 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST), | |
2167 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST), | |
2168 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST), | |
2169 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST), | |
2170 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST), | |
4ff076e5 | 2171 | /* Dell 3 stack systems */ |
8e9068b1 | 2172 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST), |
dfe495d0 | 2173 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST), |
4ff076e5 TD |
2174 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST), |
2175 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST), | |
8e9068b1 | 2176 | /* Dell 3 stack systems with verb table in BIOS */ |
2f32d909 MR |
2177 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), |
2178 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS), | |
8e9068b1 | 2179 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS), |
24918b61 | 2180 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST), |
8e9068b1 MR |
2181 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), |
2182 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), | |
2183 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), | |
2184 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS), | |
93ed1503 | 2185 | /* 965 based 5 stack systems */ |
f5fcc13c TI |
2186 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST), |
2187 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST), | |
2188 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST), | |
2189 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST), | |
2190 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST), | |
2191 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST), | |
2192 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST), | |
2193 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST), | |
2194 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST), | |
3cc08dc6 MP |
2195 | {} /* terminator */ |
2196 | }; | |
2197 | ||
f3302a59 MP |
2198 | static unsigned int ref9205_pin_configs[12] = { |
2199 | 0x40000100, 0x40000100, 0x01016011, 0x01014010, | |
09a99959 | 2200 | 0x01813122, 0x01a19021, 0x01019020, 0x40000100, |
8b65727b | 2201 | 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030 |
f3302a59 MP |
2202 | }; |
2203 | ||
dfe495d0 TI |
2204 | /* |
2205 | STAC 9205 pin configs for | |
2206 | 102801F1 | |
2207 | 102801F2 | |
2208 | 102801FC | |
2209 | 102801FD | |
2210 | 10280204 | |
2211 | 1028021F | |
3fa2ef74 | 2212 | 10280228 (Dell Vostro 1500) |
dfe495d0 TI |
2213 | */ |
2214 | static unsigned int dell_9205_m42_pin_configs[12] = { | |
2215 | 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, | |
2216 | 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9, | |
2217 | 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE, | |
2218 | }; | |
2219 | ||
2220 | /* | |
2221 | STAC 9205 pin configs for | |
2222 | 102801F9 | |
2223 | 102801FA | |
2224 | 102801FE | |
2225 | 102801FF (Dell Precision M4300) | |
2226 | 10280206 | |
2227 | 10280200 | |
2228 | 10280201 | |
2229 | */ | |
2230 | static unsigned int dell_9205_m43_pin_configs[12] = { | |
ae0a8ed8 TD |
2231 | 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310, |
2232 | 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9, | |
2233 | 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8, | |
2234 | }; | |
2235 | ||
dfe495d0 | 2236 | static unsigned int dell_9205_m44_pin_configs[12] = { |
ae0a8ed8 TD |
2237 | 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310, |
2238 | 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9, | |
2239 | 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe, | |
2240 | }; | |
2241 | ||
f5fcc13c | 2242 | static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = { |
ae0a8ed8 | 2243 | [STAC_9205_REF] = ref9205_pin_configs, |
dfe495d0 TI |
2244 | [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs, |
2245 | [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs, | |
2246 | [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs, | |
d9a4268e | 2247 | [STAC_9205_EAPD] = NULL, |
f3302a59 MP |
2248 | }; |
2249 | ||
f5fcc13c TI |
2250 | static const char *stac9205_models[STAC_9205_MODELS] = { |
2251 | [STAC_9205_REF] = "ref", | |
dfe495d0 | 2252 | [STAC_9205_DELL_M42] = "dell-m42", |
ae0a8ed8 TD |
2253 | [STAC_9205_DELL_M43] = "dell-m43", |
2254 | [STAC_9205_DELL_M44] = "dell-m44", | |
d9a4268e | 2255 | [STAC_9205_EAPD] = "eapd", |
f5fcc13c TI |
2256 | }; |
2257 | ||
2258 | static struct snd_pci_quirk stac9205_cfg_tbl[] = { | |
2259 | /* SigmaTel reference board */ | |
2260 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | |
2261 | "DFI LanParty", STAC_9205_REF), | |
577aa2c1 MR |
2262 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
2263 | "DFI LanParty", STAC_9205_REF), | |
d9a4268e | 2264 | /* Dell */ |
dfe495d0 TI |
2265 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, |
2266 | "unknown Dell", STAC_9205_DELL_M42), | |
2267 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, | |
2268 | "unknown Dell", STAC_9205_DELL_M42), | |
ae0a8ed8 | 2269 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8, |
b44ef2f1 | 2270 | "Dell Precision", STAC_9205_DELL_M43), |
ae0a8ed8 TD |
2271 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9, |
2272 | "Dell Precision", STAC_9205_DELL_M43), | |
2273 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa, | |
2274 | "Dell Precision", STAC_9205_DELL_M43), | |
dfe495d0 TI |
2275 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc, |
2276 | "unknown Dell", STAC_9205_DELL_M42), | |
2277 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd, | |
2278 | "unknown Dell", STAC_9205_DELL_M42), | |
ae0a8ed8 TD |
2279 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe, |
2280 | "Dell Precision", STAC_9205_DELL_M43), | |
2281 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff, | |
dfe495d0 | 2282 | "Dell Precision M4300", STAC_9205_DELL_M43), |
dfe495d0 TI |
2283 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204, |
2284 | "unknown Dell", STAC_9205_DELL_M42), | |
4549915c TI |
2285 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206, |
2286 | "Dell Precision", STAC_9205_DELL_M43), | |
2287 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b, | |
2288 | "Dell Precision", STAC_9205_DELL_M43), | |
2289 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c, | |
2290 | "Dell Precision", STAC_9205_DELL_M43), | |
ae0a8ed8 TD |
2291 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f, |
2292 | "Dell Inspiron", STAC_9205_DELL_M44), | |
3fa2ef74 MR |
2293 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, |
2294 | "Dell Vostro 1500", STAC_9205_DELL_M42), | |
d9a4268e TI |
2295 | /* Gateway */ |
2296 | SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), | |
f3302a59 MP |
2297 | {} /* terminator */ |
2298 | }; | |
2299 | ||
11b44bbd RF |
2300 | static int stac92xx_save_bios_config_regs(struct hda_codec *codec) |
2301 | { | |
2302 | int i; | |
2303 | struct sigmatel_spec *spec = codec->spec; | |
2304 | ||
af9f341a TI |
2305 | kfree(spec->pin_configs); |
2306 | spec->pin_configs = kcalloc(spec->num_pins, sizeof(*spec->pin_configs), | |
2307 | GFP_KERNEL); | |
2308 | if (!spec->pin_configs) | |
2309 | return -ENOMEM; | |
11b44bbd RF |
2310 | |
2311 | for (i = 0; i < spec->num_pins; i++) { | |
2312 | hda_nid_t nid = spec->pin_nids[i]; | |
2313 | unsigned int pin_cfg; | |
2314 | ||
2315 | pin_cfg = snd_hda_codec_read(codec, nid, 0, | |
2316 | AC_VERB_GET_CONFIG_DEFAULT, 0x00); | |
2317 | snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n", | |
2318 | nid, pin_cfg); | |
af9f341a | 2319 | spec->pin_configs[i] = pin_cfg; |
11b44bbd RF |
2320 | } |
2321 | ||
2322 | return 0; | |
2323 | } | |
2324 | ||
87d48363 MR |
2325 | static void stac92xx_set_config_reg(struct hda_codec *codec, |
2326 | hda_nid_t pin_nid, unsigned int pin_config) | |
2327 | { | |
2328 | int i; | |
2329 | snd_hda_codec_write(codec, pin_nid, 0, | |
2330 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0, | |
2331 | pin_config & 0x000000ff); | |
2332 | snd_hda_codec_write(codec, pin_nid, 0, | |
2333 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, | |
2334 | (pin_config & 0x0000ff00) >> 8); | |
2335 | snd_hda_codec_write(codec, pin_nid, 0, | |
2336 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, | |
2337 | (pin_config & 0x00ff0000) >> 16); | |
2338 | snd_hda_codec_write(codec, pin_nid, 0, | |
2339 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, | |
2340 | pin_config >> 24); | |
2341 | i = snd_hda_codec_read(codec, pin_nid, 0, | |
2342 | AC_VERB_GET_CONFIG_DEFAULT, | |
2343 | 0x00); | |
2344 | snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", | |
2345 | pin_nid, i); | |
2346 | } | |
2347 | ||
2f2f4251 M |
2348 | static void stac92xx_set_config_regs(struct hda_codec *codec) |
2349 | { | |
2350 | int i; | |
2351 | struct sigmatel_spec *spec = codec->spec; | |
2f2f4251 | 2352 | |
87d48363 MR |
2353 | if (!spec->pin_configs) |
2354 | return; | |
11b44bbd | 2355 | |
87d48363 MR |
2356 | for (i = 0; i < spec->num_pins; i++) |
2357 | stac92xx_set_config_reg(codec, spec->pin_nids[i], | |
2358 | spec->pin_configs[i]); | |
2f2f4251 | 2359 | } |
2f2f4251 | 2360 | |
af9f341a TI |
2361 | static int stac_save_pin_cfgs(struct hda_codec *codec, unsigned int *pins) |
2362 | { | |
2363 | struct sigmatel_spec *spec = codec->spec; | |
2364 | ||
2365 | if (!pins) | |
2366 | return stac92xx_save_bios_config_regs(codec); | |
2367 | ||
2368 | kfree(spec->pin_configs); | |
2369 | spec->pin_configs = kmemdup(pins, | |
2370 | spec->num_pins * sizeof(*pins), | |
2371 | GFP_KERNEL); | |
2372 | if (!spec->pin_configs) | |
2373 | return -ENOMEM; | |
2374 | ||
2375 | stac92xx_set_config_regs(codec); | |
2376 | return 0; | |
2377 | } | |
2378 | ||
2379 | static void stac_change_pin_config(struct hda_codec *codec, hda_nid_t nid, | |
2380 | unsigned int cfg) | |
2381 | { | |
2382 | struct sigmatel_spec *spec = codec->spec; | |
2383 | int i; | |
2384 | ||
2385 | for (i = 0; i < spec->num_pins; i++) { | |
2386 | if (spec->pin_nids[i] == nid) { | |
2387 | spec->pin_configs[i] = cfg; | |
2388 | stac92xx_set_config_reg(codec, nid, cfg); | |
2389 | break; | |
2390 | } | |
2391 | } | |
2392 | } | |
2393 | ||
dabbed6f | 2394 | /* |
c7d4b2fa | 2395 | * Analog playback callbacks |
dabbed6f | 2396 | */ |
c7d4b2fa M |
2397 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
2398 | struct hda_codec *codec, | |
c8b6bf9b | 2399 | struct snd_pcm_substream *substream) |
2f2f4251 | 2400 | { |
dabbed6f | 2401 | struct sigmatel_spec *spec = codec->spec; |
8daaaa97 MR |
2402 | if (spec->stream_delay) |
2403 | msleep(spec->stream_delay); | |
9a08160b TI |
2404 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
2405 | hinfo); | |
2f2f4251 M |
2406 | } |
2407 | ||
2f2f4251 M |
2408 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
2409 | struct hda_codec *codec, | |
2410 | unsigned int stream_tag, | |
2411 | unsigned int format, | |
c8b6bf9b | 2412 | struct snd_pcm_substream *substream) |
2f2f4251 M |
2413 | { |
2414 | struct sigmatel_spec *spec = codec->spec; | |
403d1944 | 2415 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream); |
2f2f4251 M |
2416 | } |
2417 | ||
2418 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
2419 | struct hda_codec *codec, | |
c8b6bf9b | 2420 | struct snd_pcm_substream *substream) |
2f2f4251 M |
2421 | { |
2422 | struct sigmatel_spec *spec = codec->spec; | |
2423 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | |
2424 | } | |
2425 | ||
dabbed6f M |
2426 | /* |
2427 | * Digital playback callbacks | |
2428 | */ | |
2429 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | |
2430 | struct hda_codec *codec, | |
c8b6bf9b | 2431 | struct snd_pcm_substream *substream) |
dabbed6f M |
2432 | { |
2433 | struct sigmatel_spec *spec = codec->spec; | |
2434 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | |
2435 | } | |
2436 | ||
2437 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, | |
2438 | struct hda_codec *codec, | |
c8b6bf9b | 2439 | struct snd_pcm_substream *substream) |
dabbed6f M |
2440 | { |
2441 | struct sigmatel_spec *spec = codec->spec; | |
2442 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | |
2443 | } | |
2444 | ||
6b97eb45 TI |
2445 | static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
2446 | struct hda_codec *codec, | |
2447 | unsigned int stream_tag, | |
2448 | unsigned int format, | |
2449 | struct snd_pcm_substream *substream) | |
2450 | { | |
2451 | struct sigmatel_spec *spec = codec->spec; | |
2452 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, | |
2453 | stream_tag, format, substream); | |
2454 | } | |
2455 | ||
dabbed6f | 2456 | |
2f2f4251 M |
2457 | /* |
2458 | * Analog capture callbacks | |
2459 | */ | |
2460 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | |
2461 | struct hda_codec *codec, | |
2462 | unsigned int stream_tag, | |
2463 | unsigned int format, | |
c8b6bf9b | 2464 | struct snd_pcm_substream *substream) |
2f2f4251 M |
2465 | { |
2466 | struct sigmatel_spec *spec = codec->spec; | |
8daaaa97 | 2467 | hda_nid_t nid = spec->adc_nids[substream->number]; |
2f2f4251 | 2468 | |
8daaaa97 MR |
2469 | if (spec->powerdown_adcs) { |
2470 | msleep(40); | |
8c2f767b | 2471 | snd_hda_codec_write(codec, nid, 0, |
8daaaa97 MR |
2472 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
2473 | } | |
2474 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); | |
2f2f4251 M |
2475 | return 0; |
2476 | } | |
2477 | ||
2478 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | |
2479 | struct hda_codec *codec, | |
c8b6bf9b | 2480 | struct snd_pcm_substream *substream) |
2f2f4251 M |
2481 | { |
2482 | struct sigmatel_spec *spec = codec->spec; | |
8daaaa97 | 2483 | hda_nid_t nid = spec->adc_nids[substream->number]; |
2f2f4251 | 2484 | |
8daaaa97 MR |
2485 | snd_hda_codec_cleanup_stream(codec, nid); |
2486 | if (spec->powerdown_adcs) | |
8c2f767b | 2487 | snd_hda_codec_write(codec, nid, 0, |
8daaaa97 | 2488 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
2f2f4251 M |
2489 | return 0; |
2490 | } | |
2491 | ||
dabbed6f M |
2492 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
2493 | .substreams = 1, | |
2494 | .channels_min = 2, | |
2495 | .channels_max = 2, | |
2496 | /* NID is set in stac92xx_build_pcms */ | |
2497 | .ops = { | |
2498 | .open = stac92xx_dig_playback_pcm_open, | |
6b97eb45 TI |
2499 | .close = stac92xx_dig_playback_pcm_close, |
2500 | .prepare = stac92xx_dig_playback_pcm_prepare | |
dabbed6f M |
2501 | }, |
2502 | }; | |
2503 | ||
2504 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { | |
2505 | .substreams = 1, | |
2506 | .channels_min = 2, | |
2507 | .channels_max = 2, | |
2508 | /* NID is set in stac92xx_build_pcms */ | |
2509 | }; | |
2510 | ||
2f2f4251 M |
2511 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
2512 | .substreams = 1, | |
2513 | .channels_min = 2, | |
c7d4b2fa | 2514 | .channels_max = 8, |
2f2f4251 M |
2515 | .nid = 0x02, /* NID to query formats and rates */ |
2516 | .ops = { | |
2517 | .open = stac92xx_playback_pcm_open, | |
2518 | .prepare = stac92xx_playback_pcm_prepare, | |
2519 | .cleanup = stac92xx_playback_pcm_cleanup | |
2520 | }, | |
2521 | }; | |
2522 | ||
3cc08dc6 MP |
2523 | static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
2524 | .substreams = 1, | |
2525 | .channels_min = 2, | |
2526 | .channels_max = 2, | |
2527 | .nid = 0x06, /* NID to query formats and rates */ | |
2528 | .ops = { | |
2529 | .open = stac92xx_playback_pcm_open, | |
2530 | .prepare = stac92xx_playback_pcm_prepare, | |
2531 | .cleanup = stac92xx_playback_pcm_cleanup | |
2532 | }, | |
2533 | }; | |
2534 | ||
2f2f4251 | 2535 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
2f2f4251 M |
2536 | .channels_min = 2, |
2537 | .channels_max = 2, | |
9e05b7a3 | 2538 | /* NID + .substreams is set in stac92xx_build_pcms */ |
2f2f4251 M |
2539 | .ops = { |
2540 | .prepare = stac92xx_capture_pcm_prepare, | |
2541 | .cleanup = stac92xx_capture_pcm_cleanup | |
2542 | }, | |
2543 | }; | |
2544 | ||
2545 | static int stac92xx_build_pcms(struct hda_codec *codec) | |
2546 | { | |
2547 | struct sigmatel_spec *spec = codec->spec; | |
2548 | struct hda_pcm *info = spec->pcm_rec; | |
2549 | ||
2550 | codec->num_pcms = 1; | |
2551 | codec->pcm_info = info; | |
2552 | ||
c7d4b2fa | 2553 | info->name = "STAC92xx Analog"; |
2f2f4251 | 2554 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
00a602db TI |
2555 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
2556 | spec->multiout.dac_nids[0]; | |
2f2f4251 | 2557 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
3cc08dc6 | 2558 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
9e05b7a3 | 2559 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs; |
3cc08dc6 MP |
2560 | |
2561 | if (spec->alt_switch) { | |
2562 | codec->num_pcms++; | |
2563 | info++; | |
2564 | info->name = "STAC92xx Analog Alt"; | |
2565 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; | |
2566 | } | |
2f2f4251 | 2567 | |
dabbed6f M |
2568 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
2569 | codec->num_pcms++; | |
2570 | info++; | |
2571 | info->name = "STAC92xx Digital"; | |
8c441982 | 2572 | info->pcm_type = spec->autocfg.dig_out_type; |
dabbed6f M |
2573 | if (spec->multiout.dig_out_nid) { |
2574 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; | |
2575 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; | |
2576 | } | |
2577 | if (spec->dig_in_nid) { | |
2578 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; | |
2579 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; | |
2580 | } | |
2581 | } | |
2582 | ||
2f2f4251 M |
2583 | return 0; |
2584 | } | |
2585 | ||
c960a03b TI |
2586 | static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid) |
2587 | { | |
2588 | unsigned int pincap = snd_hda_param_read(codec, nid, | |
2589 | AC_PAR_PIN_CAP); | |
2590 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; | |
2591 | if (pincap & AC_PINCAP_VREF_100) | |
2592 | return AC_PINCTL_VREF_100; | |
2593 | if (pincap & AC_PINCAP_VREF_80) | |
2594 | return AC_PINCTL_VREF_80; | |
2595 | if (pincap & AC_PINCAP_VREF_50) | |
2596 | return AC_PINCTL_VREF_50; | |
2597 | if (pincap & AC_PINCAP_VREF_GRD) | |
2598 | return AC_PINCTL_VREF_GRD; | |
2599 | return 0; | |
2600 | } | |
2601 | ||
403d1944 MP |
2602 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
2603 | ||
2604 | { | |
82beb8fd TI |
2605 | snd_hda_codec_write_cache(codec, nid, 0, |
2606 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | |
403d1944 MP |
2607 | } |
2608 | ||
7c2ba97b MR |
2609 | #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info |
2610 | ||
2611 | static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol, | |
2612 | struct snd_ctl_elem_value *ucontrol) | |
2613 | { | |
2614 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2615 | struct sigmatel_spec *spec = codec->spec; | |
2616 | ||
d7a89436 | 2617 | ucontrol->value.integer.value[0] = !!spec->hp_switch; |
7c2ba97b MR |
2618 | return 0; |
2619 | } | |
2620 | ||
c6e4c666 TI |
2621 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, |
2622 | unsigned char type); | |
2623 | ||
7c2ba97b MR |
2624 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, |
2625 | struct snd_ctl_elem_value *ucontrol) | |
2626 | { | |
2627 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2628 | struct sigmatel_spec *spec = codec->spec; | |
d7a89436 TI |
2629 | int nid = kcontrol->private_value; |
2630 | ||
2631 | spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0; | |
7c2ba97b MR |
2632 | |
2633 | /* check to be sure that the ports are upto date with | |
2634 | * switch changes | |
2635 | */ | |
c6e4c666 | 2636 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); |
7c2ba97b MR |
2637 | |
2638 | return 1; | |
2639 | } | |
2640 | ||
a5ce8890 | 2641 | #define stac92xx_io_switch_info snd_ctl_boolean_mono_info |
403d1944 MP |
2642 | |
2643 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | |
2644 | { | |
2645 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2646 | struct sigmatel_spec *spec = codec->spec; | |
2647 | int io_idx = kcontrol-> private_value & 0xff; | |
2648 | ||
2649 | ucontrol->value.integer.value[0] = spec->io_switch[io_idx]; | |
2650 | return 0; | |
2651 | } | |
2652 | ||
2653 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | |
2654 | { | |
2655 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2656 | struct sigmatel_spec *spec = codec->spec; | |
2657 | hda_nid_t nid = kcontrol->private_value >> 8; | |
2658 | int io_idx = kcontrol-> private_value & 0xff; | |
68ea7b2f | 2659 | unsigned short val = !!ucontrol->value.integer.value[0]; |
403d1944 MP |
2660 | |
2661 | spec->io_switch[io_idx] = val; | |
2662 | ||
2663 | if (val) | |
2664 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); | |
c960a03b TI |
2665 | else { |
2666 | unsigned int pinctl = AC_PINCTL_IN_EN; | |
2667 | if (io_idx) /* set VREF for mic */ | |
2668 | pinctl |= stac92xx_get_vref(codec, nid); | |
2669 | stac92xx_auto_set_pinctl(codec, nid, pinctl); | |
2670 | } | |
40c1d308 JZ |
2671 | |
2672 | /* check the auto-mute again: we need to mute/unmute the speaker | |
2673 | * appropriately according to the pin direction | |
2674 | */ | |
2675 | if (spec->hp_detect) | |
c6e4c666 | 2676 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); |
40c1d308 | 2677 | |
403d1944 MP |
2678 | return 1; |
2679 | } | |
2680 | ||
0fb87bb4 ML |
2681 | #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info |
2682 | ||
2683 | static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol, | |
2684 | struct snd_ctl_elem_value *ucontrol) | |
2685 | { | |
2686 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2687 | struct sigmatel_spec *spec = codec->spec; | |
2688 | ||
2689 | ucontrol->value.integer.value[0] = spec->clfe_swap; | |
2690 | return 0; | |
2691 | } | |
2692 | ||
2693 | static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol, | |
2694 | struct snd_ctl_elem_value *ucontrol) | |
2695 | { | |
2696 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
2697 | struct sigmatel_spec *spec = codec->spec; | |
2698 | hda_nid_t nid = kcontrol->private_value & 0xff; | |
68ea7b2f | 2699 | unsigned int val = !!ucontrol->value.integer.value[0]; |
0fb87bb4 | 2700 | |
68ea7b2f | 2701 | if (spec->clfe_swap == val) |
0fb87bb4 ML |
2702 | return 0; |
2703 | ||
68ea7b2f | 2704 | spec->clfe_swap = val; |
0fb87bb4 ML |
2705 | |
2706 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, | |
2707 | spec->clfe_swap ? 0x4 : 0x0); | |
2708 | ||
2709 | return 1; | |
2710 | } | |
2711 | ||
7c2ba97b MR |
2712 | #define STAC_CODEC_HP_SWITCH(xname) \ |
2713 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
2714 | .name = xname, \ | |
2715 | .index = 0, \ | |
2716 | .info = stac92xx_hp_switch_info, \ | |
2717 | .get = stac92xx_hp_switch_get, \ | |
2718 | .put = stac92xx_hp_switch_put, \ | |
2719 | } | |
2720 | ||
403d1944 MP |
2721 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
2722 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
2723 | .name = xname, \ | |
2724 | .index = 0, \ | |
2725 | .info = stac92xx_io_switch_info, \ | |
2726 | .get = stac92xx_io_switch_get, \ | |
2727 | .put = stac92xx_io_switch_put, \ | |
2728 | .private_value = xpval, \ | |
2729 | } | |
2730 | ||
0fb87bb4 ML |
2731 | #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \ |
2732 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | |
2733 | .name = xname, \ | |
2734 | .index = 0, \ | |
2735 | .info = stac92xx_clfe_switch_info, \ | |
2736 | .get = stac92xx_clfe_switch_get, \ | |
2737 | .put = stac92xx_clfe_switch_put, \ | |
2738 | .private_value = xpval, \ | |
2739 | } | |
403d1944 | 2740 | |
c7d4b2fa M |
2741 | enum { |
2742 | STAC_CTL_WIDGET_VOL, | |
2743 | STAC_CTL_WIDGET_MUTE, | |
09a99959 | 2744 | STAC_CTL_WIDGET_MONO_MUX, |
89385035 MR |
2745 | STAC_CTL_WIDGET_AMP_MUX, |
2746 | STAC_CTL_WIDGET_AMP_VOL, | |
7c2ba97b | 2747 | STAC_CTL_WIDGET_HP_SWITCH, |
403d1944 | 2748 | STAC_CTL_WIDGET_IO_SWITCH, |
0fb87bb4 | 2749 | STAC_CTL_WIDGET_CLFE_SWITCH |
c7d4b2fa M |
2750 | }; |
2751 | ||
c8b6bf9b | 2752 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
c7d4b2fa M |
2753 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
2754 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | |
09a99959 | 2755 | STAC_MONO_MUX, |
89385035 MR |
2756 | STAC_AMP_MUX, |
2757 | STAC_AMP_VOL(NULL, 0, 0, 0, 0), | |
7c2ba97b | 2758 | STAC_CODEC_HP_SWITCH(NULL), |
403d1944 | 2759 | STAC_CODEC_IO_SWITCH(NULL, 0), |
0fb87bb4 | 2760 | STAC_CODEC_CLFE_SWITCH(NULL, 0), |
c7d4b2fa M |
2761 | }; |
2762 | ||
2763 | /* add dynamic controls */ | |
e3c75964 TI |
2764 | static struct snd_kcontrol_new * |
2765 | stac_control_new(struct sigmatel_spec *spec, | |
2766 | struct snd_kcontrol_new *ktemp, | |
2767 | const char *name) | |
c7d4b2fa | 2768 | { |
c8b6bf9b | 2769 | struct snd_kcontrol_new *knew; |
c7d4b2fa | 2770 | |
603c4019 TI |
2771 | snd_array_init(&spec->kctls, sizeof(*knew), 32); |
2772 | knew = snd_array_new(&spec->kctls); | |
2773 | if (!knew) | |
e3c75964 | 2774 | return NULL; |
4d4e9bb3 | 2775 | *knew = *ktemp; |
82fe0c58 | 2776 | knew->name = kstrdup(name, GFP_KERNEL); |
e3c75964 TI |
2777 | if (!knew->name) { |
2778 | /* roolback */ | |
2779 | memset(knew, 0, sizeof(*knew)); | |
2780 | spec->kctls.alloced--; | |
2781 | return NULL; | |
2782 | } | |
2783 | return knew; | |
2784 | } | |
2785 | ||
2786 | static int stac92xx_add_control_temp(struct sigmatel_spec *spec, | |
2787 | struct snd_kcontrol_new *ktemp, | |
2788 | int idx, const char *name, | |
2789 | unsigned long val) | |
2790 | { | |
2791 | struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name); | |
2792 | if (!knew) | |
c7d4b2fa | 2793 | return -ENOMEM; |
e3c75964 | 2794 | knew->index = idx; |
c7d4b2fa | 2795 | knew->private_value = val; |
c7d4b2fa M |
2796 | return 0; |
2797 | } | |
2798 | ||
4d4e9bb3 TI |
2799 | static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec, |
2800 | int type, int idx, const char *name, | |
2801 | unsigned long val) | |
2802 | { | |
2803 | return stac92xx_add_control_temp(spec, | |
2804 | &stac92xx_control_templates[type], | |
2805 | idx, name, val); | |
2806 | } | |
2807 | ||
4682eee0 MR |
2808 | |
2809 | /* add dynamic controls */ | |
4d4e9bb3 TI |
2810 | static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type, |
2811 | const char *name, unsigned long val) | |
4682eee0 MR |
2812 | { |
2813 | return stac92xx_add_control_idx(spec, type, 0, name, val); | |
2814 | } | |
2815 | ||
e3c75964 TI |
2816 | static struct snd_kcontrol_new stac_input_src_temp = { |
2817 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
2818 | .name = "Input Source", | |
2819 | .info = stac92xx_mux_enum_info, | |
2820 | .get = stac92xx_mux_enum_get, | |
2821 | .put = stac92xx_mux_enum_put, | |
2822 | }; | |
2823 | ||
2824 | static int stac92xx_add_input_source(struct sigmatel_spec *spec) | |
2825 | { | |
2826 | struct snd_kcontrol_new *knew; | |
2827 | struct hda_input_mux *imux = &spec->private_imux; | |
2828 | ||
2829 | if (!spec->num_adcs || imux->num_items <= 1) | |
2830 | return 0; /* no need for input source control */ | |
2831 | knew = stac_control_new(spec, &stac_input_src_temp, | |
2832 | stac_input_src_temp.name); | |
2833 | if (!knew) | |
2834 | return -ENOMEM; | |
2835 | knew->count = spec->num_adcs; | |
2836 | return 0; | |
2837 | } | |
2838 | ||
c21ca4a8 TI |
2839 | /* check whether the line-input can be used as line-out */ |
2840 | static hda_nid_t check_line_out_switch(struct hda_codec *codec) | |
403d1944 MP |
2841 | { |
2842 | struct sigmatel_spec *spec = codec->spec; | |
c21ca4a8 TI |
2843 | struct auto_pin_cfg *cfg = &spec->autocfg; |
2844 | hda_nid_t nid; | |
2845 | unsigned int pincap; | |
8e9068b1 | 2846 | |
c21ca4a8 TI |
2847 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
2848 | return 0; | |
2849 | nid = cfg->input_pins[AUTO_PIN_LINE]; | |
2850 | pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | |
2851 | if (pincap & AC_PINCAP_OUT) | |
2852 | return nid; | |
2853 | return 0; | |
2854 | } | |
403d1944 | 2855 | |
c21ca4a8 TI |
2856 | /* check whether the mic-input can be used as line-out */ |
2857 | static hda_nid_t check_mic_out_switch(struct hda_codec *codec) | |
2858 | { | |
2859 | struct sigmatel_spec *spec = codec->spec; | |
2860 | struct auto_pin_cfg *cfg = &spec->autocfg; | |
2861 | unsigned int def_conf, pincap; | |
2862 | unsigned int mic_pin; | |
2863 | ||
2864 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) | |
2865 | return 0; | |
2866 | mic_pin = AUTO_PIN_MIC; | |
2867 | for (;;) { | |
2868 | hda_nid_t nid = cfg->input_pins[mic_pin]; | |
2869 | def_conf = snd_hda_codec_read(codec, nid, 0, | |
2870 | AC_VERB_GET_CONFIG_DEFAULT, 0); | |
2871 | /* some laptops have an internal analog microphone | |
2872 | * which can't be used as a output */ | |
2873 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { | |
2874 | pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | |
2875 | if (pincap & AC_PINCAP_OUT) | |
2876 | return nid; | |
403d1944 | 2877 | } |
c21ca4a8 TI |
2878 | if (mic_pin == AUTO_PIN_MIC) |
2879 | mic_pin = AUTO_PIN_FRONT_MIC; | |
2880 | else | |
2881 | break; | |
403d1944 | 2882 | } |
403d1944 MP |
2883 | return 0; |
2884 | } | |
2885 | ||
7b043899 SL |
2886 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
2887 | { | |
2888 | int i; | |
2889 | ||
2890 | for (i = 0; i < spec->multiout.num_dacs; i++) { | |
2891 | if (spec->multiout.dac_nids[i] == nid) | |
2892 | return 1; | |
2893 | } | |
2894 | ||
2895 | return 0; | |
2896 | } | |
2897 | ||
c21ca4a8 TI |
2898 | static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
2899 | { | |
2900 | int i; | |
2901 | if (is_in_dac_nids(spec, nid)) | |
2902 | return 1; | |
2903 | for (i = 0; i < spec->autocfg.hp_outs; i++) | |
2904 | if (spec->hp_dacs[i] == nid) | |
2905 | return 1; | |
2906 | for (i = 0; i < spec->autocfg.speaker_outs; i++) | |
2907 | if (spec->speaker_dacs[i] == nid) | |
2908 | return 1; | |
2909 | return 0; | |
2910 | } | |
2911 | ||
2912 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) | |
2913 | { | |
2914 | struct sigmatel_spec *spec = codec->spec; | |
2915 | int j, conn_len; | |
2916 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; | |
2917 | unsigned int wcaps, wtype; | |
2918 | ||
2919 | conn_len = snd_hda_get_connections(codec, nid, conn, | |
2920 | HDA_MAX_CONNECTIONS); | |
2921 | for (j = 0; j < conn_len; j++) { | |
2922 | wcaps = snd_hda_param_read(codec, conn[j], | |
2923 | AC_PAR_AUDIO_WIDGET_CAP); | |
2924 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | |
2925 | /* we check only analog outputs */ | |
2926 | if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) | |
2927 | continue; | |
2928 | /* if this route has a free DAC, assign it */ | |
2929 | if (!check_all_dac_nids(spec, conn[j])) { | |
2930 | if (conn_len > 1) { | |
2931 | /* select this DAC in the pin's input mux */ | |
2932 | snd_hda_codec_write_cache(codec, nid, 0, | |
2933 | AC_VERB_SET_CONNECT_SEL, j); | |
2934 | } | |
2935 | return conn[j]; | |
2936 | } | |
2937 | } | |
2938 | return 0; | |
2939 | } | |
2940 | ||
2941 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid); | |
2942 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid); | |
2943 | ||
3cc08dc6 | 2944 | /* |
7b043899 SL |
2945 | * Fill in the dac_nids table from the parsed pin configuration |
2946 | * This function only works when every pin in line_out_pins[] | |
2947 | * contains atleast one DAC in its connection list. Some 92xx | |
2948 | * codecs are not connected directly to a DAC, such as the 9200 | |
2949 | * and 9202/925x. For those, dac_nids[] must be hard-coded. | |
3cc08dc6 | 2950 | */ |
c21ca4a8 | 2951 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec) |
c7d4b2fa M |
2952 | { |
2953 | struct sigmatel_spec *spec = codec->spec; | |
c21ca4a8 TI |
2954 | struct auto_pin_cfg *cfg = &spec->autocfg; |
2955 | int i; | |
2956 | hda_nid_t nid, dac; | |
7b043899 | 2957 | |
c7d4b2fa M |
2958 | for (i = 0; i < cfg->line_outs; i++) { |
2959 | nid = cfg->line_out_pins[i]; | |
c21ca4a8 TI |
2960 | dac = get_unassigned_dac(codec, nid); |
2961 | if (!dac) { | |
df802952 TI |
2962 | if (spec->multiout.num_dacs > 0) { |
2963 | /* we have already working output pins, | |
2964 | * so let's drop the broken ones again | |
2965 | */ | |
2966 | cfg->line_outs = spec->multiout.num_dacs; | |
2967 | break; | |
2968 | } | |
7b043899 SL |
2969 | /* error out, no available DAC found */ |
2970 | snd_printk(KERN_ERR | |
2971 | "%s: No available DAC for pin 0x%x\n", | |
2972 | __func__, nid); | |
2973 | return -ENODEV; | |
2974 | } | |
c21ca4a8 TI |
2975 | add_spec_dacs(spec, dac); |
2976 | } | |
7b043899 | 2977 | |
c21ca4a8 TI |
2978 | /* add line-in as output */ |
2979 | nid = check_line_out_switch(codec); | |
2980 | if (nid) { | |
2981 | dac = get_unassigned_dac(codec, nid); | |
2982 | if (dac) { | |
2983 | snd_printdd("STAC: Add line-in 0x%x as output %d\n", | |
2984 | nid, cfg->line_outs); | |
2985 | cfg->line_out_pins[cfg->line_outs] = nid; | |
2986 | cfg->line_outs++; | |
2987 | spec->line_switch = nid; | |
2988 | add_spec_dacs(spec, dac); | |
2989 | } | |
2990 | } | |
2991 | /* add mic as output */ | |
2992 | nid = check_mic_out_switch(codec); | |
2993 | if (nid) { | |
2994 | dac = get_unassigned_dac(codec, nid); | |
2995 | if (dac) { | |
2996 | snd_printdd("STAC: Add mic-in 0x%x as output %d\n", | |
2997 | nid, cfg->line_outs); | |
2998 | cfg->line_out_pins[cfg->line_outs] = nid; | |
2999 | cfg->line_outs++; | |
3000 | spec->mic_switch = nid; | |
3001 | add_spec_dacs(spec, dac); | |
3002 | } | |
3003 | } | |
c7d4b2fa | 3004 | |
c21ca4a8 TI |
3005 | for (i = 0; i < cfg->hp_outs; i++) { |
3006 | nid = cfg->hp_pins[i]; | |
3007 | dac = get_unassigned_dac(codec, nid); | |
3008 | if (dac) { | |
3009 | if (!spec->multiout.hp_nid) | |
3010 | spec->multiout.hp_nid = dac; | |
3011 | else | |
3012 | add_spec_extra_dacs(spec, dac); | |
7b043899 | 3013 | } |
c21ca4a8 TI |
3014 | spec->hp_dacs[i] = dac; |
3015 | } | |
3016 | ||
3017 | for (i = 0; i < cfg->speaker_outs; i++) { | |
3018 | nid = cfg->speaker_pins[i]; | |
3019 | dac = get_unassigned_dac(codec, nid); | |
3020 | if (dac) | |
3021 | add_spec_extra_dacs(spec, dac); | |
3022 | spec->speaker_dacs[i] = dac; | |
7b043899 | 3023 | } |
c7d4b2fa | 3024 | |
c21ca4a8 | 3025 | snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", |
7b043899 SL |
3026 | spec->multiout.num_dacs, |
3027 | spec->multiout.dac_nids[0], | |
3028 | spec->multiout.dac_nids[1], | |
3029 | spec->multiout.dac_nids[2], | |
3030 | spec->multiout.dac_nids[3], | |
3031 | spec->multiout.dac_nids[4]); | |
c21ca4a8 | 3032 | |
c7d4b2fa M |
3033 | return 0; |
3034 | } | |
3035 | ||
eb06ed8f | 3036 | /* create volume control/switch for the given prefx type */ |
7c7767eb TI |
3037 | static int create_controls(struct hda_codec *codec, const char *pfx, |
3038 | hda_nid_t nid, int chs) | |
eb06ed8f | 3039 | { |
7c7767eb | 3040 | struct sigmatel_spec *spec = codec->spec; |
eb06ed8f TI |
3041 | char name[32]; |
3042 | int err; | |
3043 | ||
7c7767eb TI |
3044 | if (!spec->check_volume_offset) { |
3045 | unsigned int caps, step, nums, db_scale; | |
3046 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); | |
3047 | step = (caps & AC_AMPCAP_STEP_SIZE) >> | |
3048 | AC_AMPCAP_STEP_SIZE_SHIFT; | |
3049 | step = (step + 1) * 25; /* in .01dB unit */ | |
3050 | nums = (caps & AC_AMPCAP_NUM_STEPS) >> | |
3051 | AC_AMPCAP_NUM_STEPS_SHIFT; | |
3052 | db_scale = nums * step; | |
3053 | /* if dB scale is over -64dB, and finer enough, | |
3054 | * let's reduce it to half | |
3055 | */ | |
3056 | if (db_scale > 6400 && nums >= 0x1f) | |
3057 | spec->volume_offset = nums / 2; | |
3058 | spec->check_volume_offset = 1; | |
3059 | } | |
3060 | ||
eb06ed8f TI |
3061 | sprintf(name, "%s Playback Volume", pfx); |
3062 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name, | |
7c7767eb TI |
3063 | HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT, |
3064 | spec->volume_offset)); | |
eb06ed8f TI |
3065 | if (err < 0) |
3066 | return err; | |
3067 | sprintf(name, "%s Playback Switch", pfx); | |
3068 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name, | |
3069 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); | |
3070 | if (err < 0) | |
3071 | return err; | |
3072 | return 0; | |
3073 | } | |
3074 | ||
ae0afd81 MR |
3075 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
3076 | { | |
c21ca4a8 | 3077 | if (spec->multiout.num_dacs > 4) { |
ae0afd81 MR |
3078 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
3079 | return 1; | |
3080 | } else { | |
3081 | spec->multiout.dac_nids[spec->multiout.num_dacs] = nid; | |
3082 | spec->multiout.num_dacs++; | |
3083 | } | |
3084 | return 0; | |
3085 | } | |
3086 | ||
c21ca4a8 | 3087 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
ae0afd81 | 3088 | { |
c21ca4a8 TI |
3089 | int i; |
3090 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) { | |
3091 | if (!spec->multiout.extra_out_nid[i]) { | |
3092 | spec->multiout.extra_out_nid[i] = nid; | |
3093 | return 0; | |
3094 | } | |
3095 | } | |
3096 | printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid); | |
3097 | return 1; | |
ae0afd81 MR |
3098 | } |
3099 | ||
76624534 TI |
3100 | static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid) |
3101 | { | |
3102 | int i; | |
3103 | ||
3104 | if (spec->autocfg.line_outs != 1) | |
3105 | return 0; | |
3106 | if (spec->multiout.hp_nid == nid) | |
3107 | return 0; | |
3108 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) | |
3109 | if (spec->multiout.extra_out_nid[i] == nid) | |
3110 | return 0; | |
3111 | return 1; | |
3112 | } | |
3113 | ||
c7d4b2fa | 3114 | /* add playback controls from the parsed DAC table */ |
0fb87bb4 | 3115 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
19039bd0 | 3116 | const struct auto_pin_cfg *cfg) |
c7d4b2fa | 3117 | { |
76624534 | 3118 | struct sigmatel_spec *spec = codec->spec; |
19039bd0 TI |
3119 | static const char *chname[4] = { |
3120 | "Front", "Surround", NULL /*CLFE*/, "Side" | |
3121 | }; | |
d21995e3 | 3122 | hda_nid_t nid = 0; |
91589232 TI |
3123 | int i, err; |
3124 | unsigned int wid_caps; | |
0fb87bb4 | 3125 | |
c21ca4a8 | 3126 | for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) { |
c7d4b2fa | 3127 | nid = spec->multiout.dac_nids[i]; |
c7d4b2fa M |
3128 | if (i == 2) { |
3129 | /* Center/LFE */ | |
7c7767eb | 3130 | err = create_controls(codec, "Center", nid, 1); |
eb06ed8f | 3131 | if (err < 0) |
c7d4b2fa | 3132 | return err; |
7c7767eb | 3133 | err = create_controls(codec, "LFE", nid, 2); |
eb06ed8f | 3134 | if (err < 0) |
c7d4b2fa | 3135 | return err; |
0fb87bb4 ML |
3136 | |
3137 | wid_caps = get_wcaps(codec, nid); | |
3138 | ||
3139 | if (wid_caps & AC_WCAP_LR_SWAP) { | |
3140 | err = stac92xx_add_control(spec, | |
3141 | STAC_CTL_WIDGET_CLFE_SWITCH, | |
3142 | "Swap Center/LFE Playback Switch", nid); | |
3143 | ||
3144 | if (err < 0) | |
3145 | return err; | |
3146 | } | |
3147 | ||
c7d4b2fa | 3148 | } else { |
76624534 TI |
3149 | const char *name = chname[i]; |
3150 | /* if it's a single DAC, assign a better name */ | |
3151 | if (!i && is_unique_dac(spec, nid)) { | |
3152 | switch (cfg->line_out_type) { | |
3153 | case AUTO_PIN_HP_OUT: | |
3154 | name = "Headphone"; | |
3155 | break; | |
3156 | case AUTO_PIN_SPEAKER_OUT: | |
3157 | name = "Speaker"; | |
3158 | break; | |
3159 | } | |
3160 | } | |
7c7767eb | 3161 | err = create_controls(codec, name, nid, 3); |
eb06ed8f | 3162 | if (err < 0) |
c7d4b2fa M |
3163 | return err; |
3164 | } | |
3165 | } | |
3166 | ||
a9cb5c90 | 3167 | if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) { |
7c2ba97b MR |
3168 | err = stac92xx_add_control(spec, |
3169 | STAC_CTL_WIDGET_HP_SWITCH, | |
d7a89436 TI |
3170 | "Headphone as Line Out Switch", |
3171 | cfg->hp_pins[cfg->hp_outs - 1]); | |
7c2ba97b MR |
3172 | if (err < 0) |
3173 | return err; | |
3174 | } | |
3175 | ||
b5895dc8 | 3176 | if (spec->line_switch) { |
c21ca4a8 TI |
3177 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, |
3178 | "Line In as Output Switch", | |
3179 | spec->line_switch << 8); | |
3180 | if (err < 0) | |
3181 | return err; | |
b5895dc8 | 3182 | } |
403d1944 | 3183 | |
b5895dc8 | 3184 | if (spec->mic_switch) { |
c21ca4a8 TI |
3185 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, |
3186 | "Mic as Output Switch", | |
3187 | (spec->mic_switch << 8) | 1); | |
3188 | if (err < 0) | |
3189 | return err; | |
b5895dc8 | 3190 | } |
403d1944 | 3191 | |
c7d4b2fa M |
3192 | return 0; |
3193 | } | |
3194 | ||
eb06ed8f TI |
3195 | /* add playback controls for Speaker and HP outputs */ |
3196 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, | |
3197 | struct auto_pin_cfg *cfg) | |
3198 | { | |
3199 | struct sigmatel_spec *spec = codec->spec; | |
3200 | hda_nid_t nid; | |
c21ca4a8 | 3201 | int i, err, nums; |
eb06ed8f | 3202 | |
c21ca4a8 | 3203 | nums = 0; |
eb06ed8f | 3204 | for (i = 0; i < cfg->hp_outs; i++) { |
c21ca4a8 TI |
3205 | static const char *pfxs[] = { |
3206 | "Headphone", "Headphone2", "Headphone3", | |
3207 | }; | |
eb06ed8f TI |
3208 | unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]); |
3209 | if (wid_caps & AC_WCAP_UNSOL_CAP) | |
3210 | spec->hp_detect = 1; | |
c21ca4a8 | 3211 | if (nums >= ARRAY_SIZE(pfxs)) |
c7d4b2fa | 3212 | continue; |
c21ca4a8 TI |
3213 | nid = spec->hp_dacs[i]; |
3214 | if (!nid) | |
eb06ed8f | 3215 | continue; |
7c7767eb | 3216 | err = create_controls(codec, pfxs[nums++], nid, 3); |
c21ca4a8 TI |
3217 | if (err < 0) |
3218 | return err; | |
1b290a51 | 3219 | } |
c21ca4a8 TI |
3220 | nums = 0; |
3221 | for (i = 0; i < cfg->speaker_outs; i++) { | |
eb06ed8f TI |
3222 | static const char *pfxs[] = { |
3223 | "Speaker", "External Speaker", "Speaker2", | |
3224 | }; | |
c21ca4a8 TI |
3225 | if (nums >= ARRAY_SIZE(pfxs)) |
3226 | continue; | |
3227 | nid = spec->speaker_dacs[i]; | |
3228 | if (!nid) | |
3229 | continue; | |
7c7767eb | 3230 | err = create_controls(codec, pfxs[nums++], nid, 3); |
eb06ed8f TI |
3231 | if (err < 0) |
3232 | return err; | |
3233 | } | |
c7d4b2fa M |
3234 | return 0; |
3235 | } | |
3236 | ||
b22b4821 | 3237 | /* labels for mono mux outputs */ |
d0513fc6 MR |
3238 | static const char *stac92xx_mono_labels[4] = { |
3239 | "DAC0", "DAC1", "Mixer", "DAC2" | |
b22b4821 MR |
3240 | }; |
3241 | ||
3242 | /* create mono mux for mono out on capable codecs */ | |
3243 | static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) | |
3244 | { | |
3245 | struct sigmatel_spec *spec = codec->spec; | |
3246 | struct hda_input_mux *mono_mux = &spec->private_mono_mux; | |
3247 | int i, num_cons; | |
3248 | hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)]; | |
3249 | ||
3250 | num_cons = snd_hda_get_connections(codec, | |
3251 | spec->mono_nid, | |
3252 | con_lst, | |
3253 | HDA_MAX_NUM_INPUTS); | |
3254 | if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) | |
3255 | return -EINVAL; | |
3256 | ||
3257 | for (i = 0; i < num_cons; i++) { | |
3258 | mono_mux->items[mono_mux->num_items].label = | |
3259 | stac92xx_mono_labels[i]; | |
3260 | mono_mux->items[mono_mux->num_items].index = i; | |
3261 | mono_mux->num_items++; | |
3262 | } | |
09a99959 MR |
3263 | |
3264 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, | |
3265 | "Mono Mux", spec->mono_nid); | |
b22b4821 MR |
3266 | } |
3267 | ||
89385035 MR |
3268 | /* labels for amp mux outputs */ |
3269 | static const char *stac92xx_amp_labels[3] = { | |
4b33c767 | 3270 | "Front Microphone", "Microphone", "Line In", |
89385035 MR |
3271 | }; |
3272 | ||
3273 | /* create amp out controls mux on capable codecs */ | |
3274 | static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec) | |
3275 | { | |
3276 | struct sigmatel_spec *spec = codec->spec; | |
3277 | struct hda_input_mux *amp_mux = &spec->private_amp_mux; | |
3278 | int i, err; | |
3279 | ||
2a9c7816 | 3280 | for (i = 0; i < spec->num_amps; i++) { |
89385035 MR |
3281 | amp_mux->items[amp_mux->num_items].label = |
3282 | stac92xx_amp_labels[i]; | |
3283 | amp_mux->items[amp_mux->num_items].index = i; | |
3284 | amp_mux->num_items++; | |
3285 | } | |
3286 | ||
2a9c7816 MR |
3287 | if (spec->num_amps > 1) { |
3288 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX, | |
3289 | "Amp Selector Capture Switch", 0); | |
3290 | if (err < 0) | |
3291 | return err; | |
3292 | } | |
89385035 MR |
3293 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL, |
3294 | "Amp Capture Volume", | |
3295 | HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT)); | |
3296 | } | |
3297 | ||
3298 | ||
1cd2224c MR |
3299 | /* create PC beep volume controls */ |
3300 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, | |
3301 | hda_nid_t nid) | |
3302 | { | |
3303 | struct sigmatel_spec *spec = codec->spec; | |
3304 | u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); | |
3305 | int err; | |
3306 | ||
3307 | /* check for mute support for the the amp */ | |
3308 | if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { | |
3309 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, | |
3310 | "PC Beep Playback Switch", | |
3311 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); | |
3312 | if (err < 0) | |
3313 | return err; | |
3314 | } | |
3315 | ||
3316 | /* check to see if there is volume support for the amp */ | |
3317 | if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) { | |
3318 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, | |
3319 | "PC Beep Playback Volume", | |
3320 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); | |
3321 | if (err < 0) | |
3322 | return err; | |
3323 | } | |
3324 | return 0; | |
3325 | } | |
3326 | ||
4d4e9bb3 TI |
3327 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
3328 | #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info | |
3329 | ||
3330 | static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol, | |
3331 | struct snd_ctl_elem_value *ucontrol) | |
3332 | { | |
3333 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3334 | ucontrol->value.integer.value[0] = codec->beep->enabled; | |
3335 | return 0; | |
3336 | } | |
3337 | ||
3338 | static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol, | |
3339 | struct snd_ctl_elem_value *ucontrol) | |
3340 | { | |
3341 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | |
3342 | int enabled = !!ucontrol->value.integer.value[0]; | |
3343 | if (codec->beep->enabled != enabled) { | |
3344 | codec->beep->enabled = enabled; | |
3345 | return 1; | |
3346 | } | |
3347 | return 0; | |
3348 | } | |
3349 | ||
3350 | static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = { | |
3351 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | |
3352 | .info = stac92xx_dig_beep_switch_info, | |
3353 | .get = stac92xx_dig_beep_switch_get, | |
3354 | .put = stac92xx_dig_beep_switch_put, | |
3355 | }; | |
3356 | ||
3357 | static int stac92xx_beep_switch_ctl(struct hda_codec *codec) | |
3358 | { | |
3359 | return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl, | |
3360 | 0, "PC Beep Playback Switch", 0); | |
3361 | } | |
3362 | #endif | |
3363 | ||
4682eee0 MR |
3364 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) |
3365 | { | |
3366 | struct sigmatel_spec *spec = codec->spec; | |
3367 | int wcaps, nid, i, err = 0; | |
3368 | ||
3369 | for (i = 0; i < spec->num_muxes; i++) { | |
3370 | nid = spec->mux_nids[i]; | |
3371 | wcaps = get_wcaps(codec, nid); | |
3372 | ||
3373 | if (wcaps & AC_WCAP_OUT_AMP) { | |
3374 | err = stac92xx_add_control_idx(spec, | |
3375 | STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume", | |
3376 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | |
3377 | if (err < 0) | |
3378 | return err; | |
3379 | } | |
3380 | } | |
3381 | return 0; | |
3382 | }; | |
3383 | ||
d9737751 | 3384 | static const char *stac92xx_spdif_labels[3] = { |
65973632 | 3385 | "Digital Playback", "Analog Mux 1", "Analog Mux 2", |
d9737751 MR |
3386 | }; |
3387 | ||
3388 | static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) | |
3389 | { | |
3390 | struct sigmatel_spec *spec = codec->spec; | |
3391 | struct hda_input_mux *spdif_mux = &spec->private_smux; | |
65973632 | 3392 | const char **labels = spec->spdif_labels; |
d9737751 | 3393 | int i, num_cons; |
65973632 | 3394 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
d9737751 MR |
3395 | |
3396 | num_cons = snd_hda_get_connections(codec, | |
3397 | spec->smux_nids[0], | |
3398 | con_lst, | |
3399 | HDA_MAX_NUM_INPUTS); | |
65973632 | 3400 | if (!num_cons) |
d9737751 MR |
3401 | return -EINVAL; |
3402 | ||
65973632 MR |
3403 | if (!labels) |
3404 | labels = stac92xx_spdif_labels; | |
3405 | ||
d9737751 | 3406 | for (i = 0; i < num_cons; i++) { |
65973632 | 3407 | spdif_mux->items[spdif_mux->num_items].label = labels[i]; |
d9737751 MR |
3408 | spdif_mux->items[spdif_mux->num_items].index = i; |
3409 | spdif_mux->num_items++; | |
3410 | } | |
3411 | ||
3412 | return 0; | |
3413 | } | |
3414 | ||
8b65727b | 3415 | /* labels for dmic mux inputs */ |
ddc2cec4 | 3416 | static const char *stac92xx_dmic_labels[5] = { |
8b65727b MP |
3417 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", |
3418 | "Digital Mic 3", "Digital Mic 4" | |
3419 | }; | |
3420 | ||
3421 | /* create playback/capture controls for input pins on dmic capable codecs */ | |
3422 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, | |
3423 | const struct auto_pin_cfg *cfg) | |
3424 | { | |
3425 | struct sigmatel_spec *spec = codec->spec; | |
3426 | struct hda_input_mux *dimux = &spec->private_dimux; | |
3427 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; | |
0678accd MR |
3428 | int err, i, j; |
3429 | char name[32]; | |
8b65727b MP |
3430 | |
3431 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; | |
3432 | dimux->items[dimux->num_items].index = 0; | |
3433 | dimux->num_items++; | |
3434 | ||
3435 | for (i = 0; i < spec->num_dmics; i++) { | |
0678accd | 3436 | hda_nid_t nid; |
8b65727b MP |
3437 | int index; |
3438 | int num_cons; | |
0678accd | 3439 | unsigned int wcaps; |
8b65727b MP |
3440 | unsigned int def_conf; |
3441 | ||
3442 | def_conf = snd_hda_codec_read(codec, | |
3443 | spec->dmic_nids[i], | |
3444 | 0, | |
3445 | AC_VERB_GET_CONFIG_DEFAULT, | |
3446 | 0); | |
3447 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) | |
3448 | continue; | |
3449 | ||
0678accd | 3450 | nid = spec->dmic_nids[i]; |
8b65727b | 3451 | num_cons = snd_hda_get_connections(codec, |
e1f0d669 | 3452 | spec->dmux_nids[0], |
8b65727b MP |
3453 | con_lst, |
3454 | HDA_MAX_NUM_INPUTS); | |
3455 | for (j = 0; j < num_cons; j++) | |
0678accd | 3456 | if (con_lst[j] == nid) { |
8b65727b MP |
3457 | index = j; |
3458 | goto found; | |
3459 | } | |
3460 | continue; | |
3461 | found: | |
d0513fc6 MR |
3462 | wcaps = get_wcaps(codec, nid) & |
3463 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); | |
0678accd | 3464 | |
d0513fc6 | 3465 | if (wcaps) { |
0678accd MR |
3466 | sprintf(name, "%s Capture Volume", |
3467 | stac92xx_dmic_labels[dimux->num_items]); | |
3468 | ||
3469 | err = stac92xx_add_control(spec, | |
3470 | STAC_CTL_WIDGET_VOL, | |
3471 | name, | |
d0513fc6 MR |
3472 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
3473 | (wcaps & AC_WCAP_OUT_AMP) ? | |
3474 | HDA_OUTPUT : HDA_INPUT)); | |
0678accd MR |
3475 | if (err < 0) |
3476 | return err; | |
3477 | } | |
3478 | ||
8b65727b MP |
3479 | dimux->items[dimux->num_items].label = |
3480 | stac92xx_dmic_labels[dimux->num_items]; | |
3481 | dimux->items[dimux->num_items].index = index; | |
3482 | dimux->num_items++; | |
3483 | } | |
3484 | ||
3485 | return 0; | |
3486 | } | |
3487 | ||
c7d4b2fa M |
3488 | /* create playback/capture controls for input pins */ |
3489 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) | |
3490 | { | |
3491 | struct sigmatel_spec *spec = codec->spec; | |
c7d4b2fa M |
3492 | struct hda_input_mux *imux = &spec->private_imux; |
3493 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; | |
3494 | int i, j, k; | |
3495 | ||
3496 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
314634bc TI |
3497 | int index; |
3498 | ||
3499 | if (!cfg->input_pins[i]) | |
3500 | continue; | |
3501 | index = -1; | |
3502 | for (j = 0; j < spec->num_muxes; j++) { | |
3503 | int num_cons; | |
3504 | num_cons = snd_hda_get_connections(codec, | |
3505 | spec->mux_nids[j], | |
3506 | con_lst, | |
3507 | HDA_MAX_NUM_INPUTS); | |
3508 | for (k = 0; k < num_cons; k++) | |
3509 | if (con_lst[k] == cfg->input_pins[i]) { | |
3510 | index = k; | |
3511 | goto found; | |
3512 | } | |
c7d4b2fa | 3513 | } |
314634bc TI |
3514 | continue; |
3515 | found: | |
3516 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | |
3517 | imux->items[imux->num_items].index = index; | |
3518 | imux->num_items++; | |
c7d4b2fa M |
3519 | } |
3520 | ||
7b043899 | 3521 | if (imux->num_items) { |
62fe78e9 SR |
3522 | /* |
3523 | * Set the current input for the muxes. | |
3524 | * The STAC9221 has two input muxes with identical source | |
3525 | * NID lists. Hopefully this won't get confused. | |
3526 | */ | |
3527 | for (i = 0; i < spec->num_muxes; i++) { | |
82beb8fd TI |
3528 | snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0, |
3529 | AC_VERB_SET_CONNECT_SEL, | |
3530 | imux->items[0].index); | |
62fe78e9 SR |
3531 | } |
3532 | } | |
3533 | ||
c7d4b2fa M |
3534 | return 0; |
3535 | } | |
3536 | ||
c7d4b2fa M |
3537 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
3538 | { | |
3539 | struct sigmatel_spec *spec = codec->spec; | |
3540 | int i; | |
3541 | ||
3542 | for (i = 0; i < spec->autocfg.line_outs; i++) { | |
3543 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | |
3544 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); | |
3545 | } | |
3546 | } | |
3547 | ||
3548 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) | |
3549 | { | |
3550 | struct sigmatel_spec *spec = codec->spec; | |
eb06ed8f | 3551 | int i; |
c7d4b2fa | 3552 | |
eb06ed8f TI |
3553 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
3554 | hda_nid_t pin; | |
3555 | pin = spec->autocfg.hp_pins[i]; | |
3556 | if (pin) /* connect to front */ | |
3557 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); | |
3558 | } | |
3559 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { | |
3560 | hda_nid_t pin; | |
3561 | pin = spec->autocfg.speaker_pins[i]; | |
3562 | if (pin) /* connect to front */ | |
3563 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN); | |
3564 | } | |
c7d4b2fa M |
3565 | } |
3566 | ||
3cc08dc6 | 3567 | static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in) |
c7d4b2fa M |
3568 | { |
3569 | struct sigmatel_spec *spec = codec->spec; | |
3570 | int err; | |
3571 | ||
8b65727b MP |
3572 | if ((err = snd_hda_parse_pin_def_config(codec, |
3573 | &spec->autocfg, | |
3574 | spec->dmic_nids)) < 0) | |
c7d4b2fa | 3575 | return err; |
82bc955f | 3576 | if (! spec->autocfg.line_outs) |
869264c4 | 3577 | return 0; /* can't find valid pin config */ |
19039bd0 | 3578 | |
bcecd9bd JZ |
3579 | /* If we have no real line-out pin and multiple hp-outs, HPs should |
3580 | * be set up as multi-channel outputs. | |
3581 | */ | |
3582 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && | |
3583 | spec->autocfg.hp_outs > 1) { | |
3584 | /* Copy hp_outs to line_outs, backup line_outs in | |
3585 | * speaker_outs so that the following routines can handle | |
3586 | * HP pins as primary outputs. | |
3587 | */ | |
c21ca4a8 | 3588 | snd_printdd("stac92xx: Enabling multi-HPs workaround\n"); |
bcecd9bd JZ |
3589 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, |
3590 | sizeof(spec->autocfg.line_out_pins)); | |
3591 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; | |
3592 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, | |
3593 | sizeof(spec->autocfg.hp_pins)); | |
3594 | spec->autocfg.line_outs = spec->autocfg.hp_outs; | |
c21ca4a8 TI |
3595 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
3596 | spec->autocfg.hp_outs = 0; | |
bcecd9bd | 3597 | } |
09a99959 | 3598 | if (spec->autocfg.mono_out_pin) { |
d0513fc6 MR |
3599 | int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & |
3600 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); | |
09a99959 MR |
3601 | u32 caps = query_amp_caps(codec, |
3602 | spec->autocfg.mono_out_pin, dir); | |
3603 | hda_nid_t conn_list[1]; | |
3604 | ||
3605 | /* get the mixer node and then the mono mux if it exists */ | |
3606 | if (snd_hda_get_connections(codec, | |
3607 | spec->autocfg.mono_out_pin, conn_list, 1) && | |
3608 | snd_hda_get_connections(codec, conn_list[0], | |
3609 | conn_list, 1)) { | |
3610 | ||
3611 | int wcaps = get_wcaps(codec, conn_list[0]); | |
3612 | int wid_type = (wcaps & AC_WCAP_TYPE) | |
3613 | >> AC_WCAP_TYPE_SHIFT; | |
3614 | /* LR swap check, some stac925x have a mux that | |
3615 | * changes the DACs output path instead of the | |
3616 | * mono-mux path. | |
3617 | */ | |
3618 | if (wid_type == AC_WID_AUD_SEL && | |
3619 | !(wcaps & AC_WCAP_LR_SWAP)) | |
3620 | spec->mono_nid = conn_list[0]; | |
3621 | } | |
d0513fc6 MR |
3622 | if (dir) { |
3623 | hda_nid_t nid = spec->autocfg.mono_out_pin; | |
3624 | ||
3625 | /* most mono outs have a least a mute/unmute switch */ | |
3626 | dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT; | |
3627 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, | |
3628 | "Mono Playback Switch", | |
3629 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); | |
09a99959 MR |
3630 | if (err < 0) |
3631 | return err; | |
d0513fc6 MR |
3632 | /* check for volume support for the amp */ |
3633 | if ((caps & AC_AMPCAP_NUM_STEPS) | |
3634 | >> AC_AMPCAP_NUM_STEPS_SHIFT) { | |
3635 | err = stac92xx_add_control(spec, | |
3636 | STAC_CTL_WIDGET_VOL, | |
3637 | "Mono Playback Volume", | |
3638 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); | |
3639 | if (err < 0) | |
3640 | return err; | |
3641 | } | |
09a99959 MR |
3642 | } |
3643 | ||
3644 | stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin, | |
3645 | AC_PINCTL_OUT_EN); | |
3646 | } | |
bcecd9bd | 3647 | |
c21ca4a8 TI |
3648 | if (!spec->multiout.num_dacs) { |
3649 | err = stac92xx_auto_fill_dac_nids(codec); | |
3650 | if (err < 0) | |
19039bd0 | 3651 | return err; |
c9280d68 TI |
3652 | err = stac92xx_auto_create_multi_out_ctls(codec, |
3653 | &spec->autocfg); | |
3654 | if (err < 0) | |
3655 | return err; | |
c21ca4a8 | 3656 | } |
c7d4b2fa | 3657 | |
1cd2224c MR |
3658 | /* setup analog beep controls */ |
3659 | if (spec->anabeep_nid > 0) { | |
3660 | err = stac92xx_auto_create_beep_ctls(codec, | |
3661 | spec->anabeep_nid); | |
3662 | if (err < 0) | |
3663 | return err; | |
3664 | } | |
3665 | ||
3666 | /* setup digital beep controls and input device */ | |
3667 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | |
3668 | if (spec->digbeep_nid > 0) { | |
3669 | hda_nid_t nid = spec->digbeep_nid; | |
4d4e9bb3 | 3670 | unsigned int caps; |
1cd2224c MR |
3671 | |
3672 | err = stac92xx_auto_create_beep_ctls(codec, nid); | |
3673 | if (err < 0) | |
3674 | return err; | |
3675 | err = snd_hda_attach_beep_device(codec, nid); | |
3676 | if (err < 0) | |
3677 | return err; | |
4d4e9bb3 TI |
3678 | /* if no beep switch is available, make its own one */ |
3679 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); | |
3680 | if (codec->beep && | |
3681 | !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) { | |
3682 | err = stac92xx_beep_switch_ctl(codec); | |
3683 | if (err < 0) | |
3684 | return err; | |
3685 | } | |
1cd2224c MR |
3686 | } |
3687 | #endif | |
3688 | ||
0fb87bb4 ML |
3689 | err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); |
3690 | ||
3691 | if (err < 0) | |
3692 | return err; | |
3693 | ||
3694 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); | |
3695 | ||
3696 | if (err < 0) | |
c7d4b2fa M |
3697 | return err; |
3698 | ||
b22b4821 MR |
3699 | if (spec->mono_nid > 0) { |
3700 | err = stac92xx_auto_create_mono_output_ctls(codec); | |
3701 | if (err < 0) | |
3702 | return err; | |
3703 | } | |
2a9c7816 | 3704 | if (spec->num_amps > 0) { |
89385035 MR |
3705 | err = stac92xx_auto_create_amp_output_ctls(codec); |
3706 | if (err < 0) | |
3707 | return err; | |
3708 | } | |
2a9c7816 | 3709 | if (spec->num_dmics > 0 && !spec->dinput_mux) |
8b65727b MP |
3710 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
3711 | &spec->autocfg)) < 0) | |
3712 | return err; | |
4682eee0 MR |
3713 | if (spec->num_muxes > 0) { |
3714 | err = stac92xx_auto_create_mux_input_ctls(codec); | |
3715 | if (err < 0) | |
3716 | return err; | |
3717 | } | |
d9737751 MR |
3718 | if (spec->num_smuxes > 0) { |
3719 | err = stac92xx_auto_create_spdif_mux_ctls(codec); | |
3720 | if (err < 0) | |
3721 | return err; | |
3722 | } | |
8b65727b | 3723 | |
e3c75964 TI |
3724 | err = stac92xx_add_input_source(spec); |
3725 | if (err < 0) | |
3726 | return err; | |
3727 | ||
c7d4b2fa | 3728 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
403d1944 | 3729 | if (spec->multiout.max_channels > 2) |
c7d4b2fa | 3730 | spec->surr_switch = 1; |
c7d4b2fa | 3731 | |
82bc955f | 3732 | if (spec->autocfg.dig_out_pin) |
3cc08dc6 | 3733 | spec->multiout.dig_out_nid = dig_out; |
d0513fc6 | 3734 | if (dig_in && spec->autocfg.dig_in_pin) |
3cc08dc6 | 3735 | spec->dig_in_nid = dig_in; |
c7d4b2fa | 3736 | |
603c4019 TI |
3737 | if (spec->kctls.list) |
3738 | spec->mixers[spec->num_mixers++] = spec->kctls.list; | |
c7d4b2fa M |
3739 | |
3740 | spec->input_mux = &spec->private_imux; | |
f8ccbf65 MR |
3741 | if (!spec->dinput_mux) |
3742 | spec->dinput_mux = &spec->private_dimux; | |
d9737751 | 3743 | spec->sinput_mux = &spec->private_smux; |
b22b4821 | 3744 | spec->mono_mux = &spec->private_mono_mux; |
89385035 | 3745 | spec->amp_mux = &spec->private_amp_mux; |
c7d4b2fa M |
3746 | return 1; |
3747 | } | |
3748 | ||
82bc955f TI |
3749 | /* add playback controls for HP output */ |
3750 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, | |
3751 | struct auto_pin_cfg *cfg) | |
3752 | { | |
3753 | struct sigmatel_spec *spec = codec->spec; | |
eb06ed8f | 3754 | hda_nid_t pin = cfg->hp_pins[0]; |
82bc955f TI |
3755 | unsigned int wid_caps; |
3756 | ||
3757 | if (! pin) | |
3758 | return 0; | |
3759 | ||
3760 | wid_caps = get_wcaps(codec, pin); | |
505cb341 | 3761 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
82bc955f | 3762 | spec->hp_detect = 1; |
82bc955f TI |
3763 | |
3764 | return 0; | |
3765 | } | |
3766 | ||
160ea0dc RF |
3767 | /* add playback controls for LFE output */ |
3768 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, | |
3769 | struct auto_pin_cfg *cfg) | |
3770 | { | |
3771 | struct sigmatel_spec *spec = codec->spec; | |
3772 | int err; | |
3773 | hda_nid_t lfe_pin = 0x0; | |
3774 | int i; | |
3775 | ||
3776 | /* | |
3777 | * search speaker outs and line outs for a mono speaker pin | |
3778 | * with an amp. If one is found, add LFE controls | |
3779 | * for it. | |
3780 | */ | |
3781 | for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { | |
3782 | hda_nid_t pin = spec->autocfg.speaker_pins[i]; | |
64ed0dfd | 3783 | unsigned int wcaps = get_wcaps(codec, pin); |
160ea0dc RF |
3784 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
3785 | if (wcaps == AC_WCAP_OUT_AMP) | |
3786 | /* found a mono speaker with an amp, must be lfe */ | |
3787 | lfe_pin = pin; | |
3788 | } | |
3789 | ||
3790 | /* if speaker_outs is 0, then speakers may be in line_outs */ | |
3791 | if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { | |
3792 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { | |
3793 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; | |
64ed0dfd | 3794 | unsigned int defcfg; |
8b551785 | 3795 | defcfg = snd_hda_codec_read(codec, pin, 0, |
160ea0dc RF |
3796 | AC_VERB_GET_CONFIG_DEFAULT, |
3797 | 0x00); | |
8b551785 | 3798 | if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { |
64ed0dfd | 3799 | unsigned int wcaps = get_wcaps(codec, pin); |
160ea0dc RF |
3800 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
3801 | if (wcaps == AC_WCAP_OUT_AMP) | |
3802 | /* found a mono speaker with an amp, | |
3803 | must be lfe */ | |
3804 | lfe_pin = pin; | |
3805 | } | |
3806 | } | |
3807 | } | |
3808 | ||
3809 | if (lfe_pin) { | |
7c7767eb | 3810 | err = create_controls(codec, "LFE", lfe_pin, 1); |
160ea0dc RF |
3811 | if (err < 0) |
3812 | return err; | |
3813 | } | |
3814 | ||
3815 | return 0; | |
3816 | } | |
3817 | ||
c7d4b2fa M |
3818 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
3819 | { | |
3820 | struct sigmatel_spec *spec = codec->spec; | |
3821 | int err; | |
3822 | ||
df694daa | 3823 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
c7d4b2fa M |
3824 | return err; |
3825 | ||
3826 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) | |
3827 | return err; | |
3828 | ||
82bc955f TI |
3829 | if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) |
3830 | return err; | |
3831 | ||
160ea0dc RF |
3832 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
3833 | return err; | |
3834 | ||
355a0ec4 TI |
3835 | if (spec->num_muxes > 0) { |
3836 | err = stac92xx_auto_create_mux_input_ctls(codec); | |
3837 | if (err < 0) | |
3838 | return err; | |
3839 | } | |
3840 | ||
e3c75964 TI |
3841 | err = stac92xx_add_input_source(spec); |
3842 | if (err < 0) | |
3843 | return err; | |
3844 | ||
82bc955f | 3845 | if (spec->autocfg.dig_out_pin) |
c7d4b2fa | 3846 | spec->multiout.dig_out_nid = 0x05; |
82bc955f | 3847 | if (spec->autocfg.dig_in_pin) |
c7d4b2fa | 3848 | spec->dig_in_nid = 0x04; |
c7d4b2fa | 3849 | |
603c4019 TI |
3850 | if (spec->kctls.list) |
3851 | spec->mixers[spec->num_mixers++] = spec->kctls.list; | |
c7d4b2fa M |
3852 | |
3853 | spec->input_mux = &spec->private_imux; | |
8b65727b | 3854 | spec->dinput_mux = &spec->private_dimux; |
c7d4b2fa M |
3855 | |
3856 | return 1; | |
3857 | } | |
3858 | ||
62fe78e9 SR |
3859 | /* |
3860 | * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a | |
3861 | * funky external mute control using GPIO pins. | |
3862 | */ | |
3863 | ||
76e1ddfb | 3864 | static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, |
4fe5195c | 3865 | unsigned int dir_mask, unsigned int data) |
62fe78e9 SR |
3866 | { |
3867 | unsigned int gpiostate, gpiomask, gpiodir; | |
3868 | ||
3869 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, | |
3870 | AC_VERB_GET_GPIO_DATA, 0); | |
4fe5195c | 3871 | gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask); |
62fe78e9 SR |
3872 | |
3873 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, | |
3874 | AC_VERB_GET_GPIO_MASK, 0); | |
76e1ddfb | 3875 | gpiomask |= mask; |
62fe78e9 SR |
3876 | |
3877 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, | |
3878 | AC_VERB_GET_GPIO_DIRECTION, 0); | |
4fe5195c | 3879 | gpiodir |= dir_mask; |
62fe78e9 | 3880 | |
76e1ddfb | 3881 | /* Configure GPIOx as CMOS */ |
62fe78e9 SR |
3882 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); |
3883 | ||
3884 | snd_hda_codec_write(codec, codec->afg, 0, | |
3885 | AC_VERB_SET_GPIO_MASK, gpiomask); | |
76e1ddfb TI |
3886 | snd_hda_codec_read(codec, codec->afg, 0, |
3887 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */ | |
62fe78e9 SR |
3888 | |
3889 | msleep(1); | |
3890 | ||
76e1ddfb TI |
3891 | snd_hda_codec_read(codec, codec->afg, 0, |
3892 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ | |
62fe78e9 SR |
3893 | } |
3894 | ||
74aeaabc MR |
3895 | static int stac92xx_add_jack(struct hda_codec *codec, |
3896 | hda_nid_t nid, int type) | |
3897 | { | |
e4973e1e | 3898 | #ifdef CONFIG_SND_JACK |
74aeaabc MR |
3899 | struct sigmatel_spec *spec = codec->spec; |
3900 | struct sigmatel_jack *jack; | |
3901 | int def_conf = snd_hda_codec_read(codec, nid, | |
3902 | 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | |
3903 | int connectivity = get_defcfg_connect(def_conf); | |
3904 | char name[32]; | |
3905 | ||
3906 | if (connectivity && connectivity != AC_JACK_PORT_FIXED) | |
3907 | return 0; | |
3908 | ||
3909 | snd_array_init(&spec->jacks, sizeof(*jack), 32); | |
3910 | jack = snd_array_new(&spec->jacks); | |
3911 | if (!jack) | |
3912 | return -ENOMEM; | |
3913 | jack->nid = nid; | |
3914 | jack->type = type; | |
3915 | ||
3916 | sprintf(name, "%s at %s %s Jack", | |
3917 | snd_hda_get_jack_type(def_conf), | |
3918 | snd_hda_get_jack_connectivity(def_conf), | |
3919 | snd_hda_get_jack_location(def_conf)); | |
3920 | ||
3921 | return snd_jack_new(codec->bus->card, name, type, &jack->jack); | |
e4973e1e TI |
3922 | #else |
3923 | return 0; | |
3924 | #endif | |
74aeaabc MR |
3925 | } |
3926 | ||
c6e4c666 TI |
3927 | static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, |
3928 | unsigned char type, int data) | |
74aeaabc MR |
3929 | { |
3930 | struct sigmatel_event *event; | |
3931 | ||
3932 | snd_array_init(&spec->events, sizeof(*event), 32); | |
3933 | event = snd_array_new(&spec->events); | |
3934 | if (!event) | |
3935 | return -ENOMEM; | |
3936 | event->nid = nid; | |
c6e4c666 TI |
3937 | event->type = type; |
3938 | event->tag = spec->events.used; | |
74aeaabc MR |
3939 | event->data = data; |
3940 | ||
c6e4c666 | 3941 | return event->tag; |
74aeaabc MR |
3942 | } |
3943 | ||
c6e4c666 TI |
3944 | static struct sigmatel_event *stac_get_event(struct hda_codec *codec, |
3945 | hda_nid_t nid, unsigned char type) | |
74aeaabc MR |
3946 | { |
3947 | struct sigmatel_spec *spec = codec->spec; | |
c6e4c666 TI |
3948 | struct sigmatel_event *event = spec->events.list; |
3949 | int i; | |
3950 | ||
3951 | for (i = 0; i < spec->events.used; i++, event++) { | |
3952 | if (event->nid == nid && event->type == type) | |
3953 | return event; | |
74aeaabc | 3954 | } |
c6e4c666 | 3955 | return NULL; |
74aeaabc MR |
3956 | } |
3957 | ||
c6e4c666 TI |
3958 | static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec, |
3959 | unsigned char tag) | |
314634bc | 3960 | { |
c6e4c666 TI |
3961 | struct sigmatel_spec *spec = codec->spec; |
3962 | struct sigmatel_event *event = spec->events.list; | |
3963 | int i; | |
3964 | ||
3965 | for (i = 0; i < spec->events.used; i++, event++) { | |
3966 | if (event->tag == tag) | |
3967 | return event; | |
74aeaabc | 3968 | } |
c6e4c666 TI |
3969 | return NULL; |
3970 | } | |
3971 | ||
3972 | static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, | |
3973 | unsigned int type) | |
3974 | { | |
3975 | struct sigmatel_event *event; | |
3976 | int tag; | |
3977 | ||
3978 | if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) | |
3979 | return; | |
3980 | event = stac_get_event(codec, nid, type); | |
3981 | if (event) | |
3982 | tag = event->tag; | |
3983 | else | |
3984 | tag = stac_add_event(codec->spec, nid, type, 0); | |
3985 | if (tag < 0) | |
3986 | return; | |
3987 | snd_hda_codec_write_cache(codec, nid, 0, | |
3988 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
3989 | AC_USRSP_EN | tag); | |
314634bc TI |
3990 | } |
3991 | ||
a64135a2 MR |
3992 | static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) |
3993 | { | |
3994 | int i; | |
3995 | for (i = 0; i < cfg->hp_outs; i++) | |
3996 | if (cfg->hp_pins[i] == nid) | |
3997 | return 1; /* nid is a HP-Out */ | |
3998 | ||
3999 | return 0; /* nid is not a HP-Out */ | |
4000 | }; | |
4001 | ||
b76c850f MR |
4002 | static void stac92xx_power_down(struct hda_codec *codec) |
4003 | { | |
4004 | struct sigmatel_spec *spec = codec->spec; | |
4005 | ||
4006 | /* power down inactive DACs */ | |
4007 | hda_nid_t *dac; | |
4008 | for (dac = spec->dac_list; *dac; dac++) | |
c21ca4a8 | 4009 | if (!check_all_dac_nids(spec, *dac)) |
8c2f767b | 4010 | snd_hda_codec_write(codec, *dac, 0, |
b76c850f MR |
4011 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
4012 | } | |
4013 | ||
f73d3585 TI |
4014 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
4015 | int enable); | |
4016 | ||
c7d4b2fa M |
4017 | static int stac92xx_init(struct hda_codec *codec) |
4018 | { | |
4019 | struct sigmatel_spec *spec = codec->spec; | |
82bc955f | 4020 | struct auto_pin_cfg *cfg = &spec->autocfg; |
f73d3585 | 4021 | unsigned int gpio; |
e4973e1e | 4022 | int i; |
c7d4b2fa | 4023 | |
c7d4b2fa M |
4024 | snd_hda_sequence_write(codec, spec->init); |
4025 | ||
8daaaa97 MR |
4026 | /* power down adcs initially */ |
4027 | if (spec->powerdown_adcs) | |
4028 | for (i = 0; i < spec->num_adcs; i++) | |
8c2f767b | 4029 | snd_hda_codec_write(codec, |
8daaaa97 MR |
4030 | spec->adc_nids[i], 0, |
4031 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); | |
f73d3585 TI |
4032 | |
4033 | /* set up GPIO */ | |
4034 | gpio = spec->gpio_data; | |
4035 | /* turn on EAPD statically when spec->eapd_switch isn't set. | |
4036 | * otherwise, unsol event will turn it on/off dynamically | |
4037 | */ | |
4038 | if (!spec->eapd_switch) | |
4039 | gpio |= spec->eapd_mask; | |
4040 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio); | |
4041 | ||
82bc955f TI |
4042 | /* set up pins */ |
4043 | if (spec->hp_detect) { | |
505cb341 | 4044 | /* Enable unsolicited responses on the HP widget */ |
74aeaabc | 4045 | for (i = 0; i < cfg->hp_outs; i++) { |
74aeaabc | 4046 | hda_nid_t nid = cfg->hp_pins[i]; |
c6e4c666 | 4047 | enable_pin_detect(codec, nid, STAC_HP_EVENT); |
74aeaabc | 4048 | } |
0a07acaf TI |
4049 | /* force to enable the first line-out; the others are set up |
4050 | * in unsol_event | |
4051 | */ | |
4052 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], | |
74aeaabc | 4053 | AC_PINCTL_OUT_EN); |
82bc955f | 4054 | /* fake event to set up pins */ |
c6e4c666 TI |
4055 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], |
4056 | STAC_HP_EVENT); | |
82bc955f TI |
4057 | } else { |
4058 | stac92xx_auto_init_multi_out(codec); | |
4059 | stac92xx_auto_init_hp_out(codec); | |
12dde4c6 TI |
4060 | for (i = 0; i < cfg->hp_outs; i++) |
4061 | stac_toggle_power_map(codec, cfg->hp_pins[i], 1); | |
82bc955f TI |
4062 | } |
4063 | for (i = 0; i < AUTO_PIN_LAST; i++) { | |
c960a03b TI |
4064 | hda_nid_t nid = cfg->input_pins[i]; |
4065 | if (nid) { | |
12dde4c6 | 4066 | unsigned int pinctl, conf; |
4f1e6bc3 TI |
4067 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { |
4068 | /* for mic pins, force to initialize */ | |
4069 | pinctl = stac92xx_get_vref(codec, nid); | |
12dde4c6 TI |
4070 | pinctl |= AC_PINCTL_IN_EN; |
4071 | stac92xx_auto_set_pinctl(codec, nid, pinctl); | |
4f1e6bc3 TI |
4072 | } else { |
4073 | pinctl = snd_hda_codec_read(codec, nid, 0, | |
4074 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
4075 | /* if PINCTL already set then skip */ | |
12dde4c6 TI |
4076 | if (!(pinctl & AC_PINCTL_IN_EN)) { |
4077 | pinctl |= AC_PINCTL_IN_EN; | |
4078 | stac92xx_auto_set_pinctl(codec, nid, | |
4079 | pinctl); | |
4080 | } | |
4081 | } | |
4082 | conf = snd_hda_codec_read(codec, nid, 0, | |
4083 | AC_VERB_GET_CONFIG_DEFAULT, 0); | |
4084 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { | |
4085 | enable_pin_detect(codec, nid, | |
4086 | STAC_INSERT_EVENT); | |
4087 | stac_issue_unsol_event(codec, nid, | |
4088 | STAC_INSERT_EVENT); | |
4f1e6bc3 | 4089 | } |
c960a03b | 4090 | } |
82bc955f | 4091 | } |
a64135a2 MR |
4092 | for (i = 0; i < spec->num_dmics; i++) |
4093 | stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], | |
4094 | AC_PINCTL_IN_EN); | |
f73d3585 TI |
4095 | if (cfg->dig_out_pin) |
4096 | stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin, | |
4097 | AC_PINCTL_OUT_EN); | |
4098 | if (cfg->dig_in_pin) | |
4099 | stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, | |
4100 | AC_PINCTL_IN_EN); | |
a64135a2 | 4101 | for (i = 0; i < spec->num_pwrs; i++) { |
f73d3585 TI |
4102 | hda_nid_t nid = spec->pwr_nids[i]; |
4103 | int pinctl, def_conf; | |
f73d3585 | 4104 | |
eb632128 TI |
4105 | /* power on when no jack detection is available */ |
4106 | if (!spec->hp_detect) { | |
4107 | stac_toggle_power_map(codec, nid, 1); | |
4108 | continue; | |
4109 | } | |
4110 | ||
4111 | if (is_nid_hp_pin(cfg, nid)) | |
f73d3585 TI |
4112 | continue; /* already has an unsol event */ |
4113 | ||
4114 | pinctl = snd_hda_codec_read(codec, nid, 0, | |
4115 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
a64135a2 MR |
4116 | /* outputs are only ports capable of power management |
4117 | * any attempts on powering down a input port cause the | |
4118 | * referenced VREF to act quirky. | |
4119 | */ | |
eb632128 TI |
4120 | if (pinctl & AC_PINCTL_IN_EN) { |
4121 | stac_toggle_power_map(codec, nid, 1); | |
a64135a2 | 4122 | continue; |
eb632128 | 4123 | } |
f73d3585 TI |
4124 | def_conf = snd_hda_codec_read(codec, nid, 0, |
4125 | AC_VERB_GET_CONFIG_DEFAULT, 0); | |
4126 | def_conf = get_defcfg_connect(def_conf); | |
aafc4412 MR |
4127 | /* skip any ports that don't have jacks since presence |
4128 | * detection is useless */ | |
f73d3585 TI |
4129 | if (def_conf != AC_JACK_PORT_COMPLEX) { |
4130 | if (def_conf != AC_JACK_PORT_NONE) | |
4131 | stac_toggle_power_map(codec, nid, 1); | |
bce6c2b5 | 4132 | continue; |
f73d3585 | 4133 | } |
12dde4c6 TI |
4134 | if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) { |
4135 | enable_pin_detect(codec, nid, STAC_PWR_EVENT); | |
4136 | stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT); | |
4137 | } | |
a64135a2 | 4138 | } |
b76c850f MR |
4139 | if (spec->dac_list) |
4140 | stac92xx_power_down(codec); | |
c7d4b2fa M |
4141 | return 0; |
4142 | } | |
4143 | ||
74aeaabc MR |
4144 | static void stac92xx_free_jacks(struct hda_codec *codec) |
4145 | { | |
e4973e1e | 4146 | #ifdef CONFIG_SND_JACK |
b94d3539 | 4147 | /* free jack instances manually when clearing/reconfiguring */ |
74aeaabc | 4148 | struct sigmatel_spec *spec = codec->spec; |
b94d3539 | 4149 | if (!codec->bus->shutdown && spec->jacks.list) { |
74aeaabc MR |
4150 | struct sigmatel_jack *jacks = spec->jacks.list; |
4151 | int i; | |
4152 | for (i = 0; i < spec->jacks.used; i++) | |
4153 | snd_device_free(codec->bus->card, &jacks[i].jack); | |
4154 | } | |
4155 | snd_array_free(&spec->jacks); | |
e4973e1e | 4156 | #endif |
74aeaabc MR |
4157 | } |
4158 | ||
603c4019 TI |
4159 | static void stac92xx_free_kctls(struct hda_codec *codec) |
4160 | { | |
4161 | struct sigmatel_spec *spec = codec->spec; | |
4162 | ||
4163 | if (spec->kctls.list) { | |
4164 | struct snd_kcontrol_new *kctl = spec->kctls.list; | |
4165 | int i; | |
4166 | for (i = 0; i < spec->kctls.used; i++) | |
4167 | kfree(kctl[i].name); | |
4168 | } | |
4169 | snd_array_free(&spec->kctls); | |
4170 | } | |
4171 | ||
2f2f4251 M |
4172 | static void stac92xx_free(struct hda_codec *codec) |
4173 | { | |
c7d4b2fa | 4174 | struct sigmatel_spec *spec = codec->spec; |
c7d4b2fa M |
4175 | |
4176 | if (! spec) | |
4177 | return; | |
4178 | ||
af9f341a | 4179 | kfree(spec->pin_configs); |
74aeaabc MR |
4180 | stac92xx_free_jacks(codec); |
4181 | snd_array_free(&spec->events); | |
11b44bbd | 4182 | |
c7d4b2fa | 4183 | kfree(spec); |
1cd2224c | 4184 | snd_hda_detach_beep_device(codec); |
2f2f4251 M |
4185 | } |
4186 | ||
4e55096e M |
4187 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
4188 | unsigned int flag) | |
4189 | { | |
8ce84198 TI |
4190 | unsigned int old_ctl, pin_ctl; |
4191 | ||
4192 | pin_ctl = snd_hda_codec_read(codec, nid, | |
4e55096e | 4193 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
7b043899 | 4194 | |
f9acba43 TI |
4195 | if (pin_ctl & AC_PINCTL_IN_EN) { |
4196 | /* | |
4197 | * we need to check the current set-up direction of | |
4198 | * shared input pins since they can be switched via | |
4199 | * "xxx as Output" mixer switch | |
4200 | */ | |
4201 | struct sigmatel_spec *spec = codec->spec; | |
c21ca4a8 | 4202 | if (nid == spec->line_switch || nid == spec->mic_switch) |
f9acba43 TI |
4203 | return; |
4204 | } | |
4205 | ||
8ce84198 | 4206 | old_ctl = pin_ctl; |
7b043899 SL |
4207 | /* if setting pin direction bits, clear the current |
4208 | direction bits first */ | |
4209 | if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) | |
4210 | pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); | |
4211 | ||
8ce84198 TI |
4212 | pin_ctl |= flag; |
4213 | if (old_ctl != pin_ctl) | |
4214 | snd_hda_codec_write_cache(codec, nid, 0, | |
4215 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4216 | pin_ctl); | |
4e55096e M |
4217 | } |
4218 | ||
4219 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, | |
4220 | unsigned int flag) | |
4221 | { | |
4222 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, | |
4223 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); | |
8ce84198 TI |
4224 | if (pin_ctl & flag) |
4225 | snd_hda_codec_write_cache(codec, nid, 0, | |
4226 | AC_VERB_SET_PIN_WIDGET_CONTROL, | |
4227 | pin_ctl & ~flag); | |
4e55096e M |
4228 | } |
4229 | ||
e6e3ea25 | 4230 | static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) |
314634bc TI |
4231 | { |
4232 | if (!nid) | |
4233 | return 0; | |
4234 | if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00) | |
e6e3ea25 TI |
4235 | & (1 << 31)) |
4236 | return 1; | |
314634bc TI |
4237 | return 0; |
4238 | } | |
4239 | ||
d7a89436 TI |
4240 | /* return non-zero if the hp-pin of the given array index isn't |
4241 | * a jack-detection target | |
4242 | */ | |
4243 | static int no_hp_sensing(struct sigmatel_spec *spec, int i) | |
4244 | { | |
4245 | struct auto_pin_cfg *cfg = &spec->autocfg; | |
4246 | ||
4247 | /* ignore sensing of shared line and mic jacks */ | |
c21ca4a8 | 4248 | if (cfg->hp_pins[i] == spec->line_switch) |
d7a89436 | 4249 | return 1; |
c21ca4a8 | 4250 | if (cfg->hp_pins[i] == spec->mic_switch) |
d7a89436 TI |
4251 | return 1; |
4252 | /* ignore if the pin is set as line-out */ | |
4253 | if (cfg->hp_pins[i] == spec->hp_switch) | |
4254 | return 1; | |
4255 | return 0; | |
4256 | } | |
4257 | ||
c6e4c666 | 4258 | static void stac92xx_hp_detect(struct hda_codec *codec) |
4e55096e M |
4259 | { |
4260 | struct sigmatel_spec *spec = codec->spec; | |
4261 | struct auto_pin_cfg *cfg = &spec->autocfg; | |
4262 | int i, presence; | |
4263 | ||
eb06ed8f | 4264 | presence = 0; |
4fe5195c MR |
4265 | if (spec->gpio_mute) |
4266 | presence = !(snd_hda_codec_read(codec, codec->afg, 0, | |
4267 | AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute); | |
4268 | ||
eb06ed8f | 4269 | for (i = 0; i < cfg->hp_outs; i++) { |
314634bc TI |
4270 | if (presence) |
4271 | break; | |
d7a89436 TI |
4272 | if (no_hp_sensing(spec, i)) |
4273 | continue; | |
e6e3ea25 TI |
4274 | presence = get_pin_presence(codec, cfg->hp_pins[i]); |
4275 | if (presence) { | |
4276 | unsigned int pinctl; | |
4277 | pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, | |
4278 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | |
4279 | if (pinctl & AC_PINCTL_IN_EN) | |
4280 | presence = 0; /* mic- or line-input */ | |
4281 | } | |
eb06ed8f | 4282 | } |
4e55096e M |
4283 | |
4284 | if (presence) { | |
d7a89436 | 4285 | /* disable lineouts */ |
7c2ba97b | 4286 | if (spec->hp_switch) |
d7a89436 TI |
4287 | stac92xx_reset_pinctl(codec, spec->hp_switch, |
4288 | AC_PINCTL_OUT_EN); | |
4e55096e M |
4289 | for (i = 0; i < cfg->line_outs; i++) |
4290 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], | |
4291 | AC_PINCTL_OUT_EN); | |
eb06ed8f TI |
4292 | for (i = 0; i < cfg->speaker_outs; i++) |
4293 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], | |
4294 | AC_PINCTL_OUT_EN); | |
c0cea0d0 | 4295 | if (spec->eapd_mask && spec->eapd_switch) |
0fc9dec4 MR |
4296 | stac_gpio_set(codec, spec->gpio_mask, |
4297 | spec->gpio_dir, spec->gpio_data & | |
4298 | ~spec->eapd_mask); | |
4e55096e | 4299 | } else { |
d7a89436 | 4300 | /* enable lineouts */ |
7c2ba97b | 4301 | if (spec->hp_switch) |
d7a89436 TI |
4302 | stac92xx_set_pinctl(codec, spec->hp_switch, |
4303 | AC_PINCTL_OUT_EN); | |
4e55096e M |
4304 | for (i = 0; i < cfg->line_outs; i++) |
4305 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], | |
4306 | AC_PINCTL_OUT_EN); | |
eb06ed8f TI |
4307 | for (i = 0; i < cfg->speaker_outs; i++) |
4308 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], | |
4309 | AC_PINCTL_OUT_EN); | |
c0cea0d0 | 4310 | if (spec->eapd_mask && spec->eapd_switch) |
0fc9dec4 MR |
4311 | stac_gpio_set(codec, spec->gpio_mask, |
4312 | spec->gpio_dir, spec->gpio_data | | |
4313 | spec->eapd_mask); | |
4e55096e | 4314 | } |
d7a89436 TI |
4315 | /* toggle hp outs */ |
4316 | for (i = 0; i < cfg->hp_outs; i++) { | |
4317 | unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; | |
4318 | if (no_hp_sensing(spec, i)) | |
4319 | continue; | |
4320 | if (presence) | |
4321 | stac92xx_set_pinctl(codec, cfg->hp_pins[i], val); | |
8317e0b0 TI |
4322 | #if 0 /* FIXME */ |
4323 | /* Resetting the pinctl like below may lead to (a sort of) regressions | |
4324 | * on some devices since they use the HP pin actually for line/speaker | |
4325 | * outs although the default pin config shows a different pin (that is | |
4326 | * wrong and useless). | |
4327 | * | |
4328 | * So, it's basically a problem of default pin configs, likely a BIOS issue. | |
4329 | * But, disabling the code below just works around it, and I'm too tired of | |
4330 | * bug reports with such devices... | |
4331 | */ | |
d7a89436 TI |
4332 | else |
4333 | stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val); | |
8317e0b0 | 4334 | #endif /* FIXME */ |
d7a89436 | 4335 | } |
4e55096e M |
4336 | } |
4337 | ||
f73d3585 TI |
4338 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
4339 | int enable) | |
a64135a2 MR |
4340 | { |
4341 | struct sigmatel_spec *spec = codec->spec; | |
f73d3585 TI |
4342 | unsigned int idx, val; |
4343 | ||
4344 | for (idx = 0; idx < spec->num_pwrs; idx++) { | |
4345 | if (spec->pwr_nids[idx] == nid) | |
4346 | break; | |
4347 | } | |
4348 | if (idx >= spec->num_pwrs) | |
4349 | return; | |
d0513fc6 MR |
4350 | |
4351 | /* several codecs have two power down bits */ | |
4352 | if (spec->pwr_mapping) | |
4353 | idx = spec->pwr_mapping[idx]; | |
4354 | else | |
4355 | idx = 1 << idx; | |
a64135a2 | 4356 | |
f73d3585 TI |
4357 | val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff; |
4358 | if (enable) | |
a64135a2 MR |
4359 | val &= ~idx; |
4360 | else | |
4361 | val |= idx; | |
4362 | ||
4363 | /* power down unused output ports */ | |
4364 | snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val); | |
74aeaabc MR |
4365 | } |
4366 | ||
f73d3585 TI |
4367 | static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) |
4368 | { | |
e6e3ea25 | 4369 | stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid)); |
f73d3585 | 4370 | } |
a64135a2 | 4371 | |
74aeaabc MR |
4372 | static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) |
4373 | { | |
4374 | struct sigmatel_spec *spec = codec->spec; | |
4375 | struct sigmatel_jack *jacks = spec->jacks.list; | |
4376 | ||
4377 | if (jacks) { | |
4378 | int i; | |
4379 | for (i = 0; i < spec->jacks.used; i++) { | |
4380 | if (jacks->nid == nid) { | |
4381 | unsigned int pin_ctl = | |
4382 | snd_hda_codec_read(codec, nid, | |
4383 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, | |
4384 | 0x00); | |
4385 | int type = jacks->type; | |
4386 | if (type == (SND_JACK_LINEOUT | |
4387 | | SND_JACK_HEADPHONE)) | |
4388 | type = (pin_ctl & AC_PINCTL_HP_EN) | |
4389 | ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT; | |
4390 | snd_jack_report(jacks->jack, | |
e6e3ea25 | 4391 | get_pin_presence(codec, nid) |
74aeaabc MR |
4392 | ? type : 0); |
4393 | } | |
4394 | jacks++; | |
4395 | } | |
4396 | } | |
4397 | } | |
a64135a2 | 4398 | |
c6e4c666 TI |
4399 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, |
4400 | unsigned char type) | |
4401 | { | |
4402 | struct sigmatel_event *event = stac_get_event(codec, nid, type); | |
4403 | if (!event) | |
4404 | return; | |
4405 | codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); | |
4406 | } | |
4407 | ||
314634bc TI |
4408 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) |
4409 | { | |
a64135a2 | 4410 | struct sigmatel_spec *spec = codec->spec; |
c6e4c666 TI |
4411 | struct sigmatel_event *event; |
4412 | int tag, data; | |
a64135a2 | 4413 | |
c6e4c666 TI |
4414 | tag = (res >> 26) & 0x7f; |
4415 | event = stac_get_event_from_tag(codec, tag); | |
4416 | if (!event) | |
4417 | return; | |
4418 | ||
4419 | switch (event->type) { | |
314634bc | 4420 | case STAC_HP_EVENT: |
c6e4c666 | 4421 | stac92xx_hp_detect(codec); |
a64135a2 | 4422 | /* fallthru */ |
74aeaabc | 4423 | case STAC_INSERT_EVENT: |
a64135a2 | 4424 | case STAC_PWR_EVENT: |
c6e4c666 TI |
4425 | if (spec->num_pwrs > 0) |
4426 | stac92xx_pin_sense(codec, event->nid); | |
4427 | stac92xx_report_jack(codec, event->nid); | |
72474be6 | 4428 | break; |
c6e4c666 TI |
4429 | case STAC_VREF_EVENT: |
4430 | data = snd_hda_codec_read(codec, codec->afg, 0, | |
4431 | AC_VERB_GET_GPIO_DATA, 0); | |
72474be6 MR |
4432 | /* toggle VREF state based on GPIOx status */ |
4433 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e0, | |
c6e4c666 | 4434 | !!(data & (1 << event->data))); |
72474be6 | 4435 | break; |
314634bc TI |
4436 | } |
4437 | } | |
4438 | ||
2d34e1b3 TI |
4439 | #ifdef CONFIG_PROC_FS |
4440 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, | |
4441 | struct hda_codec *codec, hda_nid_t nid) | |
4442 | { | |
4443 | if (nid == codec->afg) | |
4444 | snd_iprintf(buffer, "Power-Map: 0x%02x\n", | |
4445 | snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0)); | |
4446 | } | |
4447 | ||
4448 | static void analog_loop_proc_hook(struct snd_info_buffer *buffer, | |
4449 | struct hda_codec *codec, | |
4450 | unsigned int verb) | |
4451 | { | |
4452 | snd_iprintf(buffer, "Analog Loopback: 0x%02x\n", | |
4453 | snd_hda_codec_read(codec, codec->afg, 0, verb, 0)); | |
4454 | } | |
4455 | ||
4456 | /* stac92hd71bxx, stac92hd73xx */ | |
4457 | static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer, | |
4458 | struct hda_codec *codec, hda_nid_t nid) | |
4459 | { | |
4460 | stac92hd_proc_hook(buffer, codec, nid); | |
4461 | if (nid == codec->afg) | |
4462 | analog_loop_proc_hook(buffer, codec, 0xfa0); | |
4463 | } | |
4464 | ||
4465 | static void stac9205_proc_hook(struct snd_info_buffer *buffer, | |
4466 | struct hda_codec *codec, hda_nid_t nid) | |
4467 | { | |
4468 | if (nid == codec->afg) | |
4469 | analog_loop_proc_hook(buffer, codec, 0xfe0); | |
4470 | } | |
4471 | ||
4472 | static void stac927x_proc_hook(struct snd_info_buffer *buffer, | |
4473 | struct hda_codec *codec, hda_nid_t nid) | |
4474 | { | |
4475 | if (nid == codec->afg) | |
4476 | analog_loop_proc_hook(buffer, codec, 0xfeb); | |
4477 | } | |
4478 | #else | |
4479 | #define stac92hd_proc_hook NULL | |
4480 | #define stac92hd7x_proc_hook NULL | |
4481 | #define stac9205_proc_hook NULL | |
4482 | #define stac927x_proc_hook NULL | |
4483 | #endif | |
4484 | ||
cb53c626 | 4485 | #ifdef SND_HDA_NEEDS_RESUME |
ff6fdc37 M |
4486 | static int stac92xx_resume(struct hda_codec *codec) |
4487 | { | |
dc81bed1 TI |
4488 | struct sigmatel_spec *spec = codec->spec; |
4489 | ||
11b44bbd | 4490 | stac92xx_set_config_regs(codec); |
2c885878 | 4491 | stac92xx_init(codec); |
82beb8fd TI |
4492 | snd_hda_codec_resume_amp(codec); |
4493 | snd_hda_codec_resume_cache(codec); | |
2c885878 | 4494 | /* fake event to set up pins again to override cached values */ |
dc81bed1 | 4495 | if (spec->hp_detect) |
c6e4c666 TI |
4496 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], |
4497 | STAC_HP_EVENT); | |
ff6fdc37 M |
4498 | return 0; |
4499 | } | |
c6798d2b MR |
4500 | |
4501 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) | |
4502 | { | |
4503 | struct sigmatel_spec *spec = codec->spec; | |
4504 | if (spec->eapd_mask) | |
4505 | stac_gpio_set(codec, spec->gpio_mask, | |
4506 | spec->gpio_dir, spec->gpio_data & | |
4507 | ~spec->eapd_mask); | |
4508 | return 0; | |
4509 | } | |
ff6fdc37 M |
4510 | #endif |
4511 | ||
2f2f4251 M |
4512 | static struct hda_codec_ops stac92xx_patch_ops = { |
4513 | .build_controls = stac92xx_build_controls, | |
4514 | .build_pcms = stac92xx_build_pcms, | |
4515 | .init = stac92xx_init, | |
4516 | .free = stac92xx_free, | |
4e55096e | 4517 | .unsol_event = stac92xx_unsol_event, |
cb53c626 | 4518 | #ifdef SND_HDA_NEEDS_RESUME |
c6798d2b | 4519 | .suspend = stac92xx_suspend, |
ff6fdc37 M |
4520 | .resume = stac92xx_resume, |
4521 | #endif | |
2f2f4251 M |
4522 | }; |
4523 | ||
4524 | static int patch_stac9200(struct hda_codec *codec) | |
4525 | { | |
4526 | struct sigmatel_spec *spec; | |
c7d4b2fa | 4527 | int err; |
2f2f4251 | 4528 | |
e560d8d8 | 4529 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
2f2f4251 M |
4530 | if (spec == NULL) |
4531 | return -ENOMEM; | |
4532 | ||
4533 | codec->spec = spec; | |
a4eed138 | 4534 | spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); |
11b44bbd | 4535 | spec->pin_nids = stac9200_pin_nids; |
f5fcc13c TI |
4536 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, |
4537 | stac9200_models, | |
4538 | stac9200_cfg_tbl); | |
11b44bbd RF |
4539 | if (spec->board_config < 0) { |
4540 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); | |
4541 | err = stac92xx_save_bios_config_regs(codec); | |
af9f341a TI |
4542 | } else |
4543 | err = stac_save_pin_cfgs(codec, | |
4544 | stac9200_brd_tbl[spec->board_config]); | |
4545 | if (err < 0) { | |
4546 | stac92xx_free(codec); | |
4547 | return err; | |
403d1944 | 4548 | } |
2f2f4251 M |
4549 | |
4550 | spec->multiout.max_channels = 2; | |
4551 | spec->multiout.num_dacs = 1; | |
4552 | spec->multiout.dac_nids = stac9200_dac_nids; | |
4553 | spec->adc_nids = stac9200_adc_nids; | |
4554 | spec->mux_nids = stac9200_mux_nids; | |
dabbed6f | 4555 | spec->num_muxes = 1; |
8b65727b | 4556 | spec->num_dmics = 0; |
9e05b7a3 | 4557 | spec->num_adcs = 1; |
a64135a2 | 4558 | spec->num_pwrs = 0; |
c7d4b2fa | 4559 | |
58eec423 MCC |
4560 | if (spec->board_config == STAC_9200_M4 || |
4561 | spec->board_config == STAC_9200_M4_2 || | |
bf277785 | 4562 | spec->board_config == STAC_9200_OQO) |
1194b5b7 TI |
4563 | spec->init = stac9200_eapd_init; |
4564 | else | |
4565 | spec->init = stac9200_core_init; | |
2f2f4251 | 4566 | spec->mixer = stac9200_mixer; |
c7d4b2fa | 4567 | |
117f257d TI |
4568 | if (spec->board_config == STAC_9200_PANASONIC) { |
4569 | spec->gpio_mask = spec->gpio_dir = 0x09; | |
4570 | spec->gpio_data = 0x00; | |
4571 | } | |
4572 | ||
c7d4b2fa M |
4573 | err = stac9200_parse_auto_config(codec); |
4574 | if (err < 0) { | |
4575 | stac92xx_free(codec); | |
4576 | return err; | |
4577 | } | |
2f2f4251 | 4578 | |
2acc9dcb TI |
4579 | /* CF-74 has no headphone detection, and the driver should *NOT* |
4580 | * do detection and HP/speaker toggle because the hardware does it. | |
4581 | */ | |
4582 | if (spec->board_config == STAC_9200_PANASONIC) | |
4583 | spec->hp_detect = 0; | |
4584 | ||
2f2f4251 M |
4585 | codec->patch_ops = stac92xx_patch_ops; |
4586 | ||
4587 | return 0; | |
4588 | } | |
4589 | ||
8e21c34c TD |
4590 | static int patch_stac925x(struct hda_codec *codec) |
4591 | { | |
4592 | struct sigmatel_spec *spec; | |
4593 | int err; | |
4594 | ||
4595 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
4596 | if (spec == NULL) | |
4597 | return -ENOMEM; | |
4598 | ||
4599 | codec->spec = spec; | |
a4eed138 | 4600 | spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); |
8e21c34c | 4601 | spec->pin_nids = stac925x_pin_nids; |
9cb36c2a MCC |
4602 | |
4603 | /* Check first for codec ID */ | |
4604 | spec->board_config = snd_hda_check_board_codec_sid_config(codec, | |
4605 | STAC_925x_MODELS, | |
4606 | stac925x_models, | |
4607 | stac925x_codec_id_cfg_tbl); | |
4608 | ||
4609 | /* Now checks for PCI ID, if codec ID is not found */ | |
4610 | if (spec->board_config < 0) | |
4611 | spec->board_config = snd_hda_check_board_config(codec, | |
4612 | STAC_925x_MODELS, | |
8e21c34c TD |
4613 | stac925x_models, |
4614 | stac925x_cfg_tbl); | |
9e507abd | 4615 | again: |
8e21c34c | 4616 | if (spec->board_config < 0) { |
9cb36c2a | 4617 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," |
2c11f955 | 4618 | "using BIOS defaults\n"); |
8e21c34c | 4619 | err = stac92xx_save_bios_config_regs(codec); |
af9f341a TI |
4620 | } else |
4621 | err = stac_save_pin_cfgs(codec, | |
4622 | stac925x_brd_tbl[spec->board_config]); | |
4623 | if (err < 0) { | |
4624 | stac92xx_free(codec); | |
4625 | return err; | |
8e21c34c TD |
4626 | } |
4627 | ||
4628 | spec->multiout.max_channels = 2; | |
4629 | spec->multiout.num_dacs = 1; | |
4630 | spec->multiout.dac_nids = stac925x_dac_nids; | |
4631 | spec->adc_nids = stac925x_adc_nids; | |
4632 | spec->mux_nids = stac925x_mux_nids; | |
4633 | spec->num_muxes = 1; | |
9e05b7a3 | 4634 | spec->num_adcs = 1; |
a64135a2 | 4635 | spec->num_pwrs = 0; |
2c11f955 TD |
4636 | switch (codec->vendor_id) { |
4637 | case 0x83847632: /* STAC9202 */ | |
4638 | case 0x83847633: /* STAC9202D */ | |
4639 | case 0x83847636: /* STAC9251 */ | |
4640 | case 0x83847637: /* STAC9251D */ | |
f6e9852a | 4641 | spec->num_dmics = STAC925X_NUM_DMICS; |
2c11f955 | 4642 | spec->dmic_nids = stac925x_dmic_nids; |
1697055e TI |
4643 | spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids); |
4644 | spec->dmux_nids = stac925x_dmux_nids; | |
2c11f955 TD |
4645 | break; |
4646 | default: | |
4647 | spec->num_dmics = 0; | |
4648 | break; | |
4649 | } | |
8e21c34c TD |
4650 | |
4651 | spec->init = stac925x_core_init; | |
4652 | spec->mixer = stac925x_mixer; | |
4653 | ||
4654 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); | |
9e507abd TI |
4655 | if (!err) { |
4656 | if (spec->board_config < 0) { | |
4657 | printk(KERN_WARNING "hda_codec: No auto-config is " | |
4658 | "available, default to model=ref\n"); | |
4659 | spec->board_config = STAC_925x_REF; | |
4660 | goto again; | |
4661 | } | |
4662 | err = -EINVAL; | |
4663 | } | |
8e21c34c TD |
4664 | if (err < 0) { |
4665 | stac92xx_free(codec); | |
4666 | return err; | |
4667 | } | |
4668 | ||
4669 | codec->patch_ops = stac92xx_patch_ops; | |
4670 | ||
4671 | return 0; | |
4672 | } | |
4673 | ||
e1f0d669 MR |
4674 | static struct hda_input_mux stac92hd73xx_dmux = { |
4675 | .num_items = 4, | |
4676 | .items = { | |
4677 | { "Analog Inputs", 0x0b }, | |
e1f0d669 MR |
4678 | { "Digital Mic 1", 0x09 }, |
4679 | { "Digital Mic 2", 0x0a }, | |
2a9c7816 | 4680 | { "CD", 0x08 }, |
e1f0d669 MR |
4681 | } |
4682 | }; | |
4683 | ||
4684 | static int patch_stac92hd73xx(struct hda_codec *codec) | |
4685 | { | |
4686 | struct sigmatel_spec *spec; | |
4687 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; | |
4688 | int err = 0; | |
c21ca4a8 | 4689 | int num_dacs; |
e1f0d669 MR |
4690 | |
4691 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
4692 | if (spec == NULL) | |
4693 | return -ENOMEM; | |
4694 | ||
4695 | codec->spec = spec; | |
e99d32b3 | 4696 | codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; |
e1f0d669 MR |
4697 | spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids); |
4698 | spec->pin_nids = stac92hd73xx_pin_nids; | |
4699 | spec->board_config = snd_hda_check_board_config(codec, | |
4700 | STAC_92HD73XX_MODELS, | |
4701 | stac92hd73xx_models, | |
4702 | stac92hd73xx_cfg_tbl); | |
4703 | again: | |
4704 | if (spec->board_config < 0) { | |
4705 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" | |
4706 | " STAC92HD73XX, using BIOS defaults\n"); | |
4707 | err = stac92xx_save_bios_config_regs(codec); | |
af9f341a TI |
4708 | } else |
4709 | err = stac_save_pin_cfgs(codec, | |
4710 | stac92hd73xx_brd_tbl[spec->board_config]); | |
4711 | if (err < 0) { | |
4712 | stac92xx_free(codec); | |
4713 | return err; | |
e1f0d669 MR |
4714 | } |
4715 | ||
c21ca4a8 | 4716 | num_dacs = snd_hda_get_connections(codec, 0x0a, |
e1f0d669 MR |
4717 | conn, STAC92HD73_DAC_COUNT + 2) - 1; |
4718 | ||
c21ca4a8 | 4719 | if (num_dacs < 3 || num_dacs > 5) { |
e1f0d669 MR |
4720 | printk(KERN_WARNING "hda_codec: Could not determine " |
4721 | "number of channels defaulting to DAC count\n"); | |
c21ca4a8 | 4722 | num_dacs = STAC92HD73_DAC_COUNT; |
e1f0d669 | 4723 | } |
c21ca4a8 | 4724 | switch (num_dacs) { |
e1f0d669 MR |
4725 | case 0x3: /* 6 Channel */ |
4726 | spec->mixer = stac92hd73xx_6ch_mixer; | |
4727 | spec->init = stac92hd73xx_6ch_core_init; | |
4728 | break; | |
4729 | case 0x4: /* 8 Channel */ | |
e1f0d669 MR |
4730 | spec->mixer = stac92hd73xx_8ch_mixer; |
4731 | spec->init = stac92hd73xx_8ch_core_init; | |
4732 | break; | |
4733 | case 0x5: /* 10 Channel */ | |
e1f0d669 MR |
4734 | spec->mixer = stac92hd73xx_10ch_mixer; |
4735 | spec->init = stac92hd73xx_10ch_core_init; | |
c21ca4a8 TI |
4736 | } |
4737 | spec->multiout.dac_nids = spec->dac_nids; | |
e1f0d669 | 4738 | |
e1f0d669 MR |
4739 | spec->aloopback_mask = 0x01; |
4740 | spec->aloopback_shift = 8; | |
4741 | ||
1cd2224c | 4742 | spec->digbeep_nid = 0x1c; |
e1f0d669 MR |
4743 | spec->mux_nids = stac92hd73xx_mux_nids; |
4744 | spec->adc_nids = stac92hd73xx_adc_nids; | |
4745 | spec->dmic_nids = stac92hd73xx_dmic_nids; | |
4746 | spec->dmux_nids = stac92hd73xx_dmux_nids; | |
d9737751 | 4747 | spec->smux_nids = stac92hd73xx_smux_nids; |
89385035 | 4748 | spec->amp_nids = stac92hd73xx_amp_nids; |
2a9c7816 | 4749 | spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids); |
e1f0d669 MR |
4750 | |
4751 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); | |
4752 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); | |
1697055e | 4753 | spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); |
2a9c7816 MR |
4754 | memcpy(&spec->private_dimux, &stac92hd73xx_dmux, |
4755 | sizeof(stac92hd73xx_dmux)); | |
4756 | ||
a7662640 | 4757 | switch (spec->board_config) { |
6b3ab21e | 4758 | case STAC_DELL_EQ: |
d654a660 | 4759 | spec->init = dell_eq_core_init; |
6b3ab21e | 4760 | /* fallthru */ |
661cd8fb TI |
4761 | case STAC_DELL_M6_AMIC: |
4762 | case STAC_DELL_M6_DMIC: | |
4763 | case STAC_DELL_M6_BOTH: | |
2a9c7816 | 4764 | spec->num_smuxes = 0; |
2a9c7816 MR |
4765 | spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER]; |
4766 | spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; | |
c0cea0d0 | 4767 | spec->eapd_switch = 0; |
2a9c7816 | 4768 | spec->num_amps = 1; |
6b3ab21e | 4769 | |
c21ca4a8 | 4770 | if (spec->board_config != STAC_DELL_EQ) |
6b3ab21e | 4771 | spec->init = dell_m6_core_init; |
661cd8fb TI |
4772 | switch (spec->board_config) { |
4773 | case STAC_DELL_M6_AMIC: /* Analog Mics */ | |
a7662640 MR |
4774 | stac92xx_set_config_reg(codec, 0x0b, 0x90A70170); |
4775 | spec->num_dmics = 0; | |
2a9c7816 | 4776 | spec->private_dimux.num_items = 1; |
a7662640 | 4777 | break; |
661cd8fb | 4778 | case STAC_DELL_M6_DMIC: /* Digital Mics */ |
a7662640 MR |
4779 | stac92xx_set_config_reg(codec, 0x13, 0x90A60160); |
4780 | spec->num_dmics = 1; | |
2a9c7816 | 4781 | spec->private_dimux.num_items = 2; |
a7662640 | 4782 | break; |
661cd8fb | 4783 | case STAC_DELL_M6_BOTH: /* Both */ |
a7662640 MR |
4784 | stac92xx_set_config_reg(codec, 0x0b, 0x90A70170); |
4785 | stac92xx_set_config_reg(codec, 0x13, 0x90A60160); | |
4786 | spec->num_dmics = 1; | |
2a9c7816 | 4787 | spec->private_dimux.num_items = 2; |
a7662640 MR |
4788 | break; |
4789 | } | |
4790 | break; | |
4791 | default: | |
4792 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; | |
2a9c7816 | 4793 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); |
c0cea0d0 | 4794 | spec->eapd_switch = 1; |
a7662640 | 4795 | } |
b2c4f4d7 MR |
4796 | if (spec->board_config > STAC_92HD73XX_REF) { |
4797 | /* GPIO0 High = Enable EAPD */ | |
4798 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; | |
4799 | spec->gpio_data = 0x01; | |
4800 | } | |
2a9c7816 | 4801 | spec->dinput_mux = &spec->private_dimux; |
a7662640 | 4802 | |
a64135a2 MR |
4803 | spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); |
4804 | spec->pwr_nids = stac92hd73xx_pwr_nids; | |
4805 | ||
d9737751 | 4806 | err = stac92xx_parse_auto_config(codec, 0x25, 0x27); |
e1f0d669 MR |
4807 | |
4808 | if (!err) { | |
4809 | if (spec->board_config < 0) { | |
4810 | printk(KERN_WARNING "hda_codec: No auto-config is " | |
4811 | "available, default to model=ref\n"); | |
4812 | spec->board_config = STAC_92HD73XX_REF; | |
4813 | goto again; | |
4814 | } | |
4815 | err = -EINVAL; | |
4816 | } | |
4817 | ||
4818 | if (err < 0) { | |
4819 | stac92xx_free(codec); | |
4820 | return err; | |
4821 | } | |
4822 | ||
9e43f0de TI |
4823 | if (spec->board_config == STAC_92HD73XX_NO_JD) |
4824 | spec->hp_detect = 0; | |
4825 | ||
e1f0d669 MR |
4826 | codec->patch_ops = stac92xx_patch_ops; |
4827 | ||
2d34e1b3 TI |
4828 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
4829 | ||
e1f0d669 MR |
4830 | return 0; |
4831 | } | |
4832 | ||
d0513fc6 MR |
4833 | static struct hda_input_mux stac92hd83xxx_dmux = { |
4834 | .num_items = 3, | |
4835 | .items = { | |
4836 | { "Analog Inputs", 0x03 }, | |
4837 | { "Digital Mic 1", 0x04 }, | |
4838 | { "Digital Mic 2", 0x05 }, | |
4839 | } | |
4840 | }; | |
4841 | ||
4842 | static int patch_stac92hd83xxx(struct hda_codec *codec) | |
4843 | { | |
4844 | struct sigmatel_spec *spec; | |
65557f35 | 4845 | hda_nid_t conn[STAC92HD83_DAC_COUNT + 1]; |
d0513fc6 | 4846 | int err; |
65557f35 | 4847 | int num_dacs; |
d0513fc6 MR |
4848 | |
4849 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
4850 | if (spec == NULL) | |
4851 | return -ENOMEM; | |
4852 | ||
4853 | codec->spec = spec; | |
0ffa9807 | 4854 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; |
d0513fc6 MR |
4855 | spec->mono_nid = 0x19; |
4856 | spec->digbeep_nid = 0x21; | |
4857 | spec->dmic_nids = stac92hd83xxx_dmic_nids; | |
4858 | spec->dmux_nids = stac92hd83xxx_dmux_nids; | |
4859 | spec->adc_nids = stac92hd83xxx_adc_nids; | |
4860 | spec->pwr_nids = stac92hd83xxx_pwr_nids; | |
c15c5060 | 4861 | spec->amp_nids = stac92hd83xxx_amp_nids; |
d0513fc6 MR |
4862 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; |
4863 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); | |
c21ca4a8 | 4864 | spec->multiout.dac_nids = spec->dac_nids; |
d0513fc6 | 4865 | |
65557f35 MR |
4866 | |
4867 | /* set port 0xe to select the last DAC | |
4868 | */ | |
4869 | num_dacs = snd_hda_get_connections(codec, 0x0e, | |
4870 | conn, STAC92HD83_DAC_COUNT + 1) - 1; | |
4871 | ||
4872 | snd_hda_codec_write_cache(codec, 0xe, 0, | |
4873 | AC_VERB_SET_CONNECT_SEL, num_dacs); | |
4874 | ||
d0513fc6 | 4875 | spec->init = stac92hd83xxx_core_init; |
d0513fc6 MR |
4876 | spec->mixer = stac92hd83xxx_mixer; |
4877 | spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); | |
4878 | spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids); | |
4879 | spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); | |
c15c5060 | 4880 | spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids); |
d0513fc6 MR |
4881 | spec->num_dmics = STAC92HD83XXX_NUM_DMICS; |
4882 | spec->dinput_mux = &stac92hd83xxx_dmux; | |
4883 | spec->pin_nids = stac92hd83xxx_pin_nids; | |
4884 | spec->board_config = snd_hda_check_board_config(codec, | |
4885 | STAC_92HD83XXX_MODELS, | |
4886 | stac92hd83xxx_models, | |
4887 | stac92hd83xxx_cfg_tbl); | |
4888 | again: | |
4889 | if (spec->board_config < 0) { | |
4890 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" | |
4891 | " STAC92HD83XXX, using BIOS defaults\n"); | |
4892 | err = stac92xx_save_bios_config_regs(codec); | |
af9f341a TI |
4893 | } else |
4894 | err = stac_save_pin_cfgs(codec, | |
4895 | stac92hd83xxx_brd_tbl[spec->board_config]); | |
4896 | if (err < 0) { | |
4897 | stac92xx_free(codec); | |
4898 | return err; | |
d0513fc6 MR |
4899 | } |
4900 | ||
32ed3f46 MR |
4901 | switch (codec->vendor_id) { |
4902 | case 0x111d7604: | |
4903 | case 0x111d7605: | |
4904 | if (spec->board_config == STAC_92HD83XXX_PWR_REF) | |
4905 | break; | |
4906 | spec->num_pwrs = 0; | |
4907 | break; | |
4908 | } | |
4909 | ||
d0513fc6 MR |
4910 | err = stac92xx_parse_auto_config(codec, 0x1d, 0); |
4911 | if (!err) { | |
4912 | if (spec->board_config < 0) { | |
4913 | printk(KERN_WARNING "hda_codec: No auto-config is " | |
4914 | "available, default to model=ref\n"); | |
4915 | spec->board_config = STAC_92HD83XXX_REF; | |
4916 | goto again; | |
4917 | } | |
4918 | err = -EINVAL; | |
4919 | } | |
4920 | ||
4921 | if (err < 0) { | |
4922 | stac92xx_free(codec); | |
4923 | return err; | |
4924 | } | |
4925 | ||
4926 | codec->patch_ops = stac92xx_patch_ops; | |
4927 | ||
2d34e1b3 TI |
4928 | codec->proc_widget_hook = stac92hd_proc_hook; |
4929 | ||
d0513fc6 MR |
4930 | return 0; |
4931 | } | |
4932 | ||
4b33c767 MR |
4933 | static struct hda_input_mux stac92hd71bxx_dmux = { |
4934 | .num_items = 4, | |
4935 | .items = { | |
4936 | { "Analog Inputs", 0x00 }, | |
4937 | { "Mixer", 0x01 }, | |
4938 | { "Digital Mic 1", 0x02 }, | |
4939 | { "Digital Mic 2", 0x03 }, | |
4940 | } | |
4941 | }; | |
4942 | ||
e035b841 MR |
4943 | static int patch_stac92hd71bxx(struct hda_codec *codec) |
4944 | { | |
4945 | struct sigmatel_spec *spec; | |
ca8d33fc | 4946 | struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; |
e035b841 MR |
4947 | int err = 0; |
4948 | ||
4949 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
4950 | if (spec == NULL) | |
4951 | return -ENOMEM; | |
4952 | ||
4953 | codec->spec = spec; | |
8daaaa97 | 4954 | codec->patch_ops = stac92xx_patch_ops; |
e035b841 | 4955 | spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids); |
aafc4412 | 4956 | spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); |
e035b841 | 4957 | spec->pin_nids = stac92hd71bxx_pin_nids; |
4b33c767 MR |
4958 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux, |
4959 | sizeof(stac92hd71bxx_dmux)); | |
e035b841 MR |
4960 | spec->board_config = snd_hda_check_board_config(codec, |
4961 | STAC_92HD71BXX_MODELS, | |
4962 | stac92hd71bxx_models, | |
4963 | stac92hd71bxx_cfg_tbl); | |
4964 | again: | |
4965 | if (spec->board_config < 0) { | |
4966 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" | |
4967 | " STAC92HD71BXX, using BIOS defaults\n"); | |
4968 | err = stac92xx_save_bios_config_regs(codec); | |
af9f341a TI |
4969 | } else |
4970 | err = stac_save_pin_cfgs(codec, | |
4971 | stac92hd71bxx_brd_tbl[spec->board_config]); | |
4972 | if (err < 0) { | |
4973 | stac92xx_free(codec); | |
4974 | return err; | |
e035b841 MR |
4975 | } |
4976 | ||
41c3b648 TI |
4977 | if (spec->board_config > STAC_92HD71BXX_REF) { |
4978 | /* GPIO0 = EAPD */ | |
4979 | spec->gpio_mask = 0x01; | |
4980 | spec->gpio_dir = 0x01; | |
4981 | spec->gpio_data = 0x01; | |
4982 | } | |
4983 | ||
541eee87 MR |
4984 | switch (codec->vendor_id) { |
4985 | case 0x111d76b6: /* 4 Port without Analog Mixer */ | |
4986 | case 0x111d76b7: | |
4987 | case 0x111d76b4: /* 6 Port without Analog Mixer */ | |
4988 | case 0x111d76b5: | |
4989 | spec->mixer = stac92hd71bxx_mixer; | |
4990 | spec->init = stac92hd71bxx_core_init; | |
0ffa9807 | 4991 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
541eee87 | 4992 | break; |
aafc4412 | 4993 | case 0x111d7608: /* 5 Port with Analog Mixer */ |
8e5f262b TI |
4994 | switch (spec->board_config) { |
4995 | case STAC_HP_M4: | |
72474be6 | 4996 | /* Enable VREF power saving on GPIO1 detect */ |
c6e4c666 TI |
4997 | err = stac_add_event(spec, codec->afg, |
4998 | STAC_VREF_EVENT, 0x02); | |
4999 | if (err < 0) | |
5000 | return err; | |
c5d08bb5 | 5001 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
72474be6 MR |
5002 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); |
5003 | snd_hda_codec_write_cache(codec, codec->afg, 0, | |
74aeaabc | 5004 | AC_VERB_SET_UNSOLICITED_ENABLE, |
c6e4c666 | 5005 | AC_USRSP_EN | err); |
72474be6 MR |
5006 | spec->gpio_mask |= 0x02; |
5007 | break; | |
5008 | } | |
8daaaa97 | 5009 | if ((codec->revision_id & 0xf) == 0 || |
8c2f767b | 5010 | (codec->revision_id & 0xf) == 1) |
8daaaa97 | 5011 | spec->stream_delay = 40; /* 40 milliseconds */ |
8daaaa97 | 5012 | |
aafc4412 MR |
5013 | /* no output amps */ |
5014 | spec->num_pwrs = 0; | |
5015 | spec->mixer = stac92hd71bxx_analog_mixer; | |
4b33c767 | 5016 | spec->dinput_mux = &spec->private_dimux; |
aafc4412 MR |
5017 | |
5018 | /* disable VSW */ | |
5019 | spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; | |
ca8d33fc | 5020 | unmute_init++; |
af9f341a | 5021 | stac_change_pin_config(codec, 0xf, 0x40f000f0); |
aafc4412 MR |
5022 | break; |
5023 | case 0x111d7603: /* 6 Port with Analog Mixer */ | |
8c2f767b | 5024 | if ((codec->revision_id & 0xf) == 1) |
8daaaa97 | 5025 | spec->stream_delay = 40; /* 40 milliseconds */ |
8daaaa97 | 5026 | |
aafc4412 MR |
5027 | /* no output amps */ |
5028 | spec->num_pwrs = 0; | |
5029 | /* fallthru */ | |
541eee87 | 5030 | default: |
4b33c767 | 5031 | spec->dinput_mux = &spec->private_dimux; |
541eee87 MR |
5032 | spec->mixer = stac92hd71bxx_analog_mixer; |
5033 | spec->init = stac92hd71bxx_analog_core_init; | |
0ffa9807 | 5034 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
541eee87 MR |
5035 | } |
5036 | ||
ca8d33fc MR |
5037 | if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) |
5038 | snd_hda_sequence_write_cache(codec, unmute_init); | |
5039 | ||
4b33c767 | 5040 | spec->aloopback_mask = 0x50; |
541eee87 MR |
5041 | spec->aloopback_shift = 0; |
5042 | ||
8daaaa97 | 5043 | spec->powerdown_adcs = 1; |
1cd2224c | 5044 | spec->digbeep_nid = 0x26; |
e035b841 MR |
5045 | spec->mux_nids = stac92hd71bxx_mux_nids; |
5046 | spec->adc_nids = stac92hd71bxx_adc_nids; | |
5047 | spec->dmic_nids = stac92hd71bxx_dmic_nids; | |
e1f0d669 | 5048 | spec->dmux_nids = stac92hd71bxx_dmux_nids; |
d9737751 | 5049 | spec->smux_nids = stac92hd71bxx_smux_nids; |
aafc4412 | 5050 | spec->pwr_nids = stac92hd71bxx_pwr_nids; |
e035b841 MR |
5051 | |
5052 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); | |
5053 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); | |
e035b841 | 5054 | |
6a14f585 MR |
5055 | switch (spec->board_config) { |
5056 | case STAC_HP_M4: | |
6a14f585 | 5057 | /* enable internal microphone */ |
af9f341a | 5058 | stac_change_pin_config(codec, 0x0e, 0x01813040); |
b9aea715 MR |
5059 | stac92xx_auto_set_pinctl(codec, 0x0e, |
5060 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); | |
3a7abfd2 MR |
5061 | /* fallthru */ |
5062 | case STAC_DELL_M4_2: | |
5063 | spec->num_dmics = 0; | |
5064 | spec->num_smuxes = 0; | |
5065 | spec->num_dmuxes = 0; | |
5066 | break; | |
5067 | case STAC_DELL_M4_1: | |
5068 | case STAC_DELL_M4_3: | |
5069 | spec->num_dmics = 1; | |
5070 | spec->num_smuxes = 0; | |
5071 | spec->num_dmuxes = 0; | |
6a14f585 MR |
5072 | break; |
5073 | default: | |
5074 | spec->num_dmics = STAC92HD71BXX_NUM_DMICS; | |
5075 | spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids); | |
5076 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); | |
5077 | }; | |
5078 | ||
c21ca4a8 | 5079 | spec->multiout.dac_nids = spec->dac_nids; |
4b33c767 MR |
5080 | if (spec->dinput_mux) |
5081 | spec->private_dimux.num_items += | |
5082 | spec->num_dmics - | |
5083 | (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1); | |
e035b841 MR |
5084 | |
5085 | err = stac92xx_parse_auto_config(codec, 0x21, 0x23); | |
5086 | if (!err) { | |
5087 | if (spec->board_config < 0) { | |
5088 | printk(KERN_WARNING "hda_codec: No auto-config is " | |
5089 | "available, default to model=ref\n"); | |
5090 | spec->board_config = STAC_92HD71BXX_REF; | |
5091 | goto again; | |
5092 | } | |
5093 | err = -EINVAL; | |
5094 | } | |
5095 | ||
5096 | if (err < 0) { | |
5097 | stac92xx_free(codec); | |
5098 | return err; | |
5099 | } | |
5100 | ||
2d34e1b3 TI |
5101 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
5102 | ||
e035b841 MR |
5103 | return 0; |
5104 | }; | |
5105 | ||
2f2f4251 M |
5106 | static int patch_stac922x(struct hda_codec *codec) |
5107 | { | |
5108 | struct sigmatel_spec *spec; | |
c7d4b2fa | 5109 | int err; |
2f2f4251 | 5110 | |
e560d8d8 | 5111 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
2f2f4251 M |
5112 | if (spec == NULL) |
5113 | return -ENOMEM; | |
5114 | ||
5115 | codec->spec = spec; | |
a4eed138 | 5116 | spec->num_pins = ARRAY_SIZE(stac922x_pin_nids); |
11b44bbd | 5117 | spec->pin_nids = stac922x_pin_nids; |
f5fcc13c TI |
5118 | spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, |
5119 | stac922x_models, | |
5120 | stac922x_cfg_tbl); | |
536319af | 5121 | if (spec->board_config == STAC_INTEL_MAC_AUTO) { |
4fe5195c MR |
5122 | spec->gpio_mask = spec->gpio_dir = 0x03; |
5123 | spec->gpio_data = 0x03; | |
3fc24d85 TI |
5124 | /* Intel Macs have all same PCI SSID, so we need to check |
5125 | * codec SSID to distinguish the exact models | |
5126 | */ | |
6f0778d8 | 5127 | printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id); |
3fc24d85 | 5128 | switch (codec->subsystem_id) { |
5d5d3bc3 IZ |
5129 | |
5130 | case 0x106b0800: | |
5131 | spec->board_config = STAC_INTEL_MAC_V1; | |
c45e20eb | 5132 | break; |
5d5d3bc3 IZ |
5133 | case 0x106b0600: |
5134 | case 0x106b0700: | |
5135 | spec->board_config = STAC_INTEL_MAC_V2; | |
6f0778d8 | 5136 | break; |
5d5d3bc3 IZ |
5137 | case 0x106b0e00: |
5138 | case 0x106b0f00: | |
5139 | case 0x106b1600: | |
5140 | case 0x106b1700: | |
5141 | case 0x106b0200: | |
5142 | case 0x106b1e00: | |
5143 | spec->board_config = STAC_INTEL_MAC_V3; | |
3fc24d85 | 5144 | break; |
5d5d3bc3 IZ |
5145 | case 0x106b1a00: |
5146 | case 0x00000100: | |
5147 | spec->board_config = STAC_INTEL_MAC_V4; | |
f16928fb | 5148 | break; |
5d5d3bc3 IZ |
5149 | case 0x106b0a00: |
5150 | case 0x106b2200: | |
5151 | spec->board_config = STAC_INTEL_MAC_V5; | |
0dae0f83 | 5152 | break; |
536319af NB |
5153 | default: |
5154 | spec->board_config = STAC_INTEL_MAC_V3; | |
5155 | break; | |
3fc24d85 TI |
5156 | } |
5157 | } | |
5158 | ||
9e507abd | 5159 | again: |
11b44bbd RF |
5160 | if (spec->board_config < 0) { |
5161 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " | |
5162 | "using BIOS defaults\n"); | |
5163 | err = stac92xx_save_bios_config_regs(codec); | |
af9f341a TI |
5164 | } else |
5165 | err = stac_save_pin_cfgs(codec, | |
5166 | stac922x_brd_tbl[spec->board_config]); | |
5167 | if (err < 0) { | |
5168 | stac92xx_free(codec); | |
5169 | return err; | |
403d1944 | 5170 | } |
2f2f4251 | 5171 | |
c7d4b2fa M |
5172 | spec->adc_nids = stac922x_adc_nids; |
5173 | spec->mux_nids = stac922x_mux_nids; | |
2549413e | 5174 | spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); |
9e05b7a3 | 5175 | spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids); |
8b65727b | 5176 | spec->num_dmics = 0; |
a64135a2 | 5177 | spec->num_pwrs = 0; |
c7d4b2fa M |
5178 | |
5179 | spec->init = stac922x_core_init; | |
2f2f4251 | 5180 | spec->mixer = stac922x_mixer; |
c7d4b2fa M |
5181 | |
5182 | spec->multiout.dac_nids = spec->dac_nids; | |
19039bd0 | 5183 | |
3cc08dc6 | 5184 | err = stac92xx_parse_auto_config(codec, 0x08, 0x09); |
9e507abd TI |
5185 | if (!err) { |
5186 | if (spec->board_config < 0) { | |
5187 | printk(KERN_WARNING "hda_codec: No auto-config is " | |
5188 | "available, default to model=ref\n"); | |
5189 | spec->board_config = STAC_D945_REF; | |
5190 | goto again; | |
5191 | } | |
5192 | err = -EINVAL; | |
5193 | } | |
3cc08dc6 MP |
5194 | if (err < 0) { |
5195 | stac92xx_free(codec); | |
5196 | return err; | |
5197 | } | |
5198 | ||
5199 | codec->patch_ops = stac92xx_patch_ops; | |
5200 | ||
807a4636 TI |
5201 | /* Fix Mux capture level; max to 2 */ |
5202 | snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT, | |
5203 | (0 << AC_AMPCAP_OFFSET_SHIFT) | | |
5204 | (2 << AC_AMPCAP_NUM_STEPS_SHIFT) | | |
5205 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | | |
5206 | (0 << AC_AMPCAP_MUTE_SHIFT)); | |
5207 | ||
3cc08dc6 MP |
5208 | return 0; |
5209 | } | |
5210 | ||
5211 | static int patch_stac927x(struct hda_codec *codec) | |
5212 | { | |
5213 | struct sigmatel_spec *spec; | |
5214 | int err; | |
5215 | ||
5216 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
5217 | if (spec == NULL) | |
5218 | return -ENOMEM; | |
5219 | ||
5220 | codec->spec = spec; | |
a4eed138 | 5221 | spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); |
11b44bbd | 5222 | spec->pin_nids = stac927x_pin_nids; |
f5fcc13c TI |
5223 | spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, |
5224 | stac927x_models, | |
5225 | stac927x_cfg_tbl); | |
9e507abd | 5226 | again: |
8e9068b1 MR |
5227 | if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) { |
5228 | if (spec->board_config < 0) | |
5229 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" | |
5230 | "STAC927x, using BIOS defaults\n"); | |
11b44bbd | 5231 | err = stac92xx_save_bios_config_regs(codec); |
af9f341a TI |
5232 | } else |
5233 | err = stac_save_pin_cfgs(codec, | |
5234 | stac927x_brd_tbl[spec->board_config]); | |
5235 | if (err < 0) { | |
5236 | stac92xx_free(codec); | |
5237 | return err; | |
3cc08dc6 MP |
5238 | } |
5239 | ||
1cd2224c | 5240 | spec->digbeep_nid = 0x23; |
8e9068b1 MR |
5241 | spec->adc_nids = stac927x_adc_nids; |
5242 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); | |
5243 | spec->mux_nids = stac927x_mux_nids; | |
5244 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); | |
d9737751 MR |
5245 | spec->smux_nids = stac927x_smux_nids; |
5246 | spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids); | |
65973632 | 5247 | spec->spdif_labels = stac927x_spdif_labels; |
b76c850f | 5248 | spec->dac_list = stac927x_dac_nids; |
8e9068b1 MR |
5249 | spec->multiout.dac_nids = spec->dac_nids; |
5250 | ||
81d3dbde | 5251 | switch (spec->board_config) { |
93ed1503 | 5252 | case STAC_D965_3ST: |
93ed1503 | 5253 | case STAC_D965_5ST: |
8e9068b1 | 5254 | /* GPIO0 High = Enable EAPD */ |
0fc9dec4 | 5255 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01; |
4fe5195c | 5256 | spec->gpio_data = 0x01; |
8e9068b1 MR |
5257 | spec->num_dmics = 0; |
5258 | ||
93ed1503 | 5259 | spec->init = d965_core_init; |
9e05b7a3 | 5260 | spec->mixer = stac927x_mixer; |
81d3dbde | 5261 | break; |
8e9068b1 | 5262 | case STAC_DELL_BIOS: |
780c8be4 MR |
5263 | switch (codec->subsystem_id) { |
5264 | case 0x10280209: | |
5265 | case 0x1028022e: | |
5266 | /* correct the device field to SPDIF out */ | |
af9f341a | 5267 | stac_change_pin_config(codec, 0x21, 0x01442070); |
780c8be4 MR |
5268 | break; |
5269 | }; | |
03d7ca17 | 5270 | /* configure the analog microphone on some laptops */ |
af9f341a | 5271 | stac_change_pin_config(codec, 0x0c, 0x90a79130); |
2f32d909 | 5272 | /* correct the front output jack as a hp out */ |
af9f341a | 5273 | stac_change_pin_config(codec, 0x0f, 0x0227011f); |
c481fca3 | 5274 | /* correct the front input jack as a mic */ |
af9f341a | 5275 | stac_change_pin_config(codec, 0x0e, 0x02a79130); |
c481fca3 | 5276 | /* fallthru */ |
8e9068b1 MR |
5277 | case STAC_DELL_3ST: |
5278 | /* GPIO2 High = Enable EAPD */ | |
0fc9dec4 | 5279 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04; |
4fe5195c | 5280 | spec->gpio_data = 0x04; |
7f16859a MR |
5281 | spec->dmic_nids = stac927x_dmic_nids; |
5282 | spec->num_dmics = STAC927X_NUM_DMICS; | |
f1f208d0 | 5283 | |
8e9068b1 MR |
5284 | spec->init = d965_core_init; |
5285 | spec->mixer = stac927x_mixer; | |
5286 | spec->dmux_nids = stac927x_dmux_nids; | |
1697055e | 5287 | spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); |
7f16859a MR |
5288 | break; |
5289 | default: | |
b2c4f4d7 MR |
5290 | if (spec->board_config > STAC_D965_REF) { |
5291 | /* GPIO0 High = Enable EAPD */ | |
5292 | spec->eapd_mask = spec->gpio_mask = 0x01; | |
5293 | spec->gpio_dir = spec->gpio_data = 0x01; | |
5294 | } | |
8e9068b1 MR |
5295 | spec->num_dmics = 0; |
5296 | ||
5297 | spec->init = stac927x_core_init; | |
5298 | spec->mixer = stac927x_mixer; | |
7f16859a MR |
5299 | } |
5300 | ||
a64135a2 | 5301 | spec->num_pwrs = 0; |
e1f0d669 MR |
5302 | spec->aloopback_mask = 0x40; |
5303 | spec->aloopback_shift = 0; | |
c0cea0d0 | 5304 | spec->eapd_switch = 1; |
8e9068b1 | 5305 | |
3cc08dc6 | 5306 | err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); |
9e507abd TI |
5307 | if (!err) { |
5308 | if (spec->board_config < 0) { | |
5309 | printk(KERN_WARNING "hda_codec: No auto-config is " | |
5310 | "available, default to model=ref\n"); | |
5311 | spec->board_config = STAC_D965_REF; | |
5312 | goto again; | |
5313 | } | |
5314 | err = -EINVAL; | |
5315 | } | |
c7d4b2fa M |
5316 | if (err < 0) { |
5317 | stac92xx_free(codec); | |
5318 | return err; | |
5319 | } | |
2f2f4251 M |
5320 | |
5321 | codec->patch_ops = stac92xx_patch_ops; | |
5322 | ||
2d34e1b3 TI |
5323 | codec->proc_widget_hook = stac927x_proc_hook; |
5324 | ||
52987656 TI |
5325 | /* |
5326 | * !!FIXME!! | |
5327 | * The STAC927x seem to require fairly long delays for certain | |
5328 | * command sequences. With too short delays (even if the answer | |
5329 | * is set to RIRB properly), it results in the silence output | |
5330 | * on some hardwares like Dell. | |
5331 | * | |
5332 | * The below flag enables the longer delay (see get_response | |
5333 | * in hda_intel.c). | |
5334 | */ | |
5335 | codec->bus->needs_damn_long_delay = 1; | |
5336 | ||
e28d8322 TI |
5337 | /* no jack detecion for ref-no-jd model */ |
5338 | if (spec->board_config == STAC_D965_REF_NO_JD) | |
5339 | spec->hp_detect = 0; | |
5340 | ||
2f2f4251 M |
5341 | return 0; |
5342 | } | |
5343 | ||
f3302a59 MP |
5344 | static int patch_stac9205(struct hda_codec *codec) |
5345 | { | |
5346 | struct sigmatel_spec *spec; | |
8259980e | 5347 | int err; |
f3302a59 MP |
5348 | |
5349 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | |
5350 | if (spec == NULL) | |
5351 | return -ENOMEM; | |
5352 | ||
5353 | codec->spec = spec; | |
a4eed138 | 5354 | spec->num_pins = ARRAY_SIZE(stac9205_pin_nids); |
11b44bbd | 5355 | spec->pin_nids = stac9205_pin_nids; |
f5fcc13c TI |
5356 | spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, |
5357 | stac9205_models, | |
5358 | stac9205_cfg_tbl); | |
9e507abd | 5359 | again: |
11b44bbd RF |
5360 | if (spec->board_config < 0) { |
5361 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); | |
5362 | err = stac92xx_save_bios_config_regs(codec); | |
af9f341a TI |
5363 | } else |
5364 | err = stac_save_pin_cfgs(codec, | |
5365 | stac9205_brd_tbl[spec->board_config]); | |
5366 | if (err < 0) { | |
5367 | stac92xx_free(codec); | |
5368 | return err; | |
f3302a59 MP |
5369 | } |
5370 | ||
1cd2224c | 5371 | spec->digbeep_nid = 0x23; |
f3302a59 | 5372 | spec->adc_nids = stac9205_adc_nids; |
9e05b7a3 | 5373 | spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids); |
f3302a59 | 5374 | spec->mux_nids = stac9205_mux_nids; |
2549413e | 5375 | spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); |
d9737751 MR |
5376 | spec->smux_nids = stac9205_smux_nids; |
5377 | spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids); | |
8b65727b | 5378 | spec->dmic_nids = stac9205_dmic_nids; |
f6e9852a | 5379 | spec->num_dmics = STAC9205_NUM_DMICS; |
e1f0d669 | 5380 | spec->dmux_nids = stac9205_dmux_nids; |
1697055e | 5381 | spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids); |
a64135a2 | 5382 | spec->num_pwrs = 0; |
f3302a59 MP |
5383 | |
5384 | spec->init = stac9205_core_init; | |
5385 | spec->mixer = stac9205_mixer; | |
5386 | ||
e1f0d669 MR |
5387 | spec->aloopback_mask = 0x40; |
5388 | spec->aloopback_shift = 0; | |
d9a4268e TI |
5389 | /* Turn on/off EAPD per HP plugging */ |
5390 | if (spec->board_config != STAC_9205_EAPD) | |
5391 | spec->eapd_switch = 1; | |
f3302a59 | 5392 | spec->multiout.dac_nids = spec->dac_nids; |
87d48363 | 5393 | |
ae0a8ed8 | 5394 | switch (spec->board_config){ |
ae0a8ed8 | 5395 | case STAC_9205_DELL_M43: |
87d48363 | 5396 | /* Enable SPDIF in/out */ |
af9f341a TI |
5397 | stac_change_pin_config(codec, 0x1f, 0x01441030); |
5398 | stac_change_pin_config(codec, 0x20, 0x1c410030); | |
87d48363 | 5399 | |
4fe5195c | 5400 | /* Enable unsol response for GPIO4/Dock HP connection */ |
c6e4c666 TI |
5401 | err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01); |
5402 | if (err < 0) | |
5403 | return err; | |
c5d08bb5 | 5404 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
4fe5195c MR |
5405 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); |
5406 | snd_hda_codec_write_cache(codec, codec->afg, 0, | |
c6e4c666 TI |
5407 | AC_VERB_SET_UNSOLICITED_ENABLE, |
5408 | AC_USRSP_EN | err); | |
4fe5195c MR |
5409 | |
5410 | spec->gpio_dir = 0x0b; | |
0fc9dec4 | 5411 | spec->eapd_mask = 0x01; |
4fe5195c MR |
5412 | spec->gpio_mask = 0x1b; |
5413 | spec->gpio_mute = 0x10; | |
e2e7d624 | 5414 | /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute, |
4fe5195c | 5415 | * GPIO3 Low = DRM |
87d48363 | 5416 | */ |
4fe5195c | 5417 | spec->gpio_data = 0x01; |
ae0a8ed8 | 5418 | break; |
b2c4f4d7 MR |
5419 | case STAC_9205_REF: |
5420 | /* SPDIF-In enabled */ | |
5421 | break; | |
ae0a8ed8 TD |
5422 | default: |
5423 | /* GPIO0 High = EAPD */ | |
0fc9dec4 | 5424 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
4fe5195c | 5425 | spec->gpio_data = 0x01; |
ae0a8ed8 TD |
5426 | break; |
5427 | } | |
33382403 | 5428 | |
f3302a59 | 5429 | err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); |
9e507abd TI |
5430 | if (!err) { |
5431 | if (spec->board_config < 0) { | |
5432 | printk(KERN_WARNING "hda_codec: No auto-config is " | |
5433 | "available, default to model=ref\n"); | |
5434 | spec->board_config = STAC_9205_REF; | |
5435 | goto again; | |
5436 | } | |
5437 | err = -EINVAL; | |
5438 | } | |
f3302a59 MP |
5439 | if (err < 0) { |
5440 | stac92xx_free(codec); | |
5441 | return err; | |
5442 | } | |
5443 | ||
5444 | codec->patch_ops = stac92xx_patch_ops; | |
5445 | ||
2d34e1b3 TI |
5446 | codec->proc_widget_hook = stac9205_proc_hook; |
5447 | ||
f3302a59 MP |
5448 | return 0; |
5449 | } | |
5450 | ||
db064e50 | 5451 | /* |
6d859065 | 5452 | * STAC9872 hack |
db064e50 TI |
5453 | */ |
5454 | ||
1e137f92 | 5455 | static struct hda_verb stac9872_core_init[] = { |
1624cb9a | 5456 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */ |
6d859065 GM |
5457 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
5458 | {} | |
5459 | }; | |
5460 | ||
caa10b6e TI |
5461 | static struct snd_kcontrol_new stac9872_mixer[] = { |
5462 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), | |
5463 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), | |
caa10b6e TI |
5464 | { } /* end */ |
5465 | }; | |
5466 | ||
5467 | static hda_nid_t stac9872_pin_nids[] = { | |
5468 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, | |
5469 | 0x11, 0x13, 0x14, | |
5470 | }; | |
5471 | ||
5472 | static hda_nid_t stac9872_adc_nids[] = { | |
5473 | 0x8 /*,0x6*/ | |
5474 | }; | |
5475 | ||
5476 | static hda_nid_t stac9872_mux_nids[] = { | |
5477 | 0x15 | |
5478 | }; | |
5479 | ||
6d859065 | 5480 | static int patch_stac9872(struct hda_codec *codec) |
db064e50 TI |
5481 | { |
5482 | struct sigmatel_spec *spec; | |
1e137f92 | 5483 | int err; |
db064e50 | 5484 | |
db064e50 TI |
5485 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
5486 | if (spec == NULL) | |
5487 | return -ENOMEM; | |
db064e50 | 5488 | codec->spec = spec; |
caa10b6e | 5489 | |
1e137f92 | 5490 | #if 0 /* no model right now */ |
caa10b6e TI |
5491 | spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, |
5492 | stac9872_models, | |
5493 | stac9872_cfg_tbl); | |
1e137f92 | 5494 | #endif |
db064e50 | 5495 | |
1e137f92 TI |
5496 | spec->num_pins = ARRAY_SIZE(stac9872_pin_nids); |
5497 | spec->pin_nids = stac9872_pin_nids; | |
5498 | spec->multiout.dac_nids = spec->dac_nids; | |
5499 | spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids); | |
5500 | spec->adc_nids = stac9872_adc_nids; | |
5501 | spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); | |
5502 | spec->mux_nids = stac9872_mux_nids; | |
5503 | spec->mixer = stac9872_mixer; | |
5504 | spec->init = stac9872_core_init; | |
5505 | ||
5506 | err = stac92xx_parse_auto_config(codec, 0x10, 0x12); | |
5507 | if (err < 0) { | |
5508 | stac92xx_free(codec); | |
5509 | return -EINVAL; | |
5510 | } | |
5511 | spec->input_mux = &spec->private_imux; | |
5512 | codec->patch_ops = stac92xx_patch_ops; | |
db064e50 TI |
5513 | return 0; |
5514 | } | |
5515 | ||
5516 | ||
2f2f4251 M |
5517 | /* |
5518 | * patch entries | |
5519 | */ | |
1289e9e8 | 5520 | static struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
2f2f4251 M |
5521 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
5522 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, | |
5523 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, | |
5524 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, | |
5525 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, | |
5526 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, | |
5527 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, | |
22a27c7f MP |
5528 | { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, |
5529 | { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, | |
5530 | { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, | |
5531 | { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, | |
5532 | { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, | |
5533 | { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, | |
3cc08dc6 MP |
5534 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
5535 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, | |
5536 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, | |
5537 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, | |
5538 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, | |
5539 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, | |
5540 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, | |
5541 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, | |
5542 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, | |
5543 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, | |
8e21c34c TD |
5544 | { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x }, |
5545 | { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x }, | |
5546 | { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x }, | |
5547 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, | |
5548 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, | |
5549 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, | |
7bd3c0f7 TI |
5550 | { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x }, |
5551 | { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x }, | |
6d859065 GM |
5552 | /* The following does not take into account .id=0x83847661 when subsys = |
5553 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are | |
5554 | * currently not fully supported. | |
5555 | */ | |
5556 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, | |
5557 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, | |
5558 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, | |
f3302a59 MP |
5559 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
5560 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, | |
5561 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, | |
5562 | { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, | |
5563 | { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, | |
5564 | { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, | |
5565 | { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, | |
5566 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, | |
aafc4412 | 5567 | { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, |
d0513fc6 MR |
5568 | { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, |
5569 | { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, | |
aafc4412 | 5570 | { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, |
541eee87 MR |
5571 | { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, |
5572 | { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, | |
e1f0d669 | 5573 | { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx }, |
541eee87 MR |
5574 | { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
5575 | { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, | |
5576 | { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, | |
5577 | { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, | |
5578 | { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, | |
5579 | { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, | |
5580 | { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, | |
5581 | { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, | |
2f2f4251 M |
5582 | {} /* terminator */ |
5583 | }; | |
1289e9e8 TI |
5584 | |
5585 | MODULE_ALIAS("snd-hda-codec-id:8384*"); | |
5586 | MODULE_ALIAS("snd-hda-codec-id:111d*"); | |
5587 | ||
5588 | MODULE_LICENSE("GPL"); | |
5589 | MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec"); | |
5590 | ||
5591 | static struct hda_codec_preset_list sigmatel_list = { | |
5592 | .preset = snd_hda_preset_sigmatel, | |
5593 | .owner = THIS_MODULE, | |
5594 | }; | |
5595 | ||
5596 | static int __init patch_sigmatel_init(void) | |
5597 | { | |
5598 | return snd_hda_add_codec_preset(&sigmatel_list); | |
5599 | } | |
5600 | ||
5601 | static void __exit patch_sigmatel_exit(void) | |
5602 | { | |
5603 | snd_hda_delete_codec_preset(&sigmatel_list); | |
5604 | } | |
5605 | ||
5606 | module_init(patch_sigmatel_init) | |
5607 | module_exit(patch_sigmatel_exit) |