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 <sound/core.h>
32 #include <sound/asoundef.h>
33 #include "hda_codec.h"
34 #include "hda_local.h"
35 #include "hda_patch.h"
38 #define NUM_CONTROL_ALLOC 32
39 #define STAC_PWR_EVENT 0x20
40 #define STAC_HP_EVENT 0x30
104 STAC_INTEL_MAC_AUTO
, /* This model is selected if no module parameter
105 * is given, one of the above models will be
106 * chosen according to the subsystem id. */
107 /* for backward compatibility */
131 struct sigmatel_spec
{
132 struct snd_kcontrol_new
*mixers
[4];
133 unsigned int num_mixers
;
136 unsigned int surr_switch
: 1;
137 unsigned int line_switch
: 1;
138 unsigned int mic_switch
: 1;
139 unsigned int alt_switch
: 1;
140 unsigned int hp_detect
: 1;
143 unsigned int eapd_mask
;
144 unsigned int gpio_mask
;
145 unsigned int gpio_dir
;
146 unsigned int gpio_data
;
147 unsigned int gpio_mute
;
150 unsigned int stream_delay
;
152 /* analog loopback */
153 unsigned char aloopback_mask
;
154 unsigned char aloopback_shift
;
156 /* power management */
157 unsigned int num_pwrs
;
158 unsigned int *pwr_mapping
;
164 struct hda_input_mux
*mono_mux
;
165 struct hda_input_mux
*amp_mux
;
166 unsigned int cur_amux
;
167 unsigned int cur_mmux
;
168 struct hda_multi_out multiout
;
169 hda_nid_t dac_nids
[5];
173 unsigned int num_adcs
;
175 unsigned int num_muxes
;
176 hda_nid_t
*dmic_nids
;
177 unsigned int num_dmics
;
178 hda_nid_t
*dmux_nids
;
179 unsigned int num_dmuxes
;
180 hda_nid_t
*smux_nids
;
181 unsigned int num_smuxes
;
183 hda_nid_t dig_in_nid
;
185 hda_nid_t anabeep_nid
;
186 hda_nid_t digbeep_nid
;
190 unsigned int num_pins
;
191 unsigned int *pin_configs
;
192 unsigned int *bios_pin_configs
;
194 /* codec specific stuff */
195 struct hda_verb
*init
;
196 struct snd_kcontrol_new
*mixer
;
199 struct hda_input_mux
*dinput_mux
;
200 unsigned int cur_dmux
[2];
201 struct hda_input_mux
*input_mux
;
202 unsigned int cur_mux
[3];
203 struct hda_input_mux
*sinput_mux
;
204 unsigned int cur_smux
[2];
205 unsigned int powerdown_adcs
;
208 unsigned int io_switch
[2];
209 unsigned int clfe_swap
;
210 unsigned int hp_switch
;
211 unsigned int aloopback
;
213 struct hda_pcm pcm_rec
[2]; /* PCM information */
215 /* dynamic controls and input_mux */
216 struct auto_pin_cfg autocfg
;
217 unsigned int num_kctl_alloc
, num_kctl_used
;
218 struct snd_kcontrol_new
*kctl_alloc
;
219 struct hda_input_mux private_dimux
;
220 struct hda_input_mux private_imux
;
221 struct hda_input_mux private_smux
;
222 struct hda_input_mux private_amp_mux
;
223 struct hda_input_mux private_mono_mux
;
226 static hda_nid_t stac9200_adc_nids
[1] = {
230 static hda_nid_t stac9200_mux_nids
[1] = {
234 static hda_nid_t stac9200_dac_nids
[1] = {
238 static hda_nid_t stac92hd73xx_pwr_nids
[8] = {
239 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
243 static hda_nid_t stac92hd73xx_slave_dig_outs
[2] = {
247 static hda_nid_t stac92hd73xx_adc_nids
[2] = {
251 static hda_nid_t stac92hd73xx_amp_nids
[4] = {
255 #define STAC92HD73XX_NUM_DMICS 2
256 static hda_nid_t stac92hd73xx_dmic_nids
[STAC92HD73XX_NUM_DMICS
+ 1] = {
260 #define STAC92HD73_DAC_COUNT 5
261 static hda_nid_t stac92hd73xx_dac_nids
[STAC92HD73_DAC_COUNT
] = {
262 0x15, 0x16, 0x17, 0x18, 0x19,
265 static hda_nid_t stac92hd73xx_mux_nids
[4] = {
266 0x28, 0x29, 0x2a, 0x2b,
269 static hda_nid_t stac92hd73xx_dmux_nids
[2] = {
273 static hda_nid_t stac92hd73xx_smux_nids
[2] = {
277 #define STAC92HD83XXX_NUM_DMICS 2
278 static hda_nid_t stac92hd83xxx_dmic_nids
[STAC92HD83XXX_NUM_DMICS
+ 1] = {
282 #define STAC92HD81_DAC_COUNT 2
283 #define STAC92HD83_DAC_COUNT 3
284 static hda_nid_t stac92hd83xxx_dac_nids
[STAC92HD73_DAC_COUNT
] = {
288 static hda_nid_t stac92hd83xxx_dmux_nids
[2] = {
292 static hda_nid_t stac92hd83xxx_adc_nids
[2] = {
296 static hda_nid_t stac92hd83xxx_pwr_nids
[4] = {
300 static hda_nid_t stac92hd83xxx_slave_dig_outs
[2] = {
304 static unsigned int stac92hd83xxx_pwr_mapping
[4] = {
305 0x03, 0x0c, 0x10, 0x40,
308 static hda_nid_t stac92hd71bxx_pwr_nids
[3] = {
312 static hda_nid_t stac92hd71bxx_adc_nids
[2] = {
316 static hda_nid_t stac92hd71bxx_mux_nids
[2] = {
320 static hda_nid_t stac92hd71bxx_dmux_nids
[1] = {
324 static hda_nid_t stac92hd71bxx_smux_nids
[2] = {
328 static hda_nid_t stac92hd71bxx_dac_nids
[1] = {
332 #define STAC92HD71BXX_NUM_DMICS 2
333 static hda_nid_t stac92hd71bxx_dmic_nids
[STAC92HD71BXX_NUM_DMICS
+ 1] = {
337 static hda_nid_t stac92hd71bxx_slave_dig_outs
[2] = {
341 static hda_nid_t stac925x_adc_nids
[1] = {
345 static hda_nid_t stac925x_mux_nids
[1] = {
349 static hda_nid_t stac925x_dac_nids
[1] = {
353 #define STAC925X_NUM_DMICS 1
354 static hda_nid_t stac925x_dmic_nids
[STAC925X_NUM_DMICS
+ 1] = {
358 static hda_nid_t stac925x_dmux_nids
[1] = {
362 static hda_nid_t stac922x_adc_nids
[2] = {
366 static hda_nid_t stac922x_mux_nids
[2] = {
370 static hda_nid_t stac927x_adc_nids
[3] = {
374 static hda_nid_t stac927x_mux_nids
[3] = {
378 static hda_nid_t stac927x_smux_nids
[1] = {
382 static hda_nid_t stac927x_dac_nids
[6] = {
383 0x02, 0x03, 0x04, 0x05, 0x06, 0
386 static hda_nid_t stac927x_dmux_nids
[1] = {
390 #define STAC927X_NUM_DMICS 2
391 static hda_nid_t stac927x_dmic_nids
[STAC927X_NUM_DMICS
+ 1] = {
395 static hda_nid_t stac9205_adc_nids
[2] = {
399 static hda_nid_t stac9205_mux_nids
[2] = {
403 static hda_nid_t stac9205_dmux_nids
[1] = {
407 static hda_nid_t stac9205_smux_nids
[1] = {
411 #define STAC9205_NUM_DMICS 2
412 static hda_nid_t stac9205_dmic_nids
[STAC9205_NUM_DMICS
+ 1] = {
416 static hda_nid_t stac9200_pin_nids
[8] = {
417 0x08, 0x09, 0x0d, 0x0e,
418 0x0f, 0x10, 0x11, 0x12,
421 static hda_nid_t stac925x_pin_nids
[8] = {
422 0x07, 0x08, 0x0a, 0x0b,
423 0x0c, 0x0d, 0x10, 0x11,
426 static hda_nid_t stac922x_pin_nids
[10] = {
427 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
428 0x0f, 0x10, 0x11, 0x15, 0x1b,
431 static hda_nid_t stac92hd73xx_pin_nids
[13] = {
432 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
433 0x0f, 0x10, 0x11, 0x12, 0x13,
437 static hda_nid_t stac92hd83xxx_pin_nids
[14] = {
438 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
439 0x0f, 0x10, 0x11, 0x12, 0x13,
440 0x1d, 0x1e, 0x1f, 0x20
442 static hda_nid_t stac92hd71bxx_pin_nids
[11] = {
443 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
444 0x0f, 0x14, 0x18, 0x19, 0x1e,
448 static hda_nid_t stac927x_pin_nids
[14] = {
449 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
450 0x0f, 0x10, 0x11, 0x12, 0x13,
451 0x14, 0x21, 0x22, 0x23,
454 static hda_nid_t stac9205_pin_nids
[12] = {
455 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
456 0x0f, 0x14, 0x16, 0x17, 0x18,
460 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
462 static int stac92xx_amp_volume_get(struct snd_kcontrol
*kcontrol
,
463 struct snd_ctl_elem_value
*ucontrol
)
465 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
466 struct sigmatel_spec
*spec
= codec
->spec
;
467 hda_nid_t nid
= spec
->amp_nids
[spec
->cur_amux
];
469 kcontrol
->private_value
^= get_amp_nid(kcontrol
);
470 kcontrol
->private_value
|= nid
;
472 return snd_hda_mixer_amp_volume_get(kcontrol
, ucontrol
);
475 static int stac92xx_amp_volume_put(struct snd_kcontrol
*kcontrol
,
476 struct snd_ctl_elem_value
*ucontrol
)
478 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
479 struct sigmatel_spec
*spec
= codec
->spec
;
480 hda_nid_t nid
= spec
->amp_nids
[spec
->cur_amux
];
482 kcontrol
->private_value
^= get_amp_nid(kcontrol
);
483 kcontrol
->private_value
|= nid
;
485 return snd_hda_mixer_amp_volume_put(kcontrol
, ucontrol
);
488 static int stac92xx_dmux_enum_info(struct snd_kcontrol
*kcontrol
,
489 struct snd_ctl_elem_info
*uinfo
)
491 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
492 struct sigmatel_spec
*spec
= codec
->spec
;
493 return snd_hda_input_mux_info(spec
->dinput_mux
, uinfo
);
496 static int stac92xx_dmux_enum_get(struct snd_kcontrol
*kcontrol
,
497 struct snd_ctl_elem_value
*ucontrol
)
499 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
500 struct sigmatel_spec
*spec
= codec
->spec
;
501 unsigned int dmux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
503 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_dmux
[dmux_idx
];
507 static int stac92xx_dmux_enum_put(struct snd_kcontrol
*kcontrol
,
508 struct snd_ctl_elem_value
*ucontrol
)
510 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
511 struct sigmatel_spec
*spec
= codec
->spec
;
512 unsigned int dmux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
514 return snd_hda_input_mux_put(codec
, spec
->dinput_mux
, ucontrol
,
515 spec
->dmux_nids
[dmux_idx
], &spec
->cur_dmux
[dmux_idx
]);
518 static int stac92xx_smux_enum_info(struct snd_kcontrol
*kcontrol
,
519 struct snd_ctl_elem_info
*uinfo
)
521 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
522 struct sigmatel_spec
*spec
= codec
->spec
;
523 return snd_hda_input_mux_info(spec
->sinput_mux
, uinfo
);
526 static int stac92xx_smux_enum_get(struct snd_kcontrol
*kcontrol
,
527 struct snd_ctl_elem_value
*ucontrol
)
529 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
530 struct sigmatel_spec
*spec
= codec
->spec
;
531 unsigned int smux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
533 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_smux
[smux_idx
];
537 static int stac92xx_smux_enum_put(struct snd_kcontrol
*kcontrol
,
538 struct snd_ctl_elem_value
*ucontrol
)
540 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
541 struct sigmatel_spec
*spec
= codec
->spec
;
542 unsigned int smux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
544 return snd_hda_input_mux_put(codec
, spec
->sinput_mux
, ucontrol
,
545 spec
->smux_nids
[smux_idx
], &spec
->cur_smux
[smux_idx
]);
548 static int stac92xx_mux_enum_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
550 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
551 struct sigmatel_spec
*spec
= codec
->spec
;
552 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
555 static int stac92xx_mux_enum_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
557 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
558 struct sigmatel_spec
*spec
= codec
->spec
;
559 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
561 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
565 static int stac92xx_mux_enum_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
567 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
568 struct sigmatel_spec
*spec
= codec
->spec
;
569 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
571 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
572 spec
->mux_nids
[adc_idx
], &spec
->cur_mux
[adc_idx
]);
575 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol
*kcontrol
,
576 struct snd_ctl_elem_info
*uinfo
)
578 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
579 struct sigmatel_spec
*spec
= codec
->spec
;
580 return snd_hda_input_mux_info(spec
->mono_mux
, uinfo
);
583 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol
*kcontrol
,
584 struct snd_ctl_elem_value
*ucontrol
)
586 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
587 struct sigmatel_spec
*spec
= codec
->spec
;
589 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mmux
;
593 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol
*kcontrol
,
594 struct snd_ctl_elem_value
*ucontrol
)
596 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
597 struct sigmatel_spec
*spec
= codec
->spec
;
599 return snd_hda_input_mux_put(codec
, spec
->mono_mux
, ucontrol
,
600 spec
->mono_nid
, &spec
->cur_mmux
);
603 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol
*kcontrol
,
604 struct snd_ctl_elem_info
*uinfo
)
606 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
607 struct sigmatel_spec
*spec
= codec
->spec
;
608 return snd_hda_input_mux_info(spec
->amp_mux
, uinfo
);
611 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol
*kcontrol
,
612 struct snd_ctl_elem_value
*ucontrol
)
614 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
615 struct sigmatel_spec
*spec
= codec
->spec
;
617 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_amux
;
621 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol
*kcontrol
,
622 struct snd_ctl_elem_value
*ucontrol
)
624 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
625 struct sigmatel_spec
*spec
= codec
->spec
;
626 struct snd_kcontrol
*ctl
=
627 snd_hda_find_mixer_ctl(codec
, "Amp Capture Volume");
631 snd_ctl_notify(codec
->bus
->card
, SNDRV_CTL_EVENT_MASK_VALUE
|
632 SNDRV_CTL_EVENT_MASK_INFO
, &ctl
->id
);
634 return snd_hda_input_mux_put(codec
, spec
->amp_mux
, ucontrol
,
638 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
640 static int stac92xx_aloopback_get(struct snd_kcontrol
*kcontrol
,
641 struct snd_ctl_elem_value
*ucontrol
)
643 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
644 unsigned int idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
645 struct sigmatel_spec
*spec
= codec
->spec
;
647 ucontrol
->value
.integer
.value
[0] = !!(spec
->aloopback
&
648 (spec
->aloopback_mask
<< idx
));
652 static int stac92xx_aloopback_put(struct snd_kcontrol
*kcontrol
,
653 struct snd_ctl_elem_value
*ucontrol
)
655 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
656 struct sigmatel_spec
*spec
= codec
->spec
;
657 unsigned int idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
658 unsigned int dac_mode
;
659 unsigned int val
, idx_val
;
661 idx_val
= spec
->aloopback_mask
<< idx
;
662 if (ucontrol
->value
.integer
.value
[0])
663 val
= spec
->aloopback
| idx_val
;
665 val
= spec
->aloopback
& ~idx_val
;
666 if (spec
->aloopback
== val
)
669 spec
->aloopback
= val
;
671 /* Only return the bits defined by the shift value of the
672 * first two bytes of the mask
674 dac_mode
= snd_hda_codec_read(codec
, codec
->afg
, 0,
675 kcontrol
->private_value
& 0xFFFF, 0x0);
676 dac_mode
>>= spec
->aloopback_shift
;
678 if (spec
->aloopback
& idx_val
) {
679 snd_hda_power_up(codec
);
682 snd_hda_power_down(codec
);
683 dac_mode
&= ~idx_val
;
686 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
687 kcontrol
->private_value
>> 16, dac_mode
);
692 static struct hda_verb stac9200_core_init
[] = {
693 /* set dac0mux for dac converter */
694 { 0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
698 static struct hda_verb stac9200_eapd_init
[] = {
699 /* set dac0mux for dac converter */
700 {0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
701 {0x08, AC_VERB_SET_EAPD_BTLENABLE
, 0x02},
705 static struct hda_verb stac92hd73xx_6ch_core_init
[] = {
706 /* set master volume and direct control */
707 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
708 /* setup audio connections */
709 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x00},
710 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x01},
711 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x02},
712 /* setup adcs to point to mixer */
713 { 0x20, AC_VERB_SET_CONNECT_SEL
, 0x0b},
714 { 0x21, AC_VERB_SET_CONNECT_SEL
, 0x0b},
715 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
716 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
717 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
718 /* setup import muxs */
719 { 0x28, AC_VERB_SET_CONNECT_SEL
, 0x01},
720 { 0x29, AC_VERB_SET_CONNECT_SEL
, 0x01},
721 { 0x2a, AC_VERB_SET_CONNECT_SEL
, 0x01},
722 { 0x2b, AC_VERB_SET_CONNECT_SEL
, 0x00},
726 static struct hda_verb dell_eq_core_init
[] = {
727 /* set master volume to max value without distortion
728 * and direct control */
729 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xec},
730 /* setup audio connections */
731 { 0x0d, AC_VERB_SET_CONNECT_SEL
, 0x00},
732 { 0x0a, AC_VERB_SET_CONNECT_SEL
, 0x01},
733 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x02},
734 /* setup adcs to point to mixer */
735 { 0x20, AC_VERB_SET_CONNECT_SEL
, 0x0b},
736 { 0x21, AC_VERB_SET_CONNECT_SEL
, 0x0b},
737 /* setup import muxs */
738 { 0x28, AC_VERB_SET_CONNECT_SEL
, 0x01},
739 { 0x29, AC_VERB_SET_CONNECT_SEL
, 0x01},
740 { 0x2a, AC_VERB_SET_CONNECT_SEL
, 0x01},
741 { 0x2b, AC_VERB_SET_CONNECT_SEL
, 0x00},
745 static struct hda_verb dell_m6_core_init
[] = {
746 /* set master volume to max value without distortion
747 * and direct control */
748 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xec},
749 /* setup audio connections */
750 { 0x0d, AC_VERB_SET_CONNECT_SEL
, 0x00},
751 { 0x0a, AC_VERB_SET_CONNECT_SEL
, 0x01},
752 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x02},
753 /* setup adcs to point to mixer */
754 { 0x20, AC_VERB_SET_CONNECT_SEL
, 0x0b},
755 { 0x21, AC_VERB_SET_CONNECT_SEL
, 0x0b},
756 /* setup import muxs */
757 { 0x28, AC_VERB_SET_CONNECT_SEL
, 0x01},
758 { 0x29, AC_VERB_SET_CONNECT_SEL
, 0x01},
759 { 0x2a, AC_VERB_SET_CONNECT_SEL
, 0x01},
760 { 0x2b, AC_VERB_SET_CONNECT_SEL
, 0x00},
764 static struct hda_verb stac92hd73xx_8ch_core_init
[] = {
765 /* set master volume and direct control */
766 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
767 /* setup audio connections */
768 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x00},
769 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x01},
770 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x02},
771 /* connect hp ports to dac3 */
772 { 0x0a, AC_VERB_SET_CONNECT_SEL
, 0x03},
773 { 0x0d, AC_VERB_SET_CONNECT_SEL
, 0x03},
774 /* setup adcs to point to mixer */
775 { 0x20, AC_VERB_SET_CONNECT_SEL
, 0x0b},
776 { 0x21, AC_VERB_SET_CONNECT_SEL
, 0x0b},
777 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
778 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
779 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
780 /* setup import muxs */
781 { 0x28, AC_VERB_SET_CONNECT_SEL
, 0x01},
782 { 0x29, AC_VERB_SET_CONNECT_SEL
, 0x01},
783 { 0x2a, AC_VERB_SET_CONNECT_SEL
, 0x01},
784 { 0x2b, AC_VERB_SET_CONNECT_SEL
, 0x03},
788 static struct hda_verb stac92hd73xx_10ch_core_init
[] = {
789 /* set master volume and direct control */
790 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
791 /* setup audio connections */
792 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x00 },
793 { 0x10, AC_VERB_SET_CONNECT_SEL
, 0x01 },
794 { 0x11, AC_VERB_SET_CONNECT_SEL
, 0x02 },
795 /* dac3 is connected to import3 mux */
796 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb07f},
797 /* connect hp ports to dac4 */
798 { 0x0a, AC_VERB_SET_CONNECT_SEL
, 0x04},
799 { 0x0d, AC_VERB_SET_CONNECT_SEL
, 0x04},
800 /* setup adcs to point to mixer */
801 { 0x20, AC_VERB_SET_CONNECT_SEL
, 0x0b},
802 { 0x21, AC_VERB_SET_CONNECT_SEL
, 0x0b},
803 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
804 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
805 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
806 /* setup import muxs */
807 { 0x28, AC_VERB_SET_CONNECT_SEL
, 0x01},
808 { 0x29, AC_VERB_SET_CONNECT_SEL
, 0x01},
809 { 0x2a, AC_VERB_SET_CONNECT_SEL
, 0x01},
810 { 0x2b, AC_VERB_SET_CONNECT_SEL
, 0x03},
814 static struct hda_verb stac92hd83xxx_core_init
[] = {
815 /* start of config #1 */
816 { 0xe, AC_VERB_SET_CONNECT_SEL
, 0x3},
818 /* start of config #2 */
819 { 0xa, AC_VERB_SET_CONNECT_SEL
, 0x0},
820 { 0xb, AC_VERB_SET_CONNECT_SEL
, 0x0},
821 { 0xd, AC_VERB_SET_CONNECT_SEL
, 0x1},
823 /* power state controls amps */
824 { 0x01, AC_VERB_SET_EAPD
, 1 << 2},
827 static struct hda_verb stac92hd71bxx_core_init
[] = {
828 /* set master volume and direct control */
829 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
830 /* connect headphone jack to dac1 */
831 { 0x0a, AC_VERB_SET_CONNECT_SEL
, 0x01},
832 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* Speaker */
833 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
834 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
835 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
836 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
839 #define HD_DISABLE_PORTF 3
840 static struct hda_verb stac92hd71bxx_analog_core_init
[] = {
841 /* start of config #1 */
843 /* connect port 0f to audio mixer */
844 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x2},
845 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* Speaker */
846 /* unmute right and left channels for node 0x0f */
847 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
848 /* start of config #2 */
850 /* set master volume and direct control */
851 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
852 /* connect headphone jack to dac1 */
853 { 0x0a, AC_VERB_SET_CONNECT_SEL
, 0x01},
854 /* connect port 0d to audio mixer */
855 { 0x0d, AC_VERB_SET_CONNECT_SEL
, 0x2},
856 /* unmute dac0 input in audio mixer */
857 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE
, 0x701f},
858 /* unmute right and left channels for nodes 0x0a, 0xd */
859 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
860 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
864 static struct hda_verb stac925x_core_init
[] = {
865 /* set dac0mux for dac converter */
866 { 0x06, AC_VERB_SET_CONNECT_SEL
, 0x00},
870 static struct hda_verb stac922x_core_init
[] = {
871 /* set master volume and direct control */
872 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
876 static struct hda_verb d965_core_init
[] = {
877 /* set master volume and direct control */
878 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
879 /* unmute node 0x1b */
880 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
881 /* select node 0x03 as DAC */
882 { 0x0b, AC_VERB_SET_CONNECT_SEL
, 0x01},
886 static struct hda_verb stac927x_core_init
[] = {
887 /* set master volume and direct control */
888 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
889 /* enable analog pc beep path */
890 { 0x01, AC_VERB_SET_DIGI_CONVERT_2
, 1 << 5},
894 static struct hda_verb stac9205_core_init
[] = {
895 /* set master volume and direct control */
896 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
897 /* enable analog pc beep path */
898 { 0x01, AC_VERB_SET_DIGI_CONVERT_2
, 1 << 5},
902 #define STAC_MONO_MUX \
904 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
905 .name = "Mono Mux", \
907 .info = stac92xx_mono_mux_enum_info, \
908 .get = stac92xx_mono_mux_enum_get, \
909 .put = stac92xx_mono_mux_enum_put, \
912 #define STAC_AMP_MUX \
914 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
915 .name = "Amp Selector Capture Switch", \
917 .info = stac92xx_amp_mux_enum_info, \
918 .get = stac92xx_amp_mux_enum_get, \
919 .put = stac92xx_amp_mux_enum_put, \
922 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
924 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
927 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
928 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
929 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
930 .info = stac92xx_amp_volume_info, \
931 .get = stac92xx_amp_volume_get, \
932 .put = stac92xx_amp_volume_put, \
933 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
934 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
937 #define STAC_INPUT_SOURCE(cnt) \
939 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
940 .name = "Input Source", \
942 .info = stac92xx_mux_enum_info, \
943 .get = stac92xx_mux_enum_get, \
944 .put = stac92xx_mux_enum_put, \
947 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
949 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
950 .name = "Analog Loopback", \
952 .info = stac92xx_aloopback_info, \
953 .get = stac92xx_aloopback_get, \
954 .put = stac92xx_aloopback_put, \
955 .private_value = verb_read | (verb_write << 16), \
958 static struct snd_kcontrol_new stac9200_mixer
[] = {
959 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT
),
960 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT
),
961 STAC_INPUT_SOURCE(1),
962 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT
),
963 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT
),
967 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer
[] = {
968 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
970 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT
),
971 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT
),
973 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT
),
974 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT
),
976 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT
),
977 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT
),
979 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT
),
980 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT
),
982 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT
),
983 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT
),
985 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT
),
986 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT
),
988 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT
),
989 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT
),
993 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer
[] = {
994 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
996 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT
),
997 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT
),
999 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT
),
1000 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT
),
1002 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT
),
1003 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT
),
1005 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT
),
1006 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT
),
1008 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT
),
1009 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT
),
1011 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT
),
1012 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT
),
1014 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT
),
1015 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT
),
1019 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer
[] = {
1020 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1022 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT
),
1023 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT
),
1025 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT
),
1026 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT
),
1028 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT
),
1029 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT
),
1031 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT
),
1032 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT
),
1034 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT
),
1035 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT
),
1037 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT
),
1038 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT
),
1040 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT
),
1041 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT
),
1046 static struct snd_kcontrol_new stac92hd83xxx_mixer
[] = {
1047 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT
),
1048 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT
),
1050 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT
),
1051 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT
),
1053 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT
),
1054 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT
),
1056 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT
),
1057 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT
),
1059 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT
),
1060 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT
),
1062 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT
),
1063 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT
),
1066 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1067 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1072 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer
[] = {
1073 STAC_INPUT_SOURCE(2),
1075 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT
),
1076 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT
),
1078 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT
),
1079 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT
),
1080 /* analog pc-beep replaced with digital beep support */
1082 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1083 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1086 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT
),
1087 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT
),
1091 static struct snd_kcontrol_new stac92hd71bxx_mixer
[] = {
1092 STAC_INPUT_SOURCE(2),
1093 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1095 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT
),
1096 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT
),
1098 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT
),
1099 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT
),
1103 static struct snd_kcontrol_new stac925x_mixer
[] = {
1104 STAC_INPUT_SOURCE(1),
1105 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT
),
1106 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT
),
1110 static struct snd_kcontrol_new stac9205_mixer
[] = {
1111 STAC_INPUT_SOURCE(2),
1112 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1114 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT
),
1115 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT
),
1117 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT
),
1118 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT
),
1122 /* This needs to be generated dynamically based on sequence */
1123 static struct snd_kcontrol_new stac922x_mixer
[] = {
1124 STAC_INPUT_SOURCE(2),
1125 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT
),
1126 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT
),
1128 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT
),
1129 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT
),
1134 static struct snd_kcontrol_new stac927x_mixer
[] = {
1135 STAC_INPUT_SOURCE(3),
1136 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1138 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT
),
1139 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT
),
1141 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT
),
1142 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT
),
1144 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT
),
1145 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT
),
1149 static struct snd_kcontrol_new stac_dmux_mixer
= {
1150 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1151 .name
= "Digital Input Source",
1152 /* count set later */
1153 .info
= stac92xx_dmux_enum_info
,
1154 .get
= stac92xx_dmux_enum_get
,
1155 .put
= stac92xx_dmux_enum_put
,
1158 static struct snd_kcontrol_new stac_smux_mixer
= {
1159 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1160 .name
= "IEC958 Playback Source",
1161 /* count set later */
1162 .info
= stac92xx_smux_enum_info
,
1163 .get
= stac92xx_smux_enum_get
,
1164 .put
= stac92xx_smux_enum_put
,
1167 static const char *slave_vols
[] = {
1168 "Front Playback Volume",
1169 "Surround Playback Volume",
1170 "Center Playback Volume",
1171 "LFE Playback Volume",
1172 "Side Playback Volume",
1173 "Headphone Playback Volume",
1174 "Headphone Playback Volume",
1175 "Speaker Playback Volume",
1176 "External Speaker Playback Volume",
1177 "Speaker2 Playback Volume",
1181 static const char *slave_sws
[] = {
1182 "Front Playback Switch",
1183 "Surround Playback Switch",
1184 "Center Playback Switch",
1185 "LFE Playback Switch",
1186 "Side Playback Switch",
1187 "Headphone Playback Switch",
1188 "Headphone Playback Switch",
1189 "Speaker Playback Switch",
1190 "External Speaker Playback Switch",
1191 "Speaker2 Playback Switch",
1192 "IEC958 Playback Switch",
1196 static int stac92xx_build_controls(struct hda_codec
*codec
)
1198 struct sigmatel_spec
*spec
= codec
->spec
;
1202 err
= snd_hda_add_new_ctls(codec
, spec
->mixer
);
1206 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1207 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
1211 if (spec
->num_dmuxes
> 0) {
1212 stac_dmux_mixer
.count
= spec
->num_dmuxes
;
1213 err
= snd_ctl_add(codec
->bus
->card
,
1214 snd_ctl_new1(&stac_dmux_mixer
, codec
));
1218 if (spec
->num_smuxes
> 0) {
1219 stac_smux_mixer
.count
= spec
->num_smuxes
;
1220 err
= snd_ctl_add(codec
->bus
->card
,
1221 snd_ctl_new1(&stac_smux_mixer
, codec
));
1226 if (spec
->multiout
.dig_out_nid
) {
1227 err
= snd_hda_create_spdif_out_ctls(codec
, spec
->multiout
.dig_out_nid
);
1230 err
= snd_hda_create_spdif_share_sw(codec
,
1234 spec
->multiout
.share_spdif
= 1;
1236 if (spec
->dig_in_nid
) {
1237 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
1242 /* if we have no master control, let's create it */
1243 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
1244 unsigned int vmaster_tlv
[4];
1245 snd_hda_set_vmaster_tlv(codec
, spec
->multiout
.dac_nids
[0],
1246 HDA_OUTPUT
, vmaster_tlv
);
1247 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
1248 vmaster_tlv
, slave_vols
);
1252 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
1253 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
1262 static unsigned int ref9200_pin_configs
[8] = {
1263 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1264 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1268 STAC 9200 pin configs for
1273 static unsigned int dell9200_d21_pin_configs
[8] = {
1274 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1275 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1279 STAC 9200 pin configs for
1283 static unsigned int dell9200_d22_pin_configs
[8] = {
1284 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1285 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1289 STAC 9200 pin configs for
1290 102801C4 (Dell Dimension E310)
1297 static unsigned int dell9200_d23_pin_configs
[8] = {
1298 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1299 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1304 STAC 9200-32 pin configs for
1305 102801B5 (Dell Inspiron 630m)
1306 102801D8 (Dell Inspiron 640m)
1308 static unsigned int dell9200_m21_pin_configs
[8] = {
1309 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1310 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1314 STAC 9200-32 pin configs for
1315 102801C2 (Dell Latitude D620)
1317 102801CC (Dell Latitude D820)
1321 static unsigned int dell9200_m22_pin_configs
[8] = {
1322 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1323 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1327 STAC 9200-32 pin configs for
1328 102801CE (Dell XPS M1710)
1329 102801CF (Dell Precision M90)
1331 static unsigned int dell9200_m23_pin_configs
[8] = {
1332 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1333 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1337 STAC 9200-32 pin configs for
1340 102801CB (Dell Latitude 120L)
1343 static unsigned int dell9200_m24_pin_configs
[8] = {
1344 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1345 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1349 STAC 9200-32 pin configs for
1350 102801BD (Dell Inspiron E1505n)
1354 static unsigned int dell9200_m25_pin_configs
[8] = {
1355 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1356 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1360 STAC 9200-32 pin configs for
1361 102801F5 (Dell Inspiron 1501)
1364 static unsigned int dell9200_m26_pin_configs
[8] = {
1365 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1366 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1371 102801CD (Dell Inspiron E1705/9400)
1373 static unsigned int dell9200_m27_pin_configs
[8] = {
1374 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1375 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1378 static unsigned int oqo9200_pin_configs
[8] = {
1379 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1380 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1384 static unsigned int *stac9200_brd_tbl
[STAC_9200_MODELS
] = {
1385 [STAC_REF
] = ref9200_pin_configs
,
1386 [STAC_9200_OQO
] = oqo9200_pin_configs
,
1387 [STAC_9200_DELL_D21
] = dell9200_d21_pin_configs
,
1388 [STAC_9200_DELL_D22
] = dell9200_d22_pin_configs
,
1389 [STAC_9200_DELL_D23
] = dell9200_d23_pin_configs
,
1390 [STAC_9200_DELL_M21
] = dell9200_m21_pin_configs
,
1391 [STAC_9200_DELL_M22
] = dell9200_m22_pin_configs
,
1392 [STAC_9200_DELL_M23
] = dell9200_m23_pin_configs
,
1393 [STAC_9200_DELL_M24
] = dell9200_m24_pin_configs
,
1394 [STAC_9200_DELL_M25
] = dell9200_m25_pin_configs
,
1395 [STAC_9200_DELL_M26
] = dell9200_m26_pin_configs
,
1396 [STAC_9200_DELL_M27
] = dell9200_m27_pin_configs
,
1397 [STAC_9200_PANASONIC
] = ref9200_pin_configs
,
1400 static const char *stac9200_models
[STAC_9200_MODELS
] = {
1402 [STAC_9200_OQO
] = "oqo",
1403 [STAC_9200_DELL_D21
] = "dell-d21",
1404 [STAC_9200_DELL_D22
] = "dell-d22",
1405 [STAC_9200_DELL_D23
] = "dell-d23",
1406 [STAC_9200_DELL_M21
] = "dell-m21",
1407 [STAC_9200_DELL_M22
] = "dell-m22",
1408 [STAC_9200_DELL_M23
] = "dell-m23",
1409 [STAC_9200_DELL_M24
] = "dell-m24",
1410 [STAC_9200_DELL_M25
] = "dell-m25",
1411 [STAC_9200_DELL_M26
] = "dell-m26",
1412 [STAC_9200_DELL_M27
] = "dell-m27",
1413 [STAC_9200_GATEWAY
] = "gateway",
1414 [STAC_9200_PANASONIC
] = "panasonic",
1417 static struct snd_pci_quirk stac9200_cfg_tbl
[] = {
1418 /* SigmaTel reference board */
1419 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1420 "DFI LanParty", STAC_REF
),
1421 /* Dell laptops have BIOS problem */
1422 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01a8,
1423 "unknown Dell", STAC_9200_DELL_D21
),
1424 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01b5,
1425 "Dell Inspiron 630m", STAC_9200_DELL_M21
),
1426 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01bd,
1427 "Dell Inspiron E1505n", STAC_9200_DELL_M25
),
1428 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c0,
1429 "unknown Dell", STAC_9200_DELL_D22
),
1430 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c1,
1431 "unknown Dell", STAC_9200_DELL_D22
),
1432 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c2,
1433 "Dell Latitude D620", STAC_9200_DELL_M22
),
1434 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c5,
1435 "unknown Dell", STAC_9200_DELL_D23
),
1436 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c7,
1437 "unknown Dell", STAC_9200_DELL_D23
),
1438 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c8,
1439 "unknown Dell", STAC_9200_DELL_M22
),
1440 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c9,
1441 "unknown Dell", STAC_9200_DELL_M24
),
1442 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ca,
1443 "unknown Dell", STAC_9200_DELL_M24
),
1444 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cb,
1445 "Dell Latitude 120L", STAC_9200_DELL_M24
),
1446 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cc,
1447 "Dell Latitude D820", STAC_9200_DELL_M22
),
1448 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cd,
1449 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27
),
1450 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ce,
1451 "Dell XPS M1710", STAC_9200_DELL_M23
),
1452 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cf,
1453 "Dell Precision M90", STAC_9200_DELL_M23
),
1454 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d3,
1455 "unknown Dell", STAC_9200_DELL_M22
),
1456 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d4,
1457 "unknown Dell", STAC_9200_DELL_M22
),
1458 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d6,
1459 "unknown Dell", STAC_9200_DELL_M22
),
1460 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d8,
1461 "Dell Inspiron 640m", STAC_9200_DELL_M21
),
1462 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d9,
1463 "unknown Dell", STAC_9200_DELL_D23
),
1464 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01da,
1465 "unknown Dell", STAC_9200_DELL_D23
),
1466 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01de,
1467 "unknown Dell", STAC_9200_DELL_D21
),
1468 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01e3,
1469 "unknown Dell", STAC_9200_DELL_D23
),
1470 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01e8,
1471 "unknown Dell", STAC_9200_DELL_D21
),
1472 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ee,
1473 "unknown Dell", STAC_9200_DELL_M25
),
1474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ef,
1475 "unknown Dell", STAC_9200_DELL_M25
),
1476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f5,
1477 "Dell Inspiron 1501", STAC_9200_DELL_M26
),
1478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f6,
1479 "unknown Dell", STAC_9200_DELL_M26
),
1481 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC
),
1482 /* Gateway machines needs EAPD to be set on resume */
1483 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY
),
1484 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1486 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1489 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO
),
1493 static unsigned int ref925x_pin_configs
[8] = {
1494 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1495 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1498 static unsigned int stac925x_MA6_pin_configs
[8] = {
1499 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1500 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1503 static unsigned int stac925x_PA6_pin_configs
[8] = {
1504 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1505 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1508 static unsigned int stac925xM2_2_pin_configs
[8] = {
1509 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1510 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
1513 static unsigned int *stac925x_brd_tbl
[STAC_925x_MODELS
] = {
1514 [STAC_REF
] = ref925x_pin_configs
,
1515 [STAC_M2_2
] = stac925xM2_2_pin_configs
,
1516 [STAC_MA6
] = stac925x_MA6_pin_configs
,
1517 [STAC_PA6
] = stac925x_PA6_pin_configs
,
1520 static const char *stac925x_models
[STAC_925x_MODELS
] = {
1522 [STAC_M2_2
] = "m2-2",
1527 static struct snd_pci_quirk stac925x_cfg_tbl
[] = {
1528 /* SigmaTel reference board */
1529 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668, "DFI LanParty", STAC_REF
),
1530 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF
),
1531 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF
),
1532 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF
),
1533 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6
),
1534 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6
),
1535 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2
),
1539 static unsigned int ref92hd73xx_pin_configs
[13] = {
1540 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1541 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1542 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1546 static unsigned int dell_m6_pin_configs
[13] = {
1547 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1548 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1549 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1553 static unsigned int *stac92hd73xx_brd_tbl
[STAC_92HD73XX_MODELS
] = {
1554 [STAC_92HD73XX_REF
] = ref92hd73xx_pin_configs
,
1555 [STAC_DELL_M6
] = dell_m6_pin_configs
,
1558 static const char *stac92hd73xx_models
[STAC_92HD73XX_MODELS
] = {
1559 [STAC_92HD73XX_REF
] = "ref",
1560 [STAC_DELL_M6
] = "dell-m6",
1563 static struct snd_pci_quirk stac92hd73xx_cfg_tbl
[] = {
1564 /* SigmaTel reference board */
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1566 "DFI LanParty", STAC_92HD73XX_REF
),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0254,
1568 "unknown Dell", STAC_DELL_M6
),
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0255,
1570 "unknown Dell", STAC_DELL_M6
),
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0256,
1572 "unknown Dell", STAC_DELL_M6
),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0257,
1574 "unknown Dell", STAC_DELL_M6
),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x025e,
1576 "unknown Dell", STAC_DELL_M6
),
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x025f,
1578 "unknown Dell", STAC_DELL_M6
),
1579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0271,
1580 "unknown Dell", STAC_DELL_M6
),
1584 static unsigned int ref92hd83xxx_pin_configs
[14] = {
1585 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1586 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1587 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1588 0x01451160, 0x98560170,
1591 static unsigned int *stac92hd83xxx_brd_tbl
[STAC_92HD83XXX_MODELS
] = {
1592 [STAC_92HD83XXX_REF
] = ref92hd83xxx_pin_configs
,
1595 static const char *stac92hd83xxx_models
[STAC_92HD83XXX_MODELS
] = {
1596 [STAC_92HD83XXX_REF
] = "ref",
1599 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl
[] = {
1600 /* SigmaTel reference board */
1601 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1602 "DFI LanParty", STAC_92HD71BXX_REF
),
1605 static unsigned int ref92hd71bxx_pin_configs
[11] = {
1606 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1607 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
1608 0x90a000f0, 0x01452050, 0x01452050,
1611 static unsigned int dell_m4_1_pin_configs
[11] = {
1612 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1613 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1614 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
1617 static unsigned int dell_m4_2_pin_configs
[11] = {
1618 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1619 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1620 0x40f000f0, 0x044413b0, 0x044413b0,
1623 static unsigned int *stac92hd71bxx_brd_tbl
[STAC_92HD71BXX_MODELS
] = {
1624 [STAC_92HD71BXX_REF
] = ref92hd71bxx_pin_configs
,
1625 [STAC_DELL_M4_1
] = dell_m4_1_pin_configs
,
1626 [STAC_DELL_M4_2
] = dell_m4_2_pin_configs
,
1627 [STAC_HP_M4
] = NULL
,
1630 static const char *stac92hd71bxx_models
[STAC_92HD71BXX_MODELS
] = {
1631 [STAC_92HD71BXX_REF
] = "ref",
1632 [STAC_DELL_M4_1
] = "dell-m4-1",
1633 [STAC_DELL_M4_2
] = "dell-m4-2",
1634 [STAC_HP_M4
] = "hp-m4",
1637 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl
[] = {
1638 /* SigmaTel reference board */
1639 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1640 "DFI LanParty", STAC_92HD71BXX_REF
),
1641 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0233,
1642 "unknown Dell", STAC_DELL_M4_1
),
1643 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0234,
1644 "unknown Dell", STAC_DELL_M4_1
),
1645 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0250,
1646 "unknown Dell", STAC_DELL_M4_1
),
1647 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x024f,
1648 "unknown Dell", STAC_DELL_M4_1
),
1649 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x024d,
1650 "unknown Dell", STAC_DELL_M4_1
),
1651 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0251,
1652 "unknown Dell", STAC_DELL_M4_1
),
1653 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0277,
1654 "unknown Dell", STAC_DELL_M4_1
),
1655 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0263,
1656 "unknown Dell", STAC_DELL_M4_2
),
1657 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0265,
1658 "unknown Dell", STAC_DELL_M4_2
),
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0262,
1660 "unknown Dell", STAC_DELL_M4_2
),
1661 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0264,
1662 "unknown Dell", STAC_DELL_M4_2
),
1666 static unsigned int ref922x_pin_configs
[10] = {
1667 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1668 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1669 0x40000100, 0x40000100,
1673 STAC 922X pin configs for
1680 static unsigned int dell_922x_d81_pin_configs
[10] = {
1681 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1682 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1683 0x01813122, 0x400001f2,
1687 STAC 922X pin configs for
1691 static unsigned int dell_922x_d82_pin_configs
[10] = {
1692 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1693 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1694 0x01813122, 0x400001f1,
1698 STAC 922X pin configs for
1701 static unsigned int dell_922x_m81_pin_configs
[10] = {
1702 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1703 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1704 0x40C003f1, 0x405003f0,
1708 STAC 9221 A1 pin configs for
1709 102801D7 (Dell XPS M1210)
1711 static unsigned int dell_922x_m82_pin_configs
[10] = {
1712 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1713 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1714 0x508003f3, 0x405003f4,
1717 static unsigned int d945gtp3_pin_configs
[10] = {
1718 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1719 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1720 0x02a19120, 0x40000100,
1723 static unsigned int d945gtp5_pin_configs
[10] = {
1724 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1725 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1726 0x02a19320, 0x40000100,
1729 static unsigned int intel_mac_v1_pin_configs
[10] = {
1730 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1731 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1732 0x400000fc, 0x400000fb,
1735 static unsigned int intel_mac_v2_pin_configs
[10] = {
1736 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1737 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1738 0x400000fc, 0x400000fb,
1741 static unsigned int intel_mac_v3_pin_configs
[10] = {
1742 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1743 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1744 0x400000fc, 0x400000fb,
1747 static unsigned int intel_mac_v4_pin_configs
[10] = {
1748 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1749 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1750 0x400000fc, 0x400000fb,
1753 static unsigned int intel_mac_v5_pin_configs
[10] = {
1754 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1755 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1756 0x400000fc, 0x400000fb,
1759 static unsigned int ecs202_pin_configs
[10] = {
1760 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1761 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1762 0x9037012e, 0x40e000f2,
1765 static unsigned int *stac922x_brd_tbl
[STAC_922X_MODELS
] = {
1766 [STAC_D945_REF
] = ref922x_pin_configs
,
1767 [STAC_D945GTP3
] = d945gtp3_pin_configs
,
1768 [STAC_D945GTP5
] = d945gtp5_pin_configs
,
1769 [STAC_INTEL_MAC_V1
] = intel_mac_v1_pin_configs
,
1770 [STAC_INTEL_MAC_V2
] = intel_mac_v2_pin_configs
,
1771 [STAC_INTEL_MAC_V3
] = intel_mac_v3_pin_configs
,
1772 [STAC_INTEL_MAC_V4
] = intel_mac_v4_pin_configs
,
1773 [STAC_INTEL_MAC_V5
] = intel_mac_v5_pin_configs
,
1774 [STAC_INTEL_MAC_AUTO
] = intel_mac_v3_pin_configs
,
1775 /* for backward compatibility */
1776 [STAC_MACMINI
] = intel_mac_v3_pin_configs
,
1777 [STAC_MACBOOK
] = intel_mac_v5_pin_configs
,
1778 [STAC_MACBOOK_PRO_V1
] = intel_mac_v3_pin_configs
,
1779 [STAC_MACBOOK_PRO_V2
] = intel_mac_v3_pin_configs
,
1780 [STAC_IMAC_INTEL
] = intel_mac_v2_pin_configs
,
1781 [STAC_IMAC_INTEL_20
] = intel_mac_v3_pin_configs
,
1782 [STAC_ECS_202
] = ecs202_pin_configs
,
1783 [STAC_922X_DELL_D81
] = dell_922x_d81_pin_configs
,
1784 [STAC_922X_DELL_D82
] = dell_922x_d82_pin_configs
,
1785 [STAC_922X_DELL_M81
] = dell_922x_m81_pin_configs
,
1786 [STAC_922X_DELL_M82
] = dell_922x_m82_pin_configs
,
1789 static const char *stac922x_models
[STAC_922X_MODELS
] = {
1790 [STAC_D945_REF
] = "ref",
1791 [STAC_D945GTP5
] = "5stack",
1792 [STAC_D945GTP3
] = "3stack",
1793 [STAC_INTEL_MAC_V1
] = "intel-mac-v1",
1794 [STAC_INTEL_MAC_V2
] = "intel-mac-v2",
1795 [STAC_INTEL_MAC_V3
] = "intel-mac-v3",
1796 [STAC_INTEL_MAC_V4
] = "intel-mac-v4",
1797 [STAC_INTEL_MAC_V5
] = "intel-mac-v5",
1798 [STAC_INTEL_MAC_AUTO
] = "intel-mac-auto",
1799 /* for backward compatibility */
1800 [STAC_MACMINI
] = "macmini",
1801 [STAC_MACBOOK
] = "macbook",
1802 [STAC_MACBOOK_PRO_V1
] = "macbook-pro-v1",
1803 [STAC_MACBOOK_PRO_V2
] = "macbook-pro",
1804 [STAC_IMAC_INTEL
] = "imac-intel",
1805 [STAC_IMAC_INTEL_20
] = "imac-intel-20",
1806 [STAC_ECS_202
] = "ecs202",
1807 [STAC_922X_DELL_D81
] = "dell-d81",
1808 [STAC_922X_DELL_D82
] = "dell-d82",
1809 [STAC_922X_DELL_M81
] = "dell-m81",
1810 [STAC_922X_DELL_M82
] = "dell-m82",
1813 static struct snd_pci_quirk stac922x_cfg_tbl
[] = {
1814 /* SigmaTel reference board */
1815 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1816 "DFI LanParty", STAC_D945_REF
),
1817 /* Intel 945G based systems */
1818 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0101,
1819 "Intel D945G", STAC_D945GTP3
),
1820 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0202,
1821 "Intel D945G", STAC_D945GTP3
),
1822 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0606,
1823 "Intel D945G", STAC_D945GTP3
),
1824 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0601,
1825 "Intel D945G", STAC_D945GTP3
),
1826 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0111,
1827 "Intel D945G", STAC_D945GTP3
),
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1115,
1829 "Intel D945G", STAC_D945GTP3
),
1830 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1116,
1831 "Intel D945G", STAC_D945GTP3
),
1832 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1117,
1833 "Intel D945G", STAC_D945GTP3
),
1834 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1118,
1835 "Intel D945G", STAC_D945GTP3
),
1836 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1119,
1837 "Intel D945G", STAC_D945GTP3
),
1838 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x8826,
1839 "Intel D945G", STAC_D945GTP3
),
1840 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5049,
1841 "Intel D945G", STAC_D945GTP3
),
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5055,
1843 "Intel D945G", STAC_D945GTP3
),
1844 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5048,
1845 "Intel D945G", STAC_D945GTP3
),
1846 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0110,
1847 "Intel D945G", STAC_D945GTP3
),
1848 /* Intel D945G 5-stack systems */
1849 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0404,
1850 "Intel D945G", STAC_D945GTP5
),
1851 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0303,
1852 "Intel D945G", STAC_D945GTP5
),
1853 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0013,
1854 "Intel D945G", STAC_D945GTP5
),
1855 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0417,
1856 "Intel D945G", STAC_D945GTP5
),
1857 /* Intel 945P based systems */
1858 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0b0b,
1859 "Intel D945P", STAC_D945GTP3
),
1860 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0112,
1861 "Intel D945P", STAC_D945GTP3
),
1862 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0d0d,
1863 "Intel D945P", STAC_D945GTP3
),
1864 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0909,
1865 "Intel D945P", STAC_D945GTP3
),
1866 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0505,
1867 "Intel D945P", STAC_D945GTP3
),
1868 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0707,
1869 "Intel D945P", STAC_D945GTP5
),
1871 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1872 SND_PCI_QUIRK(0x8384, 0x7680,
1873 "Mac", STAC_INTEL_MAC_AUTO
),
1875 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01a7,
1876 "unknown Dell", STAC_922X_DELL_D81
),
1877 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01a9,
1878 "unknown Dell", STAC_922X_DELL_D81
),
1879 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ab,
1880 "unknown Dell", STAC_922X_DELL_D81
),
1881 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ac,
1882 "unknown Dell", STAC_922X_DELL_D82
),
1883 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01bf,
1884 "unknown Dell", STAC_922X_DELL_M81
),
1885 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d0,
1886 "unknown Dell", STAC_922X_DELL_D82
),
1887 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d1,
1888 "unknown Dell", STAC_922X_DELL_D81
),
1889 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d2,
1890 "unknown Dell", STAC_922X_DELL_D81
),
1891 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d7,
1892 "Dell XPS M1210", STAC_922X_DELL_M82
),
1893 /* ECS/PC Chips boards */
1894 SND_PCI_QUIRK(0x1019, 0x2144,
1895 "ECS/PC chips", STAC_ECS_202
),
1896 SND_PCI_QUIRK(0x1019, 0x2608,
1897 "ECS/PC chips", STAC_ECS_202
),
1898 SND_PCI_QUIRK(0x1019, 0x2633,
1899 "ECS/PC chips P17G/1333", STAC_ECS_202
),
1900 SND_PCI_QUIRK(0x1019, 0x2811,
1901 "ECS/PC chips", STAC_ECS_202
),
1902 SND_PCI_QUIRK(0x1019, 0x2812,
1903 "ECS/PC chips", STAC_ECS_202
),
1904 SND_PCI_QUIRK(0x1019, 0x2813,
1905 "ECS/PC chips", STAC_ECS_202
),
1906 SND_PCI_QUIRK(0x1019, 0x2814,
1907 "ECS/PC chips", STAC_ECS_202
),
1908 SND_PCI_QUIRK(0x1019, 0x2815,
1909 "ECS/PC chips", STAC_ECS_202
),
1910 SND_PCI_QUIRK(0x1019, 0x2816,
1911 "ECS/PC chips", STAC_ECS_202
),
1912 SND_PCI_QUIRK(0x1019, 0x2817,
1913 "ECS/PC chips", STAC_ECS_202
),
1914 SND_PCI_QUIRK(0x1019, 0x2818,
1915 "ECS/PC chips", STAC_ECS_202
),
1916 SND_PCI_QUIRK(0x1019, 0x2819,
1917 "ECS/PC chips", STAC_ECS_202
),
1918 SND_PCI_QUIRK(0x1019, 0x2820,
1919 "ECS/PC chips", STAC_ECS_202
),
1923 static unsigned int ref927x_pin_configs
[14] = {
1924 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1925 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1926 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1927 0x01c42190, 0x40000100,
1930 static unsigned int d965_3st_pin_configs
[14] = {
1931 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1932 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1933 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1934 0x40000100, 0x40000100
1937 static unsigned int d965_5st_pin_configs
[14] = {
1938 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1939 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1940 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1941 0x40000100, 0x40000100
1944 static unsigned int dell_3st_pin_configs
[14] = {
1945 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1946 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1947 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
1948 0x40c003fc, 0x40000100
1951 static unsigned int *stac927x_brd_tbl
[STAC_927X_MODELS
] = {
1952 [STAC_D965_REF
] = ref927x_pin_configs
,
1953 [STAC_D965_3ST
] = d965_3st_pin_configs
,
1954 [STAC_D965_5ST
] = d965_5st_pin_configs
,
1955 [STAC_DELL_3ST
] = dell_3st_pin_configs
,
1956 [STAC_DELL_BIOS
] = NULL
,
1959 static const char *stac927x_models
[STAC_927X_MODELS
] = {
1960 [STAC_D965_REF
] = "ref",
1961 [STAC_D965_3ST
] = "3stack",
1962 [STAC_D965_5ST
] = "5stack",
1963 [STAC_DELL_3ST
] = "dell-3stack",
1964 [STAC_DELL_BIOS
] = "dell-bios",
1967 static struct snd_pci_quirk stac927x_cfg_tbl
[] = {
1968 /* SigmaTel reference board */
1969 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1970 "DFI LanParty", STAC_D965_REF
),
1971 /* Intel 946 based systems */
1972 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x3d01, "Intel D946", STAC_D965_3ST
),
1973 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0xa301, "Intel D946", STAC_D965_3ST
),
1974 /* 965 based 3 stack systems */
1975 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2116, "Intel D965", STAC_D965_3ST
),
1976 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2115, "Intel D965", STAC_D965_3ST
),
1977 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2114, "Intel D965", STAC_D965_3ST
),
1978 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2113, "Intel D965", STAC_D965_3ST
),
1979 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2112, "Intel D965", STAC_D965_3ST
),
1980 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2111, "Intel D965", STAC_D965_3ST
),
1981 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2110, "Intel D965", STAC_D965_3ST
),
1982 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2009, "Intel D965", STAC_D965_3ST
),
1983 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2008, "Intel D965", STAC_D965_3ST
),
1984 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2007, "Intel D965", STAC_D965_3ST
),
1985 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2006, "Intel D965", STAC_D965_3ST
),
1986 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2005, "Intel D965", STAC_D965_3ST
),
1987 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2004, "Intel D965", STAC_D965_3ST
),
1988 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2003, "Intel D965", STAC_D965_3ST
),
1989 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2002, "Intel D965", STAC_D965_3ST
),
1990 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2001, "Intel D965", STAC_D965_3ST
),
1991 /* Dell 3 stack systems */
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST
),
1993 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST
),
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ed, "Dell ", STAC_DELL_3ST
),
1995 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f4, "Dell ", STAC_DELL_3ST
),
1996 /* Dell 3 stack systems with verb table in BIOS */
1997 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS
),
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS
),
1999 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x022e, "Dell ", STAC_DELL_BIOS
),
2000 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST
),
2001 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0242, "Dell ", STAC_DELL_BIOS
),
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0243, "Dell ", STAC_DELL_BIOS
),
2003 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02ff, "Dell ", STAC_DELL_BIOS
),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS
),
2005 /* 965 based 5 stack systems */
2006 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2301, "Intel D965", STAC_D965_5ST
),
2007 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2302, "Intel D965", STAC_D965_5ST
),
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2303, "Intel D965", STAC_D965_5ST
),
2009 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2304, "Intel D965", STAC_D965_5ST
),
2010 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2305, "Intel D965", STAC_D965_5ST
),
2011 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2501, "Intel D965", STAC_D965_5ST
),
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2502, "Intel D965", STAC_D965_5ST
),
2013 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2503, "Intel D965", STAC_D965_5ST
),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2504, "Intel D965", STAC_D965_5ST
),
2018 static unsigned int ref9205_pin_configs
[12] = {
2019 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2020 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2021 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2025 STAC 9205 pin configs for
2032 10280228 (Dell Vostro 1500)
2034 static unsigned int dell_9205_m42_pin_configs
[12] = {
2035 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2036 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2037 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2041 STAC 9205 pin configs for
2045 102801FF (Dell Precision M4300)
2050 static unsigned int dell_9205_m43_pin_configs
[12] = {
2051 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2052 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2053 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2056 static unsigned int dell_9205_m44_pin_configs
[12] = {
2057 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2058 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2059 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2062 static unsigned int *stac9205_brd_tbl
[STAC_9205_MODELS
] = {
2063 [STAC_9205_REF
] = ref9205_pin_configs
,
2064 [STAC_9205_DELL_M42
] = dell_9205_m42_pin_configs
,
2065 [STAC_9205_DELL_M43
] = dell_9205_m43_pin_configs
,
2066 [STAC_9205_DELL_M44
] = dell_9205_m44_pin_configs
,
2069 static const char *stac9205_models
[STAC_9205_MODELS
] = {
2070 [STAC_9205_REF
] = "ref",
2071 [STAC_9205_DELL_M42
] = "dell-m42",
2072 [STAC_9205_DELL_M43
] = "dell-m43",
2073 [STAC_9205_DELL_M44
] = "dell-m44",
2076 static struct snd_pci_quirk stac9205_cfg_tbl
[] = {
2077 /* SigmaTel reference board */
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
2079 "DFI LanParty", STAC_9205_REF
),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f1,
2081 "unknown Dell", STAC_9205_DELL_M42
),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f2,
2083 "unknown Dell", STAC_9205_DELL_M42
),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f8,
2085 "Dell Precision", STAC_9205_DELL_M43
),
2086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f9,
2087 "Dell Precision", STAC_9205_DELL_M43
),
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fa,
2089 "Dell Precision", STAC_9205_DELL_M43
),
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fc,
2091 "unknown Dell", STAC_9205_DELL_M42
),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fd,
2093 "unknown Dell", STAC_9205_DELL_M42
),
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fe,
2095 "Dell Precision", STAC_9205_DELL_M43
),
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ff,
2097 "Dell Precision M4300", STAC_9205_DELL_M43
),
2098 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0204,
2099 "unknown Dell", STAC_9205_DELL_M42
),
2100 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0206,
2101 "Dell Precision", STAC_9205_DELL_M43
),
2102 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x021b,
2103 "Dell Precision", STAC_9205_DELL_M43
),
2104 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x021c,
2105 "Dell Precision", STAC_9205_DELL_M43
),
2106 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x021f,
2107 "Dell Inspiron", STAC_9205_DELL_M44
),
2108 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0228,
2109 "Dell Vostro 1500", STAC_9205_DELL_M42
),
2113 static int stac92xx_save_bios_config_regs(struct hda_codec
*codec
)
2116 struct sigmatel_spec
*spec
= codec
->spec
;
2118 if (! spec
->bios_pin_configs
) {
2119 spec
->bios_pin_configs
= kcalloc(spec
->num_pins
,
2120 sizeof(*spec
->bios_pin_configs
), GFP_KERNEL
);
2121 if (! spec
->bios_pin_configs
)
2125 for (i
= 0; i
< spec
->num_pins
; i
++) {
2126 hda_nid_t nid
= spec
->pin_nids
[i
];
2127 unsigned int pin_cfg
;
2129 pin_cfg
= snd_hda_codec_read(codec
, nid
, 0,
2130 AC_VERB_GET_CONFIG_DEFAULT
, 0x00);
2131 snd_printdd(KERN_INFO
"hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2133 spec
->bios_pin_configs
[i
] = pin_cfg
;
2139 static void stac92xx_set_config_reg(struct hda_codec
*codec
,
2140 hda_nid_t pin_nid
, unsigned int pin_config
)
2143 snd_hda_codec_write(codec
, pin_nid
, 0,
2144 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0
,
2145 pin_config
& 0x000000ff);
2146 snd_hda_codec_write(codec
, pin_nid
, 0,
2147 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1
,
2148 (pin_config
& 0x0000ff00) >> 8);
2149 snd_hda_codec_write(codec
, pin_nid
, 0,
2150 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2
,
2151 (pin_config
& 0x00ff0000) >> 16);
2152 snd_hda_codec_write(codec
, pin_nid
, 0,
2153 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3
,
2155 i
= snd_hda_codec_read(codec
, pin_nid
, 0,
2156 AC_VERB_GET_CONFIG_DEFAULT
,
2158 snd_printdd(KERN_INFO
"hda_codec: pin nid %2.2x pin config %8.8x\n",
2162 static void stac92xx_set_config_regs(struct hda_codec
*codec
)
2165 struct sigmatel_spec
*spec
= codec
->spec
;
2167 if (!spec
->pin_configs
)
2170 for (i
= 0; i
< spec
->num_pins
; i
++)
2171 stac92xx_set_config_reg(codec
, spec
->pin_nids
[i
],
2172 spec
->pin_configs
[i
]);
2176 * Analog playback callbacks
2178 static int stac92xx_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2179 struct hda_codec
*codec
,
2180 struct snd_pcm_substream
*substream
)
2182 struct sigmatel_spec
*spec
= codec
->spec
;
2183 if (spec
->stream_delay
)
2184 msleep(spec
->stream_delay
);
2185 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
2189 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2190 struct hda_codec
*codec
,
2191 unsigned int stream_tag
,
2192 unsigned int format
,
2193 struct snd_pcm_substream
*substream
)
2195 struct sigmatel_spec
*spec
= codec
->spec
;
2196 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
, stream_tag
, format
, substream
);
2199 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2200 struct hda_codec
*codec
,
2201 struct snd_pcm_substream
*substream
)
2203 struct sigmatel_spec
*spec
= codec
->spec
;
2204 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
2208 * Digital playback callbacks
2210 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2211 struct hda_codec
*codec
,
2212 struct snd_pcm_substream
*substream
)
2214 struct sigmatel_spec
*spec
= codec
->spec
;
2215 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
2218 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
2219 struct hda_codec
*codec
,
2220 struct snd_pcm_substream
*substream
)
2222 struct sigmatel_spec
*spec
= codec
->spec
;
2223 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
2226 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2227 struct hda_codec
*codec
,
2228 unsigned int stream_tag
,
2229 unsigned int format
,
2230 struct snd_pcm_substream
*substream
)
2232 struct sigmatel_spec
*spec
= codec
->spec
;
2233 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
2234 stream_tag
, format
, substream
);
2239 * Analog capture callbacks
2241 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2242 struct hda_codec
*codec
,
2243 unsigned int stream_tag
,
2244 unsigned int format
,
2245 struct snd_pcm_substream
*substream
)
2247 struct sigmatel_spec
*spec
= codec
->spec
;
2248 hda_nid_t nid
= spec
->adc_nids
[substream
->number
];
2250 if (spec
->powerdown_adcs
) {
2252 snd_hda_codec_write_cache(codec
, nid
, 0,
2253 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
2255 snd_hda_codec_setup_stream(codec
, nid
, stream_tag
, 0, format
);
2259 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2260 struct hda_codec
*codec
,
2261 struct snd_pcm_substream
*substream
)
2263 struct sigmatel_spec
*spec
= codec
->spec
;
2264 hda_nid_t nid
= spec
->adc_nids
[substream
->number
];
2266 snd_hda_codec_cleanup_stream(codec
, nid
);
2267 if (spec
->powerdown_adcs
)
2268 snd_hda_codec_write_cache(codec
, nid
, 0,
2269 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
2273 static struct hda_pcm_stream stac92xx_pcm_digital_playback
= {
2277 /* NID is set in stac92xx_build_pcms */
2279 .open
= stac92xx_dig_playback_pcm_open
,
2280 .close
= stac92xx_dig_playback_pcm_close
,
2281 .prepare
= stac92xx_dig_playback_pcm_prepare
2285 static struct hda_pcm_stream stac92xx_pcm_digital_capture
= {
2289 /* NID is set in stac92xx_build_pcms */
2292 static struct hda_pcm_stream stac92xx_pcm_analog_playback
= {
2296 .nid
= 0x02, /* NID to query formats and rates */
2298 .open
= stac92xx_playback_pcm_open
,
2299 .prepare
= stac92xx_playback_pcm_prepare
,
2300 .cleanup
= stac92xx_playback_pcm_cleanup
2304 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback
= {
2308 .nid
= 0x06, /* NID to query formats and rates */
2310 .open
= stac92xx_playback_pcm_open
,
2311 .prepare
= stac92xx_playback_pcm_prepare
,
2312 .cleanup
= stac92xx_playback_pcm_cleanup
2316 static struct hda_pcm_stream stac92xx_pcm_analog_capture
= {
2319 /* NID + .substreams is set in stac92xx_build_pcms */
2321 .prepare
= stac92xx_capture_pcm_prepare
,
2322 .cleanup
= stac92xx_capture_pcm_cleanup
2326 static int stac92xx_build_pcms(struct hda_codec
*codec
)
2328 struct sigmatel_spec
*spec
= codec
->spec
;
2329 struct hda_pcm
*info
= spec
->pcm_rec
;
2331 codec
->num_pcms
= 1;
2332 codec
->pcm_info
= info
;
2334 info
->name
= "STAC92xx Analog";
2335 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_analog_playback
;
2336 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = stac92xx_pcm_analog_capture
;
2337 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
2338 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adcs
;
2340 if (spec
->alt_switch
) {
2343 info
->name
= "STAC92xx Analog Alt";
2344 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_analog_alt_playback
;
2347 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
2350 info
->name
= "STAC92xx Digital";
2351 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
2352 if (spec
->multiout
.dig_out_nid
) {
2353 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_digital_playback
;
2354 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
2356 if (spec
->dig_in_nid
) {
2357 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = stac92xx_pcm_digital_capture
;
2358 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
2365 static unsigned int stac92xx_get_vref(struct hda_codec
*codec
, hda_nid_t nid
)
2367 unsigned int pincap
= snd_hda_param_read(codec
, nid
,
2369 pincap
= (pincap
& AC_PINCAP_VREF
) >> AC_PINCAP_VREF_SHIFT
;
2370 if (pincap
& AC_PINCAP_VREF_100
)
2371 return AC_PINCTL_VREF_100
;
2372 if (pincap
& AC_PINCAP_VREF_80
)
2373 return AC_PINCTL_VREF_80
;
2374 if (pincap
& AC_PINCAP_VREF_50
)
2375 return AC_PINCTL_VREF_50
;
2376 if (pincap
& AC_PINCAP_VREF_GRD
)
2377 return AC_PINCTL_VREF_GRD
;
2381 static void stac92xx_auto_set_pinctl(struct hda_codec
*codec
, hda_nid_t nid
, int pin_type
)
2384 snd_hda_codec_write_cache(codec
, nid
, 0,
2385 AC_VERB_SET_PIN_WIDGET_CONTROL
, pin_type
);
2388 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2390 static int stac92xx_hp_switch_get(struct snd_kcontrol
*kcontrol
,
2391 struct snd_ctl_elem_value
*ucontrol
)
2393 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2394 struct sigmatel_spec
*spec
= codec
->spec
;
2396 ucontrol
->value
.integer
.value
[0] = spec
->hp_switch
;
2400 static int stac92xx_hp_switch_put(struct snd_kcontrol
*kcontrol
,
2401 struct snd_ctl_elem_value
*ucontrol
)
2403 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2404 struct sigmatel_spec
*spec
= codec
->spec
;
2406 spec
->hp_switch
= ucontrol
->value
.integer
.value
[0];
2408 /* check to be sure that the ports are upto date with
2411 codec
->patch_ops
.unsol_event(codec
, STAC_HP_EVENT
<< 26);
2416 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2418 static int stac92xx_io_switch_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2420 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2421 struct sigmatel_spec
*spec
= codec
->spec
;
2422 int io_idx
= kcontrol
-> private_value
& 0xff;
2424 ucontrol
->value
.integer
.value
[0] = spec
->io_switch
[io_idx
];
2428 static int stac92xx_io_switch_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2430 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2431 struct sigmatel_spec
*spec
= codec
->spec
;
2432 hda_nid_t nid
= kcontrol
->private_value
>> 8;
2433 int io_idx
= kcontrol
-> private_value
& 0xff;
2434 unsigned short val
= !!ucontrol
->value
.integer
.value
[0];
2436 spec
->io_switch
[io_idx
] = val
;
2439 stac92xx_auto_set_pinctl(codec
, nid
, AC_PINCTL_OUT_EN
);
2441 unsigned int pinctl
= AC_PINCTL_IN_EN
;
2442 if (io_idx
) /* set VREF for mic */
2443 pinctl
|= stac92xx_get_vref(codec
, nid
);
2444 stac92xx_auto_set_pinctl(codec
, nid
, pinctl
);
2447 /* check the auto-mute again: we need to mute/unmute the speaker
2448 * appropriately according to the pin direction
2450 if (spec
->hp_detect
)
2451 codec
->patch_ops
.unsol_event(codec
, STAC_HP_EVENT
<< 26);
2456 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2458 static int stac92xx_clfe_switch_get(struct snd_kcontrol
*kcontrol
,
2459 struct snd_ctl_elem_value
*ucontrol
)
2461 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2462 struct sigmatel_spec
*spec
= codec
->spec
;
2464 ucontrol
->value
.integer
.value
[0] = spec
->clfe_swap
;
2468 static int stac92xx_clfe_switch_put(struct snd_kcontrol
*kcontrol
,
2469 struct snd_ctl_elem_value
*ucontrol
)
2471 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2472 struct sigmatel_spec
*spec
= codec
->spec
;
2473 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
2474 unsigned int val
= !!ucontrol
->value
.integer
.value
[0];
2476 if (spec
->clfe_swap
== val
)
2479 spec
->clfe_swap
= val
;
2481 snd_hda_codec_write_cache(codec
, nid
, 0, AC_VERB_SET_EAPD_BTLENABLE
,
2482 spec
->clfe_swap
? 0x4 : 0x0);
2487 #define STAC_CODEC_HP_SWITCH(xname) \
2488 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2491 .info = stac92xx_hp_switch_info, \
2492 .get = stac92xx_hp_switch_get, \
2493 .put = stac92xx_hp_switch_put, \
2496 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2497 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2500 .info = stac92xx_io_switch_info, \
2501 .get = stac92xx_io_switch_get, \
2502 .put = stac92xx_io_switch_put, \
2503 .private_value = xpval, \
2506 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2507 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2510 .info = stac92xx_clfe_switch_info, \
2511 .get = stac92xx_clfe_switch_get, \
2512 .put = stac92xx_clfe_switch_put, \
2513 .private_value = xpval, \
2517 STAC_CTL_WIDGET_VOL
,
2518 STAC_CTL_WIDGET_MUTE
,
2519 STAC_CTL_WIDGET_MONO_MUX
,
2520 STAC_CTL_WIDGET_AMP_MUX
,
2521 STAC_CTL_WIDGET_AMP_VOL
,
2522 STAC_CTL_WIDGET_HP_SWITCH
,
2523 STAC_CTL_WIDGET_IO_SWITCH
,
2524 STAC_CTL_WIDGET_CLFE_SWITCH
2527 static struct snd_kcontrol_new stac92xx_control_templates
[] = {
2528 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2529 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2532 STAC_AMP_VOL(NULL
, 0, 0, 0, 0),
2533 STAC_CODEC_HP_SWITCH(NULL
),
2534 STAC_CODEC_IO_SWITCH(NULL
, 0),
2535 STAC_CODEC_CLFE_SWITCH(NULL
, 0),
2538 /* add dynamic controls */
2539 static int stac92xx_add_control_idx(struct sigmatel_spec
*spec
, int type
,
2540 int idx
, const char *name
, unsigned long val
)
2542 struct snd_kcontrol_new
*knew
;
2544 if (spec
->num_kctl_used
>= spec
->num_kctl_alloc
) {
2545 int num
= spec
->num_kctl_alloc
+ NUM_CONTROL_ALLOC
;
2547 knew
= kcalloc(num
+ 1, sizeof(*knew
), GFP_KERNEL
); /* array + terminator */
2550 if (spec
->kctl_alloc
) {
2551 memcpy(knew
, spec
->kctl_alloc
, sizeof(*knew
) * spec
->num_kctl_alloc
);
2552 kfree(spec
->kctl_alloc
);
2554 spec
->kctl_alloc
= knew
;
2555 spec
->num_kctl_alloc
= num
;
2558 knew
= &spec
->kctl_alloc
[spec
->num_kctl_used
];
2559 *knew
= stac92xx_control_templates
[type
];
2561 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2564 knew
->private_value
= val
;
2565 spec
->num_kctl_used
++;
2570 /* add dynamic controls */
2571 static int stac92xx_add_control(struct sigmatel_spec
*spec
, int type
,
2572 const char *name
, unsigned long val
)
2574 return stac92xx_add_control_idx(spec
, type
, 0, name
, val
);
2577 /* flag inputs as additional dynamic lineouts */
2578 static int stac92xx_add_dyn_out_pins(struct hda_codec
*codec
, struct auto_pin_cfg
*cfg
)
2580 struct sigmatel_spec
*spec
= codec
->spec
;
2581 unsigned int wcaps
, wtype
;
2582 int i
, num_dacs
= 0;
2584 /* use the wcaps cache to count all DACs available for line-outs */
2585 for (i
= 0; i
< codec
->num_nodes
; i
++) {
2586 wcaps
= codec
->wcaps
[i
];
2587 wtype
= (wcaps
& AC_WCAP_TYPE
) >> AC_WCAP_TYPE_SHIFT
;
2589 if (wtype
== AC_WID_AUD_OUT
&& !(wcaps
& AC_WCAP_DIGITAL
))
2593 snd_printdd("%s: total dac count=%d\n", __func__
, num_dacs
);
2595 switch (cfg
->line_outs
) {
2597 /* add line-in as side */
2598 if (cfg
->input_pins
[AUTO_PIN_LINE
] && num_dacs
> 3) {
2599 cfg
->line_out_pins
[cfg
->line_outs
] =
2600 cfg
->input_pins
[AUTO_PIN_LINE
];
2601 spec
->line_switch
= 1;
2606 /* add line-in as clfe and mic as side */
2607 if (cfg
->input_pins
[AUTO_PIN_LINE
] && num_dacs
> 2) {
2608 cfg
->line_out_pins
[cfg
->line_outs
] =
2609 cfg
->input_pins
[AUTO_PIN_LINE
];
2610 spec
->line_switch
= 1;
2613 if (cfg
->input_pins
[AUTO_PIN_MIC
] && num_dacs
> 3) {
2614 cfg
->line_out_pins
[cfg
->line_outs
] =
2615 cfg
->input_pins
[AUTO_PIN_MIC
];
2616 spec
->mic_switch
= 1;
2621 /* add line-in as surr and mic as clfe */
2622 if (cfg
->input_pins
[AUTO_PIN_LINE
] && num_dacs
> 1) {
2623 cfg
->line_out_pins
[cfg
->line_outs
] =
2624 cfg
->input_pins
[AUTO_PIN_LINE
];
2625 spec
->line_switch
= 1;
2628 if (cfg
->input_pins
[AUTO_PIN_MIC
] && num_dacs
> 2) {
2629 cfg
->line_out_pins
[cfg
->line_outs
] =
2630 cfg
->input_pins
[AUTO_PIN_MIC
];
2631 spec
->mic_switch
= 1;
2641 static int is_in_dac_nids(struct sigmatel_spec
*spec
, hda_nid_t nid
)
2645 for (i
= 0; i
< spec
->multiout
.num_dacs
; i
++) {
2646 if (spec
->multiout
.dac_nids
[i
] == nid
)
2654 * Fill in the dac_nids table from the parsed pin configuration
2655 * This function only works when every pin in line_out_pins[]
2656 * contains atleast one DAC in its connection list. Some 92xx
2657 * codecs are not connected directly to a DAC, such as the 9200
2658 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2660 static int stac92xx_auto_fill_dac_nids(struct hda_codec
*codec
,
2661 struct auto_pin_cfg
*cfg
)
2663 struct sigmatel_spec
*spec
= codec
->spec
;
2664 int i
, j
, conn_len
= 0;
2665 hda_nid_t nid
, conn
[HDA_MAX_CONNECTIONS
];
2666 unsigned int wcaps
, wtype
;
2668 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2669 nid
= cfg
->line_out_pins
[i
];
2670 conn_len
= snd_hda_get_connections(codec
, nid
, conn
,
2671 HDA_MAX_CONNECTIONS
);
2672 for (j
= 0; j
< conn_len
; j
++) {
2673 wcaps
= snd_hda_param_read(codec
, conn
[j
],
2674 AC_PAR_AUDIO_WIDGET_CAP
);
2675 wtype
= (wcaps
& AC_WCAP_TYPE
) >> AC_WCAP_TYPE_SHIFT
;
2676 if (wtype
!= AC_WID_AUD_OUT
||
2677 (wcaps
& AC_WCAP_DIGITAL
))
2679 /* conn[j] is a DAC routed to this line-out */
2680 if (!is_in_dac_nids(spec
, conn
[j
]))
2684 if (j
== conn_len
) {
2685 if (spec
->multiout
.num_dacs
> 0) {
2686 /* we have already working output pins,
2687 * so let's drop the broken ones again
2689 cfg
->line_outs
= spec
->multiout
.num_dacs
;
2692 /* error out, no available DAC found */
2694 "%s: No available DAC for pin 0x%x\n",
2699 spec
->multiout
.dac_nids
[i
] = conn
[j
];
2700 spec
->multiout
.num_dacs
++;
2702 /* select this DAC in the pin's input mux */
2703 snd_hda_codec_write_cache(codec
, nid
, 0,
2704 AC_VERB_SET_CONNECT_SEL
, j
);
2709 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2710 spec
->multiout
.num_dacs
,
2711 spec
->multiout
.dac_nids
[0],
2712 spec
->multiout
.dac_nids
[1],
2713 spec
->multiout
.dac_nids
[2],
2714 spec
->multiout
.dac_nids
[3],
2715 spec
->multiout
.dac_nids
[4]);
2719 /* create volume control/switch for the given prefx type */
2720 static int create_controls(struct sigmatel_spec
*spec
, const char *pfx
, hda_nid_t nid
, int chs
)
2725 sprintf(name
, "%s Playback Volume", pfx
);
2726 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_VOL
, name
,
2727 HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
));
2730 sprintf(name
, "%s Playback Switch", pfx
);
2731 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_MUTE
, name
,
2732 HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
));
2738 static int add_spec_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
)
2740 if (!spec
->multiout
.hp_nid
)
2741 spec
->multiout
.hp_nid
= nid
;
2742 else if (spec
->multiout
.num_dacs
> 4) {
2743 printk(KERN_WARNING
"stac92xx: No space for DAC 0x%x\n", nid
);
2746 spec
->multiout
.dac_nids
[spec
->multiout
.num_dacs
] = nid
;
2747 spec
->multiout
.num_dacs
++;
2752 static int check_in_dac_nids(struct sigmatel_spec
*spec
, hda_nid_t nid
)
2754 if (is_in_dac_nids(spec
, nid
))
2756 if (spec
->multiout
.hp_nid
== nid
)
2761 /* add playback controls from the parsed DAC table */
2762 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec
*codec
,
2763 const struct auto_pin_cfg
*cfg
)
2765 static const char *chname
[4] = {
2766 "Front", "Surround", NULL
/*CLFE*/, "Side"
2771 struct sigmatel_spec
*spec
= codec
->spec
;
2772 unsigned int wid_caps
, pincap
;
2775 for (i
= 0; i
< cfg
->line_outs
&& i
< spec
->multiout
.num_dacs
; i
++) {
2776 if (!spec
->multiout
.dac_nids
[i
])
2779 nid
= spec
->multiout
.dac_nids
[i
];
2783 err
= create_controls(spec
, "Center", nid
, 1);
2786 err
= create_controls(spec
, "LFE", nid
, 2);
2790 wid_caps
= get_wcaps(codec
, nid
);
2792 if (wid_caps
& AC_WCAP_LR_SWAP
) {
2793 err
= stac92xx_add_control(spec
,
2794 STAC_CTL_WIDGET_CLFE_SWITCH
,
2795 "Swap Center/LFE Playback Switch", nid
);
2802 err
= create_controls(spec
, chname
[i
], nid
, 3);
2808 if (cfg
->hp_outs
> 1) {
2809 err
= stac92xx_add_control(spec
,
2810 STAC_CTL_WIDGET_HP_SWITCH
,
2811 "Headphone as Line Out Switch", 0);
2816 if (spec
->line_switch
) {
2817 nid
= cfg
->input_pins
[AUTO_PIN_LINE
];
2818 pincap
= snd_hda_param_read(codec
, nid
,
2820 if (pincap
& AC_PINCAP_OUT
) {
2821 err
= stac92xx_add_control(spec
,
2822 STAC_CTL_WIDGET_IO_SWITCH
,
2823 "Line In as Output Switch", nid
<< 8);
2829 if (spec
->mic_switch
) {
2830 unsigned int def_conf
;
2831 unsigned int mic_pin
= AUTO_PIN_MIC
;
2833 nid
= cfg
->input_pins
[mic_pin
];
2834 def_conf
= snd_hda_codec_read(codec
, nid
, 0,
2835 AC_VERB_GET_CONFIG_DEFAULT
, 0);
2836 /* some laptops have an internal analog microphone
2837 * which can't be used as a output */
2838 if (get_defcfg_connect(def_conf
) != AC_JACK_PORT_FIXED
) {
2839 pincap
= snd_hda_param_read(codec
, nid
,
2841 if (pincap
& AC_PINCAP_OUT
) {
2842 err
= stac92xx_add_control(spec
,
2843 STAC_CTL_WIDGET_IO_SWITCH
,
2844 "Mic as Output Switch", (nid
<< 8) | 1);
2845 nid
= snd_hda_codec_read(codec
, nid
, 0,
2846 AC_VERB_GET_CONNECT_LIST
, 0) & 0xff;
2847 if (!check_in_dac_nids(spec
, nid
))
2848 add_spec_dacs(spec
, nid
);
2852 } else if (mic_pin
== AUTO_PIN_MIC
) {
2853 mic_pin
= AUTO_PIN_FRONT_MIC
;
2861 /* add playback controls for Speaker and HP outputs */
2862 static int stac92xx_auto_create_hp_ctls(struct hda_codec
*codec
,
2863 struct auto_pin_cfg
*cfg
)
2865 struct sigmatel_spec
*spec
= codec
->spec
;
2867 int i
, old_num_dacs
, err
;
2869 old_num_dacs
= spec
->multiout
.num_dacs
;
2870 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
2871 unsigned int wid_caps
= get_wcaps(codec
, cfg
->hp_pins
[i
]);
2872 if (wid_caps
& AC_WCAP_UNSOL_CAP
)
2873 spec
->hp_detect
= 1;
2874 nid
= snd_hda_codec_read(codec
, cfg
->hp_pins
[i
], 0,
2875 AC_VERB_GET_CONNECT_LIST
, 0) & 0xff;
2876 if (check_in_dac_nids(spec
, nid
))
2880 add_spec_dacs(spec
, nid
);
2882 for (i
= 0; i
< cfg
->speaker_outs
; i
++) {
2883 nid
= snd_hda_codec_read(codec
, cfg
->speaker_pins
[i
], 0,
2884 AC_VERB_GET_CONNECT_LIST
, 0) & 0xff;
2885 if (check_in_dac_nids(spec
, nid
))
2889 add_spec_dacs(spec
, nid
);
2891 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2892 nid
= snd_hda_codec_read(codec
, cfg
->line_out_pins
[i
], 0,
2893 AC_VERB_GET_CONNECT_LIST
, 0) & 0xff;
2894 if (check_in_dac_nids(spec
, nid
))
2898 add_spec_dacs(spec
, nid
);
2900 for (i
= old_num_dacs
; i
< spec
->multiout
.num_dacs
; i
++) {
2901 static const char *pfxs
[] = {
2902 "Speaker", "External Speaker", "Speaker2",
2904 err
= create_controls(spec
, pfxs
[i
- old_num_dacs
],
2905 spec
->multiout
.dac_nids
[i
], 3);
2909 if (spec
->multiout
.hp_nid
) {
2910 err
= create_controls(spec
, "Headphone",
2911 spec
->multiout
.hp_nid
, 3);
2919 /* labels for mono mux outputs */
2920 static const char *stac92xx_mono_labels
[4] = {
2921 "DAC0", "DAC1", "Mixer", "DAC2"
2924 /* create mono mux for mono out on capable codecs */
2925 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec
*codec
)
2927 struct sigmatel_spec
*spec
= codec
->spec
;
2928 struct hda_input_mux
*mono_mux
= &spec
->private_mono_mux
;
2930 hda_nid_t con_lst
[ARRAY_SIZE(stac92xx_mono_labels
)];
2932 num_cons
= snd_hda_get_connections(codec
,
2935 HDA_MAX_NUM_INPUTS
);
2936 if (!num_cons
|| num_cons
> ARRAY_SIZE(stac92xx_mono_labels
))
2939 for (i
= 0; i
< num_cons
; i
++) {
2940 mono_mux
->items
[mono_mux
->num_items
].label
=
2941 stac92xx_mono_labels
[i
];
2942 mono_mux
->items
[mono_mux
->num_items
].index
= i
;
2943 mono_mux
->num_items
++;
2946 return stac92xx_add_control(spec
, STAC_CTL_WIDGET_MONO_MUX
,
2947 "Mono Mux", spec
->mono_nid
);
2950 /* labels for amp mux outputs */
2951 static const char *stac92xx_amp_labels
[3] = {
2952 "Front Microphone", "Microphone", "Line In"
2955 /* create amp out controls mux on capable codecs */
2956 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec
*codec
)
2958 struct sigmatel_spec
*spec
= codec
->spec
;
2959 struct hda_input_mux
*amp_mux
= &spec
->private_amp_mux
;
2962 for (i
= 0; i
< ARRAY_SIZE(stac92xx_amp_labels
); i
++) {
2963 amp_mux
->items
[amp_mux
->num_items
].label
=
2964 stac92xx_amp_labels
[i
];
2965 amp_mux
->items
[amp_mux
->num_items
].index
= i
;
2966 amp_mux
->num_items
++;
2969 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_AMP_MUX
,
2970 "Amp Selector Capture Switch", 0);
2973 return stac92xx_add_control(spec
, STAC_CTL_WIDGET_AMP_VOL
,
2974 "Amp Capture Volume",
2975 HDA_COMPOSE_AMP_VAL(spec
->amp_nids
[0], 3, 0, HDA_INPUT
));
2979 /* create PC beep volume controls */
2980 static int stac92xx_auto_create_beep_ctls(struct hda_codec
*codec
,
2983 struct sigmatel_spec
*spec
= codec
->spec
;
2984 u32 caps
= query_amp_caps(codec
, nid
, HDA_OUTPUT
);
2987 /* check for mute support for the the amp */
2988 if ((caps
& AC_AMPCAP_MUTE
) >> AC_AMPCAP_MUTE_SHIFT
) {
2989 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_MUTE
,
2990 "PC Beep Playback Switch",
2991 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, HDA_OUTPUT
));
2996 /* check to see if there is volume support for the amp */
2997 if ((caps
& AC_AMPCAP_NUM_STEPS
) >> AC_AMPCAP_NUM_STEPS_SHIFT
) {
2998 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_VOL
,
2999 "PC Beep Playback Volume",
3000 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, HDA_OUTPUT
));
3007 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec
*codec
)
3009 struct sigmatel_spec
*spec
= codec
->spec
;
3010 int wcaps
, nid
, i
, err
= 0;
3012 for (i
= 0; i
< spec
->num_muxes
; i
++) {
3013 nid
= spec
->mux_nids
[i
];
3014 wcaps
= get_wcaps(codec
, nid
);
3016 if (wcaps
& AC_WCAP_OUT_AMP
) {
3017 err
= stac92xx_add_control_idx(spec
,
3018 STAC_CTL_WIDGET_VOL
, i
, "Mux Capture Volume",
3019 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
));
3027 static const char *stac92xx_spdif_labels
[3] = {
3028 "Digital Playback", "Analog Mux 1", "Analog Mux 2"
3031 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec
*codec
)
3033 struct sigmatel_spec
*spec
= codec
->spec
;
3034 struct hda_input_mux
*spdif_mux
= &spec
->private_smux
;
3036 hda_nid_t con_lst
[ARRAY_SIZE(stac92xx_spdif_labels
)];
3038 num_cons
= snd_hda_get_connections(codec
,
3041 HDA_MAX_NUM_INPUTS
);
3042 if (!num_cons
|| num_cons
> ARRAY_SIZE(stac92xx_spdif_labels
))
3045 for (i
= 0; i
< num_cons
; i
++) {
3046 spdif_mux
->items
[spdif_mux
->num_items
].label
=
3047 stac92xx_spdif_labels
[i
];
3048 spdif_mux
->items
[spdif_mux
->num_items
].index
= i
;
3049 spdif_mux
->num_items
++;
3055 /* labels for dmic mux inputs */
3056 static const char *stac92xx_dmic_labels
[5] = {
3057 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3058 "Digital Mic 3", "Digital Mic 4"
3061 /* create playback/capture controls for input pins on dmic capable codecs */
3062 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec
*codec
,
3063 const struct auto_pin_cfg
*cfg
)
3065 struct sigmatel_spec
*spec
= codec
->spec
;
3066 struct hda_input_mux
*dimux
= &spec
->private_dimux
;
3067 hda_nid_t con_lst
[HDA_MAX_NUM_INPUTS
];
3071 dimux
->items
[dimux
->num_items
].label
= stac92xx_dmic_labels
[0];
3072 dimux
->items
[dimux
->num_items
].index
= 0;
3075 for (i
= 0; i
< spec
->num_dmics
; i
++) {
3080 unsigned int def_conf
;
3082 def_conf
= snd_hda_codec_read(codec
,
3085 AC_VERB_GET_CONFIG_DEFAULT
,
3087 if (get_defcfg_connect(def_conf
) == AC_JACK_PORT_NONE
)
3090 nid
= spec
->dmic_nids
[i
];
3091 num_cons
= snd_hda_get_connections(codec
,
3094 HDA_MAX_NUM_INPUTS
);
3095 for (j
= 0; j
< num_cons
; j
++)
3096 if (con_lst
[j
] == nid
) {
3102 wcaps
= get_wcaps(codec
, nid
) &
3103 (AC_WCAP_OUT_AMP
| AC_WCAP_IN_AMP
);
3106 sprintf(name
, "%s Capture Volume",
3107 stac92xx_dmic_labels
[dimux
->num_items
]);
3109 err
= stac92xx_add_control(spec
,
3110 STAC_CTL_WIDGET_VOL
,
3112 HDA_COMPOSE_AMP_VAL(nid
, 3, 0,
3113 (wcaps
& AC_WCAP_OUT_AMP
) ?
3114 HDA_OUTPUT
: HDA_INPUT
));
3119 dimux
->items
[dimux
->num_items
].label
=
3120 stac92xx_dmic_labels
[dimux
->num_items
];
3121 dimux
->items
[dimux
->num_items
].index
= index
;
3128 /* create playback/capture controls for input pins */
3129 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec
*codec
, const struct auto_pin_cfg
*cfg
)
3131 struct sigmatel_spec
*spec
= codec
->spec
;
3132 struct hda_input_mux
*imux
= &spec
->private_imux
;
3133 hda_nid_t con_lst
[HDA_MAX_NUM_INPUTS
];
3136 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
3139 if (!cfg
->input_pins
[i
])
3142 for (j
= 0; j
< spec
->num_muxes
; j
++) {
3144 num_cons
= snd_hda_get_connections(codec
,
3147 HDA_MAX_NUM_INPUTS
);
3148 for (k
= 0; k
< num_cons
; k
++)
3149 if (con_lst
[k
] == cfg
->input_pins
[i
]) {
3156 imux
->items
[imux
->num_items
].label
= auto_pin_cfg_labels
[i
];
3157 imux
->items
[imux
->num_items
].index
= index
;
3161 if (imux
->num_items
) {
3163 * Set the current input for the muxes.
3164 * The STAC9221 has two input muxes with identical source
3165 * NID lists. Hopefully this won't get confused.
3167 for (i
= 0; i
< spec
->num_muxes
; i
++) {
3168 snd_hda_codec_write_cache(codec
, spec
->mux_nids
[i
], 0,
3169 AC_VERB_SET_CONNECT_SEL
,
3170 imux
->items
[0].index
);
3177 static void stac92xx_auto_init_multi_out(struct hda_codec
*codec
)
3179 struct sigmatel_spec
*spec
= codec
->spec
;
3182 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
3183 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
3184 stac92xx_auto_set_pinctl(codec
, nid
, AC_PINCTL_OUT_EN
);
3188 static void stac92xx_auto_init_hp_out(struct hda_codec
*codec
)
3190 struct sigmatel_spec
*spec
= codec
->spec
;
3193 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
3195 pin
= spec
->autocfg
.hp_pins
[i
];
3196 if (pin
) /* connect to front */
3197 stac92xx_auto_set_pinctl(codec
, pin
, AC_PINCTL_OUT_EN
| AC_PINCTL_HP_EN
);
3199 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++) {
3201 pin
= spec
->autocfg
.speaker_pins
[i
];
3202 if (pin
) /* connect to front */
3203 stac92xx_auto_set_pinctl(codec
, pin
, AC_PINCTL_OUT_EN
);
3207 static int stac92xx_parse_auto_config(struct hda_codec
*codec
, hda_nid_t dig_out
, hda_nid_t dig_in
)
3209 struct sigmatel_spec
*spec
= codec
->spec
;
3211 int hp_speaker_swap
= 0;
3213 if ((err
= snd_hda_parse_pin_def_config(codec
,
3215 spec
->dmic_nids
)) < 0)
3217 if (! spec
->autocfg
.line_outs
)
3218 return 0; /* can't find valid pin config */
3220 /* If we have no real line-out pin and multiple hp-outs, HPs should
3221 * be set up as multi-channel outputs.
3223 if (spec
->autocfg
.line_out_type
== AUTO_PIN_SPEAKER_OUT
&&
3224 spec
->autocfg
.hp_outs
> 1) {
3225 /* Copy hp_outs to line_outs, backup line_outs in
3226 * speaker_outs so that the following routines can handle
3227 * HP pins as primary outputs.
3229 memcpy(spec
->autocfg
.speaker_pins
, spec
->autocfg
.line_out_pins
,
3230 sizeof(spec
->autocfg
.line_out_pins
));
3231 spec
->autocfg
.speaker_outs
= spec
->autocfg
.line_outs
;
3232 memcpy(spec
->autocfg
.line_out_pins
, spec
->autocfg
.hp_pins
,
3233 sizeof(spec
->autocfg
.hp_pins
));
3234 spec
->autocfg
.line_outs
= spec
->autocfg
.hp_outs
;
3235 hp_speaker_swap
= 1;
3237 if (spec
->autocfg
.mono_out_pin
) {
3238 int dir
= get_wcaps(codec
, spec
->autocfg
.mono_out_pin
) &
3239 (AC_WCAP_OUT_AMP
| AC_WCAP_IN_AMP
);
3240 u32 caps
= query_amp_caps(codec
,
3241 spec
->autocfg
.mono_out_pin
, dir
);
3242 hda_nid_t conn_list
[1];
3244 /* get the mixer node and then the mono mux if it exists */
3245 if (snd_hda_get_connections(codec
,
3246 spec
->autocfg
.mono_out_pin
, conn_list
, 1) &&
3247 snd_hda_get_connections(codec
, conn_list
[0],
3250 int wcaps
= get_wcaps(codec
, conn_list
[0]);
3251 int wid_type
= (wcaps
& AC_WCAP_TYPE
)
3252 >> AC_WCAP_TYPE_SHIFT
;
3253 /* LR swap check, some stac925x have a mux that
3254 * changes the DACs output path instead of the
3257 if (wid_type
== AC_WID_AUD_SEL
&&
3258 !(wcaps
& AC_WCAP_LR_SWAP
))
3259 spec
->mono_nid
= conn_list
[0];
3262 hda_nid_t nid
= spec
->autocfg
.mono_out_pin
;
3264 /* most mono outs have a least a mute/unmute switch */
3265 dir
= (dir
& AC_WCAP_OUT_AMP
) ? HDA_OUTPUT
: HDA_INPUT
;
3266 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_MUTE
,
3267 "Mono Playback Switch",
3268 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, dir
));
3271 /* check for volume support for the amp */
3272 if ((caps
& AC_AMPCAP_NUM_STEPS
)
3273 >> AC_AMPCAP_NUM_STEPS_SHIFT
) {
3274 err
= stac92xx_add_control(spec
,
3275 STAC_CTL_WIDGET_VOL
,
3276 "Mono Playback Volume",
3277 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, dir
));
3283 stac92xx_auto_set_pinctl(codec
, spec
->autocfg
.mono_out_pin
,
3287 if ((err
= stac92xx_add_dyn_out_pins(codec
, &spec
->autocfg
)) < 0)
3289 if (spec
->multiout
.num_dacs
== 0)
3290 if ((err
= stac92xx_auto_fill_dac_nids(codec
, &spec
->autocfg
)) < 0)
3293 err
= stac92xx_auto_create_multi_out_ctls(codec
, &spec
->autocfg
);
3298 /* setup analog beep controls */
3299 if (spec
->anabeep_nid
> 0) {
3300 err
= stac92xx_auto_create_beep_ctls(codec
,
3306 /* setup digital beep controls and input device */
3307 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3308 if (spec
->digbeep_nid
> 0) {
3309 hda_nid_t nid
= spec
->digbeep_nid
;
3311 err
= stac92xx_auto_create_beep_ctls(codec
, nid
);
3314 err
= snd_hda_attach_beep_device(codec
, nid
);
3320 if (hp_speaker_swap
== 1) {
3321 /* Restore the hp_outs and line_outs */
3322 memcpy(spec
->autocfg
.hp_pins
, spec
->autocfg
.line_out_pins
,
3323 sizeof(spec
->autocfg
.line_out_pins
));
3324 spec
->autocfg
.hp_outs
= spec
->autocfg
.line_outs
;
3325 memcpy(spec
->autocfg
.line_out_pins
, spec
->autocfg
.speaker_pins
,
3326 sizeof(spec
->autocfg
.speaker_pins
));
3327 spec
->autocfg
.line_outs
= spec
->autocfg
.speaker_outs
;
3328 memset(spec
->autocfg
.speaker_pins
, 0,
3329 sizeof(spec
->autocfg
.speaker_pins
));
3330 spec
->autocfg
.speaker_outs
= 0;
3333 err
= stac92xx_auto_create_hp_ctls(codec
, &spec
->autocfg
);
3338 err
= stac92xx_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
3343 if (spec
->mono_nid
> 0) {
3344 err
= stac92xx_auto_create_mono_output_ctls(codec
);
3348 if (spec
->amp_nids
) {
3349 err
= stac92xx_auto_create_amp_output_ctls(codec
);
3353 if (spec
->num_dmics
> 0)
3354 if ((err
= stac92xx_auto_create_dmic_input_ctls(codec
,
3355 &spec
->autocfg
)) < 0)
3357 if (spec
->num_muxes
> 0) {
3358 err
= stac92xx_auto_create_mux_input_ctls(codec
);
3362 if (spec
->num_smuxes
> 0) {
3363 err
= stac92xx_auto_create_spdif_mux_ctls(codec
);
3368 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3369 if (spec
->multiout
.max_channels
> 2)
3370 spec
->surr_switch
= 1;
3372 if (spec
->autocfg
.dig_out_pin
)
3373 spec
->multiout
.dig_out_nid
= dig_out
;
3374 if (dig_in
&& spec
->autocfg
.dig_in_pin
)
3375 spec
->dig_in_nid
= dig_in
;
3377 if (spec
->kctl_alloc
)
3378 spec
->mixers
[spec
->num_mixers
++] = spec
->kctl_alloc
;
3380 spec
->input_mux
= &spec
->private_imux
;
3381 if (!spec
->dinput_mux
)
3382 spec
->dinput_mux
= &spec
->private_dimux
;
3383 spec
->sinput_mux
= &spec
->private_smux
;
3384 spec
->mono_mux
= &spec
->private_mono_mux
;
3385 spec
->amp_mux
= &spec
->private_amp_mux
;
3389 /* add playback controls for HP output */
3390 static int stac9200_auto_create_hp_ctls(struct hda_codec
*codec
,
3391 struct auto_pin_cfg
*cfg
)
3393 struct sigmatel_spec
*spec
= codec
->spec
;
3394 hda_nid_t pin
= cfg
->hp_pins
[0];
3395 unsigned int wid_caps
;
3400 wid_caps
= get_wcaps(codec
, pin
);
3401 if (wid_caps
& AC_WCAP_UNSOL_CAP
)
3402 spec
->hp_detect
= 1;
3407 /* add playback controls for LFE output */
3408 static int stac9200_auto_create_lfe_ctls(struct hda_codec
*codec
,
3409 struct auto_pin_cfg
*cfg
)
3411 struct sigmatel_spec
*spec
= codec
->spec
;
3413 hda_nid_t lfe_pin
= 0x0;
3417 * search speaker outs and line outs for a mono speaker pin
3418 * with an amp. If one is found, add LFE controls
3421 for (i
= 0; i
< spec
->autocfg
.speaker_outs
&& lfe_pin
== 0x0; i
++) {
3422 hda_nid_t pin
= spec
->autocfg
.speaker_pins
[i
];
3423 unsigned int wcaps
= get_wcaps(codec
, pin
);
3424 wcaps
&= (AC_WCAP_STEREO
| AC_WCAP_OUT_AMP
);
3425 if (wcaps
== AC_WCAP_OUT_AMP
)
3426 /* found a mono speaker with an amp, must be lfe */
3430 /* if speaker_outs is 0, then speakers may be in line_outs */
3431 if (lfe_pin
== 0 && spec
->autocfg
.speaker_outs
== 0) {
3432 for (i
= 0; i
< spec
->autocfg
.line_outs
&& lfe_pin
== 0x0; i
++) {
3433 hda_nid_t pin
= spec
->autocfg
.line_out_pins
[i
];
3434 unsigned int defcfg
;
3435 defcfg
= snd_hda_codec_read(codec
, pin
, 0,
3436 AC_VERB_GET_CONFIG_DEFAULT
,
3438 if (get_defcfg_device(defcfg
) == AC_JACK_SPEAKER
) {
3439 unsigned int wcaps
= get_wcaps(codec
, pin
);
3440 wcaps
&= (AC_WCAP_STEREO
| AC_WCAP_OUT_AMP
);
3441 if (wcaps
== AC_WCAP_OUT_AMP
)
3442 /* found a mono speaker with an amp,
3450 err
= create_controls(spec
, "LFE", lfe_pin
, 1);
3458 static int stac9200_parse_auto_config(struct hda_codec
*codec
)
3460 struct sigmatel_spec
*spec
= codec
->spec
;
3463 if ((err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
)) < 0)
3466 if ((err
= stac92xx_auto_create_analog_input_ctls(codec
, &spec
->autocfg
)) < 0)
3469 if ((err
= stac9200_auto_create_hp_ctls(codec
, &spec
->autocfg
)) < 0)
3472 if ((err
= stac9200_auto_create_lfe_ctls(codec
, &spec
->autocfg
)) < 0)
3475 if (spec
->autocfg
.dig_out_pin
)
3476 spec
->multiout
.dig_out_nid
= 0x05;
3477 if (spec
->autocfg
.dig_in_pin
)
3478 spec
->dig_in_nid
= 0x04;
3480 if (spec
->kctl_alloc
)
3481 spec
->mixers
[spec
->num_mixers
++] = spec
->kctl_alloc
;
3483 spec
->input_mux
= &spec
->private_imux
;
3484 spec
->dinput_mux
= &spec
->private_dimux
;
3490 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3491 * funky external mute control using GPIO pins.
3494 static void stac_gpio_set(struct hda_codec
*codec
, unsigned int mask
,
3495 unsigned int dir_mask
, unsigned int data
)
3497 unsigned int gpiostate
, gpiomask
, gpiodir
;
3499 gpiostate
= snd_hda_codec_read(codec
, codec
->afg
, 0,
3500 AC_VERB_GET_GPIO_DATA
, 0);
3501 gpiostate
= (gpiostate
& ~dir_mask
) | (data
& dir_mask
);
3503 gpiomask
= snd_hda_codec_read(codec
, codec
->afg
, 0,
3504 AC_VERB_GET_GPIO_MASK
, 0);
3507 gpiodir
= snd_hda_codec_read(codec
, codec
->afg
, 0,
3508 AC_VERB_GET_GPIO_DIRECTION
, 0);
3509 gpiodir
|= dir_mask
;
3511 /* Configure GPIOx as CMOS */
3512 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7e7, 0);
3514 snd_hda_codec_write(codec
, codec
->afg
, 0,
3515 AC_VERB_SET_GPIO_MASK
, gpiomask
);
3516 snd_hda_codec_read(codec
, codec
->afg
, 0,
3517 AC_VERB_SET_GPIO_DIRECTION
, gpiodir
); /* sync */
3521 snd_hda_codec_read(codec
, codec
->afg
, 0,
3522 AC_VERB_SET_GPIO_DATA
, gpiostate
); /* sync */
3525 static void enable_pin_detect(struct hda_codec
*codec
, hda_nid_t nid
,
3528 if (get_wcaps(codec
, nid
) & AC_WCAP_UNSOL_CAP
)
3529 snd_hda_codec_write_cache(codec
, nid
, 0,
3530 AC_VERB_SET_UNSOLICITED_ENABLE
,
3531 (AC_USRSP_EN
| event
));
3534 static int is_nid_hp_pin(struct auto_pin_cfg
*cfg
, hda_nid_t nid
)
3537 for (i
= 0; i
< cfg
->hp_outs
; i
++)
3538 if (cfg
->hp_pins
[i
] == nid
)
3539 return 1; /* nid is a HP-Out */
3541 return 0; /* nid is not a HP-Out */
3544 static void stac92xx_power_down(struct hda_codec
*codec
)
3546 struct sigmatel_spec
*spec
= codec
->spec
;
3548 /* power down inactive DACs */
3550 for (dac
= spec
->dac_list
; *dac
; dac
++)
3551 if (!is_in_dac_nids(spec
, *dac
) &&
3552 spec
->multiout
.hp_nid
!= *dac
)
3553 snd_hda_codec_write_cache(codec
, *dac
, 0,
3554 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
3557 static int stac92xx_init(struct hda_codec
*codec
)
3559 struct sigmatel_spec
*spec
= codec
->spec
;
3560 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3563 snd_hda_sequence_write(codec
, spec
->init
);
3565 /* power down adcs initially */
3566 if (spec
->powerdown_adcs
)
3567 for (i
= 0; i
< spec
->num_adcs
; i
++)
3568 snd_hda_codec_write_cache(codec
,
3569 spec
->adc_nids
[i
], 0,
3570 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
3572 if (spec
->hp_detect
) {
3573 /* Enable unsolicited responses on the HP widget */
3574 for (i
= 0; i
< cfg
->hp_outs
; i
++)
3575 enable_pin_detect(codec
, cfg
->hp_pins
[i
],
3577 /* force to enable the first line-out; the others are set up
3580 stac92xx_auto_set_pinctl(codec
, spec
->autocfg
.line_out_pins
[0],
3582 stac92xx_auto_init_hp_out(codec
);
3583 /* fake event to set up pins */
3584 codec
->patch_ops
.unsol_event(codec
, STAC_HP_EVENT
<< 26);
3586 stac92xx_auto_init_multi_out(codec
);
3587 stac92xx_auto_init_hp_out(codec
);
3589 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
3590 hda_nid_t nid
= cfg
->input_pins
[i
];
3592 unsigned int pinctl
= AC_PINCTL_IN_EN
;
3593 if (i
== AUTO_PIN_MIC
|| i
== AUTO_PIN_FRONT_MIC
)
3594 pinctl
|= stac92xx_get_vref(codec
, nid
);
3595 stac92xx_auto_set_pinctl(codec
, nid
, pinctl
);
3598 for (i
= 0; i
< spec
->num_dmics
; i
++)
3599 stac92xx_auto_set_pinctl(codec
, spec
->dmic_nids
[i
],
3601 for (i
= 0; i
< spec
->num_pwrs
; i
++) {
3602 int event
= is_nid_hp_pin(cfg
, spec
->pwr_nids
[i
])
3603 ? STAC_HP_EVENT
: STAC_PWR_EVENT
;
3604 int pinctl
= snd_hda_codec_read(codec
, spec
->pwr_nids
[i
],
3605 0, AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
3606 int def_conf
= snd_hda_codec_read(codec
, spec
->pwr_nids
[i
],
3607 0, AC_VERB_GET_CONFIG_DEFAULT
, 0);
3608 def_conf
= get_defcfg_connect(def_conf
);
3609 /* outputs are only ports capable of power management
3610 * any attempts on powering down a input port cause the
3611 * referenced VREF to act quirky.
3613 if (pinctl
& AC_PINCTL_IN_EN
)
3615 /* skip any ports that don't have jacks since presence
3616 * detection is useless */
3617 if (def_conf
&& def_conf
!= AC_JACK_PORT_FIXED
)
3619 enable_pin_detect(codec
, spec
->pwr_nids
[i
], event
| i
);
3620 codec
->patch_ops
.unsol_event(codec
, (event
| i
) << 26);
3623 stac92xx_power_down(codec
);
3624 if (cfg
->dig_out_pin
)
3625 stac92xx_auto_set_pinctl(codec
, cfg
->dig_out_pin
,
3627 if (cfg
->dig_in_pin
)
3628 stac92xx_auto_set_pinctl(codec
, cfg
->dig_in_pin
,
3631 stac_gpio_set(codec
, spec
->gpio_mask
,
3632 spec
->gpio_dir
, spec
->gpio_data
);
3637 static void stac92xx_free(struct hda_codec
*codec
)
3639 struct sigmatel_spec
*spec
= codec
->spec
;
3645 if (spec
->kctl_alloc
) {
3646 for (i
= 0; i
< spec
->num_kctl_used
; i
++)
3647 kfree(spec
->kctl_alloc
[i
].name
);
3648 kfree(spec
->kctl_alloc
);
3651 if (spec
->bios_pin_configs
)
3652 kfree(spec
->bios_pin_configs
);
3655 snd_hda_detach_beep_device(codec
);
3658 static void stac92xx_set_pinctl(struct hda_codec
*codec
, hda_nid_t nid
,
3661 unsigned int pin_ctl
= snd_hda_codec_read(codec
, nid
,
3662 0, AC_VERB_GET_PIN_WIDGET_CONTROL
, 0x00);
3664 if (pin_ctl
& AC_PINCTL_IN_EN
) {
3666 * we need to check the current set-up direction of
3667 * shared input pins since they can be switched via
3668 * "xxx as Output" mixer switch
3670 struct sigmatel_spec
*spec
= codec
->spec
;
3671 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3672 if ((nid
== cfg
->input_pins
[AUTO_PIN_LINE
] &&
3673 spec
->line_switch
) ||
3674 (nid
== cfg
->input_pins
[AUTO_PIN_MIC
] &&
3679 /* if setting pin direction bits, clear the current
3680 direction bits first */
3681 if (flag
& (AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
))
3682 pin_ctl
&= ~(AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
);
3684 snd_hda_codec_write_cache(codec
, nid
, 0,
3685 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3689 static void stac92xx_reset_pinctl(struct hda_codec
*codec
, hda_nid_t nid
,
3692 unsigned int pin_ctl
= snd_hda_codec_read(codec
, nid
,
3693 0, AC_VERB_GET_PIN_WIDGET_CONTROL
, 0x00);
3694 snd_hda_codec_write_cache(codec
, nid
, 0,
3695 AC_VERB_SET_PIN_WIDGET_CONTROL
,
3699 static int get_hp_pin_presence(struct hda_codec
*codec
, hda_nid_t nid
)
3703 if (snd_hda_codec_read(codec
, nid
, 0, AC_VERB_GET_PIN_SENSE
, 0x00)
3705 unsigned int pinctl
;
3706 pinctl
= snd_hda_codec_read(codec
, nid
, 0,
3707 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
3708 if (pinctl
& AC_PINCTL_IN_EN
)
3709 return 0; /* mic- or line-input */
3711 return 1; /* HP-output */
3716 static void stac92xx_hp_detect(struct hda_codec
*codec
, unsigned int res
)
3718 struct sigmatel_spec
*spec
= codec
->spec
;
3719 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3720 int nid
= cfg
->hp_pins
[cfg
->hp_outs
- 1];
3724 if (spec
->gpio_mute
)
3725 presence
= !(snd_hda_codec_read(codec
, codec
->afg
, 0,
3726 AC_VERB_GET_GPIO_DATA
, 0) & spec
->gpio_mute
);
3728 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3731 if (spec
->hp_switch
&& cfg
->hp_pins
[i
] == nid
)
3733 presence
= get_hp_pin_presence(codec
, cfg
->hp_pins
[i
]);
3737 /* disable lineouts, enable hp */
3738 if (spec
->hp_switch
)
3739 stac92xx_reset_pinctl(codec
, nid
, AC_PINCTL_OUT_EN
);
3740 for (i
= 0; i
< cfg
->line_outs
; i
++)
3741 stac92xx_reset_pinctl(codec
, cfg
->line_out_pins
[i
],
3743 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
3744 stac92xx_reset_pinctl(codec
, cfg
->speaker_pins
[i
],
3746 if (spec
->eapd_mask
)
3747 stac_gpio_set(codec
, spec
->gpio_mask
,
3748 spec
->gpio_dir
, spec
->gpio_data
&
3751 /* enable lineouts, disable hp */
3752 if (spec
->hp_switch
)
3753 stac92xx_set_pinctl(codec
, nid
, AC_PINCTL_OUT_EN
);
3754 for (i
= 0; i
< cfg
->line_outs
; i
++)
3755 stac92xx_set_pinctl(codec
, cfg
->line_out_pins
[i
],
3757 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
3758 stac92xx_set_pinctl(codec
, cfg
->speaker_pins
[i
],
3760 if (spec
->eapd_mask
)
3761 stac_gpio_set(codec
, spec
->gpio_mask
,
3762 spec
->gpio_dir
, spec
->gpio_data
|
3765 if (!spec
->hp_switch
&& cfg
->hp_outs
> 1 && presence
)
3766 stac92xx_set_pinctl(codec
, nid
, AC_PINCTL_OUT_EN
);
3769 static void stac92xx_pin_sense(struct hda_codec
*codec
, int idx
)
3771 struct sigmatel_spec
*spec
= codec
->spec
;
3772 hda_nid_t nid
= spec
->pwr_nids
[idx
];
3774 val
= snd_hda_codec_read(codec
, codec
->afg
, 0, 0x0fec, 0x0)
3776 presence
= get_hp_pin_presence(codec
, nid
);
3778 /* several codecs have two power down bits */
3779 if (spec
->pwr_mapping
)
3780 idx
= spec
->pwr_mapping
[idx
];
3789 /* power down unused output ports */
3790 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7ec, val
);
3793 static void stac92xx_unsol_event(struct hda_codec
*codec
, unsigned int res
)
3795 struct sigmatel_spec
*spec
= codec
->spec
;
3796 int idx
= res
>> 26 & 0x0f;
3798 switch ((res
>> 26) & 0x30) {
3800 stac92xx_hp_detect(codec
, res
);
3802 case STAC_PWR_EVENT
:
3803 if (spec
->num_pwrs
> 0)
3804 stac92xx_pin_sense(codec
, idx
);
3808 #ifdef SND_HDA_NEEDS_RESUME
3809 static int stac92xx_resume(struct hda_codec
*codec
)
3811 struct sigmatel_spec
*spec
= codec
->spec
;
3813 stac92xx_set_config_regs(codec
);
3814 snd_hda_sequence_write(codec
, spec
->init
);
3815 stac_gpio_set(codec
, spec
->gpio_mask
,
3816 spec
->gpio_dir
, spec
->gpio_data
);
3817 snd_hda_codec_resume_amp(codec
);
3818 snd_hda_codec_resume_cache(codec
);
3819 /* power down inactive DACs */
3821 stac92xx_power_down(codec
);
3822 /* invoke unsolicited event to reset the HP state */
3823 if (spec
->hp_detect
)
3824 codec
->patch_ops
.unsol_event(codec
, STAC_HP_EVENT
<< 26);
3829 static struct hda_codec_ops stac92xx_patch_ops
= {
3830 .build_controls
= stac92xx_build_controls
,
3831 .build_pcms
= stac92xx_build_pcms
,
3832 .init
= stac92xx_init
,
3833 .free
= stac92xx_free
,
3834 .unsol_event
= stac92xx_unsol_event
,
3835 #ifdef SND_HDA_NEEDS_RESUME
3836 .resume
= stac92xx_resume
,
3840 static int patch_stac9200(struct hda_codec
*codec
)
3842 struct sigmatel_spec
*spec
;
3845 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3850 spec
->num_pins
= ARRAY_SIZE(stac9200_pin_nids
);
3851 spec
->pin_nids
= stac9200_pin_nids
;
3852 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_9200_MODELS
,
3855 if (spec
->board_config
< 0) {
3856 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3857 err
= stac92xx_save_bios_config_regs(codec
);
3859 stac92xx_free(codec
);
3862 spec
->pin_configs
= spec
->bios_pin_configs
;
3864 spec
->pin_configs
= stac9200_brd_tbl
[spec
->board_config
];
3865 stac92xx_set_config_regs(codec
);
3868 spec
->multiout
.max_channels
= 2;
3869 spec
->multiout
.num_dacs
= 1;
3870 spec
->multiout
.dac_nids
= stac9200_dac_nids
;
3871 spec
->adc_nids
= stac9200_adc_nids
;
3872 spec
->mux_nids
= stac9200_mux_nids
;
3873 spec
->num_muxes
= 1;
3874 spec
->num_dmics
= 0;
3878 if (spec
->board_config
== STAC_9200_GATEWAY
||
3879 spec
->board_config
== STAC_9200_OQO
)
3880 spec
->init
= stac9200_eapd_init
;
3882 spec
->init
= stac9200_core_init
;
3883 spec
->mixer
= stac9200_mixer
;
3885 if (spec
->board_config
== STAC_9200_PANASONIC
) {
3886 spec
->gpio_mask
= spec
->gpio_dir
= 0x09;
3887 spec
->gpio_data
= 0x00;
3890 err
= stac9200_parse_auto_config(codec
);
3892 stac92xx_free(codec
);
3896 codec
->patch_ops
= stac92xx_patch_ops
;
3901 static int patch_stac925x(struct hda_codec
*codec
)
3903 struct sigmatel_spec
*spec
;
3906 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3911 spec
->num_pins
= ARRAY_SIZE(stac925x_pin_nids
);
3912 spec
->pin_nids
= stac925x_pin_nids
;
3913 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_925x_MODELS
,
3917 if (spec
->board_config
< 0) {
3918 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC925x,"
3919 "using BIOS defaults\n");
3920 err
= stac92xx_save_bios_config_regs(codec
);
3922 stac92xx_free(codec
);
3925 spec
->pin_configs
= spec
->bios_pin_configs
;
3926 } else if (stac925x_brd_tbl
[spec
->board_config
] != NULL
){
3927 spec
->pin_configs
= stac925x_brd_tbl
[spec
->board_config
];
3928 stac92xx_set_config_regs(codec
);
3931 spec
->multiout
.max_channels
= 2;
3932 spec
->multiout
.num_dacs
= 1;
3933 spec
->multiout
.dac_nids
= stac925x_dac_nids
;
3934 spec
->adc_nids
= stac925x_adc_nids
;
3935 spec
->mux_nids
= stac925x_mux_nids
;
3936 spec
->num_muxes
= 1;
3939 switch (codec
->vendor_id
) {
3940 case 0x83847632: /* STAC9202 */
3941 case 0x83847633: /* STAC9202D */
3942 case 0x83847636: /* STAC9251 */
3943 case 0x83847637: /* STAC9251D */
3944 spec
->num_dmics
= STAC925X_NUM_DMICS
;
3945 spec
->dmic_nids
= stac925x_dmic_nids
;
3946 spec
->num_dmuxes
= ARRAY_SIZE(stac925x_dmux_nids
);
3947 spec
->dmux_nids
= stac925x_dmux_nids
;
3950 spec
->num_dmics
= 0;
3954 spec
->init
= stac925x_core_init
;
3955 spec
->mixer
= stac925x_mixer
;
3957 err
= stac92xx_parse_auto_config(codec
, 0x8, 0x7);
3959 if (spec
->board_config
< 0) {
3960 printk(KERN_WARNING
"hda_codec: No auto-config is "
3961 "available, default to model=ref\n");
3962 spec
->board_config
= STAC_925x_REF
;
3968 stac92xx_free(codec
);
3972 codec
->patch_ops
= stac92xx_patch_ops
;
3977 static struct hda_input_mux stac92hd73xx_dmux
= {
3980 { "Analog Inputs", 0x0b },
3982 { "Digital Mic 1", 0x09 },
3983 { "Digital Mic 2", 0x0a },
3987 static int patch_stac92hd73xx(struct hda_codec
*codec
)
3989 struct sigmatel_spec
*spec
;
3990 hda_nid_t conn
[STAC92HD73_DAC_COUNT
+ 2];
3993 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
3998 codec
->slave_dig_outs
= stac92hd73xx_slave_dig_outs
;
3999 spec
->num_pins
= ARRAY_SIZE(stac92hd73xx_pin_nids
);
4000 spec
->pin_nids
= stac92hd73xx_pin_nids
;
4001 spec
->board_config
= snd_hda_check_board_config(codec
,
4002 STAC_92HD73XX_MODELS
,
4003 stac92hd73xx_models
,
4004 stac92hd73xx_cfg_tbl
);
4006 if (spec
->board_config
< 0) {
4007 snd_printdd(KERN_INFO
"hda_codec: Unknown model for"
4008 " STAC92HD73XX, using BIOS defaults\n");
4009 err
= stac92xx_save_bios_config_regs(codec
);
4011 stac92xx_free(codec
);
4014 spec
->pin_configs
= spec
->bios_pin_configs
;
4016 spec
->pin_configs
= stac92hd73xx_brd_tbl
[spec
->board_config
];
4017 stac92xx_set_config_regs(codec
);
4020 spec
->multiout
.num_dacs
= snd_hda_get_connections(codec
, 0x0a,
4021 conn
, STAC92HD73_DAC_COUNT
+ 2) - 1;
4023 if (spec
->multiout
.num_dacs
< 0) {
4024 printk(KERN_WARNING
"hda_codec: Could not determine "
4025 "number of channels defaulting to DAC count\n");
4026 spec
->multiout
.num_dacs
= STAC92HD73_DAC_COUNT
;
4029 switch (spec
->multiout
.num_dacs
) {
4030 case 0x3: /* 6 Channel */
4031 spec
->mixer
= stac92hd73xx_6ch_mixer
;
4032 spec
->init
= stac92hd73xx_6ch_core_init
;
4034 case 0x4: /* 8 Channel */
4035 spec
->mixer
= stac92hd73xx_8ch_mixer
;
4036 spec
->init
= stac92hd73xx_8ch_core_init
;
4038 case 0x5: /* 10 Channel */
4039 spec
->mixer
= stac92hd73xx_10ch_mixer
;
4040 spec
->init
= stac92hd73xx_10ch_core_init
;
4043 spec
->multiout
.dac_nids
= stac92hd73xx_dac_nids
;
4044 spec
->aloopback_mask
= 0x01;
4045 spec
->aloopback_shift
= 8;
4047 spec
->digbeep_nid
= 0x1c;
4048 spec
->mux_nids
= stac92hd73xx_mux_nids
;
4049 spec
->adc_nids
= stac92hd73xx_adc_nids
;
4050 spec
->dmic_nids
= stac92hd73xx_dmic_nids
;
4051 spec
->dmux_nids
= stac92hd73xx_dmux_nids
;
4052 spec
->smux_nids
= stac92hd73xx_smux_nids
;
4053 spec
->amp_nids
= stac92hd73xx_amp_nids
;
4055 spec
->num_muxes
= ARRAY_SIZE(stac92hd73xx_mux_nids
);
4056 spec
->num_adcs
= ARRAY_SIZE(stac92hd73xx_adc_nids
);
4057 spec
->num_dmuxes
= ARRAY_SIZE(stac92hd73xx_dmux_nids
);
4058 spec
->num_smuxes
= ARRAY_SIZE(stac92hd73xx_smux_nids
);
4059 spec
->dinput_mux
= &stac92hd73xx_dmux
;
4060 /* GPIO0 High = Enable EAPD */
4061 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x1;
4062 spec
->gpio_data
= 0x01;
4064 switch (spec
->board_config
) {
4066 spec
->init
= dell_eq_core_init
;
4067 switch (codec
->subsystem_id
) {
4068 case 0x1028025e: /* Analog Mics */
4070 stac92xx_set_config_reg(codec
, 0x0b, 0x90A70170);
4071 spec
->num_dmics
= 0;
4073 case 0x10280271: /* Digital Mics */
4075 spec
->init
= dell_m6_core_init
;
4079 stac92xx_set_config_reg(codec
, 0x13, 0x90A60160);
4080 spec
->num_dmics
= 1;
4082 case 0x10280256: /* Both */
4084 stac92xx_set_config_reg(codec
, 0x0b, 0x90A70170);
4085 stac92xx_set_config_reg(codec
, 0x13, 0x90A60160);
4086 spec
->num_dmics
= 1;
4091 spec
->num_dmics
= STAC92HD73XX_NUM_DMICS
;
4094 spec
->num_pwrs
= ARRAY_SIZE(stac92hd73xx_pwr_nids
);
4095 spec
->pwr_nids
= stac92hd73xx_pwr_nids
;
4097 err
= stac92xx_parse_auto_config(codec
, 0x25, 0x27);
4100 if (spec
->board_config
< 0) {
4101 printk(KERN_WARNING
"hda_codec: No auto-config is "
4102 "available, default to model=ref\n");
4103 spec
->board_config
= STAC_92HD73XX_REF
;
4110 stac92xx_free(codec
);
4114 codec
->patch_ops
= stac92xx_patch_ops
;
4119 static struct hda_input_mux stac92hd83xxx_dmux
= {
4122 { "Analog Inputs", 0x03 },
4123 { "Digital Mic 1", 0x04 },
4124 { "Digital Mic 2", 0x05 },
4128 static int patch_stac92hd83xxx(struct hda_codec
*codec
)
4130 struct sigmatel_spec
*spec
;
4133 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4138 codec
->slave_dig_outs
= stac92hd83xxx_slave_dig_outs
;
4139 spec
->mono_nid
= 0x19;
4140 spec
->digbeep_nid
= 0x21;
4141 spec
->dmic_nids
= stac92hd83xxx_dmic_nids
;
4142 spec
->dmux_nids
= stac92hd83xxx_dmux_nids
;
4143 spec
->adc_nids
= stac92hd83xxx_adc_nids
;
4144 spec
->pwr_nids
= stac92hd83xxx_pwr_nids
;
4145 spec
->pwr_mapping
= stac92hd83xxx_pwr_mapping
;
4146 spec
->num_pwrs
= ARRAY_SIZE(stac92hd83xxx_pwr_nids
);
4147 spec
->multiout
.dac_nids
= stac92hd83xxx_dac_nids
;
4149 spec
->init
= stac92hd83xxx_core_init
;
4150 switch (codec
->vendor_id
) {
4152 spec
->multiout
.num_dacs
= STAC92HD81_DAC_COUNT
;
4156 spec
->init
++; /* switch to config #2 */
4157 spec
->multiout
.num_dacs
= STAC92HD83_DAC_COUNT
;
4160 spec
->mixer
= stac92hd83xxx_mixer
;
4161 spec
->num_pins
= ARRAY_SIZE(stac92hd83xxx_pin_nids
);
4162 spec
->num_dmuxes
= ARRAY_SIZE(stac92hd83xxx_dmux_nids
);
4163 spec
->num_adcs
= ARRAY_SIZE(stac92hd83xxx_adc_nids
);
4164 spec
->num_dmics
= STAC92HD83XXX_NUM_DMICS
;
4165 spec
->dinput_mux
= &stac92hd83xxx_dmux
;
4166 spec
->pin_nids
= stac92hd83xxx_pin_nids
;
4167 spec
->board_config
= snd_hda_check_board_config(codec
,
4168 STAC_92HD83XXX_MODELS
,
4169 stac92hd83xxx_models
,
4170 stac92hd83xxx_cfg_tbl
);
4172 if (spec
->board_config
< 0) {
4173 snd_printdd(KERN_INFO
"hda_codec: Unknown model for"
4174 " STAC92HD83XXX, using BIOS defaults\n");
4175 err
= stac92xx_save_bios_config_regs(codec
);
4177 stac92xx_free(codec
);
4180 spec
->pin_configs
= spec
->bios_pin_configs
;
4182 spec
->pin_configs
= stac92hd83xxx_brd_tbl
[spec
->board_config
];
4183 stac92xx_set_config_regs(codec
);
4186 err
= stac92xx_parse_auto_config(codec
, 0x1d, 0);
4188 if (spec
->board_config
< 0) {
4189 printk(KERN_WARNING
"hda_codec: No auto-config is "
4190 "available, default to model=ref\n");
4191 spec
->board_config
= STAC_92HD83XXX_REF
;
4198 stac92xx_free(codec
);
4202 codec
->patch_ops
= stac92xx_patch_ops
;
4207 #ifdef SND_HDA_NEEDS_RESUME
4208 static void stac92hd71xx_set_power_state(struct hda_codec
*codec
, int pwr
)
4210 struct sigmatel_spec
*spec
= codec
->spec
;
4212 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
4213 AC_VERB_SET_POWER_STATE
, pwr
);
4216 for (i
= 0; i
< spec
->num_adcs
; i
++) {
4217 snd_hda_codec_write_cache(codec
,
4218 spec
->adc_nids
[i
], 0,
4219 AC_VERB_SET_POWER_STATE
, pwr
);
4223 static int stac92hd71xx_resume(struct hda_codec
*codec
)
4225 stac92hd71xx_set_power_state(codec
, AC_PWRST_D0
);
4226 return stac92xx_resume(codec
);
4229 static int stac92hd71xx_suspend(struct hda_codec
*codec
, pm_message_t state
)
4231 stac92hd71xx_set_power_state(codec
, AC_PWRST_D3
);
4237 static struct hda_codec_ops stac92hd71bxx_patch_ops
= {
4238 .build_controls
= stac92xx_build_controls
,
4239 .build_pcms
= stac92xx_build_pcms
,
4240 .init
= stac92xx_init
,
4241 .free
= stac92xx_free
,
4242 .unsol_event
= stac92xx_unsol_event
,
4243 #ifdef SND_HDA_NEEDS_RESUME
4244 .resume
= stac92hd71xx_resume
,
4245 .suspend
= stac92hd71xx_suspend
,
4249 static int patch_stac92hd71bxx(struct hda_codec
*codec
)
4251 struct sigmatel_spec
*spec
;
4254 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4259 codec
->patch_ops
= stac92xx_patch_ops
;
4260 spec
->num_pins
= ARRAY_SIZE(stac92hd71bxx_pin_nids
);
4261 spec
->num_pwrs
= ARRAY_SIZE(stac92hd71bxx_pwr_nids
);
4262 spec
->pin_nids
= stac92hd71bxx_pin_nids
;
4263 spec
->board_config
= snd_hda_check_board_config(codec
,
4264 STAC_92HD71BXX_MODELS
,
4265 stac92hd71bxx_models
,
4266 stac92hd71bxx_cfg_tbl
);
4268 if (spec
->board_config
< 0) {
4269 snd_printdd(KERN_INFO
"hda_codec: Unknown model for"
4270 " STAC92HD71BXX, using BIOS defaults\n");
4271 err
= stac92xx_save_bios_config_regs(codec
);
4273 stac92xx_free(codec
);
4276 spec
->pin_configs
= spec
->bios_pin_configs
;
4278 spec
->pin_configs
= stac92hd71bxx_brd_tbl
[spec
->board_config
];
4279 stac92xx_set_config_regs(codec
);
4282 switch (codec
->vendor_id
) {
4283 case 0x111d76b6: /* 4 Port without Analog Mixer */
4285 case 0x111d76b4: /* 6 Port without Analog Mixer */
4287 spec
->mixer
= stac92hd71bxx_mixer
;
4288 spec
->init
= stac92hd71bxx_core_init
;
4289 codec
->slave_dig_outs
= stac92hd71bxx_slave_dig_outs
;
4291 case 0x111d7608: /* 5 Port with Analog Mixer */
4292 if ((codec
->revision_id
& 0xf) == 0 ||
4293 (codec
->revision_id
& 0xf) == 1) {
4294 #ifdef SND_HDA_NEEDS_RESUME
4295 codec
->patch_ops
= stac92hd71bxx_patch_ops
;
4297 spec
->stream_delay
= 40; /* 40 milliseconds */
4300 /* no output amps */
4302 spec
->mixer
= stac92hd71bxx_analog_mixer
;
4305 spec
->init
= &stac92hd71bxx_analog_core_init
[HD_DISABLE_PORTF
];
4306 stac92xx_set_config_reg(codec
, 0xf, 0x40f000f0);
4308 case 0x111d7603: /* 6 Port with Analog Mixer */
4309 if ((codec
->revision_id
& 0xf) == 1) {
4310 #ifdef SND_HDA_NEEDS_RESUME
4311 codec
->patch_ops
= stac92hd71bxx_patch_ops
;
4313 spec
->stream_delay
= 40; /* 40 milliseconds */
4316 /* no output amps */
4320 spec
->mixer
= stac92hd71bxx_analog_mixer
;
4321 spec
->init
= stac92hd71bxx_analog_core_init
;
4322 codec
->slave_dig_outs
= stac92hd71bxx_slave_dig_outs
;
4325 spec
->aloopback_mask
= 0x20;
4326 spec
->aloopback_shift
= 0;
4328 /* GPIO0 High = EAPD */
4329 spec
->gpio_mask
= 0x01;
4330 spec
->gpio_dir
= 0x01;
4331 spec
->gpio_data
= 0x01;
4333 spec
->powerdown_adcs
= 1;
4334 spec
->digbeep_nid
= 0x26;
4335 spec
->mux_nids
= stac92hd71bxx_mux_nids
;
4336 spec
->adc_nids
= stac92hd71bxx_adc_nids
;
4337 spec
->dmic_nids
= stac92hd71bxx_dmic_nids
;
4338 spec
->dmux_nids
= stac92hd71bxx_dmux_nids
;
4339 spec
->smux_nids
= stac92hd71bxx_smux_nids
;
4340 spec
->pwr_nids
= stac92hd71bxx_pwr_nids
;
4342 spec
->num_muxes
= ARRAY_SIZE(stac92hd71bxx_mux_nids
);
4343 spec
->num_adcs
= ARRAY_SIZE(stac92hd71bxx_adc_nids
);
4344 spec
->num_dmuxes
= ARRAY_SIZE(stac92hd71bxx_dmux_nids
);
4346 switch (spec
->board_config
) {
4348 spec
->num_dmics
= 0;
4349 spec
->num_smuxes
= 1;
4350 spec
->num_dmuxes
= 0;
4352 /* enable internal microphone */
4353 snd_hda_codec_write_cache(codec
, 0x0e, 0,
4354 AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
);
4357 spec
->num_dmics
= STAC92HD71BXX_NUM_DMICS
;
4358 spec
->num_smuxes
= ARRAY_SIZE(stac92hd71bxx_smux_nids
);
4359 spec
->num_dmuxes
= ARRAY_SIZE(stac92hd71bxx_dmux_nids
);
4362 spec
->multiout
.num_dacs
= 1;
4363 spec
->multiout
.hp_nid
= 0x11;
4364 spec
->multiout
.dac_nids
= stac92hd71bxx_dac_nids
;
4366 err
= stac92xx_parse_auto_config(codec
, 0x21, 0x23);
4368 if (spec
->board_config
< 0) {
4369 printk(KERN_WARNING
"hda_codec: No auto-config is "
4370 "available, default to model=ref\n");
4371 spec
->board_config
= STAC_92HD71BXX_REF
;
4378 stac92xx_free(codec
);
4385 static int patch_stac922x(struct hda_codec
*codec
)
4387 struct sigmatel_spec
*spec
;
4390 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4395 spec
->num_pins
= ARRAY_SIZE(stac922x_pin_nids
);
4396 spec
->pin_nids
= stac922x_pin_nids
;
4397 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_922X_MODELS
,
4400 if (spec
->board_config
== STAC_INTEL_MAC_AUTO
) {
4401 spec
->gpio_mask
= spec
->gpio_dir
= 0x03;
4402 spec
->gpio_data
= 0x03;
4403 /* Intel Macs have all same PCI SSID, so we need to check
4404 * codec SSID to distinguish the exact models
4406 printk(KERN_INFO
"hda_codec: STAC922x, Apple subsys_id=%x\n", codec
->subsystem_id
);
4407 switch (codec
->subsystem_id
) {
4410 spec
->board_config
= STAC_INTEL_MAC_V1
;
4414 spec
->board_config
= STAC_INTEL_MAC_V2
;
4422 spec
->board_config
= STAC_INTEL_MAC_V3
;
4426 spec
->board_config
= STAC_INTEL_MAC_V4
;
4430 spec
->board_config
= STAC_INTEL_MAC_V5
;
4433 spec
->board_config
= STAC_INTEL_MAC_V3
;
4439 if (spec
->board_config
< 0) {
4440 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC922x, "
4441 "using BIOS defaults\n");
4442 err
= stac92xx_save_bios_config_regs(codec
);
4444 stac92xx_free(codec
);
4447 spec
->pin_configs
= spec
->bios_pin_configs
;
4448 } else if (stac922x_brd_tbl
[spec
->board_config
] != NULL
) {
4449 spec
->pin_configs
= stac922x_brd_tbl
[spec
->board_config
];
4450 stac92xx_set_config_regs(codec
);
4453 spec
->adc_nids
= stac922x_adc_nids
;
4454 spec
->mux_nids
= stac922x_mux_nids
;
4455 spec
->num_muxes
= ARRAY_SIZE(stac922x_mux_nids
);
4456 spec
->num_adcs
= ARRAY_SIZE(stac922x_adc_nids
);
4457 spec
->num_dmics
= 0;
4460 spec
->init
= stac922x_core_init
;
4461 spec
->mixer
= stac922x_mixer
;
4463 spec
->multiout
.dac_nids
= spec
->dac_nids
;
4465 err
= stac92xx_parse_auto_config(codec
, 0x08, 0x09);
4467 if (spec
->board_config
< 0) {
4468 printk(KERN_WARNING
"hda_codec: No auto-config is "
4469 "available, default to model=ref\n");
4470 spec
->board_config
= STAC_D945_REF
;
4476 stac92xx_free(codec
);
4480 codec
->patch_ops
= stac92xx_patch_ops
;
4482 /* Fix Mux capture level; max to 2 */
4483 snd_hda_override_amp_caps(codec
, 0x12, HDA_OUTPUT
,
4484 (0 << AC_AMPCAP_OFFSET_SHIFT
) |
4485 (2 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
4486 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
4487 (0 << AC_AMPCAP_MUTE_SHIFT
));
4492 static int patch_stac927x(struct hda_codec
*codec
)
4494 struct sigmatel_spec
*spec
;
4497 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4502 spec
->num_pins
= ARRAY_SIZE(stac927x_pin_nids
);
4503 spec
->pin_nids
= stac927x_pin_nids
;
4504 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_927X_MODELS
,
4508 if (spec
->board_config
< 0 || !stac927x_brd_tbl
[spec
->board_config
]) {
4509 if (spec
->board_config
< 0)
4510 snd_printdd(KERN_INFO
"hda_codec: Unknown model for"
4511 "STAC927x, using BIOS defaults\n");
4512 err
= stac92xx_save_bios_config_regs(codec
);
4514 stac92xx_free(codec
);
4517 spec
->pin_configs
= spec
->bios_pin_configs
;
4519 spec
->pin_configs
= stac927x_brd_tbl
[spec
->board_config
];
4520 stac92xx_set_config_regs(codec
);
4523 spec
->digbeep_nid
= 0x23;
4524 spec
->adc_nids
= stac927x_adc_nids
;
4525 spec
->num_adcs
= ARRAY_SIZE(stac927x_adc_nids
);
4526 spec
->mux_nids
= stac927x_mux_nids
;
4527 spec
->num_muxes
= ARRAY_SIZE(stac927x_mux_nids
);
4528 spec
->smux_nids
= stac927x_smux_nids
;
4529 spec
->num_smuxes
= ARRAY_SIZE(stac927x_smux_nids
);
4530 spec
->dac_list
= stac927x_dac_nids
;
4531 spec
->multiout
.dac_nids
= spec
->dac_nids
;
4533 switch (spec
->board_config
) {
4536 /* GPIO0 High = Enable EAPD */
4537 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x01;
4538 spec
->gpio_data
= 0x01;
4539 spec
->num_dmics
= 0;
4541 spec
->init
= d965_core_init
;
4542 spec
->mixer
= stac927x_mixer
;
4544 case STAC_DELL_BIOS
:
4545 switch (codec
->subsystem_id
) {
4548 /* correct the device field to SPDIF out */
4549 stac92xx_set_config_reg(codec
, 0x21, 0x01442070);
4552 /* configure the analog microphone on some laptops */
4553 stac92xx_set_config_reg(codec
, 0x0c, 0x90a79130);
4554 /* correct the front output jack as a hp out */
4555 stac92xx_set_config_reg(codec
, 0x0f, 0x0227011f);
4556 /* correct the front input jack as a mic */
4557 stac92xx_set_config_reg(codec
, 0x0e, 0x02a79130);
4560 /* GPIO2 High = Enable EAPD */
4561 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x04;
4562 spec
->gpio_data
= 0x04;
4563 spec
->dmic_nids
= stac927x_dmic_nids
;
4564 spec
->num_dmics
= STAC927X_NUM_DMICS
;
4566 spec
->init
= d965_core_init
;
4567 spec
->mixer
= stac927x_mixer
;
4568 spec
->dmux_nids
= stac927x_dmux_nids
;
4569 spec
->num_dmuxes
= ARRAY_SIZE(stac927x_dmux_nids
);
4572 /* GPIO0 High = Enable EAPD */
4573 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x1;
4574 spec
->gpio_data
= 0x01;
4575 spec
->num_dmics
= 0;
4577 spec
->init
= stac927x_core_init
;
4578 spec
->mixer
= stac927x_mixer
;
4582 spec
->aloopback_mask
= 0x40;
4583 spec
->aloopback_shift
= 0;
4585 err
= stac92xx_parse_auto_config(codec
, 0x1e, 0x20);
4587 if (spec
->board_config
< 0) {
4588 printk(KERN_WARNING
"hda_codec: No auto-config is "
4589 "available, default to model=ref\n");
4590 spec
->board_config
= STAC_D965_REF
;
4596 stac92xx_free(codec
);
4600 codec
->patch_ops
= stac92xx_patch_ops
;
4604 * The STAC927x seem to require fairly long delays for certain
4605 * command sequences. With too short delays (even if the answer
4606 * is set to RIRB properly), it results in the silence output
4607 * on some hardwares like Dell.
4609 * The below flag enables the longer delay (see get_response
4612 codec
->bus
->needs_damn_long_delay
= 1;
4617 static int patch_stac9205(struct hda_codec
*codec
)
4619 struct sigmatel_spec
*spec
;
4622 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4627 spec
->num_pins
= ARRAY_SIZE(stac9205_pin_nids
);
4628 spec
->pin_nids
= stac9205_pin_nids
;
4629 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_9205_MODELS
,
4633 if (spec
->board_config
< 0) {
4634 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4635 err
= stac92xx_save_bios_config_regs(codec
);
4637 stac92xx_free(codec
);
4640 spec
->pin_configs
= spec
->bios_pin_configs
;
4642 spec
->pin_configs
= stac9205_brd_tbl
[spec
->board_config
];
4643 stac92xx_set_config_regs(codec
);
4646 spec
->digbeep_nid
= 0x23;
4647 spec
->adc_nids
= stac9205_adc_nids
;
4648 spec
->num_adcs
= ARRAY_SIZE(stac9205_adc_nids
);
4649 spec
->mux_nids
= stac9205_mux_nids
;
4650 spec
->num_muxes
= ARRAY_SIZE(stac9205_mux_nids
);
4651 spec
->smux_nids
= stac9205_smux_nids
;
4652 spec
->num_smuxes
= ARRAY_SIZE(stac9205_smux_nids
);
4653 spec
->dmic_nids
= stac9205_dmic_nids
;
4654 spec
->num_dmics
= STAC9205_NUM_DMICS
;
4655 spec
->dmux_nids
= stac9205_dmux_nids
;
4656 spec
->num_dmuxes
= ARRAY_SIZE(stac9205_dmux_nids
);
4659 spec
->init
= stac9205_core_init
;
4660 spec
->mixer
= stac9205_mixer
;
4662 spec
->aloopback_mask
= 0x40;
4663 spec
->aloopback_shift
= 0;
4664 spec
->multiout
.dac_nids
= spec
->dac_nids
;
4666 switch (spec
->board_config
){
4667 case STAC_9205_DELL_M43
:
4668 /* Enable SPDIF in/out */
4669 stac92xx_set_config_reg(codec
, 0x1f, 0x01441030);
4670 stac92xx_set_config_reg(codec
, 0x20, 0x1c410030);
4672 /* Enable unsol response for GPIO4/Dock HP connection */
4673 snd_hda_codec_write(codec
, codec
->afg
, 0,
4674 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK
, 0x10);
4675 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
4676 AC_VERB_SET_UNSOLICITED_ENABLE
,
4677 (AC_USRSP_EN
| STAC_HP_EVENT
));
4679 spec
->gpio_dir
= 0x0b;
4680 spec
->eapd_mask
= 0x01;
4681 spec
->gpio_mask
= 0x1b;
4682 spec
->gpio_mute
= 0x10;
4683 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
4686 spec
->gpio_data
= 0x01;
4689 /* GPIO0 High = EAPD */
4690 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x1;
4691 spec
->gpio_data
= 0x01;
4695 err
= stac92xx_parse_auto_config(codec
, 0x1f, 0x20);
4697 if (spec
->board_config
< 0) {
4698 printk(KERN_WARNING
"hda_codec: No auto-config is "
4699 "available, default to model=ref\n");
4700 spec
->board_config
= STAC_9205_REF
;
4706 stac92xx_free(codec
);
4710 codec
->patch_ops
= stac92xx_patch_ops
;
4719 /* static config for Sony VAIO FE550G and Sony VAIO AR */
4720 static hda_nid_t vaio_dacs
[] = { 0x2 };
4721 #define VAIO_HP_DAC 0x5
4722 static hda_nid_t vaio_adcs
[] = { 0x8 /*,0x6*/ };
4723 static hda_nid_t vaio_mux_nids
[] = { 0x15 };
4725 static struct hda_input_mux vaio_mux
= {
4728 /* { "HP", 0x0 }, */
4729 { "Mic Jack", 0x1 },
4730 { "Internal Mic", 0x2 },
4735 static struct hda_verb vaio_init
[] = {
4736 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
}, /* HP <- 0x2 */
4737 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| STAC_HP_EVENT
},
4738 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* Speaker <- 0x5 */
4739 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Mic? (<- 0x2) */
4740 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* CD */
4741 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Mic? */
4742 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mic-sel: 0a,0d,14,02 */
4743 {0x02, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
}, /* HP */
4744 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
}, /* Speaker */
4745 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4746 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4747 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
}, /* Mic-in -> 0x9 */
4751 static struct hda_verb vaio_ar_init
[] = {
4752 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
}, /* HP <- 0x2 */
4753 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* Speaker <- 0x5 */
4754 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Mic? (<- 0x2) */
4755 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* CD */
4756 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4757 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Mic? */
4758 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mic-sel: 0a,0d,14,02 */
4759 {0x02, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
}, /* HP */
4760 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
}, /* Speaker */
4761 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4762 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4763 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4764 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
}, /* Mic-in -> 0x9 */
4768 /* bind volumes of both NID 0x02 and 0x05 */
4769 static struct hda_bind_ctls vaio_bind_master_vol
= {
4770 .ops
= &snd_hda_bind_vol
,
4772 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT
),
4773 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT
),
4778 /* bind volumes of both NID 0x02 and 0x05 */
4779 static struct hda_bind_ctls vaio_bind_master_sw
= {
4780 .ops
= &snd_hda_bind_sw
,
4782 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT
),
4783 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT
),
4788 static struct snd_kcontrol_new vaio_mixer
[] = {
4789 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol
),
4790 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw
),
4791 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4792 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT
),
4793 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT
),
4795 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4796 .name
= "Capture Source",
4798 .info
= stac92xx_mux_enum_info
,
4799 .get
= stac92xx_mux_enum_get
,
4800 .put
= stac92xx_mux_enum_put
,
4805 static struct snd_kcontrol_new vaio_ar_mixer
[] = {
4806 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol
),
4807 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw
),
4808 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4809 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT
),
4810 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT
),
4811 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4812 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4814 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
4815 .name
= "Capture Source",
4817 .info
= stac92xx_mux_enum_info
,
4818 .get
= stac92xx_mux_enum_get
,
4819 .put
= stac92xx_mux_enum_put
,
4824 static struct hda_codec_ops stac9872_patch_ops
= {
4825 .build_controls
= stac92xx_build_controls
,
4826 .build_pcms
= stac92xx_build_pcms
,
4827 .init
= stac92xx_init
,
4828 .free
= stac92xx_free
,
4829 #ifdef SND_HDA_NEEDS_RESUME
4830 .resume
= stac92xx_resume
,
4834 static int stac9872_vaio_init(struct hda_codec
*codec
)
4838 err
= stac92xx_init(codec
);
4841 if (codec
->patch_ops
.unsol_event
)
4842 codec
->patch_ops
.unsol_event(codec
, STAC_HP_EVENT
<< 26);
4846 static void stac9872_vaio_hp_detect(struct hda_codec
*codec
, unsigned int res
)
4848 if (get_hp_pin_presence(codec
, 0x0a)) {
4849 stac92xx_reset_pinctl(codec
, 0x0f, AC_PINCTL_OUT_EN
);
4850 stac92xx_set_pinctl(codec
, 0x0a, AC_PINCTL_OUT_EN
);
4852 stac92xx_reset_pinctl(codec
, 0x0a, AC_PINCTL_OUT_EN
);
4853 stac92xx_set_pinctl(codec
, 0x0f, AC_PINCTL_OUT_EN
);
4857 static void stac9872_vaio_unsol_event(struct hda_codec
*codec
, unsigned int res
)
4859 switch (res
>> 26) {
4861 stac9872_vaio_hp_detect(codec
, res
);
4866 static struct hda_codec_ops stac9872_vaio_patch_ops
= {
4867 .build_controls
= stac92xx_build_controls
,
4868 .build_pcms
= stac92xx_build_pcms
,
4869 .init
= stac9872_vaio_init
,
4870 .free
= stac92xx_free
,
4871 .unsol_event
= stac9872_vaio_unsol_event
,
4873 .resume
= stac92xx_resume
,
4877 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4879 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4881 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4883 /* AR Series. id=0x83847664 and subsys=104D1300 */
4888 static const char *stac9872_models
[STAC_9872_MODELS
] = {
4889 [CXD9872RD_VAIO
] = "vaio",
4890 [CXD9872AKD_VAIO
] = "vaio-ar",
4893 static struct snd_pci_quirk stac9872_cfg_tbl
[] = {
4894 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO
),
4895 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO
),
4896 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO
),
4897 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO
),
4901 static int patch_stac9872(struct hda_codec
*codec
)
4903 struct sigmatel_spec
*spec
;
4906 board_config
= snd_hda_check_board_config(codec
, STAC_9872_MODELS
,
4909 if (board_config
< 0)
4910 /* unknown config, let generic-parser do its job... */
4911 return snd_hda_parse_generic_codec(codec
);
4913 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4918 switch (board_config
) {
4919 case CXD9872RD_VAIO
:
4920 case STAC9872AK_VAIO
:
4921 case STAC9872K_VAIO
:
4922 spec
->mixer
= vaio_mixer
;
4923 spec
->init
= vaio_init
;
4924 spec
->multiout
.max_channels
= 2;
4925 spec
->multiout
.num_dacs
= ARRAY_SIZE(vaio_dacs
);
4926 spec
->multiout
.dac_nids
= vaio_dacs
;
4927 spec
->multiout
.hp_nid
= VAIO_HP_DAC
;
4928 spec
->num_adcs
= ARRAY_SIZE(vaio_adcs
);
4929 spec
->adc_nids
= vaio_adcs
;
4931 spec
->input_mux
= &vaio_mux
;
4932 spec
->mux_nids
= vaio_mux_nids
;
4933 codec
->patch_ops
= stac9872_vaio_patch_ops
;
4936 case CXD9872AKD_VAIO
:
4937 spec
->mixer
= vaio_ar_mixer
;
4938 spec
->init
= vaio_ar_init
;
4939 spec
->multiout
.max_channels
= 2;
4940 spec
->multiout
.num_dacs
= ARRAY_SIZE(vaio_dacs
);
4941 spec
->multiout
.dac_nids
= vaio_dacs
;
4942 spec
->multiout
.hp_nid
= VAIO_HP_DAC
;
4943 spec
->num_adcs
= ARRAY_SIZE(vaio_adcs
);
4945 spec
->adc_nids
= vaio_adcs
;
4946 spec
->input_mux
= &vaio_mux
;
4947 spec
->mux_nids
= vaio_mux_nids
;
4948 codec
->patch_ops
= stac9872_patch_ops
;
4959 struct hda_codec_preset snd_hda_preset_sigmatel
[] = {
4960 { .id
= 0x83847690, .name
= "STAC9200", .patch
= patch_stac9200
},
4961 { .id
= 0x83847882, .name
= "STAC9220 A1", .patch
= patch_stac922x
},
4962 { .id
= 0x83847680, .name
= "STAC9221 A1", .patch
= patch_stac922x
},
4963 { .id
= 0x83847880, .name
= "STAC9220 A2", .patch
= patch_stac922x
},
4964 { .id
= 0x83847681, .name
= "STAC9220D/9223D A2", .patch
= patch_stac922x
},
4965 { .id
= 0x83847682, .name
= "STAC9221 A2", .patch
= patch_stac922x
},
4966 { .id
= 0x83847683, .name
= "STAC9221D A2", .patch
= patch_stac922x
},
4967 { .id
= 0x83847618, .name
= "STAC9227", .patch
= patch_stac927x
},
4968 { .id
= 0x83847619, .name
= "STAC9227", .patch
= patch_stac927x
},
4969 { .id
= 0x83847616, .name
= "STAC9228", .patch
= patch_stac927x
},
4970 { .id
= 0x83847617, .name
= "STAC9228", .patch
= patch_stac927x
},
4971 { .id
= 0x83847614, .name
= "STAC9229", .patch
= patch_stac927x
},
4972 { .id
= 0x83847615, .name
= "STAC9229", .patch
= patch_stac927x
},
4973 { .id
= 0x83847620, .name
= "STAC9274", .patch
= patch_stac927x
},
4974 { .id
= 0x83847621, .name
= "STAC9274D", .patch
= patch_stac927x
},
4975 { .id
= 0x83847622, .name
= "STAC9273X", .patch
= patch_stac927x
},
4976 { .id
= 0x83847623, .name
= "STAC9273D", .patch
= patch_stac927x
},
4977 { .id
= 0x83847624, .name
= "STAC9272X", .patch
= patch_stac927x
},
4978 { .id
= 0x83847625, .name
= "STAC9272D", .patch
= patch_stac927x
},
4979 { .id
= 0x83847626, .name
= "STAC9271X", .patch
= patch_stac927x
},
4980 { .id
= 0x83847627, .name
= "STAC9271D", .patch
= patch_stac927x
},
4981 { .id
= 0x83847628, .name
= "STAC9274X5NH", .patch
= patch_stac927x
},
4982 { .id
= 0x83847629, .name
= "STAC9274D5NH", .patch
= patch_stac927x
},
4983 { .id
= 0x83847632, .name
= "STAC9202", .patch
= patch_stac925x
},
4984 { .id
= 0x83847633, .name
= "STAC9202D", .patch
= patch_stac925x
},
4985 { .id
= 0x83847634, .name
= "STAC9250", .patch
= patch_stac925x
},
4986 { .id
= 0x83847635, .name
= "STAC9250D", .patch
= patch_stac925x
},
4987 { .id
= 0x83847636, .name
= "STAC9251", .patch
= patch_stac925x
},
4988 { .id
= 0x83847637, .name
= "STAC9250D", .patch
= patch_stac925x
},
4989 { .id
= 0x83847645, .name
= "92HD206X", .patch
= patch_stac927x
},
4990 { .id
= 0x83847646, .name
= "92HD206D", .patch
= patch_stac927x
},
4991 /* The following does not take into account .id=0x83847661 when subsys =
4992 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4993 * currently not fully supported.
4995 { .id
= 0x83847661, .name
= "CXD9872RD/K", .patch
= patch_stac9872
},
4996 { .id
= 0x83847662, .name
= "STAC9872AK", .patch
= patch_stac9872
},
4997 { .id
= 0x83847664, .name
= "CXD9872AKD", .patch
= patch_stac9872
},
4998 { .id
= 0x838476a0, .name
= "STAC9205", .patch
= patch_stac9205
},
4999 { .id
= 0x838476a1, .name
= "STAC9205D", .patch
= patch_stac9205
},
5000 { .id
= 0x838476a2, .name
= "STAC9204", .patch
= patch_stac9205
},
5001 { .id
= 0x838476a3, .name
= "STAC9204D", .patch
= patch_stac9205
},
5002 { .id
= 0x838476a4, .name
= "STAC9255", .patch
= patch_stac9205
},
5003 { .id
= 0x838476a5, .name
= "STAC9255D", .patch
= patch_stac9205
},
5004 { .id
= 0x838476a6, .name
= "STAC9254", .patch
= patch_stac9205
},
5005 { .id
= 0x838476a7, .name
= "STAC9254D", .patch
= patch_stac9205
},
5006 { .id
= 0x111d7603, .name
= "92HD75B3X5", .patch
= patch_stac92hd71bxx
},
5007 { .id
= 0x111d7604, .name
= "92HD83C1X5", .patch
= patch_stac92hd83xxx
},
5008 { .id
= 0x111d7605, .name
= "92HD81B1X5", .patch
= patch_stac92hd83xxx
},
5009 { .id
= 0x111d7608, .name
= "92HD75B2X5", .patch
= patch_stac92hd71bxx
},
5010 { .id
= 0x111d7674, .name
= "92HD73D1X5", .patch
= patch_stac92hd73xx
},
5011 { .id
= 0x111d7675, .name
= "92HD73C1X5", .patch
= patch_stac92hd73xx
},
5012 { .id
= 0x111d7676, .name
= "92HD73E1X5", .patch
= patch_stac92hd73xx
},
5013 { .id
= 0x111d76b0, .name
= "92HD71B8X", .patch
= patch_stac92hd71bxx
},
5014 { .id
= 0x111d76b1, .name
= "92HD71B8X", .patch
= patch_stac92hd71bxx
},
5015 { .id
= 0x111d76b2, .name
= "92HD71B7X", .patch
= patch_stac92hd71bxx
},
5016 { .id
= 0x111d76b3, .name
= "92HD71B7X", .patch
= patch_stac92hd71bxx
},
5017 { .id
= 0x111d76b4, .name
= "92HD71B6X", .patch
= patch_stac92hd71bxx
},
5018 { .id
= 0x111d76b5, .name
= "92HD71B6X", .patch
= patch_stac92hd71bxx
},
5019 { .id
= 0x111d76b6, .name
= "92HD71B5X", .patch
= patch_stac92hd71bxx
},
5020 { .id
= 0x111d76b7, .name
= "92HD71B5X", .patch
= patch_stac92hd71bxx
},