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