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"
77 STAC_92HD73XX_NO_JD
, /* no jack-detection */
89 STAC_92HD83XXX_PWR_REF
,
104 STAC_92HD71BXX_MODELS
130 STAC_INTEL_MAC_AUTO
, /* This model is selected if no module parameter
131 * is given, one of the above models will be
132 * chosen according to the subsystem id. */
133 /* for backward compatibility */
150 STAC_D965_REF_NO_JD
, /* no jack-detection */
165 struct sigmatel_event
{
172 struct sigmatel_jack
{
175 struct snd_jack
*jack
;
178 struct sigmatel_spec
{
179 struct snd_kcontrol_new
*mixers
[4];
180 unsigned int num_mixers
;
183 unsigned int eapd_switch
: 1;
184 unsigned int surr_switch
: 1;
185 unsigned int alt_switch
: 1;
186 unsigned int hp_detect
: 1;
187 unsigned int spdif_mute
: 1;
188 unsigned int check_volume_offset
:1;
191 unsigned int eapd_mask
;
192 unsigned int gpio_mask
;
193 unsigned int gpio_dir
;
194 unsigned int gpio_data
;
195 unsigned int gpio_mute
;
198 unsigned int stream_delay
;
200 /* analog loopback */
201 struct snd_kcontrol_new
*aloopback_ctl
;
202 unsigned char aloopback_mask
;
203 unsigned char aloopback_shift
;
205 /* power management */
206 unsigned int num_pwrs
;
207 unsigned int *pwr_mapping
;
212 struct snd_array jacks
;
215 struct snd_array events
;
218 struct hda_input_mux
*mono_mux
;
219 struct hda_input_mux
*amp_mux
;
220 unsigned int cur_mmux
;
221 struct hda_multi_out multiout
;
222 hda_nid_t dac_nids
[5];
223 hda_nid_t hp_dacs
[5];
224 hda_nid_t speaker_dacs
[5];
230 unsigned int num_adcs
;
232 unsigned int num_muxes
;
233 hda_nid_t
*dmic_nids
;
234 unsigned int num_dmics
;
235 hda_nid_t
*dmux_nids
;
236 unsigned int num_dmuxes
;
237 hda_nid_t
*smux_nids
;
238 unsigned int num_smuxes
;
239 const char **spdif_labels
;
241 hda_nid_t dig_in_nid
;
243 hda_nid_t anabeep_nid
;
244 hda_nid_t digbeep_nid
;
248 unsigned int num_pins
;
250 /* codec specific stuff */
251 struct hda_verb
*init
;
252 struct snd_kcontrol_new
*mixer
;
255 struct hda_input_mux
*dinput_mux
;
256 unsigned int cur_dmux
[2];
257 struct hda_input_mux
*input_mux
;
258 unsigned int cur_mux
[3];
259 struct hda_input_mux
*sinput_mux
;
260 unsigned int cur_smux
[2];
261 unsigned int cur_amux
;
263 unsigned int num_amps
;
264 unsigned int powerdown_adcs
;
267 unsigned int io_switch
[2];
268 unsigned int clfe_swap
;
269 hda_nid_t line_switch
; /* shared line-in for input and output */
270 hda_nid_t mic_switch
; /* shared mic-in for input and output */
271 hda_nid_t hp_switch
; /* NID of HP as line-out */
272 unsigned int aloopback
;
274 struct hda_pcm pcm_rec
[2]; /* PCM information */
276 /* dynamic controls and input_mux */
277 struct auto_pin_cfg autocfg
;
278 struct snd_array kctls
;
279 struct hda_input_mux private_dimux
;
280 struct hda_input_mux private_imux
;
281 struct hda_input_mux private_smux
;
282 struct hda_input_mux private_amp_mux
;
283 struct hda_input_mux private_mono_mux
;
286 static hda_nid_t stac9200_adc_nids
[1] = {
290 static hda_nid_t stac9200_mux_nids
[1] = {
294 static hda_nid_t stac9200_dac_nids
[1] = {
298 static hda_nid_t stac92hd73xx_pwr_nids
[8] = {
299 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
303 static hda_nid_t stac92hd73xx_slave_dig_outs
[2] = {
307 static hda_nid_t stac92hd73xx_adc_nids
[2] = {
311 #define DELL_M6_AMP 2
312 static hda_nid_t stac92hd73xx_amp_nids
[3] = {
316 #define STAC92HD73XX_NUM_DMICS 2
317 static hda_nid_t stac92hd73xx_dmic_nids
[STAC92HD73XX_NUM_DMICS
+ 1] = {
321 #define STAC92HD73_DAC_COUNT 5
323 static hda_nid_t stac92hd73xx_mux_nids
[4] = {
324 0x28, 0x29, 0x2a, 0x2b,
327 static hda_nid_t stac92hd73xx_dmux_nids
[2] = {
331 static hda_nid_t stac92hd73xx_smux_nids
[2] = {
335 #define STAC92HD83XXX_NUM_DMICS 2
336 static hda_nid_t stac92hd83xxx_dmic_nids
[STAC92HD83XXX_NUM_DMICS
+ 1] = {
340 #define STAC92HD83_DAC_COUNT 3
342 static hda_nid_t stac92hd83xxx_dmux_nids
[2] = {
346 static hda_nid_t stac92hd83xxx_adc_nids
[2] = {
350 static hda_nid_t stac92hd83xxx_pwr_nids
[4] = {
354 static hda_nid_t stac92hd83xxx_slave_dig_outs
[2] = {
358 static unsigned int stac92hd83xxx_pwr_mapping
[4] = {
359 0x03, 0x0c, 0x20, 0x40,
362 static hda_nid_t stac92hd83xxx_amp_nids
[1] = {
366 static hda_nid_t stac92hd71bxx_pwr_nids
[3] = {
370 static hda_nid_t stac92hd71bxx_adc_nids
[2] = {
374 static hda_nid_t stac92hd71bxx_mux_nids
[2] = {
378 static hda_nid_t stac92hd71bxx_dmux_nids
[2] = {
382 static hda_nid_t stac92hd71bxx_smux_nids
[2] = {
386 #define STAC92HD71BXX_NUM_DMICS 2
387 static hda_nid_t stac92hd71bxx_dmic_nids
[STAC92HD71BXX_NUM_DMICS
+ 1] = {
391 static hda_nid_t stac92hd71bxx_slave_dig_outs
[2] = {
395 static hda_nid_t stac925x_adc_nids
[1] = {
399 static hda_nid_t stac925x_mux_nids
[1] = {
403 static hda_nid_t stac925x_dac_nids
[1] = {
407 #define STAC925X_NUM_DMICS 1
408 static hda_nid_t stac925x_dmic_nids
[STAC925X_NUM_DMICS
+ 1] = {
412 static hda_nid_t stac925x_dmux_nids
[1] = {
416 static hda_nid_t stac922x_adc_nids
[2] = {
420 static hda_nid_t stac922x_mux_nids
[2] = {
424 static hda_nid_t stac927x_slave_dig_outs
[2] = {
428 static hda_nid_t stac927x_adc_nids
[3] = {
432 static hda_nid_t stac927x_mux_nids
[3] = {
436 static hda_nid_t stac927x_smux_nids
[1] = {
440 static hda_nid_t stac927x_dac_nids
[6] = {
441 0x02, 0x03, 0x04, 0x05, 0x06, 0
444 static hda_nid_t stac927x_dmux_nids
[1] = {
448 #define STAC927X_NUM_DMICS 2
449 static hda_nid_t stac927x_dmic_nids
[STAC927X_NUM_DMICS
+ 1] = {
453 static const char *stac927x_spdif_labels
[5] = {
454 "Digital Playback", "ADAT", "Analog Mux 1",
455 "Analog Mux 2", "Analog Mux 3"
458 static hda_nid_t stac9205_adc_nids
[2] = {
462 static hda_nid_t stac9205_mux_nids
[2] = {
466 static hda_nid_t stac9205_dmux_nids
[1] = {
470 static hda_nid_t stac9205_smux_nids
[1] = {
474 #define STAC9205_NUM_DMICS 2
475 static hda_nid_t stac9205_dmic_nids
[STAC9205_NUM_DMICS
+ 1] = {
479 static hda_nid_t stac9200_pin_nids
[8] = {
480 0x08, 0x09, 0x0d, 0x0e,
481 0x0f, 0x10, 0x11, 0x12,
484 static hda_nid_t stac925x_pin_nids
[8] = {
485 0x07, 0x08, 0x0a, 0x0b,
486 0x0c, 0x0d, 0x10, 0x11,
489 static hda_nid_t stac922x_pin_nids
[10] = {
490 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
491 0x0f, 0x10, 0x11, 0x15, 0x1b,
494 static hda_nid_t stac92hd73xx_pin_nids
[13] = {
495 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
496 0x0f, 0x10, 0x11, 0x12, 0x13,
500 static hda_nid_t stac92hd83xxx_pin_nids
[10] = {
501 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
502 0x0f, 0x10, 0x11, 0x1f, 0x20,
505 #define STAC92HD71BXX_NUM_PINS 13
506 static hda_nid_t stac92hd71bxx_pin_nids_4port
[STAC92HD71BXX_NUM_PINS
] = {
507 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
508 0x00, 0x14, 0x18, 0x19, 0x1e,
511 static hda_nid_t stac92hd71bxx_pin_nids_6port
[STAC92HD71BXX_NUM_PINS
] = {
512 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
513 0x0f, 0x14, 0x18, 0x19, 0x1e,
517 static hda_nid_t stac927x_pin_nids
[14] = {
518 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
519 0x0f, 0x10, 0x11, 0x12, 0x13,
520 0x14, 0x21, 0x22, 0x23,
523 static hda_nid_t stac9205_pin_nids
[12] = {
524 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
525 0x0f, 0x14, 0x16, 0x17, 0x18,
529 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
531 static int stac92xx_amp_volume_get(struct snd_kcontrol
*kcontrol
,
532 struct snd_ctl_elem_value
*ucontrol
)
534 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
535 struct sigmatel_spec
*spec
= codec
->spec
;
536 hda_nid_t nid
= spec
->amp_nids
[spec
->cur_amux
];
538 kcontrol
->private_value
^= get_amp_nid(kcontrol
);
539 kcontrol
->private_value
|= nid
;
541 return snd_hda_mixer_amp_volume_get(kcontrol
, ucontrol
);
544 static int stac92xx_amp_volume_put(struct snd_kcontrol
*kcontrol
,
545 struct snd_ctl_elem_value
*ucontrol
)
547 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
548 struct sigmatel_spec
*spec
= codec
->spec
;
549 hda_nid_t nid
= spec
->amp_nids
[spec
->cur_amux
];
551 kcontrol
->private_value
^= get_amp_nid(kcontrol
);
552 kcontrol
->private_value
|= nid
;
554 return snd_hda_mixer_amp_volume_put(kcontrol
, ucontrol
);
557 static int stac92xx_dmux_enum_info(struct snd_kcontrol
*kcontrol
,
558 struct snd_ctl_elem_info
*uinfo
)
560 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
561 struct sigmatel_spec
*spec
= codec
->spec
;
562 return snd_hda_input_mux_info(spec
->dinput_mux
, uinfo
);
565 static int stac92xx_dmux_enum_get(struct snd_kcontrol
*kcontrol
,
566 struct snd_ctl_elem_value
*ucontrol
)
568 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
569 struct sigmatel_spec
*spec
= codec
->spec
;
570 unsigned int dmux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
572 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_dmux
[dmux_idx
];
576 static int stac92xx_dmux_enum_put(struct snd_kcontrol
*kcontrol
,
577 struct snd_ctl_elem_value
*ucontrol
)
579 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
580 struct sigmatel_spec
*spec
= codec
->spec
;
581 unsigned int dmux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
583 return snd_hda_input_mux_put(codec
, spec
->dinput_mux
, ucontrol
,
584 spec
->dmux_nids
[dmux_idx
], &spec
->cur_dmux
[dmux_idx
]);
587 static int stac92xx_smux_enum_info(struct snd_kcontrol
*kcontrol
,
588 struct snd_ctl_elem_info
*uinfo
)
590 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
591 struct sigmatel_spec
*spec
= codec
->spec
;
592 return snd_hda_input_mux_info(spec
->sinput_mux
, uinfo
);
595 static int stac92xx_smux_enum_get(struct snd_kcontrol
*kcontrol
,
596 struct snd_ctl_elem_value
*ucontrol
)
598 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
599 struct sigmatel_spec
*spec
= codec
->spec
;
600 unsigned int smux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
602 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_smux
[smux_idx
];
606 static int stac92xx_smux_enum_put(struct snd_kcontrol
*kcontrol
,
607 struct snd_ctl_elem_value
*ucontrol
)
609 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
610 struct sigmatel_spec
*spec
= codec
->spec
;
611 struct hda_input_mux
*smux
= &spec
->private_smux
;
612 unsigned int smux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
616 err
= snd_hda_input_mux_put(codec
, spec
->sinput_mux
, ucontrol
,
617 spec
->smux_nids
[smux_idx
], &spec
->cur_smux
[smux_idx
]);
621 if (spec
->spdif_mute
) {
623 nid
= spec
->multiout
.dig_out_nid
;
625 nid
= codec
->slave_dig_outs
[smux_idx
- 1];
626 if (spec
->cur_smux
[smux_idx
] == smux
->num_items
- 1)
630 /* un/mute SPDIF out */
631 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
637 static unsigned int stac92xx_vref_set(struct hda_codec
*codec
,
638 hda_nid_t nid
, unsigned int new_vref
)
642 pincfg
= snd_hda_codec_read(codec
, nid
, 0,
643 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
646 pincfg
&= ~(AC_PINCTL_VREFEN
| AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
);
649 if (new_vref
== AC_PINCTL_VREF_HIZ
)
650 pincfg
|= AC_PINCTL_OUT_EN
;
652 pincfg
|= AC_PINCTL_IN_EN
;
654 error
= snd_hda_codec_write_cache(codec
, nid
, 0,
655 AC_VERB_SET_PIN_WIDGET_CONTROL
, pincfg
);
662 static unsigned int stac92xx_vref_get(struct hda_codec
*codec
, hda_nid_t nid
)
665 vref
= snd_hda_codec_read(codec
, nid
, 0,
666 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
667 vref
&= AC_PINCTL_VREFEN
;
671 static int stac92xx_dc_bias_put(struct snd_kcontrol
*kcontrol
,
672 struct snd_ctl_elem_value
*ucontrol
)
674 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
675 unsigned int new_vref
;
678 if (ucontrol
->value
.enumerated
.item
[0] == 0)
679 new_vref
= AC_PINCTL_VREF_80
;
680 else if (ucontrol
->value
.enumerated
.item
[0] == 1)
681 new_vref
= AC_PINCTL_VREF_GRD
;
683 new_vref
= AC_PINCTL_VREF_HIZ
;
685 if (new_vref
!= stac92xx_vref_get(codec
, kcontrol
->private_value
)) {
686 error
= stac92xx_vref_set(codec
,
687 kcontrol
->private_value
, new_vref
);
694 static int stac92xx_dc_bias_get(struct snd_kcontrol
*kcontrol
,
695 struct snd_ctl_elem_value
*ucontrol
)
697 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
698 unsigned int vref
= stac92xx_vref_get(codec
, kcontrol
->private_value
);
699 if (vref
== AC_PINCTL_VREF_80
)
700 ucontrol
->value
.enumerated
.item
[0] = 0;
701 else if (vref
== AC_PINCTL_VREF_GRD
)
702 ucontrol
->value
.enumerated
.item
[0] = 1;
703 else if (vref
== AC_PINCTL_VREF_HIZ
)
704 ucontrol
->value
.enumerated
.item
[0] = 2;
709 static int stac92xx_dc_bias_info(struct snd_kcontrol
*kcontrol
,
710 struct snd_ctl_elem_info
*uinfo
)
712 static char *texts
[] = {
713 "Mic In", "Line In", "Line Out"
716 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
717 uinfo
->value
.enumerated
.items
= 3;
719 if (uinfo
->value
.enumerated
.item
>= 3)
720 uinfo
->value
.enumerated
.item
= 2;
721 strcpy(uinfo
->value
.enumerated
.name
,
722 texts
[uinfo
->value
.enumerated
.item
]);
727 static int stac92xx_mux_enum_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
729 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
730 struct sigmatel_spec
*spec
= codec
->spec
;
731 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
734 static int stac92xx_mux_enum_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
736 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
737 struct sigmatel_spec
*spec
= codec
->spec
;
738 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
740 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
744 static int stac92xx_mux_enum_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
746 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
747 struct sigmatel_spec
*spec
= codec
->spec
;
748 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
750 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
751 spec
->mux_nids
[adc_idx
], &spec
->cur_mux
[adc_idx
]);
754 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol
*kcontrol
,
755 struct snd_ctl_elem_info
*uinfo
)
757 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
758 struct sigmatel_spec
*spec
= codec
->spec
;
759 return snd_hda_input_mux_info(spec
->mono_mux
, uinfo
);
762 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol
*kcontrol
,
763 struct snd_ctl_elem_value
*ucontrol
)
765 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
766 struct sigmatel_spec
*spec
= codec
->spec
;
768 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mmux
;
772 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol
*kcontrol
,
773 struct snd_ctl_elem_value
*ucontrol
)
775 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
776 struct sigmatel_spec
*spec
= codec
->spec
;
778 return snd_hda_input_mux_put(codec
, spec
->mono_mux
, ucontrol
,
779 spec
->mono_nid
, &spec
->cur_mmux
);
782 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol
*kcontrol
,
783 struct snd_ctl_elem_info
*uinfo
)
785 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
786 struct sigmatel_spec
*spec
= codec
->spec
;
787 return snd_hda_input_mux_info(spec
->amp_mux
, uinfo
);
790 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol
*kcontrol
,
791 struct snd_ctl_elem_value
*ucontrol
)
793 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
794 struct sigmatel_spec
*spec
= codec
->spec
;
796 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_amux
;
800 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol
*kcontrol
,
801 struct snd_ctl_elem_value
*ucontrol
)
803 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
804 struct sigmatel_spec
*spec
= codec
->spec
;
805 struct snd_kcontrol
*ctl
=
806 snd_hda_find_mixer_ctl(codec
, "Amp Capture Volume");
810 snd_ctl_notify(codec
->bus
->card
, SNDRV_CTL_EVENT_MASK_VALUE
|
811 SNDRV_CTL_EVENT_MASK_INFO
, &ctl
->id
);
813 return snd_hda_input_mux_put(codec
, spec
->amp_mux
, ucontrol
,
817 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
819 static int stac92xx_aloopback_get(struct snd_kcontrol
*kcontrol
,
820 struct snd_ctl_elem_value
*ucontrol
)
822 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
823 unsigned int idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
824 struct sigmatel_spec
*spec
= codec
->spec
;
826 ucontrol
->value
.integer
.value
[0] = !!(spec
->aloopback
&
827 (spec
->aloopback_mask
<< idx
));
831 static int stac92xx_aloopback_put(struct snd_kcontrol
*kcontrol
,
832 struct snd_ctl_elem_value
*ucontrol
)
834 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
835 struct sigmatel_spec
*spec
= codec
->spec
;
836 unsigned int idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
837 unsigned int dac_mode
;
838 unsigned int val
, idx_val
;
840 idx_val
= spec
->aloopback_mask
<< idx
;
841 if (ucontrol
->value
.integer
.value
[0])
842 val
= spec
->aloopback
| idx_val
;
844 val
= spec
->aloopback
& ~idx_val
;
845 if (spec
->aloopback
== val
)
848 spec
->aloopback
= val
;
850 /* Only return the bits defined by the shift value of the
851 * first two bytes of the mask
853 dac_mode
= snd_hda_codec_read(codec
, codec
->afg
, 0,
854 kcontrol
->private_value
& 0xFFFF, 0x0);
855 dac_mode
>>= spec
->aloopback_shift
;
857 if (spec
->aloopback
& idx_val
) {
858 snd_hda_power_up(codec
);
861 snd_hda_power_down(codec
);
862 dac_mode
&= ~idx_val
;
865 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
866 kcontrol
->private_value
>> 16, dac_mode
);
871 static struct hda_verb stac9200_core_init
[] = {
872 /* set dac0mux for dac converter */
873 { 0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
877 static struct hda_verb stac9200_eapd_init
[] = {
878 /* set dac0mux for dac converter */
879 {0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
880 {0x08, AC_VERB_SET_EAPD_BTLENABLE
, 0x02},
884 static struct hda_verb stac92hd73xx_6ch_core_init
[] = {
885 /* set master volume and direct control */
886 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
887 /* setup adcs to point to mixer */
888 { 0x20, AC_VERB_SET_CONNECT_SEL
, 0x0b},
889 { 0x21, AC_VERB_SET_CONNECT_SEL
, 0x0b},
890 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
891 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
892 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
893 /* setup import muxs */
894 { 0x28, AC_VERB_SET_CONNECT_SEL
, 0x01},
895 { 0x29, AC_VERB_SET_CONNECT_SEL
, 0x01},
896 { 0x2a, AC_VERB_SET_CONNECT_SEL
, 0x01},
897 { 0x2b, AC_VERB_SET_CONNECT_SEL
, 0x00},
901 static struct hda_verb dell_eq_core_init
[] = {
902 /* set master volume to max value without distortion
903 * and direct control */
904 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xec},
905 /* setup adcs to point to mixer */
906 { 0x20, AC_VERB_SET_CONNECT_SEL
, 0x0b},
907 { 0x21, AC_VERB_SET_CONNECT_SEL
, 0x0b},
908 /* setup import muxs */
909 { 0x28, AC_VERB_SET_CONNECT_SEL
, 0x01},
910 { 0x29, AC_VERB_SET_CONNECT_SEL
, 0x01},
911 { 0x2a, AC_VERB_SET_CONNECT_SEL
, 0x01},
912 { 0x2b, AC_VERB_SET_CONNECT_SEL
, 0x00},
916 static struct hda_verb dell_m6_core_init
[] = {
917 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
918 /* setup adcs to point to mixer */
919 { 0x20, AC_VERB_SET_CONNECT_SEL
, 0x0b},
920 { 0x21, AC_VERB_SET_CONNECT_SEL
, 0x0b},
921 /* setup import muxs */
922 { 0x28, AC_VERB_SET_CONNECT_SEL
, 0x01},
923 { 0x29, AC_VERB_SET_CONNECT_SEL
, 0x01},
924 { 0x2a, AC_VERB_SET_CONNECT_SEL
, 0x01},
925 { 0x2b, AC_VERB_SET_CONNECT_SEL
, 0x00},
929 static struct hda_verb stac92hd73xx_8ch_core_init
[] = {
930 /* set master volume and direct control */
931 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
932 /* setup adcs to point to mixer */
933 { 0x20, AC_VERB_SET_CONNECT_SEL
, 0x0b},
934 { 0x21, AC_VERB_SET_CONNECT_SEL
, 0x0b},
935 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
936 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
937 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
938 /* setup import muxs */
939 { 0x28, AC_VERB_SET_CONNECT_SEL
, 0x01},
940 { 0x29, AC_VERB_SET_CONNECT_SEL
, 0x01},
941 { 0x2a, AC_VERB_SET_CONNECT_SEL
, 0x01},
942 { 0x2b, AC_VERB_SET_CONNECT_SEL
, 0x03},
946 static struct hda_verb stac92hd73xx_10ch_core_init
[] = {
947 /* set master volume and direct control */
948 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
949 /* dac3 is connected to import3 mux */
950 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb07f},
951 /* setup adcs to point to mixer */
952 { 0x20, AC_VERB_SET_CONNECT_SEL
, 0x0b},
953 { 0x21, AC_VERB_SET_CONNECT_SEL
, 0x0b},
954 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
955 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
956 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
},
957 /* setup import muxs */
958 { 0x28, AC_VERB_SET_CONNECT_SEL
, 0x01},
959 { 0x29, AC_VERB_SET_CONNECT_SEL
, 0x01},
960 { 0x2a, AC_VERB_SET_CONNECT_SEL
, 0x01},
961 { 0x2b, AC_VERB_SET_CONNECT_SEL
, 0x03},
965 static struct hda_verb stac92hd83xxx_core_init
[] = {
966 { 0xa, AC_VERB_SET_CONNECT_SEL
, 0x1},
967 { 0xb, AC_VERB_SET_CONNECT_SEL
, 0x1},
968 { 0xd, AC_VERB_SET_CONNECT_SEL
, 0x0},
970 /* power state controls amps */
971 { 0x01, AC_VERB_SET_EAPD
, 1 << 2},
975 static struct hda_verb stac92hd71bxx_core_init
[] = {
976 /* set master volume and direct control */
977 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
981 #define HD_DISABLE_PORTF 1
982 static struct hda_verb stac92hd71bxx_analog_core_init
[] = {
983 /* start of config #1 */
985 /* connect port 0f to audio mixer */
986 { 0x0f, AC_VERB_SET_CONNECT_SEL
, 0x2},
987 /* start of config #2 */
989 /* set master volume and direct control */
990 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
994 static struct hda_verb stac92hd71bxx_unmute_core_init
[] = {
995 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
996 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
997 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
998 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
1002 static struct hda_verb stac925x_core_init
[] = {
1003 /* set dac0mux for dac converter */
1004 { 0x06, AC_VERB_SET_CONNECT_SEL
, 0x00},
1005 /* mute the master volume */
1006 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
1010 static struct hda_verb stac922x_core_init
[] = {
1011 /* set master volume and direct control */
1012 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
1016 static struct hda_verb d965_core_init
[] = {
1017 /* set master volume and direct control */
1018 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
1019 /* unmute node 0x1b */
1020 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
1021 /* select node 0x03 as DAC */
1022 { 0x0b, AC_VERB_SET_CONNECT_SEL
, 0x01},
1026 static struct hda_verb stac927x_core_init
[] = {
1027 /* set master volume and direct control */
1028 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
1029 /* enable analog pc beep path */
1030 { 0x01, AC_VERB_SET_DIGI_CONVERT_2
, 1 << 5},
1034 static struct hda_verb stac9205_core_init
[] = {
1035 /* set master volume and direct control */
1036 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
1037 /* enable analog pc beep path */
1038 { 0x01, AC_VERB_SET_DIGI_CONVERT_2
, 1 << 5},
1042 #define STAC_MONO_MUX \
1044 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1045 .name = "Mono Mux", \
1047 .info = stac92xx_mono_mux_enum_info, \
1048 .get = stac92xx_mono_mux_enum_get, \
1049 .put = stac92xx_mono_mux_enum_put, \
1052 #define STAC_AMP_MUX \
1054 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1055 .name = "Amp Selector Capture Switch", \
1057 .info = stac92xx_amp_mux_enum_info, \
1058 .get = stac92xx_amp_mux_enum_get, \
1059 .put = stac92xx_amp_mux_enum_put, \
1062 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
1064 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1067 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1068 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1069 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
1070 .info = stac92xx_amp_volume_info, \
1071 .get = stac92xx_amp_volume_get, \
1072 .put = stac92xx_amp_volume_put, \
1073 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
1074 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
1077 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
1079 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1080 .name = "Analog Loopback", \
1082 .info = stac92xx_aloopback_info, \
1083 .get = stac92xx_aloopback_get, \
1084 .put = stac92xx_aloopback_put, \
1085 .private_value = verb_read | (verb_write << 16), \
1088 #define DC_BIAS(xname, idx, nid) \
1090 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1093 .info = stac92xx_dc_bias_info, \
1094 .get = stac92xx_dc_bias_get, \
1095 .put = stac92xx_dc_bias_put, \
1096 .private_value = nid, \
1099 static struct snd_kcontrol_new stac9200_mixer
[] = {
1100 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT
),
1101 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT
),
1102 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT
),
1103 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT
),
1107 #define DELL_M6_MIXER 6
1108 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer
[] = {
1109 /* start of config #1 */
1110 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT
),
1111 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT
),
1113 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT
),
1114 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT
),
1116 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT
),
1117 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT
),
1119 /* start of config #2 */
1120 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT
),
1121 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT
),
1123 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT
),
1124 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT
),
1126 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT
),
1127 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT
),
1129 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT
),
1130 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT
),
1135 static struct snd_kcontrol_new stac92hd73xx_6ch_loopback
[] = {
1136 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1140 static struct snd_kcontrol_new stac92hd73xx_8ch_loopback
[] = {
1141 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1145 static struct snd_kcontrol_new stac92hd73xx_10ch_loopback
[] = {
1146 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1150 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer
[] = {
1151 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT
),
1152 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT
),
1154 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT
),
1155 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT
),
1157 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT
),
1158 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT
),
1160 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT
),
1161 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT
),
1163 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT
),
1164 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT
),
1166 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT
),
1167 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT
),
1169 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT
),
1170 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT
),
1174 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer
[] = {
1175 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT
),
1176 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT
),
1178 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT
),
1179 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT
),
1181 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT
),
1182 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT
),
1184 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT
),
1185 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT
),
1187 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT
),
1188 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT
),
1190 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT
),
1191 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT
),
1193 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT
),
1194 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT
),
1199 static struct snd_kcontrol_new stac92hd83xxx_mixer
[] = {
1200 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT
),
1201 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT
),
1203 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT
),
1204 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT
),
1206 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT
),
1207 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT
),
1209 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT
),
1210 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT
),
1212 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT
),
1213 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT
),
1215 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT
),
1216 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT
),
1219 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1220 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
1225 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer
[] = {
1226 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT
),
1227 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT
),
1229 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT
),
1230 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT
),
1231 /* analog pc-beep replaced with digital beep support */
1233 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1234 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1237 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT
),
1238 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT
),
1240 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT
),
1241 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT
),
1243 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT
),
1244 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT
),
1246 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT
),
1247 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT
),
1251 static struct snd_kcontrol_new stac92hd71bxx_loopback
[] = {
1252 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1255 static struct snd_kcontrol_new stac92hd71bxx_mixer
[] = {
1256 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT
),
1257 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT
),
1259 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT
),
1260 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT
),
1264 static struct snd_kcontrol_new stac925x_mixer
[] = {
1265 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT
),
1266 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT
),
1267 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT
),
1268 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT
),
1272 static struct snd_kcontrol_new stac9205_mixer
[] = {
1273 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT
),
1274 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT
),
1276 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT
),
1277 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT
),
1281 static struct snd_kcontrol_new stac9205_loopback
[] = {
1282 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1286 /* This needs to be generated dynamically based on sequence */
1287 static struct snd_kcontrol_new stac922x_mixer
[] = {
1288 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT
),
1289 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT
),
1291 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT
),
1292 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT
),
1297 static struct snd_kcontrol_new stac927x_mixer
[] = {
1298 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT
),
1299 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT
),
1301 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT
),
1302 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT
),
1304 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT
),
1305 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT
),
1309 static struct snd_kcontrol_new stac927x_loopback
[] = {
1310 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1314 static struct snd_kcontrol_new stac_dmux_mixer
= {
1315 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1316 .name
= "Digital Input Source",
1317 /* count set later */
1318 .info
= stac92xx_dmux_enum_info
,
1319 .get
= stac92xx_dmux_enum_get
,
1320 .put
= stac92xx_dmux_enum_put
,
1323 static struct snd_kcontrol_new stac_smux_mixer
= {
1324 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1325 .name
= "IEC958 Playback Source",
1326 /* count set later */
1327 .info
= stac92xx_smux_enum_info
,
1328 .get
= stac92xx_smux_enum_get
,
1329 .put
= stac92xx_smux_enum_put
,
1332 static const char *slave_vols
[] = {
1333 "Front Playback Volume",
1334 "Surround Playback Volume",
1335 "Center Playback Volume",
1336 "LFE Playback Volume",
1337 "Side Playback Volume",
1338 "Headphone Playback Volume",
1339 "Speaker Playback Volume",
1343 static const char *slave_sws
[] = {
1344 "Front Playback Switch",
1345 "Surround Playback Switch",
1346 "Center Playback Switch",
1347 "LFE Playback Switch",
1348 "Side Playback Switch",
1349 "Headphone Playback Switch",
1350 "Speaker Playback Switch",
1351 "IEC958 Playback Switch",
1355 static void stac92xx_free_kctls(struct hda_codec
*codec
);
1356 static int stac92xx_add_jack(struct hda_codec
*codec
, hda_nid_t nid
, int type
);
1358 static int stac92xx_build_controls(struct hda_codec
*codec
)
1360 struct sigmatel_spec
*spec
= codec
->spec
;
1361 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1366 err
= snd_hda_add_new_ctls(codec
, spec
->mixer
);
1370 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1371 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
1375 if (spec
->num_dmuxes
> 0) {
1376 stac_dmux_mixer
.count
= spec
->num_dmuxes
;
1377 err
= snd_hda_ctl_add(codec
,
1378 snd_ctl_new1(&stac_dmux_mixer
, codec
));
1382 if (spec
->num_smuxes
> 0) {
1383 int wcaps
= get_wcaps(codec
, spec
->multiout
.dig_out_nid
);
1384 struct hda_input_mux
*smux
= &spec
->private_smux
;
1385 /* check for mute support on SPDIF out */
1386 if (wcaps
& AC_WCAP_OUT_AMP
) {
1387 smux
->items
[smux
->num_items
].label
= "Off";
1388 smux
->items
[smux
->num_items
].index
= 0;
1390 spec
->spdif_mute
= 1;
1392 stac_smux_mixer
.count
= spec
->num_smuxes
;
1393 err
= snd_hda_ctl_add(codec
,
1394 snd_ctl_new1(&stac_smux_mixer
, codec
));
1399 if (spec
->multiout
.dig_out_nid
) {
1400 err
= snd_hda_create_spdif_out_ctls(codec
, spec
->multiout
.dig_out_nid
);
1403 err
= snd_hda_create_spdif_share_sw(codec
,
1407 spec
->multiout
.share_spdif
= 1;
1409 if (spec
->dig_in_nid
&& !(spec
->gpio_dir
& 0x01)) {
1410 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
1415 /* if we have no master control, let's create it */
1416 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
1417 unsigned int vmaster_tlv
[4];
1418 snd_hda_set_vmaster_tlv(codec
, spec
->multiout
.dac_nids
[0],
1419 HDA_OUTPUT
, vmaster_tlv
);
1420 /* correct volume offset */
1421 vmaster_tlv
[2] += vmaster_tlv
[3] * spec
->volume_offset
;
1422 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
1423 vmaster_tlv
, slave_vols
);
1427 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
1428 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
1434 if (spec
->aloopback_ctl
&&
1435 snd_hda_get_bool_hint(codec
, "loopback") == 1) {
1436 err
= snd_hda_add_new_ctls(codec
, spec
->aloopback_ctl
);
1441 stac92xx_free_kctls(codec
); /* no longer needed */
1443 /* create jack input elements */
1444 if (spec
->hp_detect
) {
1445 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
1446 int type
= SND_JACK_HEADPHONE
;
1447 nid
= cfg
->hp_pins
[i
];
1448 /* jack detection */
1449 if (cfg
->hp_outs
== i
)
1450 type
|= SND_JACK_LINEOUT
;
1451 err
= stac92xx_add_jack(codec
, nid
, type
);
1456 for (i
= 0; i
< cfg
->line_outs
; i
++) {
1457 err
= stac92xx_add_jack(codec
, cfg
->line_out_pins
[i
],
1462 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
1463 nid
= cfg
->input_pins
[i
];
1465 err
= stac92xx_add_jack(codec
, nid
,
1466 SND_JACK_MICROPHONE
);
1475 static unsigned int ref9200_pin_configs
[8] = {
1476 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1477 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1480 static unsigned int gateway9200_m4_pin_configs
[8] = {
1481 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1482 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1484 static unsigned int gateway9200_m4_2_pin_configs
[8] = {
1485 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1486 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1490 STAC 9200 pin configs for
1495 static unsigned int dell9200_d21_pin_configs
[8] = {
1496 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1497 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1501 STAC 9200 pin configs for
1505 static unsigned int dell9200_d22_pin_configs
[8] = {
1506 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1507 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1511 STAC 9200 pin configs for
1512 102801C4 (Dell Dimension E310)
1519 static unsigned int dell9200_d23_pin_configs
[8] = {
1520 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1521 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1526 STAC 9200-32 pin configs for
1527 102801B5 (Dell Inspiron 630m)
1528 102801D8 (Dell Inspiron 640m)
1530 static unsigned int dell9200_m21_pin_configs
[8] = {
1531 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1532 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1536 STAC 9200-32 pin configs for
1537 102801C2 (Dell Latitude D620)
1539 102801CC (Dell Latitude D820)
1543 static unsigned int dell9200_m22_pin_configs
[8] = {
1544 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1545 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1549 STAC 9200-32 pin configs for
1550 102801CE (Dell XPS M1710)
1551 102801CF (Dell Precision M90)
1553 static unsigned int dell9200_m23_pin_configs
[8] = {
1554 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1555 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1559 STAC 9200-32 pin configs for
1562 102801CB (Dell Latitude 120L)
1565 static unsigned int dell9200_m24_pin_configs
[8] = {
1566 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1567 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1571 STAC 9200-32 pin configs for
1572 102801BD (Dell Inspiron E1505n)
1576 static unsigned int dell9200_m25_pin_configs
[8] = {
1577 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1578 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1582 STAC 9200-32 pin configs for
1583 102801F5 (Dell Inspiron 1501)
1586 static unsigned int dell9200_m26_pin_configs
[8] = {
1587 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1588 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1593 102801CD (Dell Inspiron E1705/9400)
1595 static unsigned int dell9200_m27_pin_configs
[8] = {
1596 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1597 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1600 static unsigned int oqo9200_pin_configs
[8] = {
1601 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1602 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1606 static unsigned int *stac9200_brd_tbl
[STAC_9200_MODELS
] = {
1607 [STAC_REF
] = ref9200_pin_configs
,
1608 [STAC_9200_OQO
] = oqo9200_pin_configs
,
1609 [STAC_9200_DELL_D21
] = dell9200_d21_pin_configs
,
1610 [STAC_9200_DELL_D22
] = dell9200_d22_pin_configs
,
1611 [STAC_9200_DELL_D23
] = dell9200_d23_pin_configs
,
1612 [STAC_9200_DELL_M21
] = dell9200_m21_pin_configs
,
1613 [STAC_9200_DELL_M22
] = dell9200_m22_pin_configs
,
1614 [STAC_9200_DELL_M23
] = dell9200_m23_pin_configs
,
1615 [STAC_9200_DELL_M24
] = dell9200_m24_pin_configs
,
1616 [STAC_9200_DELL_M25
] = dell9200_m25_pin_configs
,
1617 [STAC_9200_DELL_M26
] = dell9200_m26_pin_configs
,
1618 [STAC_9200_DELL_M27
] = dell9200_m27_pin_configs
,
1619 [STAC_9200_M4
] = gateway9200_m4_pin_configs
,
1620 [STAC_9200_M4_2
] = gateway9200_m4_2_pin_configs
,
1621 [STAC_9200_PANASONIC
] = ref9200_pin_configs
,
1624 static const char *stac9200_models
[STAC_9200_MODELS
] = {
1625 [STAC_AUTO
] = "auto",
1627 [STAC_9200_OQO
] = "oqo",
1628 [STAC_9200_DELL_D21
] = "dell-d21",
1629 [STAC_9200_DELL_D22
] = "dell-d22",
1630 [STAC_9200_DELL_D23
] = "dell-d23",
1631 [STAC_9200_DELL_M21
] = "dell-m21",
1632 [STAC_9200_DELL_M22
] = "dell-m22",
1633 [STAC_9200_DELL_M23
] = "dell-m23",
1634 [STAC_9200_DELL_M24
] = "dell-m24",
1635 [STAC_9200_DELL_M25
] = "dell-m25",
1636 [STAC_9200_DELL_M26
] = "dell-m26",
1637 [STAC_9200_DELL_M27
] = "dell-m27",
1638 [STAC_9200_M4
] = "gateway-m4",
1639 [STAC_9200_M4_2
] = "gateway-m4-2",
1640 [STAC_9200_PANASONIC
] = "panasonic",
1643 static struct snd_pci_quirk stac9200_cfg_tbl
[] = {
1644 /* SigmaTel reference board */
1645 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1646 "DFI LanParty", STAC_REF
),
1647 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
1648 "DFI LanParty", STAC_REF
),
1649 /* Dell laptops have BIOS problem */
1650 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01a8,
1651 "unknown Dell", STAC_9200_DELL_D21
),
1652 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01b5,
1653 "Dell Inspiron 630m", STAC_9200_DELL_M21
),
1654 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01bd,
1655 "Dell Inspiron E1505n", STAC_9200_DELL_M25
),
1656 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c0,
1657 "unknown Dell", STAC_9200_DELL_D22
),
1658 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c1,
1659 "unknown Dell", STAC_9200_DELL_D22
),
1660 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c2,
1661 "Dell Latitude D620", STAC_9200_DELL_M22
),
1662 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c5,
1663 "unknown Dell", STAC_9200_DELL_D23
),
1664 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c7,
1665 "unknown Dell", STAC_9200_DELL_D23
),
1666 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c8,
1667 "unknown Dell", STAC_9200_DELL_M22
),
1668 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c9,
1669 "unknown Dell", STAC_9200_DELL_M24
),
1670 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ca,
1671 "unknown Dell", STAC_9200_DELL_M24
),
1672 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cb,
1673 "Dell Latitude 120L", STAC_9200_DELL_M24
),
1674 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cc,
1675 "Dell Latitude D820", STAC_9200_DELL_M22
),
1676 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cd,
1677 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27
),
1678 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ce,
1679 "Dell XPS M1710", STAC_9200_DELL_M23
),
1680 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cf,
1681 "Dell Precision M90", STAC_9200_DELL_M23
),
1682 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d3,
1683 "unknown Dell", STAC_9200_DELL_M22
),
1684 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d4,
1685 "unknown Dell", STAC_9200_DELL_M22
),
1686 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d6,
1687 "unknown Dell", STAC_9200_DELL_M22
),
1688 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d8,
1689 "Dell Inspiron 640m", STAC_9200_DELL_M21
),
1690 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d9,
1691 "unknown Dell", STAC_9200_DELL_D23
),
1692 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01da,
1693 "unknown Dell", STAC_9200_DELL_D23
),
1694 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01de,
1695 "unknown Dell", STAC_9200_DELL_D21
),
1696 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01e3,
1697 "unknown Dell", STAC_9200_DELL_D23
),
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01e8,
1699 "unknown Dell", STAC_9200_DELL_D21
),
1700 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ee,
1701 "unknown Dell", STAC_9200_DELL_M25
),
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ef,
1703 "unknown Dell", STAC_9200_DELL_M25
),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f5,
1705 "Dell Inspiron 1501", STAC_9200_DELL_M26
),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f6,
1707 "unknown Dell", STAC_9200_DELL_M26
),
1709 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC
),
1710 /* Gateway machines needs EAPD to be set on resume */
1711 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4
),
1712 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2
),
1713 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2
),
1715 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO
),
1719 static unsigned int ref925x_pin_configs
[8] = {
1720 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1721 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1724 static unsigned int stac925xM1_pin_configs
[8] = {
1725 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1726 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1729 static unsigned int stac925xM1_2_pin_configs
[8] = {
1730 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1731 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1734 static unsigned int stac925xM2_pin_configs
[8] = {
1735 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1736 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1739 static unsigned int stac925xM2_2_pin_configs
[8] = {
1740 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1741 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1744 static unsigned int stac925xM3_pin_configs
[8] = {
1745 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1746 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1749 static unsigned int stac925xM5_pin_configs
[8] = {
1750 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1751 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1754 static unsigned int stac925xM6_pin_configs
[8] = {
1755 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1756 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1759 static unsigned int *stac925x_brd_tbl
[STAC_925x_MODELS
] = {
1760 [STAC_REF
] = ref925x_pin_configs
,
1761 [STAC_M1
] = stac925xM1_pin_configs
,
1762 [STAC_M1_2
] = stac925xM1_2_pin_configs
,
1763 [STAC_M2
] = stac925xM2_pin_configs
,
1764 [STAC_M2_2
] = stac925xM2_2_pin_configs
,
1765 [STAC_M3
] = stac925xM3_pin_configs
,
1766 [STAC_M5
] = stac925xM5_pin_configs
,
1767 [STAC_M6
] = stac925xM6_pin_configs
,
1770 static const char *stac925x_models
[STAC_925x_MODELS
] = {
1771 [STAC_925x_AUTO
] = "auto",
1774 [STAC_M1_2
] = "m1-2",
1776 [STAC_M2_2
] = "m2-2",
1782 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl
[] = {
1783 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2
),
1784 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5
),
1785 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1
),
1786 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2
),
1787 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2
),
1788 /* Not sure about the brand name for those */
1789 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1
),
1790 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3
),
1791 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6
),
1792 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2
),
1796 static struct snd_pci_quirk stac925x_cfg_tbl
[] = {
1797 /* SigmaTel reference board */
1798 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668, "DFI LanParty", STAC_REF
),
1799 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101, "DFI LanParty", STAC_REF
),
1800 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF
),
1802 /* Default table for unknown ID */
1803 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2
),
1808 static unsigned int ref92hd73xx_pin_configs
[13] = {
1809 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1810 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1811 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1815 static unsigned int dell_m6_pin_configs
[13] = {
1816 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1817 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1818 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1822 static unsigned int *stac92hd73xx_brd_tbl
[STAC_92HD73XX_MODELS
] = {
1823 [STAC_92HD73XX_REF
] = ref92hd73xx_pin_configs
,
1824 [STAC_DELL_M6_AMIC
] = dell_m6_pin_configs
,
1825 [STAC_DELL_M6_DMIC
] = dell_m6_pin_configs
,
1826 [STAC_DELL_M6_BOTH
] = dell_m6_pin_configs
,
1827 [STAC_DELL_EQ
] = dell_m6_pin_configs
,
1830 static const char *stac92hd73xx_models
[STAC_92HD73XX_MODELS
] = {
1831 [STAC_92HD73XX_AUTO
] = "auto",
1832 [STAC_92HD73XX_NO_JD
] = "no-jd",
1833 [STAC_92HD73XX_REF
] = "ref",
1834 [STAC_DELL_M6_AMIC
] = "dell-m6-amic",
1835 [STAC_DELL_M6_DMIC
] = "dell-m6-dmic",
1836 [STAC_DELL_M6_BOTH
] = "dell-m6",
1837 [STAC_DELL_EQ
] = "dell-eq",
1840 static struct snd_pci_quirk stac92hd73xx_cfg_tbl
[] = {
1841 /* SigmaTel reference board */
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1843 "DFI LanParty", STAC_92HD73XX_REF
),
1844 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
1845 "DFI LanParty", STAC_92HD73XX_REF
),
1846 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0254,
1847 "Dell Studio 1535", STAC_DELL_M6_DMIC
),
1848 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0255,
1849 "unknown Dell", STAC_DELL_M6_DMIC
),
1850 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0256,
1851 "unknown Dell", STAC_DELL_M6_BOTH
),
1852 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0257,
1853 "unknown Dell", STAC_DELL_M6_BOTH
),
1854 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x025e,
1855 "unknown Dell", STAC_DELL_M6_AMIC
),
1856 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x025f,
1857 "unknown Dell", STAC_DELL_M6_AMIC
),
1858 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0271,
1859 "unknown Dell", STAC_DELL_M6_DMIC
),
1860 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0272,
1861 "unknown Dell", STAC_DELL_M6_DMIC
),
1862 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x029f,
1863 "Dell Studio 1537", STAC_DELL_M6_DMIC
),
1864 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02a0,
1865 "Dell Studio 17", STAC_DELL_M6_DMIC
),
1869 static unsigned int ref92hd83xxx_pin_configs
[10] = {
1870 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1871 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1872 0x01451160, 0x98560170,
1875 static unsigned int dell_s14_pin_configs
[10] = {
1876 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1877 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1878 0x40f000f0, 0x40f000f0,
1881 static unsigned int *stac92hd83xxx_brd_tbl
[STAC_92HD83XXX_MODELS
] = {
1882 [STAC_92HD83XXX_REF
] = ref92hd83xxx_pin_configs
,
1883 [STAC_92HD83XXX_PWR_REF
] = ref92hd83xxx_pin_configs
,
1884 [STAC_DELL_S14
] = dell_s14_pin_configs
,
1887 static const char *stac92hd83xxx_models
[STAC_92HD83XXX_MODELS
] = {
1888 [STAC_92HD83XXX_AUTO
] = "auto",
1889 [STAC_92HD83XXX_REF
] = "ref",
1890 [STAC_92HD83XXX_PWR_REF
] = "mic-ref",
1891 [STAC_DELL_S14
] = "dell-s14",
1894 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl
[] = {
1895 /* SigmaTel reference board */
1896 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1897 "DFI LanParty", STAC_92HD83XXX_REF
),
1898 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
1899 "DFI LanParty", STAC_92HD83XXX_REF
),
1900 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02ba,
1901 "unknown Dell", STAC_DELL_S14
),
1905 static unsigned int ref92hd71bxx_pin_configs
[STAC92HD71BXX_NUM_PINS
] = {
1906 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1907 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1908 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1912 static unsigned int dell_m4_1_pin_configs
[STAC92HD71BXX_NUM_PINS
] = {
1913 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1914 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1915 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1919 static unsigned int dell_m4_2_pin_configs
[STAC92HD71BXX_NUM_PINS
] = {
1920 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1921 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1922 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1926 static unsigned int dell_m4_3_pin_configs
[STAC92HD71BXX_NUM_PINS
] = {
1927 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1928 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1929 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1933 static unsigned int *stac92hd71bxx_brd_tbl
[STAC_92HD71BXX_MODELS
] = {
1934 [STAC_92HD71BXX_REF
] = ref92hd71bxx_pin_configs
,
1935 [STAC_DELL_M4_1
] = dell_m4_1_pin_configs
,
1936 [STAC_DELL_M4_2
] = dell_m4_2_pin_configs
,
1937 [STAC_DELL_M4_3
] = dell_m4_3_pin_configs
,
1938 [STAC_HP_M4
] = NULL
,
1939 [STAC_HP_DV5
] = NULL
,
1940 [STAC_HP_HDX
] = NULL
,
1941 [STAC_HP_DV4_1222NR
] = NULL
,
1944 static const char *stac92hd71bxx_models
[STAC_92HD71BXX_MODELS
] = {
1945 [STAC_92HD71BXX_AUTO
] = "auto",
1946 [STAC_92HD71BXX_REF
] = "ref",
1947 [STAC_DELL_M4_1
] = "dell-m4-1",
1948 [STAC_DELL_M4_2
] = "dell-m4-2",
1949 [STAC_DELL_M4_3
] = "dell-m4-3",
1950 [STAC_HP_M4
] = "hp-m4",
1951 [STAC_HP_DV5
] = "hp-dv5",
1952 [STAC_HP_HDX
] = "hp-hdx",
1953 [STAC_HP_DV4_1222NR
] = "hp-dv4-1222nr",
1956 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl
[] = {
1957 /* SigmaTel reference board */
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1959 "DFI LanParty", STAC_92HD71BXX_REF
),
1960 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
1961 "DFI LanParty", STAC_92HD71BXX_REF
),
1962 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x30fb,
1963 "HP dv4-1222nr", STAC_HP_DV4_1222NR
),
1964 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP
, 0xfff0, 0x3080,
1966 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP
, 0xfff0, 0x30f0,
1967 "HP dv4-7", STAC_HP_DV5
),
1968 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP
, 0xfff0, 0x3600,
1969 "HP dv4-7", STAC_HP_DV5
),
1970 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x3610,
1971 "HP HDX", STAC_HP_HDX
), /* HDX18 */
1972 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x361a,
1973 "HP mini 1000", STAC_HP_M4
),
1974 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x361b,
1975 "HP HDX", STAC_HP_HDX
), /* HDX16 */
1976 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0233,
1977 "unknown Dell", STAC_DELL_M4_1
),
1978 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0234,
1979 "unknown Dell", STAC_DELL_M4_1
),
1980 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0250,
1981 "unknown Dell", STAC_DELL_M4_1
),
1982 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x024f,
1983 "unknown Dell", STAC_DELL_M4_1
),
1984 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x024d,
1985 "unknown Dell", STAC_DELL_M4_1
),
1986 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0251,
1987 "unknown Dell", STAC_DELL_M4_1
),
1988 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0277,
1989 "unknown Dell", STAC_DELL_M4_1
),
1990 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0263,
1991 "unknown Dell", STAC_DELL_M4_2
),
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0265,
1993 "unknown Dell", STAC_DELL_M4_2
),
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0262,
1995 "unknown Dell", STAC_DELL_M4_2
),
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0264,
1997 "unknown Dell", STAC_DELL_M4_2
),
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02aa,
1999 "unknown Dell", STAC_DELL_M4_3
),
2003 static unsigned int ref922x_pin_configs
[10] = {
2004 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
2005 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
2006 0x40000100, 0x40000100,
2010 STAC 922X pin configs for
2017 static unsigned int dell_922x_d81_pin_configs
[10] = {
2018 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
2019 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
2020 0x01813122, 0x400001f2,
2024 STAC 922X pin configs for
2028 static unsigned int dell_922x_d82_pin_configs
[10] = {
2029 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
2030 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
2031 0x01813122, 0x400001f1,
2035 STAC 922X pin configs for
2038 static unsigned int dell_922x_m81_pin_configs
[10] = {
2039 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
2040 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
2041 0x40C003f1, 0x405003f0,
2045 STAC 9221 A1 pin configs for
2046 102801D7 (Dell XPS M1210)
2048 static unsigned int dell_922x_m82_pin_configs
[10] = {
2049 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
2050 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
2051 0x508003f3, 0x405003f4,
2054 static unsigned int d945gtp3_pin_configs
[10] = {
2055 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
2056 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2057 0x02a19120, 0x40000100,
2060 static unsigned int d945gtp5_pin_configs
[10] = {
2061 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
2062 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
2063 0x02a19320, 0x40000100,
2066 static unsigned int intel_mac_v1_pin_configs
[10] = {
2067 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
2068 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
2069 0x400000fc, 0x400000fb,
2072 static unsigned int intel_mac_v2_pin_configs
[10] = {
2073 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2074 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
2075 0x400000fc, 0x400000fb,
2078 static unsigned int intel_mac_v3_pin_configs
[10] = {
2079 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2080 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
2081 0x400000fc, 0x400000fb,
2084 static unsigned int intel_mac_v4_pin_configs
[10] = {
2085 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2086 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2087 0x400000fc, 0x400000fb,
2090 static unsigned int intel_mac_v5_pin_configs
[10] = {
2091 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2092 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2093 0x400000fc, 0x400000fb,
2096 static unsigned int ecs202_pin_configs
[10] = {
2097 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
2098 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
2099 0x9037012e, 0x40e000f2,
2102 static unsigned int *stac922x_brd_tbl
[STAC_922X_MODELS
] = {
2103 [STAC_D945_REF
] = ref922x_pin_configs
,
2104 [STAC_D945GTP3
] = d945gtp3_pin_configs
,
2105 [STAC_D945GTP5
] = d945gtp5_pin_configs
,
2106 [STAC_INTEL_MAC_V1
] = intel_mac_v1_pin_configs
,
2107 [STAC_INTEL_MAC_V2
] = intel_mac_v2_pin_configs
,
2108 [STAC_INTEL_MAC_V3
] = intel_mac_v3_pin_configs
,
2109 [STAC_INTEL_MAC_V4
] = intel_mac_v4_pin_configs
,
2110 [STAC_INTEL_MAC_V5
] = intel_mac_v5_pin_configs
,
2111 [STAC_INTEL_MAC_AUTO
] = intel_mac_v3_pin_configs
,
2112 /* for backward compatibility */
2113 [STAC_MACMINI
] = intel_mac_v3_pin_configs
,
2114 [STAC_MACBOOK
] = intel_mac_v5_pin_configs
,
2115 [STAC_MACBOOK_PRO_V1
] = intel_mac_v3_pin_configs
,
2116 [STAC_MACBOOK_PRO_V2
] = intel_mac_v3_pin_configs
,
2117 [STAC_IMAC_INTEL
] = intel_mac_v2_pin_configs
,
2118 [STAC_IMAC_INTEL_20
] = intel_mac_v3_pin_configs
,
2119 [STAC_ECS_202
] = ecs202_pin_configs
,
2120 [STAC_922X_DELL_D81
] = dell_922x_d81_pin_configs
,
2121 [STAC_922X_DELL_D82
] = dell_922x_d82_pin_configs
,
2122 [STAC_922X_DELL_M81
] = dell_922x_m81_pin_configs
,
2123 [STAC_922X_DELL_M82
] = dell_922x_m82_pin_configs
,
2126 static const char *stac922x_models
[STAC_922X_MODELS
] = {
2127 [STAC_922X_AUTO
] = "auto",
2128 [STAC_D945_REF
] = "ref",
2129 [STAC_D945GTP5
] = "5stack",
2130 [STAC_D945GTP3
] = "3stack",
2131 [STAC_INTEL_MAC_V1
] = "intel-mac-v1",
2132 [STAC_INTEL_MAC_V2
] = "intel-mac-v2",
2133 [STAC_INTEL_MAC_V3
] = "intel-mac-v3",
2134 [STAC_INTEL_MAC_V4
] = "intel-mac-v4",
2135 [STAC_INTEL_MAC_V5
] = "intel-mac-v5",
2136 [STAC_INTEL_MAC_AUTO
] = "intel-mac-auto",
2137 /* for backward compatibility */
2138 [STAC_MACMINI
] = "macmini",
2139 [STAC_MACBOOK
] = "macbook",
2140 [STAC_MACBOOK_PRO_V1
] = "macbook-pro-v1",
2141 [STAC_MACBOOK_PRO_V2
] = "macbook-pro",
2142 [STAC_IMAC_INTEL
] = "imac-intel",
2143 [STAC_IMAC_INTEL_20
] = "imac-intel-20",
2144 [STAC_ECS_202
] = "ecs202",
2145 [STAC_922X_DELL_D81
] = "dell-d81",
2146 [STAC_922X_DELL_D82
] = "dell-d82",
2147 [STAC_922X_DELL_M81
] = "dell-m81",
2148 [STAC_922X_DELL_M82
] = "dell-m82",
2151 static struct snd_pci_quirk stac922x_cfg_tbl
[] = {
2152 /* SigmaTel reference board */
2153 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
2154 "DFI LanParty", STAC_D945_REF
),
2155 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
2156 "DFI LanParty", STAC_D945_REF
),
2157 /* Intel 945G based systems */
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0101,
2159 "Intel D945G", STAC_D945GTP3
),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0202,
2161 "Intel D945G", STAC_D945GTP3
),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0606,
2163 "Intel D945G", STAC_D945GTP3
),
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0601,
2165 "Intel D945G", STAC_D945GTP3
),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0111,
2167 "Intel D945G", STAC_D945GTP3
),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1115,
2169 "Intel D945G", STAC_D945GTP3
),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1116,
2171 "Intel D945G", STAC_D945GTP3
),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1117,
2173 "Intel D945G", STAC_D945GTP3
),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1118,
2175 "Intel D945G", STAC_D945GTP3
),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1119,
2177 "Intel D945G", STAC_D945GTP3
),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x8826,
2179 "Intel D945G", STAC_D945GTP3
),
2180 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5049,
2181 "Intel D945G", STAC_D945GTP3
),
2182 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5055,
2183 "Intel D945G", STAC_D945GTP3
),
2184 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5048,
2185 "Intel D945G", STAC_D945GTP3
),
2186 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0110,
2187 "Intel D945G", STAC_D945GTP3
),
2188 /* Intel D945G 5-stack systems */
2189 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0404,
2190 "Intel D945G", STAC_D945GTP5
),
2191 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0303,
2192 "Intel D945G", STAC_D945GTP5
),
2193 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0013,
2194 "Intel D945G", STAC_D945GTP5
),
2195 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0417,
2196 "Intel D945G", STAC_D945GTP5
),
2197 /* Intel 945P based systems */
2198 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0b0b,
2199 "Intel D945P", STAC_D945GTP3
),
2200 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0112,
2201 "Intel D945P", STAC_D945GTP3
),
2202 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0d0d,
2203 "Intel D945P", STAC_D945GTP3
),
2204 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0909,
2205 "Intel D945P", STAC_D945GTP3
),
2206 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0505,
2207 "Intel D945P", STAC_D945GTP3
),
2208 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0707,
2209 "Intel D945P", STAC_D945GTP5
),
2211 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0204,
2212 "Intel D945", STAC_D945_REF
),
2214 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2215 SND_PCI_QUIRK(0x8384, 0x7680,
2216 "Mac", STAC_INTEL_MAC_AUTO
),
2218 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01a7,
2219 "unknown Dell", STAC_922X_DELL_D81
),
2220 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01a9,
2221 "unknown Dell", STAC_922X_DELL_D81
),
2222 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ab,
2223 "unknown Dell", STAC_922X_DELL_D81
),
2224 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ac,
2225 "unknown Dell", STAC_922X_DELL_D82
),
2226 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01bf,
2227 "unknown Dell", STAC_922X_DELL_M81
),
2228 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d0,
2229 "unknown Dell", STAC_922X_DELL_D82
),
2230 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d1,
2231 "unknown Dell", STAC_922X_DELL_D81
),
2232 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d2,
2233 "unknown Dell", STAC_922X_DELL_D81
),
2234 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d7,
2235 "Dell XPS M1210", STAC_922X_DELL_M82
),
2236 /* ECS/PC Chips boards */
2237 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2238 "ECS/PC chips", STAC_ECS_202
),
2242 static unsigned int ref927x_pin_configs
[14] = {
2243 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2244 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2245 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2246 0x01c42190, 0x40000100,
2249 static unsigned int d965_3st_pin_configs
[14] = {
2250 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2251 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2252 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2253 0x40000100, 0x40000100
2256 static unsigned int d965_5st_pin_configs
[14] = {
2257 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2258 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2259 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2260 0x40000100, 0x40000100
2263 static unsigned int dell_3st_pin_configs
[14] = {
2264 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2265 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2266 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2267 0x40c003fc, 0x40000100
2270 static unsigned int *stac927x_brd_tbl
[STAC_927X_MODELS
] = {
2271 [STAC_D965_REF_NO_JD
] = ref927x_pin_configs
,
2272 [STAC_D965_REF
] = ref927x_pin_configs
,
2273 [STAC_D965_3ST
] = d965_3st_pin_configs
,
2274 [STAC_D965_5ST
] = d965_5st_pin_configs
,
2275 [STAC_DELL_3ST
] = dell_3st_pin_configs
,
2276 [STAC_DELL_BIOS
] = NULL
,
2279 static const char *stac927x_models
[STAC_927X_MODELS
] = {
2280 [STAC_927X_AUTO
] = "auto",
2281 [STAC_D965_REF_NO_JD
] = "ref-no-jd",
2282 [STAC_D965_REF
] = "ref",
2283 [STAC_D965_3ST
] = "3stack",
2284 [STAC_D965_5ST
] = "5stack",
2285 [STAC_DELL_3ST
] = "dell-3stack",
2286 [STAC_DELL_BIOS
] = "dell-bios",
2289 static struct snd_pci_quirk stac927x_cfg_tbl
[] = {
2290 /* SigmaTel reference board */
2291 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
2292 "DFI LanParty", STAC_D965_REF
),
2293 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
2294 "DFI LanParty", STAC_D965_REF
),
2295 /* Intel 946 based systems */
2296 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x3d01, "Intel D946", STAC_D965_3ST
),
2297 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0xa301, "Intel D946", STAC_D965_3ST
),
2298 /* 965 based 3 stack systems */
2299 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL
, 0xff00, 0x2100,
2300 "Intel D965", STAC_D965_3ST
),
2301 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL
, 0xff00, 0x2000,
2302 "Intel D965", STAC_D965_3ST
),
2303 /* Dell 3 stack systems */
2304 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST
),
2305 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST
),
2306 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ed, "Dell ", STAC_DELL_3ST
),
2307 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f4, "Dell ", STAC_DELL_3ST
),
2308 /* Dell 3 stack systems with verb table in BIOS */
2309 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS
),
2310 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS
),
2311 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x022e, "Dell ", STAC_DELL_BIOS
),
2312 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST
),
2313 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0242, "Dell ", STAC_DELL_BIOS
),
2314 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0243, "Dell ", STAC_DELL_BIOS
),
2315 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02ff, "Dell ", STAC_DELL_BIOS
),
2316 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS
),
2317 /* 965 based 5 stack systems */
2318 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL
, 0xff00, 0x2300,
2319 "Intel D965", STAC_D965_5ST
),
2320 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL
, 0xff00, 0x2500,
2321 "Intel D965", STAC_D965_5ST
),
2325 static unsigned int ref9205_pin_configs
[12] = {
2326 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2327 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2328 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2332 STAC 9205 pin configs for
2339 10280228 (Dell Vostro 1500)
2341 static unsigned int dell_9205_m42_pin_configs
[12] = {
2342 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2343 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2344 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2348 STAC 9205 pin configs for
2352 102801FF (Dell Precision M4300)
2357 static unsigned int dell_9205_m43_pin_configs
[12] = {
2358 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2359 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2360 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2363 static unsigned int dell_9205_m44_pin_configs
[12] = {
2364 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2365 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2366 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2369 static unsigned int *stac9205_brd_tbl
[STAC_9205_MODELS
] = {
2370 [STAC_9205_REF
] = ref9205_pin_configs
,
2371 [STAC_9205_DELL_M42
] = dell_9205_m42_pin_configs
,
2372 [STAC_9205_DELL_M43
] = dell_9205_m43_pin_configs
,
2373 [STAC_9205_DELL_M44
] = dell_9205_m44_pin_configs
,
2374 [STAC_9205_EAPD
] = NULL
,
2377 static const char *stac9205_models
[STAC_9205_MODELS
] = {
2378 [STAC_9205_AUTO
] = "auto",
2379 [STAC_9205_REF
] = "ref",
2380 [STAC_9205_DELL_M42
] = "dell-m42",
2381 [STAC_9205_DELL_M43
] = "dell-m43",
2382 [STAC_9205_DELL_M44
] = "dell-m44",
2383 [STAC_9205_EAPD
] = "eapd",
2386 static struct snd_pci_quirk stac9205_cfg_tbl
[] = {
2387 /* SigmaTel reference board */
2388 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
2389 "DFI LanParty", STAC_9205_REF
),
2390 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
2391 "DFI LanParty", STAC_9205_REF
),
2393 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f1,
2394 "unknown Dell", STAC_9205_DELL_M42
),
2395 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f2,
2396 "unknown Dell", STAC_9205_DELL_M42
),
2397 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f8,
2398 "Dell Precision", STAC_9205_DELL_M43
),
2399 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f9,
2400 "Dell Precision", STAC_9205_DELL_M43
),
2401 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fa,
2402 "Dell Precision", STAC_9205_DELL_M43
),
2403 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fc,
2404 "unknown Dell", STAC_9205_DELL_M42
),
2405 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fd,
2406 "unknown Dell", STAC_9205_DELL_M42
),
2407 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fe,
2408 "Dell Precision", STAC_9205_DELL_M43
),
2409 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ff,
2410 "Dell Precision M4300", STAC_9205_DELL_M43
),
2411 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0204,
2412 "unknown Dell", STAC_9205_DELL_M42
),
2413 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0206,
2414 "Dell Precision", STAC_9205_DELL_M43
),
2415 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x021b,
2416 "Dell Precision", STAC_9205_DELL_M43
),
2417 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x021c,
2418 "Dell Precision", STAC_9205_DELL_M43
),
2419 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x021f,
2420 "Dell Inspiron", STAC_9205_DELL_M44
),
2421 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0228,
2422 "Dell Vostro 1500", STAC_9205_DELL_M42
),
2424 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD
),
2428 static void stac92xx_set_config_regs(struct hda_codec
*codec
,
2429 unsigned int *pincfgs
)
2432 struct sigmatel_spec
*spec
= codec
->spec
;
2437 for (i
= 0; i
< spec
->num_pins
; i
++)
2438 if (spec
->pin_nids
[i
] && pincfgs
[i
])
2439 snd_hda_codec_set_pincfg(codec
, spec
->pin_nids
[i
],
2444 * Analog playback callbacks
2446 static int stac92xx_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2447 struct hda_codec
*codec
,
2448 struct snd_pcm_substream
*substream
)
2450 struct sigmatel_spec
*spec
= codec
->spec
;
2451 if (spec
->stream_delay
)
2452 msleep(spec
->stream_delay
);
2453 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
2457 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2458 struct hda_codec
*codec
,
2459 unsigned int stream_tag
,
2460 unsigned int format
,
2461 struct snd_pcm_substream
*substream
)
2463 struct sigmatel_spec
*spec
= codec
->spec
;
2464 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
, stream_tag
, format
, substream
);
2467 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2468 struct hda_codec
*codec
,
2469 struct snd_pcm_substream
*substream
)
2471 struct sigmatel_spec
*spec
= codec
->spec
;
2472 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
2476 * Digital playback callbacks
2478 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2479 struct hda_codec
*codec
,
2480 struct snd_pcm_substream
*substream
)
2482 struct sigmatel_spec
*spec
= codec
->spec
;
2483 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
2486 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
2487 struct hda_codec
*codec
,
2488 struct snd_pcm_substream
*substream
)
2490 struct sigmatel_spec
*spec
= codec
->spec
;
2491 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
2494 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2495 struct hda_codec
*codec
,
2496 unsigned int stream_tag
,
2497 unsigned int format
,
2498 struct snd_pcm_substream
*substream
)
2500 struct sigmatel_spec
*spec
= codec
->spec
;
2501 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
2502 stream_tag
, format
, substream
);
2505 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2506 struct hda_codec
*codec
,
2507 struct snd_pcm_substream
*substream
)
2509 struct sigmatel_spec
*spec
= codec
->spec
;
2510 return snd_hda_multi_out_dig_cleanup(codec
, &spec
->multiout
);
2515 * Analog capture callbacks
2517 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2518 struct hda_codec
*codec
,
2519 unsigned int stream_tag
,
2520 unsigned int format
,
2521 struct snd_pcm_substream
*substream
)
2523 struct sigmatel_spec
*spec
= codec
->spec
;
2524 hda_nid_t nid
= spec
->adc_nids
[substream
->number
];
2526 if (spec
->powerdown_adcs
) {
2528 snd_hda_codec_write(codec
, nid
, 0,
2529 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
2531 snd_hda_codec_setup_stream(codec
, nid
, stream_tag
, 0, format
);
2535 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2536 struct hda_codec
*codec
,
2537 struct snd_pcm_substream
*substream
)
2539 struct sigmatel_spec
*spec
= codec
->spec
;
2540 hda_nid_t nid
= spec
->adc_nids
[substream
->number
];
2542 snd_hda_codec_cleanup_stream(codec
, nid
);
2543 if (spec
->powerdown_adcs
)
2544 snd_hda_codec_write(codec
, nid
, 0,
2545 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
2549 static struct hda_pcm_stream stac92xx_pcm_digital_playback
= {
2553 /* NID is set in stac92xx_build_pcms */
2555 .open
= stac92xx_dig_playback_pcm_open
,
2556 .close
= stac92xx_dig_playback_pcm_close
,
2557 .prepare
= stac92xx_dig_playback_pcm_prepare
,
2558 .cleanup
= stac92xx_dig_playback_pcm_cleanup
2562 static struct hda_pcm_stream stac92xx_pcm_digital_capture
= {
2566 /* NID is set in stac92xx_build_pcms */
2569 static struct hda_pcm_stream stac92xx_pcm_analog_playback
= {
2573 .nid
= 0x02, /* NID to query formats and rates */
2575 .open
= stac92xx_playback_pcm_open
,
2576 .prepare
= stac92xx_playback_pcm_prepare
,
2577 .cleanup
= stac92xx_playback_pcm_cleanup
2581 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback
= {
2585 .nid
= 0x06, /* NID to query formats and rates */
2587 .open
= stac92xx_playback_pcm_open
,
2588 .prepare
= stac92xx_playback_pcm_prepare
,
2589 .cleanup
= stac92xx_playback_pcm_cleanup
2593 static struct hda_pcm_stream stac92xx_pcm_analog_capture
= {
2596 /* NID + .substreams is set in stac92xx_build_pcms */
2598 .prepare
= stac92xx_capture_pcm_prepare
,
2599 .cleanup
= stac92xx_capture_pcm_cleanup
2603 static int stac92xx_build_pcms(struct hda_codec
*codec
)
2605 struct sigmatel_spec
*spec
= codec
->spec
;
2606 struct hda_pcm
*info
= spec
->pcm_rec
;
2608 codec
->num_pcms
= 1;
2609 codec
->pcm_info
= info
;
2611 info
->name
= "STAC92xx Analog";
2612 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_analog_playback
;
2613 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
2614 spec
->multiout
.dac_nids
[0];
2615 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = stac92xx_pcm_analog_capture
;
2616 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
2617 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adcs
;
2619 if (spec
->alt_switch
) {
2622 info
->name
= "STAC92xx Analog Alt";
2623 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_analog_alt_playback
;
2626 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
2629 info
->name
= "STAC92xx Digital";
2630 info
->pcm_type
= spec
->autocfg
.dig_out_type
[0];
2631 if (spec
->multiout
.dig_out_nid
) {
2632 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_digital_playback
;
2633 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
2635 if (spec
->dig_in_nid
) {
2636 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = stac92xx_pcm_digital_capture
;
2637 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
2644 static unsigned int stac92xx_get_vref(struct hda_codec
*codec
, hda_nid_t nid
)
2646 unsigned int pincap
= snd_hda_query_pin_caps(codec
, nid
);
2647 pincap
= (pincap
& AC_PINCAP_VREF
) >> AC_PINCAP_VREF_SHIFT
;
2648 if (pincap
& AC_PINCAP_VREF_100
)
2649 return AC_PINCTL_VREF_100
;
2650 if (pincap
& AC_PINCAP_VREF_80
)
2651 return AC_PINCTL_VREF_80
;
2652 if (pincap
& AC_PINCAP_VREF_50
)
2653 return AC_PINCTL_VREF_50
;
2654 if (pincap
& AC_PINCAP_VREF_GRD
)
2655 return AC_PINCTL_VREF_GRD
;
2659 static void stac92xx_auto_set_pinctl(struct hda_codec
*codec
, hda_nid_t nid
, int pin_type
)
2662 snd_hda_codec_write_cache(codec
, nid
, 0,
2663 AC_VERB_SET_PIN_WIDGET_CONTROL
, pin_type
);
2666 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2668 static int stac92xx_hp_switch_get(struct snd_kcontrol
*kcontrol
,
2669 struct snd_ctl_elem_value
*ucontrol
)
2671 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2672 struct sigmatel_spec
*spec
= codec
->spec
;
2674 ucontrol
->value
.integer
.value
[0] = !!spec
->hp_switch
;
2678 static void stac_issue_unsol_event(struct hda_codec
*codec
, hda_nid_t nid
,
2679 unsigned char type
);
2681 static int stac92xx_hp_switch_put(struct snd_kcontrol
*kcontrol
,
2682 struct snd_ctl_elem_value
*ucontrol
)
2684 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2685 struct sigmatel_spec
*spec
= codec
->spec
;
2686 int nid
= kcontrol
->private_value
;
2688 spec
->hp_switch
= ucontrol
->value
.integer
.value
[0] ? nid
: 0;
2690 /* check to be sure that the ports are upto date with
2693 stac_issue_unsol_event(codec
, nid
, STAC_HP_EVENT
);
2698 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2700 static int stac92xx_io_switch_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2702 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2703 struct sigmatel_spec
*spec
= codec
->spec
;
2704 int io_idx
= kcontrol
-> private_value
& 0xff;
2706 ucontrol
->value
.integer
.value
[0] = spec
->io_switch
[io_idx
];
2710 static int stac92xx_io_switch_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2712 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2713 struct sigmatel_spec
*spec
= codec
->spec
;
2714 hda_nid_t nid
= kcontrol
->private_value
>> 8;
2715 int io_idx
= kcontrol
-> private_value
& 0xff;
2716 unsigned short val
= !!ucontrol
->value
.integer
.value
[0];
2718 spec
->io_switch
[io_idx
] = val
;
2721 stac92xx_auto_set_pinctl(codec
, nid
, AC_PINCTL_OUT_EN
);
2723 unsigned int pinctl
= AC_PINCTL_IN_EN
;
2724 if (io_idx
) /* set VREF for mic */
2725 pinctl
|= stac92xx_get_vref(codec
, nid
);
2726 stac92xx_auto_set_pinctl(codec
, nid
, pinctl
);
2729 /* check the auto-mute again: we need to mute/unmute the speaker
2730 * appropriately according to the pin direction
2732 if (spec
->hp_detect
)
2733 stac_issue_unsol_event(codec
, nid
, STAC_HP_EVENT
);
2738 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2740 static int stac92xx_clfe_switch_get(struct snd_kcontrol
*kcontrol
,
2741 struct snd_ctl_elem_value
*ucontrol
)
2743 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2744 struct sigmatel_spec
*spec
= codec
->spec
;
2746 ucontrol
->value
.integer
.value
[0] = spec
->clfe_swap
;
2750 static int stac92xx_clfe_switch_put(struct snd_kcontrol
*kcontrol
,
2751 struct snd_ctl_elem_value
*ucontrol
)
2753 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2754 struct sigmatel_spec
*spec
= codec
->spec
;
2755 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
2756 unsigned int val
= !!ucontrol
->value
.integer
.value
[0];
2758 if (spec
->clfe_swap
== val
)
2761 spec
->clfe_swap
= val
;
2763 snd_hda_codec_write_cache(codec
, nid
, 0, AC_VERB_SET_EAPD_BTLENABLE
,
2764 spec
->clfe_swap
? 0x4 : 0x0);
2769 #define STAC_CODEC_HP_SWITCH(xname) \
2770 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2773 .info = stac92xx_hp_switch_info, \
2774 .get = stac92xx_hp_switch_get, \
2775 .put = stac92xx_hp_switch_put, \
2778 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2779 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2782 .info = stac92xx_io_switch_info, \
2783 .get = stac92xx_io_switch_get, \
2784 .put = stac92xx_io_switch_put, \
2785 .private_value = xpval, \
2788 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2789 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2792 .info = stac92xx_clfe_switch_info, \
2793 .get = stac92xx_clfe_switch_get, \
2794 .put = stac92xx_clfe_switch_put, \
2795 .private_value = xpval, \
2799 STAC_CTL_WIDGET_VOL
,
2800 STAC_CTL_WIDGET_MUTE
,
2801 STAC_CTL_WIDGET_MONO_MUX
,
2802 STAC_CTL_WIDGET_AMP_MUX
,
2803 STAC_CTL_WIDGET_AMP_VOL
,
2804 STAC_CTL_WIDGET_HP_SWITCH
,
2805 STAC_CTL_WIDGET_IO_SWITCH
,
2806 STAC_CTL_WIDGET_CLFE_SWITCH
,
2807 STAC_CTL_WIDGET_DC_BIAS
2810 static struct snd_kcontrol_new stac92xx_control_templates
[] = {
2811 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2812 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2815 STAC_AMP_VOL(NULL
, 0, 0, 0, 0),
2816 STAC_CODEC_HP_SWITCH(NULL
),
2817 STAC_CODEC_IO_SWITCH(NULL
, 0),
2818 STAC_CODEC_CLFE_SWITCH(NULL
, 0),
2819 DC_BIAS(NULL
, 0, 0),
2822 /* add dynamic controls */
2823 static struct snd_kcontrol_new
*
2824 stac_control_new(struct sigmatel_spec
*spec
,
2825 struct snd_kcontrol_new
*ktemp
,
2828 struct snd_kcontrol_new
*knew
;
2830 snd_array_init(&spec
->kctls
, sizeof(*knew
), 32);
2831 knew
= snd_array_new(&spec
->kctls
);
2835 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2838 memset(knew
, 0, sizeof(*knew
));
2839 spec
->kctls
.alloced
--;
2845 static int stac92xx_add_control_temp(struct sigmatel_spec
*spec
,
2846 struct snd_kcontrol_new
*ktemp
,
2847 int idx
, const char *name
,
2850 struct snd_kcontrol_new
*knew
= stac_control_new(spec
, ktemp
, name
);
2854 knew
->private_value
= val
;
2858 static inline int stac92xx_add_control_idx(struct sigmatel_spec
*spec
,
2859 int type
, int idx
, const char *name
,
2862 return stac92xx_add_control_temp(spec
,
2863 &stac92xx_control_templates
[type
],
2868 /* add dynamic controls */
2869 static inline int stac92xx_add_control(struct sigmatel_spec
*spec
, int type
,
2870 const char *name
, unsigned long val
)
2872 return stac92xx_add_control_idx(spec
, type
, 0, name
, val
);
2875 static struct snd_kcontrol_new stac_input_src_temp
= {
2876 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2877 .name
= "Input Source",
2878 .info
= stac92xx_mux_enum_info
,
2879 .get
= stac92xx_mux_enum_get
,
2880 .put
= stac92xx_mux_enum_put
,
2883 static int stac92xx_add_input_source(struct sigmatel_spec
*spec
)
2885 struct snd_kcontrol_new
*knew
;
2886 struct hda_input_mux
*imux
= &spec
->private_imux
;
2888 if (!spec
->num_adcs
|| imux
->num_items
<= 1)
2889 return 0; /* no need for input source control */
2890 knew
= stac_control_new(spec
, &stac_input_src_temp
,
2891 stac_input_src_temp
.name
);
2894 knew
->count
= spec
->num_adcs
;
2898 /* check whether the line-input can be used as line-out */
2899 static hda_nid_t
check_line_out_switch(struct hda_codec
*codec
)
2901 struct sigmatel_spec
*spec
= codec
->spec
;
2902 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2904 unsigned int pincap
;
2906 if (cfg
->line_out_type
!= AUTO_PIN_LINE_OUT
)
2908 nid
= cfg
->input_pins
[AUTO_PIN_LINE
];
2909 pincap
= snd_hda_query_pin_caps(codec
, nid
);
2910 if (pincap
& AC_PINCAP_OUT
)
2915 /* check whether the mic-input can be used as line-out */
2916 static hda_nid_t
check_mic_out_switch(struct hda_codec
*codec
)
2918 struct sigmatel_spec
*spec
= codec
->spec
;
2919 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2920 unsigned int def_conf
, pincap
;
2921 unsigned int mic_pin
;
2923 if (cfg
->line_out_type
!= AUTO_PIN_LINE_OUT
)
2925 mic_pin
= AUTO_PIN_MIC
;
2927 hda_nid_t nid
= cfg
->input_pins
[mic_pin
];
2928 def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
2929 /* some laptops have an internal analog microphone
2930 * which can't be used as a output */
2931 if (get_defcfg_connect(def_conf
) != AC_JACK_PORT_FIXED
) {
2932 pincap
= snd_hda_query_pin_caps(codec
, nid
);
2933 if (pincap
& AC_PINCAP_OUT
)
2936 if (mic_pin
== AUTO_PIN_MIC
)
2937 mic_pin
= AUTO_PIN_FRONT_MIC
;
2944 static int is_in_dac_nids(struct sigmatel_spec
*spec
, hda_nid_t nid
)
2948 for (i
= 0; i
< spec
->multiout
.num_dacs
; i
++) {
2949 if (spec
->multiout
.dac_nids
[i
] == nid
)
2956 static int check_all_dac_nids(struct sigmatel_spec
*spec
, hda_nid_t nid
)
2959 if (is_in_dac_nids(spec
, nid
))
2961 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++)
2962 if (spec
->hp_dacs
[i
] == nid
)
2964 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++)
2965 if (spec
->speaker_dacs
[i
] == nid
)
2970 static hda_nid_t
get_unassigned_dac(struct hda_codec
*codec
, hda_nid_t nid
)
2972 struct sigmatel_spec
*spec
= codec
->spec
;
2974 hda_nid_t conn
[HDA_MAX_CONNECTIONS
];
2975 unsigned int wcaps
, wtype
;
2977 conn_len
= snd_hda_get_connections(codec
, nid
, conn
,
2978 HDA_MAX_CONNECTIONS
);
2979 for (j
= 0; j
< conn_len
; j
++) {
2980 wcaps
= get_wcaps(codec
, conn
[j
]);
2981 wtype
= (wcaps
& AC_WCAP_TYPE
) >> AC_WCAP_TYPE_SHIFT
;
2982 /* we check only analog outputs */
2983 if (wtype
!= AC_WID_AUD_OUT
|| (wcaps
& AC_WCAP_DIGITAL
))
2985 /* if this route has a free DAC, assign it */
2986 if (!check_all_dac_nids(spec
, conn
[j
])) {
2988 /* select this DAC in the pin's input mux */
2989 snd_hda_codec_write_cache(codec
, nid
, 0,
2990 AC_VERB_SET_CONNECT_SEL
, j
);
2995 /* if all DACs are already assigned, connect to the primary DAC */
2997 for (j
= 0; j
< conn_len
; j
++) {
2998 if (conn
[j
] == spec
->multiout
.dac_nids
[0]) {
2999 snd_hda_codec_write_cache(codec
, nid
, 0,
3000 AC_VERB_SET_CONNECT_SEL
, j
);
3008 static int add_spec_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
);
3009 static int add_spec_extra_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
);
3012 * Fill in the dac_nids table from the parsed pin configuration
3013 * This function only works when every pin in line_out_pins[]
3014 * contains atleast one DAC in its connection list. Some 92xx
3015 * codecs are not connected directly to a DAC, such as the 9200
3016 * and 9202/925x. For those, dac_nids[] must be hard-coded.
3018 static int stac92xx_auto_fill_dac_nids(struct hda_codec
*codec
)
3020 struct sigmatel_spec
*spec
= codec
->spec
;
3021 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3025 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3026 nid
= cfg
->line_out_pins
[i
];
3027 dac
= get_unassigned_dac(codec
, nid
);
3029 if (spec
->multiout
.num_dacs
> 0) {
3030 /* we have already working output pins,
3031 * so let's drop the broken ones again
3033 cfg
->line_outs
= spec
->multiout
.num_dacs
;
3036 /* error out, no available DAC found */
3038 "%s: No available DAC for pin 0x%x\n",
3042 add_spec_dacs(spec
, dac
);
3045 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3046 nid
= cfg
->hp_pins
[i
];
3047 dac
= get_unassigned_dac(codec
, nid
);
3049 if (!spec
->multiout
.hp_nid
)
3050 spec
->multiout
.hp_nid
= dac
;
3052 add_spec_extra_dacs(spec
, dac
);
3054 spec
->hp_dacs
[i
] = dac
;
3057 for (i
= 0; i
< cfg
->speaker_outs
; i
++) {
3058 nid
= cfg
->speaker_pins
[i
];
3059 dac
= get_unassigned_dac(codec
, nid
);
3061 add_spec_extra_dacs(spec
, dac
);
3062 spec
->speaker_dacs
[i
] = dac
;
3065 /* add line-in as output */
3066 nid
= check_line_out_switch(codec
);
3068 dac
= get_unassigned_dac(codec
, nid
);
3070 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3071 nid
, cfg
->line_outs
);
3072 cfg
->line_out_pins
[cfg
->line_outs
] = nid
;
3074 spec
->line_switch
= nid
;
3075 add_spec_dacs(spec
, dac
);
3078 /* add mic as output */
3079 nid
= check_mic_out_switch(codec
);
3081 dac
= get_unassigned_dac(codec
, nid
);
3083 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3084 nid
, cfg
->line_outs
);
3085 cfg
->line_out_pins
[cfg
->line_outs
] = nid
;
3087 spec
->mic_switch
= nid
;
3088 add_spec_dacs(spec
, dac
);
3092 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
3093 spec
->multiout
.num_dacs
,
3094 spec
->multiout
.dac_nids
[0],
3095 spec
->multiout
.dac_nids
[1],
3096 spec
->multiout
.dac_nids
[2],
3097 spec
->multiout
.dac_nids
[3],
3098 spec
->multiout
.dac_nids
[4]);
3103 /* create volume control/switch for the given prefx type */
3104 static int create_controls_idx(struct hda_codec
*codec
, const char *pfx
,
3105 int idx
, hda_nid_t nid
, int chs
)
3107 struct sigmatel_spec
*spec
= codec
->spec
;
3111 if (!spec
->check_volume_offset
) {
3112 unsigned int caps
, step
, nums
, db_scale
;
3113 caps
= query_amp_caps(codec
, nid
, HDA_OUTPUT
);
3114 step
= (caps
& AC_AMPCAP_STEP_SIZE
) >>
3115 AC_AMPCAP_STEP_SIZE_SHIFT
;
3116 step
= (step
+ 1) * 25; /* in .01dB unit */
3117 nums
= (caps
& AC_AMPCAP_NUM_STEPS
) >>
3118 AC_AMPCAP_NUM_STEPS_SHIFT
;
3119 db_scale
= nums
* step
;
3120 /* if dB scale is over -64dB, and finer enough,
3121 * let's reduce it to half
3123 if (db_scale
> 6400 && nums
>= 0x1f)
3124 spec
->volume_offset
= nums
/ 2;
3125 spec
->check_volume_offset
= 1;
3128 sprintf(name
, "%s Playback Volume", pfx
);
3129 err
= stac92xx_add_control_idx(spec
, STAC_CTL_WIDGET_VOL
, idx
, name
,
3130 HDA_COMPOSE_AMP_VAL_OFS(nid
, chs
, 0, HDA_OUTPUT
,
3131 spec
->volume_offset
));
3134 sprintf(name
, "%s Playback Switch", pfx
);
3135 err
= stac92xx_add_control_idx(spec
, STAC_CTL_WIDGET_MUTE
, idx
, name
,
3136 HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
));
3142 #define create_controls(codec, pfx, nid, chs) \
3143 create_controls_idx(codec, pfx, 0, nid, chs)
3145 static int add_spec_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
)
3147 if (spec
->multiout
.num_dacs
> 4) {
3148 printk(KERN_WARNING
"stac92xx: No space for DAC 0x%x\n", nid
);
3151 spec
->multiout
.dac_nids
[spec
->multiout
.num_dacs
] = nid
;
3152 spec
->multiout
.num_dacs
++;
3157 static int add_spec_extra_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
)
3160 for (i
= 0; i
< ARRAY_SIZE(spec
->multiout
.extra_out_nid
); i
++) {
3161 if (!spec
->multiout
.extra_out_nid
[i
]) {
3162 spec
->multiout
.extra_out_nid
[i
] = nid
;
3166 printk(KERN_WARNING
"stac92xx: No space for extra DAC 0x%x\n", nid
);
3170 /* Create output controls
3171 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3173 static int create_multi_out_ctls(struct hda_codec
*codec
, int num_outs
,
3174 const hda_nid_t
*pins
,
3175 const hda_nid_t
*dac_nids
,
3178 struct sigmatel_spec
*spec
= codec
->spec
;
3179 static const char *chname
[4] = {
3180 "Front", "Surround", NULL
/*CLFE*/, "Side"
3184 unsigned int wid_caps
;
3186 for (i
= 0; i
< num_outs
&& i
< ARRAY_SIZE(chname
); i
++) {
3187 if (type
== AUTO_PIN_HP_OUT
&& !spec
->hp_detect
) {
3188 wid_caps
= get_wcaps(codec
, pins
[i
]);
3189 if (wid_caps
& AC_WCAP_UNSOL_CAP
)
3190 spec
->hp_detect
= 1;
3195 if (type
!= AUTO_PIN_HP_OUT
&& i
== 2) {
3197 err
= create_controls(codec
, "Center", nid
, 1);
3200 err
= create_controls(codec
, "LFE", nid
, 2);
3204 wid_caps
= get_wcaps(codec
, nid
);
3206 if (wid_caps
& AC_WCAP_LR_SWAP
) {
3207 err
= stac92xx_add_control(spec
,
3208 STAC_CTL_WIDGET_CLFE_SWITCH
,
3209 "Swap Center/LFE Playback Switch", nid
);
3219 case AUTO_PIN_HP_OUT
:
3223 case AUTO_PIN_SPEAKER_OUT
:
3232 err
= create_controls_idx(codec
, name
, idx
, nid
, 3);
3240 /* add playback controls from the parsed DAC table */
3241 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec
*codec
,
3242 const struct auto_pin_cfg
*cfg
)
3244 struct sigmatel_spec
*spec
= codec
->spec
;
3247 err
= create_multi_out_ctls(codec
, cfg
->line_outs
, cfg
->line_out_pins
,
3248 spec
->multiout
.dac_nids
,
3249 cfg
->line_out_type
);
3253 if (cfg
->hp_outs
> 1 && cfg
->line_out_type
== AUTO_PIN_LINE_OUT
) {
3254 err
= stac92xx_add_control(spec
,
3255 STAC_CTL_WIDGET_HP_SWITCH
,
3256 "Headphone as Line Out Switch",
3257 cfg
->hp_pins
[cfg
->hp_outs
- 1]);
3262 if (spec
->line_switch
) {
3263 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_IO_SWITCH
,
3264 "Line In as Output Switch",
3265 spec
->line_switch
<< 8);
3270 if (spec
->mic_switch
) {
3271 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_DC_BIAS
,
3281 /* add playback controls for Speaker and HP outputs */
3282 static int stac92xx_auto_create_hp_ctls(struct hda_codec
*codec
,
3283 struct auto_pin_cfg
*cfg
)
3285 struct sigmatel_spec
*spec
= codec
->spec
;
3288 err
= create_multi_out_ctls(codec
, cfg
->hp_outs
, cfg
->hp_pins
,
3289 spec
->hp_dacs
, AUTO_PIN_HP_OUT
);
3293 err
= create_multi_out_ctls(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
,
3294 spec
->speaker_dacs
, AUTO_PIN_SPEAKER_OUT
);
3301 /* labels for mono mux outputs */
3302 static const char *stac92xx_mono_labels
[4] = {
3303 "DAC0", "DAC1", "Mixer", "DAC2"
3306 /* create mono mux for mono out on capable codecs */
3307 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec
*codec
)
3309 struct sigmatel_spec
*spec
= codec
->spec
;
3310 struct hda_input_mux
*mono_mux
= &spec
->private_mono_mux
;
3312 hda_nid_t con_lst
[ARRAY_SIZE(stac92xx_mono_labels
)];
3314 num_cons
= snd_hda_get_connections(codec
,
3317 HDA_MAX_NUM_INPUTS
);
3318 if (!num_cons
|| num_cons
> ARRAY_SIZE(stac92xx_mono_labels
))
3321 for (i
= 0; i
< num_cons
; i
++) {
3322 mono_mux
->items
[mono_mux
->num_items
].label
=
3323 stac92xx_mono_labels
[i
];
3324 mono_mux
->items
[mono_mux
->num_items
].index
= i
;
3325 mono_mux
->num_items
++;
3328 return stac92xx_add_control(spec
, STAC_CTL_WIDGET_MONO_MUX
,
3329 "Mono Mux", spec
->mono_nid
);
3332 /* labels for amp mux outputs */
3333 static const char *stac92xx_amp_labels
[3] = {
3334 "Front Microphone", "Microphone", "Line In",
3337 /* create amp out controls mux on capable codecs */
3338 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec
*codec
)
3340 struct sigmatel_spec
*spec
= codec
->spec
;
3341 struct hda_input_mux
*amp_mux
= &spec
->private_amp_mux
;
3344 for (i
= 0; i
< spec
->num_amps
; i
++) {
3345 amp_mux
->items
[amp_mux
->num_items
].label
=
3346 stac92xx_amp_labels
[i
];
3347 amp_mux
->items
[amp_mux
->num_items
].index
= i
;
3348 amp_mux
->num_items
++;
3351 if (spec
->num_amps
> 1) {
3352 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_AMP_MUX
,
3353 "Amp Selector Capture Switch", 0);
3357 return stac92xx_add_control(spec
, STAC_CTL_WIDGET_AMP_VOL
,
3358 "Amp Capture Volume",
3359 HDA_COMPOSE_AMP_VAL(spec
->amp_nids
[0], 3, 0, HDA_INPUT
));
3363 /* create PC beep volume controls */
3364 static int stac92xx_auto_create_beep_ctls(struct hda_codec
*codec
,
3367 struct sigmatel_spec
*spec
= codec
->spec
;
3368 u32 caps
= query_amp_caps(codec
, nid
, HDA_OUTPUT
);
3371 /* check for mute support for the the amp */
3372 if ((caps
& AC_AMPCAP_MUTE
) >> AC_AMPCAP_MUTE_SHIFT
) {
3373 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_MUTE
,
3374 "PC Beep Playback Switch",
3375 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, HDA_OUTPUT
));
3380 /* check to see if there is volume support for the amp */
3381 if ((caps
& AC_AMPCAP_NUM_STEPS
) >> AC_AMPCAP_NUM_STEPS_SHIFT
) {
3382 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_VOL
,
3383 "PC Beep Playback Volume",
3384 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, HDA_OUTPUT
));
3391 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3392 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3394 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol
*kcontrol
,
3395 struct snd_ctl_elem_value
*ucontrol
)
3397 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3398 ucontrol
->value
.integer
.value
[0] = codec
->beep
->enabled
;
3402 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol
*kcontrol
,
3403 struct snd_ctl_elem_value
*ucontrol
)
3405 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3406 int enabled
= !!ucontrol
->value
.integer
.value
[0];
3407 if (codec
->beep
->enabled
!= enabled
) {
3408 codec
->beep
->enabled
= enabled
;
3414 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl
= {
3415 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3416 .info
= stac92xx_dig_beep_switch_info
,
3417 .get
= stac92xx_dig_beep_switch_get
,
3418 .put
= stac92xx_dig_beep_switch_put
,
3421 static int stac92xx_beep_switch_ctl(struct hda_codec
*codec
)
3423 return stac92xx_add_control_temp(codec
->spec
, &stac92xx_dig_beep_ctrl
,
3424 0, "PC Beep Playback Switch", 0);
3428 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec
*codec
)
3430 struct sigmatel_spec
*spec
= codec
->spec
;
3431 int wcaps
, nid
, i
, err
= 0;
3433 for (i
= 0; i
< spec
->num_muxes
; i
++) {
3434 nid
= spec
->mux_nids
[i
];
3435 wcaps
= get_wcaps(codec
, nid
);
3437 if (wcaps
& AC_WCAP_OUT_AMP
) {
3438 err
= stac92xx_add_control_idx(spec
,
3439 STAC_CTL_WIDGET_VOL
, i
, "Mux Capture Volume",
3440 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
));
3448 static const char *stac92xx_spdif_labels
[3] = {
3449 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3452 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec
*codec
)
3454 struct sigmatel_spec
*spec
= codec
->spec
;
3455 struct hda_input_mux
*spdif_mux
= &spec
->private_smux
;
3456 const char **labels
= spec
->spdif_labels
;
3458 hda_nid_t con_lst
[HDA_MAX_NUM_INPUTS
];
3460 num_cons
= snd_hda_get_connections(codec
,
3463 HDA_MAX_NUM_INPUTS
);
3468 labels
= stac92xx_spdif_labels
;
3470 for (i
= 0; i
< num_cons
; i
++) {
3471 spdif_mux
->items
[spdif_mux
->num_items
].label
= labels
[i
];
3472 spdif_mux
->items
[spdif_mux
->num_items
].index
= i
;
3473 spdif_mux
->num_items
++;
3479 /* labels for dmic mux inputs */
3480 static const char *stac92xx_dmic_labels
[5] = {
3481 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3482 "Digital Mic 3", "Digital Mic 4"
3485 /* create playback/capture controls for input pins on dmic capable codecs */
3486 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec
*codec
,
3487 const struct auto_pin_cfg
*cfg
)
3489 struct sigmatel_spec
*spec
= codec
->spec
;
3490 struct hda_input_mux
*dimux
= &spec
->private_dimux
;
3491 hda_nid_t con_lst
[HDA_MAX_NUM_INPUTS
];
3495 dimux
->items
[dimux
->num_items
].label
= stac92xx_dmic_labels
[0];
3496 dimux
->items
[dimux
->num_items
].index
= 0;
3499 for (i
= 0; i
< spec
->num_dmics
; i
++) {
3504 unsigned int def_conf
;
3506 def_conf
= snd_hda_codec_get_pincfg(codec
, spec
->dmic_nids
[i
]);
3507 if (get_defcfg_connect(def_conf
) == AC_JACK_PORT_NONE
)
3510 nid
= spec
->dmic_nids
[i
];
3511 num_cons
= snd_hda_get_connections(codec
,
3514 HDA_MAX_NUM_INPUTS
);
3515 for (j
= 0; j
< num_cons
; j
++)
3516 if (con_lst
[j
] == nid
) {
3522 wcaps
= get_wcaps(codec
, nid
) &
3523 (AC_WCAP_OUT_AMP
| AC_WCAP_IN_AMP
);
3526 sprintf(name
, "%s Capture Volume",
3527 stac92xx_dmic_labels
[dimux
->num_items
]);
3529 err
= stac92xx_add_control(spec
,
3530 STAC_CTL_WIDGET_VOL
,
3532 HDA_COMPOSE_AMP_VAL(nid
, 3, 0,
3533 (wcaps
& AC_WCAP_OUT_AMP
) ?
3534 HDA_OUTPUT
: HDA_INPUT
));
3539 dimux
->items
[dimux
->num_items
].label
=
3540 stac92xx_dmic_labels
[dimux
->num_items
];
3541 dimux
->items
[dimux
->num_items
].index
= index
;
3548 /* create playback/capture controls for input pins */
3549 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec
*codec
, const struct auto_pin_cfg
*cfg
)
3551 struct sigmatel_spec
*spec
= codec
->spec
;
3552 struct hda_input_mux
*imux
= &spec
->private_imux
;
3553 hda_nid_t con_lst
[HDA_MAX_NUM_INPUTS
];
3556 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
3559 if (!cfg
->input_pins
[i
])
3562 for (j
= 0; j
< spec
->num_muxes
; j
++) {
3564 num_cons
= snd_hda_get_connections(codec
,
3567 HDA_MAX_NUM_INPUTS
);
3568 for (k
= 0; k
< num_cons
; k
++)
3569 if (con_lst
[k
] == cfg
->input_pins
[i
]) {
3576 imux
->items
[imux
->num_items
].label
= auto_pin_cfg_labels
[i
];
3577 imux
->items
[imux
->num_items
].index
= index
;
3581 if (imux
->num_items
) {
3583 * Set the current input for the muxes.
3584 * The STAC9221 has two input muxes with identical source
3585 * NID lists. Hopefully this won't get confused.
3587 for (i
= 0; i
< spec
->num_muxes
; i
++) {
3588 snd_hda_codec_write_cache(codec
, spec
->mux_nids
[i
], 0,
3589 AC_VERB_SET_CONNECT_SEL
,
3590 imux
->items
[0].index
);
3597 static void stac92xx_auto_init_multi_out(struct hda_codec
*codec
)
3599 struct sigmatel_spec
*spec
= codec
->spec
;
3602 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
3603 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
3604 stac92xx_auto_set_pinctl(codec
, nid
, AC_PINCTL_OUT_EN
);
3608 static void stac92xx_auto_init_hp_out(struct hda_codec
*codec
)
3610 struct sigmatel_spec
*spec
= codec
->spec
;
3613 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
3615 pin
= spec
->autocfg
.hp_pins
[i
];
3616 if (pin
) /* connect to front */
3617 stac92xx_auto_set_pinctl(codec
, pin
, AC_PINCTL_OUT_EN
| AC_PINCTL_HP_EN
);
3619 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++) {
3621 pin
= spec
->autocfg
.speaker_pins
[i
];
3622 if (pin
) /* connect to front */
3623 stac92xx_auto_set_pinctl(codec
, pin
, AC_PINCTL_OUT_EN
);
3627 static int stac92xx_parse_auto_config(struct hda_codec
*codec
, hda_nid_t dig_out
, hda_nid_t dig_in
)
3629 struct sigmatel_spec
*spec
= codec
->spec
;
3633 if ((err
= snd_hda_parse_pin_def_config(codec
,
3635 spec
->dmic_nids
)) < 0)
3637 if (! spec
->autocfg
.line_outs
)
3638 return 0; /* can't find valid pin config */
3640 /* If we have no real line-out pin and multiple hp-outs, HPs should
3641 * be set up as multi-channel outputs.
3643 if (spec
->autocfg
.line_out_type
== AUTO_PIN_SPEAKER_OUT
&&
3644 spec
->autocfg
.hp_outs
> 1) {
3645 /* Copy hp_outs to line_outs, backup line_outs in
3646 * speaker_outs so that the following routines can handle
3647 * HP pins as primary outputs.
3649 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3650 memcpy(spec
->autocfg
.speaker_pins
, spec
->autocfg
.line_out_pins
,
3651 sizeof(spec
->autocfg
.line_out_pins
));
3652 spec
->autocfg
.speaker_outs
= spec
->autocfg
.line_outs
;
3653 memcpy(spec
->autocfg
.line_out_pins
, spec
->autocfg
.hp_pins
,
3654 sizeof(spec
->autocfg
.hp_pins
));
3655 spec
->autocfg
.line_outs
= spec
->autocfg
.hp_outs
;
3656 spec
->autocfg
.line_out_type
= AUTO_PIN_HP_OUT
;
3657 spec
->autocfg
.hp_outs
= 0;
3660 if (spec
->autocfg
.mono_out_pin
) {
3661 int dir
= get_wcaps(codec
, spec
->autocfg
.mono_out_pin
) &
3662 (AC_WCAP_OUT_AMP
| AC_WCAP_IN_AMP
);
3663 u32 caps
= query_amp_caps(codec
,
3664 spec
->autocfg
.mono_out_pin
, dir
);
3665 hda_nid_t conn_list
[1];
3667 /* get the mixer node and then the mono mux if it exists */
3668 if (snd_hda_get_connections(codec
,
3669 spec
->autocfg
.mono_out_pin
, conn_list
, 1) &&
3670 snd_hda_get_connections(codec
, conn_list
[0],
3673 int wcaps
= get_wcaps(codec
, conn_list
[0]);
3674 int wid_type
= (wcaps
& AC_WCAP_TYPE
)
3675 >> AC_WCAP_TYPE_SHIFT
;
3676 /* LR swap check, some stac925x have a mux that
3677 * changes the DACs output path instead of the
3680 if (wid_type
== AC_WID_AUD_SEL
&&
3681 !(wcaps
& AC_WCAP_LR_SWAP
))
3682 spec
->mono_nid
= conn_list
[0];
3685 hda_nid_t nid
= spec
->autocfg
.mono_out_pin
;
3687 /* most mono outs have a least a mute/unmute switch */
3688 dir
= (dir
& AC_WCAP_OUT_AMP
) ? HDA_OUTPUT
: HDA_INPUT
;
3689 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_MUTE
,
3690 "Mono Playback Switch",
3691 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, dir
));
3694 /* check for volume support for the amp */
3695 if ((caps
& AC_AMPCAP_NUM_STEPS
)
3696 >> AC_AMPCAP_NUM_STEPS_SHIFT
) {
3697 err
= stac92xx_add_control(spec
,
3698 STAC_CTL_WIDGET_VOL
,
3699 "Mono Playback Volume",
3700 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, dir
));
3706 stac92xx_auto_set_pinctl(codec
, spec
->autocfg
.mono_out_pin
,
3710 if (!spec
->multiout
.num_dacs
) {
3711 err
= stac92xx_auto_fill_dac_nids(codec
);
3714 err
= stac92xx_auto_create_multi_out_ctls(codec
,
3720 /* setup analog beep controls */
3721 if (spec
->anabeep_nid
> 0) {
3722 err
= stac92xx_auto_create_beep_ctls(codec
,
3728 /* setup digital beep controls and input device */
3729 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3730 if (spec
->digbeep_nid
> 0) {
3731 hda_nid_t nid
= spec
->digbeep_nid
;
3734 err
= stac92xx_auto_create_beep_ctls(codec
, nid
);
3737 err
= snd_hda_attach_beep_device(codec
, nid
);
3740 /* if no beep switch is available, make its own one */
3741 caps
= query_amp_caps(codec
, nid
, HDA_OUTPUT
);
3743 !((caps
& AC_AMPCAP_MUTE
) >> AC_AMPCAP_MUTE_SHIFT
)) {
3744 err
= stac92xx_beep_switch_ctl(codec
);
3751 err
= stac92xx_auto_create_hp_ctls(codec
, &spec
->autocfg
);
3755 /* All output parsing done, now restore the swapped hp pins */
3757 memcpy(spec
->autocfg
.hp_pins
, spec
->autocfg
.line_out_pins
,
3758 sizeof(spec
->autocfg
.hp_pins
));
3759 spec
->autocfg
.hp_outs
= spec
->autocfg
.line_outs
;
3760 spec
->autocfg
.line_out_type
= AUTO_PIN_HP_OUT
;
3761 spec
->autocfg
.line_outs
= 0;
3764 err
= stac92xx_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
3768 if (spec
->mono_nid
> 0) {
3769 err
= stac92xx_auto_create_mono_output_ctls(codec
);
3773 if (spec
->num_amps
> 0) {
3774 err
= stac92xx_auto_create_amp_output_ctls(codec
);
3778 if (spec
->num_dmics
> 0 && !spec
->dinput_mux
)
3779 if ((err
= stac92xx_auto_create_dmic_input_ctls(codec
,
3780 &spec
->autocfg
)) < 0)
3782 if (spec
->num_muxes
> 0) {
3783 err
= stac92xx_auto_create_mux_input_ctls(codec
);
3787 if (spec
->num_smuxes
> 0) {
3788 err
= stac92xx_auto_create_spdif_mux_ctls(codec
);
3793 err
= stac92xx_add_input_source(spec
);
3797 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3798 if (spec
->multiout
.max_channels
> 2)
3799 spec
->surr_switch
= 1;
3801 if (spec
->autocfg
.dig_outs
)
3802 spec
->multiout
.dig_out_nid
= dig_out
;
3803 if (dig_in
&& spec
->autocfg
.dig_in_pin
)
3804 spec
->dig_in_nid
= dig_in
;
3806 if (spec
->kctls
.list
)
3807 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
3809 spec
->input_mux
= &spec
->private_imux
;
3810 if (!spec
->dinput_mux
)
3811 spec
->dinput_mux
= &spec
->private_dimux
;
3812 spec
->sinput_mux
= &spec
->private_smux
;
3813 spec
->mono_mux
= &spec
->private_mono_mux
;
3814 spec
->amp_mux
= &spec
->private_amp_mux
;
3818 /* add playback controls for HP output */
3819 static int stac9200_auto_create_hp_ctls(struct hda_codec
*codec
,
3820 struct auto_pin_cfg
*cfg
)
3822 struct sigmatel_spec
*spec
= codec
->spec
;
3823 hda_nid_t pin
= cfg
->hp_pins
[0];
3824 unsigned int wid_caps
;
3829 wid_caps
= get_wcaps(codec
, pin
);
3830 if (wid_caps
& AC_WCAP_UNSOL_CAP
)
3831 spec
->hp_detect
= 1;
3836 /* add playback controls for LFE output */
3837 static int stac9200_auto_create_lfe_ctls(struct hda_codec
*codec
,
3838 struct auto_pin_cfg
*cfg
)
3840 struct sigmatel_spec
*spec
= codec
->spec
;
3842 hda_nid_t lfe_pin
= 0x0;
3846 * search speaker outs and line outs for a mono speaker pin
3847 * with an amp. If one is found, add LFE controls
3850 for (i
= 0; i
< spec
->autocfg
.speaker_outs
&& lfe_pin
== 0x0; i
++) {
3851 hda_nid_t pin
= spec
->autocfg
.speaker_pins
[i
];
3852 unsigned int wcaps
= get_wcaps(codec
, pin
);
3853 wcaps
&= (AC_WCAP_STEREO
| AC_WCAP_OUT_AMP
);
3854 if (wcaps
== AC_WCAP_OUT_AMP
)
3855 /* found a mono speaker with an amp, must be lfe */
3859 /* if speaker_outs is 0, then speakers may be in line_outs */
3860 if (lfe_pin
== 0 && spec
->autocfg
.speaker_outs
== 0) {
3861 for (i
= 0; i
< spec
->autocfg
.line_outs
&& lfe_pin
== 0x0; i
++) {
3862 hda_nid_t pin
= spec
->autocfg
.line_out_pins
[i
];
3863 unsigned int defcfg
;
3864 defcfg
= snd_hda_codec_get_pincfg(codec
, pin
);
3865 if (get_defcfg_device(defcfg
) == AC_JACK_SPEAKER
) {
3866 unsigned int wcaps
= get_wcaps(codec
, pin
);
3867 wcaps
&= (AC_WCAP_STEREO
| AC_WCAP_OUT_AMP
);
3868 if (wcaps
== AC_WCAP_OUT_AMP
)
3869 /* found a mono speaker with an amp,
3877 err
= create_controls(codec
, "LFE", lfe_pin
, 1);
3885 static int stac9200_parse_auto_config(struct hda_codec
*codec
)
3887 struct sigmatel_spec
*spec
= codec
->spec
;
3890 if ((err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
)) < 0)
3893 if ((err
= stac92xx_auto_create_analog_input_ctls(codec
, &spec
->autocfg
)) < 0)
3896 if ((err
= stac9200_auto_create_hp_ctls(codec
, &spec
->autocfg
)) < 0)
3899 if ((err
= stac9200_auto_create_lfe_ctls(codec
, &spec
->autocfg
)) < 0)
3902 if (spec
->num_muxes
> 0) {
3903 err
= stac92xx_auto_create_mux_input_ctls(codec
);
3908 err
= stac92xx_add_input_source(spec
);
3912 if (spec
->autocfg
.dig_outs
)
3913 spec
->multiout
.dig_out_nid
= 0x05;
3914 if (spec
->autocfg
.dig_in_pin
)
3915 spec
->dig_in_nid
= 0x04;
3917 if (spec
->kctls
.list
)
3918 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
3920 spec
->input_mux
= &spec
->private_imux
;
3921 spec
->dinput_mux
= &spec
->private_dimux
;
3927 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3928 * funky external mute control using GPIO pins.
3931 static void stac_gpio_set(struct hda_codec
*codec
, unsigned int mask
,
3932 unsigned int dir_mask
, unsigned int data
)
3934 unsigned int gpiostate
, gpiomask
, gpiodir
;
3936 gpiostate
= snd_hda_codec_read(codec
, codec
->afg
, 0,
3937 AC_VERB_GET_GPIO_DATA
, 0);
3938 gpiostate
= (gpiostate
& ~dir_mask
) | (data
& dir_mask
);
3940 gpiomask
= snd_hda_codec_read(codec
, codec
->afg
, 0,
3941 AC_VERB_GET_GPIO_MASK
, 0);
3944 gpiodir
= snd_hda_codec_read(codec
, codec
->afg
, 0,
3945 AC_VERB_GET_GPIO_DIRECTION
, 0);
3946 gpiodir
|= dir_mask
;
3948 /* Configure GPIOx as CMOS */
3949 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7e7, 0);
3951 snd_hda_codec_write(codec
, codec
->afg
, 0,
3952 AC_VERB_SET_GPIO_MASK
, gpiomask
);
3953 snd_hda_codec_read(codec
, codec
->afg
, 0,
3954 AC_VERB_SET_GPIO_DIRECTION
, gpiodir
); /* sync */
3958 snd_hda_codec_read(codec
, codec
->afg
, 0,
3959 AC_VERB_SET_GPIO_DATA
, gpiostate
); /* sync */
3962 #ifdef CONFIG_SND_JACK
3963 static void stac92xx_free_jack_priv(struct snd_jack
*jack
)
3965 struct sigmatel_jack
*jacks
= jack
->private_data
;
3971 static int stac92xx_add_jack(struct hda_codec
*codec
,
3972 hda_nid_t nid
, int type
)
3974 #ifdef CONFIG_SND_JACK
3975 struct sigmatel_spec
*spec
= codec
->spec
;
3976 struct sigmatel_jack
*jack
;
3977 int def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
3978 int connectivity
= get_defcfg_connect(def_conf
);
3982 if (connectivity
&& connectivity
!= AC_JACK_PORT_FIXED
)
3985 snd_array_init(&spec
->jacks
, sizeof(*jack
), 32);
3986 jack
= snd_array_new(&spec
->jacks
);
3992 sprintf(name
, "%s at %s %s Jack",
3993 snd_hda_get_jack_type(def_conf
),
3994 snd_hda_get_jack_connectivity(def_conf
),
3995 snd_hda_get_jack_location(def_conf
));
3997 err
= snd_jack_new(codec
->bus
->card
, name
, type
, &jack
->jack
);
4002 jack
->jack
->private_data
= jack
;
4003 jack
->jack
->private_free
= stac92xx_free_jack_priv
;
4008 static int stac_add_event(struct sigmatel_spec
*spec
, hda_nid_t nid
,
4009 unsigned char type
, int data
)
4011 struct sigmatel_event
*event
;
4013 snd_array_init(&spec
->events
, sizeof(*event
), 32);
4014 event
= snd_array_new(&spec
->events
);
4019 event
->tag
= spec
->events
.used
;
4025 static struct sigmatel_event
*stac_get_event(struct hda_codec
*codec
,
4026 hda_nid_t nid
, unsigned char type
)
4028 struct sigmatel_spec
*spec
= codec
->spec
;
4029 struct sigmatel_event
*event
= spec
->events
.list
;
4032 for (i
= 0; i
< spec
->events
.used
; i
++, event
++) {
4033 if (event
->nid
== nid
&& event
->type
== type
)
4039 static struct sigmatel_event
*stac_get_event_from_tag(struct hda_codec
*codec
,
4042 struct sigmatel_spec
*spec
= codec
->spec
;
4043 struct sigmatel_event
*event
= spec
->events
.list
;
4046 for (i
= 0; i
< spec
->events
.used
; i
++, event
++) {
4047 if (event
->tag
== tag
)
4053 static void enable_pin_detect(struct hda_codec
*codec
, hda_nid_t nid
,
4056 struct sigmatel_event
*event
;
4059 if (!(get_wcaps(codec
, nid
) & AC_WCAP_UNSOL_CAP
))
4061 event
= stac_get_event(codec
, nid
, type
);
4065 tag
= stac_add_event(codec
->spec
, nid
, type
, 0);
4068 snd_hda_codec_write_cache(codec
, nid
, 0,
4069 AC_VERB_SET_UNSOLICITED_ENABLE
,
4073 static int is_nid_hp_pin(struct auto_pin_cfg
*cfg
, hda_nid_t nid
)
4076 for (i
= 0; i
< cfg
->hp_outs
; i
++)
4077 if (cfg
->hp_pins
[i
] == nid
)
4078 return 1; /* nid is a HP-Out */
4080 return 0; /* nid is not a HP-Out */
4083 static void stac92xx_power_down(struct hda_codec
*codec
)
4085 struct sigmatel_spec
*spec
= codec
->spec
;
4087 /* power down inactive DACs */
4089 for (dac
= spec
->dac_list
; *dac
; dac
++)
4090 if (!check_all_dac_nids(spec
, *dac
))
4091 snd_hda_codec_write(codec
, *dac
, 0,
4092 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
4095 static void stac_toggle_power_map(struct hda_codec
*codec
, hda_nid_t nid
,
4098 /* override some hints from the hwdep entry */
4099 static void stac_store_hints(struct hda_codec
*codec
)
4101 struct sigmatel_spec
*spec
= codec
->spec
;
4105 val
= snd_hda_get_bool_hint(codec
, "hp_detect");
4107 spec
->hp_detect
= val
;
4108 p
= snd_hda_get_hint(codec
, "gpio_mask");
4110 spec
->gpio_mask
= simple_strtoul(p
, NULL
, 0);
4111 spec
->eapd_mask
= spec
->gpio_dir
= spec
->gpio_data
=
4114 p
= snd_hda_get_hint(codec
, "gpio_dir");
4116 spec
->gpio_dir
= simple_strtoul(p
, NULL
, 0) & spec
->gpio_mask
;
4117 p
= snd_hda_get_hint(codec
, "gpio_data");
4119 spec
->gpio_data
= simple_strtoul(p
, NULL
, 0) & spec
->gpio_mask
;
4120 p
= snd_hda_get_hint(codec
, "eapd_mask");
4122 spec
->eapd_mask
= simple_strtoul(p
, NULL
, 0) & spec
->gpio_mask
;
4123 val
= snd_hda_get_bool_hint(codec
, "eapd_switch");
4125 spec
->eapd_switch
= val
;
4128 static int stac92xx_init(struct hda_codec
*codec
)
4130 struct sigmatel_spec
*spec
= codec
->spec
;
4131 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4135 snd_hda_sequence_write(codec
, spec
->init
);
4137 /* power down adcs initially */
4138 if (spec
->powerdown_adcs
)
4139 for (i
= 0; i
< spec
->num_adcs
; i
++)
4140 snd_hda_codec_write(codec
,
4141 spec
->adc_nids
[i
], 0,
4142 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
4144 /* override some hints */
4145 stac_store_hints(codec
);
4148 gpio
= spec
->gpio_data
;
4149 /* turn on EAPD statically when spec->eapd_switch isn't set.
4150 * otherwise, unsol event will turn it on/off dynamically
4152 if (!spec
->eapd_switch
)
4153 gpio
|= spec
->eapd_mask
;
4154 stac_gpio_set(codec
, spec
->gpio_mask
, spec
->gpio_dir
, gpio
);
4157 if (spec
->hp_detect
) {
4158 /* Enable unsolicited responses on the HP widget */
4159 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
4160 hda_nid_t nid
= cfg
->hp_pins
[i
];
4161 enable_pin_detect(codec
, nid
, STAC_HP_EVENT
);
4163 /* force to enable the first line-out; the others are set up
4166 stac92xx_auto_set_pinctl(codec
, spec
->autocfg
.line_out_pins
[0],
4168 /* fake event to set up pins */
4169 stac_issue_unsol_event(codec
, spec
->autocfg
.hp_pins
[0],
4172 stac92xx_auto_init_multi_out(codec
);
4173 stac92xx_auto_init_hp_out(codec
);
4174 for (i
= 0; i
< cfg
->hp_outs
; i
++)
4175 stac_toggle_power_map(codec
, cfg
->hp_pins
[i
], 1);
4177 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
4178 hda_nid_t nid
= cfg
->input_pins
[i
];
4180 unsigned int pinctl
, conf
;
4181 if (i
== AUTO_PIN_MIC
|| i
== AUTO_PIN_FRONT_MIC
) {
4182 /* for mic pins, force to initialize */
4183 pinctl
= stac92xx_get_vref(codec
, nid
);
4184 pinctl
|= AC_PINCTL_IN_EN
;
4185 stac92xx_auto_set_pinctl(codec
, nid
, pinctl
);
4187 pinctl
= snd_hda_codec_read(codec
, nid
, 0,
4188 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
4189 /* if PINCTL already set then skip */
4190 /* Also, if both INPUT and OUTPUT are set,
4191 * it must be a BIOS bug; need to override, too
4193 if (!(pinctl
& AC_PINCTL_IN_EN
) ||
4194 (pinctl
& AC_PINCTL_OUT_EN
)) {
4195 pinctl
&= ~AC_PINCTL_OUT_EN
;
4196 pinctl
|= AC_PINCTL_IN_EN
;
4197 stac92xx_auto_set_pinctl(codec
, nid
,
4201 conf
= snd_hda_codec_get_pincfg(codec
, nid
);
4202 if (get_defcfg_connect(conf
) != AC_JACK_PORT_FIXED
) {
4203 enable_pin_detect(codec
, nid
,
4205 stac_issue_unsol_event(codec
, nid
,
4210 for (i
= 0; i
< spec
->num_dmics
; i
++)
4211 stac92xx_auto_set_pinctl(codec
, spec
->dmic_nids
[i
],
4213 if (cfg
->dig_out_pins
[0])
4214 stac92xx_auto_set_pinctl(codec
, cfg
->dig_out_pins
[0],
4216 if (cfg
->dig_in_pin
)
4217 stac92xx_auto_set_pinctl(codec
, cfg
->dig_in_pin
,
4219 for (i
= 0; i
< spec
->num_pwrs
; i
++) {
4220 hda_nid_t nid
= spec
->pwr_nids
[i
];
4221 int pinctl
, def_conf
;
4223 /* power on when no jack detection is available */
4224 if (!spec
->hp_detect
) {
4225 stac_toggle_power_map(codec
, nid
, 1);
4229 if (is_nid_hp_pin(cfg
, nid
))
4230 continue; /* already has an unsol event */
4232 pinctl
= snd_hda_codec_read(codec
, nid
, 0,
4233 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
4234 /* outputs are only ports capable of power management
4235 * any attempts on powering down a input port cause the
4236 * referenced VREF to act quirky.
4238 if (pinctl
& AC_PINCTL_IN_EN
) {
4239 stac_toggle_power_map(codec
, nid
, 1);
4242 def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
4243 def_conf
= get_defcfg_connect(def_conf
);
4244 /* skip any ports that don't have jacks since presence
4245 * detection is useless */
4246 if (def_conf
!= AC_JACK_PORT_COMPLEX
) {
4247 if (def_conf
!= AC_JACK_PORT_NONE
)
4248 stac_toggle_power_map(codec
, nid
, 1);
4251 if (!stac_get_event(codec
, nid
, STAC_INSERT_EVENT
)) {
4252 enable_pin_detect(codec
, nid
, STAC_PWR_EVENT
);
4253 stac_issue_unsol_event(codec
, nid
, STAC_PWR_EVENT
);
4257 stac92xx_power_down(codec
);
4261 static void stac92xx_free_jacks(struct hda_codec
*codec
)
4263 #ifdef CONFIG_SND_JACK
4264 /* free jack instances manually when clearing/reconfiguring */
4265 struct sigmatel_spec
*spec
= codec
->spec
;
4266 if (!codec
->bus
->shutdown
&& spec
->jacks
.list
) {
4267 struct sigmatel_jack
*jacks
= spec
->jacks
.list
;
4269 for (i
= 0; i
< spec
->jacks
.used
; i
++, jacks
++) {
4271 snd_device_free(codec
->bus
->card
, jacks
->jack
);
4274 snd_array_free(&spec
->jacks
);
4278 static void stac92xx_free_kctls(struct hda_codec
*codec
)
4280 struct sigmatel_spec
*spec
= codec
->spec
;
4282 if (spec
->kctls
.list
) {
4283 struct snd_kcontrol_new
*kctl
= spec
->kctls
.list
;
4285 for (i
= 0; i
< spec
->kctls
.used
; i
++)
4286 kfree(kctl
[i
].name
);
4288 snd_array_free(&spec
->kctls
);
4291 static void stac92xx_free(struct hda_codec
*codec
)
4293 struct sigmatel_spec
*spec
= codec
->spec
;
4298 stac92xx_free_jacks(codec
);
4299 snd_array_free(&spec
->events
);
4302 snd_hda_detach_beep_device(codec
);
4305 static void stac92xx_set_pinctl(struct hda_codec
*codec
, hda_nid_t nid
,
4308 unsigned int old_ctl
, pin_ctl
;
4310 pin_ctl
= snd_hda_codec_read(codec
, nid
,
4311 0, AC_VERB_GET_PIN_WIDGET_CONTROL
, 0x00);
4313 if (pin_ctl
& AC_PINCTL_IN_EN
) {
4315 * we need to check the current set-up direction of
4316 * shared input pins since they can be switched via
4317 * "xxx as Output" mixer switch
4319 struct sigmatel_spec
*spec
= codec
->spec
;
4320 if (nid
== spec
->line_switch
|| nid
== spec
->mic_switch
)
4325 /* if setting pin direction bits, clear the current
4326 direction bits first */
4327 if (flag
& (AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
))
4328 pin_ctl
&= ~(AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
);
4331 if (old_ctl
!= pin_ctl
)
4332 snd_hda_codec_write_cache(codec
, nid
, 0,
4333 AC_VERB_SET_PIN_WIDGET_CONTROL
,
4337 static void stac92xx_reset_pinctl(struct hda_codec
*codec
, hda_nid_t nid
,
4340 unsigned int pin_ctl
= snd_hda_codec_read(codec
, nid
,
4341 0, AC_VERB_GET_PIN_WIDGET_CONTROL
, 0x00);
4343 snd_hda_codec_write_cache(codec
, nid
, 0,
4344 AC_VERB_SET_PIN_WIDGET_CONTROL
,
4348 static int get_pin_presence(struct hda_codec
*codec
, hda_nid_t nid
)
4352 if (snd_hda_codec_read(codec
, nid
, 0, AC_VERB_GET_PIN_SENSE
, 0x00)
4358 /* return non-zero if the hp-pin of the given array index isn't
4359 * a jack-detection target
4361 static int no_hp_sensing(struct sigmatel_spec
*spec
, int i
)
4363 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4365 /* ignore sensing of shared line and mic jacks */
4366 if (cfg
->hp_pins
[i
] == spec
->line_switch
)
4368 if (cfg
->hp_pins
[i
] == spec
->mic_switch
)
4370 /* ignore if the pin is set as line-out */
4371 if (cfg
->hp_pins
[i
] == spec
->hp_switch
)
4376 static void stac92xx_hp_detect(struct hda_codec
*codec
)
4378 struct sigmatel_spec
*spec
= codec
->spec
;
4379 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4383 if (spec
->gpio_mute
)
4384 presence
= !(snd_hda_codec_read(codec
, codec
->afg
, 0,
4385 AC_VERB_GET_GPIO_DATA
, 0) & spec
->gpio_mute
);
4387 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
4390 if (no_hp_sensing(spec
, i
))
4392 presence
= get_pin_presence(codec
, cfg
->hp_pins
[i
]);
4394 unsigned int pinctl
;
4395 pinctl
= snd_hda_codec_read(codec
, cfg
->hp_pins
[i
], 0,
4396 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
4397 if (pinctl
& AC_PINCTL_IN_EN
)
4398 presence
= 0; /* mic- or line-input */
4403 /* disable lineouts */
4404 if (spec
->hp_switch
)
4405 stac92xx_reset_pinctl(codec
, spec
->hp_switch
,
4407 for (i
= 0; i
< cfg
->line_outs
; i
++)
4408 stac92xx_reset_pinctl(codec
, cfg
->line_out_pins
[i
],
4410 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
4411 stac92xx_reset_pinctl(codec
, cfg
->speaker_pins
[i
],
4413 if (spec
->eapd_mask
&& spec
->eapd_switch
)
4414 stac_gpio_set(codec
, spec
->gpio_mask
,
4415 spec
->gpio_dir
, spec
->gpio_data
&
4418 /* enable lineouts */
4419 if (spec
->hp_switch
)
4420 stac92xx_set_pinctl(codec
, spec
->hp_switch
,
4422 for (i
= 0; i
< cfg
->line_outs
; i
++)
4423 stac92xx_set_pinctl(codec
, cfg
->line_out_pins
[i
],
4425 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
4426 stac92xx_set_pinctl(codec
, cfg
->speaker_pins
[i
],
4428 if (spec
->eapd_mask
&& spec
->eapd_switch
)
4429 stac_gpio_set(codec
, spec
->gpio_mask
,
4430 spec
->gpio_dir
, spec
->gpio_data
|
4433 /* toggle hp outs */
4434 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
4435 unsigned int val
= AC_PINCTL_OUT_EN
| AC_PINCTL_HP_EN
;
4436 if (no_hp_sensing(spec
, i
))
4439 stac92xx_set_pinctl(codec
, cfg
->hp_pins
[i
], val
);
4441 /* Resetting the pinctl like below may lead to (a sort of) regressions
4442 * on some devices since they use the HP pin actually for line/speaker
4443 * outs although the default pin config shows a different pin (that is
4444 * wrong and useless).
4446 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4447 * But, disabling the code below just works around it, and I'm too tired of
4448 * bug reports with such devices...
4451 stac92xx_reset_pinctl(codec
, cfg
->hp_pins
[i
], val
);
4456 static void stac_toggle_power_map(struct hda_codec
*codec
, hda_nid_t nid
,
4459 struct sigmatel_spec
*spec
= codec
->spec
;
4460 unsigned int idx
, val
;
4462 for (idx
= 0; idx
< spec
->num_pwrs
; idx
++) {
4463 if (spec
->pwr_nids
[idx
] == nid
)
4466 if (idx
>= spec
->num_pwrs
)
4469 /* several codecs have two power down bits */
4470 if (spec
->pwr_mapping
)
4471 idx
= spec
->pwr_mapping
[idx
];
4475 val
= snd_hda_codec_read(codec
, codec
->afg
, 0, 0x0fec, 0x0) & 0xff;
4481 /* power down unused output ports */
4482 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7ec, val
);
4485 static void stac92xx_pin_sense(struct hda_codec
*codec
, hda_nid_t nid
)
4487 stac_toggle_power_map(codec
, nid
, get_pin_presence(codec
, nid
));
4490 static void stac92xx_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
4492 struct sigmatel_spec
*spec
= codec
->spec
;
4493 struct sigmatel_jack
*jacks
= spec
->jacks
.list
;
4497 for (i
= 0; i
< spec
->jacks
.used
; i
++) {
4498 if (jacks
->nid
== nid
) {
4499 unsigned int pin_ctl
=
4500 snd_hda_codec_read(codec
, nid
,
4501 0, AC_VERB_GET_PIN_WIDGET_CONTROL
,
4503 int type
= jacks
->type
;
4504 if (type
== (SND_JACK_LINEOUT
4505 | SND_JACK_HEADPHONE
))
4506 type
= (pin_ctl
& AC_PINCTL_HP_EN
)
4507 ? SND_JACK_HEADPHONE
: SND_JACK_LINEOUT
;
4508 snd_jack_report(jacks
->jack
,
4509 get_pin_presence(codec
, nid
)
4517 static void stac_issue_unsol_event(struct hda_codec
*codec
, hda_nid_t nid
,
4520 struct sigmatel_event
*event
= stac_get_event(codec
, nid
, type
);
4523 codec
->patch_ops
.unsol_event(codec
, (unsigned)event
->tag
<< 26);
4526 static void stac92xx_unsol_event(struct hda_codec
*codec
, unsigned int res
)
4528 struct sigmatel_spec
*spec
= codec
->spec
;
4529 struct sigmatel_event
*event
;
4532 tag
= (res
>> 26) & 0x7f;
4533 event
= stac_get_event_from_tag(codec
, tag
);
4537 switch (event
->type
) {
4539 stac92xx_hp_detect(codec
);
4541 case STAC_INSERT_EVENT
:
4542 case STAC_PWR_EVENT
:
4543 if (spec
->num_pwrs
> 0)
4544 stac92xx_pin_sense(codec
, event
->nid
);
4545 stac92xx_report_jack(codec
, event
->nid
);
4547 switch (codec
->subsystem_id
) {
4549 if (event
->nid
== 0xb) {
4550 int pin
= AC_PINCTL_IN_EN
;
4552 if (get_pin_presence(codec
, 0xa)
4553 && get_pin_presence(codec
, 0xb))
4554 pin
|= AC_PINCTL_VREF_80
;
4555 if (!get_pin_presence(codec
, 0xb))
4556 pin
|= AC_PINCTL_VREF_80
;
4558 /* toggle VREF state based on mic + hp pin
4561 stac92xx_auto_set_pinctl(codec
, 0x0a, pin
);
4565 case STAC_VREF_EVENT
:
4566 data
= snd_hda_codec_read(codec
, codec
->afg
, 0,
4567 AC_VERB_GET_GPIO_DATA
, 0);
4568 /* toggle VREF state based on GPIOx status */
4569 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7e0,
4570 !!(data
& (1 << event
->data
)));
4575 #ifdef CONFIG_PROC_FS
4576 static void stac92hd_proc_hook(struct snd_info_buffer
*buffer
,
4577 struct hda_codec
*codec
, hda_nid_t nid
)
4579 if (nid
== codec
->afg
)
4580 snd_iprintf(buffer
, "Power-Map: 0x%02x\n",
4581 snd_hda_codec_read(codec
, nid
, 0, 0x0fec, 0x0));
4584 static void analog_loop_proc_hook(struct snd_info_buffer
*buffer
,
4585 struct hda_codec
*codec
,
4588 snd_iprintf(buffer
, "Analog Loopback: 0x%02x\n",
4589 snd_hda_codec_read(codec
, codec
->afg
, 0, verb
, 0));
4592 /* stac92hd71bxx, stac92hd73xx */
4593 static void stac92hd7x_proc_hook(struct snd_info_buffer
*buffer
,
4594 struct hda_codec
*codec
, hda_nid_t nid
)
4596 stac92hd_proc_hook(buffer
, codec
, nid
);
4597 if (nid
== codec
->afg
)
4598 analog_loop_proc_hook(buffer
, codec
, 0xfa0);
4601 static void stac9205_proc_hook(struct snd_info_buffer
*buffer
,
4602 struct hda_codec
*codec
, hda_nid_t nid
)
4604 if (nid
== codec
->afg
)
4605 analog_loop_proc_hook(buffer
, codec
, 0xfe0);
4608 static void stac927x_proc_hook(struct snd_info_buffer
*buffer
,
4609 struct hda_codec
*codec
, hda_nid_t nid
)
4611 if (nid
== codec
->afg
)
4612 analog_loop_proc_hook(buffer
, codec
, 0xfeb);
4615 #define stac92hd_proc_hook NULL
4616 #define stac92hd7x_proc_hook NULL
4617 #define stac9205_proc_hook NULL
4618 #define stac927x_proc_hook NULL
4621 #ifdef SND_HDA_NEEDS_RESUME
4622 static int stac92xx_resume(struct hda_codec
*codec
)
4624 struct sigmatel_spec
*spec
= codec
->spec
;
4626 stac92xx_init(codec
);
4627 snd_hda_codec_resume_amp(codec
);
4628 snd_hda_codec_resume_cache(codec
);
4629 /* fake event to set up pins again to override cached values */
4630 if (spec
->hp_detect
)
4631 stac_issue_unsol_event(codec
, spec
->autocfg
.hp_pins
[0],
4637 * using power check for controlling mute led of HP notebooks
4638 * check for mute state only on Speakers (nid = 0x10)
4640 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4641 * the LED is NOT working properly !
4643 * Changed name to reflect that it now works for any designated
4644 * model, not just HP HDX.
4647 #ifdef CONFIG_SND_HDA_POWER_SAVE
4648 static int stac92xx_hp_check_power_status(struct hda_codec
*codec
,
4651 struct sigmatel_spec
*spec
= codec
->spec
;
4652 unsigned int gpio_bit
= 0; /* gets rid of compiler warning */
4654 switch (spec
->board_config
) {
4655 case STAC_HP_DV4_1222NR
:
4663 if (snd_hda_codec_amp_read(codec
, nid
, 0, HDA_OUTPUT
, 0) &
4665 spec
->gpio_data
&= ~gpio_bit
; /* orange */
4667 spec
->gpio_data
|= gpio_bit
; /* white */
4669 stac_gpio_set(codec
, spec
->gpio_mask
,
4678 static int stac92xx_suspend(struct hda_codec
*codec
, pm_message_t state
)
4680 struct sigmatel_spec
*spec
= codec
->spec
;
4681 if (spec
->eapd_mask
)
4682 stac_gpio_set(codec
, spec
->gpio_mask
,
4683 spec
->gpio_dir
, spec
->gpio_data
&
4689 static struct hda_codec_ops stac92xx_patch_ops
= {
4690 .build_controls
= stac92xx_build_controls
,
4691 .build_pcms
= stac92xx_build_pcms
,
4692 .init
= stac92xx_init
,
4693 .free
= stac92xx_free
,
4694 .unsol_event
= stac92xx_unsol_event
,
4695 #ifdef SND_HDA_NEEDS_RESUME
4696 .suspend
= stac92xx_suspend
,
4697 .resume
= stac92xx_resume
,
4701 static int patch_stac9200(struct hda_codec
*codec
)
4703 struct sigmatel_spec
*spec
;
4706 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4711 spec
->num_pins
= ARRAY_SIZE(stac9200_pin_nids
);
4712 spec
->pin_nids
= stac9200_pin_nids
;
4713 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_9200_MODELS
,
4716 if (spec
->board_config
< 0)
4717 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4719 stac92xx_set_config_regs(codec
,
4720 stac9200_brd_tbl
[spec
->board_config
]);
4722 spec
->multiout
.max_channels
= 2;
4723 spec
->multiout
.num_dacs
= 1;
4724 spec
->multiout
.dac_nids
= stac9200_dac_nids
;
4725 spec
->adc_nids
= stac9200_adc_nids
;
4726 spec
->mux_nids
= stac9200_mux_nids
;
4727 spec
->num_muxes
= 1;
4728 spec
->num_dmics
= 0;
4732 if (spec
->board_config
== STAC_9200_M4
||
4733 spec
->board_config
== STAC_9200_M4_2
||
4734 spec
->board_config
== STAC_9200_OQO
)
4735 spec
->init
= stac9200_eapd_init
;
4737 spec
->init
= stac9200_core_init
;
4738 spec
->mixer
= stac9200_mixer
;
4740 if (spec
->board_config
== STAC_9200_PANASONIC
) {
4741 spec
->gpio_mask
= spec
->gpio_dir
= 0x09;
4742 spec
->gpio_data
= 0x00;
4745 err
= stac9200_parse_auto_config(codec
);
4747 stac92xx_free(codec
);
4751 /* CF-74 has no headphone detection, and the driver should *NOT*
4752 * do detection and HP/speaker toggle because the hardware does it.
4754 if (spec
->board_config
== STAC_9200_PANASONIC
)
4755 spec
->hp_detect
= 0;
4757 codec
->patch_ops
= stac92xx_patch_ops
;
4762 static int patch_stac925x(struct hda_codec
*codec
)
4764 struct sigmatel_spec
*spec
;
4767 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4772 spec
->num_pins
= ARRAY_SIZE(stac925x_pin_nids
);
4773 spec
->pin_nids
= stac925x_pin_nids
;
4775 /* Check first for codec ID */
4776 spec
->board_config
= snd_hda_check_board_codec_sid_config(codec
,
4779 stac925x_codec_id_cfg_tbl
);
4781 /* Now checks for PCI ID, if codec ID is not found */
4782 if (spec
->board_config
< 0)
4783 spec
->board_config
= snd_hda_check_board_config(codec
,
4788 if (spec
->board_config
< 0)
4789 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC925x,"
4790 "using BIOS defaults\n");
4792 stac92xx_set_config_regs(codec
,
4793 stac925x_brd_tbl
[spec
->board_config
]);
4795 spec
->multiout
.max_channels
= 2;
4796 spec
->multiout
.num_dacs
= 1;
4797 spec
->multiout
.dac_nids
= stac925x_dac_nids
;
4798 spec
->adc_nids
= stac925x_adc_nids
;
4799 spec
->mux_nids
= stac925x_mux_nids
;
4800 spec
->num_muxes
= 1;
4803 switch (codec
->vendor_id
) {
4804 case 0x83847632: /* STAC9202 */
4805 case 0x83847633: /* STAC9202D */
4806 case 0x83847636: /* STAC9251 */
4807 case 0x83847637: /* STAC9251D */
4808 spec
->num_dmics
= STAC925X_NUM_DMICS
;
4809 spec
->dmic_nids
= stac925x_dmic_nids
;
4810 spec
->num_dmuxes
= ARRAY_SIZE(stac925x_dmux_nids
);
4811 spec
->dmux_nids
= stac925x_dmux_nids
;
4814 spec
->num_dmics
= 0;
4818 spec
->init
= stac925x_core_init
;
4819 spec
->mixer
= stac925x_mixer
;
4821 err
= stac92xx_parse_auto_config(codec
, 0x8, 0x7);
4823 if (spec
->board_config
< 0) {
4824 printk(KERN_WARNING
"hda_codec: No auto-config is "
4825 "available, default to model=ref\n");
4826 spec
->board_config
= STAC_925x_REF
;
4832 stac92xx_free(codec
);
4836 codec
->patch_ops
= stac92xx_patch_ops
;
4841 static struct hda_input_mux stac92hd73xx_dmux
= {
4844 { "Analog Inputs", 0x0b },
4845 { "Digital Mic 1", 0x09 },
4846 { "Digital Mic 2", 0x0a },
4851 static int patch_stac92hd73xx(struct hda_codec
*codec
)
4853 struct sigmatel_spec
*spec
;
4854 hda_nid_t conn
[STAC92HD73_DAC_COUNT
+ 2];
4858 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4863 codec
->slave_dig_outs
= stac92hd73xx_slave_dig_outs
;
4864 spec
->num_pins
= ARRAY_SIZE(stac92hd73xx_pin_nids
);
4865 spec
->pin_nids
= stac92hd73xx_pin_nids
;
4866 spec
->board_config
= snd_hda_check_board_config(codec
,
4867 STAC_92HD73XX_MODELS
,
4868 stac92hd73xx_models
,
4869 stac92hd73xx_cfg_tbl
);
4871 if (spec
->board_config
< 0)
4872 snd_printdd(KERN_INFO
"hda_codec: Unknown model for"
4873 " STAC92HD73XX, using BIOS defaults\n");
4875 stac92xx_set_config_regs(codec
,
4876 stac92hd73xx_brd_tbl
[spec
->board_config
]);
4878 num_dacs
= snd_hda_get_connections(codec
, 0x0a,
4879 conn
, STAC92HD73_DAC_COUNT
+ 2) - 1;
4881 if (num_dacs
< 3 || num_dacs
> 5) {
4882 printk(KERN_WARNING
"hda_codec: Could not determine "
4883 "number of channels defaulting to DAC count\n");
4884 num_dacs
= STAC92HD73_DAC_COUNT
;
4887 case 0x3: /* 6 Channel */
4888 spec
->mixer
= stac92hd73xx_6ch_mixer
;
4889 spec
->init
= stac92hd73xx_6ch_core_init
;
4890 spec
->aloopback_ctl
= stac92hd73xx_6ch_loopback
;
4892 case 0x4: /* 8 Channel */
4893 spec
->mixer
= stac92hd73xx_8ch_mixer
;
4894 spec
->init
= stac92hd73xx_8ch_core_init
;
4895 spec
->aloopback_ctl
= stac92hd73xx_8ch_loopback
;
4897 case 0x5: /* 10 Channel */
4898 spec
->mixer
= stac92hd73xx_10ch_mixer
;
4899 spec
->init
= stac92hd73xx_10ch_core_init
;
4900 spec
->aloopback_ctl
= stac92hd73xx_10ch_loopback
;
4903 spec
->multiout
.dac_nids
= spec
->dac_nids
;
4905 spec
->aloopback_mask
= 0x01;
4906 spec
->aloopback_shift
= 8;
4908 spec
->digbeep_nid
= 0x1c;
4909 spec
->mux_nids
= stac92hd73xx_mux_nids
;
4910 spec
->adc_nids
= stac92hd73xx_adc_nids
;
4911 spec
->dmic_nids
= stac92hd73xx_dmic_nids
;
4912 spec
->dmux_nids
= stac92hd73xx_dmux_nids
;
4913 spec
->smux_nids
= stac92hd73xx_smux_nids
;
4914 spec
->amp_nids
= stac92hd73xx_amp_nids
;
4915 spec
->num_amps
= ARRAY_SIZE(stac92hd73xx_amp_nids
);
4917 spec
->num_muxes
= ARRAY_SIZE(stac92hd73xx_mux_nids
);
4918 spec
->num_adcs
= ARRAY_SIZE(stac92hd73xx_adc_nids
);
4919 spec
->num_dmuxes
= ARRAY_SIZE(stac92hd73xx_dmux_nids
);
4920 memcpy(&spec
->private_dimux
, &stac92hd73xx_dmux
,
4921 sizeof(stac92hd73xx_dmux
));
4923 switch (spec
->board_config
) {
4925 spec
->init
= dell_eq_core_init
;
4927 case STAC_DELL_M6_AMIC
:
4928 case STAC_DELL_M6_DMIC
:
4929 case STAC_DELL_M6_BOTH
:
4930 spec
->num_smuxes
= 0;
4931 spec
->mixer
= &stac92hd73xx_6ch_mixer
[DELL_M6_MIXER
];
4932 spec
->amp_nids
= &stac92hd73xx_amp_nids
[DELL_M6_AMP
];
4933 spec
->eapd_switch
= 0;
4936 if (spec
->board_config
!= STAC_DELL_EQ
)
4937 spec
->init
= dell_m6_core_init
;
4938 switch (spec
->board_config
) {
4939 case STAC_DELL_M6_AMIC
: /* Analog Mics */
4940 snd_hda_codec_set_pincfg(codec
, 0x0b, 0x90A70170);
4941 spec
->num_dmics
= 0;
4942 spec
->private_dimux
.num_items
= 1;
4944 case STAC_DELL_M6_DMIC
: /* Digital Mics */
4945 snd_hda_codec_set_pincfg(codec
, 0x13, 0x90A60160);
4946 spec
->num_dmics
= 1;
4947 spec
->private_dimux
.num_items
= 2;
4949 case STAC_DELL_M6_BOTH
: /* Both */
4950 snd_hda_codec_set_pincfg(codec
, 0x0b, 0x90A70170);
4951 snd_hda_codec_set_pincfg(codec
, 0x13, 0x90A60160);
4952 spec
->num_dmics
= 1;
4953 spec
->private_dimux
.num_items
= 2;
4958 spec
->num_dmics
= STAC92HD73XX_NUM_DMICS
;
4959 spec
->num_smuxes
= ARRAY_SIZE(stac92hd73xx_smux_nids
);
4960 spec
->eapd_switch
= 1;
4962 if (spec
->board_config
> STAC_92HD73XX_REF
) {
4963 /* GPIO0 High = Enable EAPD */
4964 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x1;
4965 spec
->gpio_data
= 0x01;
4967 spec
->dinput_mux
= &spec
->private_dimux
;
4969 spec
->num_pwrs
= ARRAY_SIZE(stac92hd73xx_pwr_nids
);
4970 spec
->pwr_nids
= stac92hd73xx_pwr_nids
;
4972 err
= stac92xx_parse_auto_config(codec
, 0x25, 0x27);
4975 if (spec
->board_config
< 0) {
4976 printk(KERN_WARNING
"hda_codec: No auto-config is "
4977 "available, default to model=ref\n");
4978 spec
->board_config
= STAC_92HD73XX_REF
;
4985 stac92xx_free(codec
);
4989 if (spec
->board_config
== STAC_92HD73XX_NO_JD
)
4990 spec
->hp_detect
= 0;
4992 codec
->patch_ops
= stac92xx_patch_ops
;
4994 codec
->proc_widget_hook
= stac92hd7x_proc_hook
;
4999 static struct hda_input_mux stac92hd83xxx_dmux
= {
5002 { "Analog Inputs", 0x03 },
5003 { "Digital Mic 1", 0x04 },
5004 { "Digital Mic 2", 0x05 },
5008 static int patch_stac92hd83xxx(struct hda_codec
*codec
)
5010 struct sigmatel_spec
*spec
;
5011 hda_nid_t conn
[STAC92HD83_DAC_COUNT
+ 1];
5016 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5021 codec
->slave_dig_outs
= stac92hd83xxx_slave_dig_outs
;
5022 spec
->mono_nid
= 0x19;
5023 spec
->digbeep_nid
= 0x21;
5024 spec
->dmic_nids
= stac92hd83xxx_dmic_nids
;
5025 spec
->dmux_nids
= stac92hd83xxx_dmux_nids
;
5026 spec
->adc_nids
= stac92hd83xxx_adc_nids
;
5027 spec
->pwr_nids
= stac92hd83xxx_pwr_nids
;
5028 spec
->amp_nids
= stac92hd83xxx_amp_nids
;
5029 spec
->pwr_mapping
= stac92hd83xxx_pwr_mapping
;
5030 spec
->num_pwrs
= ARRAY_SIZE(stac92hd83xxx_pwr_nids
);
5031 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5033 spec
->init
= stac92hd83xxx_core_init
;
5034 spec
->mixer
= stac92hd83xxx_mixer
;
5035 spec
->num_pins
= ARRAY_SIZE(stac92hd83xxx_pin_nids
);
5036 spec
->num_dmuxes
= ARRAY_SIZE(stac92hd83xxx_dmux_nids
);
5037 spec
->num_adcs
= ARRAY_SIZE(stac92hd83xxx_adc_nids
);
5038 spec
->num_amps
= ARRAY_SIZE(stac92hd83xxx_amp_nids
);
5039 spec
->num_dmics
= STAC92HD83XXX_NUM_DMICS
;
5040 spec
->dinput_mux
= &stac92hd83xxx_dmux
;
5041 spec
->pin_nids
= stac92hd83xxx_pin_nids
;
5042 spec
->board_config
= snd_hda_check_board_config(codec
,
5043 STAC_92HD83XXX_MODELS
,
5044 stac92hd83xxx_models
,
5045 stac92hd83xxx_cfg_tbl
);
5047 if (spec
->board_config
< 0)
5048 snd_printdd(KERN_INFO
"hda_codec: Unknown model for"
5049 " STAC92HD83XXX, using BIOS defaults\n");
5051 stac92xx_set_config_regs(codec
,
5052 stac92hd83xxx_brd_tbl
[spec
->board_config
]);
5054 switch (codec
->vendor_id
) {
5058 if (spec
->board_config
== STAC_92HD83XXX_PWR_REF
)
5064 err
= stac92xx_parse_auto_config(codec
, 0x1d, 0);
5066 if (spec
->board_config
< 0) {
5067 printk(KERN_WARNING
"hda_codec: No auto-config is "
5068 "available, default to model=ref\n");
5069 spec
->board_config
= STAC_92HD83XXX_REF
;
5076 stac92xx_free(codec
);
5080 switch (spec
->board_config
) {
5089 num_dacs
= snd_hda_get_connections(codec
, nid
,
5090 conn
, STAC92HD83_DAC_COUNT
+ 1) - 1;
5092 /* set port X to select the last DAC
5094 snd_hda_codec_write_cache(codec
, nid
, 0,
5095 AC_VERB_SET_CONNECT_SEL
, num_dacs
);
5097 codec
->patch_ops
= stac92xx_patch_ops
;
5099 codec
->proc_widget_hook
= stac92hd_proc_hook
;
5104 static struct hda_input_mux stac92hd71bxx_dmux_nomixer
= {
5107 { "Analog Inputs", 0x00 },
5108 { "Digital Mic 1", 0x02 },
5109 { "Digital Mic 2", 0x03 },
5113 static struct hda_input_mux stac92hd71bxx_dmux_amixer
= {
5116 { "Analog Inputs", 0x00 },
5118 { "Digital Mic 1", 0x02 },
5119 { "Digital Mic 2", 0x03 },
5123 /* get the pin connection (fixed, none, etc) */
5124 static unsigned int stac_get_defcfg_connect(struct hda_codec
*codec
, int idx
)
5126 struct sigmatel_spec
*spec
= codec
->spec
;
5129 cfg
= snd_hda_codec_get_pincfg(codec
, spec
->pin_nids
[idx
]);
5130 return get_defcfg_connect(cfg
);
5133 static int stac92hd71bxx_connected_ports(struct hda_codec
*codec
,
5134 hda_nid_t
*nids
, int num_nids
)
5136 struct sigmatel_spec
*spec
= codec
->spec
;
5138 unsigned int def_conf
;
5140 for (num
= 0; num
< num_nids
; num
++) {
5141 for (idx
= 0; idx
< spec
->num_pins
; idx
++)
5142 if (spec
->pin_nids
[idx
] == nids
[num
])
5144 if (idx
>= spec
->num_pins
)
5146 def_conf
= stac_get_defcfg_connect(codec
, idx
);
5147 if (def_conf
== AC_JACK_PORT_NONE
)
5153 static int stac92hd71bxx_connected_smuxes(struct hda_codec
*codec
,
5156 struct sigmatel_spec
*spec
= codec
->spec
;
5159 for (idx
= 0; idx
< spec
->num_pins
; idx
++)
5160 if (spec
->pin_nids
[idx
] == dig0pin
)
5162 if ((idx
+ 2) >= spec
->num_pins
)
5166 if (stac_get_defcfg_connect(codec
, idx
+ 1) != AC_JACK_PORT_NONE
)
5169 /* dig0pin + dig2pin case */
5170 if (stac_get_defcfg_connect(codec
, idx
+ 2) != AC_JACK_PORT_NONE
)
5172 if (stac_get_defcfg_connect(codec
, idx
) != AC_JACK_PORT_NONE
)
5178 static int patch_stac92hd71bxx(struct hda_codec
*codec
)
5180 struct sigmatel_spec
*spec
;
5181 struct hda_verb
*unmute_init
= stac92hd71bxx_unmute_core_init
;
5183 unsigned int ndmic_nids
= 0;
5185 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5190 codec
->patch_ops
= stac92xx_patch_ops
;
5191 spec
->num_pins
= STAC92HD71BXX_NUM_PINS
;
5192 switch (codec
->vendor_id
) {
5195 spec
->pin_nids
= stac92hd71bxx_pin_nids_4port
;
5199 /* On 92HD75Bx 0x27 isn't a pin nid */
5203 spec
->pin_nids
= stac92hd71bxx_pin_nids_6port
;
5205 spec
->num_pwrs
= ARRAY_SIZE(stac92hd71bxx_pwr_nids
);
5206 spec
->board_config
= snd_hda_check_board_config(codec
,
5207 STAC_92HD71BXX_MODELS
,
5208 stac92hd71bxx_models
,
5209 stac92hd71bxx_cfg_tbl
);
5211 if (spec
->board_config
< 0)
5212 snd_printdd(KERN_INFO
"hda_codec: Unknown model for"
5213 " STAC92HD71BXX, using BIOS defaults\n");
5215 stac92xx_set_config_regs(codec
,
5216 stac92hd71bxx_brd_tbl
[spec
->board_config
]);
5218 if (spec
->board_config
> STAC_92HD71BXX_REF
) {
5220 spec
->gpio_mask
= 0x01;
5221 spec
->gpio_dir
= 0x01;
5222 spec
->gpio_data
= 0x01;
5225 spec
->dmic_nids
= stac92hd71bxx_dmic_nids
;
5226 spec
->dmux_nids
= stac92hd71bxx_dmux_nids
;
5228 switch (codec
->vendor_id
) {
5229 case 0x111d76b6: /* 4 Port without Analog Mixer */
5233 case 0x111d76b4: /* 6 Port without Analog Mixer */
5235 memcpy(&spec
->private_dimux
, &stac92hd71bxx_dmux_nomixer
,
5236 sizeof(stac92hd71bxx_dmux_nomixer
));
5237 spec
->mixer
= stac92hd71bxx_mixer
;
5238 spec
->init
= stac92hd71bxx_core_init
;
5239 codec
->slave_dig_outs
= stac92hd71bxx_slave_dig_outs
;
5240 spec
->num_dmics
= stac92hd71bxx_connected_ports(codec
,
5241 stac92hd71bxx_dmic_nids
,
5242 STAC92HD71BXX_NUM_DMICS
);
5243 if (spec
->num_dmics
) {
5244 spec
->num_dmuxes
= ARRAY_SIZE(stac92hd71bxx_dmux_nids
);
5245 spec
->dinput_mux
= &spec
->private_dimux
;
5246 ndmic_nids
= ARRAY_SIZE(stac92hd71bxx_dmic_nids
) - 1;
5249 case 0x111d7608: /* 5 Port with Analog Mixer */
5250 memcpy(&spec
->private_dimux
, &stac92hd71bxx_dmux_amixer
,
5251 sizeof(stac92hd71bxx_dmux_amixer
));
5252 spec
->private_dimux
.num_items
--;
5253 switch (spec
->board_config
) {
5255 /* Enable VREF power saving on GPIO1 detect */
5256 err
= stac_add_event(spec
, codec
->afg
,
5257 STAC_VREF_EVENT
, 0x02);
5260 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
5261 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK
, 0x02);
5262 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
5263 AC_VERB_SET_UNSOLICITED_ENABLE
,
5265 spec
->gpio_mask
|= 0x02;
5268 if ((codec
->revision_id
& 0xf) == 0 ||
5269 (codec
->revision_id
& 0xf) == 1)
5270 spec
->stream_delay
= 40; /* 40 milliseconds */
5272 /* no output amps */
5274 spec
->mixer
= stac92hd71bxx_analog_mixer
;
5275 spec
->dinput_mux
= &spec
->private_dimux
;
5278 spec
->init
= &stac92hd71bxx_analog_core_init
[HD_DISABLE_PORTF
];
5280 snd_hda_codec_set_pincfg(codec
, 0x0f, 0x40f000f0);
5281 snd_hda_codec_set_pincfg(codec
, 0x19, 0x40f000f3);
5282 stac92hd71bxx_dmic_nids
[STAC92HD71BXX_NUM_DMICS
- 1] = 0;
5283 spec
->num_dmics
= stac92hd71bxx_connected_ports(codec
,
5284 stac92hd71bxx_dmic_nids
,
5285 STAC92HD71BXX_NUM_DMICS
- 1);
5286 spec
->num_dmuxes
= ARRAY_SIZE(stac92hd71bxx_dmux_nids
);
5287 ndmic_nids
= ARRAY_SIZE(stac92hd71bxx_dmic_nids
) - 2;
5289 case 0x111d7603: /* 6 Port with Analog Mixer */
5290 if ((codec
->revision_id
& 0xf) == 1)
5291 spec
->stream_delay
= 40; /* 40 milliseconds */
5293 /* no output amps */
5297 memcpy(&spec
->private_dimux
, &stac92hd71bxx_dmux_amixer
,
5298 sizeof(stac92hd71bxx_dmux_amixer
));
5299 spec
->dinput_mux
= &spec
->private_dimux
;
5300 spec
->mixer
= stac92hd71bxx_analog_mixer
;
5301 spec
->init
= stac92hd71bxx_analog_core_init
;
5302 codec
->slave_dig_outs
= stac92hd71bxx_slave_dig_outs
;
5303 spec
->num_dmics
= stac92hd71bxx_connected_ports(codec
,
5304 stac92hd71bxx_dmic_nids
,
5305 STAC92HD71BXX_NUM_DMICS
);
5306 spec
->num_dmuxes
= ARRAY_SIZE(stac92hd71bxx_dmux_nids
);
5307 ndmic_nids
= ARRAY_SIZE(stac92hd71bxx_dmic_nids
) - 1;
5310 if (get_wcaps(codec
, 0xa) & AC_WCAP_IN_AMP
)
5311 snd_hda_sequence_write_cache(codec
, unmute_init
);
5313 spec
->aloopback_ctl
= stac92hd71bxx_loopback
;
5314 spec
->aloopback_mask
= 0x50;
5315 spec
->aloopback_shift
= 0;
5317 spec
->powerdown_adcs
= 1;
5318 spec
->digbeep_nid
= 0x26;
5319 spec
->mux_nids
= stac92hd71bxx_mux_nids
;
5320 spec
->adc_nids
= stac92hd71bxx_adc_nids
;
5321 spec
->smux_nids
= stac92hd71bxx_smux_nids
;
5322 spec
->pwr_nids
= stac92hd71bxx_pwr_nids
;
5324 spec
->num_muxes
= ARRAY_SIZE(stac92hd71bxx_mux_nids
);
5325 spec
->num_adcs
= ARRAY_SIZE(stac92hd71bxx_adc_nids
);
5326 spec
->num_smuxes
= stac92hd71bxx_connected_smuxes(codec
, 0x1e);
5328 switch (spec
->board_config
) {
5330 /* enable internal microphone */
5331 snd_hda_codec_set_pincfg(codec
, 0x0e, 0x01813040);
5332 stac92xx_auto_set_pinctl(codec
, 0x0e,
5333 AC_PINCTL_IN_EN
| AC_PINCTL_VREF_80
);
5335 case STAC_DELL_M4_2
:
5336 spec
->num_dmics
= 0;
5337 spec
->num_smuxes
= 0;
5338 spec
->num_dmuxes
= 0;
5340 case STAC_DELL_M4_1
:
5341 case STAC_DELL_M4_3
:
5342 spec
->num_dmics
= 1;
5343 spec
->num_smuxes
= 0;
5344 spec
->num_dmuxes
= 1;
5346 case STAC_HP_DV4_1222NR
:
5347 spec
->num_dmics
= 1;
5348 /* I don't know if it needs 1 or 2 smuxes - will wait for
5349 * bug reports to fix if needed
5351 spec
->num_smuxes
= 1;
5352 spec
->num_dmuxes
= 1;
5353 #ifdef CONFIG_SND_HDA_POWER_SAVE
5354 /* This controls MUTE LED */
5355 spec
->gpio_mask
|= 0x01;
5356 spec
->gpio_dir
|= 0x01;
5357 spec
->gpio_data
|= 0x01;
5358 codec
->patch_ops
.check_power_status
=
5359 stac92xx_hp_check_power_status
;
5363 snd_hda_codec_set_pincfg(codec
, 0x0d, 0x90170010);
5364 stac92xx_auto_set_pinctl(codec
, 0x0d, AC_PINCTL_OUT_EN
);
5367 spec
->num_dmics
= 1;
5368 spec
->num_dmuxes
= 1;
5369 spec
->num_smuxes
= 1;
5371 * For controlling MUTE LED on HP HDX16/HDX18 notebooks,
5372 * the CONFIG_SND_HDA_POWER_SAVE is needed to be set.
5374 #ifdef CONFIG_SND_HDA_POWER_SAVE
5375 /* orange/white mute led on GPIO3, orange=0, white=1 */
5376 spec
->gpio_mask
|= 0x08;
5377 spec
->gpio_dir
|= 0x08;
5378 spec
->gpio_data
|= 0x08; /* set to white */
5380 /* register check_power_status callback. */
5381 codec
->patch_ops
.check_power_status
=
5382 stac92xx_hp_check_power_status
;
5387 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5388 if (spec
->dinput_mux
)
5389 spec
->private_dimux
.num_items
+= spec
->num_dmics
- ndmic_nids
;
5391 err
= stac92xx_parse_auto_config(codec
, 0x21, 0);
5393 if (spec
->board_config
< 0) {
5394 printk(KERN_WARNING
"hda_codec: No auto-config is "
5395 "available, default to model=ref\n");
5396 spec
->board_config
= STAC_92HD71BXX_REF
;
5403 stac92xx_free(codec
);
5407 codec
->proc_widget_hook
= stac92hd7x_proc_hook
;
5412 static int patch_stac922x(struct hda_codec
*codec
)
5414 struct sigmatel_spec
*spec
;
5417 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5422 spec
->num_pins
= ARRAY_SIZE(stac922x_pin_nids
);
5423 spec
->pin_nids
= stac922x_pin_nids
;
5424 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_922X_MODELS
,
5427 if (spec
->board_config
== STAC_INTEL_MAC_AUTO
) {
5428 spec
->gpio_mask
= spec
->gpio_dir
= 0x03;
5429 spec
->gpio_data
= 0x03;
5430 /* Intel Macs have all same PCI SSID, so we need to check
5431 * codec SSID to distinguish the exact models
5433 printk(KERN_INFO
"hda_codec: STAC922x, Apple subsys_id=%x\n", codec
->subsystem_id
);
5434 switch (codec
->subsystem_id
) {
5437 spec
->board_config
= STAC_INTEL_MAC_V1
;
5441 spec
->board_config
= STAC_INTEL_MAC_V2
;
5449 spec
->board_config
= STAC_INTEL_MAC_V3
;
5453 spec
->board_config
= STAC_INTEL_MAC_V4
;
5457 spec
->board_config
= STAC_INTEL_MAC_V5
;
5460 spec
->board_config
= STAC_INTEL_MAC_V3
;
5466 if (spec
->board_config
< 0)
5467 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC922x, "
5468 "using BIOS defaults\n");
5470 stac92xx_set_config_regs(codec
,
5471 stac922x_brd_tbl
[spec
->board_config
]);
5473 spec
->adc_nids
= stac922x_adc_nids
;
5474 spec
->mux_nids
= stac922x_mux_nids
;
5475 spec
->num_muxes
= ARRAY_SIZE(stac922x_mux_nids
);
5476 spec
->num_adcs
= ARRAY_SIZE(stac922x_adc_nids
);
5477 spec
->num_dmics
= 0;
5480 spec
->init
= stac922x_core_init
;
5481 spec
->mixer
= stac922x_mixer
;
5483 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5485 err
= stac92xx_parse_auto_config(codec
, 0x08, 0x09);
5487 if (spec
->board_config
< 0) {
5488 printk(KERN_WARNING
"hda_codec: No auto-config is "
5489 "available, default to model=ref\n");
5490 spec
->board_config
= STAC_D945_REF
;
5496 stac92xx_free(codec
);
5500 codec
->patch_ops
= stac92xx_patch_ops
;
5502 /* Fix Mux capture level; max to 2 */
5503 snd_hda_override_amp_caps(codec
, 0x12, HDA_OUTPUT
,
5504 (0 << AC_AMPCAP_OFFSET_SHIFT
) |
5505 (2 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
5506 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
5507 (0 << AC_AMPCAP_MUTE_SHIFT
));
5512 static int patch_stac927x(struct hda_codec
*codec
)
5514 struct sigmatel_spec
*spec
;
5517 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5522 codec
->slave_dig_outs
= stac927x_slave_dig_outs
;
5523 spec
->num_pins
= ARRAY_SIZE(stac927x_pin_nids
);
5524 spec
->pin_nids
= stac927x_pin_nids
;
5525 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_927X_MODELS
,
5529 if (spec
->board_config
< 0)
5530 snd_printdd(KERN_INFO
"hda_codec: Unknown model for"
5531 "STAC927x, using BIOS defaults\n");
5533 stac92xx_set_config_regs(codec
,
5534 stac927x_brd_tbl
[spec
->board_config
]);
5536 spec
->digbeep_nid
= 0x23;
5537 spec
->adc_nids
= stac927x_adc_nids
;
5538 spec
->num_adcs
= ARRAY_SIZE(stac927x_adc_nids
);
5539 spec
->mux_nids
= stac927x_mux_nids
;
5540 spec
->num_muxes
= ARRAY_SIZE(stac927x_mux_nids
);
5541 spec
->smux_nids
= stac927x_smux_nids
;
5542 spec
->num_smuxes
= ARRAY_SIZE(stac927x_smux_nids
);
5543 spec
->spdif_labels
= stac927x_spdif_labels
;
5544 spec
->dac_list
= stac927x_dac_nids
;
5545 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5547 switch (spec
->board_config
) {
5550 /* GPIO0 High = Enable EAPD */
5551 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x01;
5552 spec
->gpio_data
= 0x01;
5553 spec
->num_dmics
= 0;
5555 spec
->init
= d965_core_init
;
5556 spec
->mixer
= stac927x_mixer
;
5558 case STAC_DELL_BIOS
:
5559 switch (codec
->subsystem_id
) {
5562 /* correct the device field to SPDIF out */
5563 snd_hda_codec_set_pincfg(codec
, 0x21, 0x01442070);
5566 /* configure the analog microphone on some laptops */
5567 snd_hda_codec_set_pincfg(codec
, 0x0c, 0x90a79130);
5568 /* correct the front output jack as a hp out */
5569 snd_hda_codec_set_pincfg(codec
, 0x0f, 0x0227011f);
5570 /* correct the front input jack as a mic */
5571 snd_hda_codec_set_pincfg(codec
, 0x0e, 0x02a79130);
5574 /* GPIO2 High = Enable EAPD */
5575 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x04;
5576 spec
->gpio_data
= 0x04;
5577 spec
->dmic_nids
= stac927x_dmic_nids
;
5578 spec
->num_dmics
= STAC927X_NUM_DMICS
;
5580 spec
->init
= d965_core_init
;
5581 spec
->mixer
= stac927x_mixer
;
5582 spec
->dmux_nids
= stac927x_dmux_nids
;
5583 spec
->num_dmuxes
= ARRAY_SIZE(stac927x_dmux_nids
);
5586 if (spec
->board_config
> STAC_D965_REF
) {
5587 /* GPIO0 High = Enable EAPD */
5588 spec
->eapd_mask
= spec
->gpio_mask
= 0x01;
5589 spec
->gpio_dir
= spec
->gpio_data
= 0x01;
5591 spec
->num_dmics
= 0;
5593 spec
->init
= stac927x_core_init
;
5594 spec
->mixer
= stac927x_mixer
;
5598 spec
->aloopback_ctl
= stac927x_loopback
;
5599 spec
->aloopback_mask
= 0x40;
5600 spec
->aloopback_shift
= 0;
5601 spec
->eapd_switch
= 1;
5603 err
= stac92xx_parse_auto_config(codec
, 0x1e, 0x20);
5605 if (spec
->board_config
< 0) {
5606 printk(KERN_WARNING
"hda_codec: No auto-config is "
5607 "available, default to model=ref\n");
5608 spec
->board_config
= STAC_D965_REF
;
5614 stac92xx_free(codec
);
5618 codec
->patch_ops
= stac92xx_patch_ops
;
5620 codec
->proc_widget_hook
= stac927x_proc_hook
;
5624 * The STAC927x seem to require fairly long delays for certain
5625 * command sequences. With too short delays (even if the answer
5626 * is set to RIRB properly), it results in the silence output
5627 * on some hardwares like Dell.
5629 * The below flag enables the longer delay (see get_response
5632 codec
->bus
->needs_damn_long_delay
= 1;
5634 /* no jack detecion for ref-no-jd model */
5635 if (spec
->board_config
== STAC_D965_REF_NO_JD
)
5636 spec
->hp_detect
= 0;
5641 static int patch_stac9205(struct hda_codec
*codec
)
5643 struct sigmatel_spec
*spec
;
5646 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5651 spec
->num_pins
= ARRAY_SIZE(stac9205_pin_nids
);
5652 spec
->pin_nids
= stac9205_pin_nids
;
5653 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_9205_MODELS
,
5657 if (spec
->board_config
< 0)
5658 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5660 stac92xx_set_config_regs(codec
,
5661 stac9205_brd_tbl
[spec
->board_config
]);
5663 spec
->digbeep_nid
= 0x23;
5664 spec
->adc_nids
= stac9205_adc_nids
;
5665 spec
->num_adcs
= ARRAY_SIZE(stac9205_adc_nids
);
5666 spec
->mux_nids
= stac9205_mux_nids
;
5667 spec
->num_muxes
= ARRAY_SIZE(stac9205_mux_nids
);
5668 spec
->smux_nids
= stac9205_smux_nids
;
5669 spec
->num_smuxes
= ARRAY_SIZE(stac9205_smux_nids
);
5670 spec
->dmic_nids
= stac9205_dmic_nids
;
5671 spec
->num_dmics
= STAC9205_NUM_DMICS
;
5672 spec
->dmux_nids
= stac9205_dmux_nids
;
5673 spec
->num_dmuxes
= ARRAY_SIZE(stac9205_dmux_nids
);
5676 spec
->init
= stac9205_core_init
;
5677 spec
->mixer
= stac9205_mixer
;
5678 spec
->aloopback_ctl
= stac9205_loopback
;
5680 spec
->aloopback_mask
= 0x40;
5681 spec
->aloopback_shift
= 0;
5682 /* Turn on/off EAPD per HP plugging */
5683 if (spec
->board_config
!= STAC_9205_EAPD
)
5684 spec
->eapd_switch
= 1;
5685 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5687 switch (spec
->board_config
){
5688 case STAC_9205_DELL_M43
:
5689 /* Enable SPDIF in/out */
5690 snd_hda_codec_set_pincfg(codec
, 0x1f, 0x01441030);
5691 snd_hda_codec_set_pincfg(codec
, 0x20, 0x1c410030);
5693 /* Enable unsol response for GPIO4/Dock HP connection */
5694 err
= stac_add_event(spec
, codec
->afg
, STAC_VREF_EVENT
, 0x01);
5697 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
5698 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK
, 0x10);
5699 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
5700 AC_VERB_SET_UNSOLICITED_ENABLE
,
5703 spec
->gpio_dir
= 0x0b;
5704 spec
->eapd_mask
= 0x01;
5705 spec
->gpio_mask
= 0x1b;
5706 spec
->gpio_mute
= 0x10;
5707 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
5710 spec
->gpio_data
= 0x01;
5713 /* SPDIF-In enabled */
5716 /* GPIO0 High = EAPD */
5717 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x1;
5718 spec
->gpio_data
= 0x01;
5722 err
= stac92xx_parse_auto_config(codec
, 0x1f, 0x20);
5724 if (spec
->board_config
< 0) {
5725 printk(KERN_WARNING
"hda_codec: No auto-config is "
5726 "available, default to model=ref\n");
5727 spec
->board_config
= STAC_9205_REF
;
5733 stac92xx_free(codec
);
5737 codec
->patch_ops
= stac92xx_patch_ops
;
5739 codec
->proc_widget_hook
= stac9205_proc_hook
;
5748 static struct hda_verb stac9872_core_init
[] = {
5749 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mic-sel: 0a,0d,14,02 */
5750 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
}, /* Mic-in -> 0x9 */
5754 static struct snd_kcontrol_new stac9872_mixer
[] = {
5755 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT
),
5756 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT
),
5760 static hda_nid_t stac9872_pin_nids
[] = {
5761 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5765 static hda_nid_t stac9872_adc_nids
[] = {
5769 static hda_nid_t stac9872_mux_nids
[] = {
5773 static unsigned int stac9872_vaio_pin_configs
[9] = {
5774 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5775 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
5779 static const char *stac9872_models
[STAC_9872_MODELS
] = {
5780 [STAC_9872_AUTO
] = "auto",
5781 [STAC_9872_VAIO
] = "vaio",
5784 static unsigned int *stac9872_brd_tbl
[STAC_9872_MODELS
] = {
5785 [STAC_9872_VAIO
] = stac9872_vaio_pin_configs
,
5788 static struct snd_pci_quirk stac9872_cfg_tbl
[] = {
5792 static int patch_stac9872(struct hda_codec
*codec
)
5794 struct sigmatel_spec
*spec
;
5797 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5802 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_9872_MODELS
,
5805 if (spec
->board_config
< 0)
5806 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC9872, "
5807 "using BIOS defaults\n");
5809 stac92xx_set_config_regs(codec
,
5810 stac9872_brd_tbl
[spec
->board_config
]);
5812 spec
->num_pins
= ARRAY_SIZE(stac9872_pin_nids
);
5813 spec
->pin_nids
= stac9872_pin_nids
;
5814 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5815 spec
->num_adcs
= ARRAY_SIZE(stac9872_adc_nids
);
5816 spec
->adc_nids
= stac9872_adc_nids
;
5817 spec
->num_muxes
= ARRAY_SIZE(stac9872_mux_nids
);
5818 spec
->mux_nids
= stac9872_mux_nids
;
5819 spec
->mixer
= stac9872_mixer
;
5820 spec
->init
= stac9872_core_init
;
5822 err
= stac92xx_parse_auto_config(codec
, 0x10, 0x12);
5824 stac92xx_free(codec
);
5827 spec
->input_mux
= &spec
->private_imux
;
5828 codec
->patch_ops
= stac92xx_patch_ops
;
5836 static struct hda_codec_preset snd_hda_preset_sigmatel
[] = {
5837 { .id
= 0x83847690, .name
= "STAC9200", .patch
= patch_stac9200
},
5838 { .id
= 0x83847882, .name
= "STAC9220 A1", .patch
= patch_stac922x
},
5839 { .id
= 0x83847680, .name
= "STAC9221 A1", .patch
= patch_stac922x
},
5840 { .id
= 0x83847880, .name
= "STAC9220 A2", .patch
= patch_stac922x
},
5841 { .id
= 0x83847681, .name
= "STAC9220D/9223D A2", .patch
= patch_stac922x
},
5842 { .id
= 0x83847682, .name
= "STAC9221 A2", .patch
= patch_stac922x
},
5843 { .id
= 0x83847683, .name
= "STAC9221D A2", .patch
= patch_stac922x
},
5844 { .id
= 0x83847618, .name
= "STAC9227", .patch
= patch_stac927x
},
5845 { .id
= 0x83847619, .name
= "STAC9227", .patch
= patch_stac927x
},
5846 { .id
= 0x83847616, .name
= "STAC9228", .patch
= patch_stac927x
},
5847 { .id
= 0x83847617, .name
= "STAC9228", .patch
= patch_stac927x
},
5848 { .id
= 0x83847614, .name
= "STAC9229", .patch
= patch_stac927x
},
5849 { .id
= 0x83847615, .name
= "STAC9229", .patch
= patch_stac927x
},
5850 { .id
= 0x83847620, .name
= "STAC9274", .patch
= patch_stac927x
},
5851 { .id
= 0x83847621, .name
= "STAC9274D", .patch
= patch_stac927x
},
5852 { .id
= 0x83847622, .name
= "STAC9273X", .patch
= patch_stac927x
},
5853 { .id
= 0x83847623, .name
= "STAC9273D", .patch
= patch_stac927x
},
5854 { .id
= 0x83847624, .name
= "STAC9272X", .patch
= patch_stac927x
},
5855 { .id
= 0x83847625, .name
= "STAC9272D", .patch
= patch_stac927x
},
5856 { .id
= 0x83847626, .name
= "STAC9271X", .patch
= patch_stac927x
},
5857 { .id
= 0x83847627, .name
= "STAC9271D", .patch
= patch_stac927x
},
5858 { .id
= 0x83847628, .name
= "STAC9274X5NH", .patch
= patch_stac927x
},
5859 { .id
= 0x83847629, .name
= "STAC9274D5NH", .patch
= patch_stac927x
},
5860 { .id
= 0x83847632, .name
= "STAC9202", .patch
= patch_stac925x
},
5861 { .id
= 0x83847633, .name
= "STAC9202D", .patch
= patch_stac925x
},
5862 { .id
= 0x83847634, .name
= "STAC9250", .patch
= patch_stac925x
},
5863 { .id
= 0x83847635, .name
= "STAC9250D", .patch
= patch_stac925x
},
5864 { .id
= 0x83847636, .name
= "STAC9251", .patch
= patch_stac925x
},
5865 { .id
= 0x83847637, .name
= "STAC9250D", .patch
= patch_stac925x
},
5866 { .id
= 0x83847645, .name
= "92HD206X", .patch
= patch_stac927x
},
5867 { .id
= 0x83847646, .name
= "92HD206D", .patch
= patch_stac927x
},
5868 /* The following does not take into account .id=0x83847661 when subsys =
5869 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5870 * currently not fully supported.
5872 { .id
= 0x83847661, .name
= "CXD9872RD/K", .patch
= patch_stac9872
},
5873 { .id
= 0x83847662, .name
= "STAC9872AK", .patch
= patch_stac9872
},
5874 { .id
= 0x83847664, .name
= "CXD9872AKD", .patch
= patch_stac9872
},
5875 { .id
= 0x838476a0, .name
= "STAC9205", .patch
= patch_stac9205
},
5876 { .id
= 0x838476a1, .name
= "STAC9205D", .patch
= patch_stac9205
},
5877 { .id
= 0x838476a2, .name
= "STAC9204", .patch
= patch_stac9205
},
5878 { .id
= 0x838476a3, .name
= "STAC9204D", .patch
= patch_stac9205
},
5879 { .id
= 0x838476a4, .name
= "STAC9255", .patch
= patch_stac9205
},
5880 { .id
= 0x838476a5, .name
= "STAC9255D", .patch
= patch_stac9205
},
5881 { .id
= 0x838476a6, .name
= "STAC9254", .patch
= patch_stac9205
},
5882 { .id
= 0x838476a7, .name
= "STAC9254D", .patch
= patch_stac9205
},
5883 { .id
= 0x111d7603, .name
= "92HD75B3X5", .patch
= patch_stac92hd71bxx
},
5884 { .id
= 0x111d7604, .name
= "92HD83C1X5", .patch
= patch_stac92hd83xxx
},
5885 { .id
= 0x111d7605, .name
= "92HD81B1X5", .patch
= patch_stac92hd83xxx
},
5886 { .id
= 0x111d76d5, .name
= "92HD81B1C5", .patch
= patch_stac92hd83xxx
},
5887 { .id
= 0x111d7608, .name
= "92HD75B2X5", .patch
= patch_stac92hd71bxx
},
5888 { .id
= 0x111d7674, .name
= "92HD73D1X5", .patch
= patch_stac92hd73xx
},
5889 { .id
= 0x111d7675, .name
= "92HD73C1X5", .patch
= patch_stac92hd73xx
},
5890 { .id
= 0x111d7676, .name
= "92HD73E1X5", .patch
= patch_stac92hd73xx
},
5891 { .id
= 0x111d76b0, .name
= "92HD71B8X", .patch
= patch_stac92hd71bxx
},
5892 { .id
= 0x111d76b1, .name
= "92HD71B8X", .patch
= patch_stac92hd71bxx
},
5893 { .id
= 0x111d76b2, .name
= "92HD71B7X", .patch
= patch_stac92hd71bxx
},
5894 { .id
= 0x111d76b3, .name
= "92HD71B7X", .patch
= patch_stac92hd71bxx
},
5895 { .id
= 0x111d76b4, .name
= "92HD71B6X", .patch
= patch_stac92hd71bxx
},
5896 { .id
= 0x111d76b5, .name
= "92HD71B6X", .patch
= patch_stac92hd71bxx
},
5897 { .id
= 0x111d76b6, .name
= "92HD71B5X", .patch
= patch_stac92hd71bxx
},
5898 { .id
= 0x111d76b7, .name
= "92HD71B5X", .patch
= patch_stac92hd71bxx
},
5902 MODULE_ALIAS("snd-hda-codec-id:8384*");
5903 MODULE_ALIAS("snd-hda-codec-id:111d*");
5905 MODULE_LICENSE("GPL");
5906 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5908 static struct hda_codec_preset_list sigmatel_list
= {
5909 .preset
= snd_hda_preset_sigmatel
,
5910 .owner
= THIS_MODULE
,
5913 static int __init
patch_sigmatel_init(void)
5915 return snd_hda_add_codec_preset(&sigmatel_list
);
5918 static void __exit
patch_sigmatel_exit(void)
5920 snd_hda_delete_codec_preset(&sigmatel_list
);
5923 module_init(patch_sigmatel_init
)
5924 module_exit(patch_sigmatel_exit
)