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