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