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