a39fbd89a9850d4f6e20e6fcdebd2c81e418e449
[deliverable/linux.git] / sound / pci / hda / patch_sigmatel.c
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.
7 * Matt Porter <mporter@embeddedalley.com>
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
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>
32 #include <sound/asoundef.h>
33 #include "hda_codec.h"
34 #include "hda_local.h"
35 #include "hda_patch.h"
36
37 #define NUM_CONTROL_ALLOC 32
38 #define STAC_PWR_EVENT 0x20
39 #define STAC_HP_EVENT 0x30
40
41 enum {
42 STAC_REF,
43 STAC_9200_OQO,
44 STAC_9200_DELL_D21,
45 STAC_9200_DELL_D22,
46 STAC_9200_DELL_D23,
47 STAC_9200_DELL_M21,
48 STAC_9200_DELL_M22,
49 STAC_9200_DELL_M23,
50 STAC_9200_DELL_M24,
51 STAC_9200_DELL_M25,
52 STAC_9200_DELL_M26,
53 STAC_9200_DELL_M27,
54 STAC_9200_GATEWAY,
55 STAC_9200_PANASONIC,
56 STAC_9200_MODELS
57 };
58
59 enum {
60 STAC_9205_REF,
61 STAC_9205_DELL_M42,
62 STAC_9205_DELL_M43,
63 STAC_9205_DELL_M44,
64 STAC_9205_MODELS
65 };
66
67 enum {
68 STAC_92HD73XX_REF,
69 STAC_DELL_M6,
70 STAC_92HD73XX_MODELS
71 };
72
73 enum {
74 STAC_92HD71BXX_REF,
75 STAC_DELL_M4_1,
76 STAC_DELL_M4_2,
77 STAC_92HD71BXX_MODELS
78 };
79
80 enum {
81 STAC_925x_REF,
82 STAC_M2_2,
83 STAC_MA6,
84 STAC_PA6,
85 STAC_925x_MODELS
86 };
87
88 enum {
89 STAC_D945_REF,
90 STAC_D945GTP3,
91 STAC_D945GTP5,
92 STAC_INTEL_MAC_V1,
93 STAC_INTEL_MAC_V2,
94 STAC_INTEL_MAC_V3,
95 STAC_INTEL_MAC_V4,
96 STAC_INTEL_MAC_V5,
97 /* for backward compatibility */
98 STAC_MACMINI,
99 STAC_MACBOOK,
100 STAC_MACBOOK_PRO_V1,
101 STAC_MACBOOK_PRO_V2,
102 STAC_IMAC_INTEL,
103 STAC_IMAC_INTEL_20,
104 STAC_922X_DELL_D81,
105 STAC_922X_DELL_D82,
106 STAC_922X_DELL_M81,
107 STAC_922X_DELL_M82,
108 STAC_922X_MODELS
109 };
110
111 enum {
112 STAC_D965_REF,
113 STAC_D965_3ST,
114 STAC_D965_5ST,
115 STAC_DELL_3ST,
116 STAC_DELL_BIOS,
117 STAC_927X_MODELS
118 };
119
120 struct sigmatel_spec {
121 struct snd_kcontrol_new *mixers[4];
122 unsigned int num_mixers;
123
124 int board_config;
125 unsigned int surr_switch: 1;
126 unsigned int line_switch: 1;
127 unsigned int mic_switch: 1;
128 unsigned int alt_switch: 1;
129 unsigned int hp_detect: 1;
130
131 /* gpio lines */
132 unsigned int gpio_mask;
133 unsigned int gpio_dir;
134 unsigned int gpio_data;
135 unsigned int gpio_mute;
136
137 /* analog loopback */
138 unsigned char aloopback_mask;
139 unsigned char aloopback_shift;
140
141 /* power management */
142 unsigned int num_pwrs;
143 hda_nid_t *pwr_nids;
144 hda_nid_t *dac_list;
145
146 /* playback */
147 struct hda_input_mux *mono_mux;
148 unsigned int cur_mmux;
149 struct hda_multi_out multiout;
150 hda_nid_t dac_nids[5];
151
152 /* capture */
153 hda_nid_t *adc_nids;
154 unsigned int num_adcs;
155 hda_nid_t *mux_nids;
156 unsigned int num_muxes;
157 hda_nid_t *dmic_nids;
158 unsigned int num_dmics;
159 hda_nid_t *dmux_nids;
160 unsigned int num_dmuxes;
161 hda_nid_t dig_in_nid;
162 hda_nid_t mono_nid;
163
164 /* pin widgets */
165 hda_nid_t *pin_nids;
166 unsigned int num_pins;
167 unsigned int *pin_configs;
168 unsigned int *bios_pin_configs;
169
170 /* codec specific stuff */
171 struct hda_verb *init;
172 struct snd_kcontrol_new *mixer;
173
174 /* capture source */
175 struct hda_input_mux *dinput_mux;
176 unsigned int cur_dmux[2];
177 struct hda_input_mux *input_mux;
178 unsigned int cur_mux[3];
179
180 /* i/o switches */
181 unsigned int io_switch[2];
182 unsigned int clfe_swap;
183 unsigned int aloopback;
184
185 struct hda_pcm pcm_rec[2]; /* PCM information */
186
187 /* dynamic controls and input_mux */
188 struct auto_pin_cfg autocfg;
189 unsigned int num_kctl_alloc, num_kctl_used;
190 struct snd_kcontrol_new *kctl_alloc;
191 struct hda_input_mux private_dimux;
192 struct hda_input_mux private_imux;
193 struct hda_input_mux private_mono_mux;
194 };
195
196 static hda_nid_t stac9200_adc_nids[1] = {
197 0x03,
198 };
199
200 static hda_nid_t stac9200_mux_nids[1] = {
201 0x0c,
202 };
203
204 static hda_nid_t stac9200_dac_nids[1] = {
205 0x02,
206 };
207
208 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
209 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
210 0x0f, 0x10, 0x11
211 };
212
213 static hda_nid_t stac92hd73xx_adc_nids[2] = {
214 0x1a, 0x1b
215 };
216
217 #define STAC92HD73XX_NUM_DMICS 2
218 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
219 0x13, 0x14, 0
220 };
221
222 #define STAC92HD73_DAC_COUNT 5
223 static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
224 0x15, 0x16, 0x17, 0x18, 0x19,
225 };
226
227 static hda_nid_t stac92hd73xx_mux_nids[4] = {
228 0x28, 0x29, 0x2a, 0x2b,
229 };
230
231 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
232 0x20, 0x21,
233 };
234
235 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
236 0x0a, 0x0d, 0x0f
237 };
238
239 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
240 0x12, 0x13,
241 };
242
243 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
244 0x1a, 0x1b
245 };
246
247 static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
248 0x1c,
249 };
250
251 static hda_nid_t stac92hd71bxx_dac_nids[1] = {
252 0x10, /*0x11, */
253 };
254
255 #define STAC92HD71BXX_NUM_DMICS 2
256 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
257 0x18, 0x19, 0
258 };
259
260 static hda_nid_t stac925x_adc_nids[1] = {
261 0x03,
262 };
263
264 static hda_nid_t stac925x_mux_nids[1] = {
265 0x0f,
266 };
267
268 static hda_nid_t stac925x_dac_nids[1] = {
269 0x02,
270 };
271
272 #define STAC925X_NUM_DMICS 1
273 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
274 0x15, 0
275 };
276
277 static hda_nid_t stac925x_dmux_nids[1] = {
278 0x14,
279 };
280
281 static hda_nid_t stac922x_adc_nids[2] = {
282 0x06, 0x07,
283 };
284
285 static hda_nid_t stac922x_mux_nids[2] = {
286 0x12, 0x13,
287 };
288
289 static hda_nid_t stac927x_adc_nids[3] = {
290 0x07, 0x08, 0x09
291 };
292
293 static hda_nid_t stac927x_mux_nids[3] = {
294 0x15, 0x16, 0x17
295 };
296
297 static hda_nid_t stac927x_dac_nids[6] = {
298 0x02, 0x03, 0x04, 0x05, 0x06, 0
299 };
300
301 static hda_nid_t stac927x_dmux_nids[1] = {
302 0x1b,
303 };
304
305 #define STAC927X_NUM_DMICS 2
306 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
307 0x13, 0x14, 0
308 };
309
310 static hda_nid_t stac9205_adc_nids[2] = {
311 0x12, 0x13
312 };
313
314 static hda_nid_t stac9205_mux_nids[2] = {
315 0x19, 0x1a
316 };
317
318 static hda_nid_t stac9205_dmux_nids[1] = {
319 0x1d,
320 };
321
322 #define STAC9205_NUM_DMICS 2
323 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
324 0x17, 0x18, 0
325 };
326
327 static hda_nid_t stac9200_pin_nids[8] = {
328 0x08, 0x09, 0x0d, 0x0e,
329 0x0f, 0x10, 0x11, 0x12,
330 };
331
332 static hda_nid_t stac925x_pin_nids[8] = {
333 0x07, 0x08, 0x0a, 0x0b,
334 0x0c, 0x0d, 0x10, 0x11,
335 };
336
337 static hda_nid_t stac922x_pin_nids[10] = {
338 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
339 0x0f, 0x10, 0x11, 0x15, 0x1b,
340 };
341
342 static hda_nid_t stac92hd73xx_pin_nids[13] = {
343 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
344 0x0f, 0x10, 0x11, 0x12, 0x13,
345 0x14, 0x1e, 0x22
346 };
347
348 static hda_nid_t stac92hd71bxx_pin_nids[10] = {
349 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
350 0x0f, 0x14, 0x18, 0x19, 0x1e,
351 };
352
353 static hda_nid_t stac927x_pin_nids[14] = {
354 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
355 0x0f, 0x10, 0x11, 0x12, 0x13,
356 0x14, 0x21, 0x22, 0x23,
357 };
358
359 static hda_nid_t stac9205_pin_nids[12] = {
360 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
361 0x0f, 0x14, 0x16, 0x17, 0x18,
362 0x21, 0x22,
363 };
364
365 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
366 struct snd_ctl_elem_info *uinfo)
367 {
368 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
369 struct sigmatel_spec *spec = codec->spec;
370 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
371 }
372
373 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
374 struct snd_ctl_elem_value *ucontrol)
375 {
376 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
377 struct sigmatel_spec *spec = codec->spec;
378 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
379
380 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
381 return 0;
382 }
383
384 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
385 struct snd_ctl_elem_value *ucontrol)
386 {
387 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
388 struct sigmatel_spec *spec = codec->spec;
389 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
390
391 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
392 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
393 }
394
395 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
396 {
397 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
398 struct sigmatel_spec *spec = codec->spec;
399 return snd_hda_input_mux_info(spec->input_mux, uinfo);
400 }
401
402 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
403 {
404 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
405 struct sigmatel_spec *spec = codec->spec;
406 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
407
408 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
409 return 0;
410 }
411
412 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
413 {
414 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
415 struct sigmatel_spec *spec = codec->spec;
416 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
417
418 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
419 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
420 }
421
422 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
423 struct snd_ctl_elem_info *uinfo)
424 {
425 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
426 struct sigmatel_spec *spec = codec->spec;
427 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
428 }
429
430 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
431 struct snd_ctl_elem_value *ucontrol)
432 {
433 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
434 struct sigmatel_spec *spec = codec->spec;
435
436 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
437 return 0;
438 }
439
440 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
441 struct snd_ctl_elem_value *ucontrol)
442 {
443 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
444 struct sigmatel_spec *spec = codec->spec;
445
446 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
447 spec->mono_nid, &spec->cur_mmux);
448 }
449
450 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
451
452 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
453 struct snd_ctl_elem_value *ucontrol)
454 {
455 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
456 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
457 struct sigmatel_spec *spec = codec->spec;
458
459 ucontrol->value.integer.value[0] = !!(spec->aloopback &
460 (spec->aloopback_mask << idx));
461 return 0;
462 }
463
464 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_value *ucontrol)
466 {
467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
468 struct sigmatel_spec *spec = codec->spec;
469 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
470 unsigned int dac_mode;
471 unsigned int val, idx_val;
472
473 idx_val = spec->aloopback_mask << idx;
474 if (ucontrol->value.integer.value[0])
475 val = spec->aloopback | idx_val;
476 else
477 val = spec->aloopback & ~idx_val;
478 if (spec->aloopback == val)
479 return 0;
480
481 spec->aloopback = val;
482
483 /* Only return the bits defined by the shift value of the
484 * first two bytes of the mask
485 */
486 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
487 kcontrol->private_value & 0xFFFF, 0x0);
488 dac_mode >>= spec->aloopback_shift;
489
490 if (spec->aloopback & idx_val) {
491 snd_hda_power_up(codec);
492 dac_mode |= idx_val;
493 } else {
494 snd_hda_power_down(codec);
495 dac_mode &= ~idx_val;
496 }
497
498 snd_hda_codec_write_cache(codec, codec->afg, 0,
499 kcontrol->private_value >> 16, dac_mode);
500
501 return 1;
502 }
503
504 static struct hda_verb stac9200_core_init[] = {
505 /* set dac0mux for dac converter */
506 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
507 {}
508 };
509
510 static struct hda_verb stac9200_eapd_init[] = {
511 /* set dac0mux for dac converter */
512 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
513 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
514 {}
515 };
516
517 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
518 /* set master volume and direct control */
519 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
520 /* setup audio connections */
521 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
522 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
523 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
524 /* setup adcs to point to mixer */
525 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
526 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
527 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
528 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
529 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
530 /* setup import muxs */
531 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
532 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
533 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
534 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
535 {}
536 };
537
538 static struct hda_verb dell_eq_core_init[] = {
539 /* set master volume to max value without distortion
540 * and direct control */
541 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
542 /* setup audio connections */
543 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
544 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
545 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
546 /* setup adcs to point to mixer */
547 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
548 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
549 /* setup import muxs */
550 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
551 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
552 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
553 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
554 {}
555 };
556
557 static struct hda_verb dell_m6_core_init[] = {
558 /* set master volume and direct control */
559 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
560 /* setup audio connections */
561 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
562 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
563 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
564 /* setup adcs to point to mixer */
565 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
566 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
567 /* setup import muxs */
568 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
569 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
570 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
571 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
572 {}
573 };
574
575 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
576 /* set master volume and direct control */
577 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
578 /* setup audio connections */
579 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
580 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
581 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
582 /* connect hp ports to dac3 */
583 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
584 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
585 /* setup adcs to point to mixer */
586 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
587 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
588 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
589 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
590 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
591 /* setup import muxs */
592 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
593 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
594 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
595 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
596 {}
597 };
598
599 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
600 /* set master volume and direct control */
601 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
602 /* setup audio connections */
603 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
604 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
605 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
606 /* dac3 is connected to import3 mux */
607 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
608 /* connect hp ports to dac4 */
609 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
610 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
611 /* setup adcs to point to mixer */
612 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
613 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
614 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
615 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
616 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
617 /* setup import muxs */
618 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
619 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
620 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
621 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
622 {}
623 };
624
625 static struct hda_verb stac92hd71bxx_core_init[] = {
626 /* set master volume and direct control */
627 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
628 /* connect headphone jack to dac1 */
629 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
630 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
631 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
632 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
633 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
634 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
635 };
636
637 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
638 /* set master volume and direct control */
639 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
640 /* connect headphone jack to dac1 */
641 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
642 /* connect ports 0d and 0f to audio mixer */
643 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
644 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
645 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
646 /* unmute dac0 input in audio mixer */
647 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
648 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
649 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
650 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
651 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
652 {}
653 };
654
655 static struct hda_verb stac925x_core_init[] = {
656 /* set dac0mux for dac converter */
657 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
658 {}
659 };
660
661 static struct hda_verb stac922x_core_init[] = {
662 /* set master volume and direct control */
663 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
664 {}
665 };
666
667 static struct hda_verb d965_core_init[] = {
668 /* set master volume and direct control */
669 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
670 /* unmute node 0x1b */
671 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
672 /* select node 0x03 as DAC */
673 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
674 {}
675 };
676
677 static struct hda_verb stac927x_core_init[] = {
678 /* set master volume and direct control */
679 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
680 {}
681 };
682
683 static struct hda_verb stac9205_core_init[] = {
684 /* set master volume and direct control */
685 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
686 {}
687 };
688
689 #define STAC_MONO_MUX \
690 { \
691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
692 .name = "Mono Mux", \
693 .count = 1, \
694 .info = stac92xx_mono_mux_enum_info, \
695 .get = stac92xx_mono_mux_enum_get, \
696 .put = stac92xx_mono_mux_enum_put, \
697 }
698
699 #define STAC_INPUT_SOURCE(cnt) \
700 { \
701 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
702 .name = "Input Source", \
703 .count = cnt, \
704 .info = stac92xx_mux_enum_info, \
705 .get = stac92xx_mux_enum_get, \
706 .put = stac92xx_mux_enum_put, \
707 }
708
709 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
710 { \
711 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
712 .name = "Analog Loopback", \
713 .count = cnt, \
714 .info = stac92xx_aloopback_info, \
715 .get = stac92xx_aloopback_get, \
716 .put = stac92xx_aloopback_put, \
717 .private_value = verb_read | (verb_write << 16), \
718 }
719
720 static struct snd_kcontrol_new stac9200_mixer[] = {
721 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
722 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
723 STAC_INPUT_SOURCE(1),
724 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
725 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
726 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
727 { } /* end */
728 };
729
730 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
731 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
732
733 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
734 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
735
736 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
737 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
738
739 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
740 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
741
742 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
743 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
744
745 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
746 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
747
748 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
749 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
750
751 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
752 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
753 { } /* end */
754 };
755
756 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
757 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
758
759 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
760 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
761
762 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
763 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
764
765 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
766 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
767
768 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
769 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
770
771 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
772 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
773
774 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
775 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
776
777 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
778 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
779 { } /* end */
780 };
781
782 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
783 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
784
785 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
786 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
787
788 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
789 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
790
791 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
792 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
793
794 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
795 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
796
797 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
798 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
799
800 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
801 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
802
803 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
804 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
805 { } /* end */
806 };
807
808 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
809 STAC_INPUT_SOURCE(2),
810
811 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
812 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
813 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
814
815 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
816 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
817 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
818
819 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
820 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
821 { } /* end */
822 };
823
824 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
825 STAC_INPUT_SOURCE(2),
826 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
827
828 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
829 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
830 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
831
832 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
833 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
834 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
835 { } /* end */
836 };
837
838 static struct snd_kcontrol_new stac925x_mixer[] = {
839 STAC_INPUT_SOURCE(1),
840 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
841 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT),
842 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
843 { } /* end */
844 };
845
846 static struct snd_kcontrol_new stac9205_mixer[] = {
847 STAC_INPUT_SOURCE(2),
848 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
849
850 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
851 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
852 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x19, 0x0, HDA_OUTPUT),
853
854 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
855 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
856 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT),
857
858 { } /* end */
859 };
860
861 /* This needs to be generated dynamically based on sequence */
862 static struct snd_kcontrol_new stac922x_mixer[] = {
863 STAC_INPUT_SOURCE(2),
864 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
865 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
866 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT),
867
868 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
869 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
870 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT),
871 { } /* end */
872 };
873
874
875 static struct snd_kcontrol_new stac927x_mixer[] = {
876 STAC_INPUT_SOURCE(3),
877 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
878
879 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
880 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
881 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x15, 0x0, HDA_OUTPUT),
882
883 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
884 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
885 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x16, 0x0, HDA_OUTPUT),
886
887 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
888 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
889 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT),
890 { } /* end */
891 };
892
893 static struct snd_kcontrol_new stac_dmux_mixer = {
894 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
895 .name = "Digital Input Source",
896 /* count set later */
897 .info = stac92xx_dmux_enum_info,
898 .get = stac92xx_dmux_enum_get,
899 .put = stac92xx_dmux_enum_put,
900 };
901
902 static const char *slave_vols[] = {
903 "Front Playback Volume",
904 "Surround Playback Volume",
905 "Center Playback Volume",
906 "LFE Playback Volume",
907 "Side Playback Volume",
908 "Headphone Playback Volume",
909 "Headphone Playback Volume",
910 "Speaker Playback Volume",
911 "External Speaker Playback Volume",
912 "Speaker2 Playback Volume",
913 NULL
914 };
915
916 static const char *slave_sws[] = {
917 "Front Playback Switch",
918 "Surround Playback Switch",
919 "Center Playback Switch",
920 "LFE Playback Switch",
921 "Side Playback Switch",
922 "Headphone Playback Switch",
923 "Headphone Playback Switch",
924 "Speaker Playback Switch",
925 "External Speaker Playback Switch",
926 "Speaker2 Playback Switch",
927 "IEC958 Playback Switch",
928 NULL
929 };
930
931 static int stac92xx_build_controls(struct hda_codec *codec)
932 {
933 struct sigmatel_spec *spec = codec->spec;
934 int err;
935 int i;
936
937 err = snd_hda_add_new_ctls(codec, spec->mixer);
938 if (err < 0)
939 return err;
940
941 for (i = 0; i < spec->num_mixers; i++) {
942 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
943 if (err < 0)
944 return err;
945 }
946 if (spec->num_dmuxes > 0) {
947 stac_dmux_mixer.count = spec->num_dmuxes;
948 err = snd_ctl_add(codec->bus->card,
949 snd_ctl_new1(&stac_dmux_mixer, codec));
950 if (err < 0)
951 return err;
952 }
953
954 if (spec->multiout.dig_out_nid) {
955 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
956 if (err < 0)
957 return err;
958 err = snd_hda_create_spdif_share_sw(codec,
959 &spec->multiout);
960 if (err < 0)
961 return err;
962 spec->multiout.share_spdif = 1;
963 }
964 if (spec->dig_in_nid) {
965 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
966 if (err < 0)
967 return err;
968 }
969
970 /* if we have no master control, let's create it */
971 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
972 unsigned int vmaster_tlv[4];
973 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
974 HDA_OUTPUT, vmaster_tlv);
975 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
976 vmaster_tlv, slave_vols);
977 if (err < 0)
978 return err;
979 }
980 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
981 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
982 NULL, slave_sws);
983 if (err < 0)
984 return err;
985 }
986
987 return 0;
988 }
989
990 static unsigned int ref9200_pin_configs[8] = {
991 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
992 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
993 };
994
995 /*
996 STAC 9200 pin configs for
997 102801A8
998 102801DE
999 102801E8
1000 */
1001 static unsigned int dell9200_d21_pin_configs[8] = {
1002 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1003 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1004 };
1005
1006 /*
1007 STAC 9200 pin configs for
1008 102801C0
1009 102801C1
1010 */
1011 static unsigned int dell9200_d22_pin_configs[8] = {
1012 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1013 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1014 };
1015
1016 /*
1017 STAC 9200 pin configs for
1018 102801C4 (Dell Dimension E310)
1019 102801C5
1020 102801C7
1021 102801D9
1022 102801DA
1023 102801E3
1024 */
1025 static unsigned int dell9200_d23_pin_configs[8] = {
1026 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1027 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1028 };
1029
1030
1031 /*
1032 STAC 9200-32 pin configs for
1033 102801B5 (Dell Inspiron 630m)
1034 102801D8 (Dell Inspiron 640m)
1035 */
1036 static unsigned int dell9200_m21_pin_configs[8] = {
1037 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1038 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1039 };
1040
1041 /*
1042 STAC 9200-32 pin configs for
1043 102801C2 (Dell Latitude D620)
1044 102801C8
1045 102801CC (Dell Latitude D820)
1046 102801D4
1047 102801D6
1048 */
1049 static unsigned int dell9200_m22_pin_configs[8] = {
1050 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1051 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1052 };
1053
1054 /*
1055 STAC 9200-32 pin configs for
1056 102801CE (Dell XPS M1710)
1057 102801CF (Dell Precision M90)
1058 */
1059 static unsigned int dell9200_m23_pin_configs[8] = {
1060 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1061 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1062 };
1063
1064 /*
1065 STAC 9200-32 pin configs for
1066 102801C9
1067 102801CA
1068 102801CB (Dell Latitude 120L)
1069 102801D3
1070 */
1071 static unsigned int dell9200_m24_pin_configs[8] = {
1072 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1073 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1074 };
1075
1076 /*
1077 STAC 9200-32 pin configs for
1078 102801BD (Dell Inspiron E1505n)
1079 102801EE
1080 102801EF
1081 */
1082 static unsigned int dell9200_m25_pin_configs[8] = {
1083 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1084 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1085 };
1086
1087 /*
1088 STAC 9200-32 pin configs for
1089 102801F5 (Dell Inspiron 1501)
1090 102801F6
1091 */
1092 static unsigned int dell9200_m26_pin_configs[8] = {
1093 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1094 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1095 };
1096
1097 /*
1098 STAC 9200-32
1099 102801CD (Dell Inspiron E1705/9400)
1100 */
1101 static unsigned int dell9200_m27_pin_configs[8] = {
1102 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1103 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1104 };
1105
1106 static unsigned int oqo9200_pin_configs[8] = {
1107 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1108 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1109 };
1110
1111
1112 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1113 [STAC_REF] = ref9200_pin_configs,
1114 [STAC_9200_OQO] = oqo9200_pin_configs,
1115 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1116 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1117 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1118 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1119 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1120 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1121 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1122 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1123 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1124 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1125 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1126 };
1127
1128 static const char *stac9200_models[STAC_9200_MODELS] = {
1129 [STAC_REF] = "ref",
1130 [STAC_9200_OQO] = "oqo",
1131 [STAC_9200_DELL_D21] = "dell-d21",
1132 [STAC_9200_DELL_D22] = "dell-d22",
1133 [STAC_9200_DELL_D23] = "dell-d23",
1134 [STAC_9200_DELL_M21] = "dell-m21",
1135 [STAC_9200_DELL_M22] = "dell-m22",
1136 [STAC_9200_DELL_M23] = "dell-m23",
1137 [STAC_9200_DELL_M24] = "dell-m24",
1138 [STAC_9200_DELL_M25] = "dell-m25",
1139 [STAC_9200_DELL_M26] = "dell-m26",
1140 [STAC_9200_DELL_M27] = "dell-m27",
1141 [STAC_9200_GATEWAY] = "gateway",
1142 [STAC_9200_PANASONIC] = "panasonic",
1143 };
1144
1145 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1146 /* SigmaTel reference board */
1147 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1148 "DFI LanParty", STAC_REF),
1149 /* Dell laptops have BIOS problem */
1150 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1151 "unknown Dell", STAC_9200_DELL_D21),
1152 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1153 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1155 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1156 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1157 "unknown Dell", STAC_9200_DELL_D22),
1158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1159 "unknown Dell", STAC_9200_DELL_D22),
1160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1161 "Dell Latitude D620", STAC_9200_DELL_M22),
1162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1163 "unknown Dell", STAC_9200_DELL_D23),
1164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1165 "unknown Dell", STAC_9200_DELL_D23),
1166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1167 "unknown Dell", STAC_9200_DELL_M22),
1168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1169 "unknown Dell", STAC_9200_DELL_M24),
1170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1171 "unknown Dell", STAC_9200_DELL_M24),
1172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1173 "Dell Latitude 120L", STAC_9200_DELL_M24),
1174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1175 "Dell Latitude D820", STAC_9200_DELL_M22),
1176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1177 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1179 "Dell XPS M1710", STAC_9200_DELL_M23),
1180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1181 "Dell Precision M90", STAC_9200_DELL_M23),
1182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1183 "unknown Dell", STAC_9200_DELL_M22),
1184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1185 "unknown Dell", STAC_9200_DELL_M22),
1186 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1187 "unknown Dell", STAC_9200_DELL_M22),
1188 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1189 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1190 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1191 "unknown Dell", STAC_9200_DELL_D23),
1192 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1193 "unknown Dell", STAC_9200_DELL_D23),
1194 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1195 "unknown Dell", STAC_9200_DELL_D21),
1196 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1197 "unknown Dell", STAC_9200_DELL_D23),
1198 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1199 "unknown Dell", STAC_9200_DELL_D21),
1200 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1201 "unknown Dell", STAC_9200_DELL_M25),
1202 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1203 "unknown Dell", STAC_9200_DELL_M25),
1204 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1205 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1206 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1207 "unknown Dell", STAC_9200_DELL_M26),
1208 /* Panasonic */
1209 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1210 /* Gateway machines needs EAPD to be set on resume */
1211 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1212 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1213 STAC_9200_GATEWAY),
1214 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1215 STAC_9200_GATEWAY),
1216 /* OQO Mobile */
1217 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1218 {} /* terminator */
1219 };
1220
1221 static unsigned int ref925x_pin_configs[8] = {
1222 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1223 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1224 };
1225
1226 static unsigned int stac925x_MA6_pin_configs[8] = {
1227 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1228 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1229 };
1230
1231 static unsigned int stac925x_PA6_pin_configs[8] = {
1232 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1233 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1234 };
1235
1236 static unsigned int stac925xM2_2_pin_configs[8] = {
1237 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1238 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
1239 };
1240
1241 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1242 [STAC_REF] = ref925x_pin_configs,
1243 [STAC_M2_2] = stac925xM2_2_pin_configs,
1244 [STAC_MA6] = stac925x_MA6_pin_configs,
1245 [STAC_PA6] = stac925x_PA6_pin_configs,
1246 };
1247
1248 static const char *stac925x_models[STAC_925x_MODELS] = {
1249 [STAC_REF] = "ref",
1250 [STAC_M2_2] = "m2-2",
1251 [STAC_MA6] = "m6",
1252 [STAC_PA6] = "pa6",
1253 };
1254
1255 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1256 /* SigmaTel reference board */
1257 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1258 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1259 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1260 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1261 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
1262 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
1263 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1264 {} /* terminator */
1265 };
1266
1267 static unsigned int ref92hd73xx_pin_configs[13] = {
1268 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1269 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1270 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1271 0x01452050,
1272 };
1273
1274 static unsigned int dell_m6_pin_configs[13] = {
1275 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1276 0x03a11020, 0x03011050, 0x4f0000f0, 0x4f0000f0,
1277 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1278 0x4f0000f0,
1279 };
1280
1281 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1282 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1283 [STAC_DELL_M6] = dell_m6_pin_configs,
1284 };
1285
1286 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1287 [STAC_92HD73XX_REF] = "ref",
1288 [STAC_DELL_M6] = "dell-m6",
1289 };
1290
1291 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1292 /* SigmaTel reference board */
1293 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1294 "DFI LanParty", STAC_92HD73XX_REF),
1295 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1296 "unknown Dell", STAC_DELL_M6),
1297 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1298 "unknown Dell", STAC_DELL_M6),
1299 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1300 "unknown Dell", STAC_DELL_M6),
1301 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1302 "unknown Dell", STAC_DELL_M6),
1303 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1304 "unknown Dell", STAC_DELL_M6),
1305 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1306 "unknown Dell", STAC_DELL_M6),
1307 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1308 "unknown Dell", STAC_DELL_M6),
1309 {} /* terminator */
1310 };
1311
1312 static unsigned int ref92hd71bxx_pin_configs[10] = {
1313 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1314 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
1315 0x90a000f0, 0x01452050,
1316 };
1317
1318 static unsigned int dell_m4_1_pin_configs[13] = {
1319 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1320 0x23a1902e, 0x23014250, 0x40f000f0, 0x4f0000f0,
1321 0x40f000f0, 0x4f0000f0,
1322 };
1323
1324 static unsigned int dell_m4_2_pin_configs[13] = {
1325 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1326 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1327 0x40f000f0, 0x044413b0,
1328 };
1329
1330 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1331 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1332 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1333 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1334 };
1335
1336 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1337 [STAC_92HD71BXX_REF] = "ref",
1338 [STAC_DELL_M4_1] = "dell-m4-1",
1339 [STAC_DELL_M4_2] = "dell-m4-2",
1340 };
1341
1342 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1343 /* SigmaTel reference board */
1344 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1345 "DFI LanParty", STAC_92HD71BXX_REF),
1346 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1347 "unknown Dell", STAC_DELL_M4_1),
1348 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1349 "unknown Dell", STAC_DELL_M4_1),
1350 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1351 "unknown Dell", STAC_DELL_M4_1),
1352 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1353 "unknown Dell", STAC_DELL_M4_1),
1354 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1355 "unknown Dell", STAC_DELL_M4_1),
1356 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1357 "unknown Dell", STAC_DELL_M4_1),
1358 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1359 "unknown Dell", STAC_DELL_M4_1),
1360 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1361 "unknown Dell", STAC_DELL_M4_2),
1362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1363 "unknown Dell", STAC_DELL_M4_2),
1364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1365 "unknown Dell", STAC_DELL_M4_2),
1366 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1367 "unknown Dell", STAC_DELL_M4_2),
1368 {} /* terminator */
1369 };
1370
1371 static unsigned int ref922x_pin_configs[10] = {
1372 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1373 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1374 0x40000100, 0x40000100,
1375 };
1376
1377 /*
1378 STAC 922X pin configs for
1379 102801A7
1380 102801AB
1381 102801A9
1382 102801D1
1383 102801D2
1384 */
1385 static unsigned int dell_922x_d81_pin_configs[10] = {
1386 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1387 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1388 0x01813122, 0x400001f2,
1389 };
1390
1391 /*
1392 STAC 922X pin configs for
1393 102801AC
1394 102801D0
1395 */
1396 static unsigned int dell_922x_d82_pin_configs[10] = {
1397 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1398 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1399 0x01813122, 0x400001f1,
1400 };
1401
1402 /*
1403 STAC 922X pin configs for
1404 102801BF
1405 */
1406 static unsigned int dell_922x_m81_pin_configs[10] = {
1407 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1408 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1409 0x40C003f1, 0x405003f0,
1410 };
1411
1412 /*
1413 STAC 9221 A1 pin configs for
1414 102801D7 (Dell XPS M1210)
1415 */
1416 static unsigned int dell_922x_m82_pin_configs[10] = {
1417 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1418 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1419 0x508003f3, 0x405003f4,
1420 };
1421
1422 static unsigned int d945gtp3_pin_configs[10] = {
1423 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1424 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1425 0x02a19120, 0x40000100,
1426 };
1427
1428 static unsigned int d945gtp5_pin_configs[10] = {
1429 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1430 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1431 0x02a19320, 0x40000100,
1432 };
1433
1434 static unsigned int intel_mac_v1_pin_configs[10] = {
1435 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1436 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1437 0x400000fc, 0x400000fb,
1438 };
1439
1440 static unsigned int intel_mac_v2_pin_configs[10] = {
1441 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1442 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1443 0x400000fc, 0x400000fb,
1444 };
1445
1446 static unsigned int intel_mac_v3_pin_configs[10] = {
1447 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1448 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1449 0x400000fc, 0x400000fb,
1450 };
1451
1452 static unsigned int intel_mac_v4_pin_configs[10] = {
1453 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1454 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1455 0x400000fc, 0x400000fb,
1456 };
1457
1458 static unsigned int intel_mac_v5_pin_configs[10] = {
1459 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1460 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1461 0x400000fc, 0x400000fb,
1462 };
1463
1464
1465 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1466 [STAC_D945_REF] = ref922x_pin_configs,
1467 [STAC_D945GTP3] = d945gtp3_pin_configs,
1468 [STAC_D945GTP5] = d945gtp5_pin_configs,
1469 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1470 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1471 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1472 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1473 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1474 /* for backward compatibility */
1475 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1476 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1477 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1478 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1479 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1480 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1481 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1482 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1483 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1484 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1485 };
1486
1487 static const char *stac922x_models[STAC_922X_MODELS] = {
1488 [STAC_D945_REF] = "ref",
1489 [STAC_D945GTP5] = "5stack",
1490 [STAC_D945GTP3] = "3stack",
1491 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1492 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1493 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1494 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1495 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1496 /* for backward compatibility */
1497 [STAC_MACMINI] = "macmini",
1498 [STAC_MACBOOK] = "macbook",
1499 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1500 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1501 [STAC_IMAC_INTEL] = "imac-intel",
1502 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1503 [STAC_922X_DELL_D81] = "dell-d81",
1504 [STAC_922X_DELL_D82] = "dell-d82",
1505 [STAC_922X_DELL_M81] = "dell-m81",
1506 [STAC_922X_DELL_M82] = "dell-m82",
1507 };
1508
1509 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1510 /* SigmaTel reference board */
1511 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1512 "DFI LanParty", STAC_D945_REF),
1513 /* Intel 945G based systems */
1514 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1515 "Intel D945G", STAC_D945GTP3),
1516 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1517 "Intel D945G", STAC_D945GTP3),
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1519 "Intel D945G", STAC_D945GTP3),
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1521 "Intel D945G", STAC_D945GTP3),
1522 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1523 "Intel D945G", STAC_D945GTP3),
1524 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1525 "Intel D945G", STAC_D945GTP3),
1526 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1527 "Intel D945G", STAC_D945GTP3),
1528 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1529 "Intel D945G", STAC_D945GTP3),
1530 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1531 "Intel D945G", STAC_D945GTP3),
1532 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1533 "Intel D945G", STAC_D945GTP3),
1534 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1535 "Intel D945G", STAC_D945GTP3),
1536 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1537 "Intel D945G", STAC_D945GTP3),
1538 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1539 "Intel D945G", STAC_D945GTP3),
1540 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1541 "Intel D945G", STAC_D945GTP3),
1542 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1543 "Intel D945G", STAC_D945GTP3),
1544 /* Intel D945G 5-stack systems */
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1546 "Intel D945G", STAC_D945GTP5),
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1548 "Intel D945G", STAC_D945GTP5),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1550 "Intel D945G", STAC_D945GTP5),
1551 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1552 "Intel D945G", STAC_D945GTP5),
1553 /* Intel 945P based systems */
1554 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1555 "Intel D945P", STAC_D945GTP3),
1556 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1557 "Intel D945P", STAC_D945GTP3),
1558 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1559 "Intel D945P", STAC_D945GTP3),
1560 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1561 "Intel D945P", STAC_D945GTP3),
1562 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1563 "Intel D945P", STAC_D945GTP3),
1564 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1565 "Intel D945P", STAC_D945GTP5),
1566 /* other systems */
1567 /* Apple Mac Mini (early 2006) */
1568 SND_PCI_QUIRK(0x8384, 0x7680,
1569 "Mac Mini", STAC_INTEL_MAC_V3),
1570 /* Dell systems */
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1572 "unknown Dell", STAC_922X_DELL_D81),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1574 "unknown Dell", STAC_922X_DELL_D81),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1576 "unknown Dell", STAC_922X_DELL_D81),
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1578 "unknown Dell", STAC_922X_DELL_D82),
1579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1580 "unknown Dell", STAC_922X_DELL_M81),
1581 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1582 "unknown Dell", STAC_922X_DELL_D82),
1583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1584 "unknown Dell", STAC_922X_DELL_D81),
1585 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1586 "unknown Dell", STAC_922X_DELL_D81),
1587 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1588 "Dell XPS M1210", STAC_922X_DELL_M82),
1589 {} /* terminator */
1590 };
1591
1592 static unsigned int ref927x_pin_configs[14] = {
1593 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1594 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1595 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1596 0x01c42190, 0x40000100,
1597 };
1598
1599 static unsigned int d965_3st_pin_configs[14] = {
1600 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1601 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1602 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1603 0x40000100, 0x40000100
1604 };
1605
1606 static unsigned int d965_5st_pin_configs[14] = {
1607 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1608 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1609 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1610 0x40000100, 0x40000100
1611 };
1612
1613 static unsigned int dell_3st_pin_configs[14] = {
1614 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1615 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1616 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
1617 0x40c003fc, 0x40000100
1618 };
1619
1620 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
1621 [STAC_D965_REF] = ref927x_pin_configs,
1622 [STAC_D965_3ST] = d965_3st_pin_configs,
1623 [STAC_D965_5ST] = d965_5st_pin_configs,
1624 [STAC_DELL_3ST] = dell_3st_pin_configs,
1625 [STAC_DELL_BIOS] = NULL,
1626 };
1627
1628 static const char *stac927x_models[STAC_927X_MODELS] = {
1629 [STAC_D965_REF] = "ref",
1630 [STAC_D965_3ST] = "3stack",
1631 [STAC_D965_5ST] = "5stack",
1632 [STAC_DELL_3ST] = "dell-3stack",
1633 [STAC_DELL_BIOS] = "dell-bios",
1634 };
1635
1636 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1637 /* SigmaTel reference board */
1638 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1639 "DFI LanParty", STAC_D965_REF),
1640 /* Intel 946 based systems */
1641 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1642 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
1643 /* 965 based 3 stack systems */
1644 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1645 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1646 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1647 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1648 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1649 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1650 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1651 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1652 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1653 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1654 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1655 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1656 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1657 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1658 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
1660 /* Dell 3 stack systems */
1661 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
1662 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
1664 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
1665 /* Dell 3 stack systems with verb table in BIOS */
1666 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
1667 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
1668 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell ", STAC_DELL_BIOS),
1669 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
1670 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
1671 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
1672 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
1673 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
1674 /* 965 based 5 stack systems */
1675 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
1676 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
1677 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
1678 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
1679 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
1680 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
1681 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
1682 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
1683 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
1684 {} /* terminator */
1685 };
1686
1687 static unsigned int ref9205_pin_configs[12] = {
1688 0x40000100, 0x40000100, 0x01016011, 0x01014010,
1689 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
1690 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
1691 };
1692
1693 /*
1694 STAC 9205 pin configs for
1695 102801F1
1696 102801F2
1697 102801FC
1698 102801FD
1699 10280204
1700 1028021F
1701 10280228 (Dell Vostro 1500)
1702 */
1703 static unsigned int dell_9205_m42_pin_configs[12] = {
1704 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
1705 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
1706 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
1707 };
1708
1709 /*
1710 STAC 9205 pin configs for
1711 102801F9
1712 102801FA
1713 102801FE
1714 102801FF (Dell Precision M4300)
1715 10280206
1716 10280200
1717 10280201
1718 */
1719 static unsigned int dell_9205_m43_pin_configs[12] = {
1720 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
1721 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
1722 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
1723 };
1724
1725 static unsigned int dell_9205_m44_pin_configs[12] = {
1726 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
1727 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
1728 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
1729 };
1730
1731 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
1732 [STAC_9205_REF] = ref9205_pin_configs,
1733 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
1734 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
1735 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
1736 };
1737
1738 static const char *stac9205_models[STAC_9205_MODELS] = {
1739 [STAC_9205_REF] = "ref",
1740 [STAC_9205_DELL_M42] = "dell-m42",
1741 [STAC_9205_DELL_M43] = "dell-m43",
1742 [STAC_9205_DELL_M44] = "dell-m44",
1743 };
1744
1745 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
1746 /* SigmaTel reference board */
1747 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1748 "DFI LanParty", STAC_9205_REF),
1749 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1750 "unknown Dell", STAC_9205_DELL_M42),
1751 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1752 "unknown Dell", STAC_9205_DELL_M42),
1753 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
1754 "Dell Precision", STAC_9205_DELL_M43),
1755 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
1756 "Dell Precision", STAC_9205_DELL_M43),
1757 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
1758 "Dell Precision", STAC_9205_DELL_M43),
1759 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
1760 "Dell Precision", STAC_9205_DELL_M43),
1761 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
1762 "Dell Precision", STAC_9205_DELL_M43),
1763 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1764 "unknown Dell", STAC_9205_DELL_M42),
1765 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1766 "unknown Dell", STAC_9205_DELL_M42),
1767 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
1768 "Dell Precision", STAC_9205_DELL_M43),
1769 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
1770 "Dell Precision M4300", STAC_9205_DELL_M43),
1771 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
1772 "Dell Precision", STAC_9205_DELL_M43),
1773 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1774 "Dell Inspiron", STAC_9205_DELL_M44),
1775 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1776 "Dell Inspiron", STAC_9205_DELL_M44),
1777 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1778 "Dell Inspiron", STAC_9205_DELL_M44),
1779 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1780 "Dell Inspiron", STAC_9205_DELL_M44),
1781 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
1782 "unknown Dell", STAC_9205_DELL_M42),
1783 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
1784 "Dell Inspiron", STAC_9205_DELL_M44),
1785 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
1786 "Dell Vostro 1500", STAC_9205_DELL_M42),
1787 {} /* terminator */
1788 };
1789
1790 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
1791 {
1792 int i;
1793 struct sigmatel_spec *spec = codec->spec;
1794
1795 if (! spec->bios_pin_configs) {
1796 spec->bios_pin_configs = kcalloc(spec->num_pins,
1797 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
1798 if (! spec->bios_pin_configs)
1799 return -ENOMEM;
1800 }
1801
1802 for (i = 0; i < spec->num_pins; i++) {
1803 hda_nid_t nid = spec->pin_nids[i];
1804 unsigned int pin_cfg;
1805
1806 pin_cfg = snd_hda_codec_read(codec, nid, 0,
1807 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
1808 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
1809 nid, pin_cfg);
1810 spec->bios_pin_configs[i] = pin_cfg;
1811 }
1812
1813 return 0;
1814 }
1815
1816 static void stac92xx_set_config_reg(struct hda_codec *codec,
1817 hda_nid_t pin_nid, unsigned int pin_config)
1818 {
1819 int i;
1820 snd_hda_codec_write(codec, pin_nid, 0,
1821 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
1822 pin_config & 0x000000ff);
1823 snd_hda_codec_write(codec, pin_nid, 0,
1824 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
1825 (pin_config & 0x0000ff00) >> 8);
1826 snd_hda_codec_write(codec, pin_nid, 0,
1827 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
1828 (pin_config & 0x00ff0000) >> 16);
1829 snd_hda_codec_write(codec, pin_nid, 0,
1830 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1831 pin_config >> 24);
1832 i = snd_hda_codec_read(codec, pin_nid, 0,
1833 AC_VERB_GET_CONFIG_DEFAULT,
1834 0x00);
1835 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
1836 pin_nid, i);
1837 }
1838
1839 static void stac92xx_set_config_regs(struct hda_codec *codec)
1840 {
1841 int i;
1842 struct sigmatel_spec *spec = codec->spec;
1843
1844 if (!spec->pin_configs)
1845 return;
1846
1847 for (i = 0; i < spec->num_pins; i++)
1848 stac92xx_set_config_reg(codec, spec->pin_nids[i],
1849 spec->pin_configs[i]);
1850 }
1851
1852 /*
1853 * Analog playback callbacks
1854 */
1855 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
1856 struct hda_codec *codec,
1857 struct snd_pcm_substream *substream)
1858 {
1859 struct sigmatel_spec *spec = codec->spec;
1860 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
1861 hinfo);
1862 }
1863
1864 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1865 struct hda_codec *codec,
1866 unsigned int stream_tag,
1867 unsigned int format,
1868 struct snd_pcm_substream *substream)
1869 {
1870 struct sigmatel_spec *spec = codec->spec;
1871 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
1872 }
1873
1874 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1875 struct hda_codec *codec,
1876 struct snd_pcm_substream *substream)
1877 {
1878 struct sigmatel_spec *spec = codec->spec;
1879 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1880 }
1881
1882 /*
1883 * Digital playback callbacks
1884 */
1885 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1886 struct hda_codec *codec,
1887 struct snd_pcm_substream *substream)
1888 {
1889 struct sigmatel_spec *spec = codec->spec;
1890 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1891 }
1892
1893 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1894 struct hda_codec *codec,
1895 struct snd_pcm_substream *substream)
1896 {
1897 struct sigmatel_spec *spec = codec->spec;
1898 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1899 }
1900
1901 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1902 struct hda_codec *codec,
1903 unsigned int stream_tag,
1904 unsigned int format,
1905 struct snd_pcm_substream *substream)
1906 {
1907 struct sigmatel_spec *spec = codec->spec;
1908 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
1909 stream_tag, format, substream);
1910 }
1911
1912
1913 /*
1914 * Analog capture callbacks
1915 */
1916 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1917 struct hda_codec *codec,
1918 unsigned int stream_tag,
1919 unsigned int format,
1920 struct snd_pcm_substream *substream)
1921 {
1922 struct sigmatel_spec *spec = codec->spec;
1923
1924 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1925 stream_tag, 0, format);
1926 return 0;
1927 }
1928
1929 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1930 struct hda_codec *codec,
1931 struct snd_pcm_substream *substream)
1932 {
1933 struct sigmatel_spec *spec = codec->spec;
1934
1935 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1936 return 0;
1937 }
1938
1939 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
1940 .substreams = 1,
1941 .channels_min = 2,
1942 .channels_max = 2,
1943 /* NID is set in stac92xx_build_pcms */
1944 .ops = {
1945 .open = stac92xx_dig_playback_pcm_open,
1946 .close = stac92xx_dig_playback_pcm_close,
1947 .prepare = stac92xx_dig_playback_pcm_prepare
1948 },
1949 };
1950
1951 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
1952 .substreams = 1,
1953 .channels_min = 2,
1954 .channels_max = 2,
1955 /* NID is set in stac92xx_build_pcms */
1956 };
1957
1958 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
1959 .substreams = 1,
1960 .channels_min = 2,
1961 .channels_max = 8,
1962 .nid = 0x02, /* NID to query formats and rates */
1963 .ops = {
1964 .open = stac92xx_playback_pcm_open,
1965 .prepare = stac92xx_playback_pcm_prepare,
1966 .cleanup = stac92xx_playback_pcm_cleanup
1967 },
1968 };
1969
1970 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
1971 .substreams = 1,
1972 .channels_min = 2,
1973 .channels_max = 2,
1974 .nid = 0x06, /* NID to query formats and rates */
1975 .ops = {
1976 .open = stac92xx_playback_pcm_open,
1977 .prepare = stac92xx_playback_pcm_prepare,
1978 .cleanup = stac92xx_playback_pcm_cleanup
1979 },
1980 };
1981
1982 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
1983 .channels_min = 2,
1984 .channels_max = 2,
1985 /* NID + .substreams is set in stac92xx_build_pcms */
1986 .ops = {
1987 .prepare = stac92xx_capture_pcm_prepare,
1988 .cleanup = stac92xx_capture_pcm_cleanup
1989 },
1990 };
1991
1992 static int stac92xx_build_pcms(struct hda_codec *codec)
1993 {
1994 struct sigmatel_spec *spec = codec->spec;
1995 struct hda_pcm *info = spec->pcm_rec;
1996
1997 codec->num_pcms = 1;
1998 codec->pcm_info = info;
1999
2000 info->name = "STAC92xx Analog";
2001 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2002 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2003 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2004 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2005
2006 if (spec->alt_switch) {
2007 codec->num_pcms++;
2008 info++;
2009 info->name = "STAC92xx Analog Alt";
2010 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2011 }
2012
2013 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2014 codec->num_pcms++;
2015 info++;
2016 info->name = "STAC92xx Digital";
2017 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2018 if (spec->multiout.dig_out_nid) {
2019 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2020 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2021 }
2022 if (spec->dig_in_nid) {
2023 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2024 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2025 }
2026 }
2027
2028 return 0;
2029 }
2030
2031 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2032 {
2033 unsigned int pincap = snd_hda_param_read(codec, nid,
2034 AC_PAR_PIN_CAP);
2035 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2036 if (pincap & AC_PINCAP_VREF_100)
2037 return AC_PINCTL_VREF_100;
2038 if (pincap & AC_PINCAP_VREF_80)
2039 return AC_PINCTL_VREF_80;
2040 if (pincap & AC_PINCAP_VREF_50)
2041 return AC_PINCTL_VREF_50;
2042 if (pincap & AC_PINCAP_VREF_GRD)
2043 return AC_PINCTL_VREF_GRD;
2044 return 0;
2045 }
2046
2047 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2048
2049 {
2050 snd_hda_codec_write_cache(codec, nid, 0,
2051 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2052 }
2053
2054 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2055
2056 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2057 {
2058 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2059 struct sigmatel_spec *spec = codec->spec;
2060 int io_idx = kcontrol-> private_value & 0xff;
2061
2062 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2063 return 0;
2064 }
2065
2066 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2067 {
2068 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2069 struct sigmatel_spec *spec = codec->spec;
2070 hda_nid_t nid = kcontrol->private_value >> 8;
2071 int io_idx = kcontrol-> private_value & 0xff;
2072 unsigned short val = !!ucontrol->value.integer.value[0];
2073
2074 spec->io_switch[io_idx] = val;
2075
2076 if (val)
2077 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2078 else {
2079 unsigned int pinctl = AC_PINCTL_IN_EN;
2080 if (io_idx) /* set VREF for mic */
2081 pinctl |= stac92xx_get_vref(codec, nid);
2082 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2083 }
2084
2085 /* check the auto-mute again: we need to mute/unmute the speaker
2086 * appropriately according to the pin direction
2087 */
2088 if (spec->hp_detect)
2089 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2090
2091 return 1;
2092 }
2093
2094 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2095
2096 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2097 struct snd_ctl_elem_value *ucontrol)
2098 {
2099 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2100 struct sigmatel_spec *spec = codec->spec;
2101
2102 ucontrol->value.integer.value[0] = spec->clfe_swap;
2103 return 0;
2104 }
2105
2106 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2107 struct snd_ctl_elem_value *ucontrol)
2108 {
2109 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2110 struct sigmatel_spec *spec = codec->spec;
2111 hda_nid_t nid = kcontrol->private_value & 0xff;
2112 unsigned int val = !!ucontrol->value.integer.value[0];
2113
2114 if (spec->clfe_swap == val)
2115 return 0;
2116
2117 spec->clfe_swap = val;
2118
2119 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2120 spec->clfe_swap ? 0x4 : 0x0);
2121
2122 return 1;
2123 }
2124
2125 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2126 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2127 .name = xname, \
2128 .index = 0, \
2129 .info = stac92xx_io_switch_info, \
2130 .get = stac92xx_io_switch_get, \
2131 .put = stac92xx_io_switch_put, \
2132 .private_value = xpval, \
2133 }
2134
2135 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2136 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2137 .name = xname, \
2138 .index = 0, \
2139 .info = stac92xx_clfe_switch_info, \
2140 .get = stac92xx_clfe_switch_get, \
2141 .put = stac92xx_clfe_switch_put, \
2142 .private_value = xpval, \
2143 }
2144
2145 enum {
2146 STAC_CTL_WIDGET_VOL,
2147 STAC_CTL_WIDGET_MUTE,
2148 STAC_CTL_WIDGET_MONO_MUX,
2149 STAC_CTL_WIDGET_IO_SWITCH,
2150 STAC_CTL_WIDGET_CLFE_SWITCH
2151 };
2152
2153 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2154 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2155 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2156 STAC_MONO_MUX,
2157 STAC_CODEC_IO_SWITCH(NULL, 0),
2158 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2159 };
2160
2161 /* add dynamic controls */
2162 static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
2163 {
2164 struct snd_kcontrol_new *knew;
2165
2166 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2167 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2168
2169 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2170 if (! knew)
2171 return -ENOMEM;
2172 if (spec->kctl_alloc) {
2173 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2174 kfree(spec->kctl_alloc);
2175 }
2176 spec->kctl_alloc = knew;
2177 spec->num_kctl_alloc = num;
2178 }
2179
2180 knew = &spec->kctl_alloc[spec->num_kctl_used];
2181 *knew = stac92xx_control_templates[type];
2182 knew->name = kstrdup(name, GFP_KERNEL);
2183 if (! knew->name)
2184 return -ENOMEM;
2185 knew->private_value = val;
2186 spec->num_kctl_used++;
2187 return 0;
2188 }
2189
2190 /* flag inputs as additional dynamic lineouts */
2191 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2192 {
2193 struct sigmatel_spec *spec = codec->spec;
2194 unsigned int wcaps, wtype;
2195 int i, num_dacs = 0;
2196
2197 /* use the wcaps cache to count all DACs available for line-outs */
2198 for (i = 0; i < codec->num_nodes; i++) {
2199 wcaps = codec->wcaps[i];
2200 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2201
2202 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2203 num_dacs++;
2204 }
2205
2206 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2207
2208 switch (cfg->line_outs) {
2209 case 3:
2210 /* add line-in as side */
2211 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
2212 cfg->line_out_pins[cfg->line_outs] =
2213 cfg->input_pins[AUTO_PIN_LINE];
2214 spec->line_switch = 1;
2215 cfg->line_outs++;
2216 }
2217 break;
2218 case 2:
2219 /* add line-in as clfe and mic as side */
2220 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
2221 cfg->line_out_pins[cfg->line_outs] =
2222 cfg->input_pins[AUTO_PIN_LINE];
2223 spec->line_switch = 1;
2224 cfg->line_outs++;
2225 }
2226 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
2227 cfg->line_out_pins[cfg->line_outs] =
2228 cfg->input_pins[AUTO_PIN_MIC];
2229 spec->mic_switch = 1;
2230 cfg->line_outs++;
2231 }
2232 break;
2233 case 1:
2234 /* add line-in as surr and mic as clfe */
2235 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
2236 cfg->line_out_pins[cfg->line_outs] =
2237 cfg->input_pins[AUTO_PIN_LINE];
2238 spec->line_switch = 1;
2239 cfg->line_outs++;
2240 }
2241 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
2242 cfg->line_out_pins[cfg->line_outs] =
2243 cfg->input_pins[AUTO_PIN_MIC];
2244 spec->mic_switch = 1;
2245 cfg->line_outs++;
2246 }
2247 break;
2248 }
2249
2250 return 0;
2251 }
2252
2253
2254 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2255 {
2256 int i;
2257
2258 for (i = 0; i < spec->multiout.num_dacs; i++) {
2259 if (spec->multiout.dac_nids[i] == nid)
2260 return 1;
2261 }
2262
2263 return 0;
2264 }
2265
2266 /*
2267 * Fill in the dac_nids table from the parsed pin configuration
2268 * This function only works when every pin in line_out_pins[]
2269 * contains atleast one DAC in its connection list. Some 92xx
2270 * codecs are not connected directly to a DAC, such as the 9200
2271 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2272 */
2273 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
2274 struct auto_pin_cfg *cfg)
2275 {
2276 struct sigmatel_spec *spec = codec->spec;
2277 int i, j, conn_len = 0;
2278 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2279 unsigned int wcaps, wtype;
2280
2281 for (i = 0; i < cfg->line_outs; i++) {
2282 nid = cfg->line_out_pins[i];
2283 conn_len = snd_hda_get_connections(codec, nid, conn,
2284 HDA_MAX_CONNECTIONS);
2285 for (j = 0; j < conn_len; j++) {
2286 wcaps = snd_hda_param_read(codec, conn[j],
2287 AC_PAR_AUDIO_WIDGET_CAP);
2288 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2289 if (wtype != AC_WID_AUD_OUT ||
2290 (wcaps & AC_WCAP_DIGITAL))
2291 continue;
2292 /* conn[j] is a DAC routed to this line-out */
2293 if (!is_in_dac_nids(spec, conn[j]))
2294 break;
2295 }
2296
2297 if (j == conn_len) {
2298 if (spec->multiout.num_dacs > 0) {
2299 /* we have already working output pins,
2300 * so let's drop the broken ones again
2301 */
2302 cfg->line_outs = spec->multiout.num_dacs;
2303 break;
2304 }
2305 /* error out, no available DAC found */
2306 snd_printk(KERN_ERR
2307 "%s: No available DAC for pin 0x%x\n",
2308 __func__, nid);
2309 return -ENODEV;
2310 }
2311
2312 spec->multiout.dac_nids[i] = conn[j];
2313 spec->multiout.num_dacs++;
2314 if (conn_len > 1) {
2315 /* select this DAC in the pin's input mux */
2316 snd_hda_codec_write_cache(codec, nid, 0,
2317 AC_VERB_SET_CONNECT_SEL, j);
2318
2319 }
2320 }
2321
2322 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2323 spec->multiout.num_dacs,
2324 spec->multiout.dac_nids[0],
2325 spec->multiout.dac_nids[1],
2326 spec->multiout.dac_nids[2],
2327 spec->multiout.dac_nids[3],
2328 spec->multiout.dac_nids[4]);
2329 return 0;
2330 }
2331
2332 /* create volume control/switch for the given prefx type */
2333 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2334 {
2335 char name[32];
2336 int err;
2337
2338 sprintf(name, "%s Playback Volume", pfx);
2339 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2340 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2341 if (err < 0)
2342 return err;
2343 sprintf(name, "%s Playback Switch", pfx);
2344 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2345 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2346 if (err < 0)
2347 return err;
2348 return 0;
2349 }
2350
2351 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2352 {
2353 if (!spec->multiout.hp_nid)
2354 spec->multiout.hp_nid = nid;
2355 else if (spec->multiout.num_dacs > 4) {
2356 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2357 return 1;
2358 } else {
2359 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2360 spec->multiout.num_dacs++;
2361 }
2362 return 0;
2363 }
2364
2365 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2366 {
2367 if (is_in_dac_nids(spec, nid))
2368 return 1;
2369 if (spec->multiout.hp_nid == nid)
2370 return 1;
2371 return 0;
2372 }
2373
2374 /* add playback controls from the parsed DAC table */
2375 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2376 const struct auto_pin_cfg *cfg)
2377 {
2378 static const char *chname[4] = {
2379 "Front", "Surround", NULL /*CLFE*/, "Side"
2380 };
2381 hda_nid_t nid;
2382 int i, err;
2383
2384 struct sigmatel_spec *spec = codec->spec;
2385 unsigned int wid_caps, pincap;
2386
2387
2388 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
2389 if (!spec->multiout.dac_nids[i])
2390 continue;
2391
2392 nid = spec->multiout.dac_nids[i];
2393
2394 if (i == 2) {
2395 /* Center/LFE */
2396 err = create_controls(spec, "Center", nid, 1);
2397 if (err < 0)
2398 return err;
2399 err = create_controls(spec, "LFE", nid, 2);
2400 if (err < 0)
2401 return err;
2402
2403 wid_caps = get_wcaps(codec, nid);
2404
2405 if (wid_caps & AC_WCAP_LR_SWAP) {
2406 err = stac92xx_add_control(spec,
2407 STAC_CTL_WIDGET_CLFE_SWITCH,
2408 "Swap Center/LFE Playback Switch", nid);
2409
2410 if (err < 0)
2411 return err;
2412 }
2413
2414 } else {
2415 err = create_controls(spec, chname[i], nid, 3);
2416 if (err < 0)
2417 return err;
2418 }
2419 }
2420
2421 if (spec->line_switch) {
2422 nid = cfg->input_pins[AUTO_PIN_LINE];
2423 pincap = snd_hda_param_read(codec, nid,
2424 AC_PAR_PIN_CAP);
2425 if (pincap & AC_PINCAP_OUT) {
2426 err = stac92xx_add_control(spec,
2427 STAC_CTL_WIDGET_IO_SWITCH,
2428 "Line In as Output Switch", nid << 8);
2429 if (err < 0)
2430 return err;
2431 }
2432 }
2433
2434 if (spec->mic_switch) {
2435 unsigned int def_conf;
2436 unsigned int mic_pin = AUTO_PIN_MIC;
2437 again:
2438 nid = cfg->input_pins[mic_pin];
2439 def_conf = snd_hda_codec_read(codec, nid, 0,
2440 AC_VERB_GET_CONFIG_DEFAULT, 0);
2441 /* some laptops have an internal analog microphone
2442 * which can't be used as a output */
2443 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2444 pincap = snd_hda_param_read(codec, nid,
2445 AC_PAR_PIN_CAP);
2446 if (pincap & AC_PINCAP_OUT) {
2447 err = stac92xx_add_control(spec,
2448 STAC_CTL_WIDGET_IO_SWITCH,
2449 "Mic as Output Switch", (nid << 8) | 1);
2450 nid = snd_hda_codec_read(codec, nid, 0,
2451 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2452 if (!check_in_dac_nids(spec, nid))
2453 add_spec_dacs(spec, nid);
2454 if (err < 0)
2455 return err;
2456 }
2457 } else if (mic_pin == AUTO_PIN_MIC) {
2458 mic_pin = AUTO_PIN_FRONT_MIC;
2459 goto again;
2460 }
2461 }
2462
2463 return 0;
2464 }
2465
2466 /* add playback controls for Speaker and HP outputs */
2467 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2468 struct auto_pin_cfg *cfg)
2469 {
2470 struct sigmatel_spec *spec = codec->spec;
2471 hda_nid_t nid;
2472 int i, old_num_dacs, err;
2473
2474 old_num_dacs = spec->multiout.num_dacs;
2475 for (i = 0; i < cfg->hp_outs; i++) {
2476 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2477 if (wid_caps & AC_WCAP_UNSOL_CAP)
2478 spec->hp_detect = 1;
2479 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2480 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2481 if (check_in_dac_nids(spec, nid))
2482 nid = 0;
2483 if (! nid)
2484 continue;
2485 add_spec_dacs(spec, nid);
2486 }
2487 for (i = 0; i < cfg->speaker_outs; i++) {
2488 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
2489 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2490 if (check_in_dac_nids(spec, nid))
2491 nid = 0;
2492 if (! nid)
2493 continue;
2494 add_spec_dacs(spec, nid);
2495 }
2496 for (i = 0; i < cfg->line_outs; i++) {
2497 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2498 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2499 if (check_in_dac_nids(spec, nid))
2500 nid = 0;
2501 if (! nid)
2502 continue;
2503 add_spec_dacs(spec, nid);
2504 }
2505 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2506 static const char *pfxs[] = {
2507 "Speaker", "External Speaker", "Speaker2",
2508 };
2509 err = create_controls(spec, pfxs[i - old_num_dacs],
2510 spec->multiout.dac_nids[i], 3);
2511 if (err < 0)
2512 return err;
2513 }
2514 if (spec->multiout.hp_nid) {
2515 err = create_controls(spec, "Headphone",
2516 spec->multiout.hp_nid, 3);
2517 if (err < 0)
2518 return err;
2519 }
2520
2521 return 0;
2522 }
2523
2524 /* labels for mono mux outputs */
2525 static const char *stac92xx_mono_labels[3] = {
2526 "DAC0", "DAC1", "Mixer"
2527 };
2528
2529 /* create mono mux for mono out on capable codecs */
2530 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2531 {
2532 struct sigmatel_spec *spec = codec->spec;
2533 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2534 int i, num_cons;
2535 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2536
2537 num_cons = snd_hda_get_connections(codec,
2538 spec->mono_nid,
2539 con_lst,
2540 HDA_MAX_NUM_INPUTS);
2541 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2542 return -EINVAL;
2543
2544 for (i = 0; i < num_cons; i++) {
2545 mono_mux->items[mono_mux->num_items].label =
2546 stac92xx_mono_labels[i];
2547 mono_mux->items[mono_mux->num_items].index = i;
2548 mono_mux->num_items++;
2549 }
2550
2551 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2552 "Mono Mux", spec->mono_nid);
2553 }
2554
2555 /* labels for dmic mux inputs */
2556 static const char *stac92xx_dmic_labels[5] = {
2557 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
2558 "Digital Mic 3", "Digital Mic 4"
2559 };
2560
2561 /* create playback/capture controls for input pins on dmic capable codecs */
2562 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
2563 const struct auto_pin_cfg *cfg)
2564 {
2565 struct sigmatel_spec *spec = codec->spec;
2566 struct hda_input_mux *dimux = &spec->private_dimux;
2567 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2568 int err, i, j;
2569 char name[32];
2570
2571 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
2572 dimux->items[dimux->num_items].index = 0;
2573 dimux->num_items++;
2574
2575 for (i = 0; i < spec->num_dmics; i++) {
2576 hda_nid_t nid;
2577 int index;
2578 int num_cons;
2579 unsigned int wcaps;
2580 unsigned int def_conf;
2581
2582 def_conf = snd_hda_codec_read(codec,
2583 spec->dmic_nids[i],
2584 0,
2585 AC_VERB_GET_CONFIG_DEFAULT,
2586 0);
2587 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2588 continue;
2589
2590 nid = spec->dmic_nids[i];
2591 num_cons = snd_hda_get_connections(codec,
2592 spec->dmux_nids[0],
2593 con_lst,
2594 HDA_MAX_NUM_INPUTS);
2595 for (j = 0; j < num_cons; j++)
2596 if (con_lst[j] == nid) {
2597 index = j;
2598 goto found;
2599 }
2600 continue;
2601 found:
2602 wcaps = get_wcaps(codec, nid);
2603
2604 if (wcaps & AC_WCAP_OUT_AMP) {
2605 sprintf(name, "%s Capture Volume",
2606 stac92xx_dmic_labels[dimux->num_items]);
2607
2608 err = stac92xx_add_control(spec,
2609 STAC_CTL_WIDGET_VOL,
2610 name,
2611 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
2612 if (err < 0)
2613 return err;
2614 }
2615
2616 dimux->items[dimux->num_items].label =
2617 stac92xx_dmic_labels[dimux->num_items];
2618 dimux->items[dimux->num_items].index = index;
2619 dimux->num_items++;
2620 }
2621
2622 return 0;
2623 }
2624
2625 /* create playback/capture controls for input pins */
2626 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
2627 {
2628 struct sigmatel_spec *spec = codec->spec;
2629 struct hda_input_mux *imux = &spec->private_imux;
2630 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2631 int i, j, k;
2632
2633 for (i = 0; i < AUTO_PIN_LAST; i++) {
2634 int index;
2635
2636 if (!cfg->input_pins[i])
2637 continue;
2638 index = -1;
2639 for (j = 0; j < spec->num_muxes; j++) {
2640 int num_cons;
2641 num_cons = snd_hda_get_connections(codec,
2642 spec->mux_nids[j],
2643 con_lst,
2644 HDA_MAX_NUM_INPUTS);
2645 for (k = 0; k < num_cons; k++)
2646 if (con_lst[k] == cfg->input_pins[i]) {
2647 index = k;
2648 goto found;
2649 }
2650 }
2651 continue;
2652 found:
2653 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2654 imux->items[imux->num_items].index = index;
2655 imux->num_items++;
2656 }
2657
2658 if (imux->num_items) {
2659 /*
2660 * Set the current input for the muxes.
2661 * The STAC9221 has two input muxes with identical source
2662 * NID lists. Hopefully this won't get confused.
2663 */
2664 for (i = 0; i < spec->num_muxes; i++) {
2665 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
2666 AC_VERB_SET_CONNECT_SEL,
2667 imux->items[0].index);
2668 }
2669 }
2670
2671 return 0;
2672 }
2673
2674 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
2675 {
2676 struct sigmatel_spec *spec = codec->spec;
2677 int i;
2678
2679 for (i = 0; i < spec->autocfg.line_outs; i++) {
2680 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2681 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2682 }
2683 }
2684
2685 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
2686 {
2687 struct sigmatel_spec *spec = codec->spec;
2688 int i;
2689
2690 for (i = 0; i < spec->autocfg.hp_outs; i++) {
2691 hda_nid_t pin;
2692 pin = spec->autocfg.hp_pins[i];
2693 if (pin) /* connect to front */
2694 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
2695 }
2696 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
2697 hda_nid_t pin;
2698 pin = spec->autocfg.speaker_pins[i];
2699 if (pin) /* connect to front */
2700 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
2701 }
2702 }
2703
2704 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
2705 {
2706 struct sigmatel_spec *spec = codec->spec;
2707 int err;
2708 int hp_speaker_swap = 0;
2709
2710 if ((err = snd_hda_parse_pin_def_config(codec,
2711 &spec->autocfg,
2712 spec->dmic_nids)) < 0)
2713 return err;
2714 if (! spec->autocfg.line_outs)
2715 return 0; /* can't find valid pin config */
2716
2717 /* If we have no real line-out pin and multiple hp-outs, HPs should
2718 * be set up as multi-channel outputs.
2719 */
2720 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
2721 spec->autocfg.hp_outs > 1) {
2722 /* Copy hp_outs to line_outs, backup line_outs in
2723 * speaker_outs so that the following routines can handle
2724 * HP pins as primary outputs.
2725 */
2726 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
2727 sizeof(spec->autocfg.line_out_pins));
2728 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
2729 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
2730 sizeof(spec->autocfg.hp_pins));
2731 spec->autocfg.line_outs = spec->autocfg.hp_outs;
2732 hp_speaker_swap = 1;
2733 }
2734 if (spec->autocfg.mono_out_pin) {
2735 int dir = (get_wcaps(codec, spec->autocfg.mono_out_pin)
2736 & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
2737 u32 caps = query_amp_caps(codec,
2738 spec->autocfg.mono_out_pin, dir);
2739 hda_nid_t conn_list[1];
2740
2741 /* get the mixer node and then the mono mux if it exists */
2742 if (snd_hda_get_connections(codec,
2743 spec->autocfg.mono_out_pin, conn_list, 1) &&
2744 snd_hda_get_connections(codec, conn_list[0],
2745 conn_list, 1)) {
2746
2747 int wcaps = get_wcaps(codec, conn_list[0]);
2748 int wid_type = (wcaps & AC_WCAP_TYPE)
2749 >> AC_WCAP_TYPE_SHIFT;
2750 /* LR swap check, some stac925x have a mux that
2751 * changes the DACs output path instead of the
2752 * mono-mux path.
2753 */
2754 if (wid_type == AC_WID_AUD_SEL &&
2755 !(wcaps & AC_WCAP_LR_SWAP))
2756 spec->mono_nid = conn_list[0];
2757 }
2758 /* all mono outs have a least a mute/unmute switch */
2759 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2760 "Mono Playback Switch",
2761 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2762 1, 0, dir));
2763 if (err < 0)
2764 return err;
2765 /* check to see if there is volume support for the amp */
2766 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2767 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
2768 "Mono Playback Volume",
2769 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2770 1, 0, dir));
2771 if (err < 0)
2772 return err;
2773 }
2774
2775 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
2776 AC_PINCTL_OUT_EN);
2777 }
2778
2779 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
2780 return err;
2781 if (spec->multiout.num_dacs == 0)
2782 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2783 return err;
2784
2785 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
2786
2787 if (err < 0)
2788 return err;
2789
2790 if (hp_speaker_swap == 1) {
2791 /* Restore the hp_outs and line_outs */
2792 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
2793 sizeof(spec->autocfg.line_out_pins));
2794 spec->autocfg.hp_outs = spec->autocfg.line_outs;
2795 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
2796 sizeof(spec->autocfg.speaker_pins));
2797 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
2798 memset(spec->autocfg.speaker_pins, 0,
2799 sizeof(spec->autocfg.speaker_pins));
2800 spec->autocfg.speaker_outs = 0;
2801 }
2802
2803 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
2804
2805 if (err < 0)
2806 return err;
2807
2808 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
2809
2810 if (err < 0)
2811 return err;
2812
2813 if (spec->mono_nid > 0) {
2814 err = stac92xx_auto_create_mono_output_ctls(codec);
2815 if (err < 0)
2816 return err;
2817 }
2818
2819 if (spec->num_dmics > 0)
2820 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
2821 &spec->autocfg)) < 0)
2822 return err;
2823
2824 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2825 if (spec->multiout.max_channels > 2)
2826 spec->surr_switch = 1;
2827
2828 if (spec->autocfg.dig_out_pin)
2829 spec->multiout.dig_out_nid = dig_out;
2830 if (spec->autocfg.dig_in_pin)
2831 spec->dig_in_nid = dig_in;
2832
2833 if (spec->kctl_alloc)
2834 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2835
2836 spec->input_mux = &spec->private_imux;
2837 if (!spec->dinput_mux)
2838 spec->dinput_mux = &spec->private_dimux;
2839 spec->mono_mux = &spec->private_mono_mux;
2840
2841 return 1;
2842 }
2843
2844 /* add playback controls for HP output */
2845 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
2846 struct auto_pin_cfg *cfg)
2847 {
2848 struct sigmatel_spec *spec = codec->spec;
2849 hda_nid_t pin = cfg->hp_pins[0];
2850 unsigned int wid_caps;
2851
2852 if (! pin)
2853 return 0;
2854
2855 wid_caps = get_wcaps(codec, pin);
2856 if (wid_caps & AC_WCAP_UNSOL_CAP)
2857 spec->hp_detect = 1;
2858
2859 return 0;
2860 }
2861
2862 /* add playback controls for LFE output */
2863 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
2864 struct auto_pin_cfg *cfg)
2865 {
2866 struct sigmatel_spec *spec = codec->spec;
2867 int err;
2868 hda_nid_t lfe_pin = 0x0;
2869 int i;
2870
2871 /*
2872 * search speaker outs and line outs for a mono speaker pin
2873 * with an amp. If one is found, add LFE controls
2874 * for it.
2875 */
2876 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
2877 hda_nid_t pin = spec->autocfg.speaker_pins[i];
2878 unsigned int wcaps = get_wcaps(codec, pin);
2879 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2880 if (wcaps == AC_WCAP_OUT_AMP)
2881 /* found a mono speaker with an amp, must be lfe */
2882 lfe_pin = pin;
2883 }
2884
2885 /* if speaker_outs is 0, then speakers may be in line_outs */
2886 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
2887 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
2888 hda_nid_t pin = spec->autocfg.line_out_pins[i];
2889 unsigned int defcfg;
2890 defcfg = snd_hda_codec_read(codec, pin, 0,
2891 AC_VERB_GET_CONFIG_DEFAULT,
2892 0x00);
2893 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
2894 unsigned int wcaps = get_wcaps(codec, pin);
2895 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2896 if (wcaps == AC_WCAP_OUT_AMP)
2897 /* found a mono speaker with an amp,
2898 must be lfe */
2899 lfe_pin = pin;
2900 }
2901 }
2902 }
2903
2904 if (lfe_pin) {
2905 err = create_controls(spec, "LFE", lfe_pin, 1);
2906 if (err < 0)
2907 return err;
2908 }
2909
2910 return 0;
2911 }
2912
2913 static int stac9200_parse_auto_config(struct hda_codec *codec)
2914 {
2915 struct sigmatel_spec *spec = codec->spec;
2916 int err;
2917
2918 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
2919 return err;
2920
2921 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
2922 return err;
2923
2924 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
2925 return err;
2926
2927 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
2928 return err;
2929
2930 if (spec->autocfg.dig_out_pin)
2931 spec->multiout.dig_out_nid = 0x05;
2932 if (spec->autocfg.dig_in_pin)
2933 spec->dig_in_nid = 0x04;
2934
2935 if (spec->kctl_alloc)
2936 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2937
2938 spec->input_mux = &spec->private_imux;
2939 spec->dinput_mux = &spec->private_dimux;
2940
2941 return 1;
2942 }
2943
2944 /*
2945 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
2946 * funky external mute control using GPIO pins.
2947 */
2948
2949 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
2950 unsigned int dir_mask, unsigned int data)
2951 {
2952 unsigned int gpiostate, gpiomask, gpiodir;
2953
2954 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
2955 AC_VERB_GET_GPIO_DATA, 0);
2956 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
2957
2958 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
2959 AC_VERB_GET_GPIO_MASK, 0);
2960 gpiomask |= mask;
2961
2962 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
2963 AC_VERB_GET_GPIO_DIRECTION, 0);
2964 gpiodir |= dir_mask;
2965
2966 /* Configure GPIOx as CMOS */
2967 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
2968
2969 snd_hda_codec_write(codec, codec->afg, 0,
2970 AC_VERB_SET_GPIO_MASK, gpiomask);
2971 snd_hda_codec_read(codec, codec->afg, 0,
2972 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
2973
2974 msleep(1);
2975
2976 snd_hda_codec_read(codec, codec->afg, 0,
2977 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
2978 }
2979
2980 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
2981 unsigned int event)
2982 {
2983 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
2984 snd_hda_codec_write_cache(codec, nid, 0,
2985 AC_VERB_SET_UNSOLICITED_ENABLE,
2986 (AC_USRSP_EN | event));
2987 }
2988
2989 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
2990 {
2991 int i;
2992 for (i = 0; i < cfg->hp_outs; i++)
2993 if (cfg->hp_pins[i] == nid)
2994 return 1; /* nid is a HP-Out */
2995
2996 return 0; /* nid is not a HP-Out */
2997 };
2998
2999 static void stac92xx_power_down(struct hda_codec *codec)
3000 {
3001 struct sigmatel_spec *spec = codec->spec;
3002
3003 /* power down inactive DACs */
3004 hda_nid_t *dac;
3005 for (dac = spec->dac_list; *dac; dac++)
3006 if (!is_in_dac_nids(spec, *dac) &&
3007 spec->multiout.hp_nid != *dac)
3008 snd_hda_codec_write_cache(codec, *dac, 0,
3009 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3010 }
3011
3012 static int stac92xx_init(struct hda_codec *codec)
3013 {
3014 struct sigmatel_spec *spec = codec->spec;
3015 struct auto_pin_cfg *cfg = &spec->autocfg;
3016 int i;
3017
3018 snd_hda_sequence_write(codec, spec->init);
3019
3020 /* set up pins */
3021 if (spec->hp_detect) {
3022 /* Enable unsolicited responses on the HP widget */
3023 for (i = 0; i < cfg->hp_outs; i++)
3024 enable_pin_detect(codec, cfg->hp_pins[i],
3025 STAC_HP_EVENT);
3026 /* force to enable the first line-out; the others are set up
3027 * in unsol_event
3028 */
3029 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3030 AC_PINCTL_OUT_EN);
3031 stac92xx_auto_init_hp_out(codec);
3032 /* fake event to set up pins */
3033 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3034 } else {
3035 stac92xx_auto_init_multi_out(codec);
3036 stac92xx_auto_init_hp_out(codec);
3037 }
3038 for (i = 0; i < AUTO_PIN_LAST; i++) {
3039 hda_nid_t nid = cfg->input_pins[i];
3040 if (nid) {
3041 unsigned int pinctl = AC_PINCTL_IN_EN;
3042 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3043 pinctl |= stac92xx_get_vref(codec, nid);
3044 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3045 }
3046 }
3047 for (i = 0; i < spec->num_dmics; i++)
3048 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3049 AC_PINCTL_IN_EN);
3050 for (i = 0; i < spec->num_pwrs; i++) {
3051 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3052 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3053 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3054 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3055 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3056 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3057 /* outputs are only ports capable of power management
3058 * any attempts on powering down a input port cause the
3059 * referenced VREF to act quirky.
3060 */
3061 if (pinctl & AC_PINCTL_IN_EN)
3062 continue;
3063 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED)
3064 continue;
3065 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3066 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3067 }
3068 if (spec->dac_list)
3069 stac92xx_power_down(codec);
3070 if (cfg->dig_out_pin)
3071 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3072 AC_PINCTL_OUT_EN);
3073 if (cfg->dig_in_pin)
3074 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3075 AC_PINCTL_IN_EN);
3076
3077 stac_gpio_set(codec, spec->gpio_mask,
3078 spec->gpio_dir, spec->gpio_data);
3079
3080 return 0;
3081 }
3082
3083 static void stac92xx_free(struct hda_codec *codec)
3084 {
3085 struct sigmatel_spec *spec = codec->spec;
3086 int i;
3087
3088 if (! spec)
3089 return;
3090
3091 if (spec->kctl_alloc) {
3092 for (i = 0; i < spec->num_kctl_used; i++)
3093 kfree(spec->kctl_alloc[i].name);
3094 kfree(spec->kctl_alloc);
3095 }
3096
3097 if (spec->bios_pin_configs)
3098 kfree(spec->bios_pin_configs);
3099
3100 kfree(spec);
3101 }
3102
3103 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3104 unsigned int flag)
3105 {
3106 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3107 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3108
3109 if (pin_ctl & AC_PINCTL_IN_EN) {
3110 /*
3111 * we need to check the current set-up direction of
3112 * shared input pins since they can be switched via
3113 * "xxx as Output" mixer switch
3114 */
3115 struct sigmatel_spec *spec = codec->spec;
3116 struct auto_pin_cfg *cfg = &spec->autocfg;
3117 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3118 spec->line_switch) ||
3119 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3120 spec->mic_switch))
3121 return;
3122 }
3123
3124 /* if setting pin direction bits, clear the current
3125 direction bits first */
3126 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3127 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3128
3129 snd_hda_codec_write_cache(codec, nid, 0,
3130 AC_VERB_SET_PIN_WIDGET_CONTROL,
3131 pin_ctl | flag);
3132 }
3133
3134 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3135 unsigned int flag)
3136 {
3137 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3138 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3139 snd_hda_codec_write_cache(codec, nid, 0,
3140 AC_VERB_SET_PIN_WIDGET_CONTROL,
3141 pin_ctl & ~flag);
3142 }
3143
3144 static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
3145 {
3146 if (!nid)
3147 return 0;
3148 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
3149 & (1 << 31)) {
3150 unsigned int pinctl;
3151 pinctl = snd_hda_codec_read(codec, nid, 0,
3152 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3153 if (pinctl & AC_PINCTL_IN_EN)
3154 return 0; /* mic- or line-input */
3155 else
3156 return 1; /* HP-output */
3157 }
3158 return 0;
3159 }
3160
3161 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3162 {
3163 struct sigmatel_spec *spec = codec->spec;
3164 struct auto_pin_cfg *cfg = &spec->autocfg;
3165 int i, presence;
3166
3167 presence = 0;
3168 if (spec->gpio_mute)
3169 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3170 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3171
3172 for (i = 0; i < cfg->hp_outs; i++) {
3173 if (presence)
3174 break;
3175 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
3176 }
3177
3178 if (presence) {
3179 /* disable lineouts, enable hp */
3180 for (i = 0; i < cfg->line_outs; i++)
3181 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3182 AC_PINCTL_OUT_EN);
3183 for (i = 0; i < cfg->speaker_outs; i++)
3184 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3185 AC_PINCTL_OUT_EN);
3186 } else {
3187 /* enable lineouts, disable hp */
3188 for (i = 0; i < cfg->line_outs; i++)
3189 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3190 AC_PINCTL_OUT_EN);
3191 for (i = 0; i < cfg->speaker_outs; i++)
3192 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3193 AC_PINCTL_OUT_EN);
3194 }
3195 }
3196
3197 static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3198 {
3199 struct sigmatel_spec *spec = codec->spec;
3200 hda_nid_t nid = spec->pwr_nids[idx];
3201 int presence, val;
3202 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3203 & 0x000000ff;
3204 presence = get_hp_pin_presence(codec, nid);
3205 idx = 1 << idx;
3206
3207 if (presence)
3208 val &= ~idx;
3209 else
3210 val |= idx;
3211
3212 /* power down unused output ports */
3213 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3214 };
3215
3216 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3217 {
3218 struct sigmatel_spec *spec = codec->spec;
3219 int idx = res >> 26 & 0x0f;
3220
3221 switch ((res >> 26) & 0x30) {
3222 case STAC_HP_EVENT:
3223 stac92xx_hp_detect(codec, res);
3224 /* fallthru */
3225 case STAC_PWR_EVENT:
3226 if (spec->num_pwrs > 0)
3227 stac92xx_pin_sense(codec, idx);
3228 }
3229 }
3230
3231 #ifdef SND_HDA_NEEDS_RESUME
3232 static int stac92xx_resume(struct hda_codec *codec)
3233 {
3234 struct sigmatel_spec *spec = codec->spec;
3235
3236 stac92xx_set_config_regs(codec);
3237 snd_hda_sequence_write(codec, spec->init);
3238 stac_gpio_set(codec, spec->gpio_mask,
3239 spec->gpio_dir, spec->gpio_data);
3240 snd_hda_codec_resume_amp(codec);
3241 snd_hda_codec_resume_cache(codec);
3242 /* power down inactive DACs */
3243 if (spec->dac_list)
3244 stac92xx_power_down(codec);
3245 /* invoke unsolicited event to reset the HP state */
3246 if (spec->hp_detect)
3247 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3248 return 0;
3249 }
3250 #endif
3251
3252 static struct hda_codec_ops stac92xx_patch_ops = {
3253 .build_controls = stac92xx_build_controls,
3254 .build_pcms = stac92xx_build_pcms,
3255 .init = stac92xx_init,
3256 .free = stac92xx_free,
3257 .unsol_event = stac92xx_unsol_event,
3258 #ifdef SND_HDA_NEEDS_RESUME
3259 .resume = stac92xx_resume,
3260 #endif
3261 };
3262
3263 static int patch_stac9200(struct hda_codec *codec)
3264 {
3265 struct sigmatel_spec *spec;
3266 int err;
3267
3268 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3269 if (spec == NULL)
3270 return -ENOMEM;
3271
3272 codec->spec = spec;
3273 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
3274 spec->pin_nids = stac9200_pin_nids;
3275 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3276 stac9200_models,
3277 stac9200_cfg_tbl);
3278 if (spec->board_config < 0) {
3279 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3280 err = stac92xx_save_bios_config_regs(codec);
3281 if (err < 0) {
3282 stac92xx_free(codec);
3283 return err;
3284 }
3285 spec->pin_configs = spec->bios_pin_configs;
3286 } else {
3287 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3288 stac92xx_set_config_regs(codec);
3289 }
3290
3291 spec->multiout.max_channels = 2;
3292 spec->multiout.num_dacs = 1;
3293 spec->multiout.dac_nids = stac9200_dac_nids;
3294 spec->adc_nids = stac9200_adc_nids;
3295 spec->mux_nids = stac9200_mux_nids;
3296 spec->num_muxes = 1;
3297 spec->num_dmics = 0;
3298 spec->num_adcs = 1;
3299 spec->num_pwrs = 0;
3300
3301 if (spec->board_config == STAC_9200_GATEWAY ||
3302 spec->board_config == STAC_9200_OQO)
3303 spec->init = stac9200_eapd_init;
3304 else
3305 spec->init = stac9200_core_init;
3306 spec->mixer = stac9200_mixer;
3307
3308 if (spec->board_config == STAC_9200_PANASONIC) {
3309 spec->gpio_mask = spec->gpio_dir = 0x09;
3310 spec->gpio_data = 0x00;
3311 }
3312
3313 err = stac9200_parse_auto_config(codec);
3314 if (err < 0) {
3315 stac92xx_free(codec);
3316 return err;
3317 }
3318
3319 codec->patch_ops = stac92xx_patch_ops;
3320
3321 return 0;
3322 }
3323
3324 static int patch_stac925x(struct hda_codec *codec)
3325 {
3326 struct sigmatel_spec *spec;
3327 int err;
3328
3329 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3330 if (spec == NULL)
3331 return -ENOMEM;
3332
3333 codec->spec = spec;
3334 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
3335 spec->pin_nids = stac925x_pin_nids;
3336 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3337 stac925x_models,
3338 stac925x_cfg_tbl);
3339 again:
3340 if (spec->board_config < 0) {
3341 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3342 "using BIOS defaults\n");
3343 err = stac92xx_save_bios_config_regs(codec);
3344 if (err < 0) {
3345 stac92xx_free(codec);
3346 return err;
3347 }
3348 spec->pin_configs = spec->bios_pin_configs;
3349 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3350 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3351 stac92xx_set_config_regs(codec);
3352 }
3353
3354 spec->multiout.max_channels = 2;
3355 spec->multiout.num_dacs = 1;
3356 spec->multiout.dac_nids = stac925x_dac_nids;
3357 spec->adc_nids = stac925x_adc_nids;
3358 spec->mux_nids = stac925x_mux_nids;
3359 spec->num_muxes = 1;
3360 spec->num_adcs = 1;
3361 spec->num_pwrs = 0;
3362 switch (codec->vendor_id) {
3363 case 0x83847632: /* STAC9202 */
3364 case 0x83847633: /* STAC9202D */
3365 case 0x83847636: /* STAC9251 */
3366 case 0x83847637: /* STAC9251D */
3367 spec->num_dmics = STAC925X_NUM_DMICS;
3368 spec->dmic_nids = stac925x_dmic_nids;
3369 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
3370 spec->dmux_nids = stac925x_dmux_nids;
3371 break;
3372 default:
3373 spec->num_dmics = 0;
3374 break;
3375 }
3376
3377 spec->init = stac925x_core_init;
3378 spec->mixer = stac925x_mixer;
3379
3380 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
3381 if (!err) {
3382 if (spec->board_config < 0) {
3383 printk(KERN_WARNING "hda_codec: No auto-config is "
3384 "available, default to model=ref\n");
3385 spec->board_config = STAC_925x_REF;
3386 goto again;
3387 }
3388 err = -EINVAL;
3389 }
3390 if (err < 0) {
3391 stac92xx_free(codec);
3392 return err;
3393 }
3394
3395 codec->patch_ops = stac92xx_patch_ops;
3396
3397 return 0;
3398 }
3399
3400 static struct hda_input_mux stac92hd73xx_dmux = {
3401 .num_items = 4,
3402 .items = {
3403 { "Analog Inputs", 0x0b },
3404 { "CD", 0x08 },
3405 { "Digital Mic 1", 0x09 },
3406 { "Digital Mic 2", 0x0a },
3407 }
3408 };
3409
3410 static int patch_stac92hd73xx(struct hda_codec *codec)
3411 {
3412 struct sigmatel_spec *spec;
3413 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
3414 int err = 0;
3415
3416 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3417 if (spec == NULL)
3418 return -ENOMEM;
3419
3420 codec->spec = spec;
3421 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
3422 spec->pin_nids = stac92hd73xx_pin_nids;
3423 spec->board_config = snd_hda_check_board_config(codec,
3424 STAC_92HD73XX_MODELS,
3425 stac92hd73xx_models,
3426 stac92hd73xx_cfg_tbl);
3427 again:
3428 if (spec->board_config < 0) {
3429 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3430 " STAC92HD73XX, using BIOS defaults\n");
3431 err = stac92xx_save_bios_config_regs(codec);
3432 if (err < 0) {
3433 stac92xx_free(codec);
3434 return err;
3435 }
3436 spec->pin_configs = spec->bios_pin_configs;
3437 } else {
3438 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
3439 stac92xx_set_config_regs(codec);
3440 }
3441
3442 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
3443 conn, STAC92HD73_DAC_COUNT + 2) - 1;
3444
3445 if (spec->multiout.num_dacs < 0) {
3446 printk(KERN_WARNING "hda_codec: Could not determine "
3447 "number of channels defaulting to DAC count\n");
3448 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
3449 }
3450
3451 switch (spec->multiout.num_dacs) {
3452 case 0x3: /* 6 Channel */
3453 spec->mixer = stac92hd73xx_6ch_mixer;
3454 spec->init = stac92hd73xx_6ch_core_init;
3455 break;
3456 case 0x4: /* 8 Channel */
3457 spec->multiout.hp_nid = 0x18;
3458 spec->mixer = stac92hd73xx_8ch_mixer;
3459 spec->init = stac92hd73xx_8ch_core_init;
3460 break;
3461 case 0x5: /* 10 Channel */
3462 spec->multiout.hp_nid = 0x19;
3463 spec->mixer = stac92hd73xx_10ch_mixer;
3464 spec->init = stac92hd73xx_10ch_core_init;
3465 };
3466
3467 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
3468 spec->aloopback_mask = 0x01;
3469 spec->aloopback_shift = 8;
3470
3471 spec->mux_nids = stac92hd73xx_mux_nids;
3472 spec->adc_nids = stac92hd73xx_adc_nids;
3473 spec->dmic_nids = stac92hd73xx_dmic_nids;
3474 spec->dmux_nids = stac92hd73xx_dmux_nids;
3475
3476 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
3477 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
3478 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
3479 spec->dinput_mux = &stac92hd73xx_dmux;
3480 /* GPIO0 High = Enable EAPD */
3481 spec->gpio_mask = spec->gpio_dir = 0x1;
3482 spec->gpio_data = 0x01;
3483
3484 switch (spec->board_config) {
3485 case STAC_DELL_M6:
3486 spec->init = dell_eq_core_init;
3487 switch (codec->subsystem_id) {
3488 case 0x1028025e: /* Analog Mics */
3489 case 0x1028025f:
3490 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3491 spec->num_dmics = 0;
3492 break;
3493 case 0x10280271: /* Digital Mics */
3494 case 0x10280272:
3495 spec->init = dell_m6_core_init;
3496 /* fall-through */
3497 case 0x10280254:
3498 case 0x10280255:
3499 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3500 spec->num_dmics = 1;
3501 break;
3502 case 0x10280256: /* Both */
3503 case 0x10280057:
3504 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3505 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3506 spec->num_dmics = 1;
3507 break;
3508 }
3509 break;
3510 default:
3511 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3512 }
3513
3514 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
3515 spec->pwr_nids = stac92hd73xx_pwr_nids;
3516
3517 err = stac92xx_parse_auto_config(codec, 0x22, 0x24);
3518
3519 if (!err) {
3520 if (spec->board_config < 0) {
3521 printk(KERN_WARNING "hda_codec: No auto-config is "
3522 "available, default to model=ref\n");
3523 spec->board_config = STAC_92HD73XX_REF;
3524 goto again;
3525 }
3526 err = -EINVAL;
3527 }
3528
3529 if (err < 0) {
3530 stac92xx_free(codec);
3531 return err;
3532 }
3533
3534 codec->patch_ops = stac92xx_patch_ops;
3535
3536 return 0;
3537 }
3538
3539 static int patch_stac92hd71bxx(struct hda_codec *codec)
3540 {
3541 struct sigmatel_spec *spec;
3542 int err = 0;
3543
3544 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3545 if (spec == NULL)
3546 return -ENOMEM;
3547
3548 codec->spec = spec;
3549 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
3550 spec->pin_nids = stac92hd71bxx_pin_nids;
3551 spec->board_config = snd_hda_check_board_config(codec,
3552 STAC_92HD71BXX_MODELS,
3553 stac92hd71bxx_models,
3554 stac92hd71bxx_cfg_tbl);
3555 again:
3556 if (spec->board_config < 0) {
3557 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3558 " STAC92HD71BXX, using BIOS defaults\n");
3559 err = stac92xx_save_bios_config_regs(codec);
3560 if (err < 0) {
3561 stac92xx_free(codec);
3562 return err;
3563 }
3564 spec->pin_configs = spec->bios_pin_configs;
3565 } else {
3566 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
3567 stac92xx_set_config_regs(codec);
3568 }
3569
3570 switch (codec->vendor_id) {
3571 case 0x111d76b6: /* 4 Port without Analog Mixer */
3572 case 0x111d76b7:
3573 case 0x111d76b4: /* 6 Port without Analog Mixer */
3574 case 0x111d76b5:
3575 spec->mixer = stac92hd71bxx_mixer;
3576 spec->init = stac92hd71bxx_core_init;
3577 break;
3578 default:
3579 spec->mixer = stac92hd71bxx_analog_mixer;
3580 spec->init = stac92hd71bxx_analog_core_init;
3581 }
3582
3583 spec->aloopback_mask = 0x20;
3584 spec->aloopback_shift = 0;
3585
3586 /* GPIO0 High = EAPD */
3587 spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0x1;
3588
3589 spec->mux_nids = stac92hd71bxx_mux_nids;
3590 spec->adc_nids = stac92hd71bxx_adc_nids;
3591 spec->dmic_nids = stac92hd71bxx_dmic_nids;
3592 spec->dmux_nids = stac92hd71bxx_dmux_nids;
3593
3594 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
3595 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
3596 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
3597 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
3598
3599 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
3600 spec->pwr_nids = stac92hd71bxx_pwr_nids;
3601
3602 spec->multiout.num_dacs = 1;
3603 spec->multiout.hp_nid = 0x11;
3604 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
3605
3606 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
3607 if (!err) {
3608 if (spec->board_config < 0) {
3609 printk(KERN_WARNING "hda_codec: No auto-config is "
3610 "available, default to model=ref\n");
3611 spec->board_config = STAC_92HD71BXX_REF;
3612 goto again;
3613 }
3614 err = -EINVAL;
3615 }
3616
3617 if (err < 0) {
3618 stac92xx_free(codec);
3619 return err;
3620 }
3621
3622 codec->patch_ops = stac92xx_patch_ops;
3623
3624 return 0;
3625 };
3626
3627 static int patch_stac922x(struct hda_codec *codec)
3628 {
3629 struct sigmatel_spec *spec;
3630 int err;
3631
3632 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3633 if (spec == NULL)
3634 return -ENOMEM;
3635
3636 codec->spec = spec;
3637 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
3638 spec->pin_nids = stac922x_pin_nids;
3639 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
3640 stac922x_models,
3641 stac922x_cfg_tbl);
3642 if (spec->board_config == STAC_INTEL_MAC_V3) {
3643 spec->gpio_mask = spec->gpio_dir = 0x03;
3644 spec->gpio_data = 0x03;
3645 /* Intel Macs have all same PCI SSID, so we need to check
3646 * codec SSID to distinguish the exact models
3647 */
3648 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
3649 switch (codec->subsystem_id) {
3650
3651 case 0x106b0800:
3652 spec->board_config = STAC_INTEL_MAC_V1;
3653 break;
3654 case 0x106b0600:
3655 case 0x106b0700:
3656 spec->board_config = STAC_INTEL_MAC_V2;
3657 break;
3658 case 0x106b0e00:
3659 case 0x106b0f00:
3660 case 0x106b1600:
3661 case 0x106b1700:
3662 case 0x106b0200:
3663 case 0x106b1e00:
3664 spec->board_config = STAC_INTEL_MAC_V3;
3665 break;
3666 case 0x106b1a00:
3667 case 0x00000100:
3668 spec->board_config = STAC_INTEL_MAC_V4;
3669 break;
3670 case 0x106b0a00:
3671 case 0x106b2200:
3672 spec->board_config = STAC_INTEL_MAC_V5;
3673 break;
3674 }
3675 }
3676
3677 again:
3678 if (spec->board_config < 0) {
3679 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
3680 "using BIOS defaults\n");
3681 err = stac92xx_save_bios_config_regs(codec);
3682 if (err < 0) {
3683 stac92xx_free(codec);
3684 return err;
3685 }
3686 spec->pin_configs = spec->bios_pin_configs;
3687 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
3688 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
3689 stac92xx_set_config_regs(codec);
3690 }
3691
3692 spec->adc_nids = stac922x_adc_nids;
3693 spec->mux_nids = stac922x_mux_nids;
3694 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
3695 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
3696 spec->num_dmics = 0;
3697 spec->num_pwrs = 0;
3698
3699 spec->init = stac922x_core_init;
3700 spec->mixer = stac922x_mixer;
3701
3702 spec->multiout.dac_nids = spec->dac_nids;
3703
3704 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
3705 if (!err) {
3706 if (spec->board_config < 0) {
3707 printk(KERN_WARNING "hda_codec: No auto-config is "
3708 "available, default to model=ref\n");
3709 spec->board_config = STAC_D945_REF;
3710 goto again;
3711 }
3712 err = -EINVAL;
3713 }
3714 if (err < 0) {
3715 stac92xx_free(codec);
3716 return err;
3717 }
3718
3719 codec->patch_ops = stac92xx_patch_ops;
3720
3721 /* Fix Mux capture level; max to 2 */
3722 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
3723 (0 << AC_AMPCAP_OFFSET_SHIFT) |
3724 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
3725 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3726 (0 << AC_AMPCAP_MUTE_SHIFT));
3727
3728 return 0;
3729 }
3730
3731 static int patch_stac927x(struct hda_codec *codec)
3732 {
3733 struct sigmatel_spec *spec;
3734 int err;
3735
3736 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3737 if (spec == NULL)
3738 return -ENOMEM;
3739
3740 codec->spec = spec;
3741 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
3742 spec->pin_nids = stac927x_pin_nids;
3743 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
3744 stac927x_models,
3745 stac927x_cfg_tbl);
3746 again:
3747 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
3748 if (spec->board_config < 0)
3749 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3750 "STAC927x, using BIOS defaults\n");
3751 err = stac92xx_save_bios_config_regs(codec);
3752 if (err < 0) {
3753 stac92xx_free(codec);
3754 return err;
3755 }
3756 spec->pin_configs = spec->bios_pin_configs;
3757 } else {
3758 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
3759 stac92xx_set_config_regs(codec);
3760 }
3761
3762 spec->adc_nids = stac927x_adc_nids;
3763 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
3764 spec->mux_nids = stac927x_mux_nids;
3765 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
3766 spec->dac_list = stac927x_dac_nids;
3767 spec->multiout.dac_nids = spec->dac_nids;
3768
3769 switch (spec->board_config) {
3770 case STAC_D965_3ST:
3771 case STAC_D965_5ST:
3772 /* GPIO0 High = Enable EAPD */
3773 spec->gpio_mask = spec->gpio_dir = 0x01;
3774 spec->gpio_data = 0x01;
3775 spec->num_dmics = 0;
3776
3777 spec->init = d965_core_init;
3778 spec->mixer = stac927x_mixer;
3779 break;
3780 case STAC_DELL_BIOS:
3781 /* configure the analog microphone on some laptops */
3782 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
3783 /* correct the front output jack as a hp out */
3784 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
3785 /* correct the front input jack as a mic */
3786 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
3787 /* fallthru */
3788 case STAC_DELL_3ST:
3789 /* GPIO2 High = Enable EAPD */
3790 spec->gpio_mask = spec->gpio_dir = 0x04;
3791 spec->gpio_data = 0x04;
3792 spec->dmic_nids = stac927x_dmic_nids;
3793 spec->num_dmics = STAC927X_NUM_DMICS;
3794
3795 spec->init = d965_core_init;
3796 spec->mixer = stac927x_mixer;
3797 spec->dmux_nids = stac927x_dmux_nids;
3798 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
3799 break;
3800 default:
3801 /* GPIO0 High = Enable EAPD */
3802 spec->gpio_mask = spec->gpio_dir = 0x1;
3803 spec->gpio_data = 0x01;
3804 spec->num_dmics = 0;
3805
3806 spec->init = stac927x_core_init;
3807 spec->mixer = stac927x_mixer;
3808 }
3809
3810 spec->num_pwrs = 0;
3811 spec->aloopback_mask = 0x40;
3812 spec->aloopback_shift = 0;
3813
3814 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
3815 if (!err) {
3816 if (spec->board_config < 0) {
3817 printk(KERN_WARNING "hda_codec: No auto-config is "
3818 "available, default to model=ref\n");
3819 spec->board_config = STAC_D965_REF;
3820 goto again;
3821 }
3822 err = -EINVAL;
3823 }
3824 if (err < 0) {
3825 stac92xx_free(codec);
3826 return err;
3827 }
3828
3829 codec->patch_ops = stac92xx_patch_ops;
3830
3831 /*
3832 * !!FIXME!!
3833 * The STAC927x seem to require fairly long delays for certain
3834 * command sequences. With too short delays (even if the answer
3835 * is set to RIRB properly), it results in the silence output
3836 * on some hardwares like Dell.
3837 *
3838 * The below flag enables the longer delay (see get_response
3839 * in hda_intel.c).
3840 */
3841 codec->bus->needs_damn_long_delay = 1;
3842
3843 return 0;
3844 }
3845
3846 static int patch_stac9205(struct hda_codec *codec)
3847 {
3848 struct sigmatel_spec *spec;
3849 int err;
3850
3851 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3852 if (spec == NULL)
3853 return -ENOMEM;
3854
3855 codec->spec = spec;
3856 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
3857 spec->pin_nids = stac9205_pin_nids;
3858 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
3859 stac9205_models,
3860 stac9205_cfg_tbl);
3861 again:
3862 if (spec->board_config < 0) {
3863 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
3864 err = stac92xx_save_bios_config_regs(codec);
3865 if (err < 0) {
3866 stac92xx_free(codec);
3867 return err;
3868 }
3869 spec->pin_configs = spec->bios_pin_configs;
3870 } else {
3871 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
3872 stac92xx_set_config_regs(codec);
3873 }
3874
3875 spec->adc_nids = stac9205_adc_nids;
3876 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
3877 spec->mux_nids = stac9205_mux_nids;
3878 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
3879 spec->dmic_nids = stac9205_dmic_nids;
3880 spec->num_dmics = STAC9205_NUM_DMICS;
3881 spec->dmux_nids = stac9205_dmux_nids;
3882 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
3883 spec->num_pwrs = 0;
3884
3885 spec->init = stac9205_core_init;
3886 spec->mixer = stac9205_mixer;
3887
3888 spec->aloopback_mask = 0x40;
3889 spec->aloopback_shift = 0;
3890 spec->multiout.dac_nids = spec->dac_nids;
3891
3892 switch (spec->board_config){
3893 case STAC_9205_DELL_M43:
3894 /* Enable SPDIF in/out */
3895 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
3896 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
3897
3898 /* Enable unsol response for GPIO4/Dock HP connection */
3899 snd_hda_codec_write(codec, codec->afg, 0,
3900 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
3901 snd_hda_codec_write_cache(codec, codec->afg, 0,
3902 AC_VERB_SET_UNSOLICITED_ENABLE,
3903 (AC_USRSP_EN | STAC_HP_EVENT));
3904
3905 spec->gpio_dir = 0x0b;
3906 spec->gpio_mask = 0x1b;
3907 spec->gpio_mute = 0x10;
3908 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
3909 * GPIO3 Low = DRM
3910 */
3911 spec->gpio_data = 0x01;
3912 break;
3913 default:
3914 /* GPIO0 High = EAPD */
3915 spec->gpio_mask = spec->gpio_dir = 0x1;
3916 spec->gpio_data = 0x01;
3917 break;
3918 }
3919
3920 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
3921 if (!err) {
3922 if (spec->board_config < 0) {
3923 printk(KERN_WARNING "hda_codec: No auto-config is "
3924 "available, default to model=ref\n");
3925 spec->board_config = STAC_9205_REF;
3926 goto again;
3927 }
3928 err = -EINVAL;
3929 }
3930 if (err < 0) {
3931 stac92xx_free(codec);
3932 return err;
3933 }
3934
3935 codec->patch_ops = stac92xx_patch_ops;
3936
3937 return 0;
3938 }
3939
3940 /*
3941 * STAC9872 hack
3942 */
3943
3944 /* static config for Sony VAIO FE550G and Sony VAIO AR */
3945 static hda_nid_t vaio_dacs[] = { 0x2 };
3946 #define VAIO_HP_DAC 0x5
3947 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
3948 static hda_nid_t vaio_mux_nids[] = { 0x15 };
3949
3950 static struct hda_input_mux vaio_mux = {
3951 .num_items = 3,
3952 .items = {
3953 /* { "HP", 0x0 }, */
3954 { "Mic Jack", 0x1 },
3955 { "Internal Mic", 0x2 },
3956 { "PCM", 0x3 },
3957 }
3958 };
3959
3960 static struct hda_verb vaio_init[] = {
3961 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
3962 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
3963 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
3964 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
3965 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
3966 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
3967 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
3968 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
3969 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
3970 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
3971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
3972 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
3973 {}
3974 };
3975
3976 static struct hda_verb vaio_ar_init[] = {
3977 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
3978 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
3979 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
3980 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
3981 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
3982 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
3983 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
3984 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
3985 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
3986 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
3987 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
3988 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
3989 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
3990 {}
3991 };
3992
3993 /* bind volumes of both NID 0x02 and 0x05 */
3994 static struct hda_bind_ctls vaio_bind_master_vol = {
3995 .ops = &snd_hda_bind_vol,
3996 .values = {
3997 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
3998 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
3999 0
4000 },
4001 };
4002
4003 /* bind volumes of both NID 0x02 and 0x05 */
4004 static struct hda_bind_ctls vaio_bind_master_sw = {
4005 .ops = &snd_hda_bind_sw,
4006 .values = {
4007 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4008 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4009 0,
4010 },
4011 };
4012
4013 static struct snd_kcontrol_new vaio_mixer[] = {
4014 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4015 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
4016 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4017 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4018 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4019 {
4020 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4021 .name = "Capture Source",
4022 .count = 1,
4023 .info = stac92xx_mux_enum_info,
4024 .get = stac92xx_mux_enum_get,
4025 .put = stac92xx_mux_enum_put,
4026 },
4027 {}
4028 };
4029
4030 static struct snd_kcontrol_new vaio_ar_mixer[] = {
4031 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4032 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
4033 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4034 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4035 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4036 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4037 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4038 {
4039 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4040 .name = "Capture Source",
4041 .count = 1,
4042 .info = stac92xx_mux_enum_info,
4043 .get = stac92xx_mux_enum_get,
4044 .put = stac92xx_mux_enum_put,
4045 },
4046 {}
4047 };
4048
4049 static struct hda_codec_ops stac9872_patch_ops = {
4050 .build_controls = stac92xx_build_controls,
4051 .build_pcms = stac92xx_build_pcms,
4052 .init = stac92xx_init,
4053 .free = stac92xx_free,
4054 #ifdef SND_HDA_NEEDS_RESUME
4055 .resume = stac92xx_resume,
4056 #endif
4057 };
4058
4059 static int stac9872_vaio_init(struct hda_codec *codec)
4060 {
4061 int err;
4062
4063 err = stac92xx_init(codec);
4064 if (err < 0)
4065 return err;
4066 if (codec->patch_ops.unsol_event)
4067 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4068 return 0;
4069 }
4070
4071 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4072 {
4073 if (get_hp_pin_presence(codec, 0x0a)) {
4074 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4075 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4076 } else {
4077 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4078 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4079 }
4080 }
4081
4082 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4083 {
4084 switch (res >> 26) {
4085 case STAC_HP_EVENT:
4086 stac9872_vaio_hp_detect(codec, res);
4087 break;
4088 }
4089 }
4090
4091 static struct hda_codec_ops stac9872_vaio_patch_ops = {
4092 .build_controls = stac92xx_build_controls,
4093 .build_pcms = stac92xx_build_pcms,
4094 .init = stac9872_vaio_init,
4095 .free = stac92xx_free,
4096 .unsol_event = stac9872_vaio_unsol_event,
4097 #ifdef CONFIG_PM
4098 .resume = stac92xx_resume,
4099 #endif
4100 };
4101
4102 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4103 CXD9872RD_VAIO,
4104 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4105 STAC9872AK_VAIO,
4106 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4107 STAC9872K_VAIO,
4108 /* AR Series. id=0x83847664 and subsys=104D1300 */
4109 CXD9872AKD_VAIO,
4110 STAC_9872_MODELS,
4111 };
4112
4113 static const char *stac9872_models[STAC_9872_MODELS] = {
4114 [CXD9872RD_VAIO] = "vaio",
4115 [CXD9872AKD_VAIO] = "vaio-ar",
4116 };
4117
4118 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
4119 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
4120 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
4121 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
4122 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
4123 {}
4124 };
4125
4126 static int patch_stac9872(struct hda_codec *codec)
4127 {
4128 struct sigmatel_spec *spec;
4129 int board_config;
4130
4131 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
4132 stac9872_models,
4133 stac9872_cfg_tbl);
4134 if (board_config < 0)
4135 /* unknown config, let generic-parser do its job... */
4136 return snd_hda_parse_generic_codec(codec);
4137
4138 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4139 if (spec == NULL)
4140 return -ENOMEM;
4141
4142 codec->spec = spec;
4143 switch (board_config) {
4144 case CXD9872RD_VAIO:
4145 case STAC9872AK_VAIO:
4146 case STAC9872K_VAIO:
4147 spec->mixer = vaio_mixer;
4148 spec->init = vaio_init;
4149 spec->multiout.max_channels = 2;
4150 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4151 spec->multiout.dac_nids = vaio_dacs;
4152 spec->multiout.hp_nid = VAIO_HP_DAC;
4153 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4154 spec->adc_nids = vaio_adcs;
4155 spec->num_pwrs = 0;
4156 spec->input_mux = &vaio_mux;
4157 spec->mux_nids = vaio_mux_nids;
4158 codec->patch_ops = stac9872_vaio_patch_ops;
4159 break;
4160
4161 case CXD9872AKD_VAIO:
4162 spec->mixer = vaio_ar_mixer;
4163 spec->init = vaio_ar_init;
4164 spec->multiout.max_channels = 2;
4165 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4166 spec->multiout.dac_nids = vaio_dacs;
4167 spec->multiout.hp_nid = VAIO_HP_DAC;
4168 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4169 spec->num_pwrs = 0;
4170 spec->adc_nids = vaio_adcs;
4171 spec->input_mux = &vaio_mux;
4172 spec->mux_nids = vaio_mux_nids;
4173 codec->patch_ops = stac9872_patch_ops;
4174 break;
4175 }
4176
4177 return 0;
4178 }
4179
4180
4181 /*
4182 * patch entries
4183 */
4184 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4185 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
4186 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
4187 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
4188 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
4189 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
4190 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
4191 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
4192 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
4193 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
4194 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
4195 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
4196 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
4197 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
4198 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
4199 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
4200 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
4201 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
4202 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
4203 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
4204 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
4205 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
4206 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
4207 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
4208 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
4209 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
4210 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
4211 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
4212 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
4213 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
4214 /* The following does not take into account .id=0x83847661 when subsys =
4215 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4216 * currently not fully supported.
4217 */
4218 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
4219 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
4220 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
4221 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
4222 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
4223 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
4224 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
4225 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
4226 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
4227 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
4228 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
4229 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
4230 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
4231 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
4232 { .id = 0x111d7608, .name = "92HD71BXX", .patch = patch_stac92hd71bxx },
4233 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4234 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4235 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4236 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4237 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4238 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4239 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
4240 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
4241 {} /* terminator */
4242 };
This page took 0.166917 seconds and 4 git commands to generate.