ALSA: hda - Fix silent outputs from docking-station jacks of Dell laptops
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / sound / pci / hda / patch_sigmatel.c
blob2141cab8cc98c41fb14fc290b6cdce4da6e63014
1 /*
2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for SigmaTel STAC92xx
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
7 * Matt Porter <mporter@embeddedalley.com>
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
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.
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.
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
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <linux/dmi.h>
32 #include <linux/module.h>
33 #include <sound/core.h>
34 #include <sound/asoundef.h>
35 #include <sound/jack.h>
36 #include <sound/tlv.h>
37 #include "hda_codec.h"
38 #include "hda_local.h"
39 #include "hda_beep.h"
41 enum {
42 STAC_VREF_EVENT = 1,
43 STAC_INSERT_EVENT,
44 STAC_PWR_EVENT,
45 STAC_HP_EVENT,
46 STAC_LO_EVENT,
47 STAC_MIC_EVENT,
50 enum {
51 STAC_AUTO,
52 STAC_REF,
53 STAC_9200_OQO,
54 STAC_9200_DELL_D21,
55 STAC_9200_DELL_D22,
56 STAC_9200_DELL_D23,
57 STAC_9200_DELL_M21,
58 STAC_9200_DELL_M22,
59 STAC_9200_DELL_M23,
60 STAC_9200_DELL_M24,
61 STAC_9200_DELL_M25,
62 STAC_9200_DELL_M26,
63 STAC_9200_DELL_M27,
64 STAC_9200_M4,
65 STAC_9200_M4_2,
66 STAC_9200_PANASONIC,
67 STAC_9200_MODELS
70 enum {
71 STAC_9205_AUTO,
72 STAC_9205_REF,
73 STAC_9205_DELL_M42,
74 STAC_9205_DELL_M43,
75 STAC_9205_DELL_M44,
76 STAC_9205_EAPD,
77 STAC_9205_MODELS
80 enum {
81 STAC_92HD73XX_AUTO,
82 STAC_92HD73XX_NO_JD, /* no jack-detection */
83 STAC_92HD73XX_REF,
84 STAC_92HD73XX_INTEL,
85 STAC_DELL_M6_AMIC,
86 STAC_DELL_M6_DMIC,
87 STAC_DELL_M6_BOTH,
88 STAC_DELL_EQ,
89 STAC_ALIENWARE_M17X,
90 STAC_92HD73XX_MODELS
93 enum {
94 STAC_92HD83XXX_AUTO,
95 STAC_92HD83XXX_REF,
96 STAC_92HD83XXX_PWR_REF,
97 STAC_DELL_S14,
98 STAC_DELL_VOSTRO_3500,
99 STAC_92HD83XXX_HP,
100 STAC_92HD83XXX_HP_cNB11_INTQUAD,
101 STAC_HP_DV7_4000,
102 STAC_92HD83XXX_MODELS
105 enum {
106 STAC_92HD71BXX_AUTO,
107 STAC_92HD71BXX_REF,
108 STAC_DELL_M4_1,
109 STAC_DELL_M4_2,
110 STAC_DELL_M4_3,
111 STAC_HP_M4,
112 STAC_HP_DV4,
113 STAC_HP_DV5,
114 STAC_HP_HDX,
115 STAC_HP_DV4_1222NR,
116 STAC_92HD71BXX_MODELS
119 enum {
120 STAC_925x_AUTO,
121 STAC_925x_REF,
122 STAC_M1,
123 STAC_M1_2,
124 STAC_M2,
125 STAC_M2_2,
126 STAC_M3,
127 STAC_M5,
128 STAC_M6,
129 STAC_925x_MODELS
132 enum {
133 STAC_922X_AUTO,
134 STAC_D945_REF,
135 STAC_D945GTP3,
136 STAC_D945GTP5,
137 STAC_INTEL_MAC_V1,
138 STAC_INTEL_MAC_V2,
139 STAC_INTEL_MAC_V3,
140 STAC_INTEL_MAC_V4,
141 STAC_INTEL_MAC_V5,
142 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
143 * is given, one of the above models will be
144 * chosen according to the subsystem id. */
145 /* for backward compatibility */
146 STAC_MACMINI,
147 STAC_MACBOOK,
148 STAC_MACBOOK_PRO_V1,
149 STAC_MACBOOK_PRO_V2,
150 STAC_IMAC_INTEL,
151 STAC_IMAC_INTEL_20,
152 STAC_ECS_202,
153 STAC_922X_DELL_D81,
154 STAC_922X_DELL_D82,
155 STAC_922X_DELL_M81,
156 STAC_922X_DELL_M82,
157 STAC_922X_MODELS
160 enum {
161 STAC_927X_AUTO,
162 STAC_D965_REF_NO_JD, /* no jack-detection */
163 STAC_D965_REF,
164 STAC_D965_3ST,
165 STAC_D965_5ST,
166 STAC_D965_5ST_NO_FP,
167 STAC_DELL_3ST,
168 STAC_DELL_BIOS,
169 STAC_927X_VOLKNOB,
170 STAC_927X_MODELS
173 enum {
174 STAC_9872_AUTO,
175 STAC_9872_VAIO,
176 STAC_9872_MODELS
179 struct sigmatel_event {
180 hda_nid_t nid;
181 unsigned char type;
182 unsigned char tag;
183 int data;
186 struct sigmatel_mic_route {
187 hda_nid_t pin;
188 signed char mux_idx;
189 signed char dmux_idx;
192 #define MAX_PINS_NUM 16
193 #define MAX_ADCS_NUM 4
194 #define MAX_DMICS_NUM 4
196 struct sigmatel_spec {
197 struct snd_kcontrol_new *mixers[4];
198 unsigned int num_mixers;
200 int board_config;
201 unsigned int eapd_switch: 1;
202 unsigned int surr_switch: 1;
203 unsigned int alt_switch: 1;
204 unsigned int hp_detect: 1;
205 unsigned int spdif_mute: 1;
206 unsigned int check_volume_offset:1;
207 unsigned int auto_mic:1;
208 unsigned int linear_tone_beep:1;
210 /* gpio lines */
211 unsigned int eapd_mask;
212 unsigned int gpio_mask;
213 unsigned int gpio_dir;
214 unsigned int gpio_data;
215 unsigned int gpio_mute;
216 unsigned int gpio_led;
217 unsigned int gpio_led_polarity;
218 unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
219 unsigned int vref_led;
221 /* stream */
222 unsigned int stream_delay;
224 /* analog loopback */
225 const struct snd_kcontrol_new *aloopback_ctl;
226 unsigned char aloopback_mask;
227 unsigned char aloopback_shift;
229 /* power management */
230 unsigned int num_pwrs;
231 const hda_nid_t *pwr_nids;
232 const hda_nid_t *dac_list;
234 /* events */
235 struct snd_array events;
237 /* playback */
238 struct hda_input_mux *mono_mux;
239 unsigned int cur_mmux;
240 struct hda_multi_out multiout;
241 hda_nid_t dac_nids[5];
242 hda_nid_t hp_dacs[5];
243 hda_nid_t speaker_dacs[5];
245 int volume_offset;
247 /* capture */
248 const hda_nid_t *adc_nids;
249 unsigned int num_adcs;
250 const hda_nid_t *mux_nids;
251 unsigned int num_muxes;
252 const hda_nid_t *dmic_nids;
253 unsigned int num_dmics;
254 const hda_nid_t *dmux_nids;
255 unsigned int num_dmuxes;
256 const hda_nid_t *smux_nids;
257 unsigned int num_smuxes;
258 unsigned int num_analog_muxes;
260 const unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
261 const unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
262 unsigned int num_caps; /* number of capture volume/switch elements */
264 struct sigmatel_mic_route ext_mic;
265 struct sigmatel_mic_route int_mic;
266 struct sigmatel_mic_route dock_mic;
268 const char * const *spdif_labels;
270 hda_nid_t dig_in_nid;
271 hda_nid_t mono_nid;
272 hda_nid_t anabeep_nid;
273 hda_nid_t digbeep_nid;
275 /* pin widgets */
276 const hda_nid_t *pin_nids;
277 unsigned int num_pins;
279 /* codec specific stuff */
280 const struct hda_verb *init;
281 const struct snd_kcontrol_new *mixer;
283 /* capture source */
284 struct hda_input_mux *dinput_mux;
285 unsigned int cur_dmux[2];
286 struct hda_input_mux *input_mux;
287 unsigned int cur_mux[3];
288 struct hda_input_mux *sinput_mux;
289 unsigned int cur_smux[2];
290 unsigned int cur_amux;
291 hda_nid_t *amp_nids;
292 unsigned int powerdown_adcs;
294 /* i/o switches */
295 unsigned int io_switch[2];
296 unsigned int clfe_swap;
297 hda_nid_t line_switch; /* shared line-in for input and output */
298 hda_nid_t mic_switch; /* shared mic-in for input and output */
299 hda_nid_t hp_switch; /* NID of HP as line-out */
300 unsigned int aloopback;
302 struct hda_pcm pcm_rec[2]; /* PCM information */
304 /* dynamic controls and input_mux */
305 struct auto_pin_cfg autocfg;
306 struct snd_array kctls;
307 struct hda_input_mux private_dimux;
308 struct hda_input_mux private_imux;
309 struct hda_input_mux private_smux;
310 struct hda_input_mux private_mono_mux;
312 /* auto spec */
313 unsigned auto_pin_cnt;
314 hda_nid_t auto_pin_nids[MAX_PINS_NUM];
315 unsigned auto_adc_cnt;
316 hda_nid_t auto_adc_nids[MAX_ADCS_NUM];
317 hda_nid_t auto_mux_nids[MAX_ADCS_NUM];
318 hda_nid_t auto_dmux_nids[MAX_ADCS_NUM];
319 unsigned long auto_capvols[MAX_ADCS_NUM];
320 unsigned auto_dmic_cnt;
321 hda_nid_t auto_dmic_nids[MAX_DMICS_NUM];
324 static const hda_nid_t stac9200_adc_nids[1] = {
325 0x03,
328 static const hda_nid_t stac9200_mux_nids[1] = {
329 0x0c,
332 static const hda_nid_t stac9200_dac_nids[1] = {
333 0x02,
336 static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
337 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
338 0x0f, 0x10, 0x11
341 static const hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
342 0x26, 0,
345 static const hda_nid_t stac92hd73xx_adc_nids[2] = {
346 0x1a, 0x1b
349 #define STAC92HD73XX_NUM_DMICS 2
350 static const hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
351 0x13, 0x14, 0
354 #define STAC92HD73_DAC_COUNT 5
356 static const hda_nid_t stac92hd73xx_mux_nids[2] = {
357 0x20, 0x21,
360 static const hda_nid_t stac92hd73xx_dmux_nids[2] = {
361 0x20, 0x21,
364 static const hda_nid_t stac92hd73xx_smux_nids[2] = {
365 0x22, 0x23,
368 #define STAC92HD73XX_NUM_CAPS 2
369 static const unsigned long stac92hd73xx_capvols[] = {
370 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
371 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
373 #define stac92hd73xx_capsws stac92hd73xx_capvols
375 #define STAC92HD83_DAC_COUNT 3
377 static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
378 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
379 0x0f, 0x10
382 static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
383 0x1e, 0,
386 static const hda_nid_t stac92hd83xxx_dmic_nids[] = {
387 0x11, 0x20,
390 static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
391 0x0a, 0x0d, 0x0f
394 static const hda_nid_t stac92hd71bxx_adc_nids[2] = {
395 0x12, 0x13,
398 static const hda_nid_t stac92hd71bxx_mux_nids[2] = {
399 0x1a, 0x1b
402 static const hda_nid_t stac92hd71bxx_dmux_nids[2] = {
403 0x1c, 0x1d,
406 static const hda_nid_t stac92hd71bxx_smux_nids[2] = {
407 0x24, 0x25,
410 #define STAC92HD71BXX_NUM_DMICS 2
411 static const hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
412 0x18, 0x19, 0
415 static const hda_nid_t stac92hd71bxx_dmic_5port_nids[STAC92HD71BXX_NUM_DMICS] = {
416 0x18, 0
419 static const hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
420 0x22, 0
423 #define STAC92HD71BXX_NUM_CAPS 2
424 static const unsigned long stac92hd71bxx_capvols[] = {
425 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
426 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
428 #define stac92hd71bxx_capsws stac92hd71bxx_capvols
430 static const hda_nid_t stac925x_adc_nids[1] = {
431 0x03,
434 static const hda_nid_t stac925x_mux_nids[1] = {
435 0x0f,
438 static const hda_nid_t stac925x_dac_nids[1] = {
439 0x02,
442 #define STAC925X_NUM_DMICS 1
443 static const hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
444 0x15, 0
447 static const hda_nid_t stac925x_dmux_nids[1] = {
448 0x14,
451 static const unsigned long stac925x_capvols[] = {
452 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
454 static const unsigned long stac925x_capsws[] = {
455 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
458 static const hda_nid_t stac922x_adc_nids[2] = {
459 0x06, 0x07,
462 static const hda_nid_t stac922x_mux_nids[2] = {
463 0x12, 0x13,
466 #define STAC922X_NUM_CAPS 2
467 static const unsigned long stac922x_capvols[] = {
468 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
469 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
471 #define stac922x_capsws stac922x_capvols
473 static const hda_nid_t stac927x_slave_dig_outs[2] = {
474 0x1f, 0,
477 static const hda_nid_t stac927x_adc_nids[3] = {
478 0x07, 0x08, 0x09
481 static const hda_nid_t stac927x_mux_nids[3] = {
482 0x15, 0x16, 0x17
485 static const hda_nid_t stac927x_smux_nids[1] = {
486 0x21,
489 static const hda_nid_t stac927x_dac_nids[6] = {
490 0x02, 0x03, 0x04, 0x05, 0x06, 0
493 static const hda_nid_t stac927x_dmux_nids[1] = {
494 0x1b,
497 #define STAC927X_NUM_DMICS 2
498 static const hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
499 0x13, 0x14, 0
502 #define STAC927X_NUM_CAPS 3
503 static const unsigned long stac927x_capvols[] = {
504 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
505 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
506 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
508 static const unsigned long stac927x_capsws[] = {
509 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
510 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
511 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
514 static const char * const stac927x_spdif_labels[5] = {
515 "Digital Playback", "ADAT", "Analog Mux 1",
516 "Analog Mux 2", "Analog Mux 3"
519 static const hda_nid_t stac9205_adc_nids[2] = {
520 0x12, 0x13
523 static const hda_nid_t stac9205_mux_nids[2] = {
524 0x19, 0x1a
527 static const hda_nid_t stac9205_dmux_nids[1] = {
528 0x1d,
531 static const hda_nid_t stac9205_smux_nids[1] = {
532 0x21,
535 #define STAC9205_NUM_DMICS 2
536 static const hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
537 0x17, 0x18, 0
540 #define STAC9205_NUM_CAPS 2
541 static const unsigned long stac9205_capvols[] = {
542 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
543 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
545 static const unsigned long stac9205_capsws[] = {
546 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
547 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
550 static const hda_nid_t stac9200_pin_nids[8] = {
551 0x08, 0x09, 0x0d, 0x0e,
552 0x0f, 0x10, 0x11, 0x12,
555 static const hda_nid_t stac925x_pin_nids[8] = {
556 0x07, 0x08, 0x0a, 0x0b,
557 0x0c, 0x0d, 0x10, 0x11,
560 static const hda_nid_t stac922x_pin_nids[10] = {
561 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
562 0x0f, 0x10, 0x11, 0x15, 0x1b,
565 static const hda_nid_t stac92hd73xx_pin_nids[13] = {
566 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
567 0x0f, 0x10, 0x11, 0x12, 0x13,
568 0x14, 0x22, 0x23
571 #define STAC92HD71BXX_NUM_PINS 13
572 static const hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
573 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
574 0x00, 0x14, 0x18, 0x19, 0x1e,
575 0x1f, 0x20, 0x27
577 static const hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
578 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
579 0x0f, 0x14, 0x18, 0x19, 0x1e,
580 0x1f, 0x20, 0x27
583 static const hda_nid_t stac927x_pin_nids[14] = {
584 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
585 0x0f, 0x10, 0x11, 0x12, 0x13,
586 0x14, 0x21, 0x22, 0x23,
589 static const hda_nid_t stac9205_pin_nids[12] = {
590 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
591 0x0f, 0x14, 0x16, 0x17, 0x18,
592 0x21, 0x22,
595 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
596 struct snd_ctl_elem_info *uinfo)
598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
599 struct sigmatel_spec *spec = codec->spec;
600 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
603 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
604 struct snd_ctl_elem_value *ucontrol)
606 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
607 struct sigmatel_spec *spec = codec->spec;
608 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
610 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
611 return 0;
614 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
615 struct snd_ctl_elem_value *ucontrol)
617 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
618 struct sigmatel_spec *spec = codec->spec;
619 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
621 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
622 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
625 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
626 struct snd_ctl_elem_info *uinfo)
628 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
629 struct sigmatel_spec *spec = codec->spec;
630 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
633 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
634 struct snd_ctl_elem_value *ucontrol)
636 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
637 struct sigmatel_spec *spec = codec->spec;
638 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
640 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
641 return 0;
644 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
645 struct snd_ctl_elem_value *ucontrol)
647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
648 struct sigmatel_spec *spec = codec->spec;
649 struct hda_input_mux *smux = &spec->private_smux;
650 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
651 int err, val;
652 hda_nid_t nid;
654 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
655 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
656 if (err < 0)
657 return err;
659 if (spec->spdif_mute) {
660 if (smux_idx == 0)
661 nid = spec->multiout.dig_out_nid;
662 else
663 nid = codec->slave_dig_outs[smux_idx - 1];
664 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
665 val = HDA_AMP_MUTE;
666 else
667 val = 0;
668 /* un/mute SPDIF out */
669 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
670 HDA_AMP_MUTE, val);
672 return 0;
675 #ifdef CONFIG_SND_HDA_POWER_SAVE
676 static int stac_vrefout_set(struct hda_codec *codec,
677 hda_nid_t nid, unsigned int new_vref)
679 int error, pinctl;
681 snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
682 pinctl = snd_hda_codec_read(codec, nid, 0,
683 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
685 if (pinctl < 0)
686 return pinctl;
688 pinctl &= 0xff;
689 pinctl &= ~AC_PINCTL_VREFEN;
690 pinctl |= (new_vref & AC_PINCTL_VREFEN);
692 error = snd_hda_codec_write_cache(codec, nid, 0,
693 AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl);
694 if (error < 0)
695 return error;
697 return 1;
699 #endif
701 static unsigned int stac92xx_vref_set(struct hda_codec *codec,
702 hda_nid_t nid, unsigned int new_vref)
704 int error;
705 unsigned int pincfg;
706 pincfg = snd_hda_codec_read(codec, nid, 0,
707 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
709 pincfg &= 0xff;
710 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
711 pincfg |= new_vref;
713 if (new_vref == AC_PINCTL_VREF_HIZ)
714 pincfg |= AC_PINCTL_OUT_EN;
715 else
716 pincfg |= AC_PINCTL_IN_EN;
718 error = snd_hda_codec_write_cache(codec, nid, 0,
719 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
720 if (error < 0)
721 return error;
722 else
723 return 1;
726 static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
728 unsigned int vref;
729 vref = snd_hda_codec_read(codec, nid, 0,
730 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
731 vref &= AC_PINCTL_VREFEN;
732 return vref;
735 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
737 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
738 struct sigmatel_spec *spec = codec->spec;
739 return snd_hda_input_mux_info(spec->input_mux, uinfo);
742 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
744 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
745 struct sigmatel_spec *spec = codec->spec;
746 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
748 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
749 return 0;
752 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
754 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
755 struct sigmatel_spec *spec = codec->spec;
756 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
757 const struct hda_input_mux *imux = spec->input_mux;
758 unsigned int idx, prev_idx, didx;
760 idx = ucontrol->value.enumerated.item[0];
761 if (idx >= imux->num_items)
762 idx = imux->num_items - 1;
763 prev_idx = spec->cur_mux[adc_idx];
764 if (prev_idx == idx)
765 return 0;
766 if (idx < spec->num_analog_muxes) {
767 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
768 AC_VERB_SET_CONNECT_SEL,
769 imux->items[idx].index);
770 if (prev_idx >= spec->num_analog_muxes &&
771 spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) {
772 imux = spec->dinput_mux;
773 /* 0 = analog */
774 snd_hda_codec_write_cache(codec,
775 spec->dmux_nids[adc_idx], 0,
776 AC_VERB_SET_CONNECT_SEL,
777 imux->items[0].index);
779 } else {
780 imux = spec->dinput_mux;
781 /* first dimux item is hardcoded to select analog imux,
782 * so lets skip it
784 didx = idx - spec->num_analog_muxes + 1;
785 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
786 AC_VERB_SET_CONNECT_SEL,
787 imux->items[didx].index);
789 spec->cur_mux[adc_idx] = idx;
790 return 1;
793 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
794 struct snd_ctl_elem_info *uinfo)
796 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
797 struct sigmatel_spec *spec = codec->spec;
798 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
801 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
802 struct snd_ctl_elem_value *ucontrol)
804 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
805 struct sigmatel_spec *spec = codec->spec;
807 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
808 return 0;
811 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
812 struct snd_ctl_elem_value *ucontrol)
814 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
815 struct sigmatel_spec *spec = codec->spec;
817 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
818 spec->mono_nid, &spec->cur_mmux);
821 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
823 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
824 struct snd_ctl_elem_value *ucontrol)
826 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
827 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
828 struct sigmatel_spec *spec = codec->spec;
830 ucontrol->value.integer.value[0] = !!(spec->aloopback &
831 (spec->aloopback_mask << idx));
832 return 0;
835 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
836 struct snd_ctl_elem_value *ucontrol)
838 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
839 struct sigmatel_spec *spec = codec->spec;
840 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
841 unsigned int dac_mode;
842 unsigned int val, idx_val;
844 idx_val = spec->aloopback_mask << idx;
845 if (ucontrol->value.integer.value[0])
846 val = spec->aloopback | idx_val;
847 else
848 val = spec->aloopback & ~idx_val;
849 if (spec->aloopback == val)
850 return 0;
852 spec->aloopback = val;
854 /* Only return the bits defined by the shift value of the
855 * first two bytes of the mask
857 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
858 kcontrol->private_value & 0xFFFF, 0x0);
859 dac_mode >>= spec->aloopback_shift;
861 if (spec->aloopback & idx_val) {
862 snd_hda_power_up(codec);
863 dac_mode |= idx_val;
864 } else {
865 snd_hda_power_down(codec);
866 dac_mode &= ~idx_val;
869 snd_hda_codec_write_cache(codec, codec->afg, 0,
870 kcontrol->private_value >> 16, dac_mode);
872 return 1;
875 static const struct hda_verb stac9200_core_init[] = {
876 /* set dac0mux for dac converter */
877 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
881 static const struct hda_verb stac9200_eapd_init[] = {
882 /* set dac0mux for dac converter */
883 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
884 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
888 static const struct hda_verb dell_eq_core_init[] = {
889 /* set master volume to max value without distortion
890 * and direct control */
891 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
895 static const struct hda_verb stac92hd73xx_core_init[] = {
896 /* set master volume and direct control */
897 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
901 static const struct hda_verb stac92hd83xxx_core_init[] = {
902 /* power state controls amps */
903 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
907 static const struct hda_verb stac92hd71bxx_core_init[] = {
908 /* set master volume and direct control */
909 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
913 static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
914 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
915 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
916 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
917 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
921 static const struct hda_verb stac925x_core_init[] = {
922 /* set dac0mux for dac converter */
923 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
924 /* mute the master volume */
925 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
929 static const struct hda_verb stac922x_core_init[] = {
930 /* set master volume and direct control */
931 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
935 static const struct hda_verb d965_core_init[] = {
936 /* set master volume and direct control */
937 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
938 /* unmute node 0x1b */
939 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
940 /* select node 0x03 as DAC */
941 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
945 static const struct hda_verb dell_3st_core_init[] = {
946 /* don't set delta bit */
947 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
948 /* unmute node 0x1b */
949 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
950 /* select node 0x03 as DAC */
951 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
955 static const struct hda_verb stac927x_core_init[] = {
956 /* set master volume and direct control */
957 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
958 /* enable analog pc beep path */
959 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
963 static const struct hda_verb stac927x_volknob_core_init[] = {
964 /* don't set delta bit */
965 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
966 /* enable analog pc beep path */
967 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
971 static const struct hda_verb stac9205_core_init[] = {
972 /* set master volume and direct control */
973 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
974 /* enable analog pc beep path */
975 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
979 #define STAC_MONO_MUX \
981 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
982 .name = "Mono Mux", \
983 .count = 1, \
984 .info = stac92xx_mono_mux_enum_info, \
985 .get = stac92xx_mono_mux_enum_get, \
986 .put = stac92xx_mono_mux_enum_put, \
989 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
991 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
992 .name = "Analog Loopback", \
993 .count = cnt, \
994 .info = stac92xx_aloopback_info, \
995 .get = stac92xx_aloopback_get, \
996 .put = stac92xx_aloopback_put, \
997 .private_value = verb_read | (verb_write << 16), \
1000 #define DC_BIAS(xname, idx, nid) \
1002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1003 .name = xname, \
1004 .index = idx, \
1005 .info = stac92xx_dc_bias_info, \
1006 .get = stac92xx_dc_bias_get, \
1007 .put = stac92xx_dc_bias_put, \
1008 .private_value = nid, \
1011 static const struct snd_kcontrol_new stac9200_mixer[] = {
1012 HDA_CODEC_VOLUME_MIN_MUTE("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1013 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
1014 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1015 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
1016 { } /* end */
1019 static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1020 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1024 static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1025 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1029 static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1030 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1035 static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1036 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1039 static const struct snd_kcontrol_new stac925x_mixer[] = {
1040 HDA_CODEC_VOLUME_MIN_MUTE("Master Playback Volume", 0xe, 0, HDA_OUTPUT),
1041 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1042 { } /* end */
1045 static const struct snd_kcontrol_new stac9205_loopback[] = {
1046 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1050 static const struct snd_kcontrol_new stac927x_loopback[] = {
1051 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1055 static struct snd_kcontrol_new stac_dmux_mixer = {
1056 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1057 .name = "Digital Input Source",
1058 /* count set later */
1059 .info = stac92xx_dmux_enum_info,
1060 .get = stac92xx_dmux_enum_get,
1061 .put = stac92xx_dmux_enum_put,
1064 static struct snd_kcontrol_new stac_smux_mixer = {
1065 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1066 .name = "IEC958 Playback Source",
1067 /* count set later */
1068 .info = stac92xx_smux_enum_info,
1069 .get = stac92xx_smux_enum_get,
1070 .put = stac92xx_smux_enum_put,
1073 static const char * const slave_vols[] = {
1074 "Front Playback Volume",
1075 "Surround Playback Volume",
1076 "Center Playback Volume",
1077 "LFE Playback Volume",
1078 "Side Playback Volume",
1079 "Headphone Playback Volume",
1080 "Speaker Playback Volume",
1081 NULL
1084 static const char * const slave_sws[] = {
1085 "Front Playback Switch",
1086 "Surround Playback Switch",
1087 "Center Playback Switch",
1088 "LFE Playback Switch",
1089 "Side Playback Switch",
1090 "Headphone Playback Switch",
1091 "Speaker Playback Switch",
1092 "IEC958 Playback Switch",
1093 NULL
1096 static void stac92xx_free_kctls(struct hda_codec *codec);
1097 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1099 static int stac92xx_build_controls(struct hda_codec *codec)
1101 struct sigmatel_spec *spec = codec->spec;
1102 struct auto_pin_cfg *cfg = &spec->autocfg;
1103 hda_nid_t nid;
1104 int err;
1105 int i;
1107 if (spec->mixer) {
1108 err = snd_hda_add_new_ctls(codec, spec->mixer);
1109 if (err < 0)
1110 return err;
1113 for (i = 0; i < spec->num_mixers; i++) {
1114 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1115 if (err < 0)
1116 return err;
1118 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1119 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
1120 stac_dmux_mixer.count = spec->num_dmuxes;
1121 err = snd_hda_ctl_add(codec, 0,
1122 snd_ctl_new1(&stac_dmux_mixer, codec));
1123 if (err < 0)
1124 return err;
1126 if (spec->num_smuxes > 0) {
1127 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1128 struct hda_input_mux *smux = &spec->private_smux;
1129 /* check for mute support on SPDIF out */
1130 if (wcaps & AC_WCAP_OUT_AMP) {
1131 snd_hda_add_imux_item(smux, "Off", 0, NULL);
1132 spec->spdif_mute = 1;
1134 stac_smux_mixer.count = spec->num_smuxes;
1135 err = snd_hda_ctl_add(codec, 0,
1136 snd_ctl_new1(&stac_smux_mixer, codec));
1137 if (err < 0)
1138 return err;
1141 if (spec->multiout.dig_out_nid) {
1142 err = snd_hda_create_spdif_out_ctls(codec,
1143 spec->multiout.dig_out_nid,
1144 spec->multiout.dig_out_nid);
1145 if (err < 0)
1146 return err;
1147 err = snd_hda_create_spdif_share_sw(codec,
1148 &spec->multiout);
1149 if (err < 0)
1150 return err;
1151 spec->multiout.share_spdif = 1;
1153 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1154 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1155 if (err < 0)
1156 return err;
1159 /* if we have no master control, let's create it */
1160 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1161 unsigned int vmaster_tlv[4];
1162 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1163 HDA_OUTPUT, vmaster_tlv);
1164 /* correct volume offset */
1165 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1166 /* minimum value is actually mute */
1167 vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
1168 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1169 vmaster_tlv, slave_vols);
1170 if (err < 0)
1171 return err;
1173 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1174 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1175 NULL, slave_sws);
1176 if (err < 0)
1177 return err;
1180 if (spec->aloopback_ctl &&
1181 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1182 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1183 if (err < 0)
1184 return err;
1187 stac92xx_free_kctls(codec); /* no longer needed */
1189 /* create jack input elements */
1190 if (spec->hp_detect) {
1191 for (i = 0; i < cfg->hp_outs; i++) {
1192 int type = SND_JACK_HEADPHONE;
1193 nid = cfg->hp_pins[i];
1194 /* jack detection */
1195 if (cfg->hp_outs == i)
1196 type |= SND_JACK_LINEOUT;
1197 err = stac92xx_add_jack(codec, nid, type);
1198 if (err < 0)
1199 return err;
1202 for (i = 0; i < cfg->line_outs; i++) {
1203 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1204 SND_JACK_LINEOUT);
1205 if (err < 0)
1206 return err;
1208 for (i = 0; i < cfg->num_inputs; i++) {
1209 nid = cfg->inputs[i].pin;
1210 err = stac92xx_add_jack(codec, nid, SND_JACK_MICROPHONE);
1211 if (err < 0)
1212 return err;
1215 return 0;
1218 static const unsigned int ref9200_pin_configs[8] = {
1219 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1220 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1223 static const unsigned int gateway9200_m4_pin_configs[8] = {
1224 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1225 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1227 static const unsigned int gateway9200_m4_2_pin_configs[8] = {
1228 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1229 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1233 STAC 9200 pin configs for
1234 102801A8
1235 102801DE
1236 102801E8
1238 static const unsigned int dell9200_d21_pin_configs[8] = {
1239 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1240 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1244 STAC 9200 pin configs for
1245 102801C0
1246 102801C1
1248 static const unsigned int dell9200_d22_pin_configs[8] = {
1249 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1250 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1254 STAC 9200 pin configs for
1255 102801C4 (Dell Dimension E310)
1256 102801C5
1257 102801C7
1258 102801D9
1259 102801DA
1260 102801E3
1262 static const unsigned int dell9200_d23_pin_configs[8] = {
1263 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1264 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1269 STAC 9200-32 pin configs for
1270 102801B5 (Dell Inspiron 630m)
1271 102801D8 (Dell Inspiron 640m)
1273 static const unsigned int dell9200_m21_pin_configs[8] = {
1274 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1275 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1279 STAC 9200-32 pin configs for
1280 102801C2 (Dell Latitude D620)
1281 102801C8
1282 102801CC (Dell Latitude D820)
1283 102801D4
1284 102801D6
1286 static const unsigned int dell9200_m22_pin_configs[8] = {
1287 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1288 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1292 STAC 9200-32 pin configs for
1293 102801CE (Dell XPS M1710)
1294 102801CF (Dell Precision M90)
1296 static const unsigned int dell9200_m23_pin_configs[8] = {
1297 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1298 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1302 STAC 9200-32 pin configs for
1303 102801C9
1304 102801CA
1305 102801CB (Dell Latitude 120L)
1306 102801D3
1308 static const unsigned int dell9200_m24_pin_configs[8] = {
1309 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1310 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1314 STAC 9200-32 pin configs for
1315 102801BD (Dell Inspiron E1505n)
1316 102801EE
1317 102801EF
1319 static const unsigned int dell9200_m25_pin_configs[8] = {
1320 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1321 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1325 STAC 9200-32 pin configs for
1326 102801F5 (Dell Inspiron 1501)
1327 102801F6
1329 static const unsigned int dell9200_m26_pin_configs[8] = {
1330 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1331 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1335 STAC 9200-32
1336 102801CD (Dell Inspiron E1705/9400)
1338 static const unsigned int dell9200_m27_pin_configs[8] = {
1339 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1340 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1343 static const unsigned int oqo9200_pin_configs[8] = {
1344 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1345 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1349 static const unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1350 [STAC_REF] = ref9200_pin_configs,
1351 [STAC_9200_OQO] = oqo9200_pin_configs,
1352 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1353 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1354 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1355 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1356 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1357 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1358 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1359 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1360 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1361 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1362 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1363 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1364 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1367 static const char * const stac9200_models[STAC_9200_MODELS] = {
1368 [STAC_AUTO] = "auto",
1369 [STAC_REF] = "ref",
1370 [STAC_9200_OQO] = "oqo",
1371 [STAC_9200_DELL_D21] = "dell-d21",
1372 [STAC_9200_DELL_D22] = "dell-d22",
1373 [STAC_9200_DELL_D23] = "dell-d23",
1374 [STAC_9200_DELL_M21] = "dell-m21",
1375 [STAC_9200_DELL_M22] = "dell-m22",
1376 [STAC_9200_DELL_M23] = "dell-m23",
1377 [STAC_9200_DELL_M24] = "dell-m24",
1378 [STAC_9200_DELL_M25] = "dell-m25",
1379 [STAC_9200_DELL_M26] = "dell-m26",
1380 [STAC_9200_DELL_M27] = "dell-m27",
1381 [STAC_9200_M4] = "gateway-m4",
1382 [STAC_9200_M4_2] = "gateway-m4-2",
1383 [STAC_9200_PANASONIC] = "panasonic",
1386 static const struct snd_pci_quirk stac9200_cfg_tbl[] = {
1387 /* SigmaTel reference board */
1388 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1389 "DFI LanParty", STAC_REF),
1390 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1391 "DFI LanParty", STAC_REF),
1392 /* Dell laptops have BIOS problem */
1393 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1394 "unknown Dell", STAC_9200_DELL_D21),
1395 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1396 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1397 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1398 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1399 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1400 "unknown Dell", STAC_9200_DELL_D22),
1401 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1402 "unknown Dell", STAC_9200_DELL_D22),
1403 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1404 "Dell Latitude D620", STAC_9200_DELL_M22),
1405 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1406 "unknown Dell", STAC_9200_DELL_D23),
1407 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1408 "unknown Dell", STAC_9200_DELL_D23),
1409 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1410 "unknown Dell", STAC_9200_DELL_M22),
1411 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1412 "unknown Dell", STAC_9200_DELL_M24),
1413 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1414 "unknown Dell", STAC_9200_DELL_M24),
1415 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1416 "Dell Latitude 120L", STAC_9200_DELL_M24),
1417 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1418 "Dell Latitude D820", STAC_9200_DELL_M22),
1419 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1420 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1421 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1422 "Dell XPS M1710", STAC_9200_DELL_M23),
1423 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1424 "Dell Precision M90", STAC_9200_DELL_M23),
1425 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1426 "unknown Dell", STAC_9200_DELL_M22),
1427 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1428 "unknown Dell", STAC_9200_DELL_M22),
1429 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1430 "unknown Dell", STAC_9200_DELL_M22),
1431 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1432 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1433 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1434 "unknown Dell", STAC_9200_DELL_D23),
1435 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1436 "unknown Dell", STAC_9200_DELL_D23),
1437 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1438 "unknown Dell", STAC_9200_DELL_D21),
1439 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1440 "unknown Dell", STAC_9200_DELL_D23),
1441 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1442 "unknown Dell", STAC_9200_DELL_D21),
1443 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1444 "unknown Dell", STAC_9200_DELL_M25),
1445 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1446 "unknown Dell", STAC_9200_DELL_M25),
1447 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1448 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1449 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1450 "unknown Dell", STAC_9200_DELL_M26),
1451 /* Panasonic */
1452 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1453 /* Gateway machines needs EAPD to be set on resume */
1454 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1455 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1456 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1457 /* OQO Mobile */
1458 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1459 {} /* terminator */
1462 static const unsigned int ref925x_pin_configs[8] = {
1463 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1464 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1467 static const unsigned int stac925xM1_pin_configs[8] = {
1468 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1469 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1472 static const unsigned int stac925xM1_2_pin_configs[8] = {
1473 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1474 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1477 static const unsigned int stac925xM2_pin_configs[8] = {
1478 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1479 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1482 static const unsigned int stac925xM2_2_pin_configs[8] = {
1483 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1484 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1487 static const unsigned int stac925xM3_pin_configs[8] = {
1488 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1489 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1492 static const unsigned int stac925xM5_pin_configs[8] = {
1493 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1494 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1497 static const unsigned int stac925xM6_pin_configs[8] = {
1498 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1499 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1502 static const unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1503 [STAC_REF] = ref925x_pin_configs,
1504 [STAC_M1] = stac925xM1_pin_configs,
1505 [STAC_M1_2] = stac925xM1_2_pin_configs,
1506 [STAC_M2] = stac925xM2_pin_configs,
1507 [STAC_M2_2] = stac925xM2_2_pin_configs,
1508 [STAC_M3] = stac925xM3_pin_configs,
1509 [STAC_M5] = stac925xM5_pin_configs,
1510 [STAC_M6] = stac925xM6_pin_configs,
1513 static const char * const stac925x_models[STAC_925x_MODELS] = {
1514 [STAC_925x_AUTO] = "auto",
1515 [STAC_REF] = "ref",
1516 [STAC_M1] = "m1",
1517 [STAC_M1_2] = "m1-2",
1518 [STAC_M2] = "m2",
1519 [STAC_M2_2] = "m2-2",
1520 [STAC_M3] = "m3",
1521 [STAC_M5] = "m5",
1522 [STAC_M6] = "m6",
1525 static const struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1526 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1527 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1528 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1529 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1530 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1531 /* Not sure about the brand name for those */
1532 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1533 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1534 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1535 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1536 {} /* terminator */
1539 static const struct snd_pci_quirk stac925x_cfg_tbl[] = {
1540 /* SigmaTel reference board */
1541 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1542 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1543 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1545 /* Default table for unknown ID */
1546 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1548 {} /* terminator */
1551 static const unsigned int ref92hd73xx_pin_configs[13] = {
1552 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1553 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1554 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1555 0x01452050,
1558 static const unsigned int dell_m6_pin_configs[13] = {
1559 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1560 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1561 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1562 0x4f0000f0,
1565 static const unsigned int alienware_m17x_pin_configs[13] = {
1566 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1567 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1568 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1569 0x904601b0,
1572 static const unsigned int intel_dg45id_pin_configs[13] = {
1573 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
1574 0x01A19250, 0x01011212, 0x01016211
1577 static const unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1578 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1579 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1580 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1581 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1582 [STAC_DELL_EQ] = dell_m6_pin_configs,
1583 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
1584 [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
1587 static const char * const stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1588 [STAC_92HD73XX_AUTO] = "auto",
1589 [STAC_92HD73XX_NO_JD] = "no-jd",
1590 [STAC_92HD73XX_REF] = "ref",
1591 [STAC_92HD73XX_INTEL] = "intel",
1592 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1593 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1594 [STAC_DELL_M6_BOTH] = "dell-m6",
1595 [STAC_DELL_EQ] = "dell-eq",
1596 [STAC_ALIENWARE_M17X] = "alienware",
1599 static const struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1600 /* SigmaTel reference board */
1601 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1602 "DFI LanParty", STAC_92HD73XX_REF),
1603 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1604 "DFI LanParty", STAC_92HD73XX_REF),
1605 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1606 "Intel DG45ID", STAC_92HD73XX_INTEL),
1607 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1608 "Intel DG45FC", STAC_92HD73XX_INTEL),
1609 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1610 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1611 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1612 "unknown Dell", STAC_DELL_M6_DMIC),
1613 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1614 "unknown Dell", STAC_DELL_M6_BOTH),
1615 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1616 "unknown Dell", STAC_DELL_M6_BOTH),
1617 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1618 "unknown Dell", STAC_DELL_M6_AMIC),
1619 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1620 "unknown Dell", STAC_DELL_M6_AMIC),
1621 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1622 "unknown Dell", STAC_DELL_M6_DMIC),
1623 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1624 "unknown Dell", STAC_DELL_M6_DMIC),
1625 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1626 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1627 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1628 "Dell Studio 17", STAC_DELL_M6_DMIC),
1629 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1630 "Dell Studio 1555", STAC_DELL_M6_DMIC),
1631 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1632 "Dell Studio 1557", STAC_DELL_M6_DMIC),
1633 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
1634 "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
1635 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
1636 "Dell Studio 1558", STAC_DELL_M6_DMIC),
1637 {} /* terminator */
1640 static const struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
1641 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1642 "Alienware M17x", STAC_ALIENWARE_M17X),
1643 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1644 "Alienware M17x", STAC_ALIENWARE_M17X),
1645 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
1646 "Alienware M17x", STAC_ALIENWARE_M17X),
1647 {} /* terminator */
1650 static const unsigned int ref92hd83xxx_pin_configs[10] = {
1651 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1652 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1653 0x01451160, 0x98560170,
1656 static const unsigned int dell_s14_pin_configs[10] = {
1657 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1658 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
1659 0x40f000f0, 0x40f000f0,
1662 static const unsigned int dell_vostro_3500_pin_configs[10] = {
1663 0x02a11020, 0x0221101f, 0x400000f0, 0x90170110,
1664 0x400000f1, 0x400000f2, 0x400000f3, 0x90a60160,
1665 0x400000f4, 0x400000f5,
1668 static const unsigned int hp_dv7_4000_pin_configs[10] = {
1669 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
1670 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
1671 0x40f000f0, 0x40f000f0,
1674 static const unsigned int hp_cNB11_intquad_pin_configs[10] = {
1675 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110,
1676 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130,
1677 0x40f000f0, 0x40f000f0,
1680 static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1681 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1682 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1683 [STAC_DELL_S14] = dell_s14_pin_configs,
1684 [STAC_DELL_VOSTRO_3500] = dell_vostro_3500_pin_configs,
1685 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs,
1686 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
1689 static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1690 [STAC_92HD83XXX_AUTO] = "auto",
1691 [STAC_92HD83XXX_REF] = "ref",
1692 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1693 [STAC_DELL_S14] = "dell-s14",
1694 [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
1695 [STAC_92HD83XXX_HP] = "hp",
1696 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
1697 [STAC_HP_DV7_4000] = "hp-dv7-4000",
1700 static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1701 /* SigmaTel reference board */
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1703 "DFI LanParty", STAC_92HD83XXX_REF),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1705 "DFI LanParty", STAC_92HD83XXX_REF),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1707 "unknown Dell", STAC_DELL_S14),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
1709 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
1710 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x3600,
1711 "HP", STAC_92HD83XXX_HP),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
1713 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
1715 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
1717 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
1719 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1720 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
1721 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1722 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
1723 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1724 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
1725 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1726 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
1727 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1728 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
1729 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1730 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
1731 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1732 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
1733 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1734 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
1735 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1736 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
1737 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1738 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
1739 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1740 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
1741 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1742 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
1743 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1744 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
1745 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1746 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
1747 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1748 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
1749 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1750 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
1751 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1752 {} /* terminator */
1755 static const unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1756 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1757 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1758 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1759 0x00000000
1762 static const unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1763 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1764 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1765 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1766 0x00000000
1769 static const unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1770 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1771 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1772 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1773 0x00000000
1776 static const unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1777 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1778 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1779 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1780 0x00000000
1783 static const unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1784 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1785 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1786 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1787 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1788 [STAC_HP_M4] = NULL,
1789 [STAC_HP_DV4] = NULL,
1790 [STAC_HP_DV5] = NULL,
1791 [STAC_HP_HDX] = NULL,
1792 [STAC_HP_DV4_1222NR] = NULL,
1795 static const char * const stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1796 [STAC_92HD71BXX_AUTO] = "auto",
1797 [STAC_92HD71BXX_REF] = "ref",
1798 [STAC_DELL_M4_1] = "dell-m4-1",
1799 [STAC_DELL_M4_2] = "dell-m4-2",
1800 [STAC_DELL_M4_3] = "dell-m4-3",
1801 [STAC_HP_M4] = "hp-m4",
1802 [STAC_HP_DV4] = "hp-dv4",
1803 [STAC_HP_DV5] = "hp-dv5",
1804 [STAC_HP_HDX] = "hp-hdx",
1805 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
1808 static const struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1809 /* SigmaTel reference board */
1810 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1811 "DFI LanParty", STAC_92HD71BXX_REF),
1812 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1813 "DFI LanParty", STAC_92HD71BXX_REF),
1814 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1815 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
1816 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
1817 "HP", STAC_HP_DV5),
1818 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1819 "HP", STAC_HP_DV5),
1820 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1821 "HP dv4-7", STAC_HP_DV4),
1822 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1823 "HP dv4-7", STAC_HP_DV5),
1824 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1825 "HP HDX", STAC_HP_HDX), /* HDX18 */
1826 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1827 "HP mini 1000", STAC_HP_M4),
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1829 "HP HDX", STAC_HP_HDX), /* HDX16 */
1830 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
1831 "HP dv6", STAC_HP_DV5),
1832 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
1833 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
1834 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
1835 "HP DV6", STAC_HP_DV5),
1836 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1837 "HP", STAC_HP_DV5),
1838 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1839 "unknown Dell", STAC_DELL_M4_1),
1840 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1841 "unknown Dell", STAC_DELL_M4_1),
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1843 "unknown Dell", STAC_DELL_M4_1),
1844 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1845 "unknown Dell", STAC_DELL_M4_1),
1846 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1847 "unknown Dell", STAC_DELL_M4_1),
1848 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1849 "unknown Dell", STAC_DELL_M4_1),
1850 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1851 "unknown Dell", STAC_DELL_M4_1),
1852 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1853 "unknown Dell", STAC_DELL_M4_2),
1854 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1855 "unknown Dell", STAC_DELL_M4_2),
1856 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1857 "unknown Dell", STAC_DELL_M4_2),
1858 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1859 "unknown Dell", STAC_DELL_M4_2),
1860 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1861 "unknown Dell", STAC_DELL_M4_3),
1862 {} /* terminator */
1865 static const unsigned int ref922x_pin_configs[10] = {
1866 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1867 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1868 0x40000100, 0x40000100,
1872 STAC 922X pin configs for
1873 102801A7
1874 102801AB
1875 102801A9
1876 102801D1
1877 102801D2
1879 static const unsigned int dell_922x_d81_pin_configs[10] = {
1880 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1881 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1882 0x01813122, 0x400001f2,
1886 STAC 922X pin configs for
1887 102801AC
1888 102801D0
1890 static const unsigned int dell_922x_d82_pin_configs[10] = {
1891 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1892 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1893 0x01813122, 0x400001f1,
1897 STAC 922X pin configs for
1898 102801BF
1900 static const unsigned int dell_922x_m81_pin_configs[10] = {
1901 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1902 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1903 0x40C003f1, 0x405003f0,
1907 STAC 9221 A1 pin configs for
1908 102801D7 (Dell XPS M1210)
1910 static const unsigned int dell_922x_m82_pin_configs[10] = {
1911 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1912 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1913 0x508003f3, 0x405003f4,
1916 static const unsigned int d945gtp3_pin_configs[10] = {
1917 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1918 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1919 0x02a19120, 0x40000100,
1922 static const unsigned int d945gtp5_pin_configs[10] = {
1923 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1924 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1925 0x02a19320, 0x40000100,
1928 static const unsigned int intel_mac_v1_pin_configs[10] = {
1929 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1930 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1931 0x400000fc, 0x400000fb,
1934 static const unsigned int intel_mac_v2_pin_configs[10] = {
1935 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1936 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1937 0x400000fc, 0x400000fb,
1940 static const unsigned int intel_mac_v3_pin_configs[10] = {
1941 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1942 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1943 0x400000fc, 0x400000fb,
1946 static const unsigned int intel_mac_v4_pin_configs[10] = {
1947 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1948 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1949 0x400000fc, 0x400000fb,
1952 static const unsigned int intel_mac_v5_pin_configs[10] = {
1953 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1954 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1955 0x400000fc, 0x400000fb,
1958 static const unsigned int ecs202_pin_configs[10] = {
1959 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1960 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1961 0x9037012e, 0x40e000f2,
1964 static const unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1965 [STAC_D945_REF] = ref922x_pin_configs,
1966 [STAC_D945GTP3] = d945gtp3_pin_configs,
1967 [STAC_D945GTP5] = d945gtp5_pin_configs,
1968 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1969 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1970 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1971 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1972 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1973 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1974 /* for backward compatibility */
1975 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1976 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1977 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1978 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1979 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1980 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1981 [STAC_ECS_202] = ecs202_pin_configs,
1982 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1983 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1984 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1985 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1988 static const char * const stac922x_models[STAC_922X_MODELS] = {
1989 [STAC_922X_AUTO] = "auto",
1990 [STAC_D945_REF] = "ref",
1991 [STAC_D945GTP5] = "5stack",
1992 [STAC_D945GTP3] = "3stack",
1993 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1994 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1995 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1996 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1997 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1998 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1999 /* for backward compatibility */
2000 [STAC_MACMINI] = "macmini",
2001 [STAC_MACBOOK] = "macbook",
2002 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
2003 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
2004 [STAC_IMAC_INTEL] = "imac-intel",
2005 [STAC_IMAC_INTEL_20] = "imac-intel-20",
2006 [STAC_ECS_202] = "ecs202",
2007 [STAC_922X_DELL_D81] = "dell-d81",
2008 [STAC_922X_DELL_D82] = "dell-d82",
2009 [STAC_922X_DELL_M81] = "dell-m81",
2010 [STAC_922X_DELL_M82] = "dell-m82",
2013 static const struct snd_pci_quirk stac922x_cfg_tbl[] = {
2014 /* SigmaTel reference board */
2015 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2016 "DFI LanParty", STAC_D945_REF),
2017 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2018 "DFI LanParty", STAC_D945_REF),
2019 /* Intel 945G based systems */
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2021 "Intel D945G", STAC_D945GTP3),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2023 "Intel D945G", STAC_D945GTP3),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2025 "Intel D945G", STAC_D945GTP3),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2027 "Intel D945G", STAC_D945GTP3),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2029 "Intel D945G", STAC_D945GTP3),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2031 "Intel D945G", STAC_D945GTP3),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2033 "Intel D945G", STAC_D945GTP3),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2035 "Intel D945G", STAC_D945GTP3),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2037 "Intel D945G", STAC_D945GTP3),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2039 "Intel D945G", STAC_D945GTP3),
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2041 "Intel D945G", STAC_D945GTP3),
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2043 "Intel D945G", STAC_D945GTP3),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2045 "Intel D945G", STAC_D945GTP3),
2046 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2047 "Intel D945G", STAC_D945GTP3),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2049 "Intel D945G", STAC_D945GTP3),
2050 /* Intel D945G 5-stack systems */
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2052 "Intel D945G", STAC_D945GTP5),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2054 "Intel D945G", STAC_D945GTP5),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2056 "Intel D945G", STAC_D945GTP5),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2058 "Intel D945G", STAC_D945GTP5),
2059 /* Intel 945P based systems */
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2061 "Intel D945P", STAC_D945GTP3),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2063 "Intel D945P", STAC_D945GTP3),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2065 "Intel D945P", STAC_D945GTP3),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2067 "Intel D945P", STAC_D945GTP3),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2069 "Intel D945P", STAC_D945GTP3),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2071 "Intel D945P", STAC_D945GTP5),
2072 /* other intel */
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2074 "Intel D945", STAC_D945_REF),
2075 /* other systems */
2076 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2077 SND_PCI_QUIRK(0x8384, 0x7680,
2078 "Mac", STAC_INTEL_MAC_AUTO),
2079 /* Dell systems */
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2081 "unknown Dell", STAC_922X_DELL_D81),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2083 "unknown Dell", STAC_922X_DELL_D81),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2085 "unknown Dell", STAC_922X_DELL_D81),
2086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2087 "unknown Dell", STAC_922X_DELL_D82),
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2089 "unknown Dell", STAC_922X_DELL_M81),
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2091 "unknown Dell", STAC_922X_DELL_D82),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2093 "unknown Dell", STAC_922X_DELL_D81),
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2095 "unknown Dell", STAC_922X_DELL_D81),
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2097 "Dell XPS M1210", STAC_922X_DELL_M82),
2098 /* ECS/PC Chips boards */
2099 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2100 "ECS/PC chips", STAC_ECS_202),
2101 {} /* terminator */
2104 static const unsigned int ref927x_pin_configs[14] = {
2105 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2106 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2107 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2108 0x01c42190, 0x40000100,
2111 static const unsigned int d965_3st_pin_configs[14] = {
2112 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2113 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2114 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2115 0x40000100, 0x40000100
2118 static const unsigned int d965_5st_pin_configs[14] = {
2119 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2120 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2121 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2122 0x40000100, 0x40000100
2125 static const unsigned int d965_5st_no_fp_pin_configs[14] = {
2126 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2127 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2128 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2129 0x40000100, 0x40000100
2132 static const unsigned int dell_3st_pin_configs[14] = {
2133 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2134 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2135 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2136 0x40c003fc, 0x40000100
2139 static const unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2140 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2141 [STAC_D965_REF] = ref927x_pin_configs,
2142 [STAC_D965_3ST] = d965_3st_pin_configs,
2143 [STAC_D965_5ST] = d965_5st_pin_configs,
2144 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
2145 [STAC_DELL_3ST] = dell_3st_pin_configs,
2146 [STAC_DELL_BIOS] = NULL,
2147 [STAC_927X_VOLKNOB] = NULL,
2150 static const char * const stac927x_models[STAC_927X_MODELS] = {
2151 [STAC_927X_AUTO] = "auto",
2152 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2153 [STAC_D965_REF] = "ref",
2154 [STAC_D965_3ST] = "3stack",
2155 [STAC_D965_5ST] = "5stack",
2156 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
2157 [STAC_DELL_3ST] = "dell-3stack",
2158 [STAC_DELL_BIOS] = "dell-bios",
2159 [STAC_927X_VOLKNOB] = "volknob",
2162 static const struct snd_pci_quirk stac927x_cfg_tbl[] = {
2163 /* SigmaTel reference board */
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2165 "DFI LanParty", STAC_D965_REF),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2167 "DFI LanParty", STAC_D965_REF),
2168 /* Intel 946 based systems */
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2171 /* 965 based 3 stack systems */
2172 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2173 "Intel D965", STAC_D965_3ST),
2174 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2175 "Intel D965", STAC_D965_3ST),
2176 /* Dell 3 stack systems */
2177 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2179 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2180 /* Dell 3 stack systems with verb table in BIOS */
2181 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
2183 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2185 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
2186 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2187 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2188 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2189 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2190 /* 965 based 5 stack systems */
2191 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2192 "Intel D965", STAC_D965_5ST),
2193 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2194 "Intel D965", STAC_D965_5ST),
2195 /* volume-knob fixes */
2196 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
2197 {} /* terminator */
2200 static const unsigned int ref9205_pin_configs[12] = {
2201 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2202 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2203 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2207 STAC 9205 pin configs for
2208 102801F1
2209 102801F2
2210 102801FC
2211 102801FD
2212 10280204
2213 1028021F
2214 10280228 (Dell Vostro 1500)
2215 10280229 (Dell Vostro 1700)
2217 static const unsigned int dell_9205_m42_pin_configs[12] = {
2218 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2219 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2220 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2224 STAC 9205 pin configs for
2225 102801F9
2226 102801FA
2227 102801FE
2228 102801FF (Dell Precision M4300)
2229 10280206
2230 10280200
2231 10280201
2233 static const unsigned int dell_9205_m43_pin_configs[12] = {
2234 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2235 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2236 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2239 static const unsigned int dell_9205_m44_pin_configs[12] = {
2240 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2241 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2242 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2245 static const unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2246 [STAC_9205_REF] = ref9205_pin_configs,
2247 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2248 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2249 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2250 [STAC_9205_EAPD] = NULL,
2253 static const char * const stac9205_models[STAC_9205_MODELS] = {
2254 [STAC_9205_AUTO] = "auto",
2255 [STAC_9205_REF] = "ref",
2256 [STAC_9205_DELL_M42] = "dell-m42",
2257 [STAC_9205_DELL_M43] = "dell-m43",
2258 [STAC_9205_DELL_M44] = "dell-m44",
2259 [STAC_9205_EAPD] = "eapd",
2262 static const struct snd_pci_quirk stac9205_cfg_tbl[] = {
2263 /* SigmaTel reference board */
2264 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2265 "DFI LanParty", STAC_9205_REF),
2266 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2267 "SigmaTel", STAC_9205_REF),
2268 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2269 "DFI LanParty", STAC_9205_REF),
2270 /* Dell */
2271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2272 "unknown Dell", STAC_9205_DELL_M42),
2273 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2274 "unknown Dell", STAC_9205_DELL_M42),
2275 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2276 "Dell Precision", STAC_9205_DELL_M43),
2277 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2278 "Dell Precision", STAC_9205_DELL_M43),
2279 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2280 "Dell Precision", STAC_9205_DELL_M43),
2281 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2282 "unknown Dell", STAC_9205_DELL_M42),
2283 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2284 "unknown Dell", STAC_9205_DELL_M42),
2285 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2286 "Dell Precision", STAC_9205_DELL_M43),
2287 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2288 "Dell Precision M4300", STAC_9205_DELL_M43),
2289 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2290 "unknown Dell", STAC_9205_DELL_M42),
2291 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2292 "Dell Precision", STAC_9205_DELL_M43),
2293 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2294 "Dell Precision", STAC_9205_DELL_M43),
2295 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2296 "Dell Precision", STAC_9205_DELL_M43),
2297 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2298 "Dell Inspiron", STAC_9205_DELL_M44),
2299 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2300 "Dell Vostro 1500", STAC_9205_DELL_M42),
2301 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
2302 "Dell Vostro 1700", STAC_9205_DELL_M42),
2303 /* Gateway */
2304 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
2305 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2306 {} /* terminator */
2309 static void stac92xx_set_config_regs(struct hda_codec *codec,
2310 const unsigned int *pincfgs)
2312 int i;
2313 struct sigmatel_spec *spec = codec->spec;
2315 if (!pincfgs)
2316 return;
2318 for (i = 0; i < spec->num_pins; i++)
2319 if (spec->pin_nids[i] && pincfgs[i])
2320 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2321 pincfgs[i]);
2325 * Analog playback callbacks
2327 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2328 struct hda_codec *codec,
2329 struct snd_pcm_substream *substream)
2331 struct sigmatel_spec *spec = codec->spec;
2332 if (spec->stream_delay)
2333 msleep(spec->stream_delay);
2334 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2335 hinfo);
2338 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2339 struct hda_codec *codec,
2340 unsigned int stream_tag,
2341 unsigned int format,
2342 struct snd_pcm_substream *substream)
2344 struct sigmatel_spec *spec = codec->spec;
2345 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2348 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2349 struct hda_codec *codec,
2350 struct snd_pcm_substream *substream)
2352 struct sigmatel_spec *spec = codec->spec;
2353 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2357 * Digital playback callbacks
2359 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2360 struct hda_codec *codec,
2361 struct snd_pcm_substream *substream)
2363 struct sigmatel_spec *spec = codec->spec;
2364 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2367 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2368 struct hda_codec *codec,
2369 struct snd_pcm_substream *substream)
2371 struct sigmatel_spec *spec = codec->spec;
2372 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2375 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2376 struct hda_codec *codec,
2377 unsigned int stream_tag,
2378 unsigned int format,
2379 struct snd_pcm_substream *substream)
2381 struct sigmatel_spec *spec = codec->spec;
2382 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2383 stream_tag, format, substream);
2386 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2387 struct hda_codec *codec,
2388 struct snd_pcm_substream *substream)
2390 struct sigmatel_spec *spec = codec->spec;
2391 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2396 * Analog capture callbacks
2398 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2399 struct hda_codec *codec,
2400 unsigned int stream_tag,
2401 unsigned int format,
2402 struct snd_pcm_substream *substream)
2404 struct sigmatel_spec *spec = codec->spec;
2405 hda_nid_t nid = spec->adc_nids[substream->number];
2407 if (spec->powerdown_adcs) {
2408 msleep(40);
2409 snd_hda_codec_write(codec, nid, 0,
2410 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2412 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2413 return 0;
2416 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2417 struct hda_codec *codec,
2418 struct snd_pcm_substream *substream)
2420 struct sigmatel_spec *spec = codec->spec;
2421 hda_nid_t nid = spec->adc_nids[substream->number];
2423 snd_hda_codec_cleanup_stream(codec, nid);
2424 if (spec->powerdown_adcs)
2425 snd_hda_codec_write(codec, nid, 0,
2426 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2427 return 0;
2430 static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2431 .substreams = 1,
2432 .channels_min = 2,
2433 .channels_max = 2,
2434 /* NID is set in stac92xx_build_pcms */
2435 .ops = {
2436 .open = stac92xx_dig_playback_pcm_open,
2437 .close = stac92xx_dig_playback_pcm_close,
2438 .prepare = stac92xx_dig_playback_pcm_prepare,
2439 .cleanup = stac92xx_dig_playback_pcm_cleanup
2443 static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2444 .substreams = 1,
2445 .channels_min = 2,
2446 .channels_max = 2,
2447 /* NID is set in stac92xx_build_pcms */
2450 static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2451 .substreams = 1,
2452 .channels_min = 2,
2453 .channels_max = 8,
2454 .nid = 0x02, /* NID to query formats and rates */
2455 .ops = {
2456 .open = stac92xx_playback_pcm_open,
2457 .prepare = stac92xx_playback_pcm_prepare,
2458 .cleanup = stac92xx_playback_pcm_cleanup
2462 static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2463 .substreams = 1,
2464 .channels_min = 2,
2465 .channels_max = 2,
2466 .nid = 0x06, /* NID to query formats and rates */
2467 .ops = {
2468 .open = stac92xx_playback_pcm_open,
2469 .prepare = stac92xx_playback_pcm_prepare,
2470 .cleanup = stac92xx_playback_pcm_cleanup
2474 static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2475 .channels_min = 2,
2476 .channels_max = 2,
2477 /* NID + .substreams is set in stac92xx_build_pcms */
2478 .ops = {
2479 .prepare = stac92xx_capture_pcm_prepare,
2480 .cleanup = stac92xx_capture_pcm_cleanup
2484 static int stac92xx_build_pcms(struct hda_codec *codec)
2486 struct sigmatel_spec *spec = codec->spec;
2487 struct hda_pcm *info = spec->pcm_rec;
2489 codec->num_pcms = 1;
2490 codec->pcm_info = info;
2492 info->name = "STAC92xx Analog";
2493 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2494 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2495 spec->multiout.dac_nids[0];
2496 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2497 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2498 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2500 if (spec->alt_switch) {
2501 codec->num_pcms++;
2502 info++;
2503 info->name = "STAC92xx Analog Alt";
2504 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2507 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2508 codec->num_pcms++;
2509 info++;
2510 info->name = "STAC92xx Digital";
2511 info->pcm_type = spec->autocfg.dig_out_type[0];
2512 if (spec->multiout.dig_out_nid) {
2513 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2514 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2516 if (spec->dig_in_nid) {
2517 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2518 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2522 return 0;
2525 static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2526 hda_nid_t nid)
2528 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2529 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2530 if (pincap & AC_PINCAP_VREF_100)
2531 return AC_PINCTL_VREF_100;
2532 if (pincap & AC_PINCAP_VREF_80)
2533 return AC_PINCTL_VREF_80;
2534 if (pincap & AC_PINCAP_VREF_50)
2535 return AC_PINCTL_VREF_50;
2536 if (pincap & AC_PINCAP_VREF_GRD)
2537 return AC_PINCTL_VREF_GRD;
2538 return 0;
2541 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2544 snd_hda_codec_write_cache(codec, nid, 0,
2545 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2548 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2550 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2551 struct snd_ctl_elem_value *ucontrol)
2553 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2554 struct sigmatel_spec *spec = codec->spec;
2556 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2557 return 0;
2560 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
2562 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2563 struct snd_ctl_elem_value *ucontrol)
2565 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2566 struct sigmatel_spec *spec = codec->spec;
2567 int nid = kcontrol->private_value;
2569 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2571 /* check to be sure that the ports are up to date with
2572 * switch changes
2574 stac_issue_unsol_event(codec, nid);
2576 return 1;
2579 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2580 struct snd_ctl_elem_info *uinfo)
2582 int i;
2583 static const char * const texts[] = {
2584 "Mic In", "Line In", "Line Out"
2587 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2588 struct sigmatel_spec *spec = codec->spec;
2589 hda_nid_t nid = kcontrol->private_value;
2591 if (nid == spec->mic_switch || nid == spec->line_switch)
2592 i = 3;
2593 else
2594 i = 2;
2596 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2597 uinfo->value.enumerated.items = i;
2598 uinfo->count = 1;
2599 if (uinfo->value.enumerated.item >= i)
2600 uinfo->value.enumerated.item = i-1;
2601 strcpy(uinfo->value.enumerated.name,
2602 texts[uinfo->value.enumerated.item]);
2604 return 0;
2607 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2608 struct snd_ctl_elem_value *ucontrol)
2610 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2611 hda_nid_t nid = kcontrol->private_value;
2612 unsigned int vref = stac92xx_vref_get(codec, nid);
2614 if (vref == stac92xx_get_default_vref(codec, nid))
2615 ucontrol->value.enumerated.item[0] = 0;
2616 else if (vref == AC_PINCTL_VREF_GRD)
2617 ucontrol->value.enumerated.item[0] = 1;
2618 else if (vref == AC_PINCTL_VREF_HIZ)
2619 ucontrol->value.enumerated.item[0] = 2;
2621 return 0;
2624 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2625 struct snd_ctl_elem_value *ucontrol)
2627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2628 unsigned int new_vref = 0;
2629 int error;
2630 hda_nid_t nid = kcontrol->private_value;
2632 if (ucontrol->value.enumerated.item[0] == 0)
2633 new_vref = stac92xx_get_default_vref(codec, nid);
2634 else if (ucontrol->value.enumerated.item[0] == 1)
2635 new_vref = AC_PINCTL_VREF_GRD;
2636 else if (ucontrol->value.enumerated.item[0] == 2)
2637 new_vref = AC_PINCTL_VREF_HIZ;
2638 else
2639 return 0;
2641 if (new_vref != stac92xx_vref_get(codec, nid)) {
2642 error = stac92xx_vref_set(codec, nid, new_vref);
2643 return error;
2646 return 0;
2649 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2650 struct snd_ctl_elem_info *uinfo)
2652 char *texts[2];
2653 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2654 struct sigmatel_spec *spec = codec->spec;
2656 if (kcontrol->private_value == spec->line_switch)
2657 texts[0] = "Line In";
2658 else
2659 texts[0] = "Mic In";
2660 texts[1] = "Line Out";
2661 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2662 uinfo->value.enumerated.items = 2;
2663 uinfo->count = 1;
2665 if (uinfo->value.enumerated.item >= 2)
2666 uinfo->value.enumerated.item = 1;
2667 strcpy(uinfo->value.enumerated.name,
2668 texts[uinfo->value.enumerated.item]);
2670 return 0;
2673 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2676 struct sigmatel_spec *spec = codec->spec;
2677 hda_nid_t nid = kcontrol->private_value;
2678 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2680 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
2681 return 0;
2684 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2686 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2687 struct sigmatel_spec *spec = codec->spec;
2688 hda_nid_t nid = kcontrol->private_value;
2689 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2690 unsigned short val = !!ucontrol->value.enumerated.item[0];
2692 spec->io_switch[io_idx] = val;
2694 if (val)
2695 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2696 else {
2697 unsigned int pinctl = AC_PINCTL_IN_EN;
2698 if (io_idx) /* set VREF for mic */
2699 pinctl |= stac92xx_get_default_vref(codec, nid);
2700 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2703 /* check the auto-mute again: we need to mute/unmute the speaker
2704 * appropriately according to the pin direction
2706 if (spec->hp_detect)
2707 stac_issue_unsol_event(codec, nid);
2709 return 1;
2712 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2714 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2715 struct snd_ctl_elem_value *ucontrol)
2717 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2718 struct sigmatel_spec *spec = codec->spec;
2720 ucontrol->value.integer.value[0] = spec->clfe_swap;
2721 return 0;
2724 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2725 struct snd_ctl_elem_value *ucontrol)
2727 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2728 struct sigmatel_spec *spec = codec->spec;
2729 hda_nid_t nid = kcontrol->private_value & 0xff;
2730 unsigned int val = !!ucontrol->value.integer.value[0];
2732 if (spec->clfe_swap == val)
2733 return 0;
2735 spec->clfe_swap = val;
2737 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2738 spec->clfe_swap ? 0x4 : 0x0);
2740 return 1;
2743 #define STAC_CODEC_HP_SWITCH(xname) \
2744 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2745 .name = xname, \
2746 .index = 0, \
2747 .info = stac92xx_hp_switch_info, \
2748 .get = stac92xx_hp_switch_get, \
2749 .put = stac92xx_hp_switch_put, \
2752 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2753 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2754 .name = xname, \
2755 .index = 0, \
2756 .info = stac92xx_io_switch_info, \
2757 .get = stac92xx_io_switch_get, \
2758 .put = stac92xx_io_switch_put, \
2759 .private_value = xpval, \
2762 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2763 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2764 .name = xname, \
2765 .index = 0, \
2766 .info = stac92xx_clfe_switch_info, \
2767 .get = stac92xx_clfe_switch_get, \
2768 .put = stac92xx_clfe_switch_put, \
2769 .private_value = xpval, \
2772 enum {
2773 STAC_CTL_WIDGET_VOL,
2774 STAC_CTL_WIDGET_MUTE,
2775 STAC_CTL_WIDGET_MUTE_BEEP,
2776 STAC_CTL_WIDGET_MONO_MUX,
2777 STAC_CTL_WIDGET_HP_SWITCH,
2778 STAC_CTL_WIDGET_IO_SWITCH,
2779 STAC_CTL_WIDGET_CLFE_SWITCH,
2780 STAC_CTL_WIDGET_DC_BIAS
2783 static const struct snd_kcontrol_new stac92xx_control_templates[] = {
2784 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2785 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2786 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
2787 STAC_MONO_MUX,
2788 STAC_CODEC_HP_SWITCH(NULL),
2789 STAC_CODEC_IO_SWITCH(NULL, 0),
2790 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2791 DC_BIAS(NULL, 0, 0),
2794 /* add dynamic controls */
2795 static struct snd_kcontrol_new *
2796 stac_control_new(struct sigmatel_spec *spec,
2797 const struct snd_kcontrol_new *ktemp,
2798 const char *name,
2799 unsigned int subdev)
2801 struct snd_kcontrol_new *knew;
2803 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2804 knew = snd_array_new(&spec->kctls);
2805 if (!knew)
2806 return NULL;
2807 *knew = *ktemp;
2808 knew->name = kstrdup(name, GFP_KERNEL);
2809 if (!knew->name) {
2810 /* roolback */
2811 memset(knew, 0, sizeof(*knew));
2812 spec->kctls.alloced--;
2813 return NULL;
2815 knew->subdevice = subdev;
2816 return knew;
2819 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2820 const struct snd_kcontrol_new *ktemp,
2821 int idx, const char *name,
2822 unsigned long val)
2824 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
2825 HDA_SUBDEV_AMP_FLAG);
2826 if (!knew)
2827 return -ENOMEM;
2828 knew->index = idx;
2829 knew->private_value = val;
2830 return 0;
2833 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2834 int type, int idx, const char *name,
2835 unsigned long val)
2837 return stac92xx_add_control_temp(spec,
2838 &stac92xx_control_templates[type],
2839 idx, name, val);
2843 /* add dynamic controls */
2844 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2845 const char *name, unsigned long val)
2847 return stac92xx_add_control_idx(spec, type, 0, name, val);
2850 static const struct snd_kcontrol_new stac_input_src_temp = {
2851 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2852 .name = "Input Source",
2853 .info = stac92xx_mux_enum_info,
2854 .get = stac92xx_mux_enum_get,
2855 .put = stac92xx_mux_enum_put,
2858 static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2859 hda_nid_t nid, int idx)
2861 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2862 int control = 0;
2863 struct sigmatel_spec *spec = codec->spec;
2864 char name[22];
2866 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
2867 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2868 && nid == spec->line_switch)
2869 control = STAC_CTL_WIDGET_IO_SWITCH;
2870 else if (snd_hda_query_pin_caps(codec, nid)
2871 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2872 control = STAC_CTL_WIDGET_DC_BIAS;
2873 else if (nid == spec->mic_switch)
2874 control = STAC_CTL_WIDGET_IO_SWITCH;
2877 if (control) {
2878 strcpy(name, hda_get_input_pin_label(codec, nid, 1));
2879 return stac92xx_add_control(codec->spec, control,
2880 strcat(name, " Jack Mode"), nid);
2883 return 0;
2886 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2888 struct snd_kcontrol_new *knew;
2889 struct hda_input_mux *imux = &spec->private_imux;
2891 if (spec->auto_mic)
2892 return 0; /* no need for input source */
2893 if (!spec->num_adcs || imux->num_items <= 1)
2894 return 0; /* no need for input source control */
2895 knew = stac_control_new(spec, &stac_input_src_temp,
2896 stac_input_src_temp.name, 0);
2897 if (!knew)
2898 return -ENOMEM;
2899 knew->count = spec->num_adcs;
2900 return 0;
2903 /* check whether the line-input can be used as line-out */
2904 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2906 struct sigmatel_spec *spec = codec->spec;
2907 struct auto_pin_cfg *cfg = &spec->autocfg;
2908 hda_nid_t nid;
2909 unsigned int pincap;
2910 int i;
2912 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2913 return 0;
2914 for (i = 0; i < cfg->num_inputs; i++) {
2915 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
2916 nid = cfg->inputs[i].pin;
2917 pincap = snd_hda_query_pin_caps(codec, nid);
2918 if (pincap & AC_PINCAP_OUT)
2919 return nid;
2922 return 0;
2925 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
2927 /* check whether the mic-input can be used as line-out */
2928 static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
2930 struct sigmatel_spec *spec = codec->spec;
2931 struct auto_pin_cfg *cfg = &spec->autocfg;
2932 unsigned int def_conf, pincap;
2933 int i;
2935 *dac = 0;
2936 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2937 return 0;
2938 for (i = 0; i < cfg->num_inputs; i++) {
2939 hda_nid_t nid = cfg->inputs[i].pin;
2940 if (cfg->inputs[i].type != AUTO_PIN_MIC)
2941 continue;
2942 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2943 /* some laptops have an internal analog microphone
2944 * which can't be used as a output */
2945 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
2946 pincap = snd_hda_query_pin_caps(codec, nid);
2947 if (pincap & AC_PINCAP_OUT) {
2948 *dac = get_unassigned_dac(codec, nid);
2949 if (*dac)
2950 return nid;
2954 return 0;
2957 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2959 int i;
2961 for (i = 0; i < spec->multiout.num_dacs; i++) {
2962 if (spec->multiout.dac_nids[i] == nid)
2963 return 1;
2966 return 0;
2969 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2971 int i;
2972 if (is_in_dac_nids(spec, nid))
2973 return 1;
2974 for (i = 0; i < spec->autocfg.hp_outs; i++)
2975 if (spec->hp_dacs[i] == nid)
2976 return 1;
2977 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2978 if (spec->speaker_dacs[i] == nid)
2979 return 1;
2980 return 0;
2983 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2985 struct sigmatel_spec *spec = codec->spec;
2986 struct auto_pin_cfg *cfg = &spec->autocfg;
2987 int j, conn_len;
2988 hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
2989 unsigned int wcaps, wtype;
2991 conn_len = snd_hda_get_connections(codec, nid, conn,
2992 HDA_MAX_CONNECTIONS);
2993 /* 92HD88: trace back up the link of nids to find the DAC */
2994 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
2995 != AC_WID_AUD_OUT)) {
2996 nid = conn[0];
2997 conn_len = snd_hda_get_connections(codec, nid, conn,
2998 HDA_MAX_CONNECTIONS);
3000 for (j = 0; j < conn_len; j++) {
3001 wcaps = get_wcaps(codec, conn[j]);
3002 wtype = get_wcaps_type(wcaps);
3003 /* we check only analog outputs */
3004 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
3005 continue;
3006 /* if this route has a free DAC, assign it */
3007 if (!check_all_dac_nids(spec, conn[j])) {
3008 if (conn_len > 1) {
3009 /* select this DAC in the pin's input mux */
3010 snd_hda_codec_write_cache(codec, nid, 0,
3011 AC_VERB_SET_CONNECT_SEL, j);
3013 return conn[j];
3017 /* if all DACs are already assigned, connect to the primary DAC,
3018 unless we're assigning a secondary headphone */
3019 fallback_dac = spec->multiout.dac_nids[0];
3020 if (spec->multiout.hp_nid) {
3021 for (j = 0; j < cfg->hp_outs; j++)
3022 if (cfg->hp_pins[j] == nid) {
3023 fallback_dac = spec->multiout.hp_nid;
3024 break;
3028 if (conn_len > 1) {
3029 for (j = 0; j < conn_len; j++) {
3030 if (conn[j] == fallback_dac) {
3031 snd_hda_codec_write_cache(codec, nid, 0,
3032 AC_VERB_SET_CONNECT_SEL, j);
3033 break;
3037 return 0;
3040 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3041 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3044 * Fill in the dac_nids table from the parsed pin configuration
3045 * This function only works when every pin in line_out_pins[]
3046 * contains atleast one DAC in its connection list. Some 92xx
3047 * codecs are not connected directly to a DAC, such as the 9200
3048 * and 9202/925x. For those, dac_nids[] must be hard-coded.
3050 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
3052 struct sigmatel_spec *spec = codec->spec;
3053 struct auto_pin_cfg *cfg = &spec->autocfg;
3054 int i;
3055 hda_nid_t nid, dac;
3057 for (i = 0; i < cfg->line_outs; i++) {
3058 nid = cfg->line_out_pins[i];
3059 dac = get_unassigned_dac(codec, nid);
3060 if (!dac) {
3061 if (spec->multiout.num_dacs > 0) {
3062 /* we have already working output pins,
3063 * so let's drop the broken ones again
3065 cfg->line_outs = spec->multiout.num_dacs;
3066 break;
3068 /* error out, no available DAC found */
3069 snd_printk(KERN_ERR
3070 "%s: No available DAC for pin 0x%x\n",
3071 __func__, nid);
3072 return -ENODEV;
3074 add_spec_dacs(spec, dac);
3077 for (i = 0; i < cfg->hp_outs; i++) {
3078 nid = cfg->hp_pins[i];
3079 dac = get_unassigned_dac(codec, nid);
3080 if (dac) {
3081 if (!spec->multiout.hp_nid)
3082 spec->multiout.hp_nid = dac;
3083 else
3084 add_spec_extra_dacs(spec, dac);
3086 spec->hp_dacs[i] = dac;
3089 for (i = 0; i < cfg->speaker_outs; i++) {
3090 nid = cfg->speaker_pins[i];
3091 dac = get_unassigned_dac(codec, nid);
3092 if (dac)
3093 add_spec_extra_dacs(spec, dac);
3094 spec->speaker_dacs[i] = dac;
3097 /* add line-in as output */
3098 nid = check_line_out_switch(codec);
3099 if (nid) {
3100 dac = get_unassigned_dac(codec, nid);
3101 if (dac) {
3102 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3103 nid, cfg->line_outs);
3104 cfg->line_out_pins[cfg->line_outs] = nid;
3105 cfg->line_outs++;
3106 spec->line_switch = nid;
3107 add_spec_dacs(spec, dac);
3110 /* add mic as output */
3111 nid = check_mic_out_switch(codec, &dac);
3112 if (nid && dac) {
3113 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3114 nid, cfg->line_outs);
3115 cfg->line_out_pins[cfg->line_outs] = nid;
3116 cfg->line_outs++;
3117 spec->mic_switch = nid;
3118 add_spec_dacs(spec, dac);
3121 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
3122 spec->multiout.num_dacs,
3123 spec->multiout.dac_nids[0],
3124 spec->multiout.dac_nids[1],
3125 spec->multiout.dac_nids[2],
3126 spec->multiout.dac_nids[3],
3127 spec->multiout.dac_nids[4]);
3129 return 0;
3132 /* create volume control/switch for the given prefx type */
3133 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3134 int idx, hda_nid_t nid, int chs)
3136 struct sigmatel_spec *spec = codec->spec;
3137 char name[32];
3138 int err;
3140 if (!spec->check_volume_offset) {
3141 unsigned int caps, step, nums, db_scale;
3142 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3143 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3144 AC_AMPCAP_STEP_SIZE_SHIFT;
3145 step = (step + 1) * 25; /* in .01dB unit */
3146 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3147 AC_AMPCAP_NUM_STEPS_SHIFT;
3148 db_scale = nums * step;
3149 /* if dB scale is over -64dB, and finer enough,
3150 * let's reduce it to half
3152 if (db_scale > 6400 && nums >= 0x1f)
3153 spec->volume_offset = nums / 2;
3154 spec->check_volume_offset = 1;
3157 sprintf(name, "%s Playback Volume", pfx);
3158 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
3159 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3160 spec->volume_offset));
3161 if (err < 0)
3162 return err;
3163 sprintf(name, "%s Playback Switch", pfx);
3164 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
3165 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3166 if (err < 0)
3167 return err;
3168 return 0;
3171 #define create_controls(codec, pfx, nid, chs) \
3172 create_controls_idx(codec, pfx, 0, nid, chs)
3174 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3176 if (spec->multiout.num_dacs > 4) {
3177 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3178 return 1;
3179 } else {
3180 snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
3181 spec->dac_nids[spec->multiout.num_dacs] = nid;
3182 spec->multiout.num_dacs++;
3184 return 0;
3187 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3189 int i;
3190 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3191 if (!spec->multiout.extra_out_nid[i]) {
3192 spec->multiout.extra_out_nid[i] = nid;
3193 return 0;
3196 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3197 return 1;
3200 /* Create output controls
3201 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3203 static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3204 const hda_nid_t *pins,
3205 const hda_nid_t *dac_nids,
3206 int type)
3208 struct sigmatel_spec *spec = codec->spec;
3209 static const char * const chname[4] = {
3210 "Front", "Surround", NULL /*CLFE*/, "Side"
3212 hda_nid_t nid;
3213 int i, err;
3214 unsigned int wid_caps;
3216 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3217 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3218 if (is_jack_detectable(codec, pins[i]))
3219 spec->hp_detect = 1;
3221 nid = dac_nids[i];
3222 if (!nid)
3223 continue;
3224 if (type != AUTO_PIN_HP_OUT && i == 2) {
3225 /* Center/LFE */
3226 err = create_controls(codec, "Center", nid, 1);
3227 if (err < 0)
3228 return err;
3229 err = create_controls(codec, "LFE", nid, 2);
3230 if (err < 0)
3231 return err;
3233 wid_caps = get_wcaps(codec, nid);
3235 if (wid_caps & AC_WCAP_LR_SWAP) {
3236 err = stac92xx_add_control(spec,
3237 STAC_CTL_WIDGET_CLFE_SWITCH,
3238 "Swap Center/LFE Playback Switch", nid);
3240 if (err < 0)
3241 return err;
3244 } else {
3245 const char *name;
3246 int idx;
3247 switch (type) {
3248 case AUTO_PIN_HP_OUT:
3249 name = "Headphone";
3250 idx = i;
3251 break;
3252 case AUTO_PIN_SPEAKER_OUT:
3253 name = "Speaker";
3254 idx = i;
3255 break;
3256 default:
3257 name = chname[i];
3258 idx = 0;
3259 break;
3261 err = create_controls_idx(codec, name, idx, nid, 3);
3262 if (err < 0)
3263 return err;
3266 return 0;
3269 static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3270 unsigned long sw, int idx)
3272 int err;
3273 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
3274 "Capture Volume", vol);
3275 if (err < 0)
3276 return err;
3277 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
3278 "Capture Switch", sw);
3279 if (err < 0)
3280 return err;
3281 return 0;
3284 /* add playback controls from the parsed DAC table */
3285 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3286 const struct auto_pin_cfg *cfg)
3288 struct sigmatel_spec *spec = codec->spec;
3289 hda_nid_t nid;
3290 int err;
3291 int idx;
3293 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3294 spec->multiout.dac_nids,
3295 cfg->line_out_type);
3296 if (err < 0)
3297 return err;
3299 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3300 err = stac92xx_add_control(spec,
3301 STAC_CTL_WIDGET_HP_SWITCH,
3302 "Headphone as Line Out Switch",
3303 cfg->hp_pins[cfg->hp_outs - 1]);
3304 if (err < 0)
3305 return err;
3308 for (idx = 0; idx < cfg->num_inputs; idx++) {
3309 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
3310 break;
3311 nid = cfg->inputs[idx].pin;
3312 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3313 if (err < 0)
3314 return err;
3317 return 0;
3320 /* add playback controls for Speaker and HP outputs */
3321 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3322 struct auto_pin_cfg *cfg)
3324 struct sigmatel_spec *spec = codec->spec;
3325 int err;
3327 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3328 spec->hp_dacs, AUTO_PIN_HP_OUT);
3329 if (err < 0)
3330 return err;
3332 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3333 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3334 if (err < 0)
3335 return err;
3337 return 0;
3340 /* labels for mono mux outputs */
3341 static const char * const stac92xx_mono_labels[4] = {
3342 "DAC0", "DAC1", "Mixer", "DAC2"
3345 /* create mono mux for mono out on capable codecs */
3346 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3348 struct sigmatel_spec *spec = codec->spec;
3349 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3350 int i, num_cons;
3351 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3353 num_cons = snd_hda_get_connections(codec,
3354 spec->mono_nid,
3355 con_lst,
3356 HDA_MAX_NUM_INPUTS);
3357 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3358 return -EINVAL;
3360 for (i = 0; i < num_cons; i++)
3361 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
3362 NULL);
3364 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3365 "Mono Mux", spec->mono_nid);
3368 /* create PC beep volume controls */
3369 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3370 hda_nid_t nid)
3372 struct sigmatel_spec *spec = codec->spec;
3373 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3374 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
3376 if (spec->anabeep_nid == nid)
3377 type = STAC_CTL_WIDGET_MUTE;
3379 /* check for mute support for the the amp */
3380 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3381 err = stac92xx_add_control(spec, type,
3382 "Beep Playback Switch",
3383 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3384 if (err < 0)
3385 return err;
3388 /* check to see if there is volume support for the amp */
3389 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3390 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3391 "Beep Playback Volume",
3392 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3393 if (err < 0)
3394 return err;
3396 return 0;
3399 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3400 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3402 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3403 struct snd_ctl_elem_value *ucontrol)
3405 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3406 ucontrol->value.integer.value[0] = codec->beep->enabled;
3407 return 0;
3410 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3411 struct snd_ctl_elem_value *ucontrol)
3413 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3414 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
3417 static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3418 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3419 .info = stac92xx_dig_beep_switch_info,
3420 .get = stac92xx_dig_beep_switch_get,
3421 .put = stac92xx_dig_beep_switch_put,
3424 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3426 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3427 0, "Beep Playback Switch", 0);
3429 #endif
3431 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3433 struct sigmatel_spec *spec = codec->spec;
3434 int i, j, err = 0;
3436 for (i = 0; i < spec->num_muxes; i++) {
3437 hda_nid_t nid;
3438 unsigned int wcaps;
3439 unsigned long val;
3441 nid = spec->mux_nids[i];
3442 wcaps = get_wcaps(codec, nid);
3443 if (!(wcaps & AC_WCAP_OUT_AMP))
3444 continue;
3446 /* check whether already the same control was created as
3447 * normal Capture Volume.
3449 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3450 for (j = 0; j < spec->num_caps; j++) {
3451 if (spec->capvols[j] == val)
3452 break;
3454 if (j < spec->num_caps)
3455 continue;
3457 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3458 "Mux Capture Volume", val);
3459 if (err < 0)
3460 return err;
3462 return 0;
3465 static const char * const stac92xx_spdif_labels[3] = {
3466 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3469 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3471 struct sigmatel_spec *spec = codec->spec;
3472 struct hda_input_mux *spdif_mux = &spec->private_smux;
3473 const char * const *labels = spec->spdif_labels;
3474 int i, num_cons;
3475 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3477 num_cons = snd_hda_get_connections(codec,
3478 spec->smux_nids[0],
3479 con_lst,
3480 HDA_MAX_NUM_INPUTS);
3481 if (num_cons <= 0)
3482 return -EINVAL;
3484 if (!labels)
3485 labels = stac92xx_spdif_labels;
3487 for (i = 0; i < num_cons; i++)
3488 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
3490 return 0;
3493 /* labels for dmic mux inputs */
3494 static const char * const stac92xx_dmic_labels[5] = {
3495 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3496 "Digital Mic 3", "Digital Mic 4"
3499 static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
3500 int idx)
3502 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3503 int nums;
3504 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3505 if (idx >= 0 && idx < nums)
3506 return conn[idx];
3507 return 0;
3510 /* look for NID recursively */
3511 #define get_connection_index(codec, mux, nid) \
3512 snd_hda_get_conn_index(codec, mux, nid, 1)
3514 /* create a volume assigned to the given pin (only if supported) */
3515 /* return 1 if the volume control is created */
3516 static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
3517 const char *label, int idx, int direction)
3519 unsigned int caps, nums;
3520 char name[32];
3521 int err;
3523 if (direction == HDA_OUTPUT)
3524 caps = AC_WCAP_OUT_AMP;
3525 else
3526 caps = AC_WCAP_IN_AMP;
3527 if (!(get_wcaps(codec, nid) & caps))
3528 return 0;
3529 caps = query_amp_caps(codec, nid, direction);
3530 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3531 if (!nums)
3532 return 0;
3533 snprintf(name, sizeof(name), "%s Capture Volume", label);
3534 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
3535 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
3536 if (err < 0)
3537 return err;
3538 return 1;
3541 /* create playback/capture controls for input pins on dmic capable codecs */
3542 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3543 const struct auto_pin_cfg *cfg)
3545 struct sigmatel_spec *spec = codec->spec;
3546 struct hda_input_mux *imux = &spec->private_imux;
3547 struct hda_input_mux *dimux = &spec->private_dimux;
3548 int err, i;
3549 unsigned int def_conf;
3551 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
3553 for (i = 0; i < spec->num_dmics; i++) {
3554 hda_nid_t nid;
3555 int index, type_idx;
3556 const char *label;
3558 nid = spec->dmic_nids[i];
3559 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3560 continue;
3561 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3562 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3563 continue;
3565 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3566 if (index < 0)
3567 continue;
3569 label = hda_get_input_pin_label(codec, nid, 1);
3570 snd_hda_add_imux_item(dimux, label, index, &type_idx);
3571 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
3572 snd_hda_add_imux_item(imux, label, index, &type_idx);
3574 err = create_elem_capture_vol(codec, nid, label, type_idx,
3575 HDA_INPUT);
3576 if (err < 0)
3577 return err;
3578 if (!err) {
3579 err = create_elem_capture_vol(codec, nid, label,
3580 type_idx, HDA_OUTPUT);
3581 if (err < 0)
3582 return err;
3583 if (!err) {
3584 nid = get_connected_node(codec,
3585 spec->dmux_nids[0], index);
3586 if (nid)
3587 err = create_elem_capture_vol(codec,
3588 nid, label,
3589 type_idx, HDA_INPUT);
3590 if (err < 0)
3591 return err;
3596 return 0;
3599 static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
3600 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
3602 unsigned int cfg;
3603 unsigned int type;
3605 if (!nid)
3606 return 0;
3607 cfg = snd_hda_codec_get_pincfg(codec, nid);
3608 type = get_defcfg_device(cfg);
3609 switch (snd_hda_get_input_pin_attr(cfg)) {
3610 case INPUT_PIN_ATTR_INT:
3611 if (*fixed)
3612 return 1; /* already occupied */
3613 if (type != AC_JACK_MIC_IN)
3614 return 1; /* invalid type */
3615 *fixed = nid;
3616 break;
3617 case INPUT_PIN_ATTR_UNUSED:
3618 break;
3619 case INPUT_PIN_ATTR_DOCK:
3620 if (*dock)
3621 return 1; /* already occupied */
3622 if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
3623 return 1; /* invalid type */
3624 *dock = nid;
3625 break;
3626 default:
3627 if (*ext)
3628 return 1; /* already occupied */
3629 if (type != AC_JACK_MIC_IN)
3630 return 1; /* invalid type */
3631 *ext = nid;
3632 break;
3634 return 0;
3637 static int set_mic_route(struct hda_codec *codec,
3638 struct sigmatel_mic_route *mic,
3639 hda_nid_t pin)
3641 struct sigmatel_spec *spec = codec->spec;
3642 struct auto_pin_cfg *cfg = &spec->autocfg;
3643 int i;
3645 mic->pin = pin;
3646 if (pin == 0)
3647 return 0;
3648 for (i = 0; i < cfg->num_inputs; i++) {
3649 if (pin == cfg->inputs[i].pin)
3650 break;
3652 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
3653 /* analog pin */
3654 i = get_connection_index(codec, spec->mux_nids[0], pin);
3655 if (i < 0)
3656 return -1;
3657 mic->mux_idx = i;
3658 mic->dmux_idx = -1;
3659 if (spec->dmux_nids)
3660 mic->dmux_idx = get_connection_index(codec,
3661 spec->dmux_nids[0],
3662 spec->mux_nids[0]);
3663 } else if (spec->dmux_nids) {
3664 /* digital pin */
3665 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3666 if (i < 0)
3667 return -1;
3668 mic->dmux_idx = i;
3669 mic->mux_idx = -1;
3670 if (spec->mux_nids)
3671 mic->mux_idx = get_connection_index(codec,
3672 spec->mux_nids[0],
3673 spec->dmux_nids[0]);
3675 return 0;
3678 /* return non-zero if the device is for automatic mic switch */
3679 static int stac_check_auto_mic(struct hda_codec *codec)
3681 struct sigmatel_spec *spec = codec->spec;
3682 struct auto_pin_cfg *cfg = &spec->autocfg;
3683 hda_nid_t fixed, ext, dock;
3684 int i;
3686 fixed = ext = dock = 0;
3687 for (i = 0; i < cfg->num_inputs; i++)
3688 if (check_mic_pin(codec, cfg->inputs[i].pin,
3689 &fixed, &ext, &dock))
3690 return 0;
3691 for (i = 0; i < spec->num_dmics; i++)
3692 if (check_mic_pin(codec, spec->dmic_nids[i],
3693 &fixed, &ext, &dock))
3694 return 0;
3695 if (!fixed || (!ext && !dock))
3696 return 0; /* no input to switch */
3697 if (!is_jack_detectable(codec, ext))
3698 return 0; /* no unsol support */
3699 if (set_mic_route(codec, &spec->ext_mic, ext) ||
3700 set_mic_route(codec, &spec->int_mic, fixed) ||
3701 set_mic_route(codec, &spec->dock_mic, dock))
3702 return 0; /* something is wrong */
3703 return 1;
3706 /* create playback/capture controls for input pins */
3707 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3709 struct sigmatel_spec *spec = codec->spec;
3710 struct hda_input_mux *imux = &spec->private_imux;
3711 int i, j;
3712 const char *label;
3714 for (i = 0; i < cfg->num_inputs; i++) {
3715 hda_nid_t nid = cfg->inputs[i].pin;
3716 int index, err, type_idx;
3718 index = -1;
3719 for (j = 0; j < spec->num_muxes; j++) {
3720 index = get_connection_index(codec, spec->mux_nids[j],
3721 nid);
3722 if (index >= 0)
3723 break;
3725 if (index < 0)
3726 continue;
3728 label = hda_get_autocfg_input_label(codec, cfg, i);
3729 snd_hda_add_imux_item(imux, label, index, &type_idx);
3731 err = create_elem_capture_vol(codec, nid,
3732 label, type_idx,
3733 HDA_INPUT);
3734 if (err < 0)
3735 return err;
3737 spec->num_analog_muxes = imux->num_items;
3739 if (imux->num_items) {
3741 * Set the current input for the muxes.
3742 * The STAC9221 has two input muxes with identical source
3743 * NID lists. Hopefully this won't get confused.
3745 for (i = 0; i < spec->num_muxes; i++) {
3746 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3747 AC_VERB_SET_CONNECT_SEL,
3748 imux->items[0].index);
3752 return 0;
3755 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3757 struct sigmatel_spec *spec = codec->spec;
3758 int i;
3760 for (i = 0; i < spec->autocfg.line_outs; i++) {
3761 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3762 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3766 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3768 struct sigmatel_spec *spec = codec->spec;
3769 int i;
3771 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3772 hda_nid_t pin;
3773 pin = spec->autocfg.hp_pins[i];
3774 if (pin) /* connect to front */
3775 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3777 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3778 hda_nid_t pin;
3779 pin = spec->autocfg.speaker_pins[i];
3780 if (pin) /* connect to front */
3781 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3785 static int is_dual_headphones(struct hda_codec *codec)
3787 struct sigmatel_spec *spec = codec->spec;
3788 int i, valid_hps;
3790 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
3791 spec->autocfg.hp_outs <= 1)
3792 return 0;
3793 valid_hps = 0;
3794 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3795 hda_nid_t nid = spec->autocfg.hp_pins[i];
3796 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
3797 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
3798 continue;
3799 valid_hps++;
3801 return (valid_hps > 1);
3805 static int stac92xx_parse_auto_config(struct hda_codec *codec)
3807 struct sigmatel_spec *spec = codec->spec;
3808 hda_nid_t dig_out = 0, dig_in = 0;
3809 int hp_swap = 0;
3810 int i, err;
3812 if ((err = snd_hda_parse_pin_def_config(codec,
3813 &spec->autocfg,
3814 spec->dmic_nids)) < 0)
3815 return err;
3816 if (! spec->autocfg.line_outs)
3817 return 0; /* can't find valid pin config */
3819 /* If we have no real line-out pin and multiple hp-outs, HPs should
3820 * be set up as multi-channel outputs.
3822 if (is_dual_headphones(codec)) {
3823 /* Copy hp_outs to line_outs, backup line_outs in
3824 * speaker_outs so that the following routines can handle
3825 * HP pins as primary outputs.
3827 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3828 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3829 sizeof(spec->autocfg.line_out_pins));
3830 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3831 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3832 sizeof(spec->autocfg.hp_pins));
3833 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3834 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3835 spec->autocfg.hp_outs = 0;
3836 hp_swap = 1;
3838 if (spec->autocfg.mono_out_pin) {
3839 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3840 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3841 u32 caps = query_amp_caps(codec,
3842 spec->autocfg.mono_out_pin, dir);
3843 hda_nid_t conn_list[1];
3845 /* get the mixer node and then the mono mux if it exists */
3846 if (snd_hda_get_connections(codec,
3847 spec->autocfg.mono_out_pin, conn_list, 1) &&
3848 snd_hda_get_connections(codec, conn_list[0],
3849 conn_list, 1) > 0) {
3851 int wcaps = get_wcaps(codec, conn_list[0]);
3852 int wid_type = get_wcaps_type(wcaps);
3853 /* LR swap check, some stac925x have a mux that
3854 * changes the DACs output path instead of the
3855 * mono-mux path.
3857 if (wid_type == AC_WID_AUD_SEL &&
3858 !(wcaps & AC_WCAP_LR_SWAP))
3859 spec->mono_nid = conn_list[0];
3861 if (dir) {
3862 hda_nid_t nid = spec->autocfg.mono_out_pin;
3864 /* most mono outs have a least a mute/unmute switch */
3865 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3866 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3867 "Mono Playback Switch",
3868 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3869 if (err < 0)
3870 return err;
3871 /* check for volume support for the amp */
3872 if ((caps & AC_AMPCAP_NUM_STEPS)
3873 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3874 err = stac92xx_add_control(spec,
3875 STAC_CTL_WIDGET_VOL,
3876 "Mono Playback Volume",
3877 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3878 if (err < 0)
3879 return err;
3883 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3884 AC_PINCTL_OUT_EN);
3887 if (!spec->multiout.num_dacs) {
3888 err = stac92xx_auto_fill_dac_nids(codec);
3889 if (err < 0)
3890 return err;
3891 err = stac92xx_auto_create_multi_out_ctls(codec,
3892 &spec->autocfg);
3893 if (err < 0)
3894 return err;
3897 /* setup analog beep controls */
3898 if (spec->anabeep_nid > 0) {
3899 err = stac92xx_auto_create_beep_ctls(codec,
3900 spec->anabeep_nid);
3901 if (err < 0)
3902 return err;
3905 /* setup digital beep controls and input device */
3906 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3907 if (spec->digbeep_nid > 0) {
3908 hda_nid_t nid = spec->digbeep_nid;
3909 unsigned int caps;
3911 err = stac92xx_auto_create_beep_ctls(codec, nid);
3912 if (err < 0)
3913 return err;
3914 err = snd_hda_attach_beep_device(codec, nid);
3915 if (err < 0)
3916 return err;
3917 if (codec->beep) {
3918 /* IDT/STAC codecs have linear beep tone parameter */
3919 codec->beep->linear_tone = spec->linear_tone_beep;
3920 /* if no beep switch is available, make its own one */
3921 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3922 if (!(caps & AC_AMPCAP_MUTE)) {
3923 err = stac92xx_beep_switch_ctl(codec);
3924 if (err < 0)
3925 return err;
3929 #endif
3931 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3932 if (err < 0)
3933 return err;
3935 /* All output parsing done, now restore the swapped hp pins */
3936 if (hp_swap) {
3937 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3938 sizeof(spec->autocfg.hp_pins));
3939 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3940 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3941 spec->autocfg.line_outs = 0;
3944 if (stac_check_auto_mic(codec)) {
3945 spec->auto_mic = 1;
3946 /* only one capture for auto-mic */
3947 spec->num_adcs = 1;
3948 spec->num_caps = 1;
3949 spec->num_muxes = 1;
3952 for (i = 0; i < spec->num_caps; i++) {
3953 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3954 spec->capsws[i], i);
3955 if (err < 0)
3956 return err;
3959 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3960 if (err < 0)
3961 return err;
3963 if (spec->mono_nid > 0) {
3964 err = stac92xx_auto_create_mono_output_ctls(codec);
3965 if (err < 0)
3966 return err;
3968 if (spec->num_dmics > 0 && !spec->dinput_mux)
3969 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3970 &spec->autocfg)) < 0)
3971 return err;
3972 if (spec->num_muxes > 0) {
3973 err = stac92xx_auto_create_mux_input_ctls(codec);
3974 if (err < 0)
3975 return err;
3977 if (spec->num_smuxes > 0) {
3978 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3979 if (err < 0)
3980 return err;
3983 err = stac92xx_add_input_source(spec);
3984 if (err < 0)
3985 return err;
3987 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3988 if (spec->multiout.max_channels > 2)
3989 spec->surr_switch = 1;
3991 /* find digital out and in converters */
3992 for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
3993 unsigned int wid_caps = get_wcaps(codec, i);
3994 if (wid_caps & AC_WCAP_DIGITAL) {
3995 switch (get_wcaps_type(wid_caps)) {
3996 case AC_WID_AUD_OUT:
3997 if (!dig_out)
3998 dig_out = i;
3999 break;
4000 case AC_WID_AUD_IN:
4001 if (!dig_in)
4002 dig_in = i;
4003 break;
4007 if (spec->autocfg.dig_outs)
4008 spec->multiout.dig_out_nid = dig_out;
4009 if (dig_in && spec->autocfg.dig_in_pin)
4010 spec->dig_in_nid = dig_in;
4012 if (spec->kctls.list)
4013 spec->mixers[spec->num_mixers++] = spec->kctls.list;
4015 spec->input_mux = &spec->private_imux;
4016 if (!spec->dinput_mux)
4017 spec->dinput_mux = &spec->private_dimux;
4018 spec->sinput_mux = &spec->private_smux;
4019 spec->mono_mux = &spec->private_mono_mux;
4020 return 1;
4023 /* add playback controls for HP output */
4024 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
4025 struct auto_pin_cfg *cfg)
4027 struct sigmatel_spec *spec = codec->spec;
4028 hda_nid_t pin = cfg->hp_pins[0];
4030 if (! pin)
4031 return 0;
4033 if (is_jack_detectable(codec, pin))
4034 spec->hp_detect = 1;
4036 return 0;
4039 /* add playback controls for LFE output */
4040 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
4041 struct auto_pin_cfg *cfg)
4043 struct sigmatel_spec *spec = codec->spec;
4044 int err;
4045 hda_nid_t lfe_pin = 0x0;
4046 int i;
4049 * search speaker outs and line outs for a mono speaker pin
4050 * with an amp. If one is found, add LFE controls
4051 * for it.
4053 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
4054 hda_nid_t pin = spec->autocfg.speaker_pins[i];
4055 unsigned int wcaps = get_wcaps(codec, pin);
4056 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4057 if (wcaps == AC_WCAP_OUT_AMP)
4058 /* found a mono speaker with an amp, must be lfe */
4059 lfe_pin = pin;
4062 /* if speaker_outs is 0, then speakers may be in line_outs */
4063 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
4064 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
4065 hda_nid_t pin = spec->autocfg.line_out_pins[i];
4066 unsigned int defcfg;
4067 defcfg = snd_hda_codec_get_pincfg(codec, pin);
4068 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
4069 unsigned int wcaps = get_wcaps(codec, pin);
4070 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4071 if (wcaps == AC_WCAP_OUT_AMP)
4072 /* found a mono speaker with an amp,
4073 must be lfe */
4074 lfe_pin = pin;
4079 if (lfe_pin) {
4080 err = create_controls(codec, "LFE", lfe_pin, 1);
4081 if (err < 0)
4082 return err;
4085 return 0;
4088 static int stac9200_parse_auto_config(struct hda_codec *codec)
4090 struct sigmatel_spec *spec = codec->spec;
4091 int err;
4093 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
4094 return err;
4096 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
4097 return err;
4099 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
4100 return err;
4102 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
4103 return err;
4105 if (spec->num_muxes > 0) {
4106 err = stac92xx_auto_create_mux_input_ctls(codec);
4107 if (err < 0)
4108 return err;
4111 err = stac92xx_add_input_source(spec);
4112 if (err < 0)
4113 return err;
4115 if (spec->autocfg.dig_outs)
4116 spec->multiout.dig_out_nid = 0x05;
4117 if (spec->autocfg.dig_in_pin)
4118 spec->dig_in_nid = 0x04;
4120 if (spec->kctls.list)
4121 spec->mixers[spec->num_mixers++] = spec->kctls.list;
4123 spec->input_mux = &spec->private_imux;
4124 spec->dinput_mux = &spec->private_dimux;
4126 return 1;
4130 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4131 * funky external mute control using GPIO pins.
4134 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4135 unsigned int dir_mask, unsigned int data)
4137 unsigned int gpiostate, gpiomask, gpiodir;
4139 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
4141 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4142 AC_VERB_GET_GPIO_DATA, 0);
4143 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
4145 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4146 AC_VERB_GET_GPIO_MASK, 0);
4147 gpiomask |= mask;
4149 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4150 AC_VERB_GET_GPIO_DIRECTION, 0);
4151 gpiodir |= dir_mask;
4153 /* Configure GPIOx as CMOS */
4154 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4156 snd_hda_codec_write(codec, codec->afg, 0,
4157 AC_VERB_SET_GPIO_MASK, gpiomask);
4158 snd_hda_codec_read(codec, codec->afg, 0,
4159 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
4161 msleep(1);
4163 snd_hda_codec_read(codec, codec->afg, 0,
4164 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
4167 static int stac92xx_add_jack(struct hda_codec *codec,
4168 hda_nid_t nid, int type)
4170 #ifdef CONFIG_SND_HDA_INPUT_JACK
4171 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
4172 int connectivity = get_defcfg_connect(def_conf);
4174 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4175 return 0;
4177 return snd_hda_input_jack_add(codec, nid, type, NULL);
4178 #else
4179 return 0;
4180 #endif /* CONFIG_SND_HDA_INPUT_JACK */
4183 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4184 unsigned char type, int data)
4186 struct sigmatel_event *event;
4188 snd_array_init(&spec->events, sizeof(*event), 32);
4189 event = snd_array_new(&spec->events);
4190 if (!event)
4191 return -ENOMEM;
4192 event->nid = nid;
4193 event->type = type;
4194 event->tag = spec->events.used;
4195 event->data = data;
4197 return event->tag;
4200 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4201 hda_nid_t nid)
4203 struct sigmatel_spec *spec = codec->spec;
4204 struct sigmatel_event *event = spec->events.list;
4205 int i;
4207 for (i = 0; i < spec->events.used; i++, event++) {
4208 if (event->nid == nid)
4209 return event;
4211 return NULL;
4214 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4215 unsigned char tag)
4217 struct sigmatel_spec *spec = codec->spec;
4218 struct sigmatel_event *event = spec->events.list;
4219 int i;
4221 for (i = 0; i < spec->events.used; i++, event++) {
4222 if (event->tag == tag)
4223 return event;
4225 return NULL;
4228 /* check if given nid is a valid pin and no other events are assigned
4229 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4230 * Otherwise, returns zero.
4232 static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4233 unsigned int type)
4235 struct sigmatel_event *event;
4236 int tag;
4238 if (!is_jack_detectable(codec, nid))
4239 return 0;
4240 event = stac_get_event(codec, nid);
4241 if (event) {
4242 if (event->type != type)
4243 return 0;
4244 tag = event->tag;
4245 } else {
4246 tag = stac_add_event(codec->spec, nid, type, 0);
4247 if (tag < 0)
4248 return 0;
4250 snd_hda_codec_write_cache(codec, nid, 0,
4251 AC_VERB_SET_UNSOLICITED_ENABLE,
4252 AC_USRSP_EN | tag);
4253 return 1;
4256 static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4258 int i;
4259 for (i = 0; i < cfg->hp_outs; i++)
4260 if (cfg->hp_pins[i] == nid)
4261 return 1; /* nid is a HP-Out */
4262 for (i = 0; i < cfg->line_outs; i++)
4263 if (cfg->line_out_pins[i] == nid)
4264 return 1; /* nid is a line-Out */
4265 return 0; /* nid is not a HP-Out */
4268 static void stac92xx_power_down(struct hda_codec *codec)
4270 struct sigmatel_spec *spec = codec->spec;
4272 /* power down inactive DACs */
4273 const hda_nid_t *dac;
4274 for (dac = spec->dac_list; *dac; dac++)
4275 if (!check_all_dac_nids(spec, *dac))
4276 snd_hda_codec_write(codec, *dac, 0,
4277 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4280 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4281 int enable);
4283 static inline int get_int_hint(struct hda_codec *codec, const char *key,
4284 int *valp)
4286 const char *p;
4287 p = snd_hda_get_hint(codec, key);
4288 if (p) {
4289 unsigned long val;
4290 if (!strict_strtoul(p, 0, &val)) {
4291 *valp = val;
4292 return 1;
4295 return 0;
4298 /* override some hints from the hwdep entry */
4299 static void stac_store_hints(struct hda_codec *codec)
4301 struct sigmatel_spec *spec = codec->spec;
4302 int val;
4304 val = snd_hda_get_bool_hint(codec, "hp_detect");
4305 if (val >= 0)
4306 spec->hp_detect = val;
4307 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
4308 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4309 spec->gpio_mask;
4311 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
4312 spec->gpio_mask &= spec->gpio_mask;
4313 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
4314 spec->gpio_dir &= spec->gpio_mask;
4315 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
4316 spec->eapd_mask &= spec->gpio_mask;
4317 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
4318 spec->gpio_mute &= spec->gpio_mask;
4319 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4320 if (val >= 0)
4321 spec->eapd_switch = val;
4322 get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity);
4323 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
4324 spec->gpio_mask |= spec->gpio_led;
4325 spec->gpio_dir |= spec->gpio_led;
4326 if (spec->gpio_led_polarity)
4327 spec->gpio_data |= spec->gpio_led;
4331 static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
4332 const hda_nid_t *pins)
4334 while (num_pins--)
4335 stac_issue_unsol_event(codec, *pins++);
4338 /* fake event to set up pins */
4339 static void stac_fake_hp_events(struct hda_codec *codec)
4341 struct sigmatel_spec *spec = codec->spec;
4343 if (spec->autocfg.hp_outs)
4344 stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
4345 spec->autocfg.hp_pins);
4346 if (spec->autocfg.line_outs &&
4347 spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
4348 stac_issue_unsol_events(codec, spec->autocfg.line_outs,
4349 spec->autocfg.line_out_pins);
4352 static int stac92xx_init(struct hda_codec *codec)
4354 struct sigmatel_spec *spec = codec->spec;
4355 struct auto_pin_cfg *cfg = &spec->autocfg;
4356 unsigned int gpio;
4357 int i;
4359 snd_hda_sequence_write(codec, spec->init);
4361 /* power down adcs initially */
4362 if (spec->powerdown_adcs)
4363 for (i = 0; i < spec->num_adcs; i++)
4364 snd_hda_codec_write(codec,
4365 spec->adc_nids[i], 0,
4366 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4368 /* override some hints */
4369 stac_store_hints(codec);
4371 /* set up GPIO */
4372 gpio = spec->gpio_data;
4373 /* turn on EAPD statically when spec->eapd_switch isn't set.
4374 * otherwise, unsol event will turn it on/off dynamically
4376 if (!spec->eapd_switch)
4377 gpio |= spec->eapd_mask;
4378 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4380 /* set up pins */
4381 if (spec->hp_detect) {
4382 /* Enable unsolicited responses on the HP widget */
4383 for (i = 0; i < cfg->hp_outs; i++) {
4384 hda_nid_t nid = cfg->hp_pins[i];
4385 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4387 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4388 cfg->speaker_outs > 0) {
4389 /* enable pin-detect for line-outs as well */
4390 for (i = 0; i < cfg->line_outs; i++) {
4391 hda_nid_t nid = cfg->line_out_pins[i];
4392 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4396 /* force to enable the first line-out; the others are set up
4397 * in unsol_event
4399 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4400 AC_PINCTL_OUT_EN);
4401 /* fake event to set up pins */
4402 stac_fake_hp_events(codec);
4403 } else {
4404 stac92xx_auto_init_multi_out(codec);
4405 stac92xx_auto_init_hp_out(codec);
4406 for (i = 0; i < cfg->hp_outs; i++)
4407 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4409 if (spec->auto_mic) {
4410 /* initialize connection to analog input */
4411 if (spec->dmux_nids)
4412 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4413 AC_VERB_SET_CONNECT_SEL, 0);
4414 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4415 stac_issue_unsol_event(codec, spec->ext_mic.pin);
4416 if (enable_pin_detect(codec, spec->dock_mic.pin,
4417 STAC_MIC_EVENT))
4418 stac_issue_unsol_event(codec, spec->dock_mic.pin);
4420 for (i = 0; i < cfg->num_inputs; i++) {
4421 hda_nid_t nid = cfg->inputs[i].pin;
4422 int type = cfg->inputs[i].type;
4423 unsigned int pinctl, conf;
4424 if (type == AUTO_PIN_MIC) {
4425 /* for mic pins, force to initialize */
4426 pinctl = stac92xx_get_default_vref(codec, nid);
4427 pinctl |= AC_PINCTL_IN_EN;
4428 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4429 } else {
4430 pinctl = snd_hda_codec_read(codec, nid, 0,
4431 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4432 /* if PINCTL already set then skip */
4433 /* Also, if both INPUT and OUTPUT are set,
4434 * it must be a BIOS bug; need to override, too
4436 if (!(pinctl & AC_PINCTL_IN_EN) ||
4437 (pinctl & AC_PINCTL_OUT_EN)) {
4438 pinctl &= ~AC_PINCTL_OUT_EN;
4439 pinctl |= AC_PINCTL_IN_EN;
4440 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4443 conf = snd_hda_codec_get_pincfg(codec, nid);
4444 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4445 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
4446 stac_issue_unsol_event(codec, nid);
4449 for (i = 0; i < spec->num_dmics; i++)
4450 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4451 AC_PINCTL_IN_EN);
4452 if (cfg->dig_out_pins[0])
4453 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
4454 AC_PINCTL_OUT_EN);
4455 if (cfg->dig_in_pin)
4456 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4457 AC_PINCTL_IN_EN);
4458 for (i = 0; i < spec->num_pwrs; i++) {
4459 hda_nid_t nid = spec->pwr_nids[i];
4460 int pinctl, def_conf;
4462 /* power on when no jack detection is available */
4463 /* or when the VREF is used for controlling LED */
4464 if (!spec->hp_detect ||
4465 spec->vref_mute_led_nid == nid) {
4466 stac_toggle_power_map(codec, nid, 1);
4467 continue;
4470 if (is_nid_out_jack_pin(cfg, nid))
4471 continue; /* already has an unsol event */
4473 pinctl = snd_hda_codec_read(codec, nid, 0,
4474 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4475 /* outputs are only ports capable of power management
4476 * any attempts on powering down a input port cause the
4477 * referenced VREF to act quirky.
4479 if (pinctl & AC_PINCTL_IN_EN) {
4480 stac_toggle_power_map(codec, nid, 1);
4481 continue;
4483 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4484 def_conf = get_defcfg_connect(def_conf);
4485 /* skip any ports that don't have jacks since presence
4486 * detection is useless */
4487 if (def_conf != AC_JACK_PORT_COMPLEX) {
4488 if (def_conf != AC_JACK_PORT_NONE)
4489 stac_toggle_power_map(codec, nid, 1);
4490 continue;
4492 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
4493 stac_issue_unsol_event(codec, nid);
4494 continue;
4496 /* none of the above, turn the port OFF */
4497 stac_toggle_power_map(codec, nid, 0);
4500 /* sync mute LED */
4501 if (spec->gpio_led)
4502 hda_call_check_power_status(codec, 0x01);
4503 if (spec->dac_list)
4504 stac92xx_power_down(codec);
4505 return 0;
4508 static void stac92xx_free_kctls(struct hda_codec *codec)
4510 struct sigmatel_spec *spec = codec->spec;
4512 if (spec->kctls.list) {
4513 struct snd_kcontrol_new *kctl = spec->kctls.list;
4514 int i;
4515 for (i = 0; i < spec->kctls.used; i++)
4516 kfree(kctl[i].name);
4518 snd_array_free(&spec->kctls);
4521 static void stac92xx_shutup_pins(struct hda_codec *codec)
4523 unsigned int i, def_conf;
4525 if (codec->bus->shutdown)
4526 return;
4527 for (i = 0; i < codec->init_pins.used; i++) {
4528 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
4529 def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
4530 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
4531 snd_hda_codec_write(codec, pin->nid, 0,
4532 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
4536 static void stac92xx_shutup(struct hda_codec *codec)
4538 struct sigmatel_spec *spec = codec->spec;
4540 stac92xx_shutup_pins(codec);
4542 if (spec->eapd_mask)
4543 stac_gpio_set(codec, spec->gpio_mask,
4544 spec->gpio_dir, spec->gpio_data &
4545 ~spec->eapd_mask);
4548 static void stac92xx_free(struct hda_codec *codec)
4550 struct sigmatel_spec *spec = codec->spec;
4552 if (! spec)
4553 return;
4555 stac92xx_shutup(codec);
4556 snd_hda_input_jack_free(codec);
4557 snd_array_free(&spec->events);
4559 kfree(spec);
4560 snd_hda_detach_beep_device(codec);
4563 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4564 unsigned int flag)
4566 unsigned int old_ctl, pin_ctl;
4568 pin_ctl = snd_hda_codec_read(codec, nid,
4569 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4571 if (pin_ctl & AC_PINCTL_IN_EN) {
4573 * we need to check the current set-up direction of
4574 * shared input pins since they can be switched via
4575 * "xxx as Output" mixer switch
4577 struct sigmatel_spec *spec = codec->spec;
4578 if (nid == spec->line_switch || nid == spec->mic_switch)
4579 return;
4582 old_ctl = pin_ctl;
4583 /* if setting pin direction bits, clear the current
4584 direction bits first */
4585 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4586 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4588 pin_ctl |= flag;
4589 if (old_ctl != pin_ctl)
4590 snd_hda_codec_write_cache(codec, nid, 0,
4591 AC_VERB_SET_PIN_WIDGET_CONTROL,
4592 pin_ctl);
4595 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4596 unsigned int flag)
4598 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4599 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4600 if (pin_ctl & flag)
4601 snd_hda_codec_write_cache(codec, nid, 0,
4602 AC_VERB_SET_PIN_WIDGET_CONTROL,
4603 pin_ctl & ~flag);
4606 static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4608 if (!nid)
4609 return 0;
4610 return snd_hda_jack_detect(codec, nid);
4613 static void stac92xx_line_out_detect(struct hda_codec *codec,
4614 int presence)
4616 struct sigmatel_spec *spec = codec->spec;
4617 struct auto_pin_cfg *cfg = &spec->autocfg;
4618 int i;
4620 for (i = 0; i < cfg->line_outs; i++) {
4621 if (presence)
4622 break;
4623 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4624 if (presence) {
4625 unsigned int pinctl;
4626 pinctl = snd_hda_codec_read(codec,
4627 cfg->line_out_pins[i], 0,
4628 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4629 if (pinctl & AC_PINCTL_IN_EN)
4630 presence = 0; /* mic- or line-input */
4634 if (presence) {
4635 /* disable speakers */
4636 for (i = 0; i < cfg->speaker_outs; i++)
4637 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4638 AC_PINCTL_OUT_EN);
4639 if (spec->eapd_mask && spec->eapd_switch)
4640 stac_gpio_set(codec, spec->gpio_mask,
4641 spec->gpio_dir, spec->gpio_data &
4642 ~spec->eapd_mask);
4643 } else {
4644 /* enable speakers */
4645 for (i = 0; i < cfg->speaker_outs; i++)
4646 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4647 AC_PINCTL_OUT_EN);
4648 if (spec->eapd_mask && spec->eapd_switch)
4649 stac_gpio_set(codec, spec->gpio_mask,
4650 spec->gpio_dir, spec->gpio_data |
4651 spec->eapd_mask);
4655 /* return non-zero if the hp-pin of the given array index isn't
4656 * a jack-detection target
4658 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4660 struct auto_pin_cfg *cfg = &spec->autocfg;
4662 /* ignore sensing of shared line and mic jacks */
4663 if (cfg->hp_pins[i] == spec->line_switch)
4664 return 1;
4665 if (cfg->hp_pins[i] == spec->mic_switch)
4666 return 1;
4667 /* ignore if the pin is set as line-out */
4668 if (cfg->hp_pins[i] == spec->hp_switch)
4669 return 1;
4670 return 0;
4673 static void stac92xx_hp_detect(struct hda_codec *codec)
4675 struct sigmatel_spec *spec = codec->spec;
4676 struct auto_pin_cfg *cfg = &spec->autocfg;
4677 int i, presence;
4679 presence = 0;
4680 if (spec->gpio_mute)
4681 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4682 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4684 for (i = 0; i < cfg->hp_outs; i++) {
4685 if (presence)
4686 break;
4687 if (no_hp_sensing(spec, i))
4688 continue;
4689 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4690 if (presence) {
4691 unsigned int pinctl;
4692 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4693 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4694 if (pinctl & AC_PINCTL_IN_EN)
4695 presence = 0; /* mic- or line-input */
4699 if (presence) {
4700 /* disable lineouts */
4701 if (spec->hp_switch)
4702 stac92xx_reset_pinctl(codec, spec->hp_switch,
4703 AC_PINCTL_OUT_EN);
4704 for (i = 0; i < cfg->line_outs; i++)
4705 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4706 AC_PINCTL_OUT_EN);
4707 } else {
4708 /* enable lineouts */
4709 if (spec->hp_switch)
4710 stac92xx_set_pinctl(codec, spec->hp_switch,
4711 AC_PINCTL_OUT_EN);
4712 for (i = 0; i < cfg->line_outs; i++)
4713 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4714 AC_PINCTL_OUT_EN);
4716 stac92xx_line_out_detect(codec, presence);
4717 /* toggle hp outs */
4718 for (i = 0; i < cfg->hp_outs; i++) {
4719 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4720 if (no_hp_sensing(spec, i))
4721 continue;
4722 if (presence)
4723 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4724 #if 0 /* FIXME */
4725 /* Resetting the pinctl like below may lead to (a sort of) regressions
4726 * on some devices since they use the HP pin actually for line/speaker
4727 * outs although the default pin config shows a different pin (that is
4728 * wrong and useless).
4730 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4731 * But, disabling the code below just works around it, and I'm too tired of
4732 * bug reports with such devices...
4734 else
4735 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4736 #endif /* FIXME */
4740 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4741 int enable)
4743 struct sigmatel_spec *spec = codec->spec;
4744 unsigned int idx, val;
4746 for (idx = 0; idx < spec->num_pwrs; idx++) {
4747 if (spec->pwr_nids[idx] == nid)
4748 break;
4750 if (idx >= spec->num_pwrs)
4751 return;
4753 idx = 1 << idx;
4755 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4756 if (enable)
4757 val &= ~idx;
4758 else
4759 val |= idx;
4761 /* power down unused output ports */
4762 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4765 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4767 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4770 /* get the pin connection (fixed, none, etc) */
4771 static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4773 struct sigmatel_spec *spec = codec->spec;
4774 unsigned int cfg;
4776 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4777 return get_defcfg_connect(cfg);
4780 static int stac92xx_connected_ports(struct hda_codec *codec,
4781 const hda_nid_t *nids, int num_nids)
4783 struct sigmatel_spec *spec = codec->spec;
4784 int idx, num;
4785 unsigned int def_conf;
4787 for (num = 0; num < num_nids; num++) {
4788 for (idx = 0; idx < spec->num_pins; idx++)
4789 if (spec->pin_nids[idx] == nids[num])
4790 break;
4791 if (idx >= spec->num_pins)
4792 break;
4793 def_conf = stac_get_defcfg_connect(codec, idx);
4794 if (def_conf == AC_JACK_PORT_NONE)
4795 break;
4797 return num;
4800 static void stac92xx_mic_detect(struct hda_codec *codec)
4802 struct sigmatel_spec *spec = codec->spec;
4803 struct sigmatel_mic_route *mic;
4805 if (get_pin_presence(codec, spec->ext_mic.pin))
4806 mic = &spec->ext_mic;
4807 else if (get_pin_presence(codec, spec->dock_mic.pin))
4808 mic = &spec->dock_mic;
4809 else
4810 mic = &spec->int_mic;
4811 if (mic->dmux_idx >= 0)
4812 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4813 AC_VERB_SET_CONNECT_SEL,
4814 mic->dmux_idx);
4815 if (mic->mux_idx >= 0)
4816 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4817 AC_VERB_SET_CONNECT_SEL,
4818 mic->mux_idx);
4821 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4823 struct sigmatel_event *event = stac_get_event(codec, nid);
4824 if (!event)
4825 return;
4826 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4829 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4831 struct sigmatel_spec *spec = codec->spec;
4832 struct sigmatel_event *event;
4833 int tag, data;
4835 tag = (res >> 26) & 0x7f;
4836 event = stac_get_event_from_tag(codec, tag);
4837 if (!event)
4838 return;
4840 switch (event->type) {
4841 case STAC_HP_EVENT:
4842 case STAC_LO_EVENT:
4843 stac92xx_hp_detect(codec);
4844 break;
4845 case STAC_MIC_EVENT:
4846 stac92xx_mic_detect(codec);
4847 break;
4850 switch (event->type) {
4851 case STAC_HP_EVENT:
4852 case STAC_LO_EVENT:
4853 case STAC_MIC_EVENT:
4854 case STAC_INSERT_EVENT:
4855 case STAC_PWR_EVENT:
4856 if (spec->num_pwrs > 0)
4857 stac92xx_pin_sense(codec, event->nid);
4858 snd_hda_input_jack_report(codec, event->nid);
4860 switch (codec->subsystem_id) {
4861 case 0x103c308f:
4862 if (event->nid == 0xb) {
4863 int pin = AC_PINCTL_IN_EN;
4865 if (get_pin_presence(codec, 0xa)
4866 && get_pin_presence(codec, 0xb))
4867 pin |= AC_PINCTL_VREF_80;
4868 if (!get_pin_presence(codec, 0xb))
4869 pin |= AC_PINCTL_VREF_80;
4871 /* toggle VREF state based on mic + hp pin
4872 * status
4874 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4877 break;
4878 case STAC_VREF_EVENT:
4879 data = snd_hda_codec_read(codec, codec->afg, 0,
4880 AC_VERB_GET_GPIO_DATA, 0);
4881 /* toggle VREF state based on GPIOx status */
4882 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4883 !!(data & (1 << event->data)));
4884 break;
4888 static int hp_blike_system(u32 subsystem_id);
4890 static void set_hp_led_gpio(struct hda_codec *codec)
4892 struct sigmatel_spec *spec = codec->spec;
4893 unsigned int gpio;
4895 if (spec->gpio_led)
4896 return;
4898 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
4899 gpio &= AC_GPIO_IO_COUNT;
4900 if (gpio > 3)
4901 spec->gpio_led = 0x08; /* GPIO 3 */
4902 else
4903 spec->gpio_led = 0x01; /* GPIO 0 */
4907 * This method searches for the mute LED GPIO configuration
4908 * provided as OEM string in SMBIOS. The format of that string
4909 * is HP_Mute_LED_P_G or HP_Mute_LED_P
4910 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
4911 * that corresponds to the NOT muted state of the master volume
4912 * and G is the index of the GPIO to use as the mute LED control (0..9)
4913 * If _G portion is missing it is assigned based on the codec ID
4915 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
4916 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
4919 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
4920 * SMBIOS - at least the ones I have seen do not have them - which include
4921 * my own system (HP Pavilion dv6-1110ax) and my cousin's
4922 * HP Pavilion dv9500t CTO.
4923 * Need more information on whether it is true across the entire series.
4924 * -- kunal
4926 static int find_mute_led_gpio(struct hda_codec *codec, int default_polarity)
4928 struct sigmatel_spec *spec = codec->spec;
4929 const struct dmi_device *dev = NULL;
4931 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
4932 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
4933 NULL, dev))) {
4934 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
4935 &spec->gpio_led_polarity,
4936 &spec->gpio_led) == 2) {
4937 unsigned int max_gpio;
4938 max_gpio = snd_hda_param_read(codec, codec->afg,
4939 AC_PAR_GPIO_CAP);
4940 max_gpio &= AC_GPIO_IO_COUNT;
4941 if (spec->gpio_led < max_gpio)
4942 spec->gpio_led = 1 << spec->gpio_led;
4943 else
4944 spec->vref_mute_led_nid = spec->gpio_led;
4945 return 1;
4947 if (sscanf(dev->name, "HP_Mute_LED_%d",
4948 &spec->gpio_led_polarity) == 1) {
4949 set_hp_led_gpio(codec);
4950 return 1;
4952 /* BIOS bug: unfilled OEM string */
4953 if (strstr(dev->name, "HP_Mute_LED_P_G")) {
4954 set_hp_led_gpio(codec);
4955 spec->gpio_led_polarity = 1;
4956 return 1;
4961 * Fallback case - if we don't find the DMI strings,
4962 * we statically set the GPIO - if not a B-series system.
4964 if (!hp_blike_system(codec->subsystem_id)) {
4965 set_hp_led_gpio(codec);
4966 spec->gpio_led_polarity = default_polarity;
4967 return 1;
4970 return 0;
4973 static int hp_blike_system(u32 subsystem_id)
4975 switch (subsystem_id) {
4976 case 0x103c1520:
4977 case 0x103c1521:
4978 case 0x103c1523:
4979 case 0x103c1524:
4980 case 0x103c1525:
4981 case 0x103c1722:
4982 case 0x103c1723:
4983 case 0x103c1724:
4984 case 0x103c1725:
4985 case 0x103c1726:
4986 case 0x103c1727:
4987 case 0x103c1728:
4988 case 0x103c1729:
4989 case 0x103c172a:
4990 case 0x103c172b:
4991 case 0x103c307e:
4992 case 0x103c307f:
4993 case 0x103c3080:
4994 case 0x103c3081:
4995 case 0x103c7007:
4996 case 0x103c7008:
4997 return 1;
4999 return 0;
5002 #ifdef CONFIG_PROC_FS
5003 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
5004 struct hda_codec *codec, hda_nid_t nid)
5006 if (nid == codec->afg)
5007 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
5008 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
5011 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
5012 struct hda_codec *codec,
5013 unsigned int verb)
5015 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
5016 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
5019 /* stac92hd71bxx, stac92hd73xx */
5020 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
5021 struct hda_codec *codec, hda_nid_t nid)
5023 stac92hd_proc_hook(buffer, codec, nid);
5024 if (nid == codec->afg)
5025 analog_loop_proc_hook(buffer, codec, 0xfa0);
5028 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
5029 struct hda_codec *codec, hda_nid_t nid)
5031 if (nid == codec->afg)
5032 analog_loop_proc_hook(buffer, codec, 0xfe0);
5035 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
5036 struct hda_codec *codec, hda_nid_t nid)
5038 if (nid == codec->afg)
5039 analog_loop_proc_hook(buffer, codec, 0xfeb);
5041 #else
5042 #define stac92hd_proc_hook NULL
5043 #define stac92hd7x_proc_hook NULL
5044 #define stac9205_proc_hook NULL
5045 #define stac927x_proc_hook NULL
5046 #endif
5048 #ifdef CONFIG_PM
5049 static int stac92xx_resume(struct hda_codec *codec)
5051 stac92xx_init(codec);
5052 snd_hda_codec_resume_amp(codec);
5053 snd_hda_codec_resume_cache(codec);
5054 /* fake event to set up pins again to override cached values */
5055 stac_fake_hp_events(codec);
5056 return 0;
5059 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
5061 stac92xx_shutup(codec);
5062 return 0;
5065 #ifdef CONFIG_SND_HDA_POWER_SAVE
5066 static int stac92xx_pre_resume(struct hda_codec *codec)
5068 struct sigmatel_spec *spec = codec->spec;
5070 /* sync mute LED */
5071 if (spec->vref_mute_led_nid)
5072 stac_vrefout_set(codec, spec->vref_mute_led_nid,
5073 spec->vref_led);
5074 else if (spec->gpio_led)
5075 stac_gpio_set(codec, spec->gpio_mask,
5076 spec->gpio_dir, spec->gpio_data);
5077 return 0;
5080 static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
5081 unsigned int power_state)
5083 unsigned int afg_power_state = power_state;
5084 struct sigmatel_spec *spec = codec->spec;
5086 if (power_state == AC_PWRST_D3) {
5087 if (spec->vref_mute_led_nid) {
5088 /* with vref-out pin used for mute led control
5089 * codec AFG is prevented from D3 state
5091 afg_power_state = AC_PWRST_D1;
5093 /* this delay seems necessary to avoid click noise at power-down */
5094 msleep(100);
5096 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
5097 afg_power_state);
5098 snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
5102 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed
5103 * as mute LED state is updated in check_power_status hook
5105 static int stac92xx_update_led_status(struct hda_codec *codec)
5107 struct sigmatel_spec *spec = codec->spec;
5108 int i, num_ext_dacs, muted = 1;
5109 unsigned int muted_lvl, notmtd_lvl;
5110 hda_nid_t nid;
5112 if (!spec->gpio_led)
5113 return 0;
5115 for (i = 0; i < spec->multiout.num_dacs; i++) {
5116 nid = spec->multiout.dac_nids[i];
5117 if (!(snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
5118 HDA_AMP_MUTE)) {
5119 muted = 0; /* something heard */
5120 break;
5123 if (muted && spec->multiout.hp_nid)
5124 if (!(snd_hda_codec_amp_read(codec,
5125 spec->multiout.hp_nid, 0, HDA_OUTPUT, 0) &
5126 HDA_AMP_MUTE)) {
5127 muted = 0; /* HP is not muted */
5129 num_ext_dacs = ARRAY_SIZE(spec->multiout.extra_out_nid);
5130 for (i = 0; muted && i < num_ext_dacs; i++) {
5131 nid = spec->multiout.extra_out_nid[i];
5132 if (nid == 0)
5133 break;
5134 if (!(snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
5135 HDA_AMP_MUTE)) {
5136 muted = 0; /* extra output is not muted */
5139 /*polarity defines *not* muted state level*/
5140 if (!spec->vref_mute_led_nid) {
5141 if (muted)
5142 spec->gpio_data &= ~spec->gpio_led; /* orange */
5143 else
5144 spec->gpio_data |= spec->gpio_led; /* white */
5146 if (!spec->gpio_led_polarity) {
5147 /* LED state is inverted on these systems */
5148 spec->gpio_data ^= spec->gpio_led;
5150 stac_gpio_set(codec, spec->gpio_mask,
5151 spec->gpio_dir, spec->gpio_data);
5152 } else {
5153 notmtd_lvl = spec->gpio_led_polarity ?
5154 AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_GRD;
5155 muted_lvl = spec->gpio_led_polarity ?
5156 AC_PINCTL_VREF_GRD : AC_PINCTL_VREF_HIZ;
5157 spec->vref_led = muted ? muted_lvl : notmtd_lvl;
5158 stac_vrefout_set(codec, spec->vref_mute_led_nid,
5159 spec->vref_led);
5161 return 0;
5165 * use power check for controlling mute led of HP notebooks
5167 static int stac92xx_check_power_status(struct hda_codec *codec,
5168 hda_nid_t nid)
5170 stac92xx_update_led_status(codec);
5172 return 0;
5174 #endif /* CONFIG_SND_HDA_POWER_SAVE */
5175 #endif /* CONFIG_PM */
5177 static const struct hda_codec_ops stac92xx_patch_ops = {
5178 .build_controls = stac92xx_build_controls,
5179 .build_pcms = stac92xx_build_pcms,
5180 .init = stac92xx_init,
5181 .free = stac92xx_free,
5182 .unsol_event = stac92xx_unsol_event,
5183 #ifdef CONFIG_PM
5184 .suspend = stac92xx_suspend,
5185 .resume = stac92xx_resume,
5186 #endif
5187 .reboot_notify = stac92xx_shutup,
5190 static int patch_stac9200(struct hda_codec *codec)
5192 struct sigmatel_spec *spec;
5193 int err;
5195 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5196 if (spec == NULL)
5197 return -ENOMEM;
5199 codec->no_trigger_sense = 1;
5200 codec->spec = spec;
5201 spec->linear_tone_beep = 1;
5202 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
5203 spec->pin_nids = stac9200_pin_nids;
5204 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
5205 stac9200_models,
5206 stac9200_cfg_tbl);
5207 if (spec->board_config < 0)
5208 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5209 codec->chip_name);
5210 else
5211 stac92xx_set_config_regs(codec,
5212 stac9200_brd_tbl[spec->board_config]);
5214 spec->multiout.max_channels = 2;
5215 spec->multiout.num_dacs = 1;
5216 spec->multiout.dac_nids = stac9200_dac_nids;
5217 spec->adc_nids = stac9200_adc_nids;
5218 spec->mux_nids = stac9200_mux_nids;
5219 spec->num_muxes = 1;
5220 spec->num_dmics = 0;
5221 spec->num_adcs = 1;
5222 spec->num_pwrs = 0;
5224 if (spec->board_config == STAC_9200_M4 ||
5225 spec->board_config == STAC_9200_M4_2 ||
5226 spec->board_config == STAC_9200_OQO)
5227 spec->init = stac9200_eapd_init;
5228 else
5229 spec->init = stac9200_core_init;
5230 spec->mixer = stac9200_mixer;
5232 if (spec->board_config == STAC_9200_PANASONIC) {
5233 spec->gpio_mask = spec->gpio_dir = 0x09;
5234 spec->gpio_data = 0x00;
5237 err = stac9200_parse_auto_config(codec);
5238 if (err < 0) {
5239 stac92xx_free(codec);
5240 return err;
5243 /* CF-74 has no headphone detection, and the driver should *NOT*
5244 * do detection and HP/speaker toggle because the hardware does it.
5246 if (spec->board_config == STAC_9200_PANASONIC)
5247 spec->hp_detect = 0;
5249 codec->patch_ops = stac92xx_patch_ops;
5251 return 0;
5254 static int patch_stac925x(struct hda_codec *codec)
5256 struct sigmatel_spec *spec;
5257 int err;
5259 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5260 if (spec == NULL)
5261 return -ENOMEM;
5263 codec->no_trigger_sense = 1;
5264 codec->spec = spec;
5265 spec->linear_tone_beep = 1;
5266 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
5267 spec->pin_nids = stac925x_pin_nids;
5269 /* Check first for codec ID */
5270 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
5271 STAC_925x_MODELS,
5272 stac925x_models,
5273 stac925x_codec_id_cfg_tbl);
5275 /* Now checks for PCI ID, if codec ID is not found */
5276 if (spec->board_config < 0)
5277 spec->board_config = snd_hda_check_board_config(codec,
5278 STAC_925x_MODELS,
5279 stac925x_models,
5280 stac925x_cfg_tbl);
5281 again:
5282 if (spec->board_config < 0)
5283 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5284 codec->chip_name);
5285 else
5286 stac92xx_set_config_regs(codec,
5287 stac925x_brd_tbl[spec->board_config]);
5289 spec->multiout.max_channels = 2;
5290 spec->multiout.num_dacs = 1;
5291 spec->multiout.dac_nids = stac925x_dac_nids;
5292 spec->adc_nids = stac925x_adc_nids;
5293 spec->mux_nids = stac925x_mux_nids;
5294 spec->num_muxes = 1;
5295 spec->num_adcs = 1;
5296 spec->num_pwrs = 0;
5297 switch (codec->vendor_id) {
5298 case 0x83847632: /* STAC9202 */
5299 case 0x83847633: /* STAC9202D */
5300 case 0x83847636: /* STAC9251 */
5301 case 0x83847637: /* STAC9251D */
5302 spec->num_dmics = STAC925X_NUM_DMICS;
5303 spec->dmic_nids = stac925x_dmic_nids;
5304 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
5305 spec->dmux_nids = stac925x_dmux_nids;
5306 break;
5307 default:
5308 spec->num_dmics = 0;
5309 break;
5312 spec->init = stac925x_core_init;
5313 spec->mixer = stac925x_mixer;
5314 spec->num_caps = 1;
5315 spec->capvols = stac925x_capvols;
5316 spec->capsws = stac925x_capsws;
5318 err = stac92xx_parse_auto_config(codec);
5319 if (!err) {
5320 if (spec->board_config < 0) {
5321 printk(KERN_WARNING "hda_codec: No auto-config is "
5322 "available, default to model=ref\n");
5323 spec->board_config = STAC_925x_REF;
5324 goto again;
5326 err = -EINVAL;
5328 if (err < 0) {
5329 stac92xx_free(codec);
5330 return err;
5333 codec->patch_ops = stac92xx_patch_ops;
5335 return 0;
5338 static int patch_stac92hd73xx(struct hda_codec *codec)
5340 struct sigmatel_spec *spec;
5341 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5342 int err = 0;
5343 int num_dacs;
5345 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5346 if (spec == NULL)
5347 return -ENOMEM;
5349 codec->no_trigger_sense = 1;
5350 codec->spec = spec;
5351 spec->linear_tone_beep = 0;
5352 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
5353 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5354 spec->pin_nids = stac92hd73xx_pin_nids;
5355 spec->board_config = snd_hda_check_board_config(codec,
5356 STAC_92HD73XX_MODELS,
5357 stac92hd73xx_models,
5358 stac92hd73xx_cfg_tbl);
5359 /* check codec subsystem id if not found */
5360 if (spec->board_config < 0)
5361 spec->board_config =
5362 snd_hda_check_board_codec_sid_config(codec,
5363 STAC_92HD73XX_MODELS, stac92hd73xx_models,
5364 stac92hd73xx_codec_id_cfg_tbl);
5365 again:
5366 if (spec->board_config < 0)
5367 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5368 codec->chip_name);
5369 else
5370 stac92xx_set_config_regs(codec,
5371 stac92hd73xx_brd_tbl[spec->board_config]);
5373 num_dacs = snd_hda_get_connections(codec, 0x0a,
5374 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5376 if (num_dacs < 3 || num_dacs > 5) {
5377 printk(KERN_WARNING "hda_codec: Could not determine "
5378 "number of channels defaulting to DAC count\n");
5379 num_dacs = STAC92HD73_DAC_COUNT;
5381 spec->init = stac92hd73xx_core_init;
5382 switch (num_dacs) {
5383 case 0x3: /* 6 Channel */
5384 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
5385 break;
5386 case 0x4: /* 8 Channel */
5387 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
5388 break;
5389 case 0x5: /* 10 Channel */
5390 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5391 break;
5393 spec->multiout.dac_nids = spec->dac_nids;
5395 spec->aloopback_mask = 0x01;
5396 spec->aloopback_shift = 8;
5398 spec->digbeep_nid = 0x1c;
5399 spec->mux_nids = stac92hd73xx_mux_nids;
5400 spec->adc_nids = stac92hd73xx_adc_nids;
5401 spec->dmic_nids = stac92hd73xx_dmic_nids;
5402 spec->dmux_nids = stac92hd73xx_dmux_nids;
5403 spec->smux_nids = stac92hd73xx_smux_nids;
5405 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5406 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
5407 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
5409 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5410 spec->capvols = stac92hd73xx_capvols;
5411 spec->capsws = stac92hd73xx_capsws;
5413 switch (spec->board_config) {
5414 case STAC_DELL_EQ:
5415 spec->init = dell_eq_core_init;
5416 /* fallthru */
5417 case STAC_DELL_M6_AMIC:
5418 case STAC_DELL_M6_DMIC:
5419 case STAC_DELL_M6_BOTH:
5420 spec->num_smuxes = 0;
5421 spec->eapd_switch = 0;
5423 switch (spec->board_config) {
5424 case STAC_DELL_M6_AMIC: /* Analog Mics */
5425 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5426 spec->num_dmics = 0;
5427 break;
5428 case STAC_DELL_M6_DMIC: /* Digital Mics */
5429 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5430 spec->num_dmics = 1;
5431 break;
5432 case STAC_DELL_M6_BOTH: /* Both */
5433 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5434 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5435 spec->num_dmics = 1;
5436 break;
5438 break;
5439 case STAC_ALIENWARE_M17X:
5440 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5441 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5442 spec->eapd_switch = 0;
5443 break;
5444 default:
5445 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5446 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5447 spec->eapd_switch = 1;
5448 break;
5450 if (spec->board_config != STAC_92HD73XX_REF) {
5451 /* GPIO0 High = Enable EAPD */
5452 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5453 spec->gpio_data = 0x01;
5456 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5457 spec->pwr_nids = stac92hd73xx_pwr_nids;
5459 err = stac92xx_parse_auto_config(codec);
5461 if (!err) {
5462 if (spec->board_config < 0) {
5463 printk(KERN_WARNING "hda_codec: No auto-config is "
5464 "available, default to model=ref\n");
5465 spec->board_config = STAC_92HD73XX_REF;
5466 goto again;
5468 err = -EINVAL;
5471 if (err < 0) {
5472 stac92xx_free(codec);
5473 return err;
5476 if (spec->board_config == STAC_92HD73XX_NO_JD)
5477 spec->hp_detect = 0;
5479 codec->patch_ops = stac92xx_patch_ops;
5481 codec->proc_widget_hook = stac92hd7x_proc_hook;
5483 return 0;
5486 static int hp_bnb2011_with_dock(struct hda_codec *codec)
5488 if (codec->vendor_id != 0x111d7605 &&
5489 codec->vendor_id != 0x111d76d1)
5490 return 0;
5492 switch (codec->subsystem_id) {
5493 case 0x103c1618:
5494 case 0x103c1619:
5495 case 0x103c161a:
5496 case 0x103c161b:
5497 case 0x103c161c:
5498 case 0x103c161d:
5499 case 0x103c161e:
5500 case 0x103c161f:
5502 case 0x103c162a:
5503 case 0x103c162b:
5505 case 0x103c1630:
5506 case 0x103c1631:
5508 case 0x103c1633:
5509 case 0x103c1634:
5510 case 0x103c1635:
5512 case 0x103c3587:
5513 case 0x103c3588:
5514 case 0x103c3589:
5515 case 0x103c358a:
5517 case 0x103c3667:
5518 case 0x103c3668:
5519 case 0x103c3669:
5521 return 1;
5523 return 0;
5526 static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
5528 struct sigmatel_spec *spec = codec->spec;
5529 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
5530 int i;
5532 spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
5533 spec->auto_pin_cnt++;
5535 if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
5536 get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
5537 for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
5538 if (nid == stac92hd83xxx_dmic_nids[i]) {
5539 spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
5540 spec->auto_dmic_cnt++;
5546 static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
5548 struct sigmatel_spec *spec = codec->spec;
5550 spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
5551 spec->auto_adc_cnt++;
5554 static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
5556 int i, j;
5557 struct sigmatel_spec *spec = codec->spec;
5559 for (i = 0; i < spec->auto_adc_cnt; i++) {
5560 if (get_connection_index(codec,
5561 spec->auto_adc_nids[i], nid) >= 0) {
5562 /* mux and volume for adc_nids[i] */
5563 if (!spec->auto_mux_nids[i]) {
5564 spec->auto_mux_nids[i] = nid;
5565 /* 92hd codecs capture volume is in mux */
5566 spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
5567 3, 0, HDA_OUTPUT);
5569 for (j = 0; j < spec->auto_dmic_cnt; j++) {
5570 if (get_connection_index(codec, nid,
5571 spec->auto_dmic_nids[j]) >= 0) {
5572 /* dmux for adc_nids[i] */
5573 if (!spec->auto_dmux_nids[i])
5574 spec->auto_dmux_nids[i] = nid;
5575 break;
5578 break;
5583 static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
5585 hda_nid_t nid, end_nid;
5586 unsigned int wid_caps, wid_type;
5587 struct sigmatel_spec *spec = codec->spec;
5589 end_nid = codec->start_nid + codec->num_nodes;
5591 for (nid = codec->start_nid; nid < end_nid; nid++) {
5592 wid_caps = get_wcaps(codec, nid);
5593 wid_type = get_wcaps_type(wid_caps);
5595 if (wid_type == AC_WID_PIN)
5596 stac92hd8x_add_pin(codec, nid);
5598 if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
5599 stac92hd8x_add_adc(codec, nid);
5602 for (nid = codec->start_nid; nid < end_nid; nid++) {
5603 wid_caps = get_wcaps(codec, nid);
5604 wid_type = get_wcaps_type(wid_caps);
5606 if (wid_type == AC_WID_AUD_SEL)
5607 stac92hd8x_add_mux(codec, nid);
5610 spec->pin_nids = spec->auto_pin_nids;
5611 spec->num_pins = spec->auto_pin_cnt;
5612 spec->adc_nids = spec->auto_adc_nids;
5613 spec->num_adcs = spec->auto_adc_cnt;
5614 spec->capvols = spec->auto_capvols;
5615 spec->capsws = spec->auto_capvols;
5616 spec->num_caps = spec->auto_adc_cnt;
5617 spec->mux_nids = spec->auto_mux_nids;
5618 spec->num_muxes = spec->auto_adc_cnt;
5619 spec->dmux_nids = spec->auto_dmux_nids;
5620 spec->num_dmuxes = spec->auto_adc_cnt;
5621 spec->dmic_nids = spec->auto_dmic_nids;
5622 spec->num_dmics = spec->auto_dmic_cnt;
5625 static int patch_stac92hd83xxx(struct hda_codec *codec)
5627 struct sigmatel_spec *spec;
5628 int err;
5630 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5631 if (spec == NULL)
5632 return -ENOMEM;
5634 if (hp_bnb2011_with_dock(codec)) {
5635 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
5636 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
5639 codec->no_trigger_sense = 1;
5640 codec->spec = spec;
5642 stac92hd8x_fill_auto_spec(codec);
5644 spec->linear_tone_beep = 0;
5645 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
5646 spec->digbeep_nid = 0x21;
5647 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5648 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
5649 spec->multiout.dac_nids = spec->dac_nids;
5650 spec->init = stac92hd83xxx_core_init;
5652 spec->board_config = snd_hda_check_board_config(codec,
5653 STAC_92HD83XXX_MODELS,
5654 stac92hd83xxx_models,
5655 stac92hd83xxx_cfg_tbl);
5656 again:
5657 if (spec->board_config < 0)
5658 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5659 codec->chip_name);
5660 else
5661 stac92xx_set_config_regs(codec,
5662 stac92hd83xxx_brd_tbl[spec->board_config]);
5664 codec->patch_ops = stac92xx_patch_ops;
5666 if (find_mute_led_gpio(codec, 0))
5667 snd_printd("mute LED gpio %d polarity %d\n",
5668 spec->gpio_led,
5669 spec->gpio_led_polarity);
5671 #ifdef CONFIG_SND_HDA_POWER_SAVE
5672 if (spec->gpio_led) {
5673 if (!spec->vref_mute_led_nid) {
5674 spec->gpio_mask |= spec->gpio_led;
5675 spec->gpio_dir |= spec->gpio_led;
5676 spec->gpio_data |= spec->gpio_led;
5677 } else {
5678 codec->patch_ops.set_power_state =
5679 stac92xx_set_power_state;
5681 codec->patch_ops.pre_resume = stac92xx_pre_resume;
5682 codec->patch_ops.check_power_status =
5683 stac92xx_check_power_status;
5685 #endif
5687 err = stac92xx_parse_auto_config(codec);
5688 if (!err) {
5689 if (spec->board_config < 0) {
5690 printk(KERN_WARNING "hda_codec: No auto-config is "
5691 "available, default to model=ref\n");
5692 spec->board_config = STAC_92HD83XXX_REF;
5693 goto again;
5695 err = -EINVAL;
5698 if (err < 0) {
5699 stac92xx_free(codec);
5700 return err;
5703 codec->proc_widget_hook = stac92hd_proc_hook;
5705 return 0;
5708 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5709 hda_nid_t dig0pin)
5711 struct sigmatel_spec *spec = codec->spec;
5712 int idx;
5714 for (idx = 0; idx < spec->num_pins; idx++)
5715 if (spec->pin_nids[idx] == dig0pin)
5716 break;
5717 if ((idx + 2) >= spec->num_pins)
5718 return 0;
5720 /* dig1pin case */
5721 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
5722 return 2;
5724 /* dig0pin + dig2pin case */
5725 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
5726 return 2;
5727 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
5728 return 1;
5729 else
5730 return 0;
5733 /* HP dv7 bass switch - GPIO5 */
5734 #define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
5735 static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
5736 struct snd_ctl_elem_value *ucontrol)
5738 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5739 struct sigmatel_spec *spec = codec->spec;
5740 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
5741 return 0;
5744 static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
5745 struct snd_ctl_elem_value *ucontrol)
5747 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5748 struct sigmatel_spec *spec = codec->spec;
5749 unsigned int gpio_data;
5751 gpio_data = (spec->gpio_data & ~0x20) |
5752 (ucontrol->value.integer.value[0] ? 0x20 : 0);
5753 if (gpio_data == spec->gpio_data)
5754 return 0;
5755 spec->gpio_data = gpio_data;
5756 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
5757 return 1;
5760 static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
5761 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5762 .info = stac_hp_bass_gpio_info,
5763 .get = stac_hp_bass_gpio_get,
5764 .put = stac_hp_bass_gpio_put,
5767 static int stac_add_hp_bass_switch(struct hda_codec *codec)
5769 struct sigmatel_spec *spec = codec->spec;
5771 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
5772 "Bass Speaker Playback Switch", 0))
5773 return -ENOMEM;
5775 spec->gpio_mask |= 0x20;
5776 spec->gpio_dir |= 0x20;
5777 spec->gpio_data |= 0x20;
5778 return 0;
5781 static int patch_stac92hd71bxx(struct hda_codec *codec)
5783 struct sigmatel_spec *spec;
5784 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
5785 unsigned int pin_cfg;
5786 int err = 0;
5788 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5789 if (spec == NULL)
5790 return -ENOMEM;
5792 codec->no_trigger_sense = 1;
5793 codec->spec = spec;
5794 spec->linear_tone_beep = 0;
5795 codec->patch_ops = stac92xx_patch_ops;
5796 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5797 switch (codec->vendor_id) {
5798 case 0x111d76b6:
5799 case 0x111d76b7:
5800 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5801 break;
5802 case 0x111d7603:
5803 case 0x111d7608:
5804 /* On 92HD75Bx 0x27 isn't a pin nid */
5805 spec->num_pins--;
5806 /* fallthrough */
5807 default:
5808 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5810 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
5811 spec->board_config = snd_hda_check_board_config(codec,
5812 STAC_92HD71BXX_MODELS,
5813 stac92hd71bxx_models,
5814 stac92hd71bxx_cfg_tbl);
5815 again:
5816 if (spec->board_config < 0)
5817 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5818 codec->chip_name);
5819 else
5820 stac92xx_set_config_regs(codec,
5821 stac92hd71bxx_brd_tbl[spec->board_config]);
5823 if (spec->board_config != STAC_92HD71BXX_REF) {
5824 /* GPIO0 = EAPD */
5825 spec->gpio_mask = 0x01;
5826 spec->gpio_dir = 0x01;
5827 spec->gpio_data = 0x01;
5830 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5831 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5833 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5834 spec->capvols = stac92hd71bxx_capvols;
5835 spec->capsws = stac92hd71bxx_capsws;
5837 switch (codec->vendor_id) {
5838 case 0x111d76b6: /* 4 Port without Analog Mixer */
5839 case 0x111d76b7:
5840 unmute_init++;
5841 /* fallthru */
5842 case 0x111d76b4: /* 6 Port without Analog Mixer */
5843 case 0x111d76b5:
5844 spec->init = stac92hd71bxx_core_init;
5845 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5846 spec->num_dmics = stac92xx_connected_ports(codec,
5847 stac92hd71bxx_dmic_nids,
5848 STAC92HD71BXX_NUM_DMICS);
5849 break;
5850 case 0x111d7608: /* 5 Port with Analog Mixer */
5851 switch (spec->board_config) {
5852 case STAC_HP_M4:
5853 /* Enable VREF power saving on GPIO1 detect */
5854 err = stac_add_event(spec, codec->afg,
5855 STAC_VREF_EVENT, 0x02);
5856 if (err < 0)
5857 return err;
5858 snd_hda_codec_write_cache(codec, codec->afg, 0,
5859 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5860 snd_hda_codec_write_cache(codec, codec->afg, 0,
5861 AC_VERB_SET_UNSOLICITED_ENABLE,
5862 AC_USRSP_EN | err);
5863 spec->gpio_mask |= 0x02;
5864 break;
5866 if ((codec->revision_id & 0xf) == 0 ||
5867 (codec->revision_id & 0xf) == 1)
5868 spec->stream_delay = 40; /* 40 milliseconds */
5870 /* disable VSW */
5871 spec->init = stac92hd71bxx_core_init;
5872 unmute_init++;
5873 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5874 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
5875 spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
5876 spec->num_dmics = stac92xx_connected_ports(codec,
5877 stac92hd71bxx_dmic_5port_nids,
5878 STAC92HD71BXX_NUM_DMICS - 1);
5879 break;
5880 case 0x111d7603: /* 6 Port with Analog Mixer */
5881 if ((codec->revision_id & 0xf) == 1)
5882 spec->stream_delay = 40; /* 40 milliseconds */
5884 /* fallthru */
5885 default:
5886 spec->init = stac92hd71bxx_core_init;
5887 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5888 spec->num_dmics = stac92xx_connected_ports(codec,
5889 stac92hd71bxx_dmic_nids,
5890 STAC92HD71BXX_NUM_DMICS);
5891 break;
5894 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5895 snd_hda_sequence_write_cache(codec, unmute_init);
5897 spec->aloopback_ctl = stac92hd71bxx_loopback;
5898 spec->aloopback_mask = 0x50;
5899 spec->aloopback_shift = 0;
5901 spec->powerdown_adcs = 1;
5902 spec->digbeep_nid = 0x26;
5903 spec->mux_nids = stac92hd71bxx_mux_nids;
5904 spec->adc_nids = stac92hd71bxx_adc_nids;
5905 spec->smux_nids = stac92hd71bxx_smux_nids;
5906 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5908 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5909 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5910 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5911 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5913 snd_printdd("Found board config: %d\n", spec->board_config);
5915 switch (spec->board_config) {
5916 case STAC_HP_M4:
5917 /* enable internal microphone */
5918 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
5919 stac92xx_auto_set_pinctl(codec, 0x0e,
5920 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5921 /* fallthru */
5922 case STAC_DELL_M4_2:
5923 spec->num_dmics = 0;
5924 spec->num_smuxes = 0;
5925 spec->num_dmuxes = 0;
5926 break;
5927 case STAC_DELL_M4_1:
5928 case STAC_DELL_M4_3:
5929 spec->num_dmics = 1;
5930 spec->num_smuxes = 0;
5931 spec->num_dmuxes = 1;
5932 break;
5933 case STAC_HP_DV4_1222NR:
5934 spec->num_dmics = 1;
5935 /* I don't know if it needs 1 or 2 smuxes - will wait for
5936 * bug reports to fix if needed
5938 spec->num_smuxes = 1;
5939 spec->num_dmuxes = 1;
5940 /* fallthrough */
5941 case STAC_HP_DV4:
5942 spec->gpio_led = 0x01;
5943 /* fallthrough */
5944 case STAC_HP_DV5:
5945 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5946 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5947 /* HP dv6 gives the headphone pin as a line-out. Thus we
5948 * need to set hp_detect flag here to force to enable HP
5949 * detection.
5951 spec->hp_detect = 1;
5952 break;
5953 case STAC_HP_HDX:
5954 spec->num_dmics = 1;
5955 spec->num_dmuxes = 1;
5956 spec->num_smuxes = 1;
5957 spec->gpio_led = 0x08;
5958 break;
5961 if (hp_blike_system(codec->subsystem_id)) {
5962 pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
5963 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
5964 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
5965 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
5966 /* It was changed in the BIOS to just satisfy MS DTM.
5967 * Lets turn it back into slaved HP
5969 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
5970 | (AC_JACK_HP_OUT <<
5971 AC_DEFCFG_DEVICE_SHIFT);
5972 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
5973 | AC_DEFCFG_SEQUENCE)))
5974 | 0x1f;
5975 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
5979 if (find_mute_led_gpio(codec, 1))
5980 snd_printd("mute LED gpio %d polarity %d\n",
5981 spec->gpio_led,
5982 spec->gpio_led_polarity);
5984 #ifdef CONFIG_SND_HDA_POWER_SAVE
5985 if (spec->gpio_led) {
5986 if (!spec->vref_mute_led_nid) {
5987 spec->gpio_mask |= spec->gpio_led;
5988 spec->gpio_dir |= spec->gpio_led;
5989 spec->gpio_data |= spec->gpio_led;
5990 } else {
5991 codec->patch_ops.set_power_state =
5992 stac92xx_set_power_state;
5994 codec->patch_ops.pre_resume = stac92xx_pre_resume;
5995 codec->patch_ops.check_power_status =
5996 stac92xx_check_power_status;
5998 #endif
6000 spec->multiout.dac_nids = spec->dac_nids;
6002 err = stac92xx_parse_auto_config(codec);
6003 if (!err) {
6004 if (spec->board_config < 0) {
6005 printk(KERN_WARNING "hda_codec: No auto-config is "
6006 "available, default to model=ref\n");
6007 spec->board_config = STAC_92HD71BXX_REF;
6008 goto again;
6010 err = -EINVAL;
6013 if (err < 0) {
6014 stac92xx_free(codec);
6015 return err;
6018 /* enable bass on HP dv7 */
6019 if (spec->board_config == STAC_HP_DV4 ||
6020 spec->board_config == STAC_HP_DV5) {
6021 unsigned int cap;
6022 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
6023 cap &= AC_GPIO_IO_COUNT;
6024 if (cap >= 6)
6025 stac_add_hp_bass_switch(codec);
6028 codec->proc_widget_hook = stac92hd7x_proc_hook;
6030 return 0;
6033 static int patch_stac922x(struct hda_codec *codec)
6035 struct sigmatel_spec *spec;
6036 int err;
6038 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6039 if (spec == NULL)
6040 return -ENOMEM;
6042 codec->no_trigger_sense = 1;
6043 codec->spec = spec;
6044 spec->linear_tone_beep = 1;
6045 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
6046 spec->pin_nids = stac922x_pin_nids;
6047 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
6048 stac922x_models,
6049 stac922x_cfg_tbl);
6050 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
6051 spec->gpio_mask = spec->gpio_dir = 0x03;
6052 spec->gpio_data = 0x03;
6053 /* Intel Macs have all same PCI SSID, so we need to check
6054 * codec SSID to distinguish the exact models
6056 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
6057 switch (codec->subsystem_id) {
6059 case 0x106b0800:
6060 spec->board_config = STAC_INTEL_MAC_V1;
6061 break;
6062 case 0x106b0600:
6063 case 0x106b0700:
6064 spec->board_config = STAC_INTEL_MAC_V2;
6065 break;
6066 case 0x106b0e00:
6067 case 0x106b0f00:
6068 case 0x106b1600:
6069 case 0x106b1700:
6070 case 0x106b0200:
6071 case 0x106b1e00:
6072 spec->board_config = STAC_INTEL_MAC_V3;
6073 break;
6074 case 0x106b1a00:
6075 case 0x00000100:
6076 spec->board_config = STAC_INTEL_MAC_V4;
6077 break;
6078 case 0x106b0a00:
6079 case 0x106b2200:
6080 spec->board_config = STAC_INTEL_MAC_V5;
6081 break;
6082 default:
6083 spec->board_config = STAC_INTEL_MAC_V3;
6084 break;
6088 again:
6089 if (spec->board_config < 0)
6090 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6091 codec->chip_name);
6092 else
6093 stac92xx_set_config_regs(codec,
6094 stac922x_brd_tbl[spec->board_config]);
6096 spec->adc_nids = stac922x_adc_nids;
6097 spec->mux_nids = stac922x_mux_nids;
6098 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
6099 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
6100 spec->num_dmics = 0;
6101 spec->num_pwrs = 0;
6103 spec->init = stac922x_core_init;
6105 spec->num_caps = STAC922X_NUM_CAPS;
6106 spec->capvols = stac922x_capvols;
6107 spec->capsws = stac922x_capsws;
6109 spec->multiout.dac_nids = spec->dac_nids;
6111 err = stac92xx_parse_auto_config(codec);
6112 if (!err) {
6113 if (spec->board_config < 0) {
6114 printk(KERN_WARNING "hda_codec: No auto-config is "
6115 "available, default to model=ref\n");
6116 spec->board_config = STAC_D945_REF;
6117 goto again;
6119 err = -EINVAL;
6121 if (err < 0) {
6122 stac92xx_free(codec);
6123 return err;
6126 codec->patch_ops = stac92xx_patch_ops;
6128 /* Fix Mux capture level; max to 2 */
6129 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
6130 (0 << AC_AMPCAP_OFFSET_SHIFT) |
6131 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
6132 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
6133 (0 << AC_AMPCAP_MUTE_SHIFT));
6135 return 0;
6138 static int patch_stac927x(struct hda_codec *codec)
6140 struct sigmatel_spec *spec;
6141 int err;
6143 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6144 if (spec == NULL)
6145 return -ENOMEM;
6147 codec->no_trigger_sense = 1;
6148 codec->spec = spec;
6149 spec->linear_tone_beep = 1;
6150 codec->slave_dig_outs = stac927x_slave_dig_outs;
6151 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
6152 spec->pin_nids = stac927x_pin_nids;
6153 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
6154 stac927x_models,
6155 stac927x_cfg_tbl);
6156 again:
6157 if (spec->board_config < 0)
6158 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6159 codec->chip_name);
6160 else
6161 stac92xx_set_config_regs(codec,
6162 stac927x_brd_tbl[spec->board_config]);
6164 spec->digbeep_nid = 0x23;
6165 spec->adc_nids = stac927x_adc_nids;
6166 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
6167 spec->mux_nids = stac927x_mux_nids;
6168 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
6169 spec->smux_nids = stac927x_smux_nids;
6170 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
6171 spec->spdif_labels = stac927x_spdif_labels;
6172 spec->dac_list = stac927x_dac_nids;
6173 spec->multiout.dac_nids = spec->dac_nids;
6175 if (spec->board_config != STAC_D965_REF) {
6176 /* GPIO0 High = Enable EAPD */
6177 spec->eapd_mask = spec->gpio_mask = 0x01;
6178 spec->gpio_dir = spec->gpio_data = 0x01;
6181 switch (spec->board_config) {
6182 case STAC_D965_3ST:
6183 case STAC_D965_5ST:
6184 /* GPIO0 High = Enable EAPD */
6185 spec->num_dmics = 0;
6186 spec->init = d965_core_init;
6187 break;
6188 case STAC_DELL_BIOS:
6189 switch (codec->subsystem_id) {
6190 case 0x10280209:
6191 case 0x1028022e:
6192 /* correct the device field to SPDIF out */
6193 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
6194 break;
6196 /* configure the analog microphone on some laptops */
6197 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
6198 /* correct the front output jack as a hp out */
6199 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
6200 /* correct the front input jack as a mic */
6201 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
6202 /* fallthru */
6203 case STAC_DELL_3ST:
6204 if (codec->subsystem_id != 0x1028022f) {
6205 /* GPIO2 High = Enable EAPD */
6206 spec->eapd_mask = spec->gpio_mask = 0x04;
6207 spec->gpio_dir = spec->gpio_data = 0x04;
6209 spec->dmic_nids = stac927x_dmic_nids;
6210 spec->num_dmics = STAC927X_NUM_DMICS;
6212 spec->init = dell_3st_core_init;
6213 spec->dmux_nids = stac927x_dmux_nids;
6214 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
6215 break;
6216 case STAC_927X_VOLKNOB:
6217 spec->num_dmics = 0;
6218 spec->init = stac927x_volknob_core_init;
6219 break;
6220 default:
6221 spec->num_dmics = 0;
6222 spec->init = stac927x_core_init;
6223 break;
6226 spec->num_caps = STAC927X_NUM_CAPS;
6227 spec->capvols = stac927x_capvols;
6228 spec->capsws = stac927x_capsws;
6230 spec->num_pwrs = 0;
6231 spec->aloopback_ctl = stac927x_loopback;
6232 spec->aloopback_mask = 0x40;
6233 spec->aloopback_shift = 0;
6234 spec->eapd_switch = 1;
6236 err = stac92xx_parse_auto_config(codec);
6237 if (!err) {
6238 if (spec->board_config < 0) {
6239 printk(KERN_WARNING "hda_codec: No auto-config is "
6240 "available, default to model=ref\n");
6241 spec->board_config = STAC_D965_REF;
6242 goto again;
6244 err = -EINVAL;
6246 if (err < 0) {
6247 stac92xx_free(codec);
6248 return err;
6251 codec->patch_ops = stac92xx_patch_ops;
6253 codec->proc_widget_hook = stac927x_proc_hook;
6256 * !!FIXME!!
6257 * The STAC927x seem to require fairly long delays for certain
6258 * command sequences. With too short delays (even if the answer
6259 * is set to RIRB properly), it results in the silence output
6260 * on some hardwares like Dell.
6262 * The below flag enables the longer delay (see get_response
6263 * in hda_intel.c).
6265 codec->bus->needs_damn_long_delay = 1;
6267 /* no jack detecion for ref-no-jd model */
6268 if (spec->board_config == STAC_D965_REF_NO_JD)
6269 spec->hp_detect = 0;
6271 return 0;
6274 static int patch_stac9205(struct hda_codec *codec)
6276 struct sigmatel_spec *spec;
6277 int err;
6279 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6280 if (spec == NULL)
6281 return -ENOMEM;
6283 codec->no_trigger_sense = 1;
6284 codec->spec = spec;
6285 spec->linear_tone_beep = 1;
6286 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
6287 spec->pin_nids = stac9205_pin_nids;
6288 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
6289 stac9205_models,
6290 stac9205_cfg_tbl);
6291 again:
6292 if (spec->board_config < 0)
6293 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6294 codec->chip_name);
6295 else
6296 stac92xx_set_config_regs(codec,
6297 stac9205_brd_tbl[spec->board_config]);
6299 spec->digbeep_nid = 0x23;
6300 spec->adc_nids = stac9205_adc_nids;
6301 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
6302 spec->mux_nids = stac9205_mux_nids;
6303 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
6304 spec->smux_nids = stac9205_smux_nids;
6305 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
6306 spec->dmic_nids = stac9205_dmic_nids;
6307 spec->num_dmics = STAC9205_NUM_DMICS;
6308 spec->dmux_nids = stac9205_dmux_nids;
6309 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
6310 spec->num_pwrs = 0;
6312 spec->init = stac9205_core_init;
6313 spec->aloopback_ctl = stac9205_loopback;
6315 spec->num_caps = STAC9205_NUM_CAPS;
6316 spec->capvols = stac9205_capvols;
6317 spec->capsws = stac9205_capsws;
6319 spec->aloopback_mask = 0x40;
6320 spec->aloopback_shift = 0;
6321 /* Turn on/off EAPD per HP plugging */
6322 if (spec->board_config != STAC_9205_EAPD)
6323 spec->eapd_switch = 1;
6324 spec->multiout.dac_nids = spec->dac_nids;
6326 switch (spec->board_config){
6327 case STAC_9205_DELL_M43:
6328 /* Enable SPDIF in/out */
6329 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
6330 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
6332 /* Enable unsol response for GPIO4/Dock HP connection */
6333 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
6334 if (err < 0)
6335 return err;
6336 snd_hda_codec_write_cache(codec, codec->afg, 0,
6337 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
6338 snd_hda_codec_write_cache(codec, codec->afg, 0,
6339 AC_VERB_SET_UNSOLICITED_ENABLE,
6340 AC_USRSP_EN | err);
6342 spec->gpio_dir = 0x0b;
6343 spec->eapd_mask = 0x01;
6344 spec->gpio_mask = 0x1b;
6345 spec->gpio_mute = 0x10;
6346 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
6347 * GPIO3 Low = DRM
6349 spec->gpio_data = 0x01;
6350 break;
6351 case STAC_9205_REF:
6352 /* SPDIF-In enabled */
6353 break;
6354 default:
6355 /* GPIO0 High = EAPD */
6356 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
6357 spec->gpio_data = 0x01;
6358 break;
6361 err = stac92xx_parse_auto_config(codec);
6362 if (!err) {
6363 if (spec->board_config < 0) {
6364 printk(KERN_WARNING "hda_codec: No auto-config is "
6365 "available, default to model=ref\n");
6366 spec->board_config = STAC_9205_REF;
6367 goto again;
6369 err = -EINVAL;
6371 if (err < 0) {
6372 stac92xx_free(codec);
6373 return err;
6376 codec->patch_ops = stac92xx_patch_ops;
6378 codec->proc_widget_hook = stac9205_proc_hook;
6380 return 0;
6384 * STAC9872 hack
6387 static const struct hda_verb stac9872_core_init[] = {
6388 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
6389 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
6393 static const hda_nid_t stac9872_pin_nids[] = {
6394 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6395 0x11, 0x13, 0x14,
6398 static const hda_nid_t stac9872_adc_nids[] = {
6399 0x8 /*,0x6*/
6402 static const hda_nid_t stac9872_mux_nids[] = {
6403 0x15
6406 static const unsigned long stac9872_capvols[] = {
6407 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
6409 #define stac9872_capsws stac9872_capvols
6411 static const unsigned int stac9872_vaio_pin_configs[9] = {
6412 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
6413 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
6414 0x90a7013e
6417 static const char * const stac9872_models[STAC_9872_MODELS] = {
6418 [STAC_9872_AUTO] = "auto",
6419 [STAC_9872_VAIO] = "vaio",
6422 static const unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
6423 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
6426 static const struct snd_pci_quirk stac9872_cfg_tbl[] = {
6427 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6428 "Sony VAIO F/S", STAC_9872_VAIO),
6429 {} /* terminator */
6432 static int patch_stac9872(struct hda_codec *codec)
6434 struct sigmatel_spec *spec;
6435 int err;
6437 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6438 if (spec == NULL)
6439 return -ENOMEM;
6440 codec->no_trigger_sense = 1;
6441 codec->spec = spec;
6442 spec->linear_tone_beep = 1;
6443 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
6444 spec->pin_nids = stac9872_pin_nids;
6446 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
6447 stac9872_models,
6448 stac9872_cfg_tbl);
6449 if (spec->board_config < 0)
6450 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6451 codec->chip_name);
6452 else
6453 stac92xx_set_config_regs(codec,
6454 stac9872_brd_tbl[spec->board_config]);
6456 spec->multiout.dac_nids = spec->dac_nids;
6457 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
6458 spec->adc_nids = stac9872_adc_nids;
6459 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
6460 spec->mux_nids = stac9872_mux_nids;
6461 spec->init = stac9872_core_init;
6462 spec->num_caps = 1;
6463 spec->capvols = stac9872_capvols;
6464 spec->capsws = stac9872_capsws;
6466 err = stac92xx_parse_auto_config(codec);
6467 if (err < 0) {
6468 stac92xx_free(codec);
6469 return -EINVAL;
6471 spec->input_mux = &spec->private_imux;
6472 codec->patch_ops = stac92xx_patch_ops;
6473 return 0;
6478 * patch entries
6480 static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
6481 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
6482 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
6483 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
6484 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
6485 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
6486 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
6487 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
6488 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
6489 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
6490 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
6491 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
6492 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
6493 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
6494 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
6495 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
6496 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
6497 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
6498 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
6499 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
6500 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
6501 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
6502 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
6503 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
6504 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
6505 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
6506 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
6507 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
6508 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
6509 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
6510 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6511 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
6512 /* The following does not take into account .id=0x83847661 when subsys =
6513 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6514 * currently not fully supported.
6516 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6517 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6518 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
6519 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
6520 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6521 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6522 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6523 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6524 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6525 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6526 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6527 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
6528 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
6529 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
6530 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
6531 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
6532 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
6533 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
6534 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
6535 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
6536 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
6537 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
6538 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
6539 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
6540 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6541 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
6542 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
6543 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6544 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6545 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6546 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6547 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6548 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6549 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6550 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6551 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
6552 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
6553 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
6554 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
6555 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
6556 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
6557 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
6558 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
6559 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
6560 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
6561 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
6562 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
6563 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
6564 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
6565 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
6566 { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
6567 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
6568 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
6569 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
6570 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
6571 { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
6572 { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
6573 { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
6574 { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
6575 { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
6576 { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
6577 { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
6578 { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
6579 { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
6580 { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
6581 { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
6582 { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
6583 {} /* terminator */
6586 MODULE_ALIAS("snd-hda-codec-id:8384*");
6587 MODULE_ALIAS("snd-hda-codec-id:111d*");
6589 MODULE_LICENSE("GPL");
6590 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6592 static struct hda_codec_preset_list sigmatel_list = {
6593 .preset = snd_hda_preset_sigmatel,
6594 .owner = THIS_MODULE,
6597 static int __init patch_sigmatel_init(void)
6599 return snd_hda_add_codec_preset(&sigmatel_list);
6602 static void __exit patch_sigmatel_exit(void)
6604 snd_hda_delete_codec_preset(&sigmatel_list);
6607 module_init(patch_sigmatel_init)
6608 module_exit(patch_sigmatel_exit)