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 <sound/jack.h>
34 #include "hda_codec.h"
35 #include "hda_local.h"
73 STAC_92HD73XX_NO_JD
, /* no jack-detection */
117 STAC_INTEL_MAC_AUTO
, /* This model is selected if no module parameter
118 * is given, one of the above models will be
119 * chosen according to the subsystem id. */
120 /* for backward compatibility */
136 STAC_D965_REF_NO_JD
, /* no jack-detection */
145 struct sigmatel_event
{
152 struct sigmatel_jack
{
155 struct snd_jack
*jack
;
158 struct sigmatel_spec
{
159 struct snd_kcontrol_new
*mixers
[4];
160 unsigned int num_mixers
;
163 unsigned int eapd_switch
: 1;
164 unsigned int surr_switch
: 1;
165 unsigned int alt_switch
: 1;
166 unsigned int hp_detect
: 1;
167 unsigned int spdif_mute
: 1;
170 unsigned int eapd_mask
;
171 unsigned int gpio_mask
;
172 unsigned int gpio_dir
;
173 unsigned int gpio_data
;
174 unsigned int gpio_mute
;
177 unsigned int stream_delay
;
179 /* analog loopback */
180 unsigned char aloopback_mask
;
181 unsigned char aloopback_shift
;
183 /* power management */
184 unsigned int num_pwrs
;
185 unsigned int *pwr_mapping
;
190 struct snd_array jacks
;
193 struct snd_array events
;
196 struct hda_input_mux
*mono_mux
;
197 struct hda_input_mux
*amp_mux
;
198 unsigned int cur_mmux
;
199 struct hda_multi_out multiout
;
200 hda_nid_t dac_nids
[5];
201 hda_nid_t hp_dacs
[5];
202 hda_nid_t speaker_dacs
[5];
206 unsigned int num_adcs
;
208 unsigned int num_muxes
;
209 hda_nid_t
*dmic_nids
;
210 unsigned int num_dmics
;
211 hda_nid_t
*dmux_nids
;
212 unsigned int num_dmuxes
;
213 hda_nid_t
*smux_nids
;
214 unsigned int num_smuxes
;
215 const char **spdif_labels
;
217 hda_nid_t dig_in_nid
;
219 hda_nid_t anabeep_nid
;
220 hda_nid_t digbeep_nid
;
224 unsigned int num_pins
;
225 unsigned int *pin_configs
;
227 /* codec specific stuff */
228 struct hda_verb
*init
;
229 struct snd_kcontrol_new
*mixer
;
232 struct hda_input_mux
*dinput_mux
;
233 unsigned int cur_dmux
[2];
234 struct hda_input_mux
*input_mux
;
235 unsigned int cur_mux
[3];
236 struct hda_input_mux
*sinput_mux
;
237 unsigned int cur_smux
[2];
238 unsigned int cur_amux
;
240 unsigned int num_amps
;
241 unsigned int powerdown_adcs
;
244 unsigned int io_switch
[2];
245 unsigned int clfe_swap
;
246 hda_nid_t line_switch
; /* shared line-in for input and output */
247 hda_nid_t mic_switch
; /* shared mic-in for input and output */
248 hda_nid_t hp_switch
; /* NID of HP as line-out */
249 unsigned int aloopback
;
251 struct hda_pcm pcm_rec
[2]; /* PCM information */
253 /* dynamic controls and input_mux */
254 struct auto_pin_cfg autocfg
;
255 struct snd_array kctls
;
256 struct hda_input_mux private_dimux
;
257 struct hda_input_mux private_imux
;
258 struct hda_input_mux private_smux
;
259 struct hda_input_mux private_amp_mux
;
260 struct hda_input_mux private_mono_mux
;
263 static hda_nid_t stac9200_adc_nids
[1] = {
267 static hda_nid_t stac9200_mux_nids
[1] = {
271 static hda_nid_t stac9200_dac_nids
[1] = {
275 static hda_nid_t stac92hd73xx_pwr_nids
[8] = {
276 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
280 static hda_nid_t stac92hd73xx_slave_dig_outs
[2] = {
284 static hda_nid_t stac92hd73xx_adc_nids
[2] = {
288 #define DELL_M6_AMP 2
289 static hda_nid_t stac92hd73xx_amp_nids
[3] = {
293 #define STAC92HD73XX_NUM_DMICS 2
294 static hda_nid_t stac92hd73xx_dmic_nids
[STAC92HD73XX_NUM_DMICS
+ 1] = {
298 #define STAC92HD73_DAC_COUNT 5
300 static hda_nid_t stac92hd73xx_mux_nids
[4] = {
301 0x28, 0x29, 0x2a, 0x2b,
304 static hda_nid_t stac92hd73xx_dmux_nids
[2] = {
308 static hda_nid_t stac92hd73xx_smux_nids
[2] = {
312 #define STAC92HD83XXX_NUM_DMICS 2
313 static hda_nid_t stac92hd83xxx_dmic_nids
[STAC92HD83XXX_NUM_DMICS
+ 1] = {
317 #define STAC92HD83_DAC_COUNT 3
319 static hda_nid_t stac92hd83xxx_dmux_nids
[2] = {
323 static hda_nid_t stac92hd83xxx_adc_nids
[2] = {
327 static hda_nid_t stac92hd83xxx_pwr_nids
[4] = {
331 static hda_nid_t stac92hd83xxx_slave_dig_outs
[2] = {
335 static unsigned int stac92hd83xxx_pwr_mapping
[4] = {
336 0x03, 0x0c, 0x10, 0x40,
339 static hda_nid_t stac92hd71bxx_pwr_nids
[3] = {
343 static hda_nid_t stac92hd71bxx_adc_nids
[2] = {
347 static hda_nid_t stac92hd71bxx_mux_nids
[2] = {
351 static hda_nid_t stac92hd71bxx_dmux_nids
[2] = {
355 static hda_nid_t stac92hd71bxx_smux_nids
[2] = {
359 #define STAC92HD71BXX_NUM_DMICS 2
360 static hda_nid_t stac92hd71bxx_dmic_nids
[STAC92HD71BXX_NUM_DMICS
+ 1] = {
364 static hda_nid_t stac92hd71bxx_slave_dig_outs
[2] = {
368 static hda_nid_t stac925x_adc_nids
[1] = {
372 static hda_nid_t stac925x_mux_nids
[1] = {
376 static hda_nid_t stac925x_dac_nids
[1] = {
380 #define STAC925X_NUM_DMICS 1
381 static hda_nid_t stac925x_dmic_nids
[STAC925X_NUM_DMICS
+ 1] = {
385 static hda_nid_t stac925x_dmux_nids
[1] = {
389 static hda_nid_t stac922x_adc_nids
[2] = {
393 static hda_nid_t stac922x_mux_nids
[2] = {
397 static hda_nid_t stac927x_adc_nids
[3] = {
401 static hda_nid_t stac927x_mux_nids
[3] = {
405 static hda_nid_t stac927x_smux_nids
[1] = {
409 static hda_nid_t stac927x_dac_nids
[6] = {
410 0x02, 0x03, 0x04, 0x05, 0x06, 0
413 static hda_nid_t stac927x_dmux_nids
[1] = {
417 #define STAC927X_NUM_DMICS 2
418 static hda_nid_t stac927x_dmic_nids
[STAC927X_NUM_DMICS
+ 1] = {
422 static const char *stac927x_spdif_labels
[5] = {
423 "Digital Playback", "ADAT", "Analog Mux 1",
424 "Analog Mux 2", "Analog Mux 3"
427 static hda_nid_t stac9205_adc_nids
[2] = {
431 static hda_nid_t stac9205_mux_nids
[2] = {
435 static hda_nid_t stac9205_dmux_nids
[1] = {
439 static hda_nid_t stac9205_smux_nids
[1] = {
443 #define STAC9205_NUM_DMICS 2
444 static hda_nid_t stac9205_dmic_nids
[STAC9205_NUM_DMICS
+ 1] = {
448 static hda_nid_t stac9200_pin_nids
[8] = {
449 0x08, 0x09, 0x0d, 0x0e,
450 0x0f, 0x10, 0x11, 0x12,
453 static hda_nid_t stac925x_pin_nids
[8] = {
454 0x07, 0x08, 0x0a, 0x0b,
455 0x0c, 0x0d, 0x10, 0x11,
458 static hda_nid_t stac922x_pin_nids
[10] = {
459 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
460 0x0f, 0x10, 0x11, 0x15, 0x1b,
463 static hda_nid_t stac92hd73xx_pin_nids
[13] = {
464 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
465 0x0f, 0x10, 0x11, 0x12, 0x13,
469 static hda_nid_t stac92hd83xxx_pin_nids
[14] = {
470 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
471 0x0f, 0x10, 0x11, 0x12, 0x13,
472 0x1d, 0x1e, 0x1f, 0x20
474 static hda_nid_t stac92hd71bxx_pin_nids
[11] = {
475 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
476 0x0f, 0x14, 0x18, 0x19, 0x1e,
480 static hda_nid_t stac927x_pin_nids
[14] = {
481 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
482 0x0f, 0x10, 0x11, 0x12, 0x13,
483 0x14, 0x21, 0x22, 0x23,
486 static hda_nid_t stac9205_pin_nids
[12] = {
487 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
488 0x0f, 0x14, 0x16, 0x17, 0x18,
492 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
494 static int stac92xx_amp_volume_get(struct snd_kcontrol
*kcontrol
,
495 struct snd_ctl_elem_value
*ucontrol
)
497 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
498 struct sigmatel_spec
*spec
= codec
->spec
;
499 hda_nid_t nid
= spec
->amp_nids
[spec
->cur_amux
];
501 kcontrol
->private_value
^= get_amp_nid(kcontrol
);
502 kcontrol
->private_value
|= nid
;
504 return snd_hda_mixer_amp_volume_get(kcontrol
, ucontrol
);
507 static int stac92xx_amp_volume_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 hda_nid_t nid
= spec
->amp_nids
[spec
->cur_amux
];
514 kcontrol
->private_value
^= get_amp_nid(kcontrol
);
515 kcontrol
->private_value
|= nid
;
517 return snd_hda_mixer_amp_volume_put(kcontrol
, ucontrol
);
520 static int stac92xx_dmux_enum_info(struct snd_kcontrol
*kcontrol
,
521 struct snd_ctl_elem_info
*uinfo
)
523 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
524 struct sigmatel_spec
*spec
= codec
->spec
;
525 return snd_hda_input_mux_info(spec
->dinput_mux
, uinfo
);
528 static int stac92xx_dmux_enum_get(struct snd_kcontrol
*kcontrol
,
529 struct snd_ctl_elem_value
*ucontrol
)
531 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
532 struct sigmatel_spec
*spec
= codec
->spec
;
533 unsigned int dmux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
535 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_dmux
[dmux_idx
];
539 static int stac92xx_dmux_enum_put(struct snd_kcontrol
*kcontrol
,
540 struct snd_ctl_elem_value
*ucontrol
)
542 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
543 struct sigmatel_spec
*spec
= codec
->spec
;
544 unsigned int dmux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
546 return snd_hda_input_mux_put(codec
, spec
->dinput_mux
, ucontrol
,
547 spec
->dmux_nids
[dmux_idx
], &spec
->cur_dmux
[dmux_idx
]);
550 static int stac92xx_smux_enum_info(struct snd_kcontrol
*kcontrol
,
551 struct snd_ctl_elem_info
*uinfo
)
553 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
554 struct sigmatel_spec
*spec
= codec
->spec
;
555 return snd_hda_input_mux_info(spec
->sinput_mux
, uinfo
);
558 static int stac92xx_smux_enum_get(struct snd_kcontrol
*kcontrol
,
559 struct snd_ctl_elem_value
*ucontrol
)
561 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
562 struct sigmatel_spec
*spec
= codec
->spec
;
563 unsigned int smux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
565 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_smux
[smux_idx
];
569 static int stac92xx_smux_enum_put(struct snd_kcontrol
*kcontrol
,
570 struct snd_ctl_elem_value
*ucontrol
)
572 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
573 struct sigmatel_spec
*spec
= codec
->spec
;
574 struct hda_input_mux
*smux
= &spec
->private_smux
;
575 unsigned int smux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
579 err
= snd_hda_input_mux_put(codec
, spec
->sinput_mux
, ucontrol
,
580 spec
->smux_nids
[smux_idx
], &spec
->cur_smux
[smux_idx
]);
584 if (spec
->spdif_mute
) {
586 nid
= spec
->multiout
.dig_out_nid
;
588 nid
= codec
->slave_dig_outs
[smux_idx
- 1];
589 if (spec
->cur_smux
[smux_idx
] == smux
->num_items
- 1)
593 /* un/mute SPDIF out */
594 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
600 static int stac92xx_mux_enum_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
602 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
603 struct sigmatel_spec
*spec
= codec
->spec
;
604 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
607 static int stac92xx_mux_enum_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
609 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
610 struct sigmatel_spec
*spec
= codec
->spec
;
611 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
613 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
617 static int stac92xx_mux_enum_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
619 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
620 struct sigmatel_spec
*spec
= codec
->spec
;
621 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
623 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
624 spec
->mux_nids
[adc_idx
], &spec
->cur_mux
[adc_idx
]);
627 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol
*kcontrol
,
628 struct snd_ctl_elem_info
*uinfo
)
630 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
631 struct sigmatel_spec
*spec
= codec
->spec
;
632 return snd_hda_input_mux_info(spec
->mono_mux
, uinfo
);
635 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol
*kcontrol
,
636 struct snd_ctl_elem_value
*ucontrol
)
638 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
639 struct sigmatel_spec
*spec
= codec
->spec
;
641 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mmux
;
645 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol
*kcontrol
,
646 struct snd_ctl_elem_value
*ucontrol
)
648 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
649 struct sigmatel_spec
*spec
= codec
->spec
;
651 return snd_hda_input_mux_put(codec
, spec
->mono_mux
, ucontrol
,
652 spec
->mono_nid
, &spec
->cur_mmux
);
655 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol
*kcontrol
,
656 struct snd_ctl_elem_info
*uinfo
)
658 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
659 struct sigmatel_spec
*spec
= codec
->spec
;
660 return snd_hda_input_mux_info(spec
->amp_mux
, uinfo
);
663 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol
*kcontrol
,
664 struct snd_ctl_elem_value
*ucontrol
)
666 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
667 struct sigmatel_spec
*spec
= codec
->spec
;
669 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_amux
;
673 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol
*kcontrol
,
674 struct snd_ctl_elem_value
*ucontrol
)
676 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
677 struct sigmatel_spec
*spec
= codec
->spec
;
678 struct snd_kcontrol
*ctl
=
679 snd_hda_find_mixer_ctl(codec
, "Amp Capture Volume");
683 snd_ctl_notify(codec
->bus
->card
, SNDRV_CTL_EVENT_MASK_VALUE
|
684 SNDRV_CTL_EVENT_MASK_INFO
, &ctl
->id
);
686 return snd_hda_input_mux_put(codec
, spec
->amp_mux
, ucontrol
,
690 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
692 static int stac92xx_aloopback_get(struct snd_kcontrol
*kcontrol
,
693 struct snd_ctl_elem_value
*ucontrol
)
695 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
696 unsigned int idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
697 struct sigmatel_spec
*spec
= codec
->spec
;
699 ucontrol
->value
.integer
.value
[0] = !!(spec
->aloopback
&
700 (spec
->aloopback_mask
<< idx
));
704 static int stac92xx_aloopback_put(struct snd_kcontrol
*kcontrol
,
705 struct snd_ctl_elem_value
*ucontrol
)
707 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
708 struct sigmatel_spec
*spec
= codec
->spec
;
709 unsigned int idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
710 unsigned int dac_mode
;
711 unsigned int val
, idx_val
;
713 idx_val
= spec
->aloopback_mask
<< idx
;
714 if (ucontrol
->value
.integer
.value
[0])
715 val
= spec
->aloopback
| idx_val
;
717 val
= spec
->aloopback
& ~idx_val
;
718 if (spec
->aloopback
== val
)
721 spec
->aloopback
= val
;
723 /* Only return the bits defined by the shift value of the
724 * first two bytes of the mask
726 dac_mode
= snd_hda_codec_read(codec
, codec
->afg
, 0,
727 kcontrol
->private_value
& 0xFFFF, 0x0);
728 dac_mode
>>= spec
->aloopback_shift
;
730 if (spec
->aloopback
& idx_val
) {
731 snd_hda_power_up(codec
);
734 snd_hda_power_down(codec
);
735 dac_mode
&= ~idx_val
;
738 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
739 kcontrol
->private_value
>> 16, dac_mode
);
744 static struct hda_verb stac9200_core_init
[] = {
745 /* set dac0mux for dac converter */
746 { 0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
750 static struct hda_verb stac9200_eapd_init
[] = {
751 /* set dac0mux for dac converter */
752 {0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
753 {0x08, AC_VERB_SET_EAPD_BTLENABLE
, 0x02},
757 static struct hda_verb stac92hd73xx_6ch_core_init
[] = {
758 /* set master volume and direct control */
759 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
760 /* setup adcs to point to mixer */
761 { 0x20, AC_VERB_SET_CONNECT_SEL
, 0x0b},
762 { 0x21, AC_VERB_SET_CONNECT_SEL
, 0x0b},
763 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
764 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
765 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
766 /* setup import muxs */
767 { 0x28, AC_VERB_SET_CONNECT_SEL
, 0x01},
768 { 0x29, AC_VERB_SET_CONNECT_SEL
, 0x01},
769 { 0x2a, AC_VERB_SET_CONNECT_SEL
, 0x01},
770 { 0x2b, AC_VERB_SET_CONNECT_SEL
, 0x00},
774 static struct hda_verb dell_eq_core_init
[] = {
775 /* set master volume to max value without distortion
776 * and direct control */
777 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xec},
778 /* setup adcs to point to mixer */
779 { 0x20, AC_VERB_SET_CONNECT_SEL
, 0x0b},
780 { 0x21, AC_VERB_SET_CONNECT_SEL
, 0x0b},
781 /* setup import muxs */
782 { 0x28, AC_VERB_SET_CONNECT_SEL
, 0x01},
783 { 0x29, AC_VERB_SET_CONNECT_SEL
, 0x01},
784 { 0x2a, AC_VERB_SET_CONNECT_SEL
, 0x01},
785 { 0x2b, AC_VERB_SET_CONNECT_SEL
, 0x00},
789 static struct hda_verb dell_m6_core_init
[] = {
790 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
791 /* setup adcs to point to mixer */
792 { 0x20, AC_VERB_SET_CONNECT_SEL
, 0x0b},
793 { 0x21, AC_VERB_SET_CONNECT_SEL
, 0x0b},
794 /* setup import muxs */
795 { 0x28, AC_VERB_SET_CONNECT_SEL
, 0x01},
796 { 0x29, AC_VERB_SET_CONNECT_SEL
, 0x01},
797 { 0x2a, AC_VERB_SET_CONNECT_SEL
, 0x01},
798 { 0x2b, AC_VERB_SET_CONNECT_SEL
, 0x00},
802 static struct hda_verb stac92hd73xx_8ch_core_init
[] = {
803 /* set master volume and direct control */
804 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
805 /* setup adcs to point to mixer */
806 { 0x20, AC_VERB_SET_CONNECT_SEL
, 0x0b},
807 { 0x21, AC_VERB_SET_CONNECT_SEL
, 0x0b},
808 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
809 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
810 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
811 /* setup import muxs */
812 { 0x28, AC_VERB_SET_CONNECT_SEL
, 0x01},
813 { 0x29, AC_VERB_SET_CONNECT_SEL
, 0x01},
814 { 0x2a, AC_VERB_SET_CONNECT_SEL
, 0x01},
815 { 0x2b, AC_VERB_SET_CONNECT_SEL
, 0x03},
819 static struct hda_verb stac92hd73xx_10ch_core_init
[] = {
820 /* set master volume and direct control */
821 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
822 /* dac3 is connected to import3 mux */
823 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb07f},
824 /* setup adcs to point to mixer */
825 { 0x20, AC_VERB_SET_CONNECT_SEL
, 0x0b},
826 { 0x21, AC_VERB_SET_CONNECT_SEL
, 0x0b},
827 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
828 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
829 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
830 /* setup import muxs */
831 { 0x28, AC_VERB_SET_CONNECT_SEL
, 0x01},
832 { 0x29, AC_VERB_SET_CONNECT_SEL
, 0x01},
833 { 0x2a, AC_VERB_SET_CONNECT_SEL
, 0x01},
834 { 0x2b, AC_VERB_SET_CONNECT_SEL
, 0x03},
838 static struct hda_verb stac92hd83xxx_core_init
[] = {
839 /* start of config #1 */
840 { 0xe, AC_VERB_SET_CONNECT_SEL
, 0x3},
842 /* start of config #2 */
843 { 0xa, AC_VERB_SET_CONNECT_SEL
, 0x0},
844 { 0xb, AC_VERB_SET_CONNECT_SEL
, 0x0},
845 { 0xd, AC_VERB_SET_CONNECT_SEL
, 0x1},
847 /* power state controls amps */
848 { 0x01, AC_VERB_SET_EAPD
, 1 << 2},
852 static struct hda_verb stac92hd71bxx_core_init
[] = {
853 /* set master volume and direct control */
854 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
855 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
856 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
857 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
858 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
862 #define HD_DISABLE_PORTF 2
863 static struct hda_verb stac92hd71bxx_analog_core_init
[] = {
864 /* start of config #1 */
866 /* connect port 0f to audio mixer */
867 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x2},
868 /* unmute right and left channels for node 0x0f */
869 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
870 /* start of config #2 */
872 /* set master volume and direct control */
873 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
874 /* unmute right and left channels for nodes 0x0a, 0xd */
875 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
876 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
880 static struct hda_verb stac925x_core_init
[] = {
881 /* set dac0mux for dac converter */
882 { 0x06, AC_VERB_SET_CONNECT_SEL
, 0x00},
886 static struct hda_verb stac922x_core_init
[] = {
887 /* set master volume and direct control */
888 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
892 static struct hda_verb d965_core_init
[] = {
893 /* set master volume and direct control */
894 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
895 /* unmute node 0x1b */
896 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
897 /* select node 0x03 as DAC */
898 { 0x0b, AC_VERB_SET_CONNECT_SEL
, 0x01},
902 static struct hda_verb stac927x_core_init
[] = {
903 /* set master volume and direct control */
904 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
905 /* enable analog pc beep path */
906 { 0x01, AC_VERB_SET_DIGI_CONVERT_2
, 1 << 5},
910 static struct hda_verb stac9205_core_init
[] = {
911 /* set master volume and direct control */
912 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
913 /* enable analog pc beep path */
914 { 0x01, AC_VERB_SET_DIGI_CONVERT_2
, 1 << 5},
918 #define STAC_MONO_MUX \
920 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
921 .name = "Mono Mux", \
923 .info = stac92xx_mono_mux_enum_info, \
924 .get = stac92xx_mono_mux_enum_get, \
925 .put = stac92xx_mono_mux_enum_put, \
928 #define STAC_AMP_MUX \
930 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
931 .name = "Amp Selector Capture Switch", \
933 .info = stac92xx_amp_mux_enum_info, \
934 .get = stac92xx_amp_mux_enum_get, \
935 .put = stac92xx_amp_mux_enum_put, \
938 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
940 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
943 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
944 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
945 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
946 .info = stac92xx_amp_volume_info, \
947 .get = stac92xx_amp_volume_get, \
948 .put = stac92xx_amp_volume_put, \
949 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
950 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
953 #define STAC_INPUT_SOURCE(cnt) \
955 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
956 .name = "Input Source", \
958 .info = stac92xx_mux_enum_info, \
959 .get = stac92xx_mux_enum_get, \
960 .put = stac92xx_mux_enum_put, \
963 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
966 .name = "Analog Loopback", \
968 .info = stac92xx_aloopback_info, \
969 .get = stac92xx_aloopback_get, \
970 .put = stac92xx_aloopback_put, \
971 .private_value = verb_read | (verb_write << 16), \
974 static struct snd_kcontrol_new stac9200_mixer
[] = {
975 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT
),
976 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT
),
977 STAC_INPUT_SOURCE(1),
978 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT
),
979 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT
),
983 #define DELL_M6_MIXER 6
984 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer
[] = {
985 /* start of config #1 */
986 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT
),
987 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT
),
989 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT
),
990 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT
),
992 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT
),
993 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT
),
995 /* start of config #2 */
996 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT
),
997 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT
),
999 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT
),
1000 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT
),
1002 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1004 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT
),
1005 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT
),
1007 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT
),
1008 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT
),
1013 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer
[] = {
1014 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1016 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT
),
1017 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT
),
1019 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT
),
1020 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT
),
1022 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT
),
1023 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT
),
1025 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT
),
1026 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT
),
1028 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT
),
1029 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT
),
1031 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT
),
1032 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT
),
1034 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT
),
1035 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT
),
1039 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer
[] = {
1040 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1042 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT
),
1043 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT
),
1045 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT
),
1046 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT
),
1048 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT
),
1049 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT
),
1051 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT
),
1052 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT
),
1054 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT
),
1055 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT
),
1057 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT
),
1058 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT
),
1060 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT
),
1061 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT
),
1066 static struct snd_kcontrol_new stac92hd83xxx_mixer
[] = {
1067 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT
),
1068 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT
),
1070 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT
),
1071 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT
),
1073 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT
),
1074 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT
),
1076 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT
),
1077 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT
),
1079 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT
),
1080 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT
),
1082 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT
),
1083 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT
),
1086 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1087 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
1092 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer
[] = {
1093 STAC_INPUT_SOURCE(2),
1094 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1096 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT
),
1097 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT
),
1099 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT
),
1100 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT
),
1101 /* analog pc-beep replaced with digital beep support */
1103 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1104 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1107 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT
),
1108 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT
),
1110 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT
),
1111 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT
),
1113 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT
),
1114 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT
),
1116 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT
),
1117 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT
),
1121 static struct snd_kcontrol_new stac92hd71bxx_mixer
[] = {
1122 STAC_INPUT_SOURCE(2),
1123 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1125 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT
),
1126 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT
),
1128 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT
),
1129 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT
),
1133 static struct snd_kcontrol_new stac925x_mixer
[] = {
1134 STAC_INPUT_SOURCE(1),
1135 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT
),
1136 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT
),
1140 static struct snd_kcontrol_new stac9205_mixer
[] = {
1141 STAC_INPUT_SOURCE(2),
1142 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1144 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT
),
1145 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT
),
1147 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT
),
1148 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT
),
1152 /* This needs to be generated dynamically based on sequence */
1153 static struct snd_kcontrol_new stac922x_mixer
[] = {
1154 STAC_INPUT_SOURCE(2),
1155 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT
),
1156 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT
),
1158 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT
),
1159 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT
),
1164 static struct snd_kcontrol_new stac927x_mixer
[] = {
1165 STAC_INPUT_SOURCE(3),
1166 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1168 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT
),
1169 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT
),
1171 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT
),
1172 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT
),
1174 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT
),
1175 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT
),
1179 static struct snd_kcontrol_new stac_dmux_mixer
= {
1180 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1181 .name
= "Digital Input Source",
1182 /* count set later */
1183 .info
= stac92xx_dmux_enum_info
,
1184 .get
= stac92xx_dmux_enum_get
,
1185 .put
= stac92xx_dmux_enum_put
,
1188 static struct snd_kcontrol_new stac_smux_mixer
= {
1189 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1190 .name
= "IEC958 Playback Source",
1191 /* count set later */
1192 .info
= stac92xx_smux_enum_info
,
1193 .get
= stac92xx_smux_enum_get
,
1194 .put
= stac92xx_smux_enum_put
,
1197 static const char *slave_vols
[] = {
1198 "Front Playback Volume",
1199 "Surround Playback Volume",
1200 "Center Playback Volume",
1201 "LFE Playback Volume",
1202 "Side Playback Volume",
1203 "Headphone Playback Volume",
1204 "Headphone Playback Volume",
1205 "Speaker Playback Volume",
1206 "External Speaker Playback Volume",
1207 "Speaker2 Playback Volume",
1211 static const char *slave_sws
[] = {
1212 "Front Playback Switch",
1213 "Surround Playback Switch",
1214 "Center Playback Switch",
1215 "LFE Playback Switch",
1216 "Side Playback Switch",
1217 "Headphone Playback Switch",
1218 "Headphone Playback Switch",
1219 "Speaker Playback Switch",
1220 "External Speaker Playback Switch",
1221 "Speaker2 Playback Switch",
1222 "IEC958 Playback Switch",
1226 static void stac92xx_free_kctls(struct hda_codec
*codec
);
1227 static int stac92xx_add_jack(struct hda_codec
*codec
, hda_nid_t nid
, int type
);
1229 static int stac92xx_build_controls(struct hda_codec
*codec
)
1231 struct sigmatel_spec
*spec
= codec
->spec
;
1232 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1237 err
= snd_hda_add_new_ctls(codec
, spec
->mixer
);
1241 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1242 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
1246 if (spec
->num_dmuxes
> 0) {
1247 stac_dmux_mixer
.count
= spec
->num_dmuxes
;
1248 err
= snd_hda_ctl_add(codec
,
1249 snd_ctl_new1(&stac_dmux_mixer
, codec
));
1253 if (spec
->num_smuxes
> 0) {
1254 int wcaps
= get_wcaps(codec
, spec
->multiout
.dig_out_nid
);
1255 struct hda_input_mux
*smux
= &spec
->private_smux
;
1256 /* check for mute support on SPDIF out */
1257 if (wcaps
& AC_WCAP_OUT_AMP
) {
1258 smux
->items
[smux
->num_items
].label
= "Off";
1259 smux
->items
[smux
->num_items
].index
= 0;
1261 spec
->spdif_mute
= 1;
1263 stac_smux_mixer
.count
= spec
->num_smuxes
;
1264 err
= snd_hda_ctl_add(codec
,
1265 snd_ctl_new1(&stac_smux_mixer
, codec
));
1270 if (spec
->multiout
.dig_out_nid
) {
1271 err
= snd_hda_create_spdif_out_ctls(codec
, spec
->multiout
.dig_out_nid
);
1274 err
= snd_hda_create_spdif_share_sw(codec
,
1278 spec
->multiout
.share_spdif
= 1;
1280 if (spec
->dig_in_nid
&& !(spec
->gpio_dir
& 0x01)) {
1281 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
1286 /* if we have no master control, let's create it */
1287 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
1288 unsigned int vmaster_tlv
[4];
1289 snd_hda_set_vmaster_tlv(codec
, spec
->multiout
.dac_nids
[0],
1290 HDA_OUTPUT
, vmaster_tlv
);
1291 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
1292 vmaster_tlv
, slave_vols
);
1296 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
1297 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
1303 stac92xx_free_kctls(codec
); /* no longer needed */
1305 /* create jack input elements */
1306 if (spec
->hp_detect
) {
1307 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
1308 int type
= SND_JACK_HEADPHONE
;
1309 nid
= cfg
->hp_pins
[i
];
1310 /* jack detection */
1311 if (cfg
->hp_outs
== i
)
1312 type
|= SND_JACK_LINEOUT
;
1313 err
= stac92xx_add_jack(codec
, nid
, type
);
1318 for (i
= 0; i
< cfg
->line_outs
; i
++) {
1319 err
= stac92xx_add_jack(codec
, cfg
->line_out_pins
[i
],
1324 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
1325 nid
= cfg
->input_pins
[i
];
1327 err
= stac92xx_add_jack(codec
, nid
,
1328 SND_JACK_MICROPHONE
);
1337 static unsigned int ref9200_pin_configs
[8] = {
1338 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1339 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1342 static unsigned int gateway9200_m4_pin_configs
[8] = {
1343 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1344 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1346 static unsigned int gateway9200_m4_2_pin_configs
[8] = {
1347 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1348 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1352 STAC 9200 pin configs for
1357 static unsigned int dell9200_d21_pin_configs
[8] = {
1358 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1359 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1363 STAC 9200 pin configs for
1367 static unsigned int dell9200_d22_pin_configs
[8] = {
1368 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1369 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1373 STAC 9200 pin configs for
1374 102801C4 (Dell Dimension E310)
1381 static unsigned int dell9200_d23_pin_configs
[8] = {
1382 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1383 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1388 STAC 9200-32 pin configs for
1389 102801B5 (Dell Inspiron 630m)
1390 102801D8 (Dell Inspiron 640m)
1392 static unsigned int dell9200_m21_pin_configs
[8] = {
1393 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1394 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1398 STAC 9200-32 pin configs for
1399 102801C2 (Dell Latitude D620)
1401 102801CC (Dell Latitude D820)
1405 static unsigned int dell9200_m22_pin_configs
[8] = {
1406 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1407 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1411 STAC 9200-32 pin configs for
1412 102801CE (Dell XPS M1710)
1413 102801CF (Dell Precision M90)
1415 static unsigned int dell9200_m23_pin_configs
[8] = {
1416 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1417 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1421 STAC 9200-32 pin configs for
1424 102801CB (Dell Latitude 120L)
1427 static unsigned int dell9200_m24_pin_configs
[8] = {
1428 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1429 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1433 STAC 9200-32 pin configs for
1434 102801BD (Dell Inspiron E1505n)
1438 static unsigned int dell9200_m25_pin_configs
[8] = {
1439 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1440 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1444 STAC 9200-32 pin configs for
1445 102801F5 (Dell Inspiron 1501)
1448 static unsigned int dell9200_m26_pin_configs
[8] = {
1449 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1450 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1455 102801CD (Dell Inspiron E1705/9400)
1457 static unsigned int dell9200_m27_pin_configs
[8] = {
1458 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1459 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1462 static unsigned int oqo9200_pin_configs
[8] = {
1463 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1464 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1468 static unsigned int *stac9200_brd_tbl
[STAC_9200_MODELS
] = {
1469 [STAC_REF
] = ref9200_pin_configs
,
1470 [STAC_9200_OQO
] = oqo9200_pin_configs
,
1471 [STAC_9200_DELL_D21
] = dell9200_d21_pin_configs
,
1472 [STAC_9200_DELL_D22
] = dell9200_d22_pin_configs
,
1473 [STAC_9200_DELL_D23
] = dell9200_d23_pin_configs
,
1474 [STAC_9200_DELL_M21
] = dell9200_m21_pin_configs
,
1475 [STAC_9200_DELL_M22
] = dell9200_m22_pin_configs
,
1476 [STAC_9200_DELL_M23
] = dell9200_m23_pin_configs
,
1477 [STAC_9200_DELL_M24
] = dell9200_m24_pin_configs
,
1478 [STAC_9200_DELL_M25
] = dell9200_m25_pin_configs
,
1479 [STAC_9200_DELL_M26
] = dell9200_m26_pin_configs
,
1480 [STAC_9200_DELL_M27
] = dell9200_m27_pin_configs
,
1481 [STAC_9200_M4
] = gateway9200_m4_pin_configs
,
1482 [STAC_9200_M4_2
] = gateway9200_m4_2_pin_configs
,
1483 [STAC_9200_PANASONIC
] = ref9200_pin_configs
,
1486 static const char *stac9200_models
[STAC_9200_MODELS
] = {
1488 [STAC_9200_OQO
] = "oqo",
1489 [STAC_9200_DELL_D21
] = "dell-d21",
1490 [STAC_9200_DELL_D22
] = "dell-d22",
1491 [STAC_9200_DELL_D23
] = "dell-d23",
1492 [STAC_9200_DELL_M21
] = "dell-m21",
1493 [STAC_9200_DELL_M22
] = "dell-m22",
1494 [STAC_9200_DELL_M23
] = "dell-m23",
1495 [STAC_9200_DELL_M24
] = "dell-m24",
1496 [STAC_9200_DELL_M25
] = "dell-m25",
1497 [STAC_9200_DELL_M26
] = "dell-m26",
1498 [STAC_9200_DELL_M27
] = "dell-m27",
1499 [STAC_9200_M4
] = "gateway-m4",
1500 [STAC_9200_M4_2
] = "gateway-m4-2",
1501 [STAC_9200_PANASONIC
] = "panasonic",
1504 static struct snd_pci_quirk stac9200_cfg_tbl
[] = {
1505 /* SigmaTel reference board */
1506 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1507 "DFI LanParty", STAC_REF
),
1508 /* Dell laptops have BIOS problem */
1509 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01a8,
1510 "unknown Dell", STAC_9200_DELL_D21
),
1511 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01b5,
1512 "Dell Inspiron 630m", STAC_9200_DELL_M21
),
1513 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01bd,
1514 "Dell Inspiron E1505n", STAC_9200_DELL_M25
),
1515 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c0,
1516 "unknown Dell", STAC_9200_DELL_D22
),
1517 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c1,
1518 "unknown Dell", STAC_9200_DELL_D22
),
1519 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c2,
1520 "Dell Latitude D620", STAC_9200_DELL_M22
),
1521 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c5,
1522 "unknown Dell", STAC_9200_DELL_D23
),
1523 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c7,
1524 "unknown Dell", STAC_9200_DELL_D23
),
1525 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c8,
1526 "unknown Dell", STAC_9200_DELL_M22
),
1527 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c9,
1528 "unknown Dell", STAC_9200_DELL_M24
),
1529 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ca,
1530 "unknown Dell", STAC_9200_DELL_M24
),
1531 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cb,
1532 "Dell Latitude 120L", STAC_9200_DELL_M24
),
1533 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cc,
1534 "Dell Latitude D820", STAC_9200_DELL_M22
),
1535 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cd,
1536 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27
),
1537 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ce,
1538 "Dell XPS M1710", STAC_9200_DELL_M23
),
1539 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cf,
1540 "Dell Precision M90", STAC_9200_DELL_M23
),
1541 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d3,
1542 "unknown Dell", STAC_9200_DELL_M22
),
1543 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d4,
1544 "unknown Dell", STAC_9200_DELL_M22
),
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d6,
1546 "unknown Dell", STAC_9200_DELL_M22
),
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d8,
1548 "Dell Inspiron 640m", STAC_9200_DELL_M21
),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d9,
1550 "unknown Dell", STAC_9200_DELL_D23
),
1551 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01da,
1552 "unknown Dell", STAC_9200_DELL_D23
),
1553 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01de,
1554 "unknown Dell", STAC_9200_DELL_D21
),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01e3,
1556 "unknown Dell", STAC_9200_DELL_D23
),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01e8,
1558 "unknown Dell", STAC_9200_DELL_D21
),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ee,
1560 "unknown Dell", STAC_9200_DELL_M25
),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ef,
1562 "unknown Dell", STAC_9200_DELL_M25
),
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f5,
1564 "Dell Inspiron 1501", STAC_9200_DELL_M26
),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f6,
1566 "unknown Dell", STAC_9200_DELL_M26
),
1568 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC
),
1569 /* Gateway machines needs EAPD to be set on resume */
1570 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4
),
1571 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2
),
1572 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2
),
1574 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO
),
1578 static unsigned int ref925x_pin_configs
[8] = {
1579 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1580 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1583 static unsigned int stac925xM1_pin_configs
[8] = {
1584 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1585 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1588 static unsigned int stac925xM1_2_pin_configs
[8] = {
1589 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1590 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1593 static unsigned int stac925xM2_pin_configs
[8] = {
1594 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1595 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1598 static unsigned int stac925xM2_2_pin_configs
[8] = {
1599 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1600 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1603 static unsigned int stac925xM3_pin_configs
[8] = {
1604 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1605 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1608 static unsigned int stac925xM5_pin_configs
[8] = {
1609 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1610 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1613 static unsigned int stac925xM6_pin_configs
[8] = {
1614 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1615 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1618 static unsigned int *stac925x_brd_tbl
[STAC_925x_MODELS
] = {
1619 [STAC_REF
] = ref925x_pin_configs
,
1620 [STAC_M1
] = stac925xM1_pin_configs
,
1621 [STAC_M1_2
] = stac925xM1_2_pin_configs
,
1622 [STAC_M2
] = stac925xM2_pin_configs
,
1623 [STAC_M2_2
] = stac925xM2_2_pin_configs
,
1624 [STAC_M3
] = stac925xM3_pin_configs
,
1625 [STAC_M5
] = stac925xM5_pin_configs
,
1626 [STAC_M6
] = stac925xM6_pin_configs
,
1629 static const char *stac925x_models
[STAC_925x_MODELS
] = {
1632 [STAC_M1_2
] = "m1-2",
1634 [STAC_M2_2
] = "m2-2",
1640 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl
[] = {
1641 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2
),
1642 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5
),
1643 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1
),
1644 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2
),
1645 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2
),
1646 /* Not sure about the brand name for those */
1647 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1
),
1648 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3
),
1649 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6
),
1650 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2
),
1654 static struct snd_pci_quirk stac925x_cfg_tbl
[] = {
1655 /* SigmaTel reference board */
1656 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668, "DFI LanParty", STAC_REF
),
1657 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF
),
1659 /* Default table for unknown ID */
1660 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2
),
1665 static unsigned int ref92hd73xx_pin_configs
[13] = {
1666 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1667 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1668 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1672 static unsigned int dell_m6_pin_configs
[13] = {
1673 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1674 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1675 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1679 static unsigned int *stac92hd73xx_brd_tbl
[STAC_92HD73XX_MODELS
] = {
1680 [STAC_92HD73XX_REF
] = ref92hd73xx_pin_configs
,
1681 [STAC_DELL_M6_AMIC
] = dell_m6_pin_configs
,
1682 [STAC_DELL_M6_DMIC
] = dell_m6_pin_configs
,
1683 [STAC_DELL_M6_BOTH
] = dell_m6_pin_configs
,
1684 [STAC_DELL_EQ
] = dell_m6_pin_configs
,
1687 static const char *stac92hd73xx_models
[STAC_92HD73XX_MODELS
] = {
1688 [STAC_92HD73XX_NO_JD
] = "no-jd",
1689 [STAC_92HD73XX_REF
] = "ref",
1690 [STAC_DELL_M6_AMIC
] = "dell-m6-amic",
1691 [STAC_DELL_M6_DMIC
] = "dell-m6-dmic",
1692 [STAC_DELL_M6_BOTH
] = "dell-m6",
1693 [STAC_DELL_EQ
] = "dell-eq",
1696 static struct snd_pci_quirk stac92hd73xx_cfg_tbl
[] = {
1697 /* SigmaTel reference board */
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1699 "DFI LanParty", STAC_92HD73XX_REF
),
1700 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0254,
1701 "Dell Studio 1535", STAC_DELL_M6_DMIC
),
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0255,
1703 "unknown Dell", STAC_DELL_M6_DMIC
),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0256,
1705 "unknown Dell", STAC_DELL_M6_BOTH
),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0257,
1707 "unknown Dell", STAC_DELL_M6_BOTH
),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x025e,
1709 "unknown Dell", STAC_DELL_M6_AMIC
),
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x025f,
1711 "unknown Dell", STAC_DELL_M6_AMIC
),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0271,
1713 "unknown Dell", STAC_DELL_M6_DMIC
),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0272,
1715 "unknown Dell", STAC_DELL_M6_DMIC
),
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x029f,
1717 "Dell Studio 1537", STAC_DELL_M6_DMIC
),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02a0,
1719 "Dell Studio 17", STAC_DELL_M6_DMIC
),
1723 static unsigned int ref92hd83xxx_pin_configs
[14] = {
1724 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1725 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1726 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1727 0x01451160, 0x98560170,
1730 static unsigned int *stac92hd83xxx_brd_tbl
[STAC_92HD83XXX_MODELS
] = {
1731 [STAC_92HD83XXX_REF
] = ref92hd83xxx_pin_configs
,
1734 static const char *stac92hd83xxx_models
[STAC_92HD83XXX_MODELS
] = {
1735 [STAC_92HD83XXX_REF
] = "ref",
1738 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl
[] = {
1739 /* SigmaTel reference board */
1740 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1741 "DFI LanParty", STAC_92HD83XXX_REF
),
1745 static unsigned int ref92hd71bxx_pin_configs
[11] = {
1746 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1747 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1748 0x90a000f0, 0x01452050, 0x01452050,
1751 static unsigned int dell_m4_1_pin_configs
[11] = {
1752 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1753 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1754 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
1757 static unsigned int dell_m4_2_pin_configs
[11] = {
1758 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1759 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1760 0x40f000f0, 0x044413b0, 0x044413b0,
1763 static unsigned int dell_m4_3_pin_configs
[11] = {
1764 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1765 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1766 0x40f000f0, 0x044413b0, 0x044413b0,
1769 static unsigned int *stac92hd71bxx_brd_tbl
[STAC_92HD71BXX_MODELS
] = {
1770 [STAC_92HD71BXX_REF
] = ref92hd71bxx_pin_configs
,
1771 [STAC_DELL_M4_1
] = dell_m4_1_pin_configs
,
1772 [STAC_DELL_M4_2
] = dell_m4_2_pin_configs
,
1773 [STAC_DELL_M4_3
] = dell_m4_3_pin_configs
,
1774 [STAC_HP_M4
] = NULL
,
1777 static const char *stac92hd71bxx_models
[STAC_92HD71BXX_MODELS
] = {
1778 [STAC_92HD71BXX_REF
] = "ref",
1779 [STAC_DELL_M4_1
] = "dell-m4-1",
1780 [STAC_DELL_M4_2
] = "dell-m4-2",
1781 [STAC_DELL_M4_3
] = "dell-m4-3",
1782 [STAC_HP_M4
] = "hp-m4",
1785 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl
[] = {
1786 /* SigmaTel reference board */
1787 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1788 "DFI LanParty", STAC_92HD71BXX_REF
),
1789 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x30f2,
1790 "HP dv5", STAC_HP_M4
),
1791 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x30f4,
1792 "HP dv7", STAC_HP_M4
),
1793 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x30fc,
1794 "HP dv7", STAC_HP_M4
),
1795 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x3603,
1796 "HP dv5", STAC_HP_M4
),
1797 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x361a,
1798 "unknown HP", STAC_HP_M4
),
1799 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0233,
1800 "unknown Dell", STAC_DELL_M4_1
),
1801 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0234,
1802 "unknown Dell", STAC_DELL_M4_1
),
1803 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0250,
1804 "unknown Dell", STAC_DELL_M4_1
),
1805 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x024f,
1806 "unknown Dell", STAC_DELL_M4_1
),
1807 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x024d,
1808 "unknown Dell", STAC_DELL_M4_1
),
1809 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0251,
1810 "unknown Dell", STAC_DELL_M4_1
),
1811 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0277,
1812 "unknown Dell", STAC_DELL_M4_1
),
1813 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0263,
1814 "unknown Dell", STAC_DELL_M4_2
),
1815 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0265,
1816 "unknown Dell", STAC_DELL_M4_2
),
1817 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0262,
1818 "unknown Dell", STAC_DELL_M4_2
),
1819 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0264,
1820 "unknown Dell", STAC_DELL_M4_2
),
1821 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02aa,
1822 "unknown Dell", STAC_DELL_M4_3
),
1826 static unsigned int ref922x_pin_configs
[10] = {
1827 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1828 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1829 0x40000100, 0x40000100,
1833 STAC 922X pin configs for
1840 static unsigned int dell_922x_d81_pin_configs
[10] = {
1841 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1842 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1843 0x01813122, 0x400001f2,
1847 STAC 922X pin configs for
1851 static unsigned int dell_922x_d82_pin_configs
[10] = {
1852 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1853 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1854 0x01813122, 0x400001f1,
1858 STAC 922X pin configs for
1861 static unsigned int dell_922x_m81_pin_configs
[10] = {
1862 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1863 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1864 0x40C003f1, 0x405003f0,
1868 STAC 9221 A1 pin configs for
1869 102801D7 (Dell XPS M1210)
1871 static unsigned int dell_922x_m82_pin_configs
[10] = {
1872 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1873 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1874 0x508003f3, 0x405003f4,
1877 static unsigned int d945gtp3_pin_configs
[10] = {
1878 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1879 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1880 0x02a19120, 0x40000100,
1883 static unsigned int d945gtp5_pin_configs
[10] = {
1884 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1885 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1886 0x02a19320, 0x40000100,
1889 static unsigned int intel_mac_v1_pin_configs
[10] = {
1890 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1891 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1892 0x400000fc, 0x400000fb,
1895 static unsigned int intel_mac_v2_pin_configs
[10] = {
1896 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1897 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1898 0x400000fc, 0x400000fb,
1901 static unsigned int intel_mac_v3_pin_configs
[10] = {
1902 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1903 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1904 0x400000fc, 0x400000fb,
1907 static unsigned int intel_mac_v4_pin_configs
[10] = {
1908 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1909 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1910 0x400000fc, 0x400000fb,
1913 static unsigned int intel_mac_v5_pin_configs
[10] = {
1914 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1915 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1916 0x400000fc, 0x400000fb,
1919 static unsigned int ecs202_pin_configs
[10] = {
1920 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1921 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1922 0x9037012e, 0x40e000f2,
1925 static unsigned int *stac922x_brd_tbl
[STAC_922X_MODELS
] = {
1926 [STAC_D945_REF
] = ref922x_pin_configs
,
1927 [STAC_D945GTP3
] = d945gtp3_pin_configs
,
1928 [STAC_D945GTP5
] = d945gtp5_pin_configs
,
1929 [STAC_INTEL_MAC_V1
] = intel_mac_v1_pin_configs
,
1930 [STAC_INTEL_MAC_V2
] = intel_mac_v2_pin_configs
,
1931 [STAC_INTEL_MAC_V3
] = intel_mac_v3_pin_configs
,
1932 [STAC_INTEL_MAC_V4
] = intel_mac_v4_pin_configs
,
1933 [STAC_INTEL_MAC_V5
] = intel_mac_v5_pin_configs
,
1934 [STAC_INTEL_MAC_AUTO
] = intel_mac_v3_pin_configs
,
1935 /* for backward compatibility */
1936 [STAC_MACMINI
] = intel_mac_v3_pin_configs
,
1937 [STAC_MACBOOK
] = intel_mac_v5_pin_configs
,
1938 [STAC_MACBOOK_PRO_V1
] = intel_mac_v3_pin_configs
,
1939 [STAC_MACBOOK_PRO_V2
] = intel_mac_v3_pin_configs
,
1940 [STAC_IMAC_INTEL
] = intel_mac_v2_pin_configs
,
1941 [STAC_IMAC_INTEL_20
] = intel_mac_v3_pin_configs
,
1942 [STAC_ECS_202
] = ecs202_pin_configs
,
1943 [STAC_922X_DELL_D81
] = dell_922x_d81_pin_configs
,
1944 [STAC_922X_DELL_D82
] = dell_922x_d82_pin_configs
,
1945 [STAC_922X_DELL_M81
] = dell_922x_m81_pin_configs
,
1946 [STAC_922X_DELL_M82
] = dell_922x_m82_pin_configs
,
1949 static const char *stac922x_models
[STAC_922X_MODELS
] = {
1950 [STAC_D945_REF
] = "ref",
1951 [STAC_D945GTP5
] = "5stack",
1952 [STAC_D945GTP3
] = "3stack",
1953 [STAC_INTEL_MAC_V1
] = "intel-mac-v1",
1954 [STAC_INTEL_MAC_V2
] = "intel-mac-v2",
1955 [STAC_INTEL_MAC_V3
] = "intel-mac-v3",
1956 [STAC_INTEL_MAC_V4
] = "intel-mac-v4",
1957 [STAC_INTEL_MAC_V5
] = "intel-mac-v5",
1958 [STAC_INTEL_MAC_AUTO
] = "intel-mac-auto",
1959 /* for backward compatibility */
1960 [STAC_MACMINI
] = "macmini",
1961 [STAC_MACBOOK
] = "macbook",
1962 [STAC_MACBOOK_PRO_V1
] = "macbook-pro-v1",
1963 [STAC_MACBOOK_PRO_V2
] = "macbook-pro",
1964 [STAC_IMAC_INTEL
] = "imac-intel",
1965 [STAC_IMAC_INTEL_20
] = "imac-intel-20",
1966 [STAC_ECS_202
] = "ecs202",
1967 [STAC_922X_DELL_D81
] = "dell-d81",
1968 [STAC_922X_DELL_D82
] = "dell-d82",
1969 [STAC_922X_DELL_M81
] = "dell-m81",
1970 [STAC_922X_DELL_M82
] = "dell-m82",
1973 static struct snd_pci_quirk stac922x_cfg_tbl
[] = {
1974 /* SigmaTel reference board */
1975 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1976 "DFI LanParty", STAC_D945_REF
),
1977 /* Intel 945G based systems */
1978 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0101,
1979 "Intel D945G", STAC_D945GTP3
),
1980 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0202,
1981 "Intel D945G", STAC_D945GTP3
),
1982 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0606,
1983 "Intel D945G", STAC_D945GTP3
),
1984 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0601,
1985 "Intel D945G", STAC_D945GTP3
),
1986 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0111,
1987 "Intel D945G", STAC_D945GTP3
),
1988 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1115,
1989 "Intel D945G", STAC_D945GTP3
),
1990 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1116,
1991 "Intel D945G", STAC_D945GTP3
),
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1117,
1993 "Intel D945G", STAC_D945GTP3
),
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1118,
1995 "Intel D945G", STAC_D945GTP3
),
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1119,
1997 "Intel D945G", STAC_D945GTP3
),
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x8826,
1999 "Intel D945G", STAC_D945GTP3
),
2000 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5049,
2001 "Intel D945G", STAC_D945GTP3
),
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5055,
2003 "Intel D945G", STAC_D945GTP3
),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5048,
2005 "Intel D945G", STAC_D945GTP3
),
2006 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0110,
2007 "Intel D945G", STAC_D945GTP3
),
2008 /* Intel D945G 5-stack systems */
2009 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0404,
2010 "Intel D945G", STAC_D945GTP5
),
2011 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0303,
2012 "Intel D945G", STAC_D945GTP5
),
2013 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0013,
2014 "Intel D945G", STAC_D945GTP5
),
2015 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0417,
2016 "Intel D945G", STAC_D945GTP5
),
2017 /* Intel 945P based systems */
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0b0b,
2019 "Intel D945P", STAC_D945GTP3
),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0112,
2021 "Intel D945P", STAC_D945GTP3
),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0d0d,
2023 "Intel D945P", STAC_D945GTP3
),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0909,
2025 "Intel D945P", STAC_D945GTP3
),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0505,
2027 "Intel D945P", STAC_D945GTP3
),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0707,
2029 "Intel D945P", STAC_D945GTP5
),
2031 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2032 SND_PCI_QUIRK(0x8384, 0x7680,
2033 "Mac", STAC_INTEL_MAC_AUTO
),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01a7,
2036 "unknown Dell", STAC_922X_DELL_D81
),
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01a9,
2038 "unknown Dell", STAC_922X_DELL_D81
),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ab,
2040 "unknown Dell", STAC_922X_DELL_D81
),
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ac,
2042 "unknown Dell", STAC_922X_DELL_D82
),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01bf,
2044 "unknown Dell", STAC_922X_DELL_M81
),
2045 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d0,
2046 "unknown Dell", STAC_922X_DELL_D82
),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d1,
2048 "unknown Dell", STAC_922X_DELL_D81
),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d2,
2050 "unknown Dell", STAC_922X_DELL_D81
),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d7,
2052 "Dell XPS M1210", STAC_922X_DELL_M82
),
2053 /* ECS/PC Chips boards */
2054 SND_PCI_QUIRK(0x1019, 0x2144,
2055 "ECS/PC chips", STAC_ECS_202
),
2056 SND_PCI_QUIRK(0x1019, 0x2608,
2057 "ECS/PC chips", STAC_ECS_202
),
2058 SND_PCI_QUIRK(0x1019, 0x2633,
2059 "ECS/PC chips P17G/1333", STAC_ECS_202
),
2060 SND_PCI_QUIRK(0x1019, 0x2811,
2061 "ECS/PC chips", STAC_ECS_202
),
2062 SND_PCI_QUIRK(0x1019, 0x2812,
2063 "ECS/PC chips", STAC_ECS_202
),
2064 SND_PCI_QUIRK(0x1019, 0x2813,
2065 "ECS/PC chips", STAC_ECS_202
),
2066 SND_PCI_QUIRK(0x1019, 0x2814,
2067 "ECS/PC chips", STAC_ECS_202
),
2068 SND_PCI_QUIRK(0x1019, 0x2815,
2069 "ECS/PC chips", STAC_ECS_202
),
2070 SND_PCI_QUIRK(0x1019, 0x2816,
2071 "ECS/PC chips", STAC_ECS_202
),
2072 SND_PCI_QUIRK(0x1019, 0x2817,
2073 "ECS/PC chips", STAC_ECS_202
),
2074 SND_PCI_QUIRK(0x1019, 0x2818,
2075 "ECS/PC chips", STAC_ECS_202
),
2076 SND_PCI_QUIRK(0x1019, 0x2819,
2077 "ECS/PC chips", STAC_ECS_202
),
2078 SND_PCI_QUIRK(0x1019, 0x2820,
2079 "ECS/PC chips", STAC_ECS_202
),
2083 static unsigned int ref927x_pin_configs
[14] = {
2084 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2085 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2086 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2087 0x01c42190, 0x40000100,
2090 static unsigned int d965_3st_pin_configs
[14] = {
2091 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2092 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2093 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2094 0x40000100, 0x40000100
2097 static unsigned int d965_5st_pin_configs
[14] = {
2098 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2099 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2100 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2101 0x40000100, 0x40000100
2104 static unsigned int dell_3st_pin_configs
[14] = {
2105 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2106 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2107 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2108 0x40c003fc, 0x40000100
2111 static unsigned int *stac927x_brd_tbl
[STAC_927X_MODELS
] = {
2112 [STAC_D965_REF_NO_JD
] = ref927x_pin_configs
,
2113 [STAC_D965_REF
] = ref927x_pin_configs
,
2114 [STAC_D965_3ST
] = d965_3st_pin_configs
,
2115 [STAC_D965_5ST
] = d965_5st_pin_configs
,
2116 [STAC_DELL_3ST
] = dell_3st_pin_configs
,
2117 [STAC_DELL_BIOS
] = NULL
,
2120 static const char *stac927x_models
[STAC_927X_MODELS
] = {
2121 [STAC_D965_REF_NO_JD
] = "ref-no-jd",
2122 [STAC_D965_REF
] = "ref",
2123 [STAC_D965_3ST
] = "3stack",
2124 [STAC_D965_5ST
] = "5stack",
2125 [STAC_DELL_3ST
] = "dell-3stack",
2126 [STAC_DELL_BIOS
] = "dell-bios",
2129 static struct snd_pci_quirk stac927x_cfg_tbl
[] = {
2130 /* SigmaTel reference board */
2131 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
2132 "DFI LanParty", STAC_D965_REF
),
2133 /* Intel 946 based systems */
2134 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x3d01, "Intel D946", STAC_D965_3ST
),
2135 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0xa301, "Intel D946", STAC_D965_3ST
),
2136 /* 965 based 3 stack systems */
2137 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2116, "Intel D965", STAC_D965_3ST
),
2138 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2115, "Intel D965", STAC_D965_3ST
),
2139 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2114, "Intel D965", STAC_D965_3ST
),
2140 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2113, "Intel D965", STAC_D965_3ST
),
2141 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2112, "Intel D965", STAC_D965_3ST
),
2142 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2111, "Intel D965", STAC_D965_3ST
),
2143 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2110, "Intel D965", STAC_D965_3ST
),
2144 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2009, "Intel D965", STAC_D965_3ST
),
2145 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2008, "Intel D965", STAC_D965_3ST
),
2146 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2007, "Intel D965", STAC_D965_3ST
),
2147 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2006, "Intel D965", STAC_D965_3ST
),
2148 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2005, "Intel D965", STAC_D965_3ST
),
2149 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2004, "Intel D965", STAC_D965_3ST
),
2150 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2003, "Intel D965", STAC_D965_3ST
),
2151 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2002, "Intel D965", STAC_D965_3ST
),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2001, "Intel D965", STAC_D965_3ST
),
2153 /* Dell 3 stack systems */
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST
),
2155 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST
),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ed, "Dell ", STAC_DELL_3ST
),
2157 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f4, "Dell ", STAC_DELL_3ST
),
2158 /* Dell 3 stack systems with verb table in BIOS */
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS
),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS
),
2161 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x022e, "Dell ", STAC_DELL_BIOS
),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST
),
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0242, "Dell ", STAC_DELL_BIOS
),
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0243, "Dell ", STAC_DELL_BIOS
),
2165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02ff, "Dell ", STAC_DELL_BIOS
),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS
),
2167 /* 965 based 5 stack systems */
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2301, "Intel D965", STAC_D965_5ST
),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2302, "Intel D965", STAC_D965_5ST
),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2303, "Intel D965", STAC_D965_5ST
),
2171 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2304, "Intel D965", STAC_D965_5ST
),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2305, "Intel D965", STAC_D965_5ST
),
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2501, "Intel D965", STAC_D965_5ST
),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2502, "Intel D965", STAC_D965_5ST
),
2175 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2503, "Intel D965", STAC_D965_5ST
),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2504, "Intel D965", STAC_D965_5ST
),
2180 static unsigned int ref9205_pin_configs
[12] = {
2181 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2182 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2183 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2187 STAC 9205 pin configs for
2194 10280228 (Dell Vostro 1500)
2196 static unsigned int dell_9205_m42_pin_configs
[12] = {
2197 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2198 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2199 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2203 STAC 9205 pin configs for
2207 102801FF (Dell Precision M4300)
2212 static unsigned int dell_9205_m43_pin_configs
[12] = {
2213 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2214 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2215 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2218 static unsigned int dell_9205_m44_pin_configs
[12] = {
2219 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2220 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2221 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2224 static unsigned int *stac9205_brd_tbl
[STAC_9205_MODELS
] = {
2225 [STAC_9205_REF
] = ref9205_pin_configs
,
2226 [STAC_9205_DELL_M42
] = dell_9205_m42_pin_configs
,
2227 [STAC_9205_DELL_M43
] = dell_9205_m43_pin_configs
,
2228 [STAC_9205_DELL_M44
] = dell_9205_m44_pin_configs
,
2231 static const char *stac9205_models
[STAC_9205_MODELS
] = {
2232 [STAC_9205_REF
] = "ref",
2233 [STAC_9205_DELL_M42
] = "dell-m42",
2234 [STAC_9205_DELL_M43
] = "dell-m43",
2235 [STAC_9205_DELL_M44
] = "dell-m44",
2238 static struct snd_pci_quirk stac9205_cfg_tbl
[] = {
2239 /* SigmaTel reference board */
2240 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
2241 "DFI LanParty", STAC_9205_REF
),
2242 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f1,
2243 "unknown Dell", STAC_9205_DELL_M42
),
2244 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f2,
2245 "unknown Dell", STAC_9205_DELL_M42
),
2246 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f8,
2247 "Dell Precision", STAC_9205_DELL_M43
),
2248 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f9,
2249 "Dell Precision", STAC_9205_DELL_M43
),
2250 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fa,
2251 "Dell Precision", STAC_9205_DELL_M43
),
2252 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fc,
2253 "unknown Dell", STAC_9205_DELL_M42
),
2254 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fd,
2255 "unknown Dell", STAC_9205_DELL_M42
),
2256 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fe,
2257 "Dell Precision", STAC_9205_DELL_M43
),
2258 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ff,
2259 "Dell Precision M4300", STAC_9205_DELL_M43
),
2260 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0204,
2261 "unknown Dell", STAC_9205_DELL_M42
),
2262 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0206,
2263 "Dell Precision", STAC_9205_DELL_M43
),
2264 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x021b,
2265 "Dell Precision", STAC_9205_DELL_M43
),
2266 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x021c,
2267 "Dell Precision", STAC_9205_DELL_M43
),
2268 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x021f,
2269 "Dell Inspiron", STAC_9205_DELL_M44
),
2270 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0228,
2271 "Dell Vostro 1500", STAC_9205_DELL_M42
),
2275 static int stac92xx_save_bios_config_regs(struct hda_codec
*codec
)
2278 struct sigmatel_spec
*spec
= codec
->spec
;
2280 kfree(spec
->pin_configs
);
2281 spec
->pin_configs
= kcalloc(spec
->num_pins
, sizeof(*spec
->pin_configs
),
2283 if (!spec
->pin_configs
)
2286 for (i
= 0; i
< spec
->num_pins
; i
++) {
2287 hda_nid_t nid
= spec
->pin_nids
[i
];
2288 unsigned int pin_cfg
;
2290 pin_cfg
= snd_hda_codec_read(codec
, nid
, 0,
2291 AC_VERB_GET_CONFIG_DEFAULT
, 0x00);
2292 snd_printdd(KERN_INFO
"hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2294 spec
->pin_configs
[i
] = pin_cfg
;
2300 static void stac92xx_set_config_reg(struct hda_codec
*codec
,
2301 hda_nid_t pin_nid
, unsigned int pin_config
)
2304 snd_hda_codec_write(codec
, pin_nid
, 0,
2305 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0
,
2306 pin_config
& 0x000000ff);
2307 snd_hda_codec_write(codec
, pin_nid
, 0,
2308 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1
,
2309 (pin_config
& 0x0000ff00) >> 8);
2310 snd_hda_codec_write(codec
, pin_nid
, 0,
2311 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2
,
2312 (pin_config
& 0x00ff0000) >> 16);
2313 snd_hda_codec_write(codec
, pin_nid
, 0,
2314 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3
,
2316 i
= snd_hda_codec_read(codec
, pin_nid
, 0,
2317 AC_VERB_GET_CONFIG_DEFAULT
,
2319 snd_printdd(KERN_INFO
"hda_codec: pin nid %2.2x pin config %8.8x\n",
2323 static void stac92xx_set_config_regs(struct hda_codec
*codec
)
2326 struct sigmatel_spec
*spec
= codec
->spec
;
2328 if (!spec
->pin_configs
)
2331 for (i
= 0; i
< spec
->num_pins
; i
++)
2332 stac92xx_set_config_reg(codec
, spec
->pin_nids
[i
],
2333 spec
->pin_configs
[i
]);
2336 static int stac_save_pin_cfgs(struct hda_codec
*codec
, unsigned int *pins
)
2338 struct sigmatel_spec
*spec
= codec
->spec
;
2341 return stac92xx_save_bios_config_regs(codec
);
2343 kfree(spec
->pin_configs
);
2344 spec
->pin_configs
= kmemdup(pins
,
2345 spec
->num_pins
* sizeof(*pins
),
2347 if (!spec
->pin_configs
)
2350 stac92xx_set_config_regs(codec
);
2354 static void stac_change_pin_config(struct hda_codec
*codec
, hda_nid_t nid
,
2357 struct sigmatel_spec
*spec
= codec
->spec
;
2360 for (i
= 0; i
< spec
->num_pins
; i
++) {
2361 if (spec
->pin_nids
[i
] == nid
) {
2362 spec
->pin_configs
[i
] = cfg
;
2363 stac92xx_set_config_reg(codec
, nid
, cfg
);
2370 * Analog playback callbacks
2372 static int stac92xx_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2373 struct hda_codec
*codec
,
2374 struct snd_pcm_substream
*substream
)
2376 struct sigmatel_spec
*spec
= codec
->spec
;
2377 if (spec
->stream_delay
)
2378 msleep(spec
->stream_delay
);
2379 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
2383 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2384 struct hda_codec
*codec
,
2385 unsigned int stream_tag
,
2386 unsigned int format
,
2387 struct snd_pcm_substream
*substream
)
2389 struct sigmatel_spec
*spec
= codec
->spec
;
2390 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
, stream_tag
, format
, substream
);
2393 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2394 struct hda_codec
*codec
,
2395 struct snd_pcm_substream
*substream
)
2397 struct sigmatel_spec
*spec
= codec
->spec
;
2398 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
2402 * Digital playback callbacks
2404 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2405 struct hda_codec
*codec
,
2406 struct snd_pcm_substream
*substream
)
2408 struct sigmatel_spec
*spec
= codec
->spec
;
2409 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
2412 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
2413 struct hda_codec
*codec
,
2414 struct snd_pcm_substream
*substream
)
2416 struct sigmatel_spec
*spec
= codec
->spec
;
2417 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
2420 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2421 struct hda_codec
*codec
,
2422 unsigned int stream_tag
,
2423 unsigned int format
,
2424 struct snd_pcm_substream
*substream
)
2426 struct sigmatel_spec
*spec
= codec
->spec
;
2427 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
2428 stream_tag
, format
, substream
);
2433 * Analog capture callbacks
2435 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2436 struct hda_codec
*codec
,
2437 unsigned int stream_tag
,
2438 unsigned int format
,
2439 struct snd_pcm_substream
*substream
)
2441 struct sigmatel_spec
*spec
= codec
->spec
;
2442 hda_nid_t nid
= spec
->adc_nids
[substream
->number
];
2444 if (spec
->powerdown_adcs
) {
2446 snd_hda_codec_write(codec
, nid
, 0,
2447 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
2449 snd_hda_codec_setup_stream(codec
, nid
, stream_tag
, 0, format
);
2453 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2454 struct hda_codec
*codec
,
2455 struct snd_pcm_substream
*substream
)
2457 struct sigmatel_spec
*spec
= codec
->spec
;
2458 hda_nid_t nid
= spec
->adc_nids
[substream
->number
];
2460 snd_hda_codec_cleanup_stream(codec
, nid
);
2461 if (spec
->powerdown_adcs
)
2462 snd_hda_codec_write(codec
, nid
, 0,
2463 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
2467 static struct hda_pcm_stream stac92xx_pcm_digital_playback
= {
2471 /* NID is set in stac92xx_build_pcms */
2473 .open
= stac92xx_dig_playback_pcm_open
,
2474 .close
= stac92xx_dig_playback_pcm_close
,
2475 .prepare
= stac92xx_dig_playback_pcm_prepare
2479 static struct hda_pcm_stream stac92xx_pcm_digital_capture
= {
2483 /* NID is set in stac92xx_build_pcms */
2486 static struct hda_pcm_stream stac92xx_pcm_analog_playback
= {
2490 .nid
= 0x02, /* NID to query formats and rates */
2492 .open
= stac92xx_playback_pcm_open
,
2493 .prepare
= stac92xx_playback_pcm_prepare
,
2494 .cleanup
= stac92xx_playback_pcm_cleanup
2498 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback
= {
2502 .nid
= 0x06, /* NID to query formats and rates */
2504 .open
= stac92xx_playback_pcm_open
,
2505 .prepare
= stac92xx_playback_pcm_prepare
,
2506 .cleanup
= stac92xx_playback_pcm_cleanup
2510 static struct hda_pcm_stream stac92xx_pcm_analog_capture
= {
2513 /* NID + .substreams is set in stac92xx_build_pcms */
2515 .prepare
= stac92xx_capture_pcm_prepare
,
2516 .cleanup
= stac92xx_capture_pcm_cleanup
2520 static int stac92xx_build_pcms(struct hda_codec
*codec
)
2522 struct sigmatel_spec
*spec
= codec
->spec
;
2523 struct hda_pcm
*info
= spec
->pcm_rec
;
2525 codec
->num_pcms
= 1;
2526 codec
->pcm_info
= info
;
2528 info
->name
= "STAC92xx Analog";
2529 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_analog_playback
;
2530 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = stac92xx_pcm_analog_capture
;
2531 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
2532 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adcs
;
2534 if (spec
->alt_switch
) {
2537 info
->name
= "STAC92xx Analog Alt";
2538 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_analog_alt_playback
;
2541 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
2544 info
->name
= "STAC92xx Digital";
2545 info
->pcm_type
= HDA_PCM_TYPE_SPDIF
;
2546 if (spec
->multiout
.dig_out_nid
) {
2547 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_digital_playback
;
2548 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
2550 if (spec
->dig_in_nid
) {
2551 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = stac92xx_pcm_digital_capture
;
2552 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
2559 static unsigned int stac92xx_get_vref(struct hda_codec
*codec
, hda_nid_t nid
)
2561 unsigned int pincap
= snd_hda_param_read(codec
, nid
,
2563 pincap
= (pincap
& AC_PINCAP_VREF
) >> AC_PINCAP_VREF_SHIFT
;
2564 if (pincap
& AC_PINCAP_VREF_100
)
2565 return AC_PINCTL_VREF_100
;
2566 if (pincap
& AC_PINCAP_VREF_80
)
2567 return AC_PINCTL_VREF_80
;
2568 if (pincap
& AC_PINCAP_VREF_50
)
2569 return AC_PINCTL_VREF_50
;
2570 if (pincap
& AC_PINCAP_VREF_GRD
)
2571 return AC_PINCTL_VREF_GRD
;
2575 static void stac92xx_auto_set_pinctl(struct hda_codec
*codec
, hda_nid_t nid
, int pin_type
)
2578 snd_hda_codec_write_cache(codec
, nid
, 0,
2579 AC_VERB_SET_PIN_WIDGET_CONTROL
, pin_type
);
2582 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2584 static int stac92xx_hp_switch_get(struct snd_kcontrol
*kcontrol
,
2585 struct snd_ctl_elem_value
*ucontrol
)
2587 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2588 struct sigmatel_spec
*spec
= codec
->spec
;
2590 ucontrol
->value
.integer
.value
[0] = !!spec
->hp_switch
;
2594 static void stac_issue_unsol_event(struct hda_codec
*codec
, hda_nid_t nid
,
2595 unsigned char type
);
2597 static int stac92xx_hp_switch_put(struct snd_kcontrol
*kcontrol
,
2598 struct snd_ctl_elem_value
*ucontrol
)
2600 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2601 struct sigmatel_spec
*spec
= codec
->spec
;
2602 int nid
= kcontrol
->private_value
;
2604 spec
->hp_switch
= ucontrol
->value
.integer
.value
[0] ? nid
: 0;
2606 /* check to be sure that the ports are upto date with
2609 stac_issue_unsol_event(codec
, nid
, STAC_HP_EVENT
);
2614 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2616 static int stac92xx_io_switch_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2618 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2619 struct sigmatel_spec
*spec
= codec
->spec
;
2620 int io_idx
= kcontrol
-> private_value
& 0xff;
2622 ucontrol
->value
.integer
.value
[0] = spec
->io_switch
[io_idx
];
2626 static int stac92xx_io_switch_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2628 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2629 struct sigmatel_spec
*spec
= codec
->spec
;
2630 hda_nid_t nid
= kcontrol
->private_value
>> 8;
2631 int io_idx
= kcontrol
-> private_value
& 0xff;
2632 unsigned short val
= !!ucontrol
->value
.integer
.value
[0];
2634 spec
->io_switch
[io_idx
] = val
;
2637 stac92xx_auto_set_pinctl(codec
, nid
, AC_PINCTL_OUT_EN
);
2639 unsigned int pinctl
= AC_PINCTL_IN_EN
;
2640 if (io_idx
) /* set VREF for mic */
2641 pinctl
|= stac92xx_get_vref(codec
, nid
);
2642 stac92xx_auto_set_pinctl(codec
, nid
, pinctl
);
2645 /* check the auto-mute again: we need to mute/unmute the speaker
2646 * appropriately according to the pin direction
2648 if (spec
->hp_detect
)
2649 stac_issue_unsol_event(codec
, nid
, STAC_HP_EVENT
);
2654 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2656 static int stac92xx_clfe_switch_get(struct snd_kcontrol
*kcontrol
,
2657 struct snd_ctl_elem_value
*ucontrol
)
2659 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2660 struct sigmatel_spec
*spec
= codec
->spec
;
2662 ucontrol
->value
.integer
.value
[0] = spec
->clfe_swap
;
2666 static int stac92xx_clfe_switch_put(struct snd_kcontrol
*kcontrol
,
2667 struct snd_ctl_elem_value
*ucontrol
)
2669 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2670 struct sigmatel_spec
*spec
= codec
->spec
;
2671 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
2672 unsigned int val
= !!ucontrol
->value
.integer
.value
[0];
2674 if (spec
->clfe_swap
== val
)
2677 spec
->clfe_swap
= val
;
2679 snd_hda_codec_write_cache(codec
, nid
, 0, AC_VERB_SET_EAPD_BTLENABLE
,
2680 spec
->clfe_swap
? 0x4 : 0x0);
2685 #define STAC_CODEC_HP_SWITCH(xname) \
2686 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2689 .info = stac92xx_hp_switch_info, \
2690 .get = stac92xx_hp_switch_get, \
2691 .put = stac92xx_hp_switch_put, \
2694 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2695 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2698 .info = stac92xx_io_switch_info, \
2699 .get = stac92xx_io_switch_get, \
2700 .put = stac92xx_io_switch_put, \
2701 .private_value = xpval, \
2704 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2705 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2708 .info = stac92xx_clfe_switch_info, \
2709 .get = stac92xx_clfe_switch_get, \
2710 .put = stac92xx_clfe_switch_put, \
2711 .private_value = xpval, \
2715 STAC_CTL_WIDGET_VOL
,
2716 STAC_CTL_WIDGET_MUTE
,
2717 STAC_CTL_WIDGET_MONO_MUX
,
2718 STAC_CTL_WIDGET_AMP_MUX
,
2719 STAC_CTL_WIDGET_AMP_VOL
,
2720 STAC_CTL_WIDGET_HP_SWITCH
,
2721 STAC_CTL_WIDGET_IO_SWITCH
,
2722 STAC_CTL_WIDGET_CLFE_SWITCH
2725 static struct snd_kcontrol_new stac92xx_control_templates
[] = {
2726 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2727 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2730 STAC_AMP_VOL(NULL
, 0, 0, 0, 0),
2731 STAC_CODEC_HP_SWITCH(NULL
),
2732 STAC_CODEC_IO_SWITCH(NULL
, 0),
2733 STAC_CODEC_CLFE_SWITCH(NULL
, 0),
2736 /* add dynamic controls */
2737 static int stac92xx_add_control_temp(struct sigmatel_spec
*spec
,
2738 struct snd_kcontrol_new
*ktemp
,
2739 int idx
, const char *name
,
2742 struct snd_kcontrol_new
*knew
;
2744 snd_array_init(&spec
->kctls
, sizeof(*knew
), 32);
2745 knew
= snd_array_new(&spec
->kctls
);
2750 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2753 knew
->private_value
= val
;
2757 static inline int stac92xx_add_control_idx(struct sigmatel_spec
*spec
,
2758 int type
, int idx
, const char *name
,
2761 return stac92xx_add_control_temp(spec
,
2762 &stac92xx_control_templates
[type
],
2767 /* add dynamic controls */
2768 static inline int stac92xx_add_control(struct sigmatel_spec
*spec
, int type
,
2769 const char *name
, unsigned long val
)
2771 return stac92xx_add_control_idx(spec
, type
, 0, name
, val
);
2774 /* check whether the line-input can be used as line-out */
2775 static hda_nid_t
check_line_out_switch(struct hda_codec
*codec
)
2777 struct sigmatel_spec
*spec
= codec
->spec
;
2778 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2780 unsigned int pincap
;
2782 if (cfg
->line_out_type
!= AUTO_PIN_LINE_OUT
)
2784 nid
= cfg
->input_pins
[AUTO_PIN_LINE
];
2785 pincap
= snd_hda_param_read(codec
, nid
, AC_PAR_PIN_CAP
);
2786 if (pincap
& AC_PINCAP_OUT
)
2791 /* check whether the mic-input can be used as line-out */
2792 static hda_nid_t
check_mic_out_switch(struct hda_codec
*codec
)
2794 struct sigmatel_spec
*spec
= codec
->spec
;
2795 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2796 unsigned int def_conf
, pincap
;
2797 unsigned int mic_pin
;
2799 if (cfg
->line_out_type
!= AUTO_PIN_LINE_OUT
)
2801 mic_pin
= AUTO_PIN_MIC
;
2803 hda_nid_t nid
= cfg
->input_pins
[mic_pin
];
2804 def_conf
= snd_hda_codec_read(codec
, nid
, 0,
2805 AC_VERB_GET_CONFIG_DEFAULT
, 0);
2806 /* some laptops have an internal analog microphone
2807 * which can't be used as a output */
2808 if (get_defcfg_connect(def_conf
) != AC_JACK_PORT_FIXED
) {
2809 pincap
= snd_hda_param_read(codec
, nid
, AC_PAR_PIN_CAP
);
2810 if (pincap
& AC_PINCAP_OUT
)
2813 if (mic_pin
== AUTO_PIN_MIC
)
2814 mic_pin
= AUTO_PIN_FRONT_MIC
;
2821 static int is_in_dac_nids(struct sigmatel_spec
*spec
, hda_nid_t nid
)
2825 for (i
= 0; i
< spec
->multiout
.num_dacs
; i
++) {
2826 if (spec
->multiout
.dac_nids
[i
] == nid
)
2833 static int check_all_dac_nids(struct sigmatel_spec
*spec
, hda_nid_t nid
)
2836 if (is_in_dac_nids(spec
, nid
))
2838 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++)
2839 if (spec
->hp_dacs
[i
] == nid
)
2841 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++)
2842 if (spec
->speaker_dacs
[i
] == nid
)
2847 static hda_nid_t
get_unassigned_dac(struct hda_codec
*codec
, hda_nid_t nid
)
2849 struct sigmatel_spec
*spec
= codec
->spec
;
2851 hda_nid_t conn
[HDA_MAX_CONNECTIONS
];
2852 unsigned int wcaps
, wtype
;
2854 conn_len
= snd_hda_get_connections(codec
, nid
, conn
,
2855 HDA_MAX_CONNECTIONS
);
2856 for (j
= 0; j
< conn_len
; j
++) {
2857 wcaps
= snd_hda_param_read(codec
, conn
[j
],
2858 AC_PAR_AUDIO_WIDGET_CAP
);
2859 wtype
= (wcaps
& AC_WCAP_TYPE
) >> AC_WCAP_TYPE_SHIFT
;
2860 /* we check only analog outputs */
2861 if (wtype
!= AC_WID_AUD_OUT
|| (wcaps
& AC_WCAP_DIGITAL
))
2863 /* if this route has a free DAC, assign it */
2864 if (!check_all_dac_nids(spec
, conn
[j
])) {
2866 /* select this DAC in the pin's input mux */
2867 snd_hda_codec_write_cache(codec
, nid
, 0,
2868 AC_VERB_SET_CONNECT_SEL
, j
);
2876 static int add_spec_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
);
2877 static int add_spec_extra_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
);
2880 * Fill in the dac_nids table from the parsed pin configuration
2881 * This function only works when every pin in line_out_pins[]
2882 * contains atleast one DAC in its connection list. Some 92xx
2883 * codecs are not connected directly to a DAC, such as the 9200
2884 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2886 static int stac92xx_auto_fill_dac_nids(struct hda_codec
*codec
)
2888 struct sigmatel_spec
*spec
= codec
->spec
;
2889 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2893 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2894 nid
= cfg
->line_out_pins
[i
];
2895 dac
= get_unassigned_dac(codec
, nid
);
2897 if (spec
->multiout
.num_dacs
> 0) {
2898 /* we have already working output pins,
2899 * so let's drop the broken ones again
2901 cfg
->line_outs
= spec
->multiout
.num_dacs
;
2904 /* error out, no available DAC found */
2906 "%s: No available DAC for pin 0x%x\n",
2910 add_spec_dacs(spec
, dac
);
2913 /* add line-in as output */
2914 nid
= check_line_out_switch(codec
);
2916 dac
= get_unassigned_dac(codec
, nid
);
2918 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2919 nid
, cfg
->line_outs
);
2920 cfg
->line_out_pins
[cfg
->line_outs
] = nid
;
2922 spec
->line_switch
= nid
;
2923 add_spec_dacs(spec
, dac
);
2926 /* add mic as output */
2927 nid
= check_mic_out_switch(codec
);
2929 dac
= get_unassigned_dac(codec
, nid
);
2931 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2932 nid
, cfg
->line_outs
);
2933 cfg
->line_out_pins
[cfg
->line_outs
] = nid
;
2935 spec
->mic_switch
= nid
;
2936 add_spec_dacs(spec
, dac
);
2940 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
2941 nid
= cfg
->hp_pins
[i
];
2942 dac
= get_unassigned_dac(codec
, nid
);
2944 if (!spec
->multiout
.hp_nid
)
2945 spec
->multiout
.hp_nid
= dac
;
2947 add_spec_extra_dacs(spec
, dac
);
2949 spec
->hp_dacs
[i
] = dac
;
2952 for (i
= 0; i
< cfg
->speaker_outs
; i
++) {
2953 nid
= cfg
->speaker_pins
[i
];
2954 dac
= get_unassigned_dac(codec
, nid
);
2956 add_spec_extra_dacs(spec
, dac
);
2957 spec
->speaker_dacs
[i
] = dac
;
2960 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2961 spec
->multiout
.num_dacs
,
2962 spec
->multiout
.dac_nids
[0],
2963 spec
->multiout
.dac_nids
[1],
2964 spec
->multiout
.dac_nids
[2],
2965 spec
->multiout
.dac_nids
[3],
2966 spec
->multiout
.dac_nids
[4]);
2971 /* create volume control/switch for the given prefx type */
2972 static int create_controls(struct sigmatel_spec
*spec
, const char *pfx
, hda_nid_t nid
, int chs
)
2977 sprintf(name
, "%s Playback Volume", pfx
);
2978 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_VOL
, name
,
2979 HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
));
2982 sprintf(name
, "%s Playback Switch", pfx
);
2983 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_MUTE
, name
,
2984 HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
));
2990 static int add_spec_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
)
2992 if (spec
->multiout
.num_dacs
> 4) {
2993 printk(KERN_WARNING
"stac92xx: No space for DAC 0x%x\n", nid
);
2996 spec
->multiout
.dac_nids
[spec
->multiout
.num_dacs
] = nid
;
2997 spec
->multiout
.num_dacs
++;
3002 static int add_spec_extra_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
)
3005 for (i
= 0; i
< ARRAY_SIZE(spec
->multiout
.extra_out_nid
); i
++) {
3006 if (!spec
->multiout
.extra_out_nid
[i
]) {
3007 spec
->multiout
.extra_out_nid
[i
] = nid
;
3011 printk(KERN_WARNING
"stac92xx: No space for extra DAC 0x%x\n", nid
);
3015 static int is_unique_dac(struct sigmatel_spec
*spec
, hda_nid_t nid
)
3019 if (spec
->autocfg
.line_outs
!= 1)
3021 if (spec
->multiout
.hp_nid
== nid
)
3023 for (i
= 0; i
< ARRAY_SIZE(spec
->multiout
.extra_out_nid
); i
++)
3024 if (spec
->multiout
.extra_out_nid
[i
] == nid
)
3029 /* add playback controls from the parsed DAC table */
3030 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec
*codec
,
3031 const struct auto_pin_cfg
*cfg
)
3033 struct sigmatel_spec
*spec
= codec
->spec
;
3034 static const char *chname
[4] = {
3035 "Front", "Surround", NULL
/*CLFE*/, "Side"
3039 unsigned int wid_caps
;
3041 for (i
= 0; i
< cfg
->line_outs
&& spec
->multiout
.dac_nids
[i
]; i
++) {
3042 nid
= spec
->multiout
.dac_nids
[i
];
3045 err
= create_controls(spec
, "Center", nid
, 1);
3048 err
= create_controls(spec
, "LFE", nid
, 2);
3052 wid_caps
= get_wcaps(codec
, nid
);
3054 if (wid_caps
& AC_WCAP_LR_SWAP
) {
3055 err
= stac92xx_add_control(spec
,
3056 STAC_CTL_WIDGET_CLFE_SWITCH
,
3057 "Swap Center/LFE Playback Switch", nid
);
3064 const char *name
= chname
[i
];
3065 /* if it's a single DAC, assign a better name */
3066 if (!i
&& is_unique_dac(spec
, nid
)) {
3067 switch (cfg
->line_out_type
) {
3068 case AUTO_PIN_HP_OUT
:
3071 case AUTO_PIN_SPEAKER_OUT
:
3076 err
= create_controls(spec
, name
, nid
, 3);
3082 if (cfg
->hp_outs
> 1 && cfg
->line_out_type
== AUTO_PIN_LINE_OUT
) {
3083 err
= stac92xx_add_control(spec
,
3084 STAC_CTL_WIDGET_HP_SWITCH
,
3085 "Headphone as Line Out Switch",
3086 cfg
->hp_pins
[cfg
->hp_outs
- 1]);
3091 if (spec
->line_switch
) {
3092 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_IO_SWITCH
,
3093 "Line In as Output Switch",
3094 spec
->line_switch
<< 8);
3099 if (spec
->mic_switch
) {
3100 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_IO_SWITCH
,
3101 "Mic as Output Switch",
3102 (spec
->mic_switch
<< 8) | 1);
3110 /* add playback controls for Speaker and HP outputs */
3111 static int stac92xx_auto_create_hp_ctls(struct hda_codec
*codec
,
3112 struct auto_pin_cfg
*cfg
)
3114 struct sigmatel_spec
*spec
= codec
->spec
;
3119 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3120 static const char *pfxs
[] = {
3121 "Headphone", "Headphone2", "Headphone3",
3123 unsigned int wid_caps
= get_wcaps(codec
, cfg
->hp_pins
[i
]);
3124 if (wid_caps
& AC_WCAP_UNSOL_CAP
)
3125 spec
->hp_detect
= 1;
3126 if (nums
>= ARRAY_SIZE(pfxs
))
3128 nid
= spec
->hp_dacs
[i
];
3131 err
= create_controls(spec
, pfxs
[nums
++], nid
, 3);
3136 for (i
= 0; i
< cfg
->speaker_outs
; i
++) {
3137 static const char *pfxs
[] = {
3138 "Speaker", "External Speaker", "Speaker2",
3140 if (nums
>= ARRAY_SIZE(pfxs
))
3142 nid
= spec
->speaker_dacs
[i
];
3145 err
= create_controls(spec
, pfxs
[nums
++], nid
, 3);
3152 /* labels for mono mux outputs */
3153 static const char *stac92xx_mono_labels
[4] = {
3154 "DAC0", "DAC1", "Mixer", "DAC2"
3157 /* create mono mux for mono out on capable codecs */
3158 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec
*codec
)
3160 struct sigmatel_spec
*spec
= codec
->spec
;
3161 struct hda_input_mux
*mono_mux
= &spec
->private_mono_mux
;
3163 hda_nid_t con_lst
[ARRAY_SIZE(stac92xx_mono_labels
)];
3165 num_cons
= snd_hda_get_connections(codec
,
3168 HDA_MAX_NUM_INPUTS
);
3169 if (!num_cons
|| num_cons
> ARRAY_SIZE(stac92xx_mono_labels
))
3172 for (i
= 0; i
< num_cons
; i
++) {
3173 mono_mux
->items
[mono_mux
->num_items
].label
=
3174 stac92xx_mono_labels
[i
];
3175 mono_mux
->items
[mono_mux
->num_items
].index
= i
;
3176 mono_mux
->num_items
++;
3179 return stac92xx_add_control(spec
, STAC_CTL_WIDGET_MONO_MUX
,
3180 "Mono Mux", spec
->mono_nid
);
3183 /* labels for amp mux outputs */
3184 static const char *stac92xx_amp_labels
[3] = {
3185 "Front Microphone", "Microphone", "Line In",
3188 /* create amp out controls mux on capable codecs */
3189 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec
*codec
)
3191 struct sigmatel_spec
*spec
= codec
->spec
;
3192 struct hda_input_mux
*amp_mux
= &spec
->private_amp_mux
;
3195 for (i
= 0; i
< spec
->num_amps
; i
++) {
3196 amp_mux
->items
[amp_mux
->num_items
].label
=
3197 stac92xx_amp_labels
[i
];
3198 amp_mux
->items
[amp_mux
->num_items
].index
= i
;
3199 amp_mux
->num_items
++;
3202 if (spec
->num_amps
> 1) {
3203 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_AMP_MUX
,
3204 "Amp Selector Capture Switch", 0);
3208 return stac92xx_add_control(spec
, STAC_CTL_WIDGET_AMP_VOL
,
3209 "Amp Capture Volume",
3210 HDA_COMPOSE_AMP_VAL(spec
->amp_nids
[0], 3, 0, HDA_INPUT
));
3214 /* create PC beep volume controls */
3215 static int stac92xx_auto_create_beep_ctls(struct hda_codec
*codec
,
3218 struct sigmatel_spec
*spec
= codec
->spec
;
3219 u32 caps
= query_amp_caps(codec
, nid
, HDA_OUTPUT
);
3222 /* check for mute support for the the amp */
3223 if ((caps
& AC_AMPCAP_MUTE
) >> AC_AMPCAP_MUTE_SHIFT
) {
3224 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_MUTE
,
3225 "PC Beep Playback Switch",
3226 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, HDA_OUTPUT
));
3231 /* check to see if there is volume support for the amp */
3232 if ((caps
& AC_AMPCAP_NUM_STEPS
) >> AC_AMPCAP_NUM_STEPS_SHIFT
) {
3233 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_VOL
,
3234 "PC Beep Playback Volume",
3235 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, HDA_OUTPUT
));
3242 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3243 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3245 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol
*kcontrol
,
3246 struct snd_ctl_elem_value
*ucontrol
)
3248 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3249 ucontrol
->value
.integer
.value
[0] = codec
->beep
->enabled
;
3253 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol
*kcontrol
,
3254 struct snd_ctl_elem_value
*ucontrol
)
3256 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3257 int enabled
= !!ucontrol
->value
.integer
.value
[0];
3258 if (codec
->beep
->enabled
!= enabled
) {
3259 codec
->beep
->enabled
= enabled
;
3265 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl
= {
3266 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3267 .info
= stac92xx_dig_beep_switch_info
,
3268 .get
= stac92xx_dig_beep_switch_get
,
3269 .put
= stac92xx_dig_beep_switch_put
,
3272 static int stac92xx_beep_switch_ctl(struct hda_codec
*codec
)
3274 return stac92xx_add_control_temp(codec
->spec
, &stac92xx_dig_beep_ctrl
,
3275 0, "PC Beep Playback Switch", 0);
3279 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec
*codec
)
3281 struct sigmatel_spec
*spec
= codec
->spec
;
3282 int wcaps
, nid
, i
, err
= 0;
3284 for (i
= 0; i
< spec
->num_muxes
; i
++) {
3285 nid
= spec
->mux_nids
[i
];
3286 wcaps
= get_wcaps(codec
, nid
);
3288 if (wcaps
& AC_WCAP_OUT_AMP
) {
3289 err
= stac92xx_add_control_idx(spec
,
3290 STAC_CTL_WIDGET_VOL
, i
, "Mux Capture Volume",
3291 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
));
3299 static const char *stac92xx_spdif_labels
[3] = {
3300 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3303 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec
*codec
)
3305 struct sigmatel_spec
*spec
= codec
->spec
;
3306 struct hda_input_mux
*spdif_mux
= &spec
->private_smux
;
3307 const char **labels
= spec
->spdif_labels
;
3309 hda_nid_t con_lst
[HDA_MAX_NUM_INPUTS
];
3311 num_cons
= snd_hda_get_connections(codec
,
3314 HDA_MAX_NUM_INPUTS
);
3319 labels
= stac92xx_spdif_labels
;
3321 for (i
= 0; i
< num_cons
; i
++) {
3322 spdif_mux
->items
[spdif_mux
->num_items
].label
= labels
[i
];
3323 spdif_mux
->items
[spdif_mux
->num_items
].index
= i
;
3324 spdif_mux
->num_items
++;
3330 /* labels for dmic mux inputs */
3331 static const char *stac92xx_dmic_labels
[5] = {
3332 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3333 "Digital Mic 3", "Digital Mic 4"
3336 /* create playback/capture controls for input pins on dmic capable codecs */
3337 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec
*codec
,
3338 const struct auto_pin_cfg
*cfg
)
3340 struct sigmatel_spec
*spec
= codec
->spec
;
3341 struct hda_input_mux
*dimux
= &spec
->private_dimux
;
3342 hda_nid_t con_lst
[HDA_MAX_NUM_INPUTS
];
3346 dimux
->items
[dimux
->num_items
].label
= stac92xx_dmic_labels
[0];
3347 dimux
->items
[dimux
->num_items
].index
= 0;
3350 for (i
= 0; i
< spec
->num_dmics
; i
++) {
3355 unsigned int def_conf
;
3357 def_conf
= snd_hda_codec_read(codec
,
3360 AC_VERB_GET_CONFIG_DEFAULT
,
3362 if (get_defcfg_connect(def_conf
) == AC_JACK_PORT_NONE
)
3365 nid
= spec
->dmic_nids
[i
];
3366 num_cons
= snd_hda_get_connections(codec
,
3369 HDA_MAX_NUM_INPUTS
);
3370 for (j
= 0; j
< num_cons
; j
++)
3371 if (con_lst
[j
] == nid
) {
3377 wcaps
= get_wcaps(codec
, nid
) &
3378 (AC_WCAP_OUT_AMP
| AC_WCAP_IN_AMP
);
3381 sprintf(name
, "%s Capture Volume",
3382 stac92xx_dmic_labels
[dimux
->num_items
]);
3384 err
= stac92xx_add_control(spec
,
3385 STAC_CTL_WIDGET_VOL
,
3387 HDA_COMPOSE_AMP_VAL(nid
, 3, 0,
3388 (wcaps
& AC_WCAP_OUT_AMP
) ?
3389 HDA_OUTPUT
: HDA_INPUT
));
3394 dimux
->items
[dimux
->num_items
].label
=
3395 stac92xx_dmic_labels
[dimux
->num_items
];
3396 dimux
->items
[dimux
->num_items
].index
= index
;
3403 /* create playback/capture controls for input pins */
3404 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec
*codec
, const struct auto_pin_cfg
*cfg
)
3406 struct sigmatel_spec
*spec
= codec
->spec
;
3407 struct hda_input_mux
*imux
= &spec
->private_imux
;
3408 hda_nid_t con_lst
[HDA_MAX_NUM_INPUTS
];
3411 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
3414 if (!cfg
->input_pins
[i
])
3417 for (j
= 0; j
< spec
->num_muxes
; j
++) {
3419 num_cons
= snd_hda_get_connections(codec
,
3422 HDA_MAX_NUM_INPUTS
);
3423 for (k
= 0; k
< num_cons
; k
++)
3424 if (con_lst
[k
] == cfg
->input_pins
[i
]) {
3431 imux
->items
[imux
->num_items
].label
= auto_pin_cfg_labels
[i
];
3432 imux
->items
[imux
->num_items
].index
= index
;
3436 if (imux
->num_items
) {
3438 * Set the current input for the muxes.
3439 * The STAC9221 has two input muxes with identical source
3440 * NID lists. Hopefully this won't get confused.
3442 for (i
= 0; i
< spec
->num_muxes
; i
++) {
3443 snd_hda_codec_write_cache(codec
, spec
->mux_nids
[i
], 0,
3444 AC_VERB_SET_CONNECT_SEL
,
3445 imux
->items
[0].index
);
3452 static void stac92xx_auto_init_multi_out(struct hda_codec
*codec
)
3454 struct sigmatel_spec
*spec
= codec
->spec
;
3457 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
3458 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
3459 stac92xx_auto_set_pinctl(codec
, nid
, AC_PINCTL_OUT_EN
);
3463 static void stac92xx_auto_init_hp_out(struct hda_codec
*codec
)
3465 struct sigmatel_spec
*spec
= codec
->spec
;
3468 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
3470 pin
= spec
->autocfg
.hp_pins
[i
];
3471 if (pin
) /* connect to front */
3472 stac92xx_auto_set_pinctl(codec
, pin
, AC_PINCTL_OUT_EN
| AC_PINCTL_HP_EN
);
3474 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++) {
3476 pin
= spec
->autocfg
.speaker_pins
[i
];
3477 if (pin
) /* connect to front */
3478 stac92xx_auto_set_pinctl(codec
, pin
, AC_PINCTL_OUT_EN
);
3482 static int stac92xx_parse_auto_config(struct hda_codec
*codec
, hda_nid_t dig_out
, hda_nid_t dig_in
)
3484 struct sigmatel_spec
*spec
= codec
->spec
;
3487 if ((err
= snd_hda_parse_pin_def_config(codec
,
3489 spec
->dmic_nids
)) < 0)
3491 if (! spec
->autocfg
.line_outs
)
3492 return 0; /* can't find valid pin config */
3494 /* If we have no real line-out pin and multiple hp-outs, HPs should
3495 * be set up as multi-channel outputs.
3497 if (spec
->autocfg
.line_out_type
== AUTO_PIN_SPEAKER_OUT
&&
3498 spec
->autocfg
.hp_outs
> 1) {
3499 /* Copy hp_outs to line_outs, backup line_outs in
3500 * speaker_outs so that the following routines can handle
3501 * HP pins as primary outputs.
3503 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3504 memcpy(spec
->autocfg
.speaker_pins
, spec
->autocfg
.line_out_pins
,
3505 sizeof(spec
->autocfg
.line_out_pins
));
3506 spec
->autocfg
.speaker_outs
= spec
->autocfg
.line_outs
;
3507 memcpy(spec
->autocfg
.line_out_pins
, spec
->autocfg
.hp_pins
,
3508 sizeof(spec
->autocfg
.hp_pins
));
3509 spec
->autocfg
.line_outs
= spec
->autocfg
.hp_outs
;
3510 spec
->autocfg
.line_out_type
= AUTO_PIN_HP_OUT
;
3511 spec
->autocfg
.hp_outs
= 0;
3513 if (spec
->autocfg
.mono_out_pin
) {
3514 int dir
= get_wcaps(codec
, spec
->autocfg
.mono_out_pin
) &
3515 (AC_WCAP_OUT_AMP
| AC_WCAP_IN_AMP
);
3516 u32 caps
= query_amp_caps(codec
,
3517 spec
->autocfg
.mono_out_pin
, dir
);
3518 hda_nid_t conn_list
[1];
3520 /* get the mixer node and then the mono mux if it exists */
3521 if (snd_hda_get_connections(codec
,
3522 spec
->autocfg
.mono_out_pin
, conn_list
, 1) &&
3523 snd_hda_get_connections(codec
, conn_list
[0],
3526 int wcaps
= get_wcaps(codec
, conn_list
[0]);
3527 int wid_type
= (wcaps
& AC_WCAP_TYPE
)
3528 >> AC_WCAP_TYPE_SHIFT
;
3529 /* LR swap check, some stac925x have a mux that
3530 * changes the DACs output path instead of the
3533 if (wid_type
== AC_WID_AUD_SEL
&&
3534 !(wcaps
& AC_WCAP_LR_SWAP
))
3535 spec
->mono_nid
= conn_list
[0];
3538 hda_nid_t nid
= spec
->autocfg
.mono_out_pin
;
3540 /* most mono outs have a least a mute/unmute switch */
3541 dir
= (dir
& AC_WCAP_OUT_AMP
) ? HDA_OUTPUT
: HDA_INPUT
;
3542 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_MUTE
,
3543 "Mono Playback Switch",
3544 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, dir
));
3547 /* check for volume support for the amp */
3548 if ((caps
& AC_AMPCAP_NUM_STEPS
)
3549 >> AC_AMPCAP_NUM_STEPS_SHIFT
) {
3550 err
= stac92xx_add_control(spec
,
3551 STAC_CTL_WIDGET_VOL
,
3552 "Mono Playback Volume",
3553 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, dir
));
3559 stac92xx_auto_set_pinctl(codec
, spec
->autocfg
.mono_out_pin
,
3563 if (!spec
->multiout
.num_dacs
) {
3564 err
= stac92xx_auto_fill_dac_nids(codec
);
3569 err
= stac92xx_auto_create_multi_out_ctls(codec
, &spec
->autocfg
);
3574 /* setup analog beep controls */
3575 if (spec
->anabeep_nid
> 0) {
3576 err
= stac92xx_auto_create_beep_ctls(codec
,
3582 /* setup digital beep controls and input device */
3583 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3584 if (spec
->digbeep_nid
> 0) {
3585 hda_nid_t nid
= spec
->digbeep_nid
;
3588 err
= stac92xx_auto_create_beep_ctls(codec
, nid
);
3591 err
= snd_hda_attach_beep_device(codec
, nid
);
3594 /* if no beep switch is available, make its own one */
3595 caps
= query_amp_caps(codec
, nid
, HDA_OUTPUT
);
3597 !((caps
& AC_AMPCAP_MUTE
) >> AC_AMPCAP_MUTE_SHIFT
)) {
3598 err
= stac92xx_beep_switch_ctl(codec
);
3605 err
= stac92xx_auto_create_hp_ctls(codec
, &spec
->autocfg
);
3610 err
= stac92xx_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
3615 if (spec
->mono_nid
> 0) {
3616 err
= stac92xx_auto_create_mono_output_ctls(codec
);
3620 if (spec
->num_amps
> 0) {
3621 err
= stac92xx_auto_create_amp_output_ctls(codec
);
3625 if (spec
->num_dmics
> 0 && !spec
->dinput_mux
)
3626 if ((err
= stac92xx_auto_create_dmic_input_ctls(codec
,
3627 &spec
->autocfg
)) < 0)
3629 if (spec
->num_muxes
> 0) {
3630 err
= stac92xx_auto_create_mux_input_ctls(codec
);
3634 if (spec
->num_smuxes
> 0) {
3635 err
= stac92xx_auto_create_spdif_mux_ctls(codec
);
3640 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3641 if (spec
->multiout
.max_channels
> 2)
3642 spec
->surr_switch
= 1;
3644 if (spec
->autocfg
.dig_out_pin
)
3645 spec
->multiout
.dig_out_nid
= dig_out
;
3646 if (dig_in
&& spec
->autocfg
.dig_in_pin
)
3647 spec
->dig_in_nid
= dig_in
;
3649 if (spec
->kctls
.list
)
3650 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
3652 spec
->input_mux
= &spec
->private_imux
;
3653 if (!spec
->dinput_mux
)
3654 spec
->dinput_mux
= &spec
->private_dimux
;
3655 spec
->sinput_mux
= &spec
->private_smux
;
3656 spec
->mono_mux
= &spec
->private_mono_mux
;
3657 spec
->amp_mux
= &spec
->private_amp_mux
;
3661 /* add playback controls for HP output */
3662 static int stac9200_auto_create_hp_ctls(struct hda_codec
*codec
,
3663 struct auto_pin_cfg
*cfg
)
3665 struct sigmatel_spec
*spec
= codec
->spec
;
3666 hda_nid_t pin
= cfg
->hp_pins
[0];
3667 unsigned int wid_caps
;
3672 wid_caps
= get_wcaps(codec
, pin
);
3673 if (wid_caps
& AC_WCAP_UNSOL_CAP
)
3674 spec
->hp_detect
= 1;
3679 /* add playback controls for LFE output */
3680 static int stac9200_auto_create_lfe_ctls(struct hda_codec
*codec
,
3681 struct auto_pin_cfg
*cfg
)
3683 struct sigmatel_spec
*spec
= codec
->spec
;
3685 hda_nid_t lfe_pin
= 0x0;
3689 * search speaker outs and line outs for a mono speaker pin
3690 * with an amp. If one is found, add LFE controls
3693 for (i
= 0; i
< spec
->autocfg
.speaker_outs
&& lfe_pin
== 0x0; i
++) {
3694 hda_nid_t pin
= spec
->autocfg
.speaker_pins
[i
];
3695 unsigned int wcaps
= get_wcaps(codec
, pin
);
3696 wcaps
&= (AC_WCAP_STEREO
| AC_WCAP_OUT_AMP
);
3697 if (wcaps
== AC_WCAP_OUT_AMP
)
3698 /* found a mono speaker with an amp, must be lfe */
3702 /* if speaker_outs is 0, then speakers may be in line_outs */
3703 if (lfe_pin
== 0 && spec
->autocfg
.speaker_outs
== 0) {
3704 for (i
= 0; i
< spec
->autocfg
.line_outs
&& lfe_pin
== 0x0; i
++) {
3705 hda_nid_t pin
= spec
->autocfg
.line_out_pins
[i
];
3706 unsigned int defcfg
;
3707 defcfg
= snd_hda_codec_read(codec
, pin
, 0,
3708 AC_VERB_GET_CONFIG_DEFAULT
,
3710 if (get_defcfg_device(defcfg
) == AC_JACK_SPEAKER
) {
3711 unsigned int wcaps
= get_wcaps(codec
, pin
);
3712 wcaps
&= (AC_WCAP_STEREO
| AC_WCAP_OUT_AMP
);
3713 if (wcaps
== AC_WCAP_OUT_AMP
)
3714 /* found a mono speaker with an amp,
3722 err
= create_controls(spec
, "LFE", lfe_pin
, 1);
3730 static int stac9200_parse_auto_config(struct hda_codec
*codec
)
3732 struct sigmatel_spec
*spec
= codec
->spec
;
3735 if ((err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
)) < 0)
3738 if ((err
= stac92xx_auto_create_analog_input_ctls(codec
, &spec
->autocfg
)) < 0)
3741 if ((err
= stac9200_auto_create_hp_ctls(codec
, &spec
->autocfg
)) < 0)
3744 if ((err
= stac9200_auto_create_lfe_ctls(codec
, &spec
->autocfg
)) < 0)
3747 if (spec
->num_muxes
> 0) {
3748 err
= stac92xx_auto_create_mux_input_ctls(codec
);
3753 if (spec
->autocfg
.dig_out_pin
)
3754 spec
->multiout
.dig_out_nid
= 0x05;
3755 if (spec
->autocfg
.dig_in_pin
)
3756 spec
->dig_in_nid
= 0x04;
3758 if (spec
->kctls
.list
)
3759 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
3761 spec
->input_mux
= &spec
->private_imux
;
3762 spec
->dinput_mux
= &spec
->private_dimux
;
3768 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3769 * funky external mute control using GPIO pins.
3772 static void stac_gpio_set(struct hda_codec
*codec
, unsigned int mask
,
3773 unsigned int dir_mask
, unsigned int data
)
3775 unsigned int gpiostate
, gpiomask
, gpiodir
;
3777 gpiostate
= snd_hda_codec_read(codec
, codec
->afg
, 0,
3778 AC_VERB_GET_GPIO_DATA
, 0);
3779 gpiostate
= (gpiostate
& ~dir_mask
) | (data
& dir_mask
);
3781 gpiomask
= snd_hda_codec_read(codec
, codec
->afg
, 0,
3782 AC_VERB_GET_GPIO_MASK
, 0);
3785 gpiodir
= snd_hda_codec_read(codec
, codec
->afg
, 0,
3786 AC_VERB_GET_GPIO_DIRECTION
, 0);
3787 gpiodir
|= dir_mask
;
3789 /* Configure GPIOx as CMOS */
3790 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7e7, 0);
3792 snd_hda_codec_write(codec
, codec
->afg
, 0,
3793 AC_VERB_SET_GPIO_MASK
, gpiomask
);
3794 snd_hda_codec_read(codec
, codec
->afg
, 0,
3795 AC_VERB_SET_GPIO_DIRECTION
, gpiodir
); /* sync */
3799 snd_hda_codec_read(codec
, codec
->afg
, 0,
3800 AC_VERB_SET_GPIO_DATA
, gpiostate
); /* sync */
3803 static int stac92xx_add_jack(struct hda_codec
*codec
,
3804 hda_nid_t nid
, int type
)
3806 #ifdef CONFIG_SND_JACK
3807 struct sigmatel_spec
*spec
= codec
->spec
;
3808 struct sigmatel_jack
*jack
;
3809 int def_conf
= snd_hda_codec_read(codec
, nid
,
3810 0, AC_VERB_GET_CONFIG_DEFAULT
, 0);
3811 int connectivity
= get_defcfg_connect(def_conf
);
3814 if (connectivity
&& connectivity
!= AC_JACK_PORT_FIXED
)
3817 snd_array_init(&spec
->jacks
, sizeof(*jack
), 32);
3818 jack
= snd_array_new(&spec
->jacks
);
3824 sprintf(name
, "%s at %s %s Jack",
3825 snd_hda_get_jack_type(def_conf
),
3826 snd_hda_get_jack_connectivity(def_conf
),
3827 snd_hda_get_jack_location(def_conf
));
3829 return snd_jack_new(codec
->bus
->card
, name
, type
, &jack
->jack
);
3835 static int stac_add_event(struct sigmatel_spec
*spec
, hda_nid_t nid
,
3836 unsigned char type
, int data
)
3838 struct sigmatel_event
*event
;
3840 snd_array_init(&spec
->events
, sizeof(*event
), 32);
3841 event
= snd_array_new(&spec
->events
);
3846 event
->tag
= spec
->events
.used
;
3852 static struct sigmatel_event
*stac_get_event(struct hda_codec
*codec
,
3853 hda_nid_t nid
, unsigned char type
)
3855 struct sigmatel_spec
*spec
= codec
->spec
;
3856 struct sigmatel_event
*event
= spec
->events
.list
;
3859 for (i
= 0; i
< spec
->events
.used
; i
++, event
++) {
3860 if (event
->nid
== nid
&& event
->type
== type
)
3866 static struct sigmatel_event
*stac_get_event_from_tag(struct hda_codec
*codec
,
3869 struct sigmatel_spec
*spec
= codec
->spec
;
3870 struct sigmatel_event
*event
= spec
->events
.list
;
3873 for (i
= 0; i
< spec
->events
.used
; i
++, event
++) {
3874 if (event
->tag
== tag
)
3880 static void enable_pin_detect(struct hda_codec
*codec
, hda_nid_t nid
,
3883 struct sigmatel_event
*event
;
3886 if (!(get_wcaps(codec
, nid
) & AC_WCAP_UNSOL_CAP
))
3888 event
= stac_get_event(codec
, nid
, type
);
3892 tag
= stac_add_event(codec
->spec
, nid
, type
, 0);
3895 snd_hda_codec_write_cache(codec
, nid
, 0,
3896 AC_VERB_SET_UNSOLICITED_ENABLE
,
3900 static int is_nid_hp_pin(struct auto_pin_cfg
*cfg
, hda_nid_t nid
)
3903 for (i
= 0; i
< cfg
->hp_outs
; i
++)
3904 if (cfg
->hp_pins
[i
] == nid
)
3905 return 1; /* nid is a HP-Out */
3907 return 0; /* nid is not a HP-Out */
3910 static void stac92xx_power_down(struct hda_codec
*codec
)
3912 struct sigmatel_spec
*spec
= codec
->spec
;
3914 /* power down inactive DACs */
3916 for (dac
= spec
->dac_list
; *dac
; dac
++)
3917 if (!check_all_dac_nids(spec
, *dac
))
3918 snd_hda_codec_write(codec
, *dac
, 0,
3919 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
3922 static void stac_toggle_power_map(struct hda_codec
*codec
, hda_nid_t nid
,
3925 static int stac92xx_init(struct hda_codec
*codec
)
3927 struct sigmatel_spec
*spec
= codec
->spec
;
3928 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3932 snd_hda_sequence_write(codec
, spec
->init
);
3934 /* power down adcs initially */
3935 if (spec
->powerdown_adcs
)
3936 for (i
= 0; i
< spec
->num_adcs
; i
++)
3937 snd_hda_codec_write(codec
,
3938 spec
->adc_nids
[i
], 0,
3939 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
3942 gpio
= spec
->gpio_data
;
3943 /* turn on EAPD statically when spec->eapd_switch isn't set.
3944 * otherwise, unsol event will turn it on/off dynamically
3946 if (!spec
->eapd_switch
)
3947 gpio
|= spec
->eapd_mask
;
3948 stac_gpio_set(codec
, spec
->gpio_mask
, spec
->gpio_dir
, gpio
);
3951 if (spec
->hp_detect
) {
3952 /* Enable unsolicited responses on the HP widget */
3953 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3954 hda_nid_t nid
= cfg
->hp_pins
[i
];
3955 enable_pin_detect(codec
, nid
, STAC_HP_EVENT
);
3957 /* force to enable the first line-out; the others are set up
3960 stac92xx_auto_set_pinctl(codec
, spec
->autocfg
.line_out_pins
[0],
3962 /* fake event to set up pins */
3963 stac_issue_unsol_event(codec
, spec
->autocfg
.hp_pins
[0],
3966 stac92xx_auto_init_multi_out(codec
);
3967 stac92xx_auto_init_hp_out(codec
);
3968 for (i
= 0; i
< cfg
->hp_outs
; i
++)
3969 stac_toggle_power_map(codec
, cfg
->hp_pins
[i
], 1);
3971 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
3972 hda_nid_t nid
= cfg
->input_pins
[i
];
3974 unsigned int pinctl
, conf
;
3975 if (i
== AUTO_PIN_MIC
|| i
== AUTO_PIN_FRONT_MIC
) {
3976 /* for mic pins, force to initialize */
3977 pinctl
= stac92xx_get_vref(codec
, nid
);
3978 pinctl
|= AC_PINCTL_IN_EN
;
3979 stac92xx_auto_set_pinctl(codec
, nid
, pinctl
);
3981 pinctl
= snd_hda_codec_read(codec
, nid
, 0,
3982 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
3983 /* if PINCTL already set then skip */
3984 if (!(pinctl
& AC_PINCTL_IN_EN
)) {
3985 pinctl
|= AC_PINCTL_IN_EN
;
3986 stac92xx_auto_set_pinctl(codec
, nid
,
3990 conf
= snd_hda_codec_read(codec
, nid
, 0,
3991 AC_VERB_GET_CONFIG_DEFAULT
, 0);
3992 if (get_defcfg_connect(conf
) != AC_JACK_PORT_FIXED
) {
3993 enable_pin_detect(codec
, nid
,
3995 stac_issue_unsol_event(codec
, nid
,
4000 for (i
= 0; i
< spec
->num_dmics
; i
++)
4001 stac92xx_auto_set_pinctl(codec
, spec
->dmic_nids
[i
],
4003 if (cfg
->dig_out_pin
)
4004 stac92xx_auto_set_pinctl(codec
, cfg
->dig_out_pin
,
4006 if (cfg
->dig_in_pin
)
4007 stac92xx_auto_set_pinctl(codec
, cfg
->dig_in_pin
,
4009 for (i
= 0; i
< spec
->num_pwrs
; i
++) {
4010 hda_nid_t nid
= spec
->pwr_nids
[i
];
4011 int pinctl
, def_conf
;
4013 /* power on when no jack detection is available */
4014 if (!spec
->hp_detect
) {
4015 stac_toggle_power_map(codec
, nid
, 1);
4019 if (is_nid_hp_pin(cfg
, nid
))
4020 continue; /* already has an unsol event */
4022 pinctl
= snd_hda_codec_read(codec
, nid
, 0,
4023 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
4024 /* outputs are only ports capable of power management
4025 * any attempts on powering down a input port cause the
4026 * referenced VREF to act quirky.
4028 if (pinctl
& AC_PINCTL_IN_EN
) {
4029 stac_toggle_power_map(codec
, nid
, 1);
4032 def_conf
= snd_hda_codec_read(codec
, nid
, 0,
4033 AC_VERB_GET_CONFIG_DEFAULT
, 0);
4034 def_conf
= get_defcfg_connect(def_conf
);
4035 /* skip any ports that don't have jacks since presence
4036 * detection is useless */
4037 if (def_conf
!= AC_JACK_PORT_COMPLEX
) {
4038 if (def_conf
!= AC_JACK_PORT_NONE
)
4039 stac_toggle_power_map(codec
, nid
, 1);
4042 if (!stac_get_event(codec
, nid
, STAC_INSERT_EVENT
)) {
4043 enable_pin_detect(codec
, nid
, STAC_PWR_EVENT
);
4044 stac_issue_unsol_event(codec
, nid
, STAC_PWR_EVENT
);
4048 stac92xx_power_down(codec
);
4052 static void stac92xx_free_jacks(struct hda_codec
*codec
)
4054 #ifdef CONFIG_SND_JACK
4055 /* free jack instances manually when clearing/reconfiguring */
4056 struct sigmatel_spec
*spec
= codec
->spec
;
4057 if (!codec
->bus
->shutdown
&& spec
->jacks
.list
) {
4058 struct sigmatel_jack
*jacks
= spec
->jacks
.list
;
4060 for (i
= 0; i
< spec
->jacks
.used
; i
++)
4061 snd_device_free(codec
->bus
->card
, &jacks
[i
].jack
);
4063 snd_array_free(&spec
->jacks
);
4067 static void stac92xx_free_kctls(struct hda_codec
*codec
)
4069 struct sigmatel_spec
*spec
= codec
->spec
;
4071 if (spec
->kctls
.list
) {
4072 struct snd_kcontrol_new
*kctl
= spec
->kctls
.list
;
4074 for (i
= 0; i
< spec
->kctls
.used
; i
++)
4075 kfree(kctl
[i
].name
);
4077 snd_array_free(&spec
->kctls
);
4080 static void stac92xx_free(struct hda_codec
*codec
)
4082 struct sigmatel_spec
*spec
= codec
->spec
;
4087 kfree(spec
->pin_configs
);
4088 stac92xx_free_jacks(codec
);
4089 snd_array_free(&spec
->events
);
4092 snd_hda_detach_beep_device(codec
);
4095 static void stac92xx_set_pinctl(struct hda_codec
*codec
, hda_nid_t nid
,
4098 unsigned int pin_ctl
= snd_hda_codec_read(codec
, nid
,
4099 0, AC_VERB_GET_PIN_WIDGET_CONTROL
, 0x00);
4101 if (pin_ctl
& AC_PINCTL_IN_EN
) {
4103 * we need to check the current set-up direction of
4104 * shared input pins since they can be switched via
4105 * "xxx as Output" mixer switch
4107 struct sigmatel_spec
*spec
= codec
->spec
;
4108 if (nid
== spec
->line_switch
|| nid
== spec
->mic_switch
)
4112 /* if setting pin direction bits, clear the current
4113 direction bits first */
4114 if (flag
& (AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
))
4115 pin_ctl
&= ~(AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
);
4117 snd_hda_codec_write_cache(codec
, nid
, 0,
4118 AC_VERB_SET_PIN_WIDGET_CONTROL
,
4122 static void stac92xx_reset_pinctl(struct hda_codec
*codec
, hda_nid_t nid
,
4125 unsigned int pin_ctl
= snd_hda_codec_read(codec
, nid
,
4126 0, AC_VERB_GET_PIN_WIDGET_CONTROL
, 0x00);
4127 snd_hda_codec_write_cache(codec
, nid
, 0,
4128 AC_VERB_SET_PIN_WIDGET_CONTROL
,
4132 static int get_pin_presence(struct hda_codec
*codec
, hda_nid_t nid
)
4136 if (snd_hda_codec_read(codec
, nid
, 0, AC_VERB_GET_PIN_SENSE
, 0x00)
4142 /* return non-zero if the hp-pin of the given array index isn't
4143 * a jack-detection target
4145 static int no_hp_sensing(struct sigmatel_spec
*spec
, int i
)
4147 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4149 /* ignore sensing of shared line and mic jacks */
4150 if (cfg
->hp_pins
[i
] == spec
->line_switch
)
4152 if (cfg
->hp_pins
[i
] == spec
->mic_switch
)
4154 /* ignore if the pin is set as line-out */
4155 if (cfg
->hp_pins
[i
] == spec
->hp_switch
)
4160 static void stac92xx_hp_detect(struct hda_codec
*codec
)
4162 struct sigmatel_spec
*spec
= codec
->spec
;
4163 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4167 if (spec
->gpio_mute
)
4168 presence
= !(snd_hda_codec_read(codec
, codec
->afg
, 0,
4169 AC_VERB_GET_GPIO_DATA
, 0) & spec
->gpio_mute
);
4171 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
4174 if (no_hp_sensing(spec
, i
))
4176 presence
= get_pin_presence(codec
, cfg
->hp_pins
[i
]);
4178 unsigned int pinctl
;
4179 pinctl
= snd_hda_codec_read(codec
, cfg
->hp_pins
[i
], 0,
4180 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
4181 if (pinctl
& AC_PINCTL_IN_EN
)
4182 presence
= 0; /* mic- or line-input */
4187 /* disable lineouts */
4188 if (spec
->hp_switch
)
4189 stac92xx_reset_pinctl(codec
, spec
->hp_switch
,
4191 for (i
= 0; i
< cfg
->line_outs
; i
++)
4192 stac92xx_reset_pinctl(codec
, cfg
->line_out_pins
[i
],
4194 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
4195 stac92xx_reset_pinctl(codec
, cfg
->speaker_pins
[i
],
4197 if (spec
->eapd_mask
&& spec
->eapd_switch
)
4198 stac_gpio_set(codec
, spec
->gpio_mask
,
4199 spec
->gpio_dir
, spec
->gpio_data
&
4202 /* enable lineouts */
4203 if (spec
->hp_switch
)
4204 stac92xx_set_pinctl(codec
, spec
->hp_switch
,
4206 for (i
= 0; i
< cfg
->line_outs
; i
++)
4207 stac92xx_set_pinctl(codec
, cfg
->line_out_pins
[i
],
4209 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
4210 stac92xx_set_pinctl(codec
, cfg
->speaker_pins
[i
],
4212 if (spec
->eapd_mask
&& spec
->eapd_switch
)
4213 stac_gpio_set(codec
, spec
->gpio_mask
,
4214 spec
->gpio_dir
, spec
->gpio_data
|
4217 /* toggle hp outs */
4218 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
4219 unsigned int val
= AC_PINCTL_OUT_EN
| AC_PINCTL_HP_EN
;
4220 if (no_hp_sensing(spec
, i
))
4223 stac92xx_set_pinctl(codec
, cfg
->hp_pins
[i
], val
);
4225 stac92xx_reset_pinctl(codec
, cfg
->hp_pins
[i
], val
);
4229 static void stac_toggle_power_map(struct hda_codec
*codec
, hda_nid_t nid
,
4232 struct sigmatel_spec
*spec
= codec
->spec
;
4233 unsigned int idx
, val
;
4235 for (idx
= 0; idx
< spec
->num_pwrs
; idx
++) {
4236 if (spec
->pwr_nids
[idx
] == nid
)
4239 if (idx
>= spec
->num_pwrs
)
4242 /* several codecs have two power down bits */
4243 if (spec
->pwr_mapping
)
4244 idx
= spec
->pwr_mapping
[idx
];
4248 val
= snd_hda_codec_read(codec
, codec
->afg
, 0, 0x0fec, 0x0) & 0xff;
4254 /* power down unused output ports */
4255 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7ec, val
);
4258 static void stac92xx_pin_sense(struct hda_codec
*codec
, hda_nid_t nid
)
4260 stac_toggle_power_map(codec
, nid
, get_pin_presence(codec
, nid
));
4263 static void stac92xx_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
4265 struct sigmatel_spec
*spec
= codec
->spec
;
4266 struct sigmatel_jack
*jacks
= spec
->jacks
.list
;
4270 for (i
= 0; i
< spec
->jacks
.used
; i
++) {
4271 if (jacks
->nid
== nid
) {
4272 unsigned int pin_ctl
=
4273 snd_hda_codec_read(codec
, nid
,
4274 0, AC_VERB_GET_PIN_WIDGET_CONTROL
,
4276 int type
= jacks
->type
;
4277 if (type
== (SND_JACK_LINEOUT
4278 | SND_JACK_HEADPHONE
))
4279 type
= (pin_ctl
& AC_PINCTL_HP_EN
)
4280 ? SND_JACK_HEADPHONE
: SND_JACK_LINEOUT
;
4281 snd_jack_report(jacks
->jack
,
4282 get_pin_presence(codec
, nid
)
4290 static void stac_issue_unsol_event(struct hda_codec
*codec
, hda_nid_t nid
,
4293 struct sigmatel_event
*event
= stac_get_event(codec
, nid
, type
);
4296 codec
->patch_ops
.unsol_event(codec
, (unsigned)event
->tag
<< 26);
4299 static void stac92xx_unsol_event(struct hda_codec
*codec
, unsigned int res
)
4301 struct sigmatel_spec
*spec
= codec
->spec
;
4302 struct sigmatel_event
*event
;
4305 tag
= (res
>> 26) & 0x7f;
4306 event
= stac_get_event_from_tag(codec
, tag
);
4310 switch (event
->type
) {
4312 stac92xx_hp_detect(codec
);
4314 case STAC_INSERT_EVENT
:
4315 case STAC_PWR_EVENT
:
4316 if (spec
->num_pwrs
> 0)
4317 stac92xx_pin_sense(codec
, event
->nid
);
4318 stac92xx_report_jack(codec
, event
->nid
);
4320 case STAC_VREF_EVENT
:
4321 data
= snd_hda_codec_read(codec
, codec
->afg
, 0,
4322 AC_VERB_GET_GPIO_DATA
, 0);
4323 /* toggle VREF state based on GPIOx status */
4324 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7e0,
4325 !!(data
& (1 << event
->data
)));
4330 #ifdef CONFIG_PROC_FS
4331 static void stac92hd_proc_hook(struct snd_info_buffer
*buffer
,
4332 struct hda_codec
*codec
, hda_nid_t nid
)
4334 if (nid
== codec
->afg
)
4335 snd_iprintf(buffer
, "Power-Map: 0x%02x\n",
4336 snd_hda_codec_read(codec
, nid
, 0, 0x0fec, 0x0));
4339 static void analog_loop_proc_hook(struct snd_info_buffer
*buffer
,
4340 struct hda_codec
*codec
,
4343 snd_iprintf(buffer
, "Analog Loopback: 0x%02x\n",
4344 snd_hda_codec_read(codec
, codec
->afg
, 0, verb
, 0));
4347 /* stac92hd71bxx, stac92hd73xx */
4348 static void stac92hd7x_proc_hook(struct snd_info_buffer
*buffer
,
4349 struct hda_codec
*codec
, hda_nid_t nid
)
4351 stac92hd_proc_hook(buffer
, codec
, nid
);
4352 if (nid
== codec
->afg
)
4353 analog_loop_proc_hook(buffer
, codec
, 0xfa0);
4356 static void stac9205_proc_hook(struct snd_info_buffer
*buffer
,
4357 struct hda_codec
*codec
, hda_nid_t nid
)
4359 if (nid
== codec
->afg
)
4360 analog_loop_proc_hook(buffer
, codec
, 0xfe0);
4363 static void stac927x_proc_hook(struct snd_info_buffer
*buffer
,
4364 struct hda_codec
*codec
, hda_nid_t nid
)
4366 if (nid
== codec
->afg
)
4367 analog_loop_proc_hook(buffer
, codec
, 0xfeb);
4370 #define stac92hd_proc_hook NULL
4371 #define stac92hd7x_proc_hook NULL
4372 #define stac9205_proc_hook NULL
4373 #define stac927x_proc_hook NULL
4376 #ifdef SND_HDA_NEEDS_RESUME
4377 static int stac92xx_resume(struct hda_codec
*codec
)
4379 struct sigmatel_spec
*spec
= codec
->spec
;
4381 stac92xx_set_config_regs(codec
);
4382 stac92xx_init(codec
);
4383 snd_hda_codec_resume_amp(codec
);
4384 snd_hda_codec_resume_cache(codec
);
4385 /* fake event to set up pins again to override cached values */
4386 if (spec
->hp_detect
)
4387 stac_issue_unsol_event(codec
, spec
->autocfg
.hp_pins
[0],
4392 static int stac92xx_suspend(struct hda_codec
*codec
, pm_message_t state
)
4394 struct sigmatel_spec
*spec
= codec
->spec
;
4395 if (spec
->eapd_mask
)
4396 stac_gpio_set(codec
, spec
->gpio_mask
,
4397 spec
->gpio_dir
, spec
->gpio_data
&
4403 static struct hda_codec_ops stac92xx_patch_ops
= {
4404 .build_controls
= stac92xx_build_controls
,
4405 .build_pcms
= stac92xx_build_pcms
,
4406 .init
= stac92xx_init
,
4407 .free
= stac92xx_free
,
4408 .unsol_event
= stac92xx_unsol_event
,
4409 #ifdef SND_HDA_NEEDS_RESUME
4410 .suspend
= stac92xx_suspend
,
4411 .resume
= stac92xx_resume
,
4415 static int patch_stac9200(struct hda_codec
*codec
)
4417 struct sigmatel_spec
*spec
;
4420 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4425 spec
->num_pins
= ARRAY_SIZE(stac9200_pin_nids
);
4426 spec
->pin_nids
= stac9200_pin_nids
;
4427 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_9200_MODELS
,
4430 if (spec
->board_config
< 0) {
4431 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4432 err
= stac92xx_save_bios_config_regs(codec
);
4434 err
= stac_save_pin_cfgs(codec
,
4435 stac9200_brd_tbl
[spec
->board_config
]);
4437 stac92xx_free(codec
);
4441 spec
->multiout
.max_channels
= 2;
4442 spec
->multiout
.num_dacs
= 1;
4443 spec
->multiout
.dac_nids
= stac9200_dac_nids
;
4444 spec
->adc_nids
= stac9200_adc_nids
;
4445 spec
->mux_nids
= stac9200_mux_nids
;
4446 spec
->num_muxes
= 1;
4447 spec
->num_dmics
= 0;
4451 if (spec
->board_config
== STAC_9200_M4
||
4452 spec
->board_config
== STAC_9200_M4_2
||
4453 spec
->board_config
== STAC_9200_OQO
)
4454 spec
->init
= stac9200_eapd_init
;
4456 spec
->init
= stac9200_core_init
;
4457 spec
->mixer
= stac9200_mixer
;
4459 if (spec
->board_config
== STAC_9200_PANASONIC
) {
4460 spec
->gpio_mask
= spec
->gpio_dir
= 0x09;
4461 spec
->gpio_data
= 0x00;
4464 err
= stac9200_parse_auto_config(codec
);
4466 stac92xx_free(codec
);
4470 /* CF-74 has no headphone detection, and the driver should *NOT*
4471 * do detection and HP/speaker toggle because the hardware does it.
4473 if (spec
->board_config
== STAC_9200_PANASONIC
)
4474 spec
->hp_detect
= 0;
4476 codec
->patch_ops
= stac92xx_patch_ops
;
4481 static int patch_stac925x(struct hda_codec
*codec
)
4483 struct sigmatel_spec
*spec
;
4486 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4491 spec
->num_pins
= ARRAY_SIZE(stac925x_pin_nids
);
4492 spec
->pin_nids
= stac925x_pin_nids
;
4494 /* Check first for codec ID */
4495 spec
->board_config
= snd_hda_check_board_codec_sid_config(codec
,
4498 stac925x_codec_id_cfg_tbl
);
4500 /* Now checks for PCI ID, if codec ID is not found */
4501 if (spec
->board_config
< 0)
4502 spec
->board_config
= snd_hda_check_board_config(codec
,
4507 if (spec
->board_config
< 0) {
4508 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC925x,"
4509 "using BIOS defaults\n");
4510 err
= stac92xx_save_bios_config_regs(codec
);
4512 err
= stac_save_pin_cfgs(codec
,
4513 stac925x_brd_tbl
[spec
->board_config
]);
4515 stac92xx_free(codec
);
4519 spec
->multiout
.max_channels
= 2;
4520 spec
->multiout
.num_dacs
= 1;
4521 spec
->multiout
.dac_nids
= stac925x_dac_nids
;
4522 spec
->adc_nids
= stac925x_adc_nids
;
4523 spec
->mux_nids
= stac925x_mux_nids
;
4524 spec
->num_muxes
= 1;
4527 switch (codec
->vendor_id
) {
4528 case 0x83847632: /* STAC9202 */
4529 case 0x83847633: /* STAC9202D */
4530 case 0x83847636: /* STAC9251 */
4531 case 0x83847637: /* STAC9251D */
4532 spec
->num_dmics
= STAC925X_NUM_DMICS
;
4533 spec
->dmic_nids
= stac925x_dmic_nids
;
4534 spec
->num_dmuxes
= ARRAY_SIZE(stac925x_dmux_nids
);
4535 spec
->dmux_nids
= stac925x_dmux_nids
;
4538 spec
->num_dmics
= 0;
4542 spec
->init
= stac925x_core_init
;
4543 spec
->mixer
= stac925x_mixer
;
4545 err
= stac92xx_parse_auto_config(codec
, 0x8, 0x7);
4547 if (spec
->board_config
< 0) {
4548 printk(KERN_WARNING
"hda_codec: No auto-config is "
4549 "available, default to model=ref\n");
4550 spec
->board_config
= STAC_925x_REF
;
4556 stac92xx_free(codec
);
4560 codec
->patch_ops
= stac92xx_patch_ops
;
4565 static struct hda_input_mux stac92hd73xx_dmux
= {
4568 { "Analog Inputs", 0x0b },
4569 { "Digital Mic 1", 0x09 },
4570 { "Digital Mic 2", 0x0a },
4575 static int patch_stac92hd73xx(struct hda_codec
*codec
)
4577 struct sigmatel_spec
*spec
;
4578 hda_nid_t conn
[STAC92HD73_DAC_COUNT
+ 2];
4582 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4587 codec
->slave_dig_outs
= stac92hd73xx_slave_dig_outs
;
4588 spec
->num_pins
= ARRAY_SIZE(stac92hd73xx_pin_nids
);
4589 spec
->pin_nids
= stac92hd73xx_pin_nids
;
4590 spec
->board_config
= snd_hda_check_board_config(codec
,
4591 STAC_92HD73XX_MODELS
,
4592 stac92hd73xx_models
,
4593 stac92hd73xx_cfg_tbl
);
4595 if (spec
->board_config
< 0) {
4596 snd_printdd(KERN_INFO
"hda_codec: Unknown model for"
4597 " STAC92HD73XX, using BIOS defaults\n");
4598 err
= stac92xx_save_bios_config_regs(codec
);
4600 err
= stac_save_pin_cfgs(codec
,
4601 stac92hd73xx_brd_tbl
[spec
->board_config
]);
4603 stac92xx_free(codec
);
4607 num_dacs
= snd_hda_get_connections(codec
, 0x0a,
4608 conn
, STAC92HD73_DAC_COUNT
+ 2) - 1;
4610 if (num_dacs
< 3 || num_dacs
> 5) {
4611 printk(KERN_WARNING
"hda_codec: Could not determine "
4612 "number of channels defaulting to DAC count\n");
4613 num_dacs
= STAC92HD73_DAC_COUNT
;
4616 case 0x3: /* 6 Channel */
4617 spec
->mixer
= stac92hd73xx_6ch_mixer
;
4618 spec
->init
= stac92hd73xx_6ch_core_init
;
4620 case 0x4: /* 8 Channel */
4621 spec
->mixer
= stac92hd73xx_8ch_mixer
;
4622 spec
->init
= stac92hd73xx_8ch_core_init
;
4624 case 0x5: /* 10 Channel */
4625 spec
->mixer
= stac92hd73xx_10ch_mixer
;
4626 spec
->init
= stac92hd73xx_10ch_core_init
;
4628 spec
->multiout
.dac_nids
= spec
->dac_nids
;
4630 spec
->aloopback_mask
= 0x01;
4631 spec
->aloopback_shift
= 8;
4633 spec
->digbeep_nid
= 0x1c;
4634 spec
->mux_nids
= stac92hd73xx_mux_nids
;
4635 spec
->adc_nids
= stac92hd73xx_adc_nids
;
4636 spec
->dmic_nids
= stac92hd73xx_dmic_nids
;
4637 spec
->dmux_nids
= stac92hd73xx_dmux_nids
;
4638 spec
->smux_nids
= stac92hd73xx_smux_nids
;
4639 spec
->amp_nids
= stac92hd73xx_amp_nids
;
4640 spec
->num_amps
= ARRAY_SIZE(stac92hd73xx_amp_nids
);
4642 spec
->num_muxes
= ARRAY_SIZE(stac92hd73xx_mux_nids
);
4643 spec
->num_adcs
= ARRAY_SIZE(stac92hd73xx_adc_nids
);
4644 spec
->num_dmuxes
= ARRAY_SIZE(stac92hd73xx_dmux_nids
);
4645 memcpy(&spec
->private_dimux
, &stac92hd73xx_dmux
,
4646 sizeof(stac92hd73xx_dmux
));
4648 switch (spec
->board_config
) {
4650 spec
->init
= dell_eq_core_init
;
4652 case STAC_DELL_M6_AMIC
:
4653 case STAC_DELL_M6_DMIC
:
4654 case STAC_DELL_M6_BOTH
:
4655 spec
->num_smuxes
= 0;
4656 spec
->mixer
= &stac92hd73xx_6ch_mixer
[DELL_M6_MIXER
];
4657 spec
->amp_nids
= &stac92hd73xx_amp_nids
[DELL_M6_AMP
];
4658 spec
->eapd_switch
= 0;
4661 if (spec
->board_config
!= STAC_DELL_EQ
)
4662 spec
->init
= dell_m6_core_init
;
4663 switch (spec
->board_config
) {
4664 case STAC_DELL_M6_AMIC
: /* Analog Mics */
4665 stac92xx_set_config_reg(codec
, 0x0b, 0x90A70170);
4666 spec
->num_dmics
= 0;
4667 spec
->private_dimux
.num_items
= 1;
4669 case STAC_DELL_M6_DMIC
: /* Digital Mics */
4670 stac92xx_set_config_reg(codec
, 0x13, 0x90A60160);
4671 spec
->num_dmics
= 1;
4672 spec
->private_dimux
.num_items
= 2;
4674 case STAC_DELL_M6_BOTH
: /* Both */
4675 stac92xx_set_config_reg(codec
, 0x0b, 0x90A70170);
4676 stac92xx_set_config_reg(codec
, 0x13, 0x90A60160);
4677 spec
->num_dmics
= 1;
4678 spec
->private_dimux
.num_items
= 2;
4683 spec
->num_dmics
= STAC92HD73XX_NUM_DMICS
;
4684 spec
->num_smuxes
= ARRAY_SIZE(stac92hd73xx_smux_nids
);
4685 spec
->eapd_switch
= 1;
4687 if (spec
->board_config
> STAC_92HD73XX_REF
) {
4688 /* GPIO0 High = Enable EAPD */
4689 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x1;
4690 spec
->gpio_data
= 0x01;
4692 spec
->dinput_mux
= &spec
->private_dimux
;
4694 spec
->num_pwrs
= ARRAY_SIZE(stac92hd73xx_pwr_nids
);
4695 spec
->pwr_nids
= stac92hd73xx_pwr_nids
;
4697 err
= stac92xx_parse_auto_config(codec
, 0x25, 0x27);
4700 if (spec
->board_config
< 0) {
4701 printk(KERN_WARNING
"hda_codec: No auto-config is "
4702 "available, default to model=ref\n");
4703 spec
->board_config
= STAC_92HD73XX_REF
;
4710 stac92xx_free(codec
);
4714 if (spec
->board_config
== STAC_92HD73XX_NO_JD
)
4715 spec
->hp_detect
= 0;
4717 codec
->patch_ops
= stac92xx_patch_ops
;
4719 codec
->proc_widget_hook
= stac92hd7x_proc_hook
;
4724 static struct hda_input_mux stac92hd83xxx_dmux
= {
4727 { "Analog Inputs", 0x03 },
4728 { "Digital Mic 1", 0x04 },
4729 { "Digital Mic 2", 0x05 },
4733 static int patch_stac92hd83xxx(struct hda_codec
*codec
)
4735 struct sigmatel_spec
*spec
;
4738 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4743 codec
->slave_dig_outs
= stac92hd83xxx_slave_dig_outs
;
4744 spec
->mono_nid
= 0x19;
4745 spec
->digbeep_nid
= 0x21;
4746 spec
->dmic_nids
= stac92hd83xxx_dmic_nids
;
4747 spec
->dmux_nids
= stac92hd83xxx_dmux_nids
;
4748 spec
->adc_nids
= stac92hd83xxx_adc_nids
;
4749 spec
->pwr_nids
= stac92hd83xxx_pwr_nids
;
4750 spec
->pwr_mapping
= stac92hd83xxx_pwr_mapping
;
4751 spec
->num_pwrs
= ARRAY_SIZE(stac92hd83xxx_pwr_nids
);
4752 spec
->multiout
.dac_nids
= spec
->dac_nids
;
4754 spec
->init
= stac92hd83xxx_core_init
;
4755 switch (codec
->vendor_id
) {
4760 spec
->init
++; /* switch to config #2 */
4763 spec
->mixer
= stac92hd83xxx_mixer
;
4764 spec
->num_pins
= ARRAY_SIZE(stac92hd83xxx_pin_nids
);
4765 spec
->num_dmuxes
= ARRAY_SIZE(stac92hd83xxx_dmux_nids
);
4766 spec
->num_adcs
= ARRAY_SIZE(stac92hd83xxx_adc_nids
);
4767 spec
->num_dmics
= STAC92HD83XXX_NUM_DMICS
;
4768 spec
->dinput_mux
= &stac92hd83xxx_dmux
;
4769 spec
->pin_nids
= stac92hd83xxx_pin_nids
;
4770 spec
->board_config
= snd_hda_check_board_config(codec
,
4771 STAC_92HD83XXX_MODELS
,
4772 stac92hd83xxx_models
,
4773 stac92hd83xxx_cfg_tbl
);
4775 if (spec
->board_config
< 0) {
4776 snd_printdd(KERN_INFO
"hda_codec: Unknown model for"
4777 " STAC92HD83XXX, using BIOS defaults\n");
4778 err
= stac92xx_save_bios_config_regs(codec
);
4780 err
= stac_save_pin_cfgs(codec
,
4781 stac92hd83xxx_brd_tbl
[spec
->board_config
]);
4783 stac92xx_free(codec
);
4787 err
= stac92xx_parse_auto_config(codec
, 0x1d, 0);
4789 if (spec
->board_config
< 0) {
4790 printk(KERN_WARNING
"hda_codec: No auto-config is "
4791 "available, default to model=ref\n");
4792 spec
->board_config
= STAC_92HD83XXX_REF
;
4799 stac92xx_free(codec
);
4803 codec
->patch_ops
= stac92xx_patch_ops
;
4805 codec
->proc_widget_hook
= stac92hd_proc_hook
;
4810 static struct hda_input_mux stac92hd71bxx_dmux
= {
4813 { "Analog Inputs", 0x00 },
4815 { "Digital Mic 1", 0x02 },
4816 { "Digital Mic 2", 0x03 },
4820 static int patch_stac92hd71bxx(struct hda_codec
*codec
)
4822 struct sigmatel_spec
*spec
;
4825 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4830 codec
->patch_ops
= stac92xx_patch_ops
;
4831 spec
->num_pins
= ARRAY_SIZE(stac92hd71bxx_pin_nids
);
4832 spec
->num_pwrs
= ARRAY_SIZE(stac92hd71bxx_pwr_nids
);
4833 spec
->pin_nids
= stac92hd71bxx_pin_nids
;
4834 memcpy(&spec
->private_dimux
, &stac92hd71bxx_dmux
,
4835 sizeof(stac92hd71bxx_dmux
));
4836 spec
->board_config
= snd_hda_check_board_config(codec
,
4837 STAC_92HD71BXX_MODELS
,
4838 stac92hd71bxx_models
,
4839 stac92hd71bxx_cfg_tbl
);
4841 if (spec
->board_config
< 0) {
4842 snd_printdd(KERN_INFO
"hda_codec: Unknown model for"
4843 " STAC92HD71BXX, using BIOS defaults\n");
4844 err
= stac92xx_save_bios_config_regs(codec
);
4846 err
= stac_save_pin_cfgs(codec
,
4847 stac92hd71bxx_brd_tbl
[spec
->board_config
]);
4849 stac92xx_free(codec
);
4853 if (spec
->board_config
> STAC_92HD71BXX_REF
) {
4855 spec
->gpio_mask
= 0x01;
4856 spec
->gpio_dir
= 0x01;
4857 spec
->gpio_data
= 0x01;
4860 switch (codec
->vendor_id
) {
4861 case 0x111d76b6: /* 4 Port without Analog Mixer */
4863 case 0x111d76b4: /* 6 Port without Analog Mixer */
4865 spec
->mixer
= stac92hd71bxx_mixer
;
4866 spec
->init
= stac92hd71bxx_core_init
;
4867 codec
->slave_dig_outs
= stac92hd71bxx_slave_dig_outs
;
4869 case 0x111d7608: /* 5 Port with Analog Mixer */
4870 switch (spec
->board_config
) {
4872 /* Enable VREF power saving on GPIO1 detect */
4873 err
= stac_add_event(spec
, codec
->afg
,
4874 STAC_VREF_EVENT
, 0x02);
4877 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
4878 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK
, 0x02);
4879 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
4880 AC_VERB_SET_UNSOLICITED_ENABLE
,
4882 spec
->gpio_mask
|= 0x02;
4885 if ((codec
->revision_id
& 0xf) == 0 ||
4886 (codec
->revision_id
& 0xf) == 1)
4887 spec
->stream_delay
= 40; /* 40 milliseconds */
4889 /* no output amps */
4891 spec
->mixer
= stac92hd71bxx_analog_mixer
;
4892 spec
->dinput_mux
= &spec
->private_dimux
;
4895 spec
->init
= &stac92hd71bxx_analog_core_init
[HD_DISABLE_PORTF
];
4896 stac_change_pin_config(codec
, 0xf, 0x40f000f0);
4898 case 0x111d7603: /* 6 Port with Analog Mixer */
4899 if ((codec
->revision_id
& 0xf) == 1)
4900 spec
->stream_delay
= 40; /* 40 milliseconds */
4902 /* no output amps */
4906 spec
->dinput_mux
= &spec
->private_dimux
;
4907 spec
->mixer
= stac92hd71bxx_analog_mixer
;
4908 spec
->init
= stac92hd71bxx_analog_core_init
;
4909 codec
->slave_dig_outs
= stac92hd71bxx_slave_dig_outs
;
4912 spec
->aloopback_mask
= 0x50;
4913 spec
->aloopback_shift
= 0;
4915 spec
->powerdown_adcs
= 1;
4916 spec
->digbeep_nid
= 0x26;
4917 spec
->mux_nids
= stac92hd71bxx_mux_nids
;
4918 spec
->adc_nids
= stac92hd71bxx_adc_nids
;
4919 spec
->dmic_nids
= stac92hd71bxx_dmic_nids
;
4920 spec
->dmux_nids
= stac92hd71bxx_dmux_nids
;
4921 spec
->smux_nids
= stac92hd71bxx_smux_nids
;
4922 spec
->pwr_nids
= stac92hd71bxx_pwr_nids
;
4924 spec
->num_muxes
= ARRAY_SIZE(stac92hd71bxx_mux_nids
);
4925 spec
->num_adcs
= ARRAY_SIZE(stac92hd71bxx_adc_nids
);
4927 switch (spec
->board_config
) {
4929 /* enable internal microphone */
4930 stac_change_pin_config(codec
, 0x0e, 0x01813040);
4931 stac92xx_auto_set_pinctl(codec
, 0x0e,
4932 AC_PINCTL_IN_EN
| AC_PINCTL_VREF_80
);
4934 case STAC_DELL_M4_2
:
4935 spec
->num_dmics
= 0;
4936 spec
->num_smuxes
= 0;
4937 spec
->num_dmuxes
= 0;
4939 case STAC_DELL_M4_1
:
4940 case STAC_DELL_M4_3
:
4941 spec
->num_dmics
= 1;
4942 spec
->num_smuxes
= 0;
4943 spec
->num_dmuxes
= 0;
4946 spec
->num_dmics
= STAC92HD71BXX_NUM_DMICS
;
4947 spec
->num_smuxes
= ARRAY_SIZE(stac92hd71bxx_smux_nids
);
4948 spec
->num_dmuxes
= ARRAY_SIZE(stac92hd71bxx_dmux_nids
);
4951 spec
->multiout
.dac_nids
= spec
->dac_nids
;
4952 if (spec
->dinput_mux
)
4953 spec
->private_dimux
.num_items
+=
4955 (ARRAY_SIZE(stac92hd71bxx_dmic_nids
) - 1);
4957 err
= stac92xx_parse_auto_config(codec
, 0x21, 0x23);
4959 if (spec
->board_config
< 0) {
4960 printk(KERN_WARNING
"hda_codec: No auto-config is "
4961 "available, default to model=ref\n");
4962 spec
->board_config
= STAC_92HD71BXX_REF
;
4969 stac92xx_free(codec
);
4973 codec
->proc_widget_hook
= stac92hd7x_proc_hook
;
4978 static int patch_stac922x(struct hda_codec
*codec
)
4980 struct sigmatel_spec
*spec
;
4983 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4988 spec
->num_pins
= ARRAY_SIZE(stac922x_pin_nids
);
4989 spec
->pin_nids
= stac922x_pin_nids
;
4990 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_922X_MODELS
,
4993 if (spec
->board_config
== STAC_INTEL_MAC_AUTO
) {
4994 spec
->gpio_mask
= spec
->gpio_dir
= 0x03;
4995 spec
->gpio_data
= 0x03;
4996 /* Intel Macs have all same PCI SSID, so we need to check
4997 * codec SSID to distinguish the exact models
4999 printk(KERN_INFO
"hda_codec: STAC922x, Apple subsys_id=%x\n", codec
->subsystem_id
);
5000 switch (codec
->subsystem_id
) {
5003 spec
->board_config
= STAC_INTEL_MAC_V1
;
5007 spec
->board_config
= STAC_INTEL_MAC_V2
;
5015 spec
->board_config
= STAC_INTEL_MAC_V3
;
5019 spec
->board_config
= STAC_INTEL_MAC_V4
;
5023 spec
->board_config
= STAC_INTEL_MAC_V5
;
5026 spec
->board_config
= STAC_INTEL_MAC_V3
;
5032 if (spec
->board_config
< 0) {
5033 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC922x, "
5034 "using BIOS defaults\n");
5035 err
= stac92xx_save_bios_config_regs(codec
);
5037 err
= stac_save_pin_cfgs(codec
,
5038 stac922x_brd_tbl
[spec
->board_config
]);
5040 stac92xx_free(codec
);
5044 spec
->adc_nids
= stac922x_adc_nids
;
5045 spec
->mux_nids
= stac922x_mux_nids
;
5046 spec
->num_muxes
= ARRAY_SIZE(stac922x_mux_nids
);
5047 spec
->num_adcs
= ARRAY_SIZE(stac922x_adc_nids
);
5048 spec
->num_dmics
= 0;
5051 spec
->init
= stac922x_core_init
;
5052 spec
->mixer
= stac922x_mixer
;
5054 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5056 err
= stac92xx_parse_auto_config(codec
, 0x08, 0x09);
5058 if (spec
->board_config
< 0) {
5059 printk(KERN_WARNING
"hda_codec: No auto-config is "
5060 "available, default to model=ref\n");
5061 spec
->board_config
= STAC_D945_REF
;
5067 stac92xx_free(codec
);
5071 codec
->patch_ops
= stac92xx_patch_ops
;
5073 /* Fix Mux capture level; max to 2 */
5074 snd_hda_override_amp_caps(codec
, 0x12, HDA_OUTPUT
,
5075 (0 << AC_AMPCAP_OFFSET_SHIFT
) |
5076 (2 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
5077 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
5078 (0 << AC_AMPCAP_MUTE_SHIFT
));
5083 static int patch_stac927x(struct hda_codec
*codec
)
5085 struct sigmatel_spec
*spec
;
5088 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5093 spec
->num_pins
= ARRAY_SIZE(stac927x_pin_nids
);
5094 spec
->pin_nids
= stac927x_pin_nids
;
5095 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_927X_MODELS
,
5099 if (spec
->board_config
< 0 || !stac927x_brd_tbl
[spec
->board_config
]) {
5100 if (spec
->board_config
< 0)
5101 snd_printdd(KERN_INFO
"hda_codec: Unknown model for"
5102 "STAC927x, using BIOS defaults\n");
5103 err
= stac92xx_save_bios_config_regs(codec
);
5105 err
= stac_save_pin_cfgs(codec
,
5106 stac927x_brd_tbl
[spec
->board_config
]);
5108 stac92xx_free(codec
);
5112 spec
->digbeep_nid
= 0x23;
5113 spec
->adc_nids
= stac927x_adc_nids
;
5114 spec
->num_adcs
= ARRAY_SIZE(stac927x_adc_nids
);
5115 spec
->mux_nids
= stac927x_mux_nids
;
5116 spec
->num_muxes
= ARRAY_SIZE(stac927x_mux_nids
);
5117 spec
->smux_nids
= stac927x_smux_nids
;
5118 spec
->num_smuxes
= ARRAY_SIZE(stac927x_smux_nids
);
5119 spec
->spdif_labels
= stac927x_spdif_labels
;
5120 spec
->dac_list
= stac927x_dac_nids
;
5121 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5123 switch (spec
->board_config
) {
5126 /* GPIO0 High = Enable EAPD */
5127 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x01;
5128 spec
->gpio_data
= 0x01;
5129 spec
->num_dmics
= 0;
5131 spec
->init
= d965_core_init
;
5132 spec
->mixer
= stac927x_mixer
;
5134 case STAC_DELL_BIOS
:
5135 switch (codec
->subsystem_id
) {
5138 /* correct the device field to SPDIF out */
5139 stac_change_pin_config(codec
, 0x21, 0x01442070);
5142 /* configure the analog microphone on some laptops */
5143 stac_change_pin_config(codec
, 0x0c, 0x90a79130);
5144 /* correct the front output jack as a hp out */
5145 stac_change_pin_config(codec
, 0x0f, 0x0227011f);
5146 /* correct the front input jack as a mic */
5147 stac_change_pin_config(codec
, 0x0e, 0x02a79130);
5150 /* GPIO2 High = Enable EAPD */
5151 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x04;
5152 spec
->gpio_data
= 0x04;
5153 spec
->dmic_nids
= stac927x_dmic_nids
;
5154 spec
->num_dmics
= STAC927X_NUM_DMICS
;
5156 spec
->init
= d965_core_init
;
5157 spec
->mixer
= stac927x_mixer
;
5158 spec
->dmux_nids
= stac927x_dmux_nids
;
5159 spec
->num_dmuxes
= ARRAY_SIZE(stac927x_dmux_nids
);
5162 if (spec
->board_config
> STAC_D965_REF
) {
5163 /* GPIO0 High = Enable EAPD */
5164 spec
->eapd_mask
= spec
->gpio_mask
= 0x01;
5165 spec
->gpio_dir
= spec
->gpio_data
= 0x01;
5167 spec
->num_dmics
= 0;
5169 spec
->init
= stac927x_core_init
;
5170 spec
->mixer
= stac927x_mixer
;
5174 spec
->aloopback_mask
= 0x40;
5175 spec
->aloopback_shift
= 0;
5176 spec
->eapd_switch
= 1;
5178 err
= stac92xx_parse_auto_config(codec
, 0x1e, 0x20);
5180 if (spec
->board_config
< 0) {
5181 printk(KERN_WARNING
"hda_codec: No auto-config is "
5182 "available, default to model=ref\n");
5183 spec
->board_config
= STAC_D965_REF
;
5189 stac92xx_free(codec
);
5193 codec
->patch_ops
= stac92xx_patch_ops
;
5195 codec
->proc_widget_hook
= stac927x_proc_hook
;
5199 * The STAC927x seem to require fairly long delays for certain
5200 * command sequences. With too short delays (even if the answer
5201 * is set to RIRB properly), it results in the silence output
5202 * on some hardwares like Dell.
5204 * The below flag enables the longer delay (see get_response
5207 codec
->bus
->needs_damn_long_delay
= 1;
5209 /* no jack detecion for ref-no-jd model */
5210 if (spec
->board_config
== STAC_D965_REF_NO_JD
)
5211 spec
->hp_detect
= 0;
5216 static int patch_stac9205(struct hda_codec
*codec
)
5218 struct sigmatel_spec
*spec
;
5221 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5226 spec
->num_pins
= ARRAY_SIZE(stac9205_pin_nids
);
5227 spec
->pin_nids
= stac9205_pin_nids
;
5228 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_9205_MODELS
,
5232 if (spec
->board_config
< 0) {
5233 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5234 err
= stac92xx_save_bios_config_regs(codec
);
5236 err
= stac_save_pin_cfgs(codec
,
5237 stac9205_brd_tbl
[spec
->board_config
]);
5239 stac92xx_free(codec
);
5243 spec
->digbeep_nid
= 0x23;
5244 spec
->adc_nids
= stac9205_adc_nids
;
5245 spec
->num_adcs
= ARRAY_SIZE(stac9205_adc_nids
);
5246 spec
->mux_nids
= stac9205_mux_nids
;
5247 spec
->num_muxes
= ARRAY_SIZE(stac9205_mux_nids
);
5248 spec
->smux_nids
= stac9205_smux_nids
;
5249 spec
->num_smuxes
= ARRAY_SIZE(stac9205_smux_nids
);
5250 spec
->dmic_nids
= stac9205_dmic_nids
;
5251 spec
->num_dmics
= STAC9205_NUM_DMICS
;
5252 spec
->dmux_nids
= stac9205_dmux_nids
;
5253 spec
->num_dmuxes
= ARRAY_SIZE(stac9205_dmux_nids
);
5256 spec
->init
= stac9205_core_init
;
5257 spec
->mixer
= stac9205_mixer
;
5259 spec
->aloopback_mask
= 0x40;
5260 spec
->aloopback_shift
= 0;
5261 spec
->eapd_switch
= 1;
5262 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5264 switch (spec
->board_config
){
5265 case STAC_9205_DELL_M43
:
5266 /* Enable SPDIF in/out */
5267 stac_change_pin_config(codec
, 0x1f, 0x01441030);
5268 stac_change_pin_config(codec
, 0x20, 0x1c410030);
5270 /* Enable unsol response for GPIO4/Dock HP connection */
5271 err
= stac_add_event(spec
, codec
->afg
, STAC_VREF_EVENT
, 0x01);
5274 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
5275 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK
, 0x10);
5276 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
5277 AC_VERB_SET_UNSOLICITED_ENABLE
,
5280 spec
->gpio_dir
= 0x0b;
5281 spec
->eapd_mask
= 0x01;
5282 spec
->gpio_mask
= 0x1b;
5283 spec
->gpio_mute
= 0x10;
5284 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
5287 spec
->gpio_data
= 0x01;
5290 /* SPDIF-In enabled */
5293 /* GPIO0 High = EAPD */
5294 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x1;
5295 spec
->gpio_data
= 0x01;
5299 err
= stac92xx_parse_auto_config(codec
, 0x1f, 0x20);
5301 if (spec
->board_config
< 0) {
5302 printk(KERN_WARNING
"hda_codec: No auto-config is "
5303 "available, default to model=ref\n");
5304 spec
->board_config
= STAC_9205_REF
;
5310 stac92xx_free(codec
);
5314 codec
->patch_ops
= stac92xx_patch_ops
;
5316 codec
->proc_widget_hook
= stac9205_proc_hook
;
5325 /* static config for Sony VAIO FE550G and Sony VAIO AR */
5326 static hda_nid_t vaio_dacs
[] = { 0x2 };
5327 #define VAIO_HP_DAC 0x5
5328 static hda_nid_t vaio_adcs
[] = { 0x8 /*,0x6*/ };
5329 static hda_nid_t vaio_mux_nids
[] = { 0x15 };
5331 static struct hda_input_mux vaio_mux
= {
5334 /* { "HP", 0x0 }, */
5335 { "Mic Jack", 0x1 },
5336 { "Internal Mic", 0x2 },
5341 static struct hda_verb vaio_init
[] = {
5342 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
}, /* HP <- 0x2 */
5343 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE
, AC_USRSP_EN
| STAC_HP_EVENT
},
5344 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* Speaker <- 0x5 */
5345 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Mic? (<- 0x2) */
5346 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* CD */
5347 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Mic? */
5348 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mic-sel: 0a,0d,14,02 */
5349 {0x02, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
}, /* HP */
5350 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
}, /* Speaker */
5351 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5352 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5353 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
}, /* Mic-in -> 0x9 */
5357 static struct hda_verb vaio_ar_init
[] = {
5358 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
}, /* HP <- 0x2 */
5359 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* Speaker <- 0x5 */
5360 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Mic? (<- 0x2) */
5361 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* CD */
5362 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5363 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Mic? */
5364 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mic-sel: 0a,0d,14,02 */
5365 {0x02, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
}, /* HP */
5366 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
}, /* Speaker */
5367 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5368 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5369 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5370 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
}, /* Mic-in -> 0x9 */
5374 static struct snd_kcontrol_new vaio_mixer
[] = {
5375 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT
),
5376 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT
),
5377 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT
),
5378 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT
),
5379 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5380 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT
),
5381 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT
),
5383 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
5384 .name
= "Capture Source",
5386 .info
= stac92xx_mux_enum_info
,
5387 .get
= stac92xx_mux_enum_get
,
5388 .put
= stac92xx_mux_enum_put
,
5393 static struct snd_kcontrol_new vaio_ar_mixer
[] = {
5394 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT
),
5395 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT
),
5396 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT
),
5397 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT
),
5398 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5399 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT
),
5400 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT
),
5401 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5402 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5404 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
5405 .name
= "Capture Source",
5407 .info
= stac92xx_mux_enum_info
,
5408 .get
= stac92xx_mux_enum_get
,
5409 .put
= stac92xx_mux_enum_put
,
5414 static struct hda_codec_ops stac9872_patch_ops
= {
5415 .build_controls
= stac92xx_build_controls
,
5416 .build_pcms
= stac92xx_build_pcms
,
5417 .init
= stac92xx_init
,
5418 .free
= stac92xx_free
,
5419 #ifdef SND_HDA_NEEDS_RESUME
5420 .resume
= stac92xx_resume
,
5424 static int stac9872_vaio_init(struct hda_codec
*codec
)
5428 err
= stac92xx_init(codec
);
5431 if (codec
->patch_ops
.unsol_event
)
5432 codec
->patch_ops
.unsol_event(codec
, STAC_HP_EVENT
<< 26);
5436 static void stac9872_vaio_hp_detect(struct hda_codec
*codec
, unsigned int res
)
5438 if (get_pin_presence(codec
, 0x0a)) {
5439 stac92xx_reset_pinctl(codec
, 0x0f, AC_PINCTL_OUT_EN
);
5440 stac92xx_set_pinctl(codec
, 0x0a, AC_PINCTL_OUT_EN
);
5442 stac92xx_reset_pinctl(codec
, 0x0a, AC_PINCTL_OUT_EN
);
5443 stac92xx_set_pinctl(codec
, 0x0f, AC_PINCTL_OUT_EN
);
5447 static void stac9872_vaio_unsol_event(struct hda_codec
*codec
, unsigned int res
)
5449 switch (res
>> 26) {
5451 stac9872_vaio_hp_detect(codec
, res
);
5456 static struct hda_codec_ops stac9872_vaio_patch_ops
= {
5457 .build_controls
= stac92xx_build_controls
,
5458 .build_pcms
= stac92xx_build_pcms
,
5459 .init
= stac9872_vaio_init
,
5460 .free
= stac92xx_free
,
5461 .unsol_event
= stac9872_vaio_unsol_event
,
5463 .resume
= stac92xx_resume
,
5467 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5469 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5471 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5473 /* AR Series. id=0x83847664 and subsys=104D1300 */
5478 static const char *stac9872_models
[STAC_9872_MODELS
] = {
5479 [CXD9872RD_VAIO
] = "vaio",
5480 [CXD9872AKD_VAIO
] = "vaio-ar",
5483 static struct snd_pci_quirk stac9872_cfg_tbl
[] = {
5484 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO
),
5485 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO
),
5486 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO
),
5487 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO
),
5491 static int patch_stac9872(struct hda_codec
*codec
)
5493 struct sigmatel_spec
*spec
;
5496 board_config
= snd_hda_check_board_config(codec
, STAC_9872_MODELS
,
5499 if (board_config
< 0)
5500 /* unknown config, let generic-parser do its job... */
5501 return snd_hda_parse_generic_codec(codec
);
5503 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5508 switch (board_config
) {
5509 case CXD9872RD_VAIO
:
5510 case STAC9872AK_VAIO
:
5511 case STAC9872K_VAIO
:
5512 spec
->mixer
= vaio_mixer
;
5513 spec
->init
= vaio_init
;
5514 spec
->multiout
.max_channels
= 2;
5515 spec
->multiout
.num_dacs
= ARRAY_SIZE(vaio_dacs
);
5516 spec
->multiout
.dac_nids
= vaio_dacs
;
5517 spec
->multiout
.hp_nid
= VAIO_HP_DAC
;
5518 spec
->num_adcs
= ARRAY_SIZE(vaio_adcs
);
5519 spec
->adc_nids
= vaio_adcs
;
5521 spec
->input_mux
= &vaio_mux
;
5522 spec
->mux_nids
= vaio_mux_nids
;
5523 codec
->patch_ops
= stac9872_vaio_patch_ops
;
5526 case CXD9872AKD_VAIO
:
5527 spec
->mixer
= vaio_ar_mixer
;
5528 spec
->init
= vaio_ar_init
;
5529 spec
->multiout
.max_channels
= 2;
5530 spec
->multiout
.num_dacs
= ARRAY_SIZE(vaio_dacs
);
5531 spec
->multiout
.dac_nids
= vaio_dacs
;
5532 spec
->multiout
.hp_nid
= VAIO_HP_DAC
;
5533 spec
->num_adcs
= ARRAY_SIZE(vaio_adcs
);
5535 spec
->adc_nids
= vaio_adcs
;
5536 spec
->input_mux
= &vaio_mux
;
5537 spec
->mux_nids
= vaio_mux_nids
;
5538 codec
->patch_ops
= stac9872_patch_ops
;
5549 static struct hda_codec_preset snd_hda_preset_sigmatel
[] = {
5550 { .id
= 0x83847690, .name
= "STAC9200", .patch
= patch_stac9200
},
5551 { .id
= 0x83847882, .name
= "STAC9220 A1", .patch
= patch_stac922x
},
5552 { .id
= 0x83847680, .name
= "STAC9221 A1", .patch
= patch_stac922x
},
5553 { .id
= 0x83847880, .name
= "STAC9220 A2", .patch
= patch_stac922x
},
5554 { .id
= 0x83847681, .name
= "STAC9220D/9223D A2", .patch
= patch_stac922x
},
5555 { .id
= 0x83847682, .name
= "STAC9221 A2", .patch
= patch_stac922x
},
5556 { .id
= 0x83847683, .name
= "STAC9221D A2", .patch
= patch_stac922x
},
5557 { .id
= 0x83847618, .name
= "STAC9227", .patch
= patch_stac927x
},
5558 { .id
= 0x83847619, .name
= "STAC9227", .patch
= patch_stac927x
},
5559 { .id
= 0x83847616, .name
= "STAC9228", .patch
= patch_stac927x
},
5560 { .id
= 0x83847617, .name
= "STAC9228", .patch
= patch_stac927x
},
5561 { .id
= 0x83847614, .name
= "STAC9229", .patch
= patch_stac927x
},
5562 { .id
= 0x83847615, .name
= "STAC9229", .patch
= patch_stac927x
},
5563 { .id
= 0x83847620, .name
= "STAC9274", .patch
= patch_stac927x
},
5564 { .id
= 0x83847621, .name
= "STAC9274D", .patch
= patch_stac927x
},
5565 { .id
= 0x83847622, .name
= "STAC9273X", .patch
= patch_stac927x
},
5566 { .id
= 0x83847623, .name
= "STAC9273D", .patch
= patch_stac927x
},
5567 { .id
= 0x83847624, .name
= "STAC9272X", .patch
= patch_stac927x
},
5568 { .id
= 0x83847625, .name
= "STAC9272D", .patch
= patch_stac927x
},
5569 { .id
= 0x83847626, .name
= "STAC9271X", .patch
= patch_stac927x
},
5570 { .id
= 0x83847627, .name
= "STAC9271D", .patch
= patch_stac927x
},
5571 { .id
= 0x83847628, .name
= "STAC9274X5NH", .patch
= patch_stac927x
},
5572 { .id
= 0x83847629, .name
= "STAC9274D5NH", .patch
= patch_stac927x
},
5573 { .id
= 0x83847632, .name
= "STAC9202", .patch
= patch_stac925x
},
5574 { .id
= 0x83847633, .name
= "STAC9202D", .patch
= patch_stac925x
},
5575 { .id
= 0x83847634, .name
= "STAC9250", .patch
= patch_stac925x
},
5576 { .id
= 0x83847635, .name
= "STAC9250D", .patch
= patch_stac925x
},
5577 { .id
= 0x83847636, .name
= "STAC9251", .patch
= patch_stac925x
},
5578 { .id
= 0x83847637, .name
= "STAC9250D", .patch
= patch_stac925x
},
5579 { .id
= 0x83847645, .name
= "92HD206X", .patch
= patch_stac927x
},
5580 { .id
= 0x83847646, .name
= "92HD206D", .patch
= patch_stac927x
},
5581 /* The following does not take into account .id=0x83847661 when subsys =
5582 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5583 * currently not fully supported.
5585 { .id
= 0x83847661, .name
= "CXD9872RD/K", .patch
= patch_stac9872
},
5586 { .id
= 0x83847662, .name
= "STAC9872AK", .patch
= patch_stac9872
},
5587 { .id
= 0x83847664, .name
= "CXD9872AKD", .patch
= patch_stac9872
},
5588 { .id
= 0x838476a0, .name
= "STAC9205", .patch
= patch_stac9205
},
5589 { .id
= 0x838476a1, .name
= "STAC9205D", .patch
= patch_stac9205
},
5590 { .id
= 0x838476a2, .name
= "STAC9204", .patch
= patch_stac9205
},
5591 { .id
= 0x838476a3, .name
= "STAC9204D", .patch
= patch_stac9205
},
5592 { .id
= 0x838476a4, .name
= "STAC9255", .patch
= patch_stac9205
},
5593 { .id
= 0x838476a5, .name
= "STAC9255D", .patch
= patch_stac9205
},
5594 { .id
= 0x838476a6, .name
= "STAC9254", .patch
= patch_stac9205
},
5595 { .id
= 0x838476a7, .name
= "STAC9254D", .patch
= patch_stac9205
},
5596 { .id
= 0x111d7603, .name
= "92HD75B3X5", .patch
= patch_stac92hd71bxx
},
5597 { .id
= 0x111d7604, .name
= "92HD83C1X5", .patch
= patch_stac92hd83xxx
},
5598 { .id
= 0x111d7605, .name
= "92HD81B1X5", .patch
= patch_stac92hd83xxx
},
5599 { .id
= 0x111d7608, .name
= "92HD75B2X5", .patch
= patch_stac92hd71bxx
},
5600 { .id
= 0x111d7674, .name
= "92HD73D1X5", .patch
= patch_stac92hd73xx
},
5601 { .id
= 0x111d7675, .name
= "92HD73C1X5", .patch
= patch_stac92hd73xx
},
5602 { .id
= 0x111d7676, .name
= "92HD73E1X5", .patch
= patch_stac92hd73xx
},
5603 { .id
= 0x111d76b0, .name
= "92HD71B8X", .patch
= patch_stac92hd71bxx
},
5604 { .id
= 0x111d76b1, .name
= "92HD71B8X", .patch
= patch_stac92hd71bxx
},
5605 { .id
= 0x111d76b2, .name
= "92HD71B7X", .patch
= patch_stac92hd71bxx
},
5606 { .id
= 0x111d76b3, .name
= "92HD71B7X", .patch
= patch_stac92hd71bxx
},
5607 { .id
= 0x111d76b4, .name
= "92HD71B6X", .patch
= patch_stac92hd71bxx
},
5608 { .id
= 0x111d76b5, .name
= "92HD71B6X", .patch
= patch_stac92hd71bxx
},
5609 { .id
= 0x111d76b6, .name
= "92HD71B5X", .patch
= patch_stac92hd71bxx
},
5610 { .id
= 0x111d76b7, .name
= "92HD71B5X", .patch
= patch_stac92hd71bxx
},
5614 MODULE_ALIAS("snd-hda-codec-id:8384*");
5615 MODULE_ALIAS("snd-hda-codec-id:111d*");
5617 MODULE_LICENSE("GPL");
5618 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5620 static struct hda_codec_preset_list sigmatel_list
= {
5621 .preset
= snd_hda_preset_sigmatel
,
5622 .owner
= THIS_MODULE
,
5625 static int __init
patch_sigmatel_init(void)
5627 return snd_hda_add_codec_preset(&sigmatel_list
);
5630 static void __exit
patch_sigmatel_exit(void)
5632 snd_hda_delete_codec_preset(&sigmatel_list
);
5635 module_init(patch_sigmatel_init
)
5636 module_exit(patch_sigmatel_exit
)