2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for SigmaTel STAC92xx
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
7 * Matt Porter <mporter@embeddedalley.com>
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <linux/dmi.h>
32 #include <linux/module.h>
33 #include <sound/core.h>
34 #include <sound/asoundef.h>
35 #include <sound/jack.h>
36 #include <sound/tlv.h>
37 #include "hda_codec.h"
38 #include "hda_local.h"
82 STAC_92HD73XX_NO_JD
, /* no jack-detection */
96 STAC_92HD83XXX_PWR_REF
,
99 STAC_92HD83XXX_HP_cNB11_INTQUAD
,
101 STAC_92HD83XXX_MODELS
115 STAC_92HD71BXX_MODELS
141 STAC_INTEL_MAC_AUTO
, /* This model is selected if no module parameter
142 * is given, one of the above models will be
143 * chosen according to the subsystem id. */
144 /* for backward compatibility */
161 STAC_D965_REF_NO_JD
, /* no jack-detection */
178 struct sigmatel_event
{
185 struct sigmatel_mic_route
{
188 signed char dmux_idx
;
191 #define MAX_PINS_NUM 16
192 #define MAX_ADCS_NUM 4
193 #define MAX_DMICS_NUM 4
195 struct sigmatel_spec
{
196 struct snd_kcontrol_new
*mixers
[4];
197 unsigned int num_mixers
;
200 unsigned int eapd_switch
: 1;
201 unsigned int surr_switch
: 1;
202 unsigned int alt_switch
: 1;
203 unsigned int hp_detect
: 1;
204 unsigned int spdif_mute
: 1;
205 unsigned int check_volume_offset
:1;
206 unsigned int auto_mic
:1;
207 unsigned int linear_tone_beep
:1;
210 unsigned int eapd_mask
;
211 unsigned int gpio_mask
;
212 unsigned int gpio_dir
;
213 unsigned int gpio_data
;
214 unsigned int gpio_mute
;
215 unsigned int gpio_led
;
216 unsigned int gpio_led_polarity
;
217 unsigned int vref_led
;
220 unsigned int stream_delay
;
222 /* analog loopback */
223 const struct snd_kcontrol_new
*aloopback_ctl
;
224 unsigned char aloopback_mask
;
225 unsigned char aloopback_shift
;
227 /* power management */
228 unsigned int num_pwrs
;
229 const unsigned int *pwr_mapping
;
230 const hda_nid_t
*pwr_nids
;
231 const hda_nid_t
*dac_list
;
234 struct snd_array events
;
237 struct hda_input_mux
*mono_mux
;
238 unsigned int cur_mmux
;
239 struct hda_multi_out multiout
;
240 hda_nid_t dac_nids
[5];
241 hda_nid_t hp_dacs
[5];
242 hda_nid_t speaker_dacs
[5];
247 const hda_nid_t
*adc_nids
;
248 unsigned int num_adcs
;
249 const hda_nid_t
*mux_nids
;
250 unsigned int num_muxes
;
251 const hda_nid_t
*dmic_nids
;
252 unsigned int num_dmics
;
253 const hda_nid_t
*dmux_nids
;
254 unsigned int num_dmuxes
;
255 const hda_nid_t
*smux_nids
;
256 unsigned int num_smuxes
;
257 unsigned int num_analog_muxes
;
259 const unsigned long *capvols
; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
260 const unsigned long *capsws
; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
261 unsigned int num_caps
; /* number of capture volume/switch elements */
263 struct sigmatel_mic_route ext_mic
;
264 struct sigmatel_mic_route int_mic
;
265 struct sigmatel_mic_route dock_mic
;
267 const char * const *spdif_labels
;
269 hda_nid_t dig_in_nid
;
271 hda_nid_t anabeep_nid
;
272 hda_nid_t digbeep_nid
;
275 const hda_nid_t
*pin_nids
;
276 unsigned int num_pins
;
278 /* codec specific stuff */
279 const struct hda_verb
*init
;
280 const struct snd_kcontrol_new
*mixer
;
283 struct hda_input_mux
*dinput_mux
;
284 unsigned int cur_dmux
[2];
285 struct hda_input_mux
*input_mux
;
286 unsigned int cur_mux
[3];
287 struct hda_input_mux
*sinput_mux
;
288 unsigned int cur_smux
[2];
289 unsigned int cur_amux
;
291 unsigned int powerdown_adcs
;
294 unsigned int io_switch
[2];
295 unsigned int clfe_swap
;
296 hda_nid_t line_switch
; /* shared line-in for input and output */
297 hda_nid_t mic_switch
; /* shared mic-in for input and output */
298 hda_nid_t hp_switch
; /* NID of HP as line-out */
299 unsigned int aloopback
;
301 struct hda_pcm pcm_rec
[2]; /* PCM information */
303 /* dynamic controls and input_mux */
304 struct auto_pin_cfg autocfg
;
305 struct snd_array kctls
;
306 struct hda_input_mux private_dimux
;
307 struct hda_input_mux private_imux
;
308 struct hda_input_mux private_smux
;
309 struct hda_input_mux private_mono_mux
;
312 unsigned auto_pin_cnt
;
313 hda_nid_t auto_pin_nids
[MAX_PINS_NUM
];
314 unsigned auto_adc_cnt
;
315 hda_nid_t auto_adc_nids
[MAX_ADCS_NUM
];
316 hda_nid_t auto_mux_nids
[MAX_ADCS_NUM
];
317 hda_nid_t auto_dmux_nids
[MAX_ADCS_NUM
];
318 unsigned long auto_capvols
[MAX_ADCS_NUM
];
319 unsigned auto_dmic_cnt
;
320 hda_nid_t auto_dmic_nids
[MAX_DMICS_NUM
];
323 static const hda_nid_t stac9200_adc_nids
[1] = {
327 static const hda_nid_t stac9200_mux_nids
[1] = {
331 static const hda_nid_t stac9200_dac_nids
[1] = {
335 static const hda_nid_t stac92hd73xx_pwr_nids
[8] = {
336 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
340 static const hda_nid_t stac92hd73xx_slave_dig_outs
[2] = {
344 static const hda_nid_t stac92hd73xx_adc_nids
[2] = {
348 #define STAC92HD73XX_NUM_DMICS 2
349 static const hda_nid_t stac92hd73xx_dmic_nids
[STAC92HD73XX_NUM_DMICS
+ 1] = {
353 #define STAC92HD73_DAC_COUNT 5
355 static const hda_nid_t stac92hd73xx_mux_nids
[2] = {
359 static const hda_nid_t stac92hd73xx_dmux_nids
[2] = {
363 static const hda_nid_t stac92hd73xx_smux_nids
[2] = {
367 #define STAC92HD73XX_NUM_CAPS 2
368 static const unsigned long stac92hd73xx_capvols
[] = {
369 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT
),
370 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT
),
372 #define stac92hd73xx_capsws stac92hd73xx_capvols
374 #define STAC92HD83_DAC_COUNT 3
376 static const hda_nid_t stac92hd83xxx_pwr_nids
[4] = {
380 static const hda_nid_t stac92hd83xxx_slave_dig_outs
[2] = {
384 static const unsigned int stac92hd83xxx_pwr_mapping
[4] = {
385 0x03, 0x0c, 0x20, 0x40,
388 static const hda_nid_t stac92hd83xxx_dmic_nids
[] = {
392 static const hda_nid_t stac92hd71bxx_pwr_nids
[3] = {
396 static const hda_nid_t stac92hd71bxx_adc_nids
[2] = {
400 static const hda_nid_t stac92hd71bxx_mux_nids
[2] = {
404 static const hda_nid_t stac92hd71bxx_dmux_nids
[2] = {
408 static const hda_nid_t stac92hd71bxx_smux_nids
[2] = {
412 #define STAC92HD71BXX_NUM_DMICS 2
413 static const hda_nid_t stac92hd71bxx_dmic_nids
[STAC92HD71BXX_NUM_DMICS
+ 1] = {
417 static const hda_nid_t stac92hd71bxx_dmic_5port_nids
[STAC92HD71BXX_NUM_DMICS
] = {
421 static const hda_nid_t stac92hd71bxx_slave_dig_outs
[2] = {
425 #define STAC92HD71BXX_NUM_CAPS 2
426 static const unsigned long stac92hd71bxx_capvols
[] = {
427 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT
),
428 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT
),
430 #define stac92hd71bxx_capsws stac92hd71bxx_capvols
432 static const hda_nid_t stac925x_adc_nids
[1] = {
436 static const hda_nid_t stac925x_mux_nids
[1] = {
440 static const hda_nid_t stac925x_dac_nids
[1] = {
444 #define STAC925X_NUM_DMICS 1
445 static const hda_nid_t stac925x_dmic_nids
[STAC925X_NUM_DMICS
+ 1] = {
449 static const hda_nid_t stac925x_dmux_nids
[1] = {
453 static const unsigned long stac925x_capvols
[] = {
454 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT
),
456 static const unsigned long stac925x_capsws
[] = {
457 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT
),
460 static const hda_nid_t stac922x_adc_nids
[2] = {
464 static const hda_nid_t stac922x_mux_nids
[2] = {
468 #define STAC922X_NUM_CAPS 2
469 static const unsigned long stac922x_capvols
[] = {
470 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT
),
471 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT
),
473 #define stac922x_capsws stac922x_capvols
475 static const hda_nid_t stac927x_slave_dig_outs
[2] = {
479 static const hda_nid_t stac927x_adc_nids
[3] = {
483 static const hda_nid_t stac927x_mux_nids
[3] = {
487 static const hda_nid_t stac927x_smux_nids
[1] = {
491 static const hda_nid_t stac927x_dac_nids
[6] = {
492 0x02, 0x03, 0x04, 0x05, 0x06, 0
495 static const hda_nid_t stac927x_dmux_nids
[1] = {
499 #define STAC927X_NUM_DMICS 2
500 static const hda_nid_t stac927x_dmic_nids
[STAC927X_NUM_DMICS
+ 1] = {
504 #define STAC927X_NUM_CAPS 3
505 static const unsigned long stac927x_capvols
[] = {
506 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT
),
507 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT
),
508 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT
),
510 static const unsigned long stac927x_capsws
[] = {
511 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT
),
512 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT
),
513 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT
),
516 static const char * const stac927x_spdif_labels
[5] = {
517 "Digital Playback", "ADAT", "Analog Mux 1",
518 "Analog Mux 2", "Analog Mux 3"
521 static const hda_nid_t stac9205_adc_nids
[2] = {
525 static const hda_nid_t stac9205_mux_nids
[2] = {
529 static const hda_nid_t stac9205_dmux_nids
[1] = {
533 static const hda_nid_t stac9205_smux_nids
[1] = {
537 #define STAC9205_NUM_DMICS 2
538 static const hda_nid_t stac9205_dmic_nids
[STAC9205_NUM_DMICS
+ 1] = {
542 #define STAC9205_NUM_CAPS 2
543 static const unsigned long stac9205_capvols
[] = {
544 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT
),
545 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT
),
547 static const unsigned long stac9205_capsws
[] = {
548 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT
),
549 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT
),
552 static const hda_nid_t stac9200_pin_nids
[8] = {
553 0x08, 0x09, 0x0d, 0x0e,
554 0x0f, 0x10, 0x11, 0x12,
557 static const hda_nid_t stac925x_pin_nids
[8] = {
558 0x07, 0x08, 0x0a, 0x0b,
559 0x0c, 0x0d, 0x10, 0x11,
562 static const hda_nid_t stac922x_pin_nids
[10] = {
563 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
564 0x0f, 0x10, 0x11, 0x15, 0x1b,
567 static const hda_nid_t stac92hd73xx_pin_nids
[13] = {
568 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
569 0x0f, 0x10, 0x11, 0x12, 0x13,
573 #define STAC92HD71BXX_NUM_PINS 13
574 static const hda_nid_t stac92hd71bxx_pin_nids_4port
[STAC92HD71BXX_NUM_PINS
] = {
575 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
576 0x00, 0x14, 0x18, 0x19, 0x1e,
579 static const hda_nid_t stac92hd71bxx_pin_nids_6port
[STAC92HD71BXX_NUM_PINS
] = {
580 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
581 0x0f, 0x14, 0x18, 0x19, 0x1e,
585 static const hda_nid_t stac927x_pin_nids
[14] = {
586 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
587 0x0f, 0x10, 0x11, 0x12, 0x13,
588 0x14, 0x21, 0x22, 0x23,
591 static const hda_nid_t stac9205_pin_nids
[12] = {
592 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
593 0x0f, 0x14, 0x16, 0x17, 0x18,
597 static int stac92xx_dmux_enum_info(struct snd_kcontrol
*kcontrol
,
598 struct snd_ctl_elem_info
*uinfo
)
600 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
601 struct sigmatel_spec
*spec
= codec
->spec
;
602 return snd_hda_input_mux_info(spec
->dinput_mux
, uinfo
);
605 static int stac92xx_dmux_enum_get(struct snd_kcontrol
*kcontrol
,
606 struct snd_ctl_elem_value
*ucontrol
)
608 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
609 struct sigmatel_spec
*spec
= codec
->spec
;
610 unsigned int dmux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
612 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_dmux
[dmux_idx
];
616 static int stac92xx_dmux_enum_put(struct snd_kcontrol
*kcontrol
,
617 struct snd_ctl_elem_value
*ucontrol
)
619 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
620 struct sigmatel_spec
*spec
= codec
->spec
;
621 unsigned int dmux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
623 return snd_hda_input_mux_put(codec
, spec
->dinput_mux
, ucontrol
,
624 spec
->dmux_nids
[dmux_idx
], &spec
->cur_dmux
[dmux_idx
]);
627 static int stac92xx_smux_enum_info(struct snd_kcontrol
*kcontrol
,
628 struct snd_ctl_elem_info
*uinfo
)
630 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
631 struct sigmatel_spec
*spec
= codec
->spec
;
632 return snd_hda_input_mux_info(spec
->sinput_mux
, uinfo
);
635 static int stac92xx_smux_enum_get(struct snd_kcontrol
*kcontrol
,
636 struct snd_ctl_elem_value
*ucontrol
)
638 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
639 struct sigmatel_spec
*spec
= codec
->spec
;
640 unsigned int smux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
642 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_smux
[smux_idx
];
646 static int stac92xx_smux_enum_put(struct snd_kcontrol
*kcontrol
,
647 struct snd_ctl_elem_value
*ucontrol
)
649 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
650 struct sigmatel_spec
*spec
= codec
->spec
;
651 struct hda_input_mux
*smux
= &spec
->private_smux
;
652 unsigned int smux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
656 err
= snd_hda_input_mux_put(codec
, spec
->sinput_mux
, ucontrol
,
657 spec
->smux_nids
[smux_idx
], &spec
->cur_smux
[smux_idx
]);
661 if (spec
->spdif_mute
) {
663 nid
= spec
->multiout
.dig_out_nid
;
665 nid
= codec
->slave_dig_outs
[smux_idx
- 1];
666 if (spec
->cur_smux
[smux_idx
] == smux
->num_items
- 1)
670 /* un/mute SPDIF out */
671 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
677 #ifdef CONFIG_SND_HDA_POWER_SAVE
678 static int stac_vrefout_set(struct hda_codec
*codec
,
679 hda_nid_t nid
, unsigned int new_vref
)
683 snd_printdd("%s, nid %x ctl %x\n", __func__
, nid
, new_vref
);
684 pinctl
= snd_hda_codec_read(codec
, nid
, 0,
685 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
691 pinctl
&= ~AC_PINCTL_VREFEN
;
692 pinctl
|= (new_vref
& AC_PINCTL_VREFEN
);
694 error
= snd_hda_codec_write_cache(codec
, nid
, 0,
695 AC_VERB_SET_PIN_WIDGET_CONTROL
, pinctl
);
703 static unsigned int stac92xx_vref_set(struct hda_codec
*codec
,
704 hda_nid_t nid
, unsigned int new_vref
)
708 pincfg
= snd_hda_codec_read(codec
, nid
, 0,
709 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
712 pincfg
&= ~(AC_PINCTL_VREFEN
| AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
);
715 if (new_vref
== AC_PINCTL_VREF_HIZ
)
716 pincfg
|= AC_PINCTL_OUT_EN
;
718 pincfg
|= AC_PINCTL_IN_EN
;
720 error
= snd_hda_codec_write_cache(codec
, nid
, 0,
721 AC_VERB_SET_PIN_WIDGET_CONTROL
, pincfg
);
728 static unsigned int stac92xx_vref_get(struct hda_codec
*codec
, hda_nid_t nid
)
731 vref
= snd_hda_codec_read(codec
, nid
, 0,
732 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
733 vref
&= AC_PINCTL_VREFEN
;
737 static int stac92xx_mux_enum_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
739 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
740 struct sigmatel_spec
*spec
= codec
->spec
;
741 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
744 static int stac92xx_mux_enum_get(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 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
754 static int stac92xx_mux_enum_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
756 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
757 struct sigmatel_spec
*spec
= codec
->spec
;
758 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
759 const struct hda_input_mux
*imux
= spec
->input_mux
;
760 unsigned int idx
, prev_idx
, didx
;
762 idx
= ucontrol
->value
.enumerated
.item
[0];
763 if (idx
>= imux
->num_items
)
764 idx
= imux
->num_items
- 1;
765 prev_idx
= spec
->cur_mux
[adc_idx
];
768 if (idx
< spec
->num_analog_muxes
) {
769 snd_hda_codec_write_cache(codec
, spec
->mux_nids
[adc_idx
], 0,
770 AC_VERB_SET_CONNECT_SEL
,
771 imux
->items
[idx
].index
);
772 if (prev_idx
>= spec
->num_analog_muxes
&&
773 spec
->mux_nids
[adc_idx
] != spec
->dmux_nids
[adc_idx
]) {
774 imux
= spec
->dinput_mux
;
776 snd_hda_codec_write_cache(codec
,
777 spec
->dmux_nids
[adc_idx
], 0,
778 AC_VERB_SET_CONNECT_SEL
,
779 imux
->items
[0].index
);
782 imux
= spec
->dinput_mux
;
783 /* first dimux item is hardcoded to select analog imux,
786 didx
= idx
- spec
->num_analog_muxes
+ 1;
787 snd_hda_codec_write_cache(codec
, spec
->dmux_nids
[adc_idx
], 0,
788 AC_VERB_SET_CONNECT_SEL
,
789 imux
->items
[didx
].index
);
791 spec
->cur_mux
[adc_idx
] = idx
;
795 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol
*kcontrol
,
796 struct snd_ctl_elem_info
*uinfo
)
798 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
799 struct sigmatel_spec
*spec
= codec
->spec
;
800 return snd_hda_input_mux_info(spec
->mono_mux
, uinfo
);
803 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol
*kcontrol
,
804 struct snd_ctl_elem_value
*ucontrol
)
806 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
807 struct sigmatel_spec
*spec
= codec
->spec
;
809 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mmux
;
813 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol
*kcontrol
,
814 struct snd_ctl_elem_value
*ucontrol
)
816 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
817 struct sigmatel_spec
*spec
= codec
->spec
;
819 return snd_hda_input_mux_put(codec
, spec
->mono_mux
, ucontrol
,
820 spec
->mono_nid
, &spec
->cur_mmux
);
823 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
825 static int stac92xx_aloopback_get(struct snd_kcontrol
*kcontrol
,
826 struct snd_ctl_elem_value
*ucontrol
)
828 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
829 unsigned int idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
830 struct sigmatel_spec
*spec
= codec
->spec
;
832 ucontrol
->value
.integer
.value
[0] = !!(spec
->aloopback
&
833 (spec
->aloopback_mask
<< idx
));
837 static int stac92xx_aloopback_put(struct snd_kcontrol
*kcontrol
,
838 struct snd_ctl_elem_value
*ucontrol
)
840 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
841 struct sigmatel_spec
*spec
= codec
->spec
;
842 unsigned int idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
843 unsigned int dac_mode
;
844 unsigned int val
, idx_val
;
846 idx_val
= spec
->aloopback_mask
<< idx
;
847 if (ucontrol
->value
.integer
.value
[0])
848 val
= spec
->aloopback
| idx_val
;
850 val
= spec
->aloopback
& ~idx_val
;
851 if (spec
->aloopback
== val
)
854 spec
->aloopback
= val
;
856 /* Only return the bits defined by the shift value of the
857 * first two bytes of the mask
859 dac_mode
= snd_hda_codec_read(codec
, codec
->afg
, 0,
860 kcontrol
->private_value
& 0xFFFF, 0x0);
861 dac_mode
>>= spec
->aloopback_shift
;
863 if (spec
->aloopback
& idx_val
) {
864 snd_hda_power_up(codec
);
867 snd_hda_power_down(codec
);
868 dac_mode
&= ~idx_val
;
871 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
872 kcontrol
->private_value
>> 16, dac_mode
);
877 static const struct hda_verb stac9200_core_init
[] = {
878 /* set dac0mux for dac converter */
879 { 0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
883 static const struct hda_verb stac9200_eapd_init
[] = {
884 /* set dac0mux for dac converter */
885 {0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
886 {0x08, AC_VERB_SET_EAPD_BTLENABLE
, 0x02},
890 static const struct hda_verb dell_eq_core_init
[] = {
891 /* set master volume to max value without distortion
892 * and direct control */
893 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xec},
897 static const struct hda_verb stac92hd73xx_core_init
[] = {
898 /* set master volume and direct control */
899 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
903 static const struct hda_verb stac92hd83xxx_core_init
[] = {
904 /* power state controls amps */
905 { 0x01, AC_VERB_SET_EAPD
, 1 << 2},
909 static const struct hda_verb stac92hd71bxx_core_init
[] = {
910 /* set master volume and direct control */
911 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
915 static const struct hda_verb stac92hd71bxx_unmute_core_init
[] = {
916 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
917 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
918 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
919 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
923 static const struct hda_verb stac925x_core_init
[] = {
924 /* set dac0mux for dac converter */
925 { 0x06, AC_VERB_SET_CONNECT_SEL
, 0x00},
926 /* mute the master volume */
927 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
931 static const struct hda_verb stac922x_core_init
[] = {
932 /* set master volume and direct control */
933 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
937 static const struct hda_verb d965_core_init
[] = {
938 /* set master volume and direct control */
939 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
940 /* unmute node 0x1b */
941 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
942 /* select node 0x03 as DAC */
943 { 0x0b, AC_VERB_SET_CONNECT_SEL
, 0x01},
947 static const struct hda_verb dell_3st_core_init
[] = {
948 /* don't set delta bit */
949 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0x7f},
950 /* unmute node 0x1b */
951 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
952 /* select node 0x03 as DAC */
953 {0x0b, AC_VERB_SET_CONNECT_SEL
, 0x01},
957 static const struct hda_verb stac927x_core_init
[] = {
958 /* set master volume and direct control */
959 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
960 /* enable analog pc beep path */
961 { 0x01, AC_VERB_SET_DIGI_CONVERT_2
, 1 << 5},
965 static const struct hda_verb stac927x_volknob_core_init
[] = {
966 /* don't set delta bit */
967 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0x7f},
968 /* enable analog pc beep path */
969 {0x01, AC_VERB_SET_DIGI_CONVERT_2
, 1 << 5},
973 static const struct hda_verb stac9205_core_init
[] = {
974 /* set master volume and direct control */
975 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
976 /* enable analog pc beep path */
977 { 0x01, AC_VERB_SET_DIGI_CONVERT_2
, 1 << 5},
981 #define STAC_MONO_MUX \
983 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
984 .name = "Mono Mux", \
986 .info = stac92xx_mono_mux_enum_info, \
987 .get = stac92xx_mono_mux_enum_get, \
988 .put = stac92xx_mono_mux_enum_put, \
991 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
993 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
994 .name = "Analog Loopback", \
996 .info = stac92xx_aloopback_info, \
997 .get = stac92xx_aloopback_get, \
998 .put = stac92xx_aloopback_put, \
999 .private_value = verb_read | (verb_write << 16), \
1002 #define DC_BIAS(xname, idx, nid) \
1004 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1007 .info = stac92xx_dc_bias_info, \
1008 .get = stac92xx_dc_bias_get, \
1009 .put = stac92xx_dc_bias_put, \
1010 .private_value = nid, \
1013 static const struct snd_kcontrol_new stac9200_mixer
[] = {
1014 HDA_CODEC_VOLUME_MIN_MUTE("Master Playback Volume", 0xb, 0, HDA_OUTPUT
),
1015 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT
),
1016 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT
),
1017 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT
),
1021 static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback
[] = {
1022 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1026 static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback
[] = {
1027 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1031 static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback
[] = {
1032 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1037 static const struct snd_kcontrol_new stac92hd71bxx_loopback
[] = {
1038 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1041 static const struct snd_kcontrol_new stac925x_mixer
[] = {
1042 HDA_CODEC_VOLUME_MIN_MUTE("Master Playback Volume", 0xe, 0, HDA_OUTPUT
),
1043 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT
),
1047 static const struct snd_kcontrol_new stac9205_loopback
[] = {
1048 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1052 static const struct snd_kcontrol_new stac927x_loopback
[] = {
1053 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1057 static struct snd_kcontrol_new stac_dmux_mixer
= {
1058 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1059 .name
= "Digital Input Source",
1060 /* count set later */
1061 .info
= stac92xx_dmux_enum_info
,
1062 .get
= stac92xx_dmux_enum_get
,
1063 .put
= stac92xx_dmux_enum_put
,
1066 static struct snd_kcontrol_new stac_smux_mixer
= {
1067 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1068 .name
= "IEC958 Playback Source",
1069 /* count set later */
1070 .info
= stac92xx_smux_enum_info
,
1071 .get
= stac92xx_smux_enum_get
,
1072 .put
= stac92xx_smux_enum_put
,
1075 static const char * const slave_vols
[] = {
1076 "Front Playback Volume",
1077 "Surround Playback Volume",
1078 "Center Playback Volume",
1079 "LFE Playback Volume",
1080 "Side Playback Volume",
1081 "Headphone Playback Volume",
1082 "Speaker Playback Volume",
1086 static const char * const slave_sws
[] = {
1087 "Front Playback Switch",
1088 "Surround Playback Switch",
1089 "Center Playback Switch",
1090 "LFE Playback Switch",
1091 "Side Playback Switch",
1092 "Headphone Playback Switch",
1093 "Speaker Playback Switch",
1094 "IEC958 Playback Switch",
1098 static void stac92xx_free_kctls(struct hda_codec
*codec
);
1099 static int stac92xx_add_jack(struct hda_codec
*codec
, hda_nid_t nid
, int type
);
1101 static int stac92xx_build_controls(struct hda_codec
*codec
)
1103 struct sigmatel_spec
*spec
= codec
->spec
;
1104 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1110 err
= snd_hda_add_new_ctls(codec
, spec
->mixer
);
1115 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1116 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
1120 if (!spec
->auto_mic
&& spec
->num_dmuxes
> 0 &&
1121 snd_hda_get_bool_hint(codec
, "separate_dmux") == 1) {
1122 stac_dmux_mixer
.count
= spec
->num_dmuxes
;
1123 err
= snd_hda_ctl_add(codec
, 0,
1124 snd_ctl_new1(&stac_dmux_mixer
, codec
));
1128 if (spec
->num_smuxes
> 0) {
1129 int wcaps
= get_wcaps(codec
, spec
->multiout
.dig_out_nid
);
1130 struct hda_input_mux
*smux
= &spec
->private_smux
;
1131 /* check for mute support on SPDIF out */
1132 if (wcaps
& AC_WCAP_OUT_AMP
) {
1133 snd_hda_add_imux_item(smux
, "Off", 0, NULL
);
1134 spec
->spdif_mute
= 1;
1136 stac_smux_mixer
.count
= spec
->num_smuxes
;
1137 err
= snd_hda_ctl_add(codec
, 0,
1138 snd_ctl_new1(&stac_smux_mixer
, codec
));
1143 if (spec
->multiout
.dig_out_nid
) {
1144 err
= snd_hda_create_spdif_out_ctls(codec
,
1145 spec
->multiout
.dig_out_nid
,
1146 spec
->multiout
.dig_out_nid
);
1149 err
= snd_hda_create_spdif_share_sw(codec
,
1153 spec
->multiout
.share_spdif
= 1;
1155 if (spec
->dig_in_nid
&& !(spec
->gpio_dir
& 0x01)) {
1156 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
1161 /* if we have no master control, let's create it */
1162 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
1163 unsigned int vmaster_tlv
[4];
1164 snd_hda_set_vmaster_tlv(codec
, spec
->multiout
.dac_nids
[0],
1165 HDA_OUTPUT
, vmaster_tlv
);
1166 /* correct volume offset */
1167 vmaster_tlv
[2] += vmaster_tlv
[3] * spec
->volume_offset
;
1168 /* minimum value is actually mute */
1169 vmaster_tlv
[3] |= TLV_DB_SCALE_MUTE
;
1170 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
1171 vmaster_tlv
, slave_vols
);
1175 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
1176 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
1182 if (spec
->aloopback_ctl
&&
1183 snd_hda_get_bool_hint(codec
, "loopback") == 1) {
1184 err
= snd_hda_add_new_ctls(codec
, spec
->aloopback_ctl
);
1189 stac92xx_free_kctls(codec
); /* no longer needed */
1191 /* create jack input elements */
1192 if (spec
->hp_detect
) {
1193 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
1194 int type
= SND_JACK_HEADPHONE
;
1195 nid
= cfg
->hp_pins
[i
];
1196 /* jack detection */
1197 if (cfg
->hp_outs
== i
)
1198 type
|= SND_JACK_LINEOUT
;
1199 err
= stac92xx_add_jack(codec
, nid
, type
);
1204 for (i
= 0; i
< cfg
->line_outs
; i
++) {
1205 err
= stac92xx_add_jack(codec
, cfg
->line_out_pins
[i
],
1210 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
1211 nid
= cfg
->inputs
[i
].pin
;
1212 err
= stac92xx_add_jack(codec
, nid
, SND_JACK_MICROPHONE
);
1220 static const unsigned int ref9200_pin_configs
[8] = {
1221 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1222 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1225 static const unsigned int gateway9200_m4_pin_configs
[8] = {
1226 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1227 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1229 static const unsigned int gateway9200_m4_2_pin_configs
[8] = {
1230 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1231 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1235 STAC 9200 pin configs for
1240 static const unsigned int dell9200_d21_pin_configs
[8] = {
1241 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1242 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1246 STAC 9200 pin configs for
1250 static const unsigned int dell9200_d22_pin_configs
[8] = {
1251 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1252 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1256 STAC 9200 pin configs for
1257 102801C4 (Dell Dimension E310)
1264 static const unsigned int dell9200_d23_pin_configs
[8] = {
1265 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1266 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1271 STAC 9200-32 pin configs for
1272 102801B5 (Dell Inspiron 630m)
1273 102801D8 (Dell Inspiron 640m)
1275 static const unsigned int dell9200_m21_pin_configs
[8] = {
1276 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1277 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1281 STAC 9200-32 pin configs for
1282 102801C2 (Dell Latitude D620)
1284 102801CC (Dell Latitude D820)
1288 static const unsigned int dell9200_m22_pin_configs
[8] = {
1289 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1290 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1294 STAC 9200-32 pin configs for
1295 102801CE (Dell XPS M1710)
1296 102801CF (Dell Precision M90)
1298 static const unsigned int dell9200_m23_pin_configs
[8] = {
1299 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1300 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1304 STAC 9200-32 pin configs for
1307 102801CB (Dell Latitude 120L)
1310 static const unsigned int dell9200_m24_pin_configs
[8] = {
1311 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1312 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1316 STAC 9200-32 pin configs for
1317 102801BD (Dell Inspiron E1505n)
1321 static const unsigned int dell9200_m25_pin_configs
[8] = {
1322 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1323 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1327 STAC 9200-32 pin configs for
1328 102801F5 (Dell Inspiron 1501)
1331 static const unsigned int dell9200_m26_pin_configs
[8] = {
1332 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1333 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1338 102801CD (Dell Inspiron E1705/9400)
1340 static const unsigned int dell9200_m27_pin_configs
[8] = {
1341 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1342 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1345 static const unsigned int oqo9200_pin_configs
[8] = {
1346 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1347 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1351 static const unsigned int *stac9200_brd_tbl
[STAC_9200_MODELS
] = {
1352 [STAC_REF
] = ref9200_pin_configs
,
1353 [STAC_9200_OQO
] = oqo9200_pin_configs
,
1354 [STAC_9200_DELL_D21
] = dell9200_d21_pin_configs
,
1355 [STAC_9200_DELL_D22
] = dell9200_d22_pin_configs
,
1356 [STAC_9200_DELL_D23
] = dell9200_d23_pin_configs
,
1357 [STAC_9200_DELL_M21
] = dell9200_m21_pin_configs
,
1358 [STAC_9200_DELL_M22
] = dell9200_m22_pin_configs
,
1359 [STAC_9200_DELL_M23
] = dell9200_m23_pin_configs
,
1360 [STAC_9200_DELL_M24
] = dell9200_m24_pin_configs
,
1361 [STAC_9200_DELL_M25
] = dell9200_m25_pin_configs
,
1362 [STAC_9200_DELL_M26
] = dell9200_m26_pin_configs
,
1363 [STAC_9200_DELL_M27
] = dell9200_m27_pin_configs
,
1364 [STAC_9200_M4
] = gateway9200_m4_pin_configs
,
1365 [STAC_9200_M4_2
] = gateway9200_m4_2_pin_configs
,
1366 [STAC_9200_PANASONIC
] = ref9200_pin_configs
,
1369 static const char * const stac9200_models
[STAC_9200_MODELS
] = {
1370 [STAC_AUTO
] = "auto",
1372 [STAC_9200_OQO
] = "oqo",
1373 [STAC_9200_DELL_D21
] = "dell-d21",
1374 [STAC_9200_DELL_D22
] = "dell-d22",
1375 [STAC_9200_DELL_D23
] = "dell-d23",
1376 [STAC_9200_DELL_M21
] = "dell-m21",
1377 [STAC_9200_DELL_M22
] = "dell-m22",
1378 [STAC_9200_DELL_M23
] = "dell-m23",
1379 [STAC_9200_DELL_M24
] = "dell-m24",
1380 [STAC_9200_DELL_M25
] = "dell-m25",
1381 [STAC_9200_DELL_M26
] = "dell-m26",
1382 [STAC_9200_DELL_M27
] = "dell-m27",
1383 [STAC_9200_M4
] = "gateway-m4",
1384 [STAC_9200_M4_2
] = "gateway-m4-2",
1385 [STAC_9200_PANASONIC
] = "panasonic",
1388 static const struct snd_pci_quirk stac9200_cfg_tbl
[] = {
1389 /* SigmaTel reference board */
1390 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1391 "DFI LanParty", STAC_REF
),
1392 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
1393 "DFI LanParty", STAC_REF
),
1394 /* Dell laptops have BIOS problem */
1395 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01a8,
1396 "unknown Dell", STAC_9200_DELL_D21
),
1397 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01b5,
1398 "Dell Inspiron 630m", STAC_9200_DELL_M21
),
1399 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01bd,
1400 "Dell Inspiron E1505n", STAC_9200_DELL_M25
),
1401 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c0,
1402 "unknown Dell", STAC_9200_DELL_D22
),
1403 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c1,
1404 "unknown Dell", STAC_9200_DELL_D22
),
1405 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c2,
1406 "Dell Latitude D620", STAC_9200_DELL_M22
),
1407 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c5,
1408 "unknown Dell", STAC_9200_DELL_D23
),
1409 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c7,
1410 "unknown Dell", STAC_9200_DELL_D23
),
1411 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c8,
1412 "unknown Dell", STAC_9200_DELL_M22
),
1413 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c9,
1414 "unknown Dell", STAC_9200_DELL_M24
),
1415 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ca,
1416 "unknown Dell", STAC_9200_DELL_M24
),
1417 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cb,
1418 "Dell Latitude 120L", STAC_9200_DELL_M24
),
1419 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cc,
1420 "Dell Latitude D820", STAC_9200_DELL_M22
),
1421 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cd,
1422 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27
),
1423 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ce,
1424 "Dell XPS M1710", STAC_9200_DELL_M23
),
1425 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cf,
1426 "Dell Precision M90", STAC_9200_DELL_M23
),
1427 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d3,
1428 "unknown Dell", STAC_9200_DELL_M22
),
1429 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d4,
1430 "unknown Dell", STAC_9200_DELL_M22
),
1431 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d6,
1432 "unknown Dell", STAC_9200_DELL_M22
),
1433 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d8,
1434 "Dell Inspiron 640m", STAC_9200_DELL_M21
),
1435 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d9,
1436 "unknown Dell", STAC_9200_DELL_D23
),
1437 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01da,
1438 "unknown Dell", STAC_9200_DELL_D23
),
1439 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01de,
1440 "unknown Dell", STAC_9200_DELL_D21
),
1441 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01e3,
1442 "unknown Dell", STAC_9200_DELL_D23
),
1443 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01e8,
1444 "unknown Dell", STAC_9200_DELL_D21
),
1445 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ee,
1446 "unknown Dell", STAC_9200_DELL_M25
),
1447 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ef,
1448 "unknown Dell", STAC_9200_DELL_M25
),
1449 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f5,
1450 "Dell Inspiron 1501", STAC_9200_DELL_M26
),
1451 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f6,
1452 "unknown Dell", STAC_9200_DELL_M26
),
1454 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC
),
1455 /* Gateway machines needs EAPD to be set on resume */
1456 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4
),
1457 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2
),
1458 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2
),
1460 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO
),
1464 static const unsigned int ref925x_pin_configs
[8] = {
1465 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1466 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1469 static const unsigned int stac925xM1_pin_configs
[8] = {
1470 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1471 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1474 static const unsigned int stac925xM1_2_pin_configs
[8] = {
1475 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1476 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1479 static const unsigned int stac925xM2_pin_configs
[8] = {
1480 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1481 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1484 static const unsigned int stac925xM2_2_pin_configs
[8] = {
1485 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1486 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1489 static const unsigned int stac925xM3_pin_configs
[8] = {
1490 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1491 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1494 static const unsigned int stac925xM5_pin_configs
[8] = {
1495 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1496 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1499 static const unsigned int stac925xM6_pin_configs
[8] = {
1500 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1501 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1504 static const unsigned int *stac925x_brd_tbl
[STAC_925x_MODELS
] = {
1505 [STAC_REF
] = ref925x_pin_configs
,
1506 [STAC_M1
] = stac925xM1_pin_configs
,
1507 [STAC_M1_2
] = stac925xM1_2_pin_configs
,
1508 [STAC_M2
] = stac925xM2_pin_configs
,
1509 [STAC_M2_2
] = stac925xM2_2_pin_configs
,
1510 [STAC_M3
] = stac925xM3_pin_configs
,
1511 [STAC_M5
] = stac925xM5_pin_configs
,
1512 [STAC_M6
] = stac925xM6_pin_configs
,
1515 static const char * const stac925x_models
[STAC_925x_MODELS
] = {
1516 [STAC_925x_AUTO
] = "auto",
1519 [STAC_M1_2
] = "m1-2",
1521 [STAC_M2_2
] = "m2-2",
1527 static const struct snd_pci_quirk stac925x_codec_id_cfg_tbl
[] = {
1528 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2
),
1529 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5
),
1530 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1
),
1531 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2
),
1532 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2
),
1533 /* Not sure about the brand name for those */
1534 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1
),
1535 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3
),
1536 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6
),
1537 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2
),
1541 static const struct snd_pci_quirk stac925x_cfg_tbl
[] = {
1542 /* SigmaTel reference board */
1543 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668, "DFI LanParty", STAC_REF
),
1544 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101, "DFI LanParty", STAC_REF
),
1545 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF
),
1547 /* Default table for unknown ID */
1548 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2
),
1553 static const unsigned int ref92hd73xx_pin_configs
[13] = {
1554 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1555 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1556 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1560 static const unsigned int dell_m6_pin_configs
[13] = {
1561 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1562 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1563 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1567 static const unsigned int alienware_m17x_pin_configs
[13] = {
1568 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1569 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1570 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1574 static const unsigned int intel_dg45id_pin_configs
[13] = {
1575 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
1576 0x01A19250, 0x01011212, 0x01016211
1579 static const unsigned int *stac92hd73xx_brd_tbl
[STAC_92HD73XX_MODELS
] = {
1580 [STAC_92HD73XX_REF
] = ref92hd73xx_pin_configs
,
1581 [STAC_DELL_M6_AMIC
] = dell_m6_pin_configs
,
1582 [STAC_DELL_M6_DMIC
] = dell_m6_pin_configs
,
1583 [STAC_DELL_M6_BOTH
] = dell_m6_pin_configs
,
1584 [STAC_DELL_EQ
] = dell_m6_pin_configs
,
1585 [STAC_ALIENWARE_M17X
] = alienware_m17x_pin_configs
,
1586 [STAC_92HD73XX_INTEL
] = intel_dg45id_pin_configs
,
1589 static const char * const stac92hd73xx_models
[STAC_92HD73XX_MODELS
] = {
1590 [STAC_92HD73XX_AUTO
] = "auto",
1591 [STAC_92HD73XX_NO_JD
] = "no-jd",
1592 [STAC_92HD73XX_REF
] = "ref",
1593 [STAC_92HD73XX_INTEL
] = "intel",
1594 [STAC_DELL_M6_AMIC
] = "dell-m6-amic",
1595 [STAC_DELL_M6_DMIC
] = "dell-m6-dmic",
1596 [STAC_DELL_M6_BOTH
] = "dell-m6",
1597 [STAC_DELL_EQ
] = "dell-eq",
1598 [STAC_ALIENWARE_M17X
] = "alienware",
1601 static const struct snd_pci_quirk stac92hd73xx_cfg_tbl
[] = {
1602 /* SigmaTel reference board */
1603 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1604 "DFI LanParty", STAC_92HD73XX_REF
),
1605 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
1606 "DFI LanParty", STAC_92HD73XX_REF
),
1607 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5002,
1608 "Intel DG45ID", STAC_92HD73XX_INTEL
),
1609 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5003,
1610 "Intel DG45FC", STAC_92HD73XX_INTEL
),
1611 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0254,
1612 "Dell Studio 1535", STAC_DELL_M6_DMIC
),
1613 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0255,
1614 "unknown Dell", STAC_DELL_M6_DMIC
),
1615 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0256,
1616 "unknown Dell", STAC_DELL_M6_BOTH
),
1617 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0257,
1618 "unknown Dell", STAC_DELL_M6_BOTH
),
1619 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x025e,
1620 "unknown Dell", STAC_DELL_M6_AMIC
),
1621 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x025f,
1622 "unknown Dell", STAC_DELL_M6_AMIC
),
1623 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0271,
1624 "unknown Dell", STAC_DELL_M6_DMIC
),
1625 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0272,
1626 "unknown Dell", STAC_DELL_M6_DMIC
),
1627 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x029f,
1628 "Dell Studio 1537", STAC_DELL_M6_DMIC
),
1629 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02a0,
1630 "Dell Studio 17", STAC_DELL_M6_DMIC
),
1631 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02be,
1632 "Dell Studio 1555", STAC_DELL_M6_DMIC
),
1633 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02bd,
1634 "Dell Studio 1557", STAC_DELL_M6_DMIC
),
1635 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02fe,
1636 "Dell Studio XPS 1645", STAC_DELL_M6_BOTH
),
1637 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0413,
1638 "Dell Studio 1558", STAC_DELL_M6_DMIC
),
1642 static const struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl
[] = {
1643 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02a1,
1644 "Alienware M17x", STAC_ALIENWARE_M17X
),
1645 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x043a,
1646 "Alienware M17x", STAC_ALIENWARE_M17X
),
1650 static const unsigned int ref92hd83xxx_pin_configs
[10] = {
1651 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1652 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1653 0x01451160, 0x98560170,
1656 static const unsigned int dell_s14_pin_configs
[10] = {
1657 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1658 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
1659 0x40f000f0, 0x40f000f0,
1662 static const unsigned int hp_dv7_4000_pin_configs
[10] = {
1663 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
1664 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
1665 0x40f000f0, 0x40f000f0,
1668 static const unsigned int hp_cNB11_intquad_pin_configs
[10] = {
1669 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110,
1670 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130,
1671 0x40f000f0, 0x40f000f0,
1674 static const unsigned int *stac92hd83xxx_brd_tbl
[STAC_92HD83XXX_MODELS
] = {
1675 [STAC_92HD83XXX_REF
] = ref92hd83xxx_pin_configs
,
1676 [STAC_92HD83XXX_PWR_REF
] = ref92hd83xxx_pin_configs
,
1677 [STAC_DELL_S14
] = dell_s14_pin_configs
,
1678 [STAC_92HD83XXX_HP_cNB11_INTQUAD
] = hp_cNB11_intquad_pin_configs
,
1679 [STAC_HP_DV7_4000
] = hp_dv7_4000_pin_configs
,
1682 static const char * const stac92hd83xxx_models
[STAC_92HD83XXX_MODELS
] = {
1683 [STAC_92HD83XXX_AUTO
] = "auto",
1684 [STAC_92HD83XXX_REF
] = "ref",
1685 [STAC_92HD83XXX_PWR_REF
] = "mic-ref",
1686 [STAC_DELL_S14
] = "dell-s14",
1687 [STAC_92HD83XXX_HP
] = "hp",
1688 [STAC_92HD83XXX_HP_cNB11_INTQUAD
] = "hp_cNB11_intquad",
1689 [STAC_HP_DV7_4000
] = "hp-dv7-4000",
1692 static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl
[] = {
1693 /* SigmaTel reference board */
1694 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1695 "DFI LanParty", STAC_92HD83XXX_REF
),
1696 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
1697 "DFI LanParty", STAC_92HD83XXX_REF
),
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02ba,
1699 "unknown Dell", STAC_DELL_S14
),
1700 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP
, 0xff00, 0x3600,
1701 "HP", STAC_92HD83XXX_HP
),
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x1656,
1703 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x1657,
1705 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x1658,
1707 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x1659,
1709 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x165A,
1711 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x165B,
1713 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x3388,
1715 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x3389,
1717 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x355B,
1719 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1720 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x355C,
1721 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1722 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x355D,
1723 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1724 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x355E,
1725 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1726 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x355F,
1727 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1728 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x3560,
1729 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1730 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x358B,
1731 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1732 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x358C,
1733 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1734 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x358D,
1735 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1736 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x3591,
1737 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1738 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x3592,
1739 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1740 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x3593,
1741 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD
),
1745 static const unsigned int ref92hd71bxx_pin_configs
[STAC92HD71BXX_NUM_PINS
] = {
1746 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1747 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1748 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1752 static const unsigned int dell_m4_1_pin_configs
[STAC92HD71BXX_NUM_PINS
] = {
1753 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1754 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1755 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1759 static const unsigned int dell_m4_2_pin_configs
[STAC92HD71BXX_NUM_PINS
] = {
1760 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1761 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1762 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1766 static const unsigned int dell_m4_3_pin_configs
[STAC92HD71BXX_NUM_PINS
] = {
1767 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1768 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1769 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1773 static const unsigned int *stac92hd71bxx_brd_tbl
[STAC_92HD71BXX_MODELS
] = {
1774 [STAC_92HD71BXX_REF
] = ref92hd71bxx_pin_configs
,
1775 [STAC_DELL_M4_1
] = dell_m4_1_pin_configs
,
1776 [STAC_DELL_M4_2
] = dell_m4_2_pin_configs
,
1777 [STAC_DELL_M4_3
] = dell_m4_3_pin_configs
,
1778 [STAC_HP_M4
] = NULL
,
1779 [STAC_HP_DV4
] = NULL
,
1780 [STAC_HP_DV5
] = NULL
,
1781 [STAC_HP_HDX
] = NULL
,
1782 [STAC_HP_DV4_1222NR
] = NULL
,
1785 static const char * const stac92hd71bxx_models
[STAC_92HD71BXX_MODELS
] = {
1786 [STAC_92HD71BXX_AUTO
] = "auto",
1787 [STAC_92HD71BXX_REF
] = "ref",
1788 [STAC_DELL_M4_1
] = "dell-m4-1",
1789 [STAC_DELL_M4_2
] = "dell-m4-2",
1790 [STAC_DELL_M4_3
] = "dell-m4-3",
1791 [STAC_HP_M4
] = "hp-m4",
1792 [STAC_HP_DV4
] = "hp-dv4",
1793 [STAC_HP_DV5
] = "hp-dv5",
1794 [STAC_HP_HDX
] = "hp-hdx",
1795 [STAC_HP_DV4_1222NR
] = "hp-dv4-1222nr",
1798 static const struct snd_pci_quirk stac92hd71bxx_cfg_tbl
[] = {
1799 /* SigmaTel reference board */
1800 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1801 "DFI LanParty", STAC_92HD71BXX_REF
),
1802 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
1803 "DFI LanParty", STAC_92HD71BXX_REF
),
1804 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x30fb,
1805 "HP dv4-1222nr", STAC_HP_DV4_1222NR
),
1806 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP
, 0xfff0, 0x1720,
1808 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP
, 0xfff0, 0x3080,
1810 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP
, 0xfff0, 0x30f0,
1811 "HP dv4-7", STAC_HP_DV4
),
1812 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP
, 0xfff0, 0x3600,
1813 "HP dv4-7", STAC_HP_DV5
),
1814 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x3610,
1815 "HP HDX", STAC_HP_HDX
), /* HDX18 */
1816 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x361a,
1817 "HP mini 1000", STAC_HP_M4
),
1818 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x361b,
1819 "HP HDX", STAC_HP_HDX
), /* HDX16 */
1820 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP
, 0xfff0, 0x3620,
1821 "HP dv6", STAC_HP_DV5
),
1822 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x3061,
1823 "HP dv6", STAC_HP_DV5
), /* HP dv6-1110ax */
1824 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x363e,
1825 "HP DV6", STAC_HP_DV5
),
1826 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP
, 0xfff0, 0x7010,
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0233,
1829 "unknown Dell", STAC_DELL_M4_1
),
1830 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0234,
1831 "unknown Dell", STAC_DELL_M4_1
),
1832 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0250,
1833 "unknown Dell", STAC_DELL_M4_1
),
1834 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x024f,
1835 "unknown Dell", STAC_DELL_M4_1
),
1836 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x024d,
1837 "unknown Dell", STAC_DELL_M4_1
),
1838 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0251,
1839 "unknown Dell", STAC_DELL_M4_1
),
1840 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0277,
1841 "unknown Dell", STAC_DELL_M4_1
),
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0263,
1843 "unknown Dell", STAC_DELL_M4_2
),
1844 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0265,
1845 "unknown Dell", STAC_DELL_M4_2
),
1846 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0262,
1847 "unknown Dell", STAC_DELL_M4_2
),
1848 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0264,
1849 "unknown Dell", STAC_DELL_M4_2
),
1850 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02aa,
1851 "unknown Dell", STAC_DELL_M4_3
),
1855 static const unsigned int ref922x_pin_configs
[10] = {
1856 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1857 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1858 0x40000100, 0x40000100,
1862 STAC 922X pin configs for
1869 static const unsigned int dell_922x_d81_pin_configs
[10] = {
1870 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1871 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1872 0x01813122, 0x400001f2,
1876 STAC 922X pin configs for
1880 static const unsigned int dell_922x_d82_pin_configs
[10] = {
1881 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1882 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1883 0x01813122, 0x400001f1,
1887 STAC 922X pin configs for
1890 static const unsigned int dell_922x_m81_pin_configs
[10] = {
1891 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1892 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1893 0x40C003f1, 0x405003f0,
1897 STAC 9221 A1 pin configs for
1898 102801D7 (Dell XPS M1210)
1900 static const unsigned int dell_922x_m82_pin_configs
[10] = {
1901 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1902 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1903 0x508003f3, 0x405003f4,
1906 static const unsigned int d945gtp3_pin_configs
[10] = {
1907 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1908 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1909 0x02a19120, 0x40000100,
1912 static const unsigned int d945gtp5_pin_configs
[10] = {
1913 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1914 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1915 0x02a19320, 0x40000100,
1918 static const unsigned int intel_mac_v1_pin_configs
[10] = {
1919 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1920 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1921 0x400000fc, 0x400000fb,
1924 static const unsigned int intel_mac_v2_pin_configs
[10] = {
1925 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1926 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1927 0x400000fc, 0x400000fb,
1930 static const unsigned int intel_mac_v3_pin_configs
[10] = {
1931 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1932 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1933 0x400000fc, 0x400000fb,
1936 static const unsigned int intel_mac_v4_pin_configs
[10] = {
1937 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1938 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1939 0x400000fc, 0x400000fb,
1942 static const unsigned int intel_mac_v5_pin_configs
[10] = {
1943 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1944 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1945 0x400000fc, 0x400000fb,
1948 static const unsigned int ecs202_pin_configs
[10] = {
1949 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1950 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1951 0x9037012e, 0x40e000f2,
1954 static const unsigned int *stac922x_brd_tbl
[STAC_922X_MODELS
] = {
1955 [STAC_D945_REF
] = ref922x_pin_configs
,
1956 [STAC_D945GTP3
] = d945gtp3_pin_configs
,
1957 [STAC_D945GTP5
] = d945gtp5_pin_configs
,
1958 [STAC_INTEL_MAC_V1
] = intel_mac_v1_pin_configs
,
1959 [STAC_INTEL_MAC_V2
] = intel_mac_v2_pin_configs
,
1960 [STAC_INTEL_MAC_V3
] = intel_mac_v3_pin_configs
,
1961 [STAC_INTEL_MAC_V4
] = intel_mac_v4_pin_configs
,
1962 [STAC_INTEL_MAC_V5
] = intel_mac_v5_pin_configs
,
1963 [STAC_INTEL_MAC_AUTO
] = intel_mac_v3_pin_configs
,
1964 /* for backward compatibility */
1965 [STAC_MACMINI
] = intel_mac_v3_pin_configs
,
1966 [STAC_MACBOOK
] = intel_mac_v5_pin_configs
,
1967 [STAC_MACBOOK_PRO_V1
] = intel_mac_v3_pin_configs
,
1968 [STAC_MACBOOK_PRO_V2
] = intel_mac_v3_pin_configs
,
1969 [STAC_IMAC_INTEL
] = intel_mac_v2_pin_configs
,
1970 [STAC_IMAC_INTEL_20
] = intel_mac_v3_pin_configs
,
1971 [STAC_ECS_202
] = ecs202_pin_configs
,
1972 [STAC_922X_DELL_D81
] = dell_922x_d81_pin_configs
,
1973 [STAC_922X_DELL_D82
] = dell_922x_d82_pin_configs
,
1974 [STAC_922X_DELL_M81
] = dell_922x_m81_pin_configs
,
1975 [STAC_922X_DELL_M82
] = dell_922x_m82_pin_configs
,
1978 static const char * const stac922x_models
[STAC_922X_MODELS
] = {
1979 [STAC_922X_AUTO
] = "auto",
1980 [STAC_D945_REF
] = "ref",
1981 [STAC_D945GTP5
] = "5stack",
1982 [STAC_D945GTP3
] = "3stack",
1983 [STAC_INTEL_MAC_V1
] = "intel-mac-v1",
1984 [STAC_INTEL_MAC_V2
] = "intel-mac-v2",
1985 [STAC_INTEL_MAC_V3
] = "intel-mac-v3",
1986 [STAC_INTEL_MAC_V4
] = "intel-mac-v4",
1987 [STAC_INTEL_MAC_V5
] = "intel-mac-v5",
1988 [STAC_INTEL_MAC_AUTO
] = "intel-mac-auto",
1989 /* for backward compatibility */
1990 [STAC_MACMINI
] = "macmini",
1991 [STAC_MACBOOK
] = "macbook",
1992 [STAC_MACBOOK_PRO_V1
] = "macbook-pro-v1",
1993 [STAC_MACBOOK_PRO_V2
] = "macbook-pro",
1994 [STAC_IMAC_INTEL
] = "imac-intel",
1995 [STAC_IMAC_INTEL_20
] = "imac-intel-20",
1996 [STAC_ECS_202
] = "ecs202",
1997 [STAC_922X_DELL_D81
] = "dell-d81",
1998 [STAC_922X_DELL_D82
] = "dell-d82",
1999 [STAC_922X_DELL_M81
] = "dell-m81",
2000 [STAC_922X_DELL_M82
] = "dell-m82",
2003 static const struct snd_pci_quirk stac922x_cfg_tbl
[] = {
2004 /* SigmaTel reference board */
2005 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
2006 "DFI LanParty", STAC_D945_REF
),
2007 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
2008 "DFI LanParty", STAC_D945_REF
),
2009 /* Intel 945G based systems */
2010 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0101,
2011 "Intel D945G", STAC_D945GTP3
),
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0202,
2013 "Intel D945G", STAC_D945GTP3
),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0606,
2015 "Intel D945G", STAC_D945GTP3
),
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0601,
2017 "Intel D945G", STAC_D945GTP3
),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0111,
2019 "Intel D945G", STAC_D945GTP3
),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1115,
2021 "Intel D945G", STAC_D945GTP3
),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1116,
2023 "Intel D945G", STAC_D945GTP3
),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1117,
2025 "Intel D945G", STAC_D945GTP3
),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1118,
2027 "Intel D945G", STAC_D945GTP3
),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1119,
2029 "Intel D945G", STAC_D945GTP3
),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x8826,
2031 "Intel D945G", STAC_D945GTP3
),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5049,
2033 "Intel D945G", STAC_D945GTP3
),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5055,
2035 "Intel D945G", STAC_D945GTP3
),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5048,
2037 "Intel D945G", STAC_D945GTP3
),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0110,
2039 "Intel D945G", STAC_D945GTP3
),
2040 /* Intel D945G 5-stack systems */
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0404,
2042 "Intel D945G", STAC_D945GTP5
),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0303,
2044 "Intel D945G", STAC_D945GTP5
),
2045 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0013,
2046 "Intel D945G", STAC_D945GTP5
),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0417,
2048 "Intel D945G", STAC_D945GTP5
),
2049 /* Intel 945P based systems */
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0b0b,
2051 "Intel D945P", STAC_D945GTP3
),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0112,
2053 "Intel D945P", STAC_D945GTP3
),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0d0d,
2055 "Intel D945P", STAC_D945GTP3
),
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0909,
2057 "Intel D945P", STAC_D945GTP3
),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0505,
2059 "Intel D945P", STAC_D945GTP3
),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0707,
2061 "Intel D945P", STAC_D945GTP5
),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0204,
2064 "Intel D945", STAC_D945_REF
),
2066 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2067 SND_PCI_QUIRK(0x8384, 0x7680,
2068 "Mac", STAC_INTEL_MAC_AUTO
),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01a7,
2071 "unknown Dell", STAC_922X_DELL_D81
),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01a9,
2073 "unknown Dell", STAC_922X_DELL_D81
),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ab,
2075 "unknown Dell", STAC_922X_DELL_D81
),
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ac,
2077 "unknown Dell", STAC_922X_DELL_D82
),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01bf,
2079 "unknown Dell", STAC_922X_DELL_M81
),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d0,
2081 "unknown Dell", STAC_922X_DELL_D82
),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d1,
2083 "unknown Dell", STAC_922X_DELL_D81
),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d2,
2085 "unknown Dell", STAC_922X_DELL_D81
),
2086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d7,
2087 "Dell XPS M1210", STAC_922X_DELL_M82
),
2088 /* ECS/PC Chips boards */
2089 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2090 "ECS/PC chips", STAC_ECS_202
),
2094 static const unsigned int ref927x_pin_configs
[14] = {
2095 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2096 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2097 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2098 0x01c42190, 0x40000100,
2101 static const unsigned int d965_3st_pin_configs
[14] = {
2102 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2103 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2104 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2105 0x40000100, 0x40000100
2108 static const unsigned int d965_5st_pin_configs
[14] = {
2109 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2110 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2111 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2112 0x40000100, 0x40000100
2115 static const unsigned int d965_5st_no_fp_pin_configs
[14] = {
2116 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2117 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2118 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2119 0x40000100, 0x40000100
2122 static const unsigned int dell_3st_pin_configs
[14] = {
2123 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2124 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2125 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2126 0x40c003fc, 0x40000100
2129 static const unsigned int *stac927x_brd_tbl
[STAC_927X_MODELS
] = {
2130 [STAC_D965_REF_NO_JD
] = ref927x_pin_configs
,
2131 [STAC_D965_REF
] = ref927x_pin_configs
,
2132 [STAC_D965_3ST
] = d965_3st_pin_configs
,
2133 [STAC_D965_5ST
] = d965_5st_pin_configs
,
2134 [STAC_D965_5ST_NO_FP
] = d965_5st_no_fp_pin_configs
,
2135 [STAC_DELL_3ST
] = dell_3st_pin_configs
,
2136 [STAC_DELL_BIOS
] = NULL
,
2137 [STAC_927X_VOLKNOB
] = NULL
,
2140 static const char * const stac927x_models
[STAC_927X_MODELS
] = {
2141 [STAC_927X_AUTO
] = "auto",
2142 [STAC_D965_REF_NO_JD
] = "ref-no-jd",
2143 [STAC_D965_REF
] = "ref",
2144 [STAC_D965_3ST
] = "3stack",
2145 [STAC_D965_5ST
] = "5stack",
2146 [STAC_D965_5ST_NO_FP
] = "5stack-no-fp",
2147 [STAC_DELL_3ST
] = "dell-3stack",
2148 [STAC_DELL_BIOS
] = "dell-bios",
2149 [STAC_927X_VOLKNOB
] = "volknob",
2152 static const struct snd_pci_quirk stac927x_cfg_tbl
[] = {
2153 /* SigmaTel reference board */
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
2155 "DFI LanParty", STAC_D965_REF
),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
2157 "DFI LanParty", STAC_D965_REF
),
2158 /* Intel 946 based systems */
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x3d01, "Intel D946", STAC_D965_3ST
),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0xa301, "Intel D946", STAC_D965_3ST
),
2161 /* 965 based 3 stack systems */
2162 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL
, 0xff00, 0x2100,
2163 "Intel D965", STAC_D965_3ST
),
2164 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL
, 0xff00, 0x2000,
2165 "Intel D965", STAC_D965_3ST
),
2166 /* Dell 3 stack systems */
2167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST
),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ed, "Dell ", STAC_DELL_3ST
),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f4, "Dell ", STAC_DELL_3ST
),
2170 /* Dell 3 stack systems with verb table in BIOS */
2171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS
),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS
),
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS
),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x022e, "Dell ", STAC_DELL_BIOS
),
2175 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS
),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0242, "Dell ", STAC_DELL_BIOS
),
2177 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0243, "Dell ", STAC_DELL_BIOS
),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02ff, "Dell ", STAC_DELL_BIOS
),
2179 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS
),
2180 /* 965 based 5 stack systems */
2181 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL
, 0xff00, 0x2300,
2182 "Intel D965", STAC_D965_5ST
),
2183 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL
, 0xff00, 0x2500,
2184 "Intel D965", STAC_D965_5ST
),
2185 /* volume-knob fixes */
2186 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB
),
2190 static const unsigned int ref9205_pin_configs
[12] = {
2191 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2192 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2193 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2197 STAC 9205 pin configs for
2204 10280228 (Dell Vostro 1500)
2205 10280229 (Dell Vostro 1700)
2207 static const unsigned int dell_9205_m42_pin_configs
[12] = {
2208 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2209 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2210 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2214 STAC 9205 pin configs for
2218 102801FF (Dell Precision M4300)
2223 static const unsigned int dell_9205_m43_pin_configs
[12] = {
2224 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2225 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2226 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2229 static const unsigned int dell_9205_m44_pin_configs
[12] = {
2230 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2231 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2232 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2235 static const unsigned int *stac9205_brd_tbl
[STAC_9205_MODELS
] = {
2236 [STAC_9205_REF
] = ref9205_pin_configs
,
2237 [STAC_9205_DELL_M42
] = dell_9205_m42_pin_configs
,
2238 [STAC_9205_DELL_M43
] = dell_9205_m43_pin_configs
,
2239 [STAC_9205_DELL_M44
] = dell_9205_m44_pin_configs
,
2240 [STAC_9205_EAPD
] = NULL
,
2243 static const char * const stac9205_models
[STAC_9205_MODELS
] = {
2244 [STAC_9205_AUTO
] = "auto",
2245 [STAC_9205_REF
] = "ref",
2246 [STAC_9205_DELL_M42
] = "dell-m42",
2247 [STAC_9205_DELL_M43
] = "dell-m43",
2248 [STAC_9205_DELL_M44
] = "dell-m44",
2249 [STAC_9205_EAPD
] = "eapd",
2252 static const struct snd_pci_quirk stac9205_cfg_tbl
[] = {
2253 /* SigmaTel reference board */
2254 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
2255 "DFI LanParty", STAC_9205_REF
),
2256 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0xfb30,
2257 "SigmaTel", STAC_9205_REF
),
2258 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
2259 "DFI LanParty", STAC_9205_REF
),
2261 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f1,
2262 "unknown Dell", STAC_9205_DELL_M42
),
2263 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f2,
2264 "unknown Dell", STAC_9205_DELL_M42
),
2265 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f8,
2266 "Dell Precision", STAC_9205_DELL_M43
),
2267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f9,
2268 "Dell Precision", STAC_9205_DELL_M43
),
2269 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fa,
2270 "Dell Precision", STAC_9205_DELL_M43
),
2271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fc,
2272 "unknown Dell", STAC_9205_DELL_M42
),
2273 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fd,
2274 "unknown Dell", STAC_9205_DELL_M42
),
2275 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fe,
2276 "Dell Precision", STAC_9205_DELL_M43
),
2277 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ff,
2278 "Dell Precision M4300", STAC_9205_DELL_M43
),
2279 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0204,
2280 "unknown Dell", STAC_9205_DELL_M42
),
2281 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0206,
2282 "Dell Precision", STAC_9205_DELL_M43
),
2283 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x021b,
2284 "Dell Precision", STAC_9205_DELL_M43
),
2285 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x021c,
2286 "Dell Precision", STAC_9205_DELL_M43
),
2287 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x021f,
2288 "Dell Inspiron", STAC_9205_DELL_M44
),
2289 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0228,
2290 "Dell Vostro 1500", STAC_9205_DELL_M42
),
2291 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0229,
2292 "Dell Vostro 1700", STAC_9205_DELL_M42
),
2294 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD
),
2295 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD
),
2299 static void stac92xx_set_config_regs(struct hda_codec
*codec
,
2300 const unsigned int *pincfgs
)
2303 struct sigmatel_spec
*spec
= codec
->spec
;
2308 for (i
= 0; i
< spec
->num_pins
; i
++)
2309 if (spec
->pin_nids
[i
] && pincfgs
[i
])
2310 snd_hda_codec_set_pincfg(codec
, spec
->pin_nids
[i
],
2315 * Analog playback callbacks
2317 static int stac92xx_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2318 struct hda_codec
*codec
,
2319 struct snd_pcm_substream
*substream
)
2321 struct sigmatel_spec
*spec
= codec
->spec
;
2322 if (spec
->stream_delay
)
2323 msleep(spec
->stream_delay
);
2324 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
2328 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2329 struct hda_codec
*codec
,
2330 unsigned int stream_tag
,
2331 unsigned int format
,
2332 struct snd_pcm_substream
*substream
)
2334 struct sigmatel_spec
*spec
= codec
->spec
;
2335 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
, stream_tag
, format
, substream
);
2338 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2339 struct hda_codec
*codec
,
2340 struct snd_pcm_substream
*substream
)
2342 struct sigmatel_spec
*spec
= codec
->spec
;
2343 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
2347 * Digital playback callbacks
2349 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2350 struct hda_codec
*codec
,
2351 struct snd_pcm_substream
*substream
)
2353 struct sigmatel_spec
*spec
= codec
->spec
;
2354 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
2357 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
2358 struct hda_codec
*codec
,
2359 struct snd_pcm_substream
*substream
)
2361 struct sigmatel_spec
*spec
= codec
->spec
;
2362 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
2365 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2366 struct hda_codec
*codec
,
2367 unsigned int stream_tag
,
2368 unsigned int format
,
2369 struct snd_pcm_substream
*substream
)
2371 struct sigmatel_spec
*spec
= codec
->spec
;
2372 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
2373 stream_tag
, format
, substream
);
2376 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2377 struct hda_codec
*codec
,
2378 struct snd_pcm_substream
*substream
)
2380 struct sigmatel_spec
*spec
= codec
->spec
;
2381 return snd_hda_multi_out_dig_cleanup(codec
, &spec
->multiout
);
2386 * Analog capture callbacks
2388 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2389 struct hda_codec
*codec
,
2390 unsigned int stream_tag
,
2391 unsigned int format
,
2392 struct snd_pcm_substream
*substream
)
2394 struct sigmatel_spec
*spec
= codec
->spec
;
2395 hda_nid_t nid
= spec
->adc_nids
[substream
->number
];
2397 if (spec
->powerdown_adcs
) {
2399 snd_hda_codec_write(codec
, nid
, 0,
2400 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
2402 snd_hda_codec_setup_stream(codec
, nid
, stream_tag
, 0, format
);
2406 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2407 struct hda_codec
*codec
,
2408 struct snd_pcm_substream
*substream
)
2410 struct sigmatel_spec
*spec
= codec
->spec
;
2411 hda_nid_t nid
= spec
->adc_nids
[substream
->number
];
2413 snd_hda_codec_cleanup_stream(codec
, nid
);
2414 if (spec
->powerdown_adcs
)
2415 snd_hda_codec_write(codec
, nid
, 0,
2416 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
2420 static const struct hda_pcm_stream stac92xx_pcm_digital_playback
= {
2424 /* NID is set in stac92xx_build_pcms */
2426 .open
= stac92xx_dig_playback_pcm_open
,
2427 .close
= stac92xx_dig_playback_pcm_close
,
2428 .prepare
= stac92xx_dig_playback_pcm_prepare
,
2429 .cleanup
= stac92xx_dig_playback_pcm_cleanup
2433 static const struct hda_pcm_stream stac92xx_pcm_digital_capture
= {
2437 /* NID is set in stac92xx_build_pcms */
2440 static const struct hda_pcm_stream stac92xx_pcm_analog_playback
= {
2444 .nid
= 0x02, /* NID to query formats and rates */
2446 .open
= stac92xx_playback_pcm_open
,
2447 .prepare
= stac92xx_playback_pcm_prepare
,
2448 .cleanup
= stac92xx_playback_pcm_cleanup
2452 static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback
= {
2456 .nid
= 0x06, /* NID to query formats and rates */
2458 .open
= stac92xx_playback_pcm_open
,
2459 .prepare
= stac92xx_playback_pcm_prepare
,
2460 .cleanup
= stac92xx_playback_pcm_cleanup
2464 static const struct hda_pcm_stream stac92xx_pcm_analog_capture
= {
2467 /* NID + .substreams is set in stac92xx_build_pcms */
2469 .prepare
= stac92xx_capture_pcm_prepare
,
2470 .cleanup
= stac92xx_capture_pcm_cleanup
2474 static int stac92xx_build_pcms(struct hda_codec
*codec
)
2476 struct sigmatel_spec
*spec
= codec
->spec
;
2477 struct hda_pcm
*info
= spec
->pcm_rec
;
2479 codec
->num_pcms
= 1;
2480 codec
->pcm_info
= info
;
2482 info
->name
= "STAC92xx Analog";
2483 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_analog_playback
;
2484 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
2485 spec
->multiout
.dac_nids
[0];
2486 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = stac92xx_pcm_analog_capture
;
2487 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
2488 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adcs
;
2490 if (spec
->alt_switch
) {
2493 info
->name
= "STAC92xx Analog Alt";
2494 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_analog_alt_playback
;
2497 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
2500 info
->name
= "STAC92xx Digital";
2501 info
->pcm_type
= spec
->autocfg
.dig_out_type
[0];
2502 if (spec
->multiout
.dig_out_nid
) {
2503 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_digital_playback
;
2504 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
2506 if (spec
->dig_in_nid
) {
2507 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = stac92xx_pcm_digital_capture
;
2508 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
2515 static unsigned int stac92xx_get_default_vref(struct hda_codec
*codec
,
2518 unsigned int pincap
= snd_hda_query_pin_caps(codec
, nid
);
2519 pincap
= (pincap
& AC_PINCAP_VREF
) >> AC_PINCAP_VREF_SHIFT
;
2520 if (pincap
& AC_PINCAP_VREF_100
)
2521 return AC_PINCTL_VREF_100
;
2522 if (pincap
& AC_PINCAP_VREF_80
)
2523 return AC_PINCTL_VREF_80
;
2524 if (pincap
& AC_PINCAP_VREF_50
)
2525 return AC_PINCTL_VREF_50
;
2526 if (pincap
& AC_PINCAP_VREF_GRD
)
2527 return AC_PINCTL_VREF_GRD
;
2531 static void stac92xx_auto_set_pinctl(struct hda_codec
*codec
, hda_nid_t nid
, int pin_type
)
2534 snd_hda_codec_write_cache(codec
, nid
, 0,
2535 AC_VERB_SET_PIN_WIDGET_CONTROL
, pin_type
);
2538 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2540 static int stac92xx_hp_switch_get(struct snd_kcontrol
*kcontrol
,
2541 struct snd_ctl_elem_value
*ucontrol
)
2543 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2544 struct sigmatel_spec
*spec
= codec
->spec
;
2546 ucontrol
->value
.integer
.value
[0] = !!spec
->hp_switch
;
2550 static void stac_issue_unsol_event(struct hda_codec
*codec
, hda_nid_t nid
);
2552 static int stac92xx_hp_switch_put(struct snd_kcontrol
*kcontrol
,
2553 struct snd_ctl_elem_value
*ucontrol
)
2555 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2556 struct sigmatel_spec
*spec
= codec
->spec
;
2557 int nid
= kcontrol
->private_value
;
2559 spec
->hp_switch
= ucontrol
->value
.integer
.value
[0] ? nid
: 0;
2561 /* check to be sure that the ports are up to date with
2564 stac_issue_unsol_event(codec
, nid
);
2569 static int stac92xx_dc_bias_info(struct snd_kcontrol
*kcontrol
,
2570 struct snd_ctl_elem_info
*uinfo
)
2573 static const char * const texts
[] = {
2574 "Mic In", "Line In", "Line Out"
2577 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2578 struct sigmatel_spec
*spec
= codec
->spec
;
2579 hda_nid_t nid
= kcontrol
->private_value
;
2581 if (nid
== spec
->mic_switch
|| nid
== spec
->line_switch
)
2586 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
2587 uinfo
->value
.enumerated
.items
= i
;
2589 if (uinfo
->value
.enumerated
.item
>= i
)
2590 uinfo
->value
.enumerated
.item
= i
-1;
2591 strcpy(uinfo
->value
.enumerated
.name
,
2592 texts
[uinfo
->value
.enumerated
.item
]);
2597 static int stac92xx_dc_bias_get(struct snd_kcontrol
*kcontrol
,
2598 struct snd_ctl_elem_value
*ucontrol
)
2600 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2601 hda_nid_t nid
= kcontrol
->private_value
;
2602 unsigned int vref
= stac92xx_vref_get(codec
, nid
);
2604 if (vref
== stac92xx_get_default_vref(codec
, nid
))
2605 ucontrol
->value
.enumerated
.item
[0] = 0;
2606 else if (vref
== AC_PINCTL_VREF_GRD
)
2607 ucontrol
->value
.enumerated
.item
[0] = 1;
2608 else if (vref
== AC_PINCTL_VREF_HIZ
)
2609 ucontrol
->value
.enumerated
.item
[0] = 2;
2614 static int stac92xx_dc_bias_put(struct snd_kcontrol
*kcontrol
,
2615 struct snd_ctl_elem_value
*ucontrol
)
2617 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2618 unsigned int new_vref
= 0;
2620 hda_nid_t nid
= kcontrol
->private_value
;
2622 if (ucontrol
->value
.enumerated
.item
[0] == 0)
2623 new_vref
= stac92xx_get_default_vref(codec
, nid
);
2624 else if (ucontrol
->value
.enumerated
.item
[0] == 1)
2625 new_vref
= AC_PINCTL_VREF_GRD
;
2626 else if (ucontrol
->value
.enumerated
.item
[0] == 2)
2627 new_vref
= AC_PINCTL_VREF_HIZ
;
2631 if (new_vref
!= stac92xx_vref_get(codec
, nid
)) {
2632 error
= stac92xx_vref_set(codec
, nid
, new_vref
);
2639 static int stac92xx_io_switch_info(struct snd_kcontrol
*kcontrol
,
2640 struct snd_ctl_elem_info
*uinfo
)
2643 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2644 struct sigmatel_spec
*spec
= codec
->spec
;
2646 if (kcontrol
->private_value
== spec
->line_switch
)
2647 texts
[0] = "Line In";
2649 texts
[0] = "Mic In";
2650 texts
[1] = "Line Out";
2651 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
2652 uinfo
->value
.enumerated
.items
= 2;
2655 if (uinfo
->value
.enumerated
.item
>= 2)
2656 uinfo
->value
.enumerated
.item
= 1;
2657 strcpy(uinfo
->value
.enumerated
.name
,
2658 texts
[uinfo
->value
.enumerated
.item
]);
2663 static int stac92xx_io_switch_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2665 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2666 struct sigmatel_spec
*spec
= codec
->spec
;
2667 hda_nid_t nid
= kcontrol
->private_value
;
2668 int io_idx
= (nid
== spec
->mic_switch
) ? 1 : 0;
2670 ucontrol
->value
.enumerated
.item
[0] = spec
->io_switch
[io_idx
];
2674 static int stac92xx_io_switch_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2676 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2677 struct sigmatel_spec
*spec
= codec
->spec
;
2678 hda_nid_t nid
= kcontrol
->private_value
;
2679 int io_idx
= (nid
== spec
->mic_switch
) ? 1 : 0;
2680 unsigned short val
= !!ucontrol
->value
.enumerated
.item
[0];
2682 spec
->io_switch
[io_idx
] = val
;
2685 stac92xx_auto_set_pinctl(codec
, nid
, AC_PINCTL_OUT_EN
);
2687 unsigned int pinctl
= AC_PINCTL_IN_EN
;
2688 if (io_idx
) /* set VREF for mic */
2689 pinctl
|= stac92xx_get_default_vref(codec
, nid
);
2690 stac92xx_auto_set_pinctl(codec
, nid
, pinctl
);
2693 /* check the auto-mute again: we need to mute/unmute the speaker
2694 * appropriately according to the pin direction
2696 if (spec
->hp_detect
)
2697 stac_issue_unsol_event(codec
, nid
);
2702 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2704 static int stac92xx_clfe_switch_get(struct snd_kcontrol
*kcontrol
,
2705 struct snd_ctl_elem_value
*ucontrol
)
2707 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2708 struct sigmatel_spec
*spec
= codec
->spec
;
2710 ucontrol
->value
.integer
.value
[0] = spec
->clfe_swap
;
2714 static int stac92xx_clfe_switch_put(struct snd_kcontrol
*kcontrol
,
2715 struct snd_ctl_elem_value
*ucontrol
)
2717 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2718 struct sigmatel_spec
*spec
= codec
->spec
;
2719 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
2720 unsigned int val
= !!ucontrol
->value
.integer
.value
[0];
2722 if (spec
->clfe_swap
== val
)
2725 spec
->clfe_swap
= val
;
2727 snd_hda_codec_write_cache(codec
, nid
, 0, AC_VERB_SET_EAPD_BTLENABLE
,
2728 spec
->clfe_swap
? 0x4 : 0x0);
2733 #define STAC_CODEC_HP_SWITCH(xname) \
2734 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2737 .info = stac92xx_hp_switch_info, \
2738 .get = stac92xx_hp_switch_get, \
2739 .put = stac92xx_hp_switch_put, \
2742 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2743 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2746 .info = stac92xx_io_switch_info, \
2747 .get = stac92xx_io_switch_get, \
2748 .put = stac92xx_io_switch_put, \
2749 .private_value = xpval, \
2752 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2753 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2756 .info = stac92xx_clfe_switch_info, \
2757 .get = stac92xx_clfe_switch_get, \
2758 .put = stac92xx_clfe_switch_put, \
2759 .private_value = xpval, \
2763 STAC_CTL_WIDGET_VOL
,
2764 STAC_CTL_WIDGET_MUTE
,
2765 STAC_CTL_WIDGET_MUTE_BEEP
,
2766 STAC_CTL_WIDGET_MONO_MUX
,
2767 STAC_CTL_WIDGET_HP_SWITCH
,
2768 STAC_CTL_WIDGET_IO_SWITCH
,
2769 STAC_CTL_WIDGET_CLFE_SWITCH
,
2770 STAC_CTL_WIDGET_DC_BIAS
2773 static const struct snd_kcontrol_new stac92xx_control_templates
[] = {
2774 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2775 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2776 HDA_CODEC_MUTE_BEEP(NULL
, 0, 0, 0),
2778 STAC_CODEC_HP_SWITCH(NULL
),
2779 STAC_CODEC_IO_SWITCH(NULL
, 0),
2780 STAC_CODEC_CLFE_SWITCH(NULL
, 0),
2781 DC_BIAS(NULL
, 0, 0),
2784 /* add dynamic controls */
2785 static struct snd_kcontrol_new
*
2786 stac_control_new(struct sigmatel_spec
*spec
,
2787 const struct snd_kcontrol_new
*ktemp
,
2789 unsigned int subdev
)
2791 struct snd_kcontrol_new
*knew
;
2793 snd_array_init(&spec
->kctls
, sizeof(*knew
), 32);
2794 knew
= snd_array_new(&spec
->kctls
);
2798 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2801 memset(knew
, 0, sizeof(*knew
));
2802 spec
->kctls
.alloced
--;
2805 knew
->subdevice
= subdev
;
2809 static int stac92xx_add_control_temp(struct sigmatel_spec
*spec
,
2810 const struct snd_kcontrol_new
*ktemp
,
2811 int idx
, const char *name
,
2814 struct snd_kcontrol_new
*knew
= stac_control_new(spec
, ktemp
, name
,
2815 HDA_SUBDEV_AMP_FLAG
);
2819 knew
->private_value
= val
;
2823 static inline int stac92xx_add_control_idx(struct sigmatel_spec
*spec
,
2824 int type
, int idx
, const char *name
,
2827 return stac92xx_add_control_temp(spec
,
2828 &stac92xx_control_templates
[type
],
2833 /* add dynamic controls */
2834 static inline int stac92xx_add_control(struct sigmatel_spec
*spec
, int type
,
2835 const char *name
, unsigned long val
)
2837 return stac92xx_add_control_idx(spec
, type
, 0, name
, val
);
2840 static const struct snd_kcontrol_new stac_input_src_temp
= {
2841 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2842 .name
= "Input Source",
2843 .info
= stac92xx_mux_enum_info
,
2844 .get
= stac92xx_mux_enum_get
,
2845 .put
= stac92xx_mux_enum_put
,
2848 static inline int stac92xx_add_jack_mode_control(struct hda_codec
*codec
,
2849 hda_nid_t nid
, int idx
)
2851 int def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
2853 struct sigmatel_spec
*spec
= codec
->spec
;
2856 if (snd_hda_get_input_pin_attr(def_conf
) != INPUT_PIN_ATTR_INT
) {
2857 if (stac92xx_get_default_vref(codec
, nid
) == AC_PINCTL_VREF_GRD
2858 && nid
== spec
->line_switch
)
2859 control
= STAC_CTL_WIDGET_IO_SWITCH
;
2860 else if (snd_hda_query_pin_caps(codec
, nid
)
2861 & (AC_PINCAP_VREF_GRD
<< AC_PINCAP_VREF_SHIFT
))
2862 control
= STAC_CTL_WIDGET_DC_BIAS
;
2863 else if (nid
== spec
->mic_switch
)
2864 control
= STAC_CTL_WIDGET_IO_SWITCH
;
2868 strcpy(name
, hda_get_input_pin_label(codec
, nid
, 1));
2869 return stac92xx_add_control(codec
->spec
, control
,
2870 strcat(name
, " Jack Mode"), nid
);
2876 static int stac92xx_add_input_source(struct sigmatel_spec
*spec
)
2878 struct snd_kcontrol_new
*knew
;
2879 struct hda_input_mux
*imux
= &spec
->private_imux
;
2882 return 0; /* no need for input source */
2883 if (!spec
->num_adcs
|| imux
->num_items
<= 1)
2884 return 0; /* no need for input source control */
2885 knew
= stac_control_new(spec
, &stac_input_src_temp
,
2886 stac_input_src_temp
.name
, 0);
2889 knew
->count
= spec
->num_adcs
;
2893 /* check whether the line-input can be used as line-out */
2894 static hda_nid_t
check_line_out_switch(struct hda_codec
*codec
)
2896 struct sigmatel_spec
*spec
= codec
->spec
;
2897 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2899 unsigned int pincap
;
2902 if (cfg
->line_out_type
!= AUTO_PIN_LINE_OUT
)
2904 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2905 if (cfg
->inputs
[i
].type
== AUTO_PIN_LINE_IN
) {
2906 nid
= cfg
->inputs
[i
].pin
;
2907 pincap
= snd_hda_query_pin_caps(codec
, nid
);
2908 if (pincap
& AC_PINCAP_OUT
)
2915 static hda_nid_t
get_unassigned_dac(struct hda_codec
*codec
, hda_nid_t nid
);
2917 /* check whether the mic-input can be used as line-out */
2918 static hda_nid_t
check_mic_out_switch(struct hda_codec
*codec
, hda_nid_t
*dac
)
2920 struct sigmatel_spec
*spec
= codec
->spec
;
2921 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2922 unsigned int def_conf
, pincap
;
2926 if (cfg
->line_out_type
!= AUTO_PIN_LINE_OUT
)
2928 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
2929 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
2930 if (cfg
->inputs
[i
].type
!= AUTO_PIN_MIC
)
2932 def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
2933 /* some laptops have an internal analog microphone
2934 * which can't be used as a output */
2935 if (snd_hda_get_input_pin_attr(def_conf
) != INPUT_PIN_ATTR_INT
) {
2936 pincap
= snd_hda_query_pin_caps(codec
, nid
);
2937 if (pincap
& AC_PINCAP_OUT
) {
2938 *dac
= get_unassigned_dac(codec
, nid
);
2947 static int is_in_dac_nids(struct sigmatel_spec
*spec
, hda_nid_t nid
)
2951 for (i
= 0; i
< spec
->multiout
.num_dacs
; i
++) {
2952 if (spec
->multiout
.dac_nids
[i
] == nid
)
2959 static int check_all_dac_nids(struct sigmatel_spec
*spec
, hda_nid_t nid
)
2962 if (is_in_dac_nids(spec
, nid
))
2964 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++)
2965 if (spec
->hp_dacs
[i
] == nid
)
2967 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++)
2968 if (spec
->speaker_dacs
[i
] == nid
)
2973 static hda_nid_t
get_unassigned_dac(struct hda_codec
*codec
, hda_nid_t nid
)
2975 struct sigmatel_spec
*spec
= codec
->spec
;
2976 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2978 hda_nid_t conn
[HDA_MAX_CONNECTIONS
], fallback_dac
;
2979 unsigned int wcaps
, wtype
;
2981 conn_len
= snd_hda_get_connections(codec
, nid
, conn
,
2982 HDA_MAX_CONNECTIONS
);
2983 /* 92HD88: trace back up the link of nids to find the DAC */
2984 while (conn_len
== 1 && (get_wcaps_type(get_wcaps(codec
, conn
[0]))
2985 != AC_WID_AUD_OUT
)) {
2987 conn_len
= snd_hda_get_connections(codec
, nid
, conn
,
2988 HDA_MAX_CONNECTIONS
);
2990 for (j
= 0; j
< conn_len
; j
++) {
2991 wcaps
= get_wcaps(codec
, conn
[j
]);
2992 wtype
= get_wcaps_type(wcaps
);
2993 /* we check only analog outputs */
2994 if (wtype
!= AC_WID_AUD_OUT
|| (wcaps
& AC_WCAP_DIGITAL
))
2996 /* if this route has a free DAC, assign it */
2997 if (!check_all_dac_nids(spec
, conn
[j
])) {
2999 /* select this DAC in the pin's input mux */
3000 snd_hda_codec_write_cache(codec
, nid
, 0,
3001 AC_VERB_SET_CONNECT_SEL
, j
);
3007 /* if all DACs are already assigned, connect to the primary DAC,
3008 unless we're assigning a secondary headphone */
3009 fallback_dac
= spec
->multiout
.dac_nids
[0];
3010 if (spec
->multiout
.hp_nid
) {
3011 for (j
= 0; j
< cfg
->hp_outs
; j
++)
3012 if (cfg
->hp_pins
[j
] == nid
) {
3013 fallback_dac
= spec
->multiout
.hp_nid
;
3019 for (j
= 0; j
< conn_len
; j
++) {
3020 if (conn
[j
] == fallback_dac
) {
3021 snd_hda_codec_write_cache(codec
, nid
, 0,
3022 AC_VERB_SET_CONNECT_SEL
, j
);
3030 static int add_spec_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
);
3031 static int add_spec_extra_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
);
3034 * Fill in the dac_nids table from the parsed pin configuration
3035 * This function only works when every pin in line_out_pins[]
3036 * contains atleast one DAC in its connection list. Some 92xx
3037 * codecs are not connected directly to a DAC, such as the 9200
3038 * and 9202/925x. For those, dac_nids[] must be hard-coded.
3040 static int stac92xx_auto_fill_dac_nids(struct hda_codec
*codec
)
3042 struct sigmatel_spec
*spec
= codec
->spec
;
3043 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3047 for (i
= 0; i
< cfg
->line_outs
; i
++) {
3048 nid
= cfg
->line_out_pins
[i
];
3049 dac
= get_unassigned_dac(codec
, nid
);
3051 if (spec
->multiout
.num_dacs
> 0) {
3052 /* we have already working output pins,
3053 * so let's drop the broken ones again
3055 cfg
->line_outs
= spec
->multiout
.num_dacs
;
3058 /* error out, no available DAC found */
3060 "%s: No available DAC for pin 0x%x\n",
3064 add_spec_dacs(spec
, dac
);
3067 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
3068 nid
= cfg
->hp_pins
[i
];
3069 dac
= get_unassigned_dac(codec
, nid
);
3071 if (!spec
->multiout
.hp_nid
)
3072 spec
->multiout
.hp_nid
= dac
;
3074 add_spec_extra_dacs(spec
, dac
);
3076 spec
->hp_dacs
[i
] = dac
;
3079 for (i
= 0; i
< cfg
->speaker_outs
; i
++) {
3080 nid
= cfg
->speaker_pins
[i
];
3081 dac
= get_unassigned_dac(codec
, nid
);
3083 add_spec_extra_dacs(spec
, dac
);
3084 spec
->speaker_dacs
[i
] = dac
;
3087 /* add line-in as output */
3088 nid
= check_line_out_switch(codec
);
3090 dac
= get_unassigned_dac(codec
, nid
);
3092 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3093 nid
, cfg
->line_outs
);
3094 cfg
->line_out_pins
[cfg
->line_outs
] = nid
;
3096 spec
->line_switch
= nid
;
3097 add_spec_dacs(spec
, dac
);
3100 /* add mic as output */
3101 nid
= check_mic_out_switch(codec
, &dac
);
3103 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3104 nid
, cfg
->line_outs
);
3105 cfg
->line_out_pins
[cfg
->line_outs
] = nid
;
3107 spec
->mic_switch
= nid
;
3108 add_spec_dacs(spec
, dac
);
3111 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
3112 spec
->multiout
.num_dacs
,
3113 spec
->multiout
.dac_nids
[0],
3114 spec
->multiout
.dac_nids
[1],
3115 spec
->multiout
.dac_nids
[2],
3116 spec
->multiout
.dac_nids
[3],
3117 spec
->multiout
.dac_nids
[4]);
3122 /* create volume control/switch for the given prefx type */
3123 static int create_controls_idx(struct hda_codec
*codec
, const char *pfx
,
3124 int idx
, hda_nid_t nid
, int chs
)
3126 struct sigmatel_spec
*spec
= codec
->spec
;
3130 if (!spec
->check_volume_offset
) {
3131 unsigned int caps
, step
, nums
, db_scale
;
3132 caps
= query_amp_caps(codec
, nid
, HDA_OUTPUT
);
3133 step
= (caps
& AC_AMPCAP_STEP_SIZE
) >>
3134 AC_AMPCAP_STEP_SIZE_SHIFT
;
3135 step
= (step
+ 1) * 25; /* in .01dB unit */
3136 nums
= (caps
& AC_AMPCAP_NUM_STEPS
) >>
3137 AC_AMPCAP_NUM_STEPS_SHIFT
;
3138 db_scale
= nums
* step
;
3139 /* if dB scale is over -64dB, and finer enough,
3140 * let's reduce it to half
3142 if (db_scale
> 6400 && nums
>= 0x1f)
3143 spec
->volume_offset
= nums
/ 2;
3144 spec
->check_volume_offset
= 1;
3147 sprintf(name
, "%s Playback Volume", pfx
);
3148 err
= stac92xx_add_control_idx(spec
, STAC_CTL_WIDGET_VOL
, idx
, name
,
3149 HDA_COMPOSE_AMP_VAL_OFS(nid
, chs
, 0, HDA_OUTPUT
,
3150 spec
->volume_offset
));
3153 sprintf(name
, "%s Playback Switch", pfx
);
3154 err
= stac92xx_add_control_idx(spec
, STAC_CTL_WIDGET_MUTE
, idx
, name
,
3155 HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
));
3161 #define create_controls(codec, pfx, nid, chs) \
3162 create_controls_idx(codec, pfx, 0, nid, chs)
3164 static int add_spec_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
)
3166 if (spec
->multiout
.num_dacs
> 4) {
3167 printk(KERN_WARNING
"stac92xx: No space for DAC 0x%x\n", nid
);
3170 snd_BUG_ON(spec
->multiout
.dac_nids
!= spec
->dac_nids
);
3171 spec
->dac_nids
[spec
->multiout
.num_dacs
] = nid
;
3172 spec
->multiout
.num_dacs
++;
3177 static int add_spec_extra_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
)
3180 for (i
= 0; i
< ARRAY_SIZE(spec
->multiout
.extra_out_nid
); i
++) {
3181 if (!spec
->multiout
.extra_out_nid
[i
]) {
3182 spec
->multiout
.extra_out_nid
[i
] = nid
;
3186 printk(KERN_WARNING
"stac92xx: No space for extra DAC 0x%x\n", nid
);
3190 /* Create output controls
3191 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3193 static int create_multi_out_ctls(struct hda_codec
*codec
, int num_outs
,
3194 const hda_nid_t
*pins
,
3195 const hda_nid_t
*dac_nids
,
3198 struct sigmatel_spec
*spec
= codec
->spec
;
3199 static const char * const chname
[4] = {
3200 "Front", "Surround", NULL
/*CLFE*/, "Side"
3204 unsigned int wid_caps
;
3206 for (i
= 0; i
< num_outs
&& i
< ARRAY_SIZE(chname
); i
++) {
3207 if (type
== AUTO_PIN_HP_OUT
&& !spec
->hp_detect
) {
3208 if (is_jack_detectable(codec
, pins
[i
]))
3209 spec
->hp_detect
= 1;
3214 if (type
!= AUTO_PIN_HP_OUT
&& i
== 2) {
3216 err
= create_controls(codec
, "Center", nid
, 1);
3219 err
= create_controls(codec
, "LFE", nid
, 2);
3223 wid_caps
= get_wcaps(codec
, nid
);
3225 if (wid_caps
& AC_WCAP_LR_SWAP
) {
3226 err
= stac92xx_add_control(spec
,
3227 STAC_CTL_WIDGET_CLFE_SWITCH
,
3228 "Swap Center/LFE Playback Switch", nid
);
3238 case AUTO_PIN_HP_OUT
:
3242 case AUTO_PIN_SPEAKER_OUT
:
3251 err
= create_controls_idx(codec
, name
, idx
, nid
, 3);
3259 static int stac92xx_add_capvol_ctls(struct hda_codec
*codec
, unsigned long vol
,
3260 unsigned long sw
, int idx
)
3263 err
= stac92xx_add_control_idx(codec
->spec
, STAC_CTL_WIDGET_VOL
, idx
,
3264 "Capture Volume", vol
);
3267 err
= stac92xx_add_control_idx(codec
->spec
, STAC_CTL_WIDGET_MUTE
, idx
,
3268 "Capture Switch", sw
);
3274 /* add playback controls from the parsed DAC table */
3275 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec
*codec
,
3276 const struct auto_pin_cfg
*cfg
)
3278 struct sigmatel_spec
*spec
= codec
->spec
;
3283 err
= create_multi_out_ctls(codec
, cfg
->line_outs
, cfg
->line_out_pins
,
3284 spec
->multiout
.dac_nids
,
3285 cfg
->line_out_type
);
3289 if (cfg
->hp_outs
> 1 && cfg
->line_out_type
== AUTO_PIN_LINE_OUT
) {
3290 err
= stac92xx_add_control(spec
,
3291 STAC_CTL_WIDGET_HP_SWITCH
,
3292 "Headphone as Line Out Switch",
3293 cfg
->hp_pins
[cfg
->hp_outs
- 1]);
3298 for (idx
= 0; idx
< cfg
->num_inputs
; idx
++) {
3299 if (cfg
->inputs
[idx
].type
> AUTO_PIN_LINE_IN
)
3301 nid
= cfg
->inputs
[idx
].pin
;
3302 err
= stac92xx_add_jack_mode_control(codec
, nid
, idx
);
3310 /* add playback controls for Speaker and HP outputs */
3311 static int stac92xx_auto_create_hp_ctls(struct hda_codec
*codec
,
3312 struct auto_pin_cfg
*cfg
)
3314 struct sigmatel_spec
*spec
= codec
->spec
;
3317 err
= create_multi_out_ctls(codec
, cfg
->hp_outs
, cfg
->hp_pins
,
3318 spec
->hp_dacs
, AUTO_PIN_HP_OUT
);
3322 err
= create_multi_out_ctls(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
,
3323 spec
->speaker_dacs
, AUTO_PIN_SPEAKER_OUT
);
3330 /* labels for mono mux outputs */
3331 static const char * const stac92xx_mono_labels
[4] = {
3332 "DAC0", "DAC1", "Mixer", "DAC2"
3335 /* create mono mux for mono out on capable codecs */
3336 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec
*codec
)
3338 struct sigmatel_spec
*spec
= codec
->spec
;
3339 struct hda_input_mux
*mono_mux
= &spec
->private_mono_mux
;
3341 hda_nid_t con_lst
[ARRAY_SIZE(stac92xx_mono_labels
)];
3343 num_cons
= snd_hda_get_connections(codec
,
3346 HDA_MAX_NUM_INPUTS
);
3347 if (num_cons
<= 0 || num_cons
> ARRAY_SIZE(stac92xx_mono_labels
))
3350 for (i
= 0; i
< num_cons
; i
++)
3351 snd_hda_add_imux_item(mono_mux
, stac92xx_mono_labels
[i
], i
,
3354 return stac92xx_add_control(spec
, STAC_CTL_WIDGET_MONO_MUX
,
3355 "Mono Mux", spec
->mono_nid
);
3358 /* create PC beep volume controls */
3359 static int stac92xx_auto_create_beep_ctls(struct hda_codec
*codec
,
3362 struct sigmatel_spec
*spec
= codec
->spec
;
3363 u32 caps
= query_amp_caps(codec
, nid
, HDA_OUTPUT
);
3364 int err
, type
= STAC_CTL_WIDGET_MUTE_BEEP
;
3366 if (spec
->anabeep_nid
== nid
)
3367 type
= STAC_CTL_WIDGET_MUTE
;
3369 /* check for mute support for the the amp */
3370 if ((caps
& AC_AMPCAP_MUTE
) >> AC_AMPCAP_MUTE_SHIFT
) {
3371 err
= stac92xx_add_control(spec
, type
,
3372 "Beep Playback Switch",
3373 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, HDA_OUTPUT
));
3378 /* check to see if there is volume support for the amp */
3379 if ((caps
& AC_AMPCAP_NUM_STEPS
) >> AC_AMPCAP_NUM_STEPS_SHIFT
) {
3380 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_VOL
,
3381 "Beep Playback Volume",
3382 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, HDA_OUTPUT
));
3389 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3390 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3392 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol
*kcontrol
,
3393 struct snd_ctl_elem_value
*ucontrol
)
3395 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3396 ucontrol
->value
.integer
.value
[0] = codec
->beep
->enabled
;
3400 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol
*kcontrol
,
3401 struct snd_ctl_elem_value
*ucontrol
)
3403 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3404 return snd_hda_enable_beep_device(codec
, ucontrol
->value
.integer
.value
[0]);
3407 static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl
= {
3408 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3409 .info
= stac92xx_dig_beep_switch_info
,
3410 .get
= stac92xx_dig_beep_switch_get
,
3411 .put
= stac92xx_dig_beep_switch_put
,
3414 static int stac92xx_beep_switch_ctl(struct hda_codec
*codec
)
3416 return stac92xx_add_control_temp(codec
->spec
, &stac92xx_dig_beep_ctrl
,
3417 0, "Beep Playback Switch", 0);
3421 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec
*codec
)
3423 struct sigmatel_spec
*spec
= codec
->spec
;
3426 for (i
= 0; i
< spec
->num_muxes
; i
++) {
3431 nid
= spec
->mux_nids
[i
];
3432 wcaps
= get_wcaps(codec
, nid
);
3433 if (!(wcaps
& AC_WCAP_OUT_AMP
))
3436 /* check whether already the same control was created as
3437 * normal Capture Volume.
3439 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
3440 for (j
= 0; j
< spec
->num_caps
; j
++) {
3441 if (spec
->capvols
[j
] == val
)
3444 if (j
< spec
->num_caps
)
3447 err
= stac92xx_add_control_idx(spec
, STAC_CTL_WIDGET_VOL
, i
,
3448 "Mux Capture Volume", val
);
3455 static const char * const stac92xx_spdif_labels
[3] = {
3456 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3459 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec
*codec
)
3461 struct sigmatel_spec
*spec
= codec
->spec
;
3462 struct hda_input_mux
*spdif_mux
= &spec
->private_smux
;
3463 const char * const *labels
= spec
->spdif_labels
;
3465 hda_nid_t con_lst
[HDA_MAX_NUM_INPUTS
];
3467 num_cons
= snd_hda_get_connections(codec
,
3470 HDA_MAX_NUM_INPUTS
);
3475 labels
= stac92xx_spdif_labels
;
3477 for (i
= 0; i
< num_cons
; i
++)
3478 snd_hda_add_imux_item(spdif_mux
, labels
[i
], i
, NULL
);
3483 /* labels for dmic mux inputs */
3484 static const char * const stac92xx_dmic_labels
[5] = {
3485 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3486 "Digital Mic 3", "Digital Mic 4"
3489 static hda_nid_t
get_connected_node(struct hda_codec
*codec
, hda_nid_t mux
,
3492 hda_nid_t conn
[HDA_MAX_NUM_INPUTS
];
3494 nums
= snd_hda_get_connections(codec
, mux
, conn
, ARRAY_SIZE(conn
));
3495 if (idx
>= 0 && idx
< nums
)
3500 /* look for NID recursively */
3501 #define get_connection_index(codec, mux, nid) \
3502 snd_hda_get_conn_index(codec, mux, nid, 1)
3504 /* create a volume assigned to the given pin (only if supported) */
3505 /* return 1 if the volume control is created */
3506 static int create_elem_capture_vol(struct hda_codec
*codec
, hda_nid_t nid
,
3507 const char *label
, int idx
, int direction
)
3509 unsigned int caps
, nums
;
3513 if (direction
== HDA_OUTPUT
)
3514 caps
= AC_WCAP_OUT_AMP
;
3516 caps
= AC_WCAP_IN_AMP
;
3517 if (!(get_wcaps(codec
, nid
) & caps
))
3519 caps
= query_amp_caps(codec
, nid
, direction
);
3520 nums
= (caps
& AC_AMPCAP_NUM_STEPS
) >> AC_AMPCAP_NUM_STEPS_SHIFT
;
3523 snprintf(name
, sizeof(name
), "%s Capture Volume", label
);
3524 err
= stac92xx_add_control_idx(codec
->spec
, STAC_CTL_WIDGET_VOL
, idx
, name
,
3525 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, direction
));
3531 /* create playback/capture controls for input pins on dmic capable codecs */
3532 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec
*codec
,
3533 const struct auto_pin_cfg
*cfg
)
3535 struct sigmatel_spec
*spec
= codec
->spec
;
3536 struct hda_input_mux
*imux
= &spec
->private_imux
;
3537 struct hda_input_mux
*dimux
= &spec
->private_dimux
;
3539 unsigned int def_conf
;
3541 snd_hda_add_imux_item(dimux
, stac92xx_dmic_labels
[0], 0, NULL
);
3543 for (i
= 0; i
< spec
->num_dmics
; i
++) {
3545 int index
, type_idx
;
3548 nid
= spec
->dmic_nids
[i
];
3549 if (get_wcaps_type(get_wcaps(codec
, nid
)) != AC_WID_PIN
)
3551 def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
3552 if (get_defcfg_connect(def_conf
) == AC_JACK_PORT_NONE
)
3555 index
= get_connection_index(codec
, spec
->dmux_nids
[0], nid
);
3559 label
= hda_get_input_pin_label(codec
, nid
, 1);
3560 snd_hda_add_imux_item(dimux
, label
, index
, &type_idx
);
3561 if (snd_hda_get_bool_hint(codec
, "separate_dmux") != 1)
3562 snd_hda_add_imux_item(imux
, label
, index
, &type_idx
);
3564 err
= create_elem_capture_vol(codec
, nid
, label
, type_idx
,
3569 err
= create_elem_capture_vol(codec
, nid
, label
,
3570 type_idx
, HDA_OUTPUT
);
3574 nid
= get_connected_node(codec
,
3575 spec
->dmux_nids
[0], index
);
3577 err
= create_elem_capture_vol(codec
,
3579 type_idx
, HDA_INPUT
);
3589 static int check_mic_pin(struct hda_codec
*codec
, hda_nid_t nid
,
3590 hda_nid_t
*fixed
, hda_nid_t
*ext
, hda_nid_t
*dock
)
3597 cfg
= snd_hda_codec_get_pincfg(codec
, nid
);
3598 type
= get_defcfg_device(cfg
);
3599 switch (snd_hda_get_input_pin_attr(cfg
)) {
3600 case INPUT_PIN_ATTR_INT
:
3602 return 1; /* already occupied */
3603 if (type
!= AC_JACK_MIC_IN
)
3604 return 1; /* invalid type */
3607 case INPUT_PIN_ATTR_UNUSED
:
3609 case INPUT_PIN_ATTR_DOCK
:
3611 return 1; /* already occupied */
3612 if (type
!= AC_JACK_MIC_IN
&& type
!= AC_JACK_LINE_IN
)
3613 return 1; /* invalid type */
3618 return 1; /* already occupied */
3619 if (type
!= AC_JACK_MIC_IN
)
3620 return 1; /* invalid type */
3627 static int set_mic_route(struct hda_codec
*codec
,
3628 struct sigmatel_mic_route
*mic
,
3631 struct sigmatel_spec
*spec
= codec
->spec
;
3632 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3638 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3639 if (pin
== cfg
->inputs
[i
].pin
)
3642 if (i
< cfg
->num_inputs
&& cfg
->inputs
[i
].type
== AUTO_PIN_MIC
) {
3644 i
= get_connection_index(codec
, spec
->mux_nids
[0], pin
);
3649 if (spec
->dmux_nids
)
3650 mic
->dmux_idx
= get_connection_index(codec
,
3653 } else if (spec
->dmux_nids
) {
3655 i
= get_connection_index(codec
, spec
->dmux_nids
[0], pin
);
3661 mic
->mux_idx
= get_connection_index(codec
,
3663 spec
->dmux_nids
[0]);
3668 /* return non-zero if the device is for automatic mic switch */
3669 static int stac_check_auto_mic(struct hda_codec
*codec
)
3671 struct sigmatel_spec
*spec
= codec
->spec
;
3672 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3673 hda_nid_t fixed
, ext
, dock
;
3676 fixed
= ext
= dock
= 0;
3677 for (i
= 0; i
< cfg
->num_inputs
; i
++)
3678 if (check_mic_pin(codec
, cfg
->inputs
[i
].pin
,
3679 &fixed
, &ext
, &dock
))
3681 for (i
= 0; i
< spec
->num_dmics
; i
++)
3682 if (check_mic_pin(codec
, spec
->dmic_nids
[i
],
3683 &fixed
, &ext
, &dock
))
3685 if (!fixed
|| (!ext
&& !dock
))
3686 return 0; /* no input to switch */
3687 if (!is_jack_detectable(codec
, ext
))
3688 return 0; /* no unsol support */
3689 if (set_mic_route(codec
, &spec
->ext_mic
, ext
) ||
3690 set_mic_route(codec
, &spec
->int_mic
, fixed
) ||
3691 set_mic_route(codec
, &spec
->dock_mic
, dock
))
3692 return 0; /* something is wrong */
3696 /* create playback/capture controls for input pins */
3697 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec
*codec
, const struct auto_pin_cfg
*cfg
)
3699 struct sigmatel_spec
*spec
= codec
->spec
;
3700 struct hda_input_mux
*imux
= &spec
->private_imux
;
3704 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
3705 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
3706 int index
, err
, type_idx
;
3709 for (j
= 0; j
< spec
->num_muxes
; j
++) {
3710 index
= get_connection_index(codec
, spec
->mux_nids
[j
],
3718 label
= hda_get_autocfg_input_label(codec
, cfg
, i
);
3719 snd_hda_add_imux_item(imux
, label
, index
, &type_idx
);
3721 err
= create_elem_capture_vol(codec
, nid
,
3727 spec
->num_analog_muxes
= imux
->num_items
;
3729 if (imux
->num_items
) {
3731 * Set the current input for the muxes.
3732 * The STAC9221 has two input muxes with identical source
3733 * NID lists. Hopefully this won't get confused.
3735 for (i
= 0; i
< spec
->num_muxes
; i
++) {
3736 snd_hda_codec_write_cache(codec
, spec
->mux_nids
[i
], 0,
3737 AC_VERB_SET_CONNECT_SEL
,
3738 imux
->items
[0].index
);
3745 static void stac92xx_auto_init_multi_out(struct hda_codec
*codec
)
3747 struct sigmatel_spec
*spec
= codec
->spec
;
3750 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
3751 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
3752 stac92xx_auto_set_pinctl(codec
, nid
, AC_PINCTL_OUT_EN
);
3756 static void stac92xx_auto_init_hp_out(struct hda_codec
*codec
)
3758 struct sigmatel_spec
*spec
= codec
->spec
;
3761 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
3763 pin
= spec
->autocfg
.hp_pins
[i
];
3764 if (pin
) /* connect to front */
3765 stac92xx_auto_set_pinctl(codec
, pin
, AC_PINCTL_OUT_EN
| AC_PINCTL_HP_EN
);
3767 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++) {
3769 pin
= spec
->autocfg
.speaker_pins
[i
];
3770 if (pin
) /* connect to front */
3771 stac92xx_auto_set_pinctl(codec
, pin
, AC_PINCTL_OUT_EN
);
3775 static int is_dual_headphones(struct hda_codec
*codec
)
3777 struct sigmatel_spec
*spec
= codec
->spec
;
3780 if (spec
->autocfg
.line_out_type
!= AUTO_PIN_SPEAKER_OUT
||
3781 spec
->autocfg
.hp_outs
<= 1)
3784 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
3785 hda_nid_t nid
= spec
->autocfg
.hp_pins
[i
];
3786 unsigned int cfg
= snd_hda_codec_get_pincfg(codec
, nid
);
3787 if (get_defcfg_location(cfg
) & AC_JACK_LOC_SEPARATE
)
3791 return (valid_hps
> 1);
3795 static int stac92xx_parse_auto_config(struct hda_codec
*codec
)
3797 struct sigmatel_spec
*spec
= codec
->spec
;
3798 hda_nid_t dig_out
= 0, dig_in
= 0;
3802 if ((err
= snd_hda_parse_pin_def_config(codec
,
3804 spec
->dmic_nids
)) < 0)
3806 if (! spec
->autocfg
.line_outs
)
3807 return 0; /* can't find valid pin config */
3809 /* If we have no real line-out pin and multiple hp-outs, HPs should
3810 * be set up as multi-channel outputs.
3812 if (is_dual_headphones(codec
)) {
3813 /* Copy hp_outs to line_outs, backup line_outs in
3814 * speaker_outs so that the following routines can handle
3815 * HP pins as primary outputs.
3817 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3818 memcpy(spec
->autocfg
.speaker_pins
, spec
->autocfg
.line_out_pins
,
3819 sizeof(spec
->autocfg
.line_out_pins
));
3820 spec
->autocfg
.speaker_outs
= spec
->autocfg
.line_outs
;
3821 memcpy(spec
->autocfg
.line_out_pins
, spec
->autocfg
.hp_pins
,
3822 sizeof(spec
->autocfg
.hp_pins
));
3823 spec
->autocfg
.line_outs
= spec
->autocfg
.hp_outs
;
3824 spec
->autocfg
.line_out_type
= AUTO_PIN_HP_OUT
;
3825 spec
->autocfg
.hp_outs
= 0;
3828 if (spec
->autocfg
.mono_out_pin
) {
3829 int dir
= get_wcaps(codec
, spec
->autocfg
.mono_out_pin
) &
3830 (AC_WCAP_OUT_AMP
| AC_WCAP_IN_AMP
);
3831 u32 caps
= query_amp_caps(codec
,
3832 spec
->autocfg
.mono_out_pin
, dir
);
3833 hda_nid_t conn_list
[1];
3835 /* get the mixer node and then the mono mux if it exists */
3836 if (snd_hda_get_connections(codec
,
3837 spec
->autocfg
.mono_out_pin
, conn_list
, 1) &&
3838 snd_hda_get_connections(codec
, conn_list
[0],
3839 conn_list
, 1) > 0) {
3841 int wcaps
= get_wcaps(codec
, conn_list
[0]);
3842 int wid_type
= get_wcaps_type(wcaps
);
3843 /* LR swap check, some stac925x have a mux that
3844 * changes the DACs output path instead of the
3847 if (wid_type
== AC_WID_AUD_SEL
&&
3848 !(wcaps
& AC_WCAP_LR_SWAP
))
3849 spec
->mono_nid
= conn_list
[0];
3852 hda_nid_t nid
= spec
->autocfg
.mono_out_pin
;
3854 /* most mono outs have a least a mute/unmute switch */
3855 dir
= (dir
& AC_WCAP_OUT_AMP
) ? HDA_OUTPUT
: HDA_INPUT
;
3856 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_MUTE
,
3857 "Mono Playback Switch",
3858 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, dir
));
3861 /* check for volume support for the amp */
3862 if ((caps
& AC_AMPCAP_NUM_STEPS
)
3863 >> AC_AMPCAP_NUM_STEPS_SHIFT
) {
3864 err
= stac92xx_add_control(spec
,
3865 STAC_CTL_WIDGET_VOL
,
3866 "Mono Playback Volume",
3867 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, dir
));
3873 stac92xx_auto_set_pinctl(codec
, spec
->autocfg
.mono_out_pin
,
3877 if (!spec
->multiout
.num_dacs
) {
3878 err
= stac92xx_auto_fill_dac_nids(codec
);
3881 err
= stac92xx_auto_create_multi_out_ctls(codec
,
3887 /* setup analog beep controls */
3888 if (spec
->anabeep_nid
> 0) {
3889 err
= stac92xx_auto_create_beep_ctls(codec
,
3895 /* setup digital beep controls and input device */
3896 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3897 if (spec
->digbeep_nid
> 0) {
3898 hda_nid_t nid
= spec
->digbeep_nid
;
3901 err
= stac92xx_auto_create_beep_ctls(codec
, nid
);
3904 err
= snd_hda_attach_beep_device(codec
, nid
);
3908 /* IDT/STAC codecs have linear beep tone parameter */
3909 codec
->beep
->linear_tone
= spec
->linear_tone_beep
;
3910 /* if no beep switch is available, make its own one */
3911 caps
= query_amp_caps(codec
, nid
, HDA_OUTPUT
);
3912 if (!(caps
& AC_AMPCAP_MUTE
)) {
3913 err
= stac92xx_beep_switch_ctl(codec
);
3921 err
= stac92xx_auto_create_hp_ctls(codec
, &spec
->autocfg
);
3925 /* All output parsing done, now restore the swapped hp pins */
3927 memcpy(spec
->autocfg
.hp_pins
, spec
->autocfg
.line_out_pins
,
3928 sizeof(spec
->autocfg
.hp_pins
));
3929 spec
->autocfg
.hp_outs
= spec
->autocfg
.line_outs
;
3930 spec
->autocfg
.line_out_type
= AUTO_PIN_HP_OUT
;
3931 spec
->autocfg
.line_outs
= 0;
3934 if (stac_check_auto_mic(codec
)) {
3936 /* only one capture for auto-mic */
3939 spec
->num_muxes
= 1;
3942 for (i
= 0; i
< spec
->num_caps
; i
++) {
3943 err
= stac92xx_add_capvol_ctls(codec
, spec
->capvols
[i
],
3944 spec
->capsws
[i
], i
);
3949 err
= stac92xx_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
3953 if (spec
->mono_nid
> 0) {
3954 err
= stac92xx_auto_create_mono_output_ctls(codec
);
3958 if (spec
->num_dmics
> 0 && !spec
->dinput_mux
)
3959 if ((err
= stac92xx_auto_create_dmic_input_ctls(codec
,
3960 &spec
->autocfg
)) < 0)
3962 if (spec
->num_muxes
> 0) {
3963 err
= stac92xx_auto_create_mux_input_ctls(codec
);
3967 if (spec
->num_smuxes
> 0) {
3968 err
= stac92xx_auto_create_spdif_mux_ctls(codec
);
3973 err
= stac92xx_add_input_source(spec
);
3977 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3978 if (spec
->multiout
.max_channels
> 2)
3979 spec
->surr_switch
= 1;
3981 /* find digital out and in converters */
3982 for (i
= codec
->start_nid
; i
< codec
->start_nid
+ codec
->num_nodes
; i
++) {
3983 unsigned int wid_caps
= get_wcaps(codec
, i
);
3984 if (wid_caps
& AC_WCAP_DIGITAL
) {
3985 switch (get_wcaps_type(wid_caps
)) {
3986 case AC_WID_AUD_OUT
:
3997 if (spec
->autocfg
.dig_outs
)
3998 spec
->multiout
.dig_out_nid
= dig_out
;
3999 if (dig_in
&& spec
->autocfg
.dig_in_pin
)
4000 spec
->dig_in_nid
= dig_in
;
4002 if (spec
->kctls
.list
)
4003 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
4005 spec
->input_mux
= &spec
->private_imux
;
4006 if (!spec
->dinput_mux
)
4007 spec
->dinput_mux
= &spec
->private_dimux
;
4008 spec
->sinput_mux
= &spec
->private_smux
;
4009 spec
->mono_mux
= &spec
->private_mono_mux
;
4013 /* add playback controls for HP output */
4014 static int stac9200_auto_create_hp_ctls(struct hda_codec
*codec
,
4015 struct auto_pin_cfg
*cfg
)
4017 struct sigmatel_spec
*spec
= codec
->spec
;
4018 hda_nid_t pin
= cfg
->hp_pins
[0];
4023 if (is_jack_detectable(codec
, pin
))
4024 spec
->hp_detect
= 1;
4029 /* add playback controls for LFE output */
4030 static int stac9200_auto_create_lfe_ctls(struct hda_codec
*codec
,
4031 struct auto_pin_cfg
*cfg
)
4033 struct sigmatel_spec
*spec
= codec
->spec
;
4035 hda_nid_t lfe_pin
= 0x0;
4039 * search speaker outs and line outs for a mono speaker pin
4040 * with an amp. If one is found, add LFE controls
4043 for (i
= 0; i
< spec
->autocfg
.speaker_outs
&& lfe_pin
== 0x0; i
++) {
4044 hda_nid_t pin
= spec
->autocfg
.speaker_pins
[i
];
4045 unsigned int wcaps
= get_wcaps(codec
, pin
);
4046 wcaps
&= (AC_WCAP_STEREO
| AC_WCAP_OUT_AMP
);
4047 if (wcaps
== AC_WCAP_OUT_AMP
)
4048 /* found a mono speaker with an amp, must be lfe */
4052 /* if speaker_outs is 0, then speakers may be in line_outs */
4053 if (lfe_pin
== 0 && spec
->autocfg
.speaker_outs
== 0) {
4054 for (i
= 0; i
< spec
->autocfg
.line_outs
&& lfe_pin
== 0x0; i
++) {
4055 hda_nid_t pin
= spec
->autocfg
.line_out_pins
[i
];
4056 unsigned int defcfg
;
4057 defcfg
= snd_hda_codec_get_pincfg(codec
, pin
);
4058 if (get_defcfg_device(defcfg
) == AC_JACK_SPEAKER
) {
4059 unsigned int wcaps
= get_wcaps(codec
, pin
);
4060 wcaps
&= (AC_WCAP_STEREO
| AC_WCAP_OUT_AMP
);
4061 if (wcaps
== AC_WCAP_OUT_AMP
)
4062 /* found a mono speaker with an amp,
4070 err
= create_controls(codec
, "LFE", lfe_pin
, 1);
4078 static int stac9200_parse_auto_config(struct hda_codec
*codec
)
4080 struct sigmatel_spec
*spec
= codec
->spec
;
4083 if ((err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
)) < 0)
4086 if ((err
= stac92xx_auto_create_analog_input_ctls(codec
, &spec
->autocfg
)) < 0)
4089 if ((err
= stac9200_auto_create_hp_ctls(codec
, &spec
->autocfg
)) < 0)
4092 if ((err
= stac9200_auto_create_lfe_ctls(codec
, &spec
->autocfg
)) < 0)
4095 if (spec
->num_muxes
> 0) {
4096 err
= stac92xx_auto_create_mux_input_ctls(codec
);
4101 err
= stac92xx_add_input_source(spec
);
4105 if (spec
->autocfg
.dig_outs
)
4106 spec
->multiout
.dig_out_nid
= 0x05;
4107 if (spec
->autocfg
.dig_in_pin
)
4108 spec
->dig_in_nid
= 0x04;
4110 if (spec
->kctls
.list
)
4111 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
4113 spec
->input_mux
= &spec
->private_imux
;
4114 spec
->dinput_mux
= &spec
->private_dimux
;
4120 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4121 * funky external mute control using GPIO pins.
4124 static void stac_gpio_set(struct hda_codec
*codec
, unsigned int mask
,
4125 unsigned int dir_mask
, unsigned int data
)
4127 unsigned int gpiostate
, gpiomask
, gpiodir
;
4129 snd_printdd("%s msk %x dir %x gpio %x\n", __func__
, mask
, dir_mask
, data
);
4131 gpiostate
= snd_hda_codec_read(codec
, codec
->afg
, 0,
4132 AC_VERB_GET_GPIO_DATA
, 0);
4133 gpiostate
= (gpiostate
& ~dir_mask
) | (data
& dir_mask
);
4135 gpiomask
= snd_hda_codec_read(codec
, codec
->afg
, 0,
4136 AC_VERB_GET_GPIO_MASK
, 0);
4139 gpiodir
= snd_hda_codec_read(codec
, codec
->afg
, 0,
4140 AC_VERB_GET_GPIO_DIRECTION
, 0);
4141 gpiodir
|= dir_mask
;
4143 /* Configure GPIOx as CMOS */
4144 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7e7, 0);
4146 snd_hda_codec_write(codec
, codec
->afg
, 0,
4147 AC_VERB_SET_GPIO_MASK
, gpiomask
);
4148 snd_hda_codec_read(codec
, codec
->afg
, 0,
4149 AC_VERB_SET_GPIO_DIRECTION
, gpiodir
); /* sync */
4153 snd_hda_codec_read(codec
, codec
->afg
, 0,
4154 AC_VERB_SET_GPIO_DATA
, gpiostate
); /* sync */
4157 static int stac92xx_add_jack(struct hda_codec
*codec
,
4158 hda_nid_t nid
, int type
)
4160 #ifdef CONFIG_SND_HDA_INPUT_JACK
4161 int def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
4162 int connectivity
= get_defcfg_connect(def_conf
);
4164 if (connectivity
&& connectivity
!= AC_JACK_PORT_FIXED
)
4167 return snd_hda_input_jack_add(codec
, nid
, type
, NULL
);
4170 #endif /* CONFIG_SND_HDA_INPUT_JACK */
4173 static int stac_add_event(struct sigmatel_spec
*spec
, hda_nid_t nid
,
4174 unsigned char type
, int data
)
4176 struct sigmatel_event
*event
;
4178 snd_array_init(&spec
->events
, sizeof(*event
), 32);
4179 event
= snd_array_new(&spec
->events
);
4184 event
->tag
= spec
->events
.used
;
4190 static struct sigmatel_event
*stac_get_event(struct hda_codec
*codec
,
4193 struct sigmatel_spec
*spec
= codec
->spec
;
4194 struct sigmatel_event
*event
= spec
->events
.list
;
4197 for (i
= 0; i
< spec
->events
.used
; i
++, event
++) {
4198 if (event
->nid
== nid
)
4204 static struct sigmatel_event
*stac_get_event_from_tag(struct hda_codec
*codec
,
4207 struct sigmatel_spec
*spec
= codec
->spec
;
4208 struct sigmatel_event
*event
= spec
->events
.list
;
4211 for (i
= 0; i
< spec
->events
.used
; i
++, event
++) {
4212 if (event
->tag
== tag
)
4218 /* check if given nid is a valid pin and no other events are assigned
4219 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4220 * Otherwise, returns zero.
4222 static int enable_pin_detect(struct hda_codec
*codec
, hda_nid_t nid
,
4225 struct sigmatel_event
*event
;
4228 if (!is_jack_detectable(codec
, nid
))
4230 event
= stac_get_event(codec
, nid
);
4232 if (event
->type
!= type
)
4236 tag
= stac_add_event(codec
->spec
, nid
, type
, 0);
4240 snd_hda_codec_write_cache(codec
, nid
, 0,
4241 AC_VERB_SET_UNSOLICITED_ENABLE
,
4246 static int is_nid_hp_pin(struct auto_pin_cfg
*cfg
, hda_nid_t nid
)
4249 for (i
= 0; i
< cfg
->hp_outs
; i
++)
4250 if (cfg
->hp_pins
[i
] == nid
)
4251 return 1; /* nid is a HP-Out */
4253 return 0; /* nid is not a HP-Out */
4256 static void stac92xx_power_down(struct hda_codec
*codec
)
4258 struct sigmatel_spec
*spec
= codec
->spec
;
4260 /* power down inactive DACs */
4261 const hda_nid_t
*dac
;
4262 for (dac
= spec
->dac_list
; *dac
; dac
++)
4263 if (!check_all_dac_nids(spec
, *dac
))
4264 snd_hda_codec_write(codec
, *dac
, 0,
4265 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
4268 static void stac_toggle_power_map(struct hda_codec
*codec
, hda_nid_t nid
,
4271 static inline int get_int_hint(struct hda_codec
*codec
, const char *key
,
4275 p
= snd_hda_get_hint(codec
, key
);
4278 if (!strict_strtoul(p
, 0, &val
)) {
4286 /* override some hints from the hwdep entry */
4287 static void stac_store_hints(struct hda_codec
*codec
)
4289 struct sigmatel_spec
*spec
= codec
->spec
;
4292 val
= snd_hda_get_bool_hint(codec
, "hp_detect");
4294 spec
->hp_detect
= val
;
4295 if (get_int_hint(codec
, "gpio_mask", &spec
->gpio_mask
)) {
4296 spec
->eapd_mask
= spec
->gpio_dir
= spec
->gpio_data
=
4299 if (get_int_hint(codec
, "gpio_dir", &spec
->gpio_dir
))
4300 spec
->gpio_mask
&= spec
->gpio_mask
;
4301 if (get_int_hint(codec
, "gpio_data", &spec
->gpio_data
))
4302 spec
->gpio_dir
&= spec
->gpio_mask
;
4303 if (get_int_hint(codec
, "eapd_mask", &spec
->eapd_mask
))
4304 spec
->eapd_mask
&= spec
->gpio_mask
;
4305 if (get_int_hint(codec
, "gpio_mute", &spec
->gpio_mute
))
4306 spec
->gpio_mute
&= spec
->gpio_mask
;
4307 val
= snd_hda_get_bool_hint(codec
, "eapd_switch");
4309 spec
->eapd_switch
= val
;
4310 get_int_hint(codec
, "gpio_led_polarity", &spec
->gpio_led_polarity
);
4311 if (get_int_hint(codec
, "gpio_led", &spec
->gpio_led
)) {
4312 if (spec
->gpio_led
<= 8) {
4313 spec
->gpio_mask
|= spec
->gpio_led
;
4314 spec
->gpio_dir
|= spec
->gpio_led
;
4315 if (spec
->gpio_led_polarity
)
4316 spec
->gpio_data
|= spec
->gpio_led
;
4321 static int stac92xx_init(struct hda_codec
*codec
)
4323 struct sigmatel_spec
*spec
= codec
->spec
;
4324 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4328 snd_hda_sequence_write(codec
, spec
->init
);
4330 /* power down adcs initially */
4331 if (spec
->powerdown_adcs
)
4332 for (i
= 0; i
< spec
->num_adcs
; i
++)
4333 snd_hda_codec_write(codec
,
4334 spec
->adc_nids
[i
], 0,
4335 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
4337 /* override some hints */
4338 stac_store_hints(codec
);
4341 gpio
= spec
->gpio_data
;
4342 /* turn on EAPD statically when spec->eapd_switch isn't set.
4343 * otherwise, unsol event will turn it on/off dynamically
4345 if (!spec
->eapd_switch
)
4346 gpio
|= spec
->eapd_mask
;
4347 stac_gpio_set(codec
, spec
->gpio_mask
, spec
->gpio_dir
, gpio
);
4350 if (spec
->hp_detect
) {
4351 /* Enable unsolicited responses on the HP widget */
4352 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
4353 hda_nid_t nid
= cfg
->hp_pins
[i
];
4354 enable_pin_detect(codec
, nid
, STAC_HP_EVENT
);
4356 if (cfg
->line_out_type
== AUTO_PIN_LINE_OUT
&&
4357 cfg
->speaker_outs
> 0) {
4358 /* enable pin-detect for line-outs as well */
4359 for (i
= 0; i
< cfg
->line_outs
; i
++) {
4360 hda_nid_t nid
= cfg
->line_out_pins
[i
];
4361 enable_pin_detect(codec
, nid
, STAC_LO_EVENT
);
4365 /* force to enable the first line-out; the others are set up
4368 stac92xx_auto_set_pinctl(codec
, spec
->autocfg
.line_out_pins
[0],
4370 /* fake event to set up pins */
4371 if (cfg
->hp_pins
[0])
4372 stac_issue_unsol_event(codec
, cfg
->hp_pins
[0]);
4373 else if (cfg
->line_out_pins
[0])
4374 stac_issue_unsol_event(codec
, cfg
->line_out_pins
[0]);
4376 stac92xx_auto_init_multi_out(codec
);
4377 stac92xx_auto_init_hp_out(codec
);
4378 for (i
= 0; i
< cfg
->hp_outs
; i
++)
4379 stac_toggle_power_map(codec
, cfg
->hp_pins
[i
], 1);
4381 if (spec
->auto_mic
) {
4382 /* initialize connection to analog input */
4383 if (spec
->dmux_nids
)
4384 snd_hda_codec_write_cache(codec
, spec
->dmux_nids
[0], 0,
4385 AC_VERB_SET_CONNECT_SEL
, 0);
4386 if (enable_pin_detect(codec
, spec
->ext_mic
.pin
, STAC_MIC_EVENT
))
4387 stac_issue_unsol_event(codec
, spec
->ext_mic
.pin
);
4388 if (enable_pin_detect(codec
, spec
->dock_mic
.pin
,
4390 stac_issue_unsol_event(codec
, spec
->dock_mic
.pin
);
4392 for (i
= 0; i
< cfg
->num_inputs
; i
++) {
4393 hda_nid_t nid
= cfg
->inputs
[i
].pin
;
4394 int type
= cfg
->inputs
[i
].type
;
4395 unsigned int pinctl
, conf
;
4396 if (type
== AUTO_PIN_MIC
) {
4397 /* for mic pins, force to initialize */
4398 pinctl
= stac92xx_get_default_vref(codec
, nid
);
4399 pinctl
|= AC_PINCTL_IN_EN
;
4400 stac92xx_auto_set_pinctl(codec
, nid
, pinctl
);
4402 pinctl
= snd_hda_codec_read(codec
, nid
, 0,
4403 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
4404 /* if PINCTL already set then skip */
4405 /* Also, if both INPUT and OUTPUT are set,
4406 * it must be a BIOS bug; need to override, too
4408 if (!(pinctl
& AC_PINCTL_IN_EN
) ||
4409 (pinctl
& AC_PINCTL_OUT_EN
)) {
4410 pinctl
&= ~AC_PINCTL_OUT_EN
;
4411 pinctl
|= AC_PINCTL_IN_EN
;
4412 stac92xx_auto_set_pinctl(codec
, nid
, pinctl
);
4415 conf
= snd_hda_codec_get_pincfg(codec
, nid
);
4416 if (get_defcfg_connect(conf
) != AC_JACK_PORT_FIXED
) {
4417 if (enable_pin_detect(codec
, nid
, STAC_INSERT_EVENT
))
4418 stac_issue_unsol_event(codec
, nid
);
4421 for (i
= 0; i
< spec
->num_dmics
; i
++)
4422 stac92xx_auto_set_pinctl(codec
, spec
->dmic_nids
[i
],
4424 if (cfg
->dig_out_pins
[0])
4425 stac92xx_auto_set_pinctl(codec
, cfg
->dig_out_pins
[0],
4427 if (cfg
->dig_in_pin
)
4428 stac92xx_auto_set_pinctl(codec
, cfg
->dig_in_pin
,
4430 for (i
= 0; i
< spec
->num_pwrs
; i
++) {
4431 hda_nid_t nid
= spec
->pwr_nids
[i
];
4432 int pinctl
, def_conf
;
4434 /* power on when no jack detection is available */
4435 if (!spec
->hp_detect
) {
4436 stac_toggle_power_map(codec
, nid
, 1);
4440 if (is_nid_hp_pin(cfg
, nid
))
4441 continue; /* already has an unsol event */
4443 pinctl
= snd_hda_codec_read(codec
, nid
, 0,
4444 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
4445 /* outputs are only ports capable of power management
4446 * any attempts on powering down a input port cause the
4447 * referenced VREF to act quirky.
4449 if (pinctl
& AC_PINCTL_IN_EN
) {
4450 stac_toggle_power_map(codec
, nid
, 1);
4453 def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
4454 def_conf
= get_defcfg_connect(def_conf
);
4455 /* skip any ports that don't have jacks since presence
4456 * detection is useless */
4457 if (def_conf
!= AC_JACK_PORT_COMPLEX
) {
4458 if (def_conf
!= AC_JACK_PORT_NONE
)
4459 stac_toggle_power_map(codec
, nid
, 1);
4462 if (enable_pin_detect(codec
, nid
, STAC_PWR_EVENT
))
4463 stac_issue_unsol_event(codec
, nid
);
4468 hda_call_check_power_status(codec
, 0x01);
4470 stac92xx_power_down(codec
);
4474 static void stac92xx_free_kctls(struct hda_codec
*codec
)
4476 struct sigmatel_spec
*spec
= codec
->spec
;
4478 if (spec
->kctls
.list
) {
4479 struct snd_kcontrol_new
*kctl
= spec
->kctls
.list
;
4481 for (i
= 0; i
< spec
->kctls
.used
; i
++)
4482 kfree(kctl
[i
].name
);
4484 snd_array_free(&spec
->kctls
);
4487 static void stac92xx_shutup_pins(struct hda_codec
*codec
)
4489 unsigned int i
, def_conf
;
4491 if (codec
->bus
->shutdown
)
4493 for (i
= 0; i
< codec
->init_pins
.used
; i
++) {
4494 struct hda_pincfg
*pin
= snd_array_elem(&codec
->init_pins
, i
);
4495 def_conf
= snd_hda_codec_get_pincfg(codec
, pin
->nid
);
4496 if (get_defcfg_connect(def_conf
) != AC_JACK_PORT_NONE
)
4497 snd_hda_codec_write(codec
, pin
->nid
, 0,
4498 AC_VERB_SET_PIN_WIDGET_CONTROL
, 0);
4502 static void stac92xx_shutup(struct hda_codec
*codec
)
4504 struct sigmatel_spec
*spec
= codec
->spec
;
4506 stac92xx_shutup_pins(codec
);
4508 if (spec
->eapd_mask
)
4509 stac_gpio_set(codec
, spec
->gpio_mask
,
4510 spec
->gpio_dir
, spec
->gpio_data
&
4514 static void stac92xx_free(struct hda_codec
*codec
)
4516 struct sigmatel_spec
*spec
= codec
->spec
;
4521 stac92xx_shutup(codec
);
4522 snd_hda_input_jack_free(codec
);
4523 snd_array_free(&spec
->events
);
4526 snd_hda_detach_beep_device(codec
);
4529 static void stac92xx_set_pinctl(struct hda_codec
*codec
, hda_nid_t nid
,
4532 unsigned int old_ctl
, pin_ctl
;
4534 pin_ctl
= snd_hda_codec_read(codec
, nid
,
4535 0, AC_VERB_GET_PIN_WIDGET_CONTROL
, 0x00);
4537 if (pin_ctl
& AC_PINCTL_IN_EN
) {
4539 * we need to check the current set-up direction of
4540 * shared input pins since they can be switched via
4541 * "xxx as Output" mixer switch
4543 struct sigmatel_spec
*spec
= codec
->spec
;
4544 if (nid
== spec
->line_switch
|| nid
== spec
->mic_switch
)
4549 /* if setting pin direction bits, clear the current
4550 direction bits first */
4551 if (flag
& (AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
))
4552 pin_ctl
&= ~(AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
);
4555 if (old_ctl
!= pin_ctl
)
4556 snd_hda_codec_write_cache(codec
, nid
, 0,
4557 AC_VERB_SET_PIN_WIDGET_CONTROL
,
4561 static void stac92xx_reset_pinctl(struct hda_codec
*codec
, hda_nid_t nid
,
4564 unsigned int pin_ctl
= snd_hda_codec_read(codec
, nid
,
4565 0, AC_VERB_GET_PIN_WIDGET_CONTROL
, 0x00);
4567 snd_hda_codec_write_cache(codec
, nid
, 0,
4568 AC_VERB_SET_PIN_WIDGET_CONTROL
,
4572 static inline int get_pin_presence(struct hda_codec
*codec
, hda_nid_t nid
)
4576 return snd_hda_jack_detect(codec
, nid
);
4579 static void stac92xx_line_out_detect(struct hda_codec
*codec
,
4582 struct sigmatel_spec
*spec
= codec
->spec
;
4583 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4586 for (i
= 0; i
< cfg
->line_outs
; i
++) {
4589 presence
= get_pin_presence(codec
, cfg
->line_out_pins
[i
]);
4591 unsigned int pinctl
;
4592 pinctl
= snd_hda_codec_read(codec
,
4593 cfg
->line_out_pins
[i
], 0,
4594 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
4595 if (pinctl
& AC_PINCTL_IN_EN
)
4596 presence
= 0; /* mic- or line-input */
4601 /* disable speakers */
4602 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
4603 stac92xx_reset_pinctl(codec
, cfg
->speaker_pins
[i
],
4605 if (spec
->eapd_mask
&& spec
->eapd_switch
)
4606 stac_gpio_set(codec
, spec
->gpio_mask
,
4607 spec
->gpio_dir
, spec
->gpio_data
&
4610 /* enable speakers */
4611 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
4612 stac92xx_set_pinctl(codec
, cfg
->speaker_pins
[i
],
4614 if (spec
->eapd_mask
&& spec
->eapd_switch
)
4615 stac_gpio_set(codec
, spec
->gpio_mask
,
4616 spec
->gpio_dir
, spec
->gpio_data
|
4621 /* return non-zero if the hp-pin of the given array index isn't
4622 * a jack-detection target
4624 static int no_hp_sensing(struct sigmatel_spec
*spec
, int i
)
4626 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4628 /* ignore sensing of shared line and mic jacks */
4629 if (cfg
->hp_pins
[i
] == spec
->line_switch
)
4631 if (cfg
->hp_pins
[i
] == spec
->mic_switch
)
4633 /* ignore if the pin is set as line-out */
4634 if (cfg
->hp_pins
[i
] == spec
->hp_switch
)
4639 static void stac92xx_hp_detect(struct hda_codec
*codec
)
4641 struct sigmatel_spec
*spec
= codec
->spec
;
4642 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4646 if (spec
->gpio_mute
)
4647 presence
= !(snd_hda_codec_read(codec
, codec
->afg
, 0,
4648 AC_VERB_GET_GPIO_DATA
, 0) & spec
->gpio_mute
);
4650 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
4653 if (no_hp_sensing(spec
, i
))
4655 presence
= get_pin_presence(codec
, cfg
->hp_pins
[i
]);
4657 unsigned int pinctl
;
4658 pinctl
= snd_hda_codec_read(codec
, cfg
->hp_pins
[i
], 0,
4659 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
4660 if (pinctl
& AC_PINCTL_IN_EN
)
4661 presence
= 0; /* mic- or line-input */
4666 /* disable lineouts */
4667 if (spec
->hp_switch
)
4668 stac92xx_reset_pinctl(codec
, spec
->hp_switch
,
4670 for (i
= 0; i
< cfg
->line_outs
; i
++)
4671 stac92xx_reset_pinctl(codec
, cfg
->line_out_pins
[i
],
4674 /* enable lineouts */
4675 if (spec
->hp_switch
)
4676 stac92xx_set_pinctl(codec
, spec
->hp_switch
,
4678 for (i
= 0; i
< cfg
->line_outs
; i
++)
4679 stac92xx_set_pinctl(codec
, cfg
->line_out_pins
[i
],
4682 stac92xx_line_out_detect(codec
, presence
);
4683 /* toggle hp outs */
4684 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
4685 unsigned int val
= AC_PINCTL_OUT_EN
| AC_PINCTL_HP_EN
;
4686 if (no_hp_sensing(spec
, i
))
4689 stac92xx_set_pinctl(codec
, cfg
->hp_pins
[i
], val
);
4691 /* Resetting the pinctl like below may lead to (a sort of) regressions
4692 * on some devices since they use the HP pin actually for line/speaker
4693 * outs although the default pin config shows a different pin (that is
4694 * wrong and useless).
4696 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4697 * But, disabling the code below just works around it, and I'm too tired of
4698 * bug reports with such devices...
4701 stac92xx_reset_pinctl(codec
, cfg
->hp_pins
[i
], val
);
4706 static void stac_toggle_power_map(struct hda_codec
*codec
, hda_nid_t nid
,
4709 struct sigmatel_spec
*spec
= codec
->spec
;
4710 unsigned int idx
, val
;
4712 for (idx
= 0; idx
< spec
->num_pwrs
; idx
++) {
4713 if (spec
->pwr_nids
[idx
] == nid
)
4716 if (idx
>= spec
->num_pwrs
)
4719 /* several codecs have two power down bits */
4720 if (spec
->pwr_mapping
)
4721 idx
= spec
->pwr_mapping
[idx
];
4725 val
= snd_hda_codec_read(codec
, codec
->afg
, 0, 0x0fec, 0x0) & 0xff;
4731 /* power down unused output ports */
4732 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7ec, val
);
4735 static void stac92xx_pin_sense(struct hda_codec
*codec
, hda_nid_t nid
)
4737 stac_toggle_power_map(codec
, nid
, get_pin_presence(codec
, nid
));
4740 /* get the pin connection (fixed, none, etc) */
4741 static unsigned int stac_get_defcfg_connect(struct hda_codec
*codec
, int idx
)
4743 struct sigmatel_spec
*spec
= codec
->spec
;
4746 cfg
= snd_hda_codec_get_pincfg(codec
, spec
->pin_nids
[idx
]);
4747 return get_defcfg_connect(cfg
);
4750 static int stac92xx_connected_ports(struct hda_codec
*codec
,
4751 const hda_nid_t
*nids
, int num_nids
)
4753 struct sigmatel_spec
*spec
= codec
->spec
;
4755 unsigned int def_conf
;
4757 for (num
= 0; num
< num_nids
; num
++) {
4758 for (idx
= 0; idx
< spec
->num_pins
; idx
++)
4759 if (spec
->pin_nids
[idx
] == nids
[num
])
4761 if (idx
>= spec
->num_pins
)
4763 def_conf
= stac_get_defcfg_connect(codec
, idx
);
4764 if (def_conf
== AC_JACK_PORT_NONE
)
4770 static void stac92xx_mic_detect(struct hda_codec
*codec
)
4772 struct sigmatel_spec
*spec
= codec
->spec
;
4773 struct sigmatel_mic_route
*mic
;
4775 if (get_pin_presence(codec
, spec
->ext_mic
.pin
))
4776 mic
= &spec
->ext_mic
;
4777 else if (get_pin_presence(codec
, spec
->dock_mic
.pin
))
4778 mic
= &spec
->dock_mic
;
4780 mic
= &spec
->int_mic
;
4781 if (mic
->dmux_idx
>= 0)
4782 snd_hda_codec_write_cache(codec
, spec
->dmux_nids
[0], 0,
4783 AC_VERB_SET_CONNECT_SEL
,
4785 if (mic
->mux_idx
>= 0)
4786 snd_hda_codec_write_cache(codec
, spec
->mux_nids
[0], 0,
4787 AC_VERB_SET_CONNECT_SEL
,
4791 static void stac_issue_unsol_event(struct hda_codec
*codec
, hda_nid_t nid
)
4793 struct sigmatel_event
*event
= stac_get_event(codec
, nid
);
4796 codec
->patch_ops
.unsol_event(codec
, (unsigned)event
->tag
<< 26);
4799 static void stac92xx_unsol_event(struct hda_codec
*codec
, unsigned int res
)
4801 struct sigmatel_spec
*spec
= codec
->spec
;
4802 struct sigmatel_event
*event
;
4805 tag
= (res
>> 26) & 0x7f;
4806 event
= stac_get_event_from_tag(codec
, tag
);
4810 switch (event
->type
) {
4813 stac92xx_hp_detect(codec
);
4815 case STAC_MIC_EVENT
:
4816 stac92xx_mic_detect(codec
);
4820 switch (event
->type
) {
4823 case STAC_MIC_EVENT
:
4824 case STAC_INSERT_EVENT
:
4825 case STAC_PWR_EVENT
:
4826 if (spec
->num_pwrs
> 0)
4827 stac92xx_pin_sense(codec
, event
->nid
);
4828 snd_hda_input_jack_report(codec
, event
->nid
);
4830 switch (codec
->subsystem_id
) {
4832 if (event
->nid
== 0xb) {
4833 int pin
= AC_PINCTL_IN_EN
;
4835 if (get_pin_presence(codec
, 0xa)
4836 && get_pin_presence(codec
, 0xb))
4837 pin
|= AC_PINCTL_VREF_80
;
4838 if (!get_pin_presence(codec
, 0xb))
4839 pin
|= AC_PINCTL_VREF_80
;
4841 /* toggle VREF state based on mic + hp pin
4844 stac92xx_auto_set_pinctl(codec
, 0x0a, pin
);
4848 case STAC_VREF_EVENT
:
4849 data
= snd_hda_codec_read(codec
, codec
->afg
, 0,
4850 AC_VERB_GET_GPIO_DATA
, 0);
4851 /* toggle VREF state based on GPIOx status */
4852 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7e0,
4853 !!(data
& (1 << event
->data
)));
4858 static int hp_blike_system(u32 subsystem_id
);
4860 static void set_hp_led_gpio(struct hda_codec
*codec
)
4862 struct sigmatel_spec
*spec
= codec
->spec
;
4868 gpio
= snd_hda_param_read(codec
, codec
->afg
, AC_PAR_GPIO_CAP
);
4869 gpio
&= AC_GPIO_IO_COUNT
;
4871 spec
->gpio_led
= 0x08; /* GPIO 3 */
4873 spec
->gpio_led
= 0x01; /* GPIO 0 */
4877 * This method searches for the mute LED GPIO configuration
4878 * provided as OEM string in SMBIOS. The format of that string
4879 * is HP_Mute_LED_P_G or HP_Mute_LED_P
4880 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
4881 * that corresponds to the NOT muted state of the master volume
4882 * and G is the index of the GPIO to use as the mute LED control (0..9)
4883 * If _G portion is missing it is assigned based on the codec ID
4885 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
4886 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
4889 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
4890 * SMBIOS - at least the ones I have seen do not have them - which include
4891 * my own system (HP Pavilion dv6-1110ax) and my cousin's
4892 * HP Pavilion dv9500t CTO.
4893 * Need more information on whether it is true across the entire series.
4896 static int find_mute_led_gpio(struct hda_codec
*codec
, int default_polarity
)
4898 struct sigmatel_spec
*spec
= codec
->spec
;
4899 const struct dmi_device
*dev
= NULL
;
4901 if ((codec
->subsystem_id
>> 16) == PCI_VENDOR_ID_HP
) {
4902 while ((dev
= dmi_find_device(DMI_DEV_TYPE_OEM_STRING
,
4904 if (sscanf(dev
->name
, "HP_Mute_LED_%d_%x",
4905 &spec
->gpio_led_polarity
,
4906 &spec
->gpio_led
) == 2) {
4907 if (spec
->gpio_led
< 4)
4908 spec
->gpio_led
= 1 << spec
->gpio_led
;
4911 if (sscanf(dev
->name
, "HP_Mute_LED_%d",
4912 &spec
->gpio_led_polarity
) == 1) {
4913 set_hp_led_gpio(codec
);
4919 * Fallback case - if we don't find the DMI strings,
4920 * we statically set the GPIO - if not a B-series system.
4922 if (!hp_blike_system(codec
->subsystem_id
)) {
4923 set_hp_led_gpio(codec
);
4924 spec
->gpio_led_polarity
= default_polarity
;
4931 static int hp_blike_system(u32 subsystem_id
)
4933 switch (subsystem_id
) {
4960 #ifdef CONFIG_PROC_FS
4961 static void stac92hd_proc_hook(struct snd_info_buffer
*buffer
,
4962 struct hda_codec
*codec
, hda_nid_t nid
)
4964 if (nid
== codec
->afg
)
4965 snd_iprintf(buffer
, "Power-Map: 0x%02x\n",
4966 snd_hda_codec_read(codec
, nid
, 0, 0x0fec, 0x0));
4969 static void analog_loop_proc_hook(struct snd_info_buffer
*buffer
,
4970 struct hda_codec
*codec
,
4973 snd_iprintf(buffer
, "Analog Loopback: 0x%02x\n",
4974 snd_hda_codec_read(codec
, codec
->afg
, 0, verb
, 0));
4977 /* stac92hd71bxx, stac92hd73xx */
4978 static void stac92hd7x_proc_hook(struct snd_info_buffer
*buffer
,
4979 struct hda_codec
*codec
, hda_nid_t nid
)
4981 stac92hd_proc_hook(buffer
, codec
, nid
);
4982 if (nid
== codec
->afg
)
4983 analog_loop_proc_hook(buffer
, codec
, 0xfa0);
4986 static void stac9205_proc_hook(struct snd_info_buffer
*buffer
,
4987 struct hda_codec
*codec
, hda_nid_t nid
)
4989 if (nid
== codec
->afg
)
4990 analog_loop_proc_hook(buffer
, codec
, 0xfe0);
4993 static void stac927x_proc_hook(struct snd_info_buffer
*buffer
,
4994 struct hda_codec
*codec
, hda_nid_t nid
)
4996 if (nid
== codec
->afg
)
4997 analog_loop_proc_hook(buffer
, codec
, 0xfeb);
5000 #define stac92hd_proc_hook NULL
5001 #define stac92hd7x_proc_hook NULL
5002 #define stac9205_proc_hook NULL
5003 #define stac927x_proc_hook NULL
5007 static int stac92xx_resume(struct hda_codec
*codec
)
5009 struct sigmatel_spec
*spec
= codec
->spec
;
5011 stac92xx_init(codec
);
5012 snd_hda_codec_resume_amp(codec
);
5013 snd_hda_codec_resume_cache(codec
);
5014 /* fake event to set up pins again to override cached values */
5015 if (spec
->hp_detect
) {
5016 if (spec
->autocfg
.hp_pins
[0])
5017 stac_issue_unsol_event(codec
, spec
->autocfg
.hp_pins
[0]);
5018 else if (spec
->autocfg
.line_out_pins
[0])
5019 stac_issue_unsol_event(codec
,
5020 spec
->autocfg
.line_out_pins
[0]);
5025 static int stac92xx_suspend(struct hda_codec
*codec
, pm_message_t state
)
5027 stac92xx_shutup(codec
);
5031 #ifdef CONFIG_SND_HDA_POWER_SAVE
5032 static int stac92xx_pre_resume(struct hda_codec
*codec
)
5034 struct sigmatel_spec
*spec
= codec
->spec
;
5037 if (spec
->gpio_led
) {
5038 if (spec
->gpio_led
<= 8) {
5039 stac_gpio_set(codec
, spec
->gpio_mask
,
5040 spec
->gpio_dir
, spec
->gpio_data
);
5042 stac_vrefout_set(codec
,
5043 spec
->gpio_led
, spec
->vref_led
);
5049 static int stac92xx_post_suspend(struct hda_codec
*codec
)
5051 struct sigmatel_spec
*spec
= codec
->spec
;
5052 if (spec
->gpio_led
> 8) {
5053 /* with vref-out pin used for mute led control
5054 * codec AFG is prevented from D3 state, but on
5055 * system suspend it can (and should) be used
5057 snd_hda_codec_read(codec
, codec
->afg
, 0,
5058 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
5063 static void stac92xx_set_power_state(struct hda_codec
*codec
, hda_nid_t fg
,
5064 unsigned int power_state
)
5066 unsigned int afg_power_state
= power_state
;
5067 struct sigmatel_spec
*spec
= codec
->spec
;
5069 if (power_state
== AC_PWRST_D3
) {
5070 if (spec
->gpio_led
> 8) {
5071 /* with vref-out pin used for mute led control
5072 * codec AFG is prevented from D3 state
5074 afg_power_state
= AC_PWRST_D1
;
5076 /* this delay seems necessary to avoid click noise at power-down */
5079 snd_hda_codec_read(codec
, fg
, 0, AC_VERB_SET_POWER_STATE
,
5081 snd_hda_codec_set_power_to_all(codec
, fg
, power_state
, true);
5085 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed
5086 * as mute LED state is updated in check_power_status hook
5088 static int stac92xx_update_led_status(struct hda_codec
*codec
)
5090 struct sigmatel_spec
*spec
= codec
->spec
;
5091 int i
, num_ext_dacs
, muted
= 1;
5092 unsigned int muted_lvl
, notmtd_lvl
;
5095 if (!spec
->gpio_led
)
5098 for (i
= 0; i
< spec
->multiout
.num_dacs
; i
++) {
5099 nid
= spec
->multiout
.dac_nids
[i
];
5100 if (!(snd_hda_codec_amp_read(codec
, nid
, 0, HDA_OUTPUT
, 0) &
5102 muted
= 0; /* something heard */
5106 if (muted
&& spec
->multiout
.hp_nid
)
5107 if (!(snd_hda_codec_amp_read(codec
,
5108 spec
->multiout
.hp_nid
, 0, HDA_OUTPUT
, 0) &
5110 muted
= 0; /* HP is not muted */
5112 num_ext_dacs
= ARRAY_SIZE(spec
->multiout
.extra_out_nid
);
5113 for (i
= 0; muted
&& i
< num_ext_dacs
; i
++) {
5114 nid
= spec
->multiout
.extra_out_nid
[i
];
5117 if (!(snd_hda_codec_amp_read(codec
, nid
, 0, HDA_OUTPUT
, 0) &
5119 muted
= 0; /* extra output is not muted */
5122 /*polarity defines *not* muted state level*/
5123 if (spec
->gpio_led
<= 8) {
5125 spec
->gpio_data
&= ~spec
->gpio_led
; /* orange */
5127 spec
->gpio_data
|= spec
->gpio_led
; /* white */
5129 if (!spec
->gpio_led_polarity
) {
5130 /* LED state is inverted on these systems */
5131 spec
->gpio_data
^= spec
->gpio_led
;
5133 stac_gpio_set(codec
, spec
->gpio_mask
,
5134 spec
->gpio_dir
, spec
->gpio_data
);
5136 notmtd_lvl
= spec
->gpio_led_polarity
?
5137 AC_PINCTL_VREF_HIZ
: AC_PINCTL_VREF_GRD
;
5138 muted_lvl
= spec
->gpio_led_polarity
?
5139 AC_PINCTL_VREF_GRD
: AC_PINCTL_VREF_HIZ
;
5140 spec
->vref_led
= muted
? muted_lvl
: notmtd_lvl
;
5141 stac_vrefout_set(codec
, spec
->gpio_led
, spec
->vref_led
);
5147 * use power check for controlling mute led of HP notebooks
5149 static int stac92xx_check_power_status(struct hda_codec
*codec
,
5152 stac92xx_update_led_status(codec
);
5156 #endif /* CONFIG_SND_HDA_POWER_SAVE */
5157 #endif /* CONFIG_PM */
5159 static const struct hda_codec_ops stac92xx_patch_ops
= {
5160 .build_controls
= stac92xx_build_controls
,
5161 .build_pcms
= stac92xx_build_pcms
,
5162 .init
= stac92xx_init
,
5163 .free
= stac92xx_free
,
5164 .unsol_event
= stac92xx_unsol_event
,
5166 .suspend
= stac92xx_suspend
,
5167 .resume
= stac92xx_resume
,
5169 .reboot_notify
= stac92xx_shutup
,
5172 static int patch_stac9200(struct hda_codec
*codec
)
5174 struct sigmatel_spec
*spec
;
5177 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5181 codec
->no_trigger_sense
= 1;
5183 spec
->linear_tone_beep
= 1;
5184 spec
->num_pins
= ARRAY_SIZE(stac9200_pin_nids
);
5185 spec
->pin_nids
= stac9200_pin_nids
;
5186 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_9200_MODELS
,
5189 if (spec
->board_config
< 0)
5190 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
5193 stac92xx_set_config_regs(codec
,
5194 stac9200_brd_tbl
[spec
->board_config
]);
5196 spec
->multiout
.max_channels
= 2;
5197 spec
->multiout
.num_dacs
= 1;
5198 spec
->multiout
.dac_nids
= stac9200_dac_nids
;
5199 spec
->adc_nids
= stac9200_adc_nids
;
5200 spec
->mux_nids
= stac9200_mux_nids
;
5201 spec
->num_muxes
= 1;
5202 spec
->num_dmics
= 0;
5206 if (spec
->board_config
== STAC_9200_M4
||
5207 spec
->board_config
== STAC_9200_M4_2
||
5208 spec
->board_config
== STAC_9200_OQO
)
5209 spec
->init
= stac9200_eapd_init
;
5211 spec
->init
= stac9200_core_init
;
5212 spec
->mixer
= stac9200_mixer
;
5214 if (spec
->board_config
== STAC_9200_PANASONIC
) {
5215 spec
->gpio_mask
= spec
->gpio_dir
= 0x09;
5216 spec
->gpio_data
= 0x00;
5219 err
= stac9200_parse_auto_config(codec
);
5221 stac92xx_free(codec
);
5225 /* CF-74 has no headphone detection, and the driver should *NOT*
5226 * do detection and HP/speaker toggle because the hardware does it.
5228 if (spec
->board_config
== STAC_9200_PANASONIC
)
5229 spec
->hp_detect
= 0;
5231 codec
->patch_ops
= stac92xx_patch_ops
;
5236 static int patch_stac925x(struct hda_codec
*codec
)
5238 struct sigmatel_spec
*spec
;
5241 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5245 codec
->no_trigger_sense
= 1;
5247 spec
->linear_tone_beep
= 1;
5248 spec
->num_pins
= ARRAY_SIZE(stac925x_pin_nids
);
5249 spec
->pin_nids
= stac925x_pin_nids
;
5251 /* Check first for codec ID */
5252 spec
->board_config
= snd_hda_check_board_codec_sid_config(codec
,
5255 stac925x_codec_id_cfg_tbl
);
5257 /* Now checks for PCI ID, if codec ID is not found */
5258 if (spec
->board_config
< 0)
5259 spec
->board_config
= snd_hda_check_board_config(codec
,
5264 if (spec
->board_config
< 0)
5265 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
5268 stac92xx_set_config_regs(codec
,
5269 stac925x_brd_tbl
[spec
->board_config
]);
5271 spec
->multiout
.max_channels
= 2;
5272 spec
->multiout
.num_dacs
= 1;
5273 spec
->multiout
.dac_nids
= stac925x_dac_nids
;
5274 spec
->adc_nids
= stac925x_adc_nids
;
5275 spec
->mux_nids
= stac925x_mux_nids
;
5276 spec
->num_muxes
= 1;
5279 switch (codec
->vendor_id
) {
5280 case 0x83847632: /* STAC9202 */
5281 case 0x83847633: /* STAC9202D */
5282 case 0x83847636: /* STAC9251 */
5283 case 0x83847637: /* STAC9251D */
5284 spec
->num_dmics
= STAC925X_NUM_DMICS
;
5285 spec
->dmic_nids
= stac925x_dmic_nids
;
5286 spec
->num_dmuxes
= ARRAY_SIZE(stac925x_dmux_nids
);
5287 spec
->dmux_nids
= stac925x_dmux_nids
;
5290 spec
->num_dmics
= 0;
5294 spec
->init
= stac925x_core_init
;
5295 spec
->mixer
= stac925x_mixer
;
5297 spec
->capvols
= stac925x_capvols
;
5298 spec
->capsws
= stac925x_capsws
;
5300 err
= stac92xx_parse_auto_config(codec
);
5302 if (spec
->board_config
< 0) {
5303 printk(KERN_WARNING
"hda_codec: No auto-config is "
5304 "available, default to model=ref\n");
5305 spec
->board_config
= STAC_925x_REF
;
5311 stac92xx_free(codec
);
5315 codec
->patch_ops
= stac92xx_patch_ops
;
5320 static int patch_stac92hd73xx(struct hda_codec
*codec
)
5322 struct sigmatel_spec
*spec
;
5323 hda_nid_t conn
[STAC92HD73_DAC_COUNT
+ 2];
5327 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5331 codec
->no_trigger_sense
= 1;
5333 spec
->linear_tone_beep
= 0;
5334 codec
->slave_dig_outs
= stac92hd73xx_slave_dig_outs
;
5335 spec
->num_pins
= ARRAY_SIZE(stac92hd73xx_pin_nids
);
5336 spec
->pin_nids
= stac92hd73xx_pin_nids
;
5337 spec
->board_config
= snd_hda_check_board_config(codec
,
5338 STAC_92HD73XX_MODELS
,
5339 stac92hd73xx_models
,
5340 stac92hd73xx_cfg_tbl
);
5341 /* check codec subsystem id if not found */
5342 if (spec
->board_config
< 0)
5343 spec
->board_config
=
5344 snd_hda_check_board_codec_sid_config(codec
,
5345 STAC_92HD73XX_MODELS
, stac92hd73xx_models
,
5346 stac92hd73xx_codec_id_cfg_tbl
);
5348 if (spec
->board_config
< 0)
5349 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
5352 stac92xx_set_config_regs(codec
,
5353 stac92hd73xx_brd_tbl
[spec
->board_config
]);
5355 num_dacs
= snd_hda_get_connections(codec
, 0x0a,
5356 conn
, STAC92HD73_DAC_COUNT
+ 2) - 1;
5358 if (num_dacs
< 3 || num_dacs
> 5) {
5359 printk(KERN_WARNING
"hda_codec: Could not determine "
5360 "number of channels defaulting to DAC count\n");
5361 num_dacs
= STAC92HD73_DAC_COUNT
;
5363 spec
->init
= stac92hd73xx_core_init
;
5365 case 0x3: /* 6 Channel */
5366 spec
->aloopback_ctl
= stac92hd73xx_6ch_loopback
;
5368 case 0x4: /* 8 Channel */
5369 spec
->aloopback_ctl
= stac92hd73xx_8ch_loopback
;
5371 case 0x5: /* 10 Channel */
5372 spec
->aloopback_ctl
= stac92hd73xx_10ch_loopback
;
5375 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5377 spec
->aloopback_mask
= 0x01;
5378 spec
->aloopback_shift
= 8;
5380 spec
->digbeep_nid
= 0x1c;
5381 spec
->mux_nids
= stac92hd73xx_mux_nids
;
5382 spec
->adc_nids
= stac92hd73xx_adc_nids
;
5383 spec
->dmic_nids
= stac92hd73xx_dmic_nids
;
5384 spec
->dmux_nids
= stac92hd73xx_dmux_nids
;
5385 spec
->smux_nids
= stac92hd73xx_smux_nids
;
5387 spec
->num_muxes
= ARRAY_SIZE(stac92hd73xx_mux_nids
);
5388 spec
->num_adcs
= ARRAY_SIZE(stac92hd73xx_adc_nids
);
5389 spec
->num_dmuxes
= ARRAY_SIZE(stac92hd73xx_dmux_nids
);
5391 spec
->num_caps
= STAC92HD73XX_NUM_CAPS
;
5392 spec
->capvols
= stac92hd73xx_capvols
;
5393 spec
->capsws
= stac92hd73xx_capsws
;
5395 switch (spec
->board_config
) {
5397 spec
->init
= dell_eq_core_init
;
5399 case STAC_DELL_M6_AMIC
:
5400 case STAC_DELL_M6_DMIC
:
5401 case STAC_DELL_M6_BOTH
:
5402 spec
->num_smuxes
= 0;
5403 spec
->eapd_switch
= 0;
5405 switch (spec
->board_config
) {
5406 case STAC_DELL_M6_AMIC
: /* Analog Mics */
5407 snd_hda_codec_set_pincfg(codec
, 0x0b, 0x90A70170);
5408 spec
->num_dmics
= 0;
5410 case STAC_DELL_M6_DMIC
: /* Digital Mics */
5411 snd_hda_codec_set_pincfg(codec
, 0x13, 0x90A60160);
5412 spec
->num_dmics
= 1;
5414 case STAC_DELL_M6_BOTH
: /* Both */
5415 snd_hda_codec_set_pincfg(codec
, 0x0b, 0x90A70170);
5416 snd_hda_codec_set_pincfg(codec
, 0x13, 0x90A60160);
5417 spec
->num_dmics
= 1;
5421 case STAC_ALIENWARE_M17X
:
5422 spec
->num_dmics
= STAC92HD73XX_NUM_DMICS
;
5423 spec
->num_smuxes
= ARRAY_SIZE(stac92hd73xx_smux_nids
);
5424 spec
->eapd_switch
= 0;
5427 spec
->num_dmics
= STAC92HD73XX_NUM_DMICS
;
5428 spec
->num_smuxes
= ARRAY_SIZE(stac92hd73xx_smux_nids
);
5429 spec
->eapd_switch
= 1;
5432 if (spec
->board_config
!= STAC_92HD73XX_REF
) {
5433 /* GPIO0 High = Enable EAPD */
5434 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x1;
5435 spec
->gpio_data
= 0x01;
5438 spec
->num_pwrs
= ARRAY_SIZE(stac92hd73xx_pwr_nids
);
5439 spec
->pwr_nids
= stac92hd73xx_pwr_nids
;
5441 err
= stac92xx_parse_auto_config(codec
);
5444 if (spec
->board_config
< 0) {
5445 printk(KERN_WARNING
"hda_codec: No auto-config is "
5446 "available, default to model=ref\n");
5447 spec
->board_config
= STAC_92HD73XX_REF
;
5454 stac92xx_free(codec
);
5458 if (spec
->board_config
== STAC_92HD73XX_NO_JD
)
5459 spec
->hp_detect
= 0;
5461 codec
->patch_ops
= stac92xx_patch_ops
;
5463 codec
->proc_widget_hook
= stac92hd7x_proc_hook
;
5468 static int hp_bnb2011_with_dock(struct hda_codec
*codec
)
5470 if (codec
->vendor_id
!= 0x111d7605 &&
5471 codec
->vendor_id
!= 0x111d76d1)
5474 switch (codec
->subsystem_id
) {
5508 static void stac92hd8x_add_pin(struct hda_codec
*codec
, hda_nid_t nid
)
5510 struct sigmatel_spec
*spec
= codec
->spec
;
5511 unsigned int def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
5514 spec
->auto_pin_nids
[spec
->auto_pin_cnt
] = nid
;
5515 spec
->auto_pin_cnt
++;
5517 if (get_defcfg_device(def_conf
) == AC_JACK_MIC_IN
&&
5518 get_defcfg_connect(def_conf
) != AC_JACK_PORT_NONE
) {
5519 for (i
= 0; i
< ARRAY_SIZE(stac92hd83xxx_dmic_nids
); i
++) {
5520 if (nid
== stac92hd83xxx_dmic_nids
[i
]) {
5521 spec
->auto_dmic_nids
[spec
->auto_dmic_cnt
] = nid
;
5522 spec
->auto_dmic_cnt
++;
5528 static void stac92hd8x_add_adc(struct hda_codec
*codec
, hda_nid_t nid
)
5530 struct sigmatel_spec
*spec
= codec
->spec
;
5532 spec
->auto_adc_nids
[spec
->auto_adc_cnt
] = nid
;
5533 spec
->auto_adc_cnt
++;
5536 static void stac92hd8x_add_mux(struct hda_codec
*codec
, hda_nid_t nid
)
5539 struct sigmatel_spec
*spec
= codec
->spec
;
5541 for (i
= 0; i
< spec
->auto_adc_cnt
; i
++) {
5542 if (get_connection_index(codec
,
5543 spec
->auto_adc_nids
[i
], nid
) >= 0) {
5544 /* mux and volume for adc_nids[i] */
5545 if (!spec
->auto_mux_nids
[i
]) {
5546 spec
->auto_mux_nids
[i
] = nid
;
5547 /* 92hd codecs capture volume is in mux */
5548 spec
->auto_capvols
[i
] = HDA_COMPOSE_AMP_VAL(nid
,
5551 for (j
= 0; j
< spec
->auto_dmic_cnt
; j
++) {
5552 if (get_connection_index(codec
, nid
,
5553 spec
->auto_dmic_nids
[j
]) >= 0) {
5554 /* dmux for adc_nids[i] */
5555 if (!spec
->auto_dmux_nids
[i
])
5556 spec
->auto_dmux_nids
[i
] = nid
;
5565 static void stac92hd8x_fill_auto_spec(struct hda_codec
*codec
)
5567 hda_nid_t nid
, end_nid
;
5568 unsigned int wid_caps
, wid_type
;
5569 struct sigmatel_spec
*spec
= codec
->spec
;
5571 end_nid
= codec
->start_nid
+ codec
->num_nodes
;
5573 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
5574 wid_caps
= get_wcaps(codec
, nid
);
5575 wid_type
= get_wcaps_type(wid_caps
);
5577 if (wid_type
== AC_WID_PIN
)
5578 stac92hd8x_add_pin(codec
, nid
);
5580 if (wid_type
== AC_WID_AUD_IN
&& !(wid_caps
& AC_WCAP_DIGITAL
))
5581 stac92hd8x_add_adc(codec
, nid
);
5584 for (nid
= codec
->start_nid
; nid
< end_nid
; nid
++) {
5585 wid_caps
= get_wcaps(codec
, nid
);
5586 wid_type
= get_wcaps_type(wid_caps
);
5588 if (wid_type
== AC_WID_AUD_SEL
)
5589 stac92hd8x_add_mux(codec
, nid
);
5592 spec
->pin_nids
= spec
->auto_pin_nids
;
5593 spec
->num_pins
= spec
->auto_pin_cnt
;
5594 spec
->adc_nids
= spec
->auto_adc_nids
;
5595 spec
->num_adcs
= spec
->auto_adc_cnt
;
5596 spec
->capvols
= spec
->auto_capvols
;
5597 spec
->capsws
= spec
->auto_capvols
;
5598 spec
->num_caps
= spec
->auto_adc_cnt
;
5599 spec
->mux_nids
= spec
->auto_mux_nids
;
5600 spec
->num_muxes
= spec
->auto_adc_cnt
;
5601 spec
->dmux_nids
= spec
->auto_dmux_nids
;
5602 spec
->num_dmuxes
= spec
->auto_adc_cnt
;
5603 spec
->dmic_nids
= spec
->auto_dmic_nids
;
5604 spec
->num_dmics
= spec
->auto_dmic_cnt
;
5607 static int patch_stac92hd83xxx(struct hda_codec
*codec
)
5609 struct sigmatel_spec
*spec
;
5612 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5616 if (hp_bnb2011_with_dock(codec
)) {
5617 snd_hda_codec_set_pincfg(codec
, 0xa, 0x2101201f);
5618 snd_hda_codec_set_pincfg(codec
, 0xf, 0x2181205e);
5621 /* reset pin power-down; Windows may leave these bits after reboot */
5622 snd_hda_codec_write_cache(codec
, codec
->afg
, 0, 0x7EC, 0);
5623 snd_hda_codec_write_cache(codec
, codec
->afg
, 0, 0x7ED, 0);
5624 codec
->no_trigger_sense
= 1;
5627 stac92hd8x_fill_auto_spec(codec
);
5629 spec
->linear_tone_beep
= 0;
5630 codec
->slave_dig_outs
= stac92hd83xxx_slave_dig_outs
;
5631 spec
->digbeep_nid
= 0x21;
5632 spec
->pwr_nids
= stac92hd83xxx_pwr_nids
;
5633 spec
->pwr_mapping
= stac92hd83xxx_pwr_mapping
;
5634 spec
->num_pwrs
= ARRAY_SIZE(stac92hd83xxx_pwr_nids
);
5635 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5636 spec
->init
= stac92hd83xxx_core_init
;
5638 spec
->board_config
= snd_hda_check_board_config(codec
,
5639 STAC_92HD83XXX_MODELS
,
5640 stac92hd83xxx_models
,
5641 stac92hd83xxx_cfg_tbl
);
5643 if (spec
->board_config
< 0)
5644 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
5647 stac92xx_set_config_regs(codec
,
5648 stac92hd83xxx_brd_tbl
[spec
->board_config
]);
5650 if (spec
->board_config
!= STAC_92HD83XXX_PWR_REF
)
5653 codec
->patch_ops
= stac92xx_patch_ops
;
5655 if (find_mute_led_gpio(codec
, 0))
5656 snd_printd("mute LED gpio %d polarity %d\n",
5658 spec
->gpio_led_polarity
);
5660 #ifdef CONFIG_SND_HDA_POWER_SAVE
5661 if (spec
->gpio_led
) {
5662 if (spec
->gpio_led
<= 8) {
5663 spec
->gpio_mask
|= spec
->gpio_led
;
5664 spec
->gpio_dir
|= spec
->gpio_led
;
5665 spec
->gpio_data
|= spec
->gpio_led
;
5667 codec
->patch_ops
.set_power_state
=
5668 stac92xx_set_power_state
;
5669 codec
->patch_ops
.post_suspend
=
5670 stac92xx_post_suspend
;
5672 codec
->patch_ops
.pre_resume
= stac92xx_pre_resume
;
5673 codec
->patch_ops
.check_power_status
=
5674 stac92xx_check_power_status
;
5678 err
= stac92xx_parse_auto_config(codec
);
5680 if (spec
->board_config
< 0) {
5681 printk(KERN_WARNING
"hda_codec: No auto-config is "
5682 "available, default to model=ref\n");
5683 spec
->board_config
= STAC_92HD83XXX_REF
;
5690 stac92xx_free(codec
);
5694 codec
->proc_widget_hook
= stac92hd_proc_hook
;
5699 static int stac92hd71bxx_connected_smuxes(struct hda_codec
*codec
,
5702 struct sigmatel_spec
*spec
= codec
->spec
;
5705 for (idx
= 0; idx
< spec
->num_pins
; idx
++)
5706 if (spec
->pin_nids
[idx
] == dig0pin
)
5708 if ((idx
+ 2) >= spec
->num_pins
)
5712 if (stac_get_defcfg_connect(codec
, idx
+ 1) != AC_JACK_PORT_NONE
)
5715 /* dig0pin + dig2pin case */
5716 if (stac_get_defcfg_connect(codec
, idx
+ 2) != AC_JACK_PORT_NONE
)
5718 if (stac_get_defcfg_connect(codec
, idx
) != AC_JACK_PORT_NONE
)
5724 /* HP dv7 bass switch - GPIO5 */
5725 #define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
5726 static int stac_hp_bass_gpio_get(struct snd_kcontrol
*kcontrol
,
5727 struct snd_ctl_elem_value
*ucontrol
)
5729 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
5730 struct sigmatel_spec
*spec
= codec
->spec
;
5731 ucontrol
->value
.integer
.value
[0] = !!(spec
->gpio_data
& 0x20);
5735 static int stac_hp_bass_gpio_put(struct snd_kcontrol
*kcontrol
,
5736 struct snd_ctl_elem_value
*ucontrol
)
5738 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
5739 struct sigmatel_spec
*spec
= codec
->spec
;
5740 unsigned int gpio_data
;
5742 gpio_data
= (spec
->gpio_data
& ~0x20) |
5743 (ucontrol
->value
.integer
.value
[0] ? 0x20 : 0);
5744 if (gpio_data
== spec
->gpio_data
)
5746 spec
->gpio_data
= gpio_data
;
5747 stac_gpio_set(codec
, spec
->gpio_mask
, spec
->gpio_dir
, spec
->gpio_data
);
5751 static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl
= {
5752 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
5753 .info
= stac_hp_bass_gpio_info
,
5754 .get
= stac_hp_bass_gpio_get
,
5755 .put
= stac_hp_bass_gpio_put
,
5758 static int stac_add_hp_bass_switch(struct hda_codec
*codec
)
5760 struct sigmatel_spec
*spec
= codec
->spec
;
5762 if (!stac_control_new(spec
, &stac_hp_bass_sw_ctrl
,
5763 "Bass Speaker Playback Switch", 0))
5766 spec
->gpio_mask
|= 0x20;
5767 spec
->gpio_dir
|= 0x20;
5768 spec
->gpio_data
|= 0x20;
5772 static int patch_stac92hd71bxx(struct hda_codec
*codec
)
5774 struct sigmatel_spec
*spec
;
5775 const struct hda_verb
*unmute_init
= stac92hd71bxx_unmute_core_init
;
5776 unsigned int pin_cfg
;
5779 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5783 codec
->no_trigger_sense
= 1;
5785 spec
->linear_tone_beep
= 0;
5786 codec
->patch_ops
= stac92xx_patch_ops
;
5787 spec
->num_pins
= STAC92HD71BXX_NUM_PINS
;
5788 switch (codec
->vendor_id
) {
5791 spec
->pin_nids
= stac92hd71bxx_pin_nids_4port
;
5795 /* On 92HD75Bx 0x27 isn't a pin nid */
5799 spec
->pin_nids
= stac92hd71bxx_pin_nids_6port
;
5801 spec
->num_pwrs
= ARRAY_SIZE(stac92hd71bxx_pwr_nids
);
5802 spec
->board_config
= snd_hda_check_board_config(codec
,
5803 STAC_92HD71BXX_MODELS
,
5804 stac92hd71bxx_models
,
5805 stac92hd71bxx_cfg_tbl
);
5807 if (spec
->board_config
< 0)
5808 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
5811 stac92xx_set_config_regs(codec
,
5812 stac92hd71bxx_brd_tbl
[spec
->board_config
]);
5814 if (spec
->board_config
!= STAC_92HD71BXX_REF
) {
5816 spec
->gpio_mask
= 0x01;
5817 spec
->gpio_dir
= 0x01;
5818 spec
->gpio_data
= 0x01;
5821 spec
->dmic_nids
= stac92hd71bxx_dmic_nids
;
5822 spec
->dmux_nids
= stac92hd71bxx_dmux_nids
;
5824 spec
->num_caps
= STAC92HD71BXX_NUM_CAPS
;
5825 spec
->capvols
= stac92hd71bxx_capvols
;
5826 spec
->capsws
= stac92hd71bxx_capsws
;
5828 switch (codec
->vendor_id
) {
5829 case 0x111d76b6: /* 4 Port without Analog Mixer */
5833 case 0x111d76b4: /* 6 Port without Analog Mixer */
5835 spec
->init
= stac92hd71bxx_core_init
;
5836 codec
->slave_dig_outs
= stac92hd71bxx_slave_dig_outs
;
5837 spec
->num_dmics
= stac92xx_connected_ports(codec
,
5838 stac92hd71bxx_dmic_nids
,
5839 STAC92HD71BXX_NUM_DMICS
);
5841 case 0x111d7608: /* 5 Port with Analog Mixer */
5842 switch (spec
->board_config
) {
5844 /* Enable VREF power saving on GPIO1 detect */
5845 err
= stac_add_event(spec
, codec
->afg
,
5846 STAC_VREF_EVENT
, 0x02);
5849 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
5850 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK
, 0x02);
5851 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
5852 AC_VERB_SET_UNSOLICITED_ENABLE
,
5854 spec
->gpio_mask
|= 0x02;
5857 if ((codec
->revision_id
& 0xf) == 0 ||
5858 (codec
->revision_id
& 0xf) == 1)
5859 spec
->stream_delay
= 40; /* 40 milliseconds */
5861 /* no output amps */
5864 spec
->init
= stac92hd71bxx_core_init
;
5866 snd_hda_codec_set_pincfg(codec
, 0x0f, 0x40f000f0);
5867 snd_hda_codec_set_pincfg(codec
, 0x19, 0x40f000f3);
5868 spec
->dmic_nids
= stac92hd71bxx_dmic_5port_nids
;
5869 spec
->num_dmics
= stac92xx_connected_ports(codec
,
5870 stac92hd71bxx_dmic_5port_nids
,
5871 STAC92HD71BXX_NUM_DMICS
- 1);
5873 case 0x111d7603: /* 6 Port with Analog Mixer */
5874 if ((codec
->revision_id
& 0xf) == 1)
5875 spec
->stream_delay
= 40; /* 40 milliseconds */
5877 /* no output amps */
5881 spec
->init
= stac92hd71bxx_core_init
;
5882 codec
->slave_dig_outs
= stac92hd71bxx_slave_dig_outs
;
5883 spec
->num_dmics
= stac92xx_connected_ports(codec
,
5884 stac92hd71bxx_dmic_nids
,
5885 STAC92HD71BXX_NUM_DMICS
);
5889 if (get_wcaps(codec
, 0xa) & AC_WCAP_IN_AMP
)
5890 snd_hda_sequence_write_cache(codec
, unmute_init
);
5892 spec
->aloopback_ctl
= stac92hd71bxx_loopback
;
5893 spec
->aloopback_mask
= 0x50;
5894 spec
->aloopback_shift
= 0;
5896 spec
->powerdown_adcs
= 1;
5897 spec
->digbeep_nid
= 0x26;
5898 spec
->mux_nids
= stac92hd71bxx_mux_nids
;
5899 spec
->adc_nids
= stac92hd71bxx_adc_nids
;
5900 spec
->smux_nids
= stac92hd71bxx_smux_nids
;
5901 spec
->pwr_nids
= stac92hd71bxx_pwr_nids
;
5903 spec
->num_muxes
= ARRAY_SIZE(stac92hd71bxx_mux_nids
);
5904 spec
->num_adcs
= ARRAY_SIZE(stac92hd71bxx_adc_nids
);
5905 spec
->num_dmuxes
= ARRAY_SIZE(stac92hd71bxx_dmux_nids
);
5906 spec
->num_smuxes
= stac92hd71bxx_connected_smuxes(codec
, 0x1e);
5908 snd_printdd("Found board config: %d\n", spec
->board_config
);
5910 switch (spec
->board_config
) {
5912 /* enable internal microphone */
5913 snd_hda_codec_set_pincfg(codec
, 0x0e, 0x01813040);
5914 stac92xx_auto_set_pinctl(codec
, 0x0e,
5915 AC_PINCTL_IN_EN
| AC_PINCTL_VREF_80
);
5917 case STAC_DELL_M4_2
:
5918 spec
->num_dmics
= 0;
5919 spec
->num_smuxes
= 0;
5920 spec
->num_dmuxes
= 0;
5922 case STAC_DELL_M4_1
:
5923 case STAC_DELL_M4_3
:
5924 spec
->num_dmics
= 1;
5925 spec
->num_smuxes
= 0;
5926 spec
->num_dmuxes
= 1;
5928 case STAC_HP_DV4_1222NR
:
5929 spec
->num_dmics
= 1;
5930 /* I don't know if it needs 1 or 2 smuxes - will wait for
5931 * bug reports to fix if needed
5933 spec
->num_smuxes
= 1;
5934 spec
->num_dmuxes
= 1;
5937 spec
->gpio_led
= 0x01;
5940 snd_hda_codec_set_pincfg(codec
, 0x0d, 0x90170010);
5941 stac92xx_auto_set_pinctl(codec
, 0x0d, AC_PINCTL_OUT_EN
);
5942 /* HP dv6 gives the headphone pin as a line-out. Thus we
5943 * need to set hp_detect flag here to force to enable HP
5946 spec
->hp_detect
= 1;
5949 spec
->num_dmics
= 1;
5950 spec
->num_dmuxes
= 1;
5951 spec
->num_smuxes
= 1;
5952 spec
->gpio_led
= 0x08;
5956 if (hp_blike_system(codec
->subsystem_id
)) {
5957 pin_cfg
= snd_hda_codec_get_pincfg(codec
, 0x0f);
5958 if (get_defcfg_device(pin_cfg
) == AC_JACK_LINE_OUT
||
5959 get_defcfg_device(pin_cfg
) == AC_JACK_SPEAKER
||
5960 get_defcfg_device(pin_cfg
) == AC_JACK_HP_OUT
) {
5961 /* It was changed in the BIOS to just satisfy MS DTM.
5962 * Lets turn it back into slaved HP
5964 pin_cfg
= (pin_cfg
& (~AC_DEFCFG_DEVICE
))
5965 | (AC_JACK_HP_OUT
<<
5966 AC_DEFCFG_DEVICE_SHIFT
);
5967 pin_cfg
= (pin_cfg
& (~(AC_DEFCFG_DEF_ASSOC
5968 | AC_DEFCFG_SEQUENCE
)))
5970 snd_hda_codec_set_pincfg(codec
, 0x0f, pin_cfg
);
5974 if (find_mute_led_gpio(codec
, 1))
5975 snd_printd("mute LED gpio %d polarity %d\n",
5977 spec
->gpio_led_polarity
);
5979 #ifdef CONFIG_SND_HDA_POWER_SAVE
5980 if (spec
->gpio_led
) {
5981 if (spec
->gpio_led
<= 8) {
5982 spec
->gpio_mask
|= spec
->gpio_led
;
5983 spec
->gpio_dir
|= spec
->gpio_led
;
5984 spec
->gpio_data
|= spec
->gpio_led
;
5986 codec
->patch_ops
.set_power_state
=
5987 stac92xx_set_power_state
;
5988 codec
->patch_ops
.post_suspend
=
5989 stac92xx_post_suspend
;
5991 codec
->patch_ops
.pre_resume
= stac92xx_pre_resume
;
5992 codec
->patch_ops
.check_power_status
=
5993 stac92xx_check_power_status
;
5997 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5999 err
= stac92xx_parse_auto_config(codec
);
6001 if (spec
->board_config
< 0) {
6002 printk(KERN_WARNING
"hda_codec: No auto-config is "
6003 "available, default to model=ref\n");
6004 spec
->board_config
= STAC_92HD71BXX_REF
;
6011 stac92xx_free(codec
);
6015 /* enable bass on HP dv7 */
6016 if (spec
->board_config
== STAC_HP_DV4
||
6017 spec
->board_config
== STAC_HP_DV5
) {
6019 cap
= snd_hda_param_read(codec
, 0x1, AC_PAR_GPIO_CAP
);
6020 cap
&= AC_GPIO_IO_COUNT
;
6022 stac_add_hp_bass_switch(codec
);
6025 codec
->proc_widget_hook
= stac92hd7x_proc_hook
;
6030 static int patch_stac922x(struct hda_codec
*codec
)
6032 struct sigmatel_spec
*spec
;
6035 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
6039 codec
->no_trigger_sense
= 1;
6041 spec
->linear_tone_beep
= 1;
6042 spec
->num_pins
= ARRAY_SIZE(stac922x_pin_nids
);
6043 spec
->pin_nids
= stac922x_pin_nids
;
6044 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_922X_MODELS
,
6047 if (spec
->board_config
== STAC_INTEL_MAC_AUTO
) {
6048 spec
->gpio_mask
= spec
->gpio_dir
= 0x03;
6049 spec
->gpio_data
= 0x03;
6050 /* Intel Macs have all same PCI SSID, so we need to check
6051 * codec SSID to distinguish the exact models
6053 printk(KERN_INFO
"hda_codec: STAC922x, Apple subsys_id=%x\n", codec
->subsystem_id
);
6054 switch (codec
->subsystem_id
) {
6057 spec
->board_config
= STAC_INTEL_MAC_V1
;
6061 spec
->board_config
= STAC_INTEL_MAC_V2
;
6069 spec
->board_config
= STAC_INTEL_MAC_V3
;
6073 spec
->board_config
= STAC_INTEL_MAC_V4
;
6077 spec
->board_config
= STAC_INTEL_MAC_V5
;
6080 spec
->board_config
= STAC_INTEL_MAC_V3
;
6086 if (spec
->board_config
< 0)
6087 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
6090 stac92xx_set_config_regs(codec
,
6091 stac922x_brd_tbl
[spec
->board_config
]);
6093 spec
->adc_nids
= stac922x_adc_nids
;
6094 spec
->mux_nids
= stac922x_mux_nids
;
6095 spec
->num_muxes
= ARRAY_SIZE(stac922x_mux_nids
);
6096 spec
->num_adcs
= ARRAY_SIZE(stac922x_adc_nids
);
6097 spec
->num_dmics
= 0;
6100 spec
->init
= stac922x_core_init
;
6102 spec
->num_caps
= STAC922X_NUM_CAPS
;
6103 spec
->capvols
= stac922x_capvols
;
6104 spec
->capsws
= stac922x_capsws
;
6106 spec
->multiout
.dac_nids
= spec
->dac_nids
;
6108 err
= stac92xx_parse_auto_config(codec
);
6110 if (spec
->board_config
< 0) {
6111 printk(KERN_WARNING
"hda_codec: No auto-config is "
6112 "available, default to model=ref\n");
6113 spec
->board_config
= STAC_D945_REF
;
6119 stac92xx_free(codec
);
6123 codec
->patch_ops
= stac92xx_patch_ops
;
6125 /* Fix Mux capture level; max to 2 */
6126 snd_hda_override_amp_caps(codec
, 0x12, HDA_OUTPUT
,
6127 (0 << AC_AMPCAP_OFFSET_SHIFT
) |
6128 (2 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
6129 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
6130 (0 << AC_AMPCAP_MUTE_SHIFT
));
6135 static int patch_stac927x(struct hda_codec
*codec
)
6137 struct sigmatel_spec
*spec
;
6140 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
6144 codec
->no_trigger_sense
= 1;
6146 spec
->linear_tone_beep
= 1;
6147 codec
->slave_dig_outs
= stac927x_slave_dig_outs
;
6148 spec
->num_pins
= ARRAY_SIZE(stac927x_pin_nids
);
6149 spec
->pin_nids
= stac927x_pin_nids
;
6150 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_927X_MODELS
,
6154 if (spec
->board_config
< 0)
6155 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
6158 stac92xx_set_config_regs(codec
,
6159 stac927x_brd_tbl
[spec
->board_config
]);
6161 spec
->digbeep_nid
= 0x23;
6162 spec
->adc_nids
= stac927x_adc_nids
;
6163 spec
->num_adcs
= ARRAY_SIZE(stac927x_adc_nids
);
6164 spec
->mux_nids
= stac927x_mux_nids
;
6165 spec
->num_muxes
= ARRAY_SIZE(stac927x_mux_nids
);
6166 spec
->smux_nids
= stac927x_smux_nids
;
6167 spec
->num_smuxes
= ARRAY_SIZE(stac927x_smux_nids
);
6168 spec
->spdif_labels
= stac927x_spdif_labels
;
6169 spec
->dac_list
= stac927x_dac_nids
;
6170 spec
->multiout
.dac_nids
= spec
->dac_nids
;
6172 if (spec
->board_config
!= STAC_D965_REF
) {
6173 /* GPIO0 High = Enable EAPD */
6174 spec
->eapd_mask
= spec
->gpio_mask
= 0x01;
6175 spec
->gpio_dir
= spec
->gpio_data
= 0x01;
6178 switch (spec
->board_config
) {
6181 /* GPIO0 High = Enable EAPD */
6182 spec
->num_dmics
= 0;
6183 spec
->init
= d965_core_init
;
6185 case STAC_DELL_BIOS
:
6186 switch (codec
->subsystem_id
) {
6189 /* correct the device field to SPDIF out */
6190 snd_hda_codec_set_pincfg(codec
, 0x21, 0x01442070);
6193 /* configure the analog microphone on some laptops */
6194 snd_hda_codec_set_pincfg(codec
, 0x0c, 0x90a79130);
6195 /* correct the front output jack as a hp out */
6196 snd_hda_codec_set_pincfg(codec
, 0x0f, 0x0227011f);
6197 /* correct the front input jack as a mic */
6198 snd_hda_codec_set_pincfg(codec
, 0x0e, 0x02a79130);
6201 if (codec
->subsystem_id
!= 0x1028022f) {
6202 /* GPIO2 High = Enable EAPD */
6203 spec
->eapd_mask
= spec
->gpio_mask
= 0x04;
6204 spec
->gpio_dir
= spec
->gpio_data
= 0x04;
6206 spec
->dmic_nids
= stac927x_dmic_nids
;
6207 spec
->num_dmics
= STAC927X_NUM_DMICS
;
6209 spec
->init
= dell_3st_core_init
;
6210 spec
->dmux_nids
= stac927x_dmux_nids
;
6211 spec
->num_dmuxes
= ARRAY_SIZE(stac927x_dmux_nids
);
6213 case STAC_927X_VOLKNOB
:
6214 spec
->num_dmics
= 0;
6215 spec
->init
= stac927x_volknob_core_init
;
6218 spec
->num_dmics
= 0;
6219 spec
->init
= stac927x_core_init
;
6223 spec
->num_caps
= STAC927X_NUM_CAPS
;
6224 spec
->capvols
= stac927x_capvols
;
6225 spec
->capsws
= stac927x_capsws
;
6228 spec
->aloopback_ctl
= stac927x_loopback
;
6229 spec
->aloopback_mask
= 0x40;
6230 spec
->aloopback_shift
= 0;
6231 spec
->eapd_switch
= 1;
6233 err
= stac92xx_parse_auto_config(codec
);
6235 if (spec
->board_config
< 0) {
6236 printk(KERN_WARNING
"hda_codec: No auto-config is "
6237 "available, default to model=ref\n");
6238 spec
->board_config
= STAC_D965_REF
;
6244 stac92xx_free(codec
);
6248 codec
->patch_ops
= stac92xx_patch_ops
;
6250 codec
->proc_widget_hook
= stac927x_proc_hook
;
6254 * The STAC927x seem to require fairly long delays for certain
6255 * command sequences. With too short delays (even if the answer
6256 * is set to RIRB properly), it results in the silence output
6257 * on some hardwares like Dell.
6259 * The below flag enables the longer delay (see get_response
6262 codec
->bus
->needs_damn_long_delay
= 1;
6264 /* no jack detecion for ref-no-jd model */
6265 if (spec
->board_config
== STAC_D965_REF_NO_JD
)
6266 spec
->hp_detect
= 0;
6271 static int patch_stac9205(struct hda_codec
*codec
)
6273 struct sigmatel_spec
*spec
;
6276 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
6280 codec
->no_trigger_sense
= 1;
6282 spec
->linear_tone_beep
= 1;
6283 spec
->num_pins
= ARRAY_SIZE(stac9205_pin_nids
);
6284 spec
->pin_nids
= stac9205_pin_nids
;
6285 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_9205_MODELS
,
6289 if (spec
->board_config
< 0)
6290 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
6293 stac92xx_set_config_regs(codec
,
6294 stac9205_brd_tbl
[spec
->board_config
]);
6296 spec
->digbeep_nid
= 0x23;
6297 spec
->adc_nids
= stac9205_adc_nids
;
6298 spec
->num_adcs
= ARRAY_SIZE(stac9205_adc_nids
);
6299 spec
->mux_nids
= stac9205_mux_nids
;
6300 spec
->num_muxes
= ARRAY_SIZE(stac9205_mux_nids
);
6301 spec
->smux_nids
= stac9205_smux_nids
;
6302 spec
->num_smuxes
= ARRAY_SIZE(stac9205_smux_nids
);
6303 spec
->dmic_nids
= stac9205_dmic_nids
;
6304 spec
->num_dmics
= STAC9205_NUM_DMICS
;
6305 spec
->dmux_nids
= stac9205_dmux_nids
;
6306 spec
->num_dmuxes
= ARRAY_SIZE(stac9205_dmux_nids
);
6309 spec
->init
= stac9205_core_init
;
6310 spec
->aloopback_ctl
= stac9205_loopback
;
6312 spec
->num_caps
= STAC9205_NUM_CAPS
;
6313 spec
->capvols
= stac9205_capvols
;
6314 spec
->capsws
= stac9205_capsws
;
6316 spec
->aloopback_mask
= 0x40;
6317 spec
->aloopback_shift
= 0;
6318 /* Turn on/off EAPD per HP plugging */
6319 if (spec
->board_config
!= STAC_9205_EAPD
)
6320 spec
->eapd_switch
= 1;
6321 spec
->multiout
.dac_nids
= spec
->dac_nids
;
6323 switch (spec
->board_config
){
6324 case STAC_9205_DELL_M43
:
6325 /* Enable SPDIF in/out */
6326 snd_hda_codec_set_pincfg(codec
, 0x1f, 0x01441030);
6327 snd_hda_codec_set_pincfg(codec
, 0x20, 0x1c410030);
6329 /* Enable unsol response for GPIO4/Dock HP connection */
6330 err
= stac_add_event(spec
, codec
->afg
, STAC_VREF_EVENT
, 0x01);
6333 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
6334 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK
, 0x10);
6335 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
6336 AC_VERB_SET_UNSOLICITED_ENABLE
,
6339 spec
->gpio_dir
= 0x0b;
6340 spec
->eapd_mask
= 0x01;
6341 spec
->gpio_mask
= 0x1b;
6342 spec
->gpio_mute
= 0x10;
6343 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
6346 spec
->gpio_data
= 0x01;
6349 /* SPDIF-In enabled */
6352 /* GPIO0 High = EAPD */
6353 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x1;
6354 spec
->gpio_data
= 0x01;
6358 err
= stac92xx_parse_auto_config(codec
);
6360 if (spec
->board_config
< 0) {
6361 printk(KERN_WARNING
"hda_codec: No auto-config is "
6362 "available, default to model=ref\n");
6363 spec
->board_config
= STAC_9205_REF
;
6369 stac92xx_free(codec
);
6373 codec
->patch_ops
= stac92xx_patch_ops
;
6375 codec
->proc_widget_hook
= stac9205_proc_hook
;
6384 static const struct hda_verb stac9872_core_init
[] = {
6385 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mic-sel: 0a,0d,14,02 */
6386 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
}, /* Mic-in -> 0x9 */
6390 static const hda_nid_t stac9872_pin_nids
[] = {
6391 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6395 static const hda_nid_t stac9872_adc_nids
[] = {
6399 static const hda_nid_t stac9872_mux_nids
[] = {
6403 static const unsigned long stac9872_capvols
[] = {
6404 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT
),
6406 #define stac9872_capsws stac9872_capvols
6408 static const unsigned int stac9872_vaio_pin_configs
[9] = {
6409 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
6410 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
6414 static const char * const stac9872_models
[STAC_9872_MODELS
] = {
6415 [STAC_9872_AUTO
] = "auto",
6416 [STAC_9872_VAIO
] = "vaio",
6419 static const unsigned int *stac9872_brd_tbl
[STAC_9872_MODELS
] = {
6420 [STAC_9872_VAIO
] = stac9872_vaio_pin_configs
,
6423 static const struct snd_pci_quirk stac9872_cfg_tbl
[] = {
6424 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6425 "Sony VAIO F/S", STAC_9872_VAIO
),
6429 static int patch_stac9872(struct hda_codec
*codec
)
6431 struct sigmatel_spec
*spec
;
6434 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
6437 codec
->no_trigger_sense
= 1;
6439 spec
->linear_tone_beep
= 1;
6440 spec
->num_pins
= ARRAY_SIZE(stac9872_pin_nids
);
6441 spec
->pin_nids
= stac9872_pin_nids
;
6443 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_9872_MODELS
,
6446 if (spec
->board_config
< 0)
6447 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
6450 stac92xx_set_config_regs(codec
,
6451 stac9872_brd_tbl
[spec
->board_config
]);
6453 spec
->multiout
.dac_nids
= spec
->dac_nids
;
6454 spec
->num_adcs
= ARRAY_SIZE(stac9872_adc_nids
);
6455 spec
->adc_nids
= stac9872_adc_nids
;
6456 spec
->num_muxes
= ARRAY_SIZE(stac9872_mux_nids
);
6457 spec
->mux_nids
= stac9872_mux_nids
;
6458 spec
->init
= stac9872_core_init
;
6460 spec
->capvols
= stac9872_capvols
;
6461 spec
->capsws
= stac9872_capsws
;
6463 err
= stac92xx_parse_auto_config(codec
);
6465 stac92xx_free(codec
);
6468 spec
->input_mux
= &spec
->private_imux
;
6469 codec
->patch_ops
= stac92xx_patch_ops
;
6477 static const struct hda_codec_preset snd_hda_preset_sigmatel
[] = {
6478 { .id
= 0x83847690, .name
= "STAC9200", .patch
= patch_stac9200
},
6479 { .id
= 0x83847882, .name
= "STAC9220 A1", .patch
= patch_stac922x
},
6480 { .id
= 0x83847680, .name
= "STAC9221 A1", .patch
= patch_stac922x
},
6481 { .id
= 0x83847880, .name
= "STAC9220 A2", .patch
= patch_stac922x
},
6482 { .id
= 0x83847681, .name
= "STAC9220D/9223D A2", .patch
= patch_stac922x
},
6483 { .id
= 0x83847682, .name
= "STAC9221 A2", .patch
= patch_stac922x
},
6484 { .id
= 0x83847683, .name
= "STAC9221D A2", .patch
= patch_stac922x
},
6485 { .id
= 0x83847618, .name
= "STAC9227", .patch
= patch_stac927x
},
6486 { .id
= 0x83847619, .name
= "STAC9227", .patch
= patch_stac927x
},
6487 { .id
= 0x83847616, .name
= "STAC9228", .patch
= patch_stac927x
},
6488 { .id
= 0x83847617, .name
= "STAC9228", .patch
= patch_stac927x
},
6489 { .id
= 0x83847614, .name
= "STAC9229", .patch
= patch_stac927x
},
6490 { .id
= 0x83847615, .name
= "STAC9229", .patch
= patch_stac927x
},
6491 { .id
= 0x83847620, .name
= "STAC9274", .patch
= patch_stac927x
},
6492 { .id
= 0x83847621, .name
= "STAC9274D", .patch
= patch_stac927x
},
6493 { .id
= 0x83847622, .name
= "STAC9273X", .patch
= patch_stac927x
},
6494 { .id
= 0x83847623, .name
= "STAC9273D", .patch
= patch_stac927x
},
6495 { .id
= 0x83847624, .name
= "STAC9272X", .patch
= patch_stac927x
},
6496 { .id
= 0x83847625, .name
= "STAC9272D", .patch
= patch_stac927x
},
6497 { .id
= 0x83847626, .name
= "STAC9271X", .patch
= patch_stac927x
},
6498 { .id
= 0x83847627, .name
= "STAC9271D", .patch
= patch_stac927x
},
6499 { .id
= 0x83847628, .name
= "STAC9274X5NH", .patch
= patch_stac927x
},
6500 { .id
= 0x83847629, .name
= "STAC9274D5NH", .patch
= patch_stac927x
},
6501 { .id
= 0x83847632, .name
= "STAC9202", .patch
= patch_stac925x
},
6502 { .id
= 0x83847633, .name
= "STAC9202D", .patch
= patch_stac925x
},
6503 { .id
= 0x83847634, .name
= "STAC9250", .patch
= patch_stac925x
},
6504 { .id
= 0x83847635, .name
= "STAC9250D", .patch
= patch_stac925x
},
6505 { .id
= 0x83847636, .name
= "STAC9251", .patch
= patch_stac925x
},
6506 { .id
= 0x83847637, .name
= "STAC9250D", .patch
= patch_stac925x
},
6507 { .id
= 0x83847645, .name
= "92HD206X", .patch
= patch_stac927x
},
6508 { .id
= 0x83847646, .name
= "92HD206D", .patch
= patch_stac927x
},
6509 /* The following does not take into account .id=0x83847661 when subsys =
6510 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6511 * currently not fully supported.
6513 { .id
= 0x83847661, .name
= "CXD9872RD/K", .patch
= patch_stac9872
},
6514 { .id
= 0x83847662, .name
= "STAC9872AK", .patch
= patch_stac9872
},
6515 { .id
= 0x83847664, .name
= "CXD9872AKD", .patch
= patch_stac9872
},
6516 { .id
= 0x83847698, .name
= "STAC9205", .patch
= patch_stac9205
},
6517 { .id
= 0x838476a0, .name
= "STAC9205", .patch
= patch_stac9205
},
6518 { .id
= 0x838476a1, .name
= "STAC9205D", .patch
= patch_stac9205
},
6519 { .id
= 0x838476a2, .name
= "STAC9204", .patch
= patch_stac9205
},
6520 { .id
= 0x838476a3, .name
= "STAC9204D", .patch
= patch_stac9205
},
6521 { .id
= 0x838476a4, .name
= "STAC9255", .patch
= patch_stac9205
},
6522 { .id
= 0x838476a5, .name
= "STAC9255D", .patch
= patch_stac9205
},
6523 { .id
= 0x838476a6, .name
= "STAC9254", .patch
= patch_stac9205
},
6524 { .id
= 0x838476a7, .name
= "STAC9254D", .patch
= patch_stac9205
},
6525 { .id
= 0x111d7603, .name
= "92HD75B3X5", .patch
= patch_stac92hd71bxx
},
6526 { .id
= 0x111d7604, .name
= "92HD83C1X5", .patch
= patch_stac92hd83xxx
},
6527 { .id
= 0x111d76d4, .name
= "92HD83C1C5", .patch
= patch_stac92hd83xxx
},
6528 { .id
= 0x111d7605, .name
= "92HD81B1X5", .patch
= patch_stac92hd83xxx
},
6529 { .id
= 0x111d76d5, .name
= "92HD81B1C5", .patch
= patch_stac92hd83xxx
},
6530 { .id
= 0x111d76d1, .name
= "92HD87B1/3", .patch
= patch_stac92hd83xxx
},
6531 { .id
= 0x111d76d9, .name
= "92HD87B2/4", .patch
= patch_stac92hd83xxx
},
6532 { .id
= 0x111d7666, .name
= "92HD88B3", .patch
= patch_stac92hd83xxx
},
6533 { .id
= 0x111d7667, .name
= "92HD88B1", .patch
= patch_stac92hd83xxx
},
6534 { .id
= 0x111d7668, .name
= "92HD88B2", .patch
= patch_stac92hd83xxx
},
6535 { .id
= 0x111d7669, .name
= "92HD88B4", .patch
= patch_stac92hd83xxx
},
6536 { .id
= 0x111d7608, .name
= "92HD75B2X5", .patch
= patch_stac92hd71bxx
},
6537 { .id
= 0x111d7674, .name
= "92HD73D1X5", .patch
= patch_stac92hd73xx
},
6538 { .id
= 0x111d7675, .name
= "92HD73C1X5", .patch
= patch_stac92hd73xx
},
6539 { .id
= 0x111d7676, .name
= "92HD73E1X5", .patch
= patch_stac92hd73xx
},
6540 { .id
= 0x111d76b0, .name
= "92HD71B8X", .patch
= patch_stac92hd71bxx
},
6541 { .id
= 0x111d76b1, .name
= "92HD71B8X", .patch
= patch_stac92hd71bxx
},
6542 { .id
= 0x111d76b2, .name
= "92HD71B7X", .patch
= patch_stac92hd71bxx
},
6543 { .id
= 0x111d76b3, .name
= "92HD71B7X", .patch
= patch_stac92hd71bxx
},
6544 { .id
= 0x111d76b4, .name
= "92HD71B6X", .patch
= patch_stac92hd71bxx
},
6545 { .id
= 0x111d76b5, .name
= "92HD71B6X", .patch
= patch_stac92hd71bxx
},
6546 { .id
= 0x111d76b6, .name
= "92HD71B5X", .patch
= patch_stac92hd71bxx
},
6547 { .id
= 0x111d76b7, .name
= "92HD71B5X", .patch
= patch_stac92hd71bxx
},
6548 { .id
= 0x111d76c0, .name
= "92HD89C3", .patch
= patch_stac92hd73xx
},
6549 { .id
= 0x111d76c1, .name
= "92HD89C2", .patch
= patch_stac92hd73xx
},
6550 { .id
= 0x111d76c2, .name
= "92HD89C1", .patch
= patch_stac92hd73xx
},
6551 { .id
= 0x111d76c3, .name
= "92HD89B3", .patch
= patch_stac92hd73xx
},
6552 { .id
= 0x111d76c4, .name
= "92HD89B2", .patch
= patch_stac92hd73xx
},
6553 { .id
= 0x111d76c5, .name
= "92HD89B1", .patch
= patch_stac92hd73xx
},
6554 { .id
= 0x111d76c6, .name
= "92HD89E3", .patch
= patch_stac92hd73xx
},
6555 { .id
= 0x111d76c7, .name
= "92HD89E2", .patch
= patch_stac92hd73xx
},
6556 { .id
= 0x111d76c8, .name
= "92HD89E1", .patch
= patch_stac92hd73xx
},
6557 { .id
= 0x111d76c9, .name
= "92HD89D3", .patch
= patch_stac92hd73xx
},
6558 { .id
= 0x111d76ca, .name
= "92HD89D2", .patch
= patch_stac92hd73xx
},
6559 { .id
= 0x111d76cb, .name
= "92HD89D1", .patch
= patch_stac92hd73xx
},
6560 { .id
= 0x111d76cc, .name
= "92HD89F3", .patch
= patch_stac92hd73xx
},
6561 { .id
= 0x111d76cd, .name
= "92HD89F2", .patch
= patch_stac92hd73xx
},
6562 { .id
= 0x111d76ce, .name
= "92HD89F1", .patch
= patch_stac92hd73xx
},
6563 { .id
= 0x111d76df, .name
= "92HD93BXX", .patch
= patch_stac92hd83xxx
},
6564 { .id
= 0x111d76e0, .name
= "92HD91BXX", .patch
= patch_stac92hd83xxx
},
6565 { .id
= 0x111d76e3, .name
= "92HD98BXX", .patch
= patch_stac92hd83xxx
},
6566 { .id
= 0x111d76e5, .name
= "92HD99BXX", .patch
= patch_stac92hd83xxx
},
6567 { .id
= 0x111d76e7, .name
= "92HD90BXX", .patch
= patch_stac92hd83xxx
},
6568 { .id
= 0x111d76e8, .name
= "92HD66B1X5", .patch
= patch_stac92hd83xxx
},
6569 { .id
= 0x111d76e9, .name
= "92HD66B2X5", .patch
= patch_stac92hd83xxx
},
6570 { .id
= 0x111d76ea, .name
= "92HD66B3X5", .patch
= patch_stac92hd83xxx
},
6571 { .id
= 0x111d76eb, .name
= "92HD66C1X5", .patch
= patch_stac92hd83xxx
},
6572 { .id
= 0x111d76ec, .name
= "92HD66C2X5", .patch
= patch_stac92hd83xxx
},
6573 { .id
= 0x111d76ed, .name
= "92HD66C3X5", .patch
= patch_stac92hd83xxx
},
6574 { .id
= 0x111d76ee, .name
= "92HD66B1X3", .patch
= patch_stac92hd83xxx
},
6575 { .id
= 0x111d76ef, .name
= "92HD66B2X3", .patch
= patch_stac92hd83xxx
},
6576 { .id
= 0x111d76f0, .name
= "92HD66B3X3", .patch
= patch_stac92hd83xxx
},
6577 { .id
= 0x111d76f1, .name
= "92HD66C1X3", .patch
= patch_stac92hd83xxx
},
6578 { .id
= 0x111d76f2, .name
= "92HD66C2X3", .patch
= patch_stac92hd83xxx
},
6579 { .id
= 0x111d76f3, .name
= "92HD66C3/65", .patch
= patch_stac92hd83xxx
},
6583 MODULE_ALIAS("snd-hda-codec-id:8384*");
6584 MODULE_ALIAS("snd-hda-codec-id:111d*");
6586 MODULE_LICENSE("GPL");
6587 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6589 static struct hda_codec_preset_list sigmatel_list
= {
6590 .preset
= snd_hda_preset_sigmatel
,
6591 .owner
= THIS_MODULE
,
6594 static int __init
patch_sigmatel_init(void)
6596 return snd_hda_add_codec_preset(&sigmatel_list
);
6599 static void __exit
patch_sigmatel_exit(void)
6601 snd_hda_delete_codec_preset(&sigmatel_list
);
6604 module_init(patch_sigmatel_init
)
6605 module_exit(patch_sigmatel_exit
)