2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for SigmaTel STAC92xx
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
7 * Matt Porter <mporter@embeddedalley.com>
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <sound/core.h>
32 #include <sound/asoundef.h>
33 #include <sound/jack.h>
34 #include "hda_codec.h"
35 #include "hda_local.h"
79 STAC_92HD73XX_NO_JD
, /* no jack-detection */
93 STAC_92HD83XXX_PWR_REF
,
108 STAC_92HD71BXX_MODELS
134 STAC_INTEL_MAC_AUTO
, /* This model is selected if no module parameter
135 * is given, one of the above models will be
136 * chosen according to the subsystem id. */
137 /* for backward compatibility */
154 STAC_D965_REF_NO_JD
, /* no jack-detection */
170 struct sigmatel_event
{
177 struct sigmatel_jack
{
180 struct snd_jack
*jack
;
183 struct sigmatel_mic_route
{
185 unsigned char mux_idx
;
186 unsigned char dmux_idx
;
189 struct sigmatel_spec
{
190 struct snd_kcontrol_new
*mixers
[4];
191 unsigned int num_mixers
;
194 unsigned int eapd_switch
: 1;
195 unsigned int surr_switch
: 1;
196 unsigned int alt_switch
: 1;
197 unsigned int hp_detect
: 1;
198 unsigned int spdif_mute
: 1;
199 unsigned int check_volume_offset
:1;
200 unsigned int auto_mic
:1;
203 unsigned int eapd_mask
;
204 unsigned int gpio_mask
;
205 unsigned int gpio_dir
;
206 unsigned int gpio_data
;
207 unsigned int gpio_mute
;
208 unsigned int gpio_led
;
211 unsigned int stream_delay
;
213 /* analog loopback */
214 struct snd_kcontrol_new
*aloopback_ctl
;
215 unsigned char aloopback_mask
;
216 unsigned char aloopback_shift
;
218 /* power management */
219 unsigned int num_pwrs
;
220 unsigned int *pwr_mapping
;
225 struct snd_array jacks
;
228 struct snd_array events
;
231 struct hda_input_mux
*mono_mux
;
232 unsigned int cur_mmux
;
233 struct hda_multi_out multiout
;
234 hda_nid_t dac_nids
[5];
235 hda_nid_t hp_dacs
[5];
236 hda_nid_t speaker_dacs
[5];
242 unsigned int num_adcs
;
244 unsigned int num_muxes
;
245 hda_nid_t
*dmic_nids
;
246 unsigned int num_dmics
;
247 hda_nid_t
*dmux_nids
;
248 unsigned int num_dmuxes
;
249 hda_nid_t
*smux_nids
;
250 unsigned int num_smuxes
;
251 unsigned int num_analog_muxes
;
253 unsigned long *capvols
; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
254 unsigned long *capsws
; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
255 unsigned int num_caps
; /* number of capture volume/switch elements */
257 struct sigmatel_mic_route ext_mic
;
258 struct sigmatel_mic_route int_mic
;
260 const char **spdif_labels
;
262 hda_nid_t dig_in_nid
;
264 hda_nid_t anabeep_nid
;
265 hda_nid_t digbeep_nid
;
269 unsigned int num_pins
;
271 /* codec specific stuff */
272 struct hda_verb
*init
;
273 struct snd_kcontrol_new
*mixer
;
276 struct hda_input_mux
*dinput_mux
;
277 unsigned int cur_dmux
[2];
278 struct hda_input_mux
*input_mux
;
279 unsigned int cur_mux
[3];
280 struct hda_input_mux
*sinput_mux
;
281 unsigned int cur_smux
[2];
282 unsigned int cur_amux
;
284 unsigned int powerdown_adcs
;
287 unsigned int io_switch
[2];
288 unsigned int clfe_swap
;
289 hda_nid_t line_switch
; /* shared line-in for input and output */
290 hda_nid_t mic_switch
; /* shared mic-in for input and output */
291 hda_nid_t hp_switch
; /* NID of HP as line-out */
292 unsigned int aloopback
;
294 struct hda_pcm pcm_rec
[2]; /* PCM information */
296 /* dynamic controls and input_mux */
297 struct auto_pin_cfg autocfg
;
298 struct snd_array kctls
;
299 struct hda_input_mux private_dimux
;
300 struct hda_input_mux private_imux
;
301 struct hda_input_mux private_smux
;
302 struct hda_input_mux private_mono_mux
;
305 static hda_nid_t stac9200_adc_nids
[1] = {
309 static hda_nid_t stac9200_mux_nids
[1] = {
313 static hda_nid_t stac9200_dac_nids
[1] = {
317 static hda_nid_t stac92hd73xx_pwr_nids
[8] = {
318 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
322 static hda_nid_t stac92hd73xx_slave_dig_outs
[2] = {
326 static hda_nid_t stac92hd73xx_adc_nids
[2] = {
330 #define STAC92HD73XX_NUM_DMICS 2
331 static hda_nid_t stac92hd73xx_dmic_nids
[STAC92HD73XX_NUM_DMICS
+ 1] = {
335 #define STAC92HD73_DAC_COUNT 5
337 static hda_nid_t stac92hd73xx_mux_nids
[2] = {
341 static hda_nid_t stac92hd73xx_dmux_nids
[2] = {
345 static hda_nid_t stac92hd73xx_smux_nids
[2] = {
349 #define STAC92HD73XX_NUM_CAPS 2
350 static unsigned long stac92hd73xx_capvols
[] = {
351 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT
),
352 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT
),
354 #define stac92hd73xx_capsws stac92hd73xx_capvols
356 #define STAC92HD83_DAC_COUNT 3
358 static hda_nid_t stac92hd83xxx_mux_nids
[2] = {
362 static hda_nid_t stac92hd83xxx_adc_nids
[2] = {
366 static hda_nid_t stac92hd83xxx_pwr_nids
[4] = {
370 static hda_nid_t stac92hd83xxx_slave_dig_outs
[2] = {
374 static unsigned int stac92hd83xxx_pwr_mapping
[4] = {
375 0x03, 0x0c, 0x20, 0x40,
378 #define STAC92HD83XXX_NUM_CAPS 2
379 static unsigned long stac92hd83xxx_capvols
[] = {
380 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT
),
381 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT
),
383 #define stac92hd83xxx_capsws stac92hd83xxx_capvols
385 static hda_nid_t stac92hd71bxx_pwr_nids
[3] = {
389 static hda_nid_t stac92hd71bxx_adc_nids
[2] = {
393 static hda_nid_t stac92hd71bxx_mux_nids
[2] = {
397 static hda_nid_t stac92hd71bxx_dmux_nids
[2] = {
401 static hda_nid_t stac92hd71bxx_smux_nids
[2] = {
405 #define STAC92HD71BXX_NUM_DMICS 2
406 static hda_nid_t stac92hd71bxx_dmic_nids
[STAC92HD71BXX_NUM_DMICS
+ 1] = {
410 static hda_nid_t stac92hd71bxx_slave_dig_outs
[2] = {
414 #define STAC92HD71BXX_NUM_CAPS 2
415 static unsigned long stac92hd71bxx_capvols
[] = {
416 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT
),
417 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT
),
419 #define stac92hd71bxx_capsws stac92hd71bxx_capvols
421 static hda_nid_t stac925x_adc_nids
[1] = {
425 static hda_nid_t stac925x_mux_nids
[1] = {
429 static hda_nid_t stac925x_dac_nids
[1] = {
433 #define STAC925X_NUM_DMICS 1
434 static hda_nid_t stac925x_dmic_nids
[STAC925X_NUM_DMICS
+ 1] = {
438 static hda_nid_t stac925x_dmux_nids
[1] = {
442 static unsigned long stac925x_capvols
[] = {
443 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT
),
445 static unsigned long stac925x_capsws
[] = {
446 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT
),
449 static hda_nid_t stac922x_adc_nids
[2] = {
453 static hda_nid_t stac922x_mux_nids
[2] = {
457 #define STAC922X_NUM_CAPS 2
458 static unsigned long stac922x_capvols
[] = {
459 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT
),
460 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT
),
462 #define stac922x_capsws stac922x_capvols
464 static hda_nid_t stac927x_slave_dig_outs
[2] = {
468 static hda_nid_t stac927x_adc_nids
[3] = {
472 static hda_nid_t stac927x_mux_nids
[3] = {
476 static hda_nid_t stac927x_smux_nids
[1] = {
480 static hda_nid_t stac927x_dac_nids
[6] = {
481 0x02, 0x03, 0x04, 0x05, 0x06, 0
484 static hda_nid_t stac927x_dmux_nids
[1] = {
488 #define STAC927X_NUM_DMICS 2
489 static hda_nid_t stac927x_dmic_nids
[STAC927X_NUM_DMICS
+ 1] = {
493 #define STAC927X_NUM_CAPS 3
494 static unsigned long stac927x_capvols
[] = {
495 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT
),
496 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT
),
497 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT
),
499 static unsigned long stac927x_capsws
[] = {
500 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT
),
501 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT
),
502 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT
),
505 static const char *stac927x_spdif_labels
[5] = {
506 "Digital Playback", "ADAT", "Analog Mux 1",
507 "Analog Mux 2", "Analog Mux 3"
510 static hda_nid_t stac9205_adc_nids
[2] = {
514 static hda_nid_t stac9205_mux_nids
[2] = {
518 static hda_nid_t stac9205_dmux_nids
[1] = {
522 static hda_nid_t stac9205_smux_nids
[1] = {
526 #define STAC9205_NUM_DMICS 2
527 static hda_nid_t stac9205_dmic_nids
[STAC9205_NUM_DMICS
+ 1] = {
531 #define STAC9205_NUM_CAPS 2
532 static unsigned long stac9205_capvols
[] = {
533 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT
),
534 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT
),
536 static unsigned long stac9205_capsws
[] = {
537 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT
),
538 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT
),
541 static hda_nid_t stac9200_pin_nids
[8] = {
542 0x08, 0x09, 0x0d, 0x0e,
543 0x0f, 0x10, 0x11, 0x12,
546 static hda_nid_t stac925x_pin_nids
[8] = {
547 0x07, 0x08, 0x0a, 0x0b,
548 0x0c, 0x0d, 0x10, 0x11,
551 static hda_nid_t stac922x_pin_nids
[10] = {
552 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
553 0x0f, 0x10, 0x11, 0x15, 0x1b,
556 static hda_nid_t stac92hd73xx_pin_nids
[13] = {
557 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
558 0x0f, 0x10, 0x11, 0x12, 0x13,
562 static hda_nid_t stac92hd83xxx_pin_nids
[10] = {
563 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
564 0x0f, 0x10, 0x11, 0x1f, 0x20,
567 #define STAC92HD71BXX_NUM_PINS 13
568 static hda_nid_t stac92hd71bxx_pin_nids_4port
[STAC92HD71BXX_NUM_PINS
] = {
569 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
570 0x00, 0x14, 0x18, 0x19, 0x1e,
573 static hda_nid_t stac92hd71bxx_pin_nids_6port
[STAC92HD71BXX_NUM_PINS
] = {
574 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
575 0x0f, 0x14, 0x18, 0x19, 0x1e,
579 static hda_nid_t stac927x_pin_nids
[14] = {
580 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
581 0x0f, 0x10, 0x11, 0x12, 0x13,
582 0x14, 0x21, 0x22, 0x23,
585 static hda_nid_t stac9205_pin_nids
[12] = {
586 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
587 0x0f, 0x14, 0x16, 0x17, 0x18,
591 static int stac92xx_dmux_enum_info(struct snd_kcontrol
*kcontrol
,
592 struct snd_ctl_elem_info
*uinfo
)
594 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
595 struct sigmatel_spec
*spec
= codec
->spec
;
596 return snd_hda_input_mux_info(spec
->dinput_mux
, uinfo
);
599 static int stac92xx_dmux_enum_get(struct snd_kcontrol
*kcontrol
,
600 struct snd_ctl_elem_value
*ucontrol
)
602 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
603 struct sigmatel_spec
*spec
= codec
->spec
;
604 unsigned int dmux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
606 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_dmux
[dmux_idx
];
610 static int stac92xx_dmux_enum_put(struct snd_kcontrol
*kcontrol
,
611 struct snd_ctl_elem_value
*ucontrol
)
613 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
614 struct sigmatel_spec
*spec
= codec
->spec
;
615 unsigned int dmux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
617 return snd_hda_input_mux_put(codec
, spec
->dinput_mux
, ucontrol
,
618 spec
->dmux_nids
[dmux_idx
], &spec
->cur_dmux
[dmux_idx
]);
621 static int stac92xx_smux_enum_info(struct snd_kcontrol
*kcontrol
,
622 struct snd_ctl_elem_info
*uinfo
)
624 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
625 struct sigmatel_spec
*spec
= codec
->spec
;
626 return snd_hda_input_mux_info(spec
->sinput_mux
, uinfo
);
629 static int stac92xx_smux_enum_get(struct snd_kcontrol
*kcontrol
,
630 struct snd_ctl_elem_value
*ucontrol
)
632 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
633 struct sigmatel_spec
*spec
= codec
->spec
;
634 unsigned int smux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
636 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_smux
[smux_idx
];
640 static int stac92xx_smux_enum_put(struct snd_kcontrol
*kcontrol
,
641 struct snd_ctl_elem_value
*ucontrol
)
643 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
644 struct sigmatel_spec
*spec
= codec
->spec
;
645 struct hda_input_mux
*smux
= &spec
->private_smux
;
646 unsigned int smux_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
650 err
= snd_hda_input_mux_put(codec
, spec
->sinput_mux
, ucontrol
,
651 spec
->smux_nids
[smux_idx
], &spec
->cur_smux
[smux_idx
]);
655 if (spec
->spdif_mute
) {
657 nid
= spec
->multiout
.dig_out_nid
;
659 nid
= codec
->slave_dig_outs
[smux_idx
- 1];
660 if (spec
->cur_smux
[smux_idx
] == smux
->num_items
- 1)
664 /* un/mute SPDIF out */
665 snd_hda_codec_amp_stereo(codec
, nid
, HDA_OUTPUT
, 0,
671 static unsigned int stac92xx_vref_set(struct hda_codec
*codec
,
672 hda_nid_t nid
, unsigned int new_vref
)
676 pincfg
= snd_hda_codec_read(codec
, nid
, 0,
677 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
680 pincfg
&= ~(AC_PINCTL_VREFEN
| AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
);
683 if (new_vref
== AC_PINCTL_VREF_HIZ
)
684 pincfg
|= AC_PINCTL_OUT_EN
;
686 pincfg
|= AC_PINCTL_IN_EN
;
688 error
= snd_hda_codec_write_cache(codec
, nid
, 0,
689 AC_VERB_SET_PIN_WIDGET_CONTROL
, pincfg
);
696 static unsigned int stac92xx_vref_get(struct hda_codec
*codec
, hda_nid_t nid
)
699 vref
= snd_hda_codec_read(codec
, nid
, 0,
700 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
701 vref
&= AC_PINCTL_VREFEN
;
705 static int stac92xx_mux_enum_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
707 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
708 struct sigmatel_spec
*spec
= codec
->spec
;
709 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
712 static int stac92xx_mux_enum_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
714 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
715 struct sigmatel_spec
*spec
= codec
->spec
;
716 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
718 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
722 static int stac92xx_mux_enum_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
724 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
725 struct sigmatel_spec
*spec
= codec
->spec
;
726 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
727 const struct hda_input_mux
*imux
= spec
->input_mux
;
728 unsigned int idx
, prev_idx
;
730 idx
= ucontrol
->value
.enumerated
.item
[0];
731 if (idx
>= imux
->num_items
)
732 idx
= imux
->num_items
- 1;
733 prev_idx
= spec
->cur_mux
[adc_idx
];
736 if (idx
< spec
->num_analog_muxes
) {
737 snd_hda_codec_write_cache(codec
, spec
->mux_nids
[adc_idx
], 0,
738 AC_VERB_SET_CONNECT_SEL
,
739 imux
->items
[idx
].index
);
740 if (prev_idx
>= spec
->num_analog_muxes
) {
741 imux
= spec
->dinput_mux
;
743 snd_hda_codec_write_cache(codec
,
744 spec
->dmux_nids
[adc_idx
], 0,
745 AC_VERB_SET_CONNECT_SEL
,
746 imux
->items
[0].index
);
749 imux
= spec
->dinput_mux
;
750 snd_hda_codec_write_cache(codec
, spec
->dmux_nids
[adc_idx
], 0,
751 AC_VERB_SET_CONNECT_SEL
,
752 imux
->items
[idx
- 1].index
);
754 spec
->cur_mux
[adc_idx
] = idx
;
758 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol
*kcontrol
,
759 struct snd_ctl_elem_info
*uinfo
)
761 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
762 struct sigmatel_spec
*spec
= codec
->spec
;
763 return snd_hda_input_mux_info(spec
->mono_mux
, uinfo
);
766 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol
*kcontrol
,
767 struct snd_ctl_elem_value
*ucontrol
)
769 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
770 struct sigmatel_spec
*spec
= codec
->spec
;
772 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mmux
;
776 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol
*kcontrol
,
777 struct snd_ctl_elem_value
*ucontrol
)
779 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
780 struct sigmatel_spec
*spec
= codec
->spec
;
782 return snd_hda_input_mux_put(codec
, spec
->mono_mux
, ucontrol
,
783 spec
->mono_nid
, &spec
->cur_mmux
);
786 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
788 static int stac92xx_aloopback_get(struct snd_kcontrol
*kcontrol
,
789 struct snd_ctl_elem_value
*ucontrol
)
791 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
792 unsigned int idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
793 struct sigmatel_spec
*spec
= codec
->spec
;
795 ucontrol
->value
.integer
.value
[0] = !!(spec
->aloopback
&
796 (spec
->aloopback_mask
<< idx
));
800 static int stac92xx_aloopback_put(struct snd_kcontrol
*kcontrol
,
801 struct snd_ctl_elem_value
*ucontrol
)
803 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
804 struct sigmatel_spec
*spec
= codec
->spec
;
805 unsigned int idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
806 unsigned int dac_mode
;
807 unsigned int val
, idx_val
;
809 idx_val
= spec
->aloopback_mask
<< idx
;
810 if (ucontrol
->value
.integer
.value
[0])
811 val
= spec
->aloopback
| idx_val
;
813 val
= spec
->aloopback
& ~idx_val
;
814 if (spec
->aloopback
== val
)
817 spec
->aloopback
= val
;
819 /* Only return the bits defined by the shift value of the
820 * first two bytes of the mask
822 dac_mode
= snd_hda_codec_read(codec
, codec
->afg
, 0,
823 kcontrol
->private_value
& 0xFFFF, 0x0);
824 dac_mode
>>= spec
->aloopback_shift
;
826 if (spec
->aloopback
& idx_val
) {
827 snd_hda_power_up(codec
);
830 snd_hda_power_down(codec
);
831 dac_mode
&= ~idx_val
;
834 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
835 kcontrol
->private_value
>> 16, dac_mode
);
840 static struct hda_verb stac9200_core_init
[] = {
841 /* set dac0mux for dac converter */
842 { 0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
846 static struct hda_verb stac9200_eapd_init
[] = {
847 /* set dac0mux for dac converter */
848 {0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
849 {0x08, AC_VERB_SET_EAPD_BTLENABLE
, 0x02},
853 static struct hda_verb dell_eq_core_init
[] = {
854 /* set master volume to max value without distortion
855 * and direct control */
856 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xec},
860 static struct hda_verb stac92hd73xx_core_init
[] = {
861 /* set master volume and direct control */
862 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
866 static struct hda_verb stac92hd83xxx_core_init
[] = {
867 { 0xa, AC_VERB_SET_CONNECT_SEL
, 0x1},
868 { 0xb, AC_VERB_SET_CONNECT_SEL
, 0x1},
869 { 0xd, AC_VERB_SET_CONNECT_SEL
, 0x0},
871 /* power state controls amps */
872 { 0x01, AC_VERB_SET_EAPD
, 1 << 2},
876 static struct hda_verb stac92hd71bxx_core_init
[] = {
877 /* set master volume and direct control */
878 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
882 static struct hda_verb stac92hd71bxx_unmute_core_init
[] = {
883 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
884 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
885 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
886 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)},
890 static struct hda_verb stac925x_core_init
[] = {
891 /* set dac0mux for dac converter */
892 { 0x06, AC_VERB_SET_CONNECT_SEL
, 0x00},
893 /* mute the master volume */
894 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
},
898 static struct hda_verb stac922x_core_init
[] = {
899 /* set master volume and direct control */
900 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
904 static struct hda_verb d965_core_init
[] = {
905 /* set master volume and direct control */
906 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
907 /* unmute node 0x1b */
908 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
909 /* select node 0x03 as DAC */
910 { 0x0b, AC_VERB_SET_CONNECT_SEL
, 0x01},
914 static struct hda_verb stac927x_core_init
[] = {
915 /* set master volume and direct control */
916 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
917 /* enable analog pc beep path */
918 { 0x01, AC_VERB_SET_DIGI_CONVERT_2
, 1 << 5},
922 static struct hda_verb stac9205_core_init
[] = {
923 /* set master volume and direct control */
924 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
925 /* enable analog pc beep path */
926 { 0x01, AC_VERB_SET_DIGI_CONVERT_2
, 1 << 5},
930 #define STAC_MONO_MUX \
932 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
933 .name = "Mono Mux", \
935 .info = stac92xx_mono_mux_enum_info, \
936 .get = stac92xx_mono_mux_enum_get, \
937 .put = stac92xx_mono_mux_enum_put, \
940 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
943 .name = "Analog Loopback", \
945 .info = stac92xx_aloopback_info, \
946 .get = stac92xx_aloopback_get, \
947 .put = stac92xx_aloopback_put, \
948 .private_value = verb_read | (verb_write << 16), \
951 #define DC_BIAS(xname, idx, nid) \
953 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
956 .info = stac92xx_dc_bias_info, \
957 .get = stac92xx_dc_bias_get, \
958 .put = stac92xx_dc_bias_put, \
959 .private_value = nid, \
962 static struct snd_kcontrol_new stac9200_mixer
[] = {
963 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT
),
964 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT
),
965 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT
),
966 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT
),
970 static struct snd_kcontrol_new stac92hd73xx_6ch_loopback
[] = {
971 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
975 static struct snd_kcontrol_new stac92hd73xx_8ch_loopback
[] = {
976 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
980 static struct snd_kcontrol_new stac92hd73xx_10ch_loopback
[] = {
981 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
986 static struct snd_kcontrol_new stac92hd71bxx_loopback
[] = {
987 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
990 static struct snd_kcontrol_new stac925x_mixer
[] = {
991 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT
),
992 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT
),
996 static struct snd_kcontrol_new stac9205_loopback
[] = {
997 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1001 static struct snd_kcontrol_new stac927x_loopback
[] = {
1002 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1006 static struct snd_kcontrol_new stac_dmux_mixer
= {
1007 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1008 .name
= "Digital Input Source",
1009 /* count set later */
1010 .info
= stac92xx_dmux_enum_info
,
1011 .get
= stac92xx_dmux_enum_get
,
1012 .put
= stac92xx_dmux_enum_put
,
1015 static struct snd_kcontrol_new stac_smux_mixer
= {
1016 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1017 .name
= "IEC958 Playback Source",
1018 /* count set later */
1019 .info
= stac92xx_smux_enum_info
,
1020 .get
= stac92xx_smux_enum_get
,
1021 .put
= stac92xx_smux_enum_put
,
1024 static const char *slave_vols
[] = {
1025 "Front Playback Volume",
1026 "Surround Playback Volume",
1027 "Center Playback Volume",
1028 "LFE Playback Volume",
1029 "Side Playback Volume",
1030 "Headphone Playback Volume",
1031 "Speaker Playback Volume",
1035 static const char *slave_sws
[] = {
1036 "Front Playback Switch",
1037 "Surround Playback Switch",
1038 "Center Playback Switch",
1039 "LFE Playback Switch",
1040 "Side Playback Switch",
1041 "Headphone Playback Switch",
1042 "Speaker Playback Switch",
1043 "IEC958 Playback Switch",
1047 static void stac92xx_free_kctls(struct hda_codec
*codec
);
1048 static int stac92xx_add_jack(struct hda_codec
*codec
, hda_nid_t nid
, int type
);
1050 static int stac92xx_build_controls(struct hda_codec
*codec
)
1052 struct sigmatel_spec
*spec
= codec
->spec
;
1053 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1059 err
= snd_hda_add_new_ctls(codec
, spec
->mixer
);
1064 for (i
= 0; i
< spec
->num_mixers
; i
++) {
1065 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
1069 if (!spec
->auto_mic
&& spec
->num_dmuxes
> 0 &&
1070 snd_hda_get_bool_hint(codec
, "separate_dmux") == 1) {
1071 stac_dmux_mixer
.count
= spec
->num_dmuxes
;
1072 err
= snd_hda_ctl_add(codec
,
1073 snd_ctl_new1(&stac_dmux_mixer
, codec
));
1077 if (spec
->num_smuxes
> 0) {
1078 int wcaps
= get_wcaps(codec
, spec
->multiout
.dig_out_nid
);
1079 struct hda_input_mux
*smux
= &spec
->private_smux
;
1080 /* check for mute support on SPDIF out */
1081 if (wcaps
& AC_WCAP_OUT_AMP
) {
1082 smux
->items
[smux
->num_items
].label
= "Off";
1083 smux
->items
[smux
->num_items
].index
= 0;
1085 spec
->spdif_mute
= 1;
1087 stac_smux_mixer
.count
= spec
->num_smuxes
;
1088 err
= snd_hda_ctl_add(codec
,
1089 snd_ctl_new1(&stac_smux_mixer
, codec
));
1094 if (spec
->multiout
.dig_out_nid
) {
1095 err
= snd_hda_create_spdif_out_ctls(codec
, spec
->multiout
.dig_out_nid
);
1098 err
= snd_hda_create_spdif_share_sw(codec
,
1102 spec
->multiout
.share_spdif
= 1;
1104 if (spec
->dig_in_nid
&& !(spec
->gpio_dir
& 0x01)) {
1105 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
1110 /* if we have no master control, let's create it */
1111 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Volume")) {
1112 unsigned int vmaster_tlv
[4];
1113 snd_hda_set_vmaster_tlv(codec
, spec
->multiout
.dac_nids
[0],
1114 HDA_OUTPUT
, vmaster_tlv
);
1115 /* correct volume offset */
1116 vmaster_tlv
[2] += vmaster_tlv
[3] * spec
->volume_offset
;
1117 err
= snd_hda_add_vmaster(codec
, "Master Playback Volume",
1118 vmaster_tlv
, slave_vols
);
1122 if (!snd_hda_find_mixer_ctl(codec
, "Master Playback Switch")) {
1123 err
= snd_hda_add_vmaster(codec
, "Master Playback Switch",
1129 if (spec
->aloopback_ctl
&&
1130 snd_hda_get_bool_hint(codec
, "loopback") == 1) {
1131 err
= snd_hda_add_new_ctls(codec
, spec
->aloopback_ctl
);
1136 stac92xx_free_kctls(codec
); /* no longer needed */
1138 /* create jack input elements */
1139 if (spec
->hp_detect
) {
1140 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
1141 int type
= SND_JACK_HEADPHONE
;
1142 nid
= cfg
->hp_pins
[i
];
1143 /* jack detection */
1144 if (cfg
->hp_outs
== i
)
1145 type
|= SND_JACK_LINEOUT
;
1146 err
= stac92xx_add_jack(codec
, nid
, type
);
1151 for (i
= 0; i
< cfg
->line_outs
; i
++) {
1152 err
= stac92xx_add_jack(codec
, cfg
->line_out_pins
[i
],
1157 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
1158 nid
= cfg
->input_pins
[i
];
1160 err
= stac92xx_add_jack(codec
, nid
,
1161 SND_JACK_MICROPHONE
);
1170 static unsigned int ref9200_pin_configs
[8] = {
1171 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1172 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1175 static unsigned int gateway9200_m4_pin_configs
[8] = {
1176 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1177 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1179 static unsigned int gateway9200_m4_2_pin_configs
[8] = {
1180 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1181 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1185 STAC 9200 pin configs for
1190 static unsigned int dell9200_d21_pin_configs
[8] = {
1191 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1192 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1196 STAC 9200 pin configs for
1200 static unsigned int dell9200_d22_pin_configs
[8] = {
1201 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1202 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1206 STAC 9200 pin configs for
1207 102801C4 (Dell Dimension E310)
1214 static unsigned int dell9200_d23_pin_configs
[8] = {
1215 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1216 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1221 STAC 9200-32 pin configs for
1222 102801B5 (Dell Inspiron 630m)
1223 102801D8 (Dell Inspiron 640m)
1225 static unsigned int dell9200_m21_pin_configs
[8] = {
1226 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1227 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1231 STAC 9200-32 pin configs for
1232 102801C2 (Dell Latitude D620)
1234 102801CC (Dell Latitude D820)
1238 static unsigned int dell9200_m22_pin_configs
[8] = {
1239 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1240 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1244 STAC 9200-32 pin configs for
1245 102801CE (Dell XPS M1710)
1246 102801CF (Dell Precision M90)
1248 static unsigned int dell9200_m23_pin_configs
[8] = {
1249 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1250 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1254 STAC 9200-32 pin configs for
1257 102801CB (Dell Latitude 120L)
1260 static unsigned int dell9200_m24_pin_configs
[8] = {
1261 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1262 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1266 STAC 9200-32 pin configs for
1267 102801BD (Dell Inspiron E1505n)
1271 static unsigned int dell9200_m25_pin_configs
[8] = {
1272 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1273 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1277 STAC 9200-32 pin configs for
1278 102801F5 (Dell Inspiron 1501)
1281 static unsigned int dell9200_m26_pin_configs
[8] = {
1282 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1283 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1288 102801CD (Dell Inspiron E1705/9400)
1290 static unsigned int dell9200_m27_pin_configs
[8] = {
1291 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1292 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1295 static unsigned int oqo9200_pin_configs
[8] = {
1296 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1297 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1301 static unsigned int *stac9200_brd_tbl
[STAC_9200_MODELS
] = {
1302 [STAC_REF
] = ref9200_pin_configs
,
1303 [STAC_9200_OQO
] = oqo9200_pin_configs
,
1304 [STAC_9200_DELL_D21
] = dell9200_d21_pin_configs
,
1305 [STAC_9200_DELL_D22
] = dell9200_d22_pin_configs
,
1306 [STAC_9200_DELL_D23
] = dell9200_d23_pin_configs
,
1307 [STAC_9200_DELL_M21
] = dell9200_m21_pin_configs
,
1308 [STAC_9200_DELL_M22
] = dell9200_m22_pin_configs
,
1309 [STAC_9200_DELL_M23
] = dell9200_m23_pin_configs
,
1310 [STAC_9200_DELL_M24
] = dell9200_m24_pin_configs
,
1311 [STAC_9200_DELL_M25
] = dell9200_m25_pin_configs
,
1312 [STAC_9200_DELL_M26
] = dell9200_m26_pin_configs
,
1313 [STAC_9200_DELL_M27
] = dell9200_m27_pin_configs
,
1314 [STAC_9200_M4
] = gateway9200_m4_pin_configs
,
1315 [STAC_9200_M4_2
] = gateway9200_m4_2_pin_configs
,
1316 [STAC_9200_PANASONIC
] = ref9200_pin_configs
,
1319 static const char *stac9200_models
[STAC_9200_MODELS
] = {
1320 [STAC_AUTO
] = "auto",
1322 [STAC_9200_OQO
] = "oqo",
1323 [STAC_9200_DELL_D21
] = "dell-d21",
1324 [STAC_9200_DELL_D22
] = "dell-d22",
1325 [STAC_9200_DELL_D23
] = "dell-d23",
1326 [STAC_9200_DELL_M21
] = "dell-m21",
1327 [STAC_9200_DELL_M22
] = "dell-m22",
1328 [STAC_9200_DELL_M23
] = "dell-m23",
1329 [STAC_9200_DELL_M24
] = "dell-m24",
1330 [STAC_9200_DELL_M25
] = "dell-m25",
1331 [STAC_9200_DELL_M26
] = "dell-m26",
1332 [STAC_9200_DELL_M27
] = "dell-m27",
1333 [STAC_9200_M4
] = "gateway-m4",
1334 [STAC_9200_M4_2
] = "gateway-m4-2",
1335 [STAC_9200_PANASONIC
] = "panasonic",
1338 static struct snd_pci_quirk stac9200_cfg_tbl
[] = {
1339 /* SigmaTel reference board */
1340 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1341 "DFI LanParty", STAC_REF
),
1342 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
1343 "DFI LanParty", STAC_REF
),
1344 /* Dell laptops have BIOS problem */
1345 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01a8,
1346 "unknown Dell", STAC_9200_DELL_D21
),
1347 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01b5,
1348 "Dell Inspiron 630m", STAC_9200_DELL_M21
),
1349 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01bd,
1350 "Dell Inspiron E1505n", STAC_9200_DELL_M25
),
1351 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c0,
1352 "unknown Dell", STAC_9200_DELL_D22
),
1353 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c1,
1354 "unknown Dell", STAC_9200_DELL_D22
),
1355 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c2,
1356 "Dell Latitude D620", STAC_9200_DELL_M22
),
1357 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c5,
1358 "unknown Dell", STAC_9200_DELL_D23
),
1359 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c7,
1360 "unknown Dell", STAC_9200_DELL_D23
),
1361 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c8,
1362 "unknown Dell", STAC_9200_DELL_M22
),
1363 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c9,
1364 "unknown Dell", STAC_9200_DELL_M24
),
1365 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ca,
1366 "unknown Dell", STAC_9200_DELL_M24
),
1367 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cb,
1368 "Dell Latitude 120L", STAC_9200_DELL_M24
),
1369 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cc,
1370 "Dell Latitude D820", STAC_9200_DELL_M22
),
1371 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cd,
1372 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27
),
1373 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ce,
1374 "Dell XPS M1710", STAC_9200_DELL_M23
),
1375 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cf,
1376 "Dell Precision M90", STAC_9200_DELL_M23
),
1377 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d3,
1378 "unknown Dell", STAC_9200_DELL_M22
),
1379 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d4,
1380 "unknown Dell", STAC_9200_DELL_M22
),
1381 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d6,
1382 "unknown Dell", STAC_9200_DELL_M22
),
1383 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d8,
1384 "Dell Inspiron 640m", STAC_9200_DELL_M21
),
1385 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d9,
1386 "unknown Dell", STAC_9200_DELL_D23
),
1387 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01da,
1388 "unknown Dell", STAC_9200_DELL_D23
),
1389 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01de,
1390 "unknown Dell", STAC_9200_DELL_D21
),
1391 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01e3,
1392 "unknown Dell", STAC_9200_DELL_D23
),
1393 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01e8,
1394 "unknown Dell", STAC_9200_DELL_D21
),
1395 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ee,
1396 "unknown Dell", STAC_9200_DELL_M25
),
1397 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ef,
1398 "unknown Dell", STAC_9200_DELL_M25
),
1399 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f5,
1400 "Dell Inspiron 1501", STAC_9200_DELL_M26
),
1401 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f6,
1402 "unknown Dell", STAC_9200_DELL_M26
),
1404 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC
),
1405 /* Gateway machines needs EAPD to be set on resume */
1406 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4
),
1407 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2
),
1408 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2
),
1410 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO
),
1414 static unsigned int ref925x_pin_configs
[8] = {
1415 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1416 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1419 static unsigned int stac925xM1_pin_configs
[8] = {
1420 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1421 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1424 static unsigned int stac925xM1_2_pin_configs
[8] = {
1425 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1426 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1429 static unsigned int stac925xM2_pin_configs
[8] = {
1430 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1431 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1434 static unsigned int stac925xM2_2_pin_configs
[8] = {
1435 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1436 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1439 static unsigned int stac925xM3_pin_configs
[8] = {
1440 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1441 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1444 static unsigned int stac925xM5_pin_configs
[8] = {
1445 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1446 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1449 static unsigned int stac925xM6_pin_configs
[8] = {
1450 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1451 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1454 static unsigned int *stac925x_brd_tbl
[STAC_925x_MODELS
] = {
1455 [STAC_REF
] = ref925x_pin_configs
,
1456 [STAC_M1
] = stac925xM1_pin_configs
,
1457 [STAC_M1_2
] = stac925xM1_2_pin_configs
,
1458 [STAC_M2
] = stac925xM2_pin_configs
,
1459 [STAC_M2_2
] = stac925xM2_2_pin_configs
,
1460 [STAC_M3
] = stac925xM3_pin_configs
,
1461 [STAC_M5
] = stac925xM5_pin_configs
,
1462 [STAC_M6
] = stac925xM6_pin_configs
,
1465 static const char *stac925x_models
[STAC_925x_MODELS
] = {
1466 [STAC_925x_AUTO
] = "auto",
1469 [STAC_M1_2
] = "m1-2",
1471 [STAC_M2_2
] = "m2-2",
1477 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl
[] = {
1478 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2
),
1479 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5
),
1480 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1
),
1481 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2
),
1482 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2
),
1483 /* Not sure about the brand name for those */
1484 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1
),
1485 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3
),
1486 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6
),
1487 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2
),
1491 static struct snd_pci_quirk stac925x_cfg_tbl
[] = {
1492 /* SigmaTel reference board */
1493 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668, "DFI LanParty", STAC_REF
),
1494 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101, "DFI LanParty", STAC_REF
),
1495 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF
),
1497 /* Default table for unknown ID */
1498 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2
),
1503 static unsigned int ref92hd73xx_pin_configs
[13] = {
1504 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1505 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1506 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1510 static unsigned int dell_m6_pin_configs
[13] = {
1511 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1512 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1513 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1517 static unsigned int alienware_m17x_pin_configs
[13] = {
1518 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1519 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1520 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1524 static unsigned int *stac92hd73xx_brd_tbl
[STAC_92HD73XX_MODELS
] = {
1525 [STAC_92HD73XX_REF
] = ref92hd73xx_pin_configs
,
1526 [STAC_DELL_M6_AMIC
] = dell_m6_pin_configs
,
1527 [STAC_DELL_M6_DMIC
] = dell_m6_pin_configs
,
1528 [STAC_DELL_M6_BOTH
] = dell_m6_pin_configs
,
1529 [STAC_DELL_EQ
] = dell_m6_pin_configs
,
1530 [STAC_ALIENWARE_M17X
] = alienware_m17x_pin_configs
,
1533 static const char *stac92hd73xx_models
[STAC_92HD73XX_MODELS
] = {
1534 [STAC_92HD73XX_AUTO
] = "auto",
1535 [STAC_92HD73XX_NO_JD
] = "no-jd",
1536 [STAC_92HD73XX_REF
] = "ref",
1537 [STAC_92HD73XX_INTEL
] = "intel",
1538 [STAC_DELL_M6_AMIC
] = "dell-m6-amic",
1539 [STAC_DELL_M6_DMIC
] = "dell-m6-dmic",
1540 [STAC_DELL_M6_BOTH
] = "dell-m6",
1541 [STAC_DELL_EQ
] = "dell-eq",
1542 [STAC_ALIENWARE_M17X
] = "alienware",
1545 static struct snd_pci_quirk stac92hd73xx_cfg_tbl
[] = {
1546 /* SigmaTel reference board */
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1548 "DFI LanParty", STAC_92HD73XX_REF
),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
1550 "DFI LanParty", STAC_92HD73XX_REF
),
1551 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5002,
1552 "Intel DG45ID", STAC_92HD73XX_INTEL
),
1553 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5003,
1554 "Intel DG45FC", STAC_92HD73XX_INTEL
),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0254,
1556 "Dell Studio 1535", STAC_DELL_M6_DMIC
),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0255,
1558 "unknown Dell", STAC_DELL_M6_DMIC
),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0256,
1560 "unknown Dell", STAC_DELL_M6_BOTH
),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0257,
1562 "unknown Dell", STAC_DELL_M6_BOTH
),
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x025e,
1564 "unknown Dell", STAC_DELL_M6_AMIC
),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x025f,
1566 "unknown Dell", STAC_DELL_M6_AMIC
),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0271,
1568 "unknown Dell", STAC_DELL_M6_DMIC
),
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0272,
1570 "unknown Dell", STAC_DELL_M6_DMIC
),
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x029f,
1572 "Dell Studio 1537", STAC_DELL_M6_DMIC
),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02a0,
1574 "Dell Studio 17", STAC_DELL_M6_DMIC
),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02be,
1576 "Dell Studio 1555", STAC_DELL_M6_DMIC
),
1580 static struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl
[] = {
1581 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02a1,
1582 "Alienware M17x", STAC_ALIENWARE_M17X
),
1586 static unsigned int ref92hd83xxx_pin_configs
[10] = {
1587 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1588 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1589 0x01451160, 0x98560170,
1592 static unsigned int dell_s14_pin_configs
[10] = {
1593 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1594 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1595 0x40f000f0, 0x40f000f0,
1598 static unsigned int *stac92hd83xxx_brd_tbl
[STAC_92HD83XXX_MODELS
] = {
1599 [STAC_92HD83XXX_REF
] = ref92hd83xxx_pin_configs
,
1600 [STAC_92HD83XXX_PWR_REF
] = ref92hd83xxx_pin_configs
,
1601 [STAC_DELL_S14
] = dell_s14_pin_configs
,
1604 static const char *stac92hd83xxx_models
[STAC_92HD83XXX_MODELS
] = {
1605 [STAC_92HD83XXX_AUTO
] = "auto",
1606 [STAC_92HD83XXX_REF
] = "ref",
1607 [STAC_92HD83XXX_PWR_REF
] = "mic-ref",
1608 [STAC_DELL_S14
] = "dell-s14",
1611 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl
[] = {
1612 /* SigmaTel reference board */
1613 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1614 "DFI LanParty", STAC_92HD83XXX_REF
),
1615 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
1616 "DFI LanParty", STAC_92HD83XXX_REF
),
1617 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02ba,
1618 "unknown Dell", STAC_DELL_S14
),
1622 static unsigned int ref92hd71bxx_pin_configs
[STAC92HD71BXX_NUM_PINS
] = {
1623 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1624 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1625 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1629 static unsigned int dell_m4_1_pin_configs
[STAC92HD71BXX_NUM_PINS
] = {
1630 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1631 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1632 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1636 static unsigned int dell_m4_2_pin_configs
[STAC92HD71BXX_NUM_PINS
] = {
1637 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1638 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1639 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1643 static unsigned int dell_m4_3_pin_configs
[STAC92HD71BXX_NUM_PINS
] = {
1644 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1645 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1646 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1650 static unsigned int *stac92hd71bxx_brd_tbl
[STAC_92HD71BXX_MODELS
] = {
1651 [STAC_92HD71BXX_REF
] = ref92hd71bxx_pin_configs
,
1652 [STAC_DELL_M4_1
] = dell_m4_1_pin_configs
,
1653 [STAC_DELL_M4_2
] = dell_m4_2_pin_configs
,
1654 [STAC_DELL_M4_3
] = dell_m4_3_pin_configs
,
1655 [STAC_HP_M4
] = NULL
,
1656 [STAC_HP_DV5
] = NULL
,
1657 [STAC_HP_HDX
] = NULL
,
1658 [STAC_HP_DV4_1222NR
] = NULL
,
1661 static const char *stac92hd71bxx_models
[STAC_92HD71BXX_MODELS
] = {
1662 [STAC_92HD71BXX_AUTO
] = "auto",
1663 [STAC_92HD71BXX_REF
] = "ref",
1664 [STAC_DELL_M4_1
] = "dell-m4-1",
1665 [STAC_DELL_M4_2
] = "dell-m4-2",
1666 [STAC_DELL_M4_3
] = "dell-m4-3",
1667 [STAC_HP_M4
] = "hp-m4",
1668 [STAC_HP_DV5
] = "hp-dv5",
1669 [STAC_HP_HDX
] = "hp-hdx",
1670 [STAC_HP_DV4_1222NR
] = "hp-dv4-1222nr",
1673 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl
[] = {
1674 /* SigmaTel reference board */
1675 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1676 "DFI LanParty", STAC_92HD71BXX_REF
),
1677 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
1678 "DFI LanParty", STAC_92HD71BXX_REF
),
1679 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x30fb,
1680 "HP dv4-1222nr", STAC_HP_DV4_1222NR
),
1681 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP
, 0xfff0, 0x3080,
1683 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP
, 0xfff0, 0x30f0,
1684 "HP dv4-7", STAC_HP_DV5
),
1685 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP
, 0xfff0, 0x3600,
1686 "HP dv4-7", STAC_HP_DV5
),
1687 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x3610,
1688 "HP HDX", STAC_HP_HDX
), /* HDX18 */
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x361a,
1690 "HP mini 1000", STAC_HP_M4
),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_HP
, 0x361b,
1692 "HP HDX", STAC_HP_HDX
), /* HDX16 */
1693 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP
, 0xfff0, 0x7010,
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0233,
1696 "unknown Dell", STAC_DELL_M4_1
),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0234,
1698 "unknown Dell", STAC_DELL_M4_1
),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0250,
1700 "unknown Dell", STAC_DELL_M4_1
),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x024f,
1702 "unknown Dell", STAC_DELL_M4_1
),
1703 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x024d,
1704 "unknown Dell", STAC_DELL_M4_1
),
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0251,
1706 "unknown Dell", STAC_DELL_M4_1
),
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0277,
1708 "unknown Dell", STAC_DELL_M4_1
),
1709 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0263,
1710 "unknown Dell", STAC_DELL_M4_2
),
1711 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0265,
1712 "unknown Dell", STAC_DELL_M4_2
),
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0262,
1714 "unknown Dell", STAC_DELL_M4_2
),
1715 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0264,
1716 "unknown Dell", STAC_DELL_M4_2
),
1717 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02aa,
1718 "unknown Dell", STAC_DELL_M4_3
),
1722 static unsigned int ref922x_pin_configs
[10] = {
1723 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1724 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1725 0x40000100, 0x40000100,
1729 STAC 922X pin configs for
1736 static unsigned int dell_922x_d81_pin_configs
[10] = {
1737 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1738 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1739 0x01813122, 0x400001f2,
1743 STAC 922X pin configs for
1747 static unsigned int dell_922x_d82_pin_configs
[10] = {
1748 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1749 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1750 0x01813122, 0x400001f1,
1754 STAC 922X pin configs for
1757 static unsigned int dell_922x_m81_pin_configs
[10] = {
1758 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1759 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1760 0x40C003f1, 0x405003f0,
1764 STAC 9221 A1 pin configs for
1765 102801D7 (Dell XPS M1210)
1767 static unsigned int dell_922x_m82_pin_configs
[10] = {
1768 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1769 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1770 0x508003f3, 0x405003f4,
1773 static unsigned int d945gtp3_pin_configs
[10] = {
1774 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1775 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1776 0x02a19120, 0x40000100,
1779 static unsigned int d945gtp5_pin_configs
[10] = {
1780 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1781 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1782 0x02a19320, 0x40000100,
1785 static unsigned int intel_mac_v1_pin_configs
[10] = {
1786 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1787 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1788 0x400000fc, 0x400000fb,
1791 static unsigned int intel_mac_v2_pin_configs
[10] = {
1792 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1793 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1794 0x400000fc, 0x400000fb,
1797 static unsigned int intel_mac_v3_pin_configs
[10] = {
1798 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1799 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1800 0x400000fc, 0x400000fb,
1803 static unsigned int intel_mac_v4_pin_configs
[10] = {
1804 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1805 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1806 0x400000fc, 0x400000fb,
1809 static unsigned int intel_mac_v5_pin_configs
[10] = {
1810 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1811 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1812 0x400000fc, 0x400000fb,
1815 static unsigned int ecs202_pin_configs
[10] = {
1816 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1817 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1818 0x9037012e, 0x40e000f2,
1821 static unsigned int *stac922x_brd_tbl
[STAC_922X_MODELS
] = {
1822 [STAC_D945_REF
] = ref922x_pin_configs
,
1823 [STAC_D945GTP3
] = d945gtp3_pin_configs
,
1824 [STAC_D945GTP5
] = d945gtp5_pin_configs
,
1825 [STAC_INTEL_MAC_V1
] = intel_mac_v1_pin_configs
,
1826 [STAC_INTEL_MAC_V2
] = intel_mac_v2_pin_configs
,
1827 [STAC_INTEL_MAC_V3
] = intel_mac_v3_pin_configs
,
1828 [STAC_INTEL_MAC_V4
] = intel_mac_v4_pin_configs
,
1829 [STAC_INTEL_MAC_V5
] = intel_mac_v5_pin_configs
,
1830 [STAC_INTEL_MAC_AUTO
] = intel_mac_v3_pin_configs
,
1831 /* for backward compatibility */
1832 [STAC_MACMINI
] = intel_mac_v3_pin_configs
,
1833 [STAC_MACBOOK
] = intel_mac_v5_pin_configs
,
1834 [STAC_MACBOOK_PRO_V1
] = intel_mac_v3_pin_configs
,
1835 [STAC_MACBOOK_PRO_V2
] = intel_mac_v3_pin_configs
,
1836 [STAC_IMAC_INTEL
] = intel_mac_v2_pin_configs
,
1837 [STAC_IMAC_INTEL_20
] = intel_mac_v3_pin_configs
,
1838 [STAC_ECS_202
] = ecs202_pin_configs
,
1839 [STAC_922X_DELL_D81
] = dell_922x_d81_pin_configs
,
1840 [STAC_922X_DELL_D82
] = dell_922x_d82_pin_configs
,
1841 [STAC_922X_DELL_M81
] = dell_922x_m81_pin_configs
,
1842 [STAC_922X_DELL_M82
] = dell_922x_m82_pin_configs
,
1845 static const char *stac922x_models
[STAC_922X_MODELS
] = {
1846 [STAC_922X_AUTO
] = "auto",
1847 [STAC_D945_REF
] = "ref",
1848 [STAC_D945GTP5
] = "5stack",
1849 [STAC_D945GTP3
] = "3stack",
1850 [STAC_INTEL_MAC_V1
] = "intel-mac-v1",
1851 [STAC_INTEL_MAC_V2
] = "intel-mac-v2",
1852 [STAC_INTEL_MAC_V3
] = "intel-mac-v3",
1853 [STAC_INTEL_MAC_V4
] = "intel-mac-v4",
1854 [STAC_INTEL_MAC_V5
] = "intel-mac-v5",
1855 [STAC_INTEL_MAC_AUTO
] = "intel-mac-auto",
1856 /* for backward compatibility */
1857 [STAC_MACMINI
] = "macmini",
1858 [STAC_MACBOOK
] = "macbook",
1859 [STAC_MACBOOK_PRO_V1
] = "macbook-pro-v1",
1860 [STAC_MACBOOK_PRO_V2
] = "macbook-pro",
1861 [STAC_IMAC_INTEL
] = "imac-intel",
1862 [STAC_IMAC_INTEL_20
] = "imac-intel-20",
1863 [STAC_ECS_202
] = "ecs202",
1864 [STAC_922X_DELL_D81
] = "dell-d81",
1865 [STAC_922X_DELL_D82
] = "dell-d82",
1866 [STAC_922X_DELL_M81
] = "dell-m81",
1867 [STAC_922X_DELL_M82
] = "dell-m82",
1870 static struct snd_pci_quirk stac922x_cfg_tbl
[] = {
1871 /* SigmaTel reference board */
1872 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
1873 "DFI LanParty", STAC_D945_REF
),
1874 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
1875 "DFI LanParty", STAC_D945_REF
),
1876 /* Intel 945G based systems */
1877 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0101,
1878 "Intel D945G", STAC_D945GTP3
),
1879 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0202,
1880 "Intel D945G", STAC_D945GTP3
),
1881 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0606,
1882 "Intel D945G", STAC_D945GTP3
),
1883 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0601,
1884 "Intel D945G", STAC_D945GTP3
),
1885 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0111,
1886 "Intel D945G", STAC_D945GTP3
),
1887 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1115,
1888 "Intel D945G", STAC_D945GTP3
),
1889 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1116,
1890 "Intel D945G", STAC_D945GTP3
),
1891 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1117,
1892 "Intel D945G", STAC_D945GTP3
),
1893 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1118,
1894 "Intel D945G", STAC_D945GTP3
),
1895 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1119,
1896 "Intel D945G", STAC_D945GTP3
),
1897 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x8826,
1898 "Intel D945G", STAC_D945GTP3
),
1899 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5049,
1900 "Intel D945G", STAC_D945GTP3
),
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5055,
1902 "Intel D945G", STAC_D945GTP3
),
1903 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5048,
1904 "Intel D945G", STAC_D945GTP3
),
1905 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0110,
1906 "Intel D945G", STAC_D945GTP3
),
1907 /* Intel D945G 5-stack systems */
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0404,
1909 "Intel D945G", STAC_D945GTP5
),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0303,
1911 "Intel D945G", STAC_D945GTP5
),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0013,
1913 "Intel D945G", STAC_D945GTP5
),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0417,
1915 "Intel D945G", STAC_D945GTP5
),
1916 /* Intel 945P based systems */
1917 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0b0b,
1918 "Intel D945P", STAC_D945GTP3
),
1919 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0112,
1920 "Intel D945P", STAC_D945GTP3
),
1921 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0d0d,
1922 "Intel D945P", STAC_D945GTP3
),
1923 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0909,
1924 "Intel D945P", STAC_D945GTP3
),
1925 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0505,
1926 "Intel D945P", STAC_D945GTP3
),
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0707,
1928 "Intel D945P", STAC_D945GTP5
),
1930 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0204,
1931 "Intel D945", STAC_D945_REF
),
1933 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1934 SND_PCI_QUIRK(0x8384, 0x7680,
1935 "Mac", STAC_INTEL_MAC_AUTO
),
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01a7,
1938 "unknown Dell", STAC_922X_DELL_D81
),
1939 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01a9,
1940 "unknown Dell", STAC_922X_DELL_D81
),
1941 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ab,
1942 "unknown Dell", STAC_922X_DELL_D81
),
1943 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ac,
1944 "unknown Dell", STAC_922X_DELL_D82
),
1945 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01bf,
1946 "unknown Dell", STAC_922X_DELL_M81
),
1947 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d0,
1948 "unknown Dell", STAC_922X_DELL_D82
),
1949 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d1,
1950 "unknown Dell", STAC_922X_DELL_D81
),
1951 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d2,
1952 "unknown Dell", STAC_922X_DELL_D81
),
1953 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d7,
1954 "Dell XPS M1210", STAC_922X_DELL_M82
),
1955 /* ECS/PC Chips boards */
1956 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
1957 "ECS/PC chips", STAC_ECS_202
),
1961 static unsigned int ref927x_pin_configs
[14] = {
1962 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1963 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1964 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1965 0x01c42190, 0x40000100,
1968 static unsigned int d965_3st_pin_configs
[14] = {
1969 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1970 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1971 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1972 0x40000100, 0x40000100
1975 static unsigned int d965_5st_pin_configs
[14] = {
1976 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1977 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1978 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1979 0x40000100, 0x40000100
1982 static unsigned int d965_5st_no_fp_pin_configs
[14] = {
1983 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
1984 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1985 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1986 0x40000100, 0x40000100
1989 static unsigned int dell_3st_pin_configs
[14] = {
1990 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1991 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1992 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
1993 0x40c003fc, 0x40000100
1996 static unsigned int *stac927x_brd_tbl
[STAC_927X_MODELS
] = {
1997 [STAC_D965_REF_NO_JD
] = ref927x_pin_configs
,
1998 [STAC_D965_REF
] = ref927x_pin_configs
,
1999 [STAC_D965_3ST
] = d965_3st_pin_configs
,
2000 [STAC_D965_5ST
] = d965_5st_pin_configs
,
2001 [STAC_D965_5ST_NO_FP
] = d965_5st_no_fp_pin_configs
,
2002 [STAC_DELL_3ST
] = dell_3st_pin_configs
,
2003 [STAC_DELL_BIOS
] = NULL
,
2006 static const char *stac927x_models
[STAC_927X_MODELS
] = {
2007 [STAC_927X_AUTO
] = "auto",
2008 [STAC_D965_REF_NO_JD
] = "ref-no-jd",
2009 [STAC_D965_REF
] = "ref",
2010 [STAC_D965_3ST
] = "3stack",
2011 [STAC_D965_5ST
] = "5stack",
2012 [STAC_D965_5ST_NO_FP
] = "5stack-no-fp",
2013 [STAC_DELL_3ST
] = "dell-3stack",
2014 [STAC_DELL_BIOS
] = "dell-bios",
2017 static struct snd_pci_quirk stac927x_cfg_tbl
[] = {
2018 /* SigmaTel reference board */
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
2020 "DFI LanParty", STAC_D965_REF
),
2021 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
2022 "DFI LanParty", STAC_D965_REF
),
2023 /* Intel 946 based systems */
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x3d01, "Intel D946", STAC_D965_3ST
),
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0xa301, "Intel D946", STAC_D965_3ST
),
2026 /* 965 based 3 stack systems */
2027 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL
, 0xff00, 0x2100,
2028 "Intel D965", STAC_D965_3ST
),
2029 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL
, 0xff00, 0x2000,
2030 "Intel D965", STAC_D965_3ST
),
2031 /* Dell 3 stack systems */
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST
),
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST
),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ed, "Dell ", STAC_DELL_3ST
),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f4, "Dell ", STAC_DELL_3ST
),
2036 /* Dell 3 stack systems with verb table in BIOS */
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS
),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS
),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x022e, "Dell ", STAC_DELL_BIOS
),
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS
),
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0242, "Dell ", STAC_DELL_BIOS
),
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0243, "Dell ", STAC_DELL_BIOS
),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x02ff, "Dell ", STAC_DELL_BIOS
),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS
),
2045 /* 965 based 5 stack systems */
2046 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL
, 0xff00, 0x2300,
2047 "Intel D965", STAC_D965_5ST
),
2048 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL
, 0xff00, 0x2500,
2049 "Intel D965", STAC_D965_5ST
),
2053 static unsigned int ref9205_pin_configs
[12] = {
2054 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2055 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2056 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2060 STAC 9205 pin configs for
2067 10280228 (Dell Vostro 1500)
2069 static unsigned int dell_9205_m42_pin_configs
[12] = {
2070 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2071 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2072 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2076 STAC 9205 pin configs for
2080 102801FF (Dell Precision M4300)
2085 static unsigned int dell_9205_m43_pin_configs
[12] = {
2086 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2087 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2088 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2091 static unsigned int dell_9205_m44_pin_configs
[12] = {
2092 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2093 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2094 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2097 static unsigned int *stac9205_brd_tbl
[STAC_9205_MODELS
] = {
2098 [STAC_9205_REF
] = ref9205_pin_configs
,
2099 [STAC_9205_DELL_M42
] = dell_9205_m42_pin_configs
,
2100 [STAC_9205_DELL_M43
] = dell_9205_m43_pin_configs
,
2101 [STAC_9205_DELL_M44
] = dell_9205_m44_pin_configs
,
2102 [STAC_9205_EAPD
] = NULL
,
2105 static const char *stac9205_models
[STAC_9205_MODELS
] = {
2106 [STAC_9205_AUTO
] = "auto",
2107 [STAC_9205_REF
] = "ref",
2108 [STAC_9205_DELL_M42
] = "dell-m42",
2109 [STAC_9205_DELL_M43
] = "dell-m43",
2110 [STAC_9205_DELL_M44
] = "dell-m44",
2111 [STAC_9205_EAPD
] = "eapd",
2114 static struct snd_pci_quirk stac9205_cfg_tbl
[] = {
2115 /* SigmaTel reference board */
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
2117 "DFI LanParty", STAC_9205_REF
),
2118 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0xfb30,
2119 "SigmaTel", STAC_9205_REF
),
2120 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI
, 0x3101,
2121 "DFI LanParty", STAC_9205_REF
),
2123 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f1,
2124 "unknown Dell", STAC_9205_DELL_M42
),
2125 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f2,
2126 "unknown Dell", STAC_9205_DELL_M42
),
2127 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f8,
2128 "Dell Precision", STAC_9205_DELL_M43
),
2129 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f9,
2130 "Dell Precision", STAC_9205_DELL_M43
),
2131 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fa,
2132 "Dell Precision", STAC_9205_DELL_M43
),
2133 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fc,
2134 "unknown Dell", STAC_9205_DELL_M42
),
2135 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fd,
2136 "unknown Dell", STAC_9205_DELL_M42
),
2137 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01fe,
2138 "Dell Precision", STAC_9205_DELL_M43
),
2139 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ff,
2140 "Dell Precision M4300", STAC_9205_DELL_M43
),
2141 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0204,
2142 "unknown Dell", STAC_9205_DELL_M42
),
2143 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0206,
2144 "Dell Precision", STAC_9205_DELL_M43
),
2145 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x021b,
2146 "Dell Precision", STAC_9205_DELL_M43
),
2147 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x021c,
2148 "Dell Precision", STAC_9205_DELL_M43
),
2149 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x021f,
2150 "Dell Inspiron", STAC_9205_DELL_M44
),
2151 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x0228,
2152 "Dell Vostro 1500", STAC_9205_DELL_M42
),
2154 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD
),
2155 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD
),
2159 static void stac92xx_set_config_regs(struct hda_codec
*codec
,
2160 unsigned int *pincfgs
)
2163 struct sigmatel_spec
*spec
= codec
->spec
;
2168 for (i
= 0; i
< spec
->num_pins
; i
++)
2169 if (spec
->pin_nids
[i
] && pincfgs
[i
])
2170 snd_hda_codec_set_pincfg(codec
, spec
->pin_nids
[i
],
2175 * Analog playback callbacks
2177 static int stac92xx_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2178 struct hda_codec
*codec
,
2179 struct snd_pcm_substream
*substream
)
2181 struct sigmatel_spec
*spec
= codec
->spec
;
2182 if (spec
->stream_delay
)
2183 msleep(spec
->stream_delay
);
2184 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
,
2188 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2189 struct hda_codec
*codec
,
2190 unsigned int stream_tag
,
2191 unsigned int format
,
2192 struct snd_pcm_substream
*substream
)
2194 struct sigmatel_spec
*spec
= codec
->spec
;
2195 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
, stream_tag
, format
, substream
);
2198 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2199 struct hda_codec
*codec
,
2200 struct snd_pcm_substream
*substream
)
2202 struct sigmatel_spec
*spec
= codec
->spec
;
2203 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
2207 * Digital playback callbacks
2209 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
2210 struct hda_codec
*codec
,
2211 struct snd_pcm_substream
*substream
)
2213 struct sigmatel_spec
*spec
= codec
->spec
;
2214 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
2217 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
2218 struct hda_codec
*codec
,
2219 struct snd_pcm_substream
*substream
)
2221 struct sigmatel_spec
*spec
= codec
->spec
;
2222 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
2225 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2226 struct hda_codec
*codec
,
2227 unsigned int stream_tag
,
2228 unsigned int format
,
2229 struct snd_pcm_substream
*substream
)
2231 struct sigmatel_spec
*spec
= codec
->spec
;
2232 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
2233 stream_tag
, format
, substream
);
2236 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2237 struct hda_codec
*codec
,
2238 struct snd_pcm_substream
*substream
)
2240 struct sigmatel_spec
*spec
= codec
->spec
;
2241 return snd_hda_multi_out_dig_cleanup(codec
, &spec
->multiout
);
2246 * Analog capture callbacks
2248 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
2249 struct hda_codec
*codec
,
2250 unsigned int stream_tag
,
2251 unsigned int format
,
2252 struct snd_pcm_substream
*substream
)
2254 struct sigmatel_spec
*spec
= codec
->spec
;
2255 hda_nid_t nid
= spec
->adc_nids
[substream
->number
];
2257 if (spec
->powerdown_adcs
) {
2259 snd_hda_codec_write(codec
, nid
, 0,
2260 AC_VERB_SET_POWER_STATE
, AC_PWRST_D0
);
2262 snd_hda_codec_setup_stream(codec
, nid
, stream_tag
, 0, format
);
2266 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
2267 struct hda_codec
*codec
,
2268 struct snd_pcm_substream
*substream
)
2270 struct sigmatel_spec
*spec
= codec
->spec
;
2271 hda_nid_t nid
= spec
->adc_nids
[substream
->number
];
2273 snd_hda_codec_cleanup_stream(codec
, nid
);
2274 if (spec
->powerdown_adcs
)
2275 snd_hda_codec_write(codec
, nid
, 0,
2276 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
2280 static struct hda_pcm_stream stac92xx_pcm_digital_playback
= {
2284 /* NID is set in stac92xx_build_pcms */
2286 .open
= stac92xx_dig_playback_pcm_open
,
2287 .close
= stac92xx_dig_playback_pcm_close
,
2288 .prepare
= stac92xx_dig_playback_pcm_prepare
,
2289 .cleanup
= stac92xx_dig_playback_pcm_cleanup
2293 static struct hda_pcm_stream stac92xx_pcm_digital_capture
= {
2297 /* NID is set in stac92xx_build_pcms */
2300 static struct hda_pcm_stream stac92xx_pcm_analog_playback
= {
2304 .nid
= 0x02, /* NID to query formats and rates */
2306 .open
= stac92xx_playback_pcm_open
,
2307 .prepare
= stac92xx_playback_pcm_prepare
,
2308 .cleanup
= stac92xx_playback_pcm_cleanup
2312 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback
= {
2316 .nid
= 0x06, /* NID to query formats and rates */
2318 .open
= stac92xx_playback_pcm_open
,
2319 .prepare
= stac92xx_playback_pcm_prepare
,
2320 .cleanup
= stac92xx_playback_pcm_cleanup
2324 static struct hda_pcm_stream stac92xx_pcm_analog_capture
= {
2327 /* NID + .substreams is set in stac92xx_build_pcms */
2329 .prepare
= stac92xx_capture_pcm_prepare
,
2330 .cleanup
= stac92xx_capture_pcm_cleanup
2334 static int stac92xx_build_pcms(struct hda_codec
*codec
)
2336 struct sigmatel_spec
*spec
= codec
->spec
;
2337 struct hda_pcm
*info
= spec
->pcm_rec
;
2339 codec
->num_pcms
= 1;
2340 codec
->pcm_info
= info
;
2342 info
->name
= "STAC92xx Analog";
2343 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_analog_playback
;
2344 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
=
2345 spec
->multiout
.dac_nids
[0];
2346 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = stac92xx_pcm_analog_capture
;
2347 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
2348 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].substreams
= spec
->num_adcs
;
2350 if (spec
->alt_switch
) {
2353 info
->name
= "STAC92xx Analog Alt";
2354 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_analog_alt_playback
;
2357 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
2360 info
->name
= "STAC92xx Digital";
2361 info
->pcm_type
= spec
->autocfg
.dig_out_type
[0];
2362 if (spec
->multiout
.dig_out_nid
) {
2363 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_digital_playback
;
2364 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
2366 if (spec
->dig_in_nid
) {
2367 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = stac92xx_pcm_digital_capture
;
2368 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
2375 static unsigned int stac92xx_get_default_vref(struct hda_codec
*codec
,
2378 unsigned int pincap
= snd_hda_query_pin_caps(codec
, nid
);
2379 pincap
= (pincap
& AC_PINCAP_VREF
) >> AC_PINCAP_VREF_SHIFT
;
2380 if (pincap
& AC_PINCAP_VREF_100
)
2381 return AC_PINCTL_VREF_100
;
2382 if (pincap
& AC_PINCAP_VREF_80
)
2383 return AC_PINCTL_VREF_80
;
2384 if (pincap
& AC_PINCAP_VREF_50
)
2385 return AC_PINCTL_VREF_50
;
2386 if (pincap
& AC_PINCAP_VREF_GRD
)
2387 return AC_PINCTL_VREF_GRD
;
2391 static void stac92xx_auto_set_pinctl(struct hda_codec
*codec
, hda_nid_t nid
, int pin_type
)
2394 snd_hda_codec_write_cache(codec
, nid
, 0,
2395 AC_VERB_SET_PIN_WIDGET_CONTROL
, pin_type
);
2398 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2400 static int stac92xx_hp_switch_get(struct snd_kcontrol
*kcontrol
,
2401 struct snd_ctl_elem_value
*ucontrol
)
2403 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2404 struct sigmatel_spec
*spec
= codec
->spec
;
2406 ucontrol
->value
.integer
.value
[0] = !!spec
->hp_switch
;
2410 static void stac_issue_unsol_event(struct hda_codec
*codec
, hda_nid_t nid
);
2412 static int stac92xx_hp_switch_put(struct snd_kcontrol
*kcontrol
,
2413 struct snd_ctl_elem_value
*ucontrol
)
2415 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2416 struct sigmatel_spec
*spec
= codec
->spec
;
2417 int nid
= kcontrol
->private_value
;
2419 spec
->hp_switch
= ucontrol
->value
.integer
.value
[0] ? nid
: 0;
2421 /* check to be sure that the ports are upto date with
2424 stac_issue_unsol_event(codec
, nid
);
2429 static int stac92xx_dc_bias_info(struct snd_kcontrol
*kcontrol
,
2430 struct snd_ctl_elem_info
*uinfo
)
2433 static char *texts
[] = {
2434 "Mic In", "Line In", "Line Out"
2437 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2438 struct sigmatel_spec
*spec
= codec
->spec
;
2439 hda_nid_t nid
= kcontrol
->private_value
;
2441 if (nid
== spec
->mic_switch
|| nid
== spec
->line_switch
)
2446 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
2447 uinfo
->value
.enumerated
.items
= i
;
2449 if (uinfo
->value
.enumerated
.item
>= i
)
2450 uinfo
->value
.enumerated
.item
= i
-1;
2451 strcpy(uinfo
->value
.enumerated
.name
,
2452 texts
[uinfo
->value
.enumerated
.item
]);
2457 static int stac92xx_dc_bias_get(struct snd_kcontrol
*kcontrol
,
2458 struct snd_ctl_elem_value
*ucontrol
)
2460 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2461 hda_nid_t nid
= kcontrol
->private_value
;
2462 unsigned int vref
= stac92xx_vref_get(codec
, nid
);
2464 if (vref
== stac92xx_get_default_vref(codec
, nid
))
2465 ucontrol
->value
.enumerated
.item
[0] = 0;
2466 else if (vref
== AC_PINCTL_VREF_GRD
)
2467 ucontrol
->value
.enumerated
.item
[0] = 1;
2468 else if (vref
== AC_PINCTL_VREF_HIZ
)
2469 ucontrol
->value
.enumerated
.item
[0] = 2;
2474 static int stac92xx_dc_bias_put(struct snd_kcontrol
*kcontrol
,
2475 struct snd_ctl_elem_value
*ucontrol
)
2477 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2478 unsigned int new_vref
= 0;
2480 hda_nid_t nid
= kcontrol
->private_value
;
2482 if (ucontrol
->value
.enumerated
.item
[0] == 0)
2483 new_vref
= stac92xx_get_default_vref(codec
, nid
);
2484 else if (ucontrol
->value
.enumerated
.item
[0] == 1)
2485 new_vref
= AC_PINCTL_VREF_GRD
;
2486 else if (ucontrol
->value
.enumerated
.item
[0] == 2)
2487 new_vref
= AC_PINCTL_VREF_HIZ
;
2491 if (new_vref
!= stac92xx_vref_get(codec
, nid
)) {
2492 error
= stac92xx_vref_set(codec
, nid
, new_vref
);
2499 static int stac92xx_io_switch_info(struct snd_kcontrol
*kcontrol
,
2500 struct snd_ctl_elem_info
*uinfo
)
2502 static char *texts
[2];
2503 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2504 struct sigmatel_spec
*spec
= codec
->spec
;
2506 if (kcontrol
->private_value
== spec
->line_switch
)
2507 texts
[0] = "Line In";
2509 texts
[0] = "Mic In";
2510 texts
[1] = "Line Out";
2511 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_ENUMERATED
;
2512 uinfo
->value
.enumerated
.items
= 2;
2515 if (uinfo
->value
.enumerated
.item
>= 2)
2516 uinfo
->value
.enumerated
.item
= 1;
2517 strcpy(uinfo
->value
.enumerated
.name
,
2518 texts
[uinfo
->value
.enumerated
.item
]);
2523 static int stac92xx_io_switch_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2525 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2526 struct sigmatel_spec
*spec
= codec
->spec
;
2527 hda_nid_t nid
= kcontrol
->private_value
;
2528 int io_idx
= (nid
== spec
->mic_switch
) ? 1 : 0;
2530 ucontrol
->value
.enumerated
.item
[0] = spec
->io_switch
[io_idx
];
2534 static int stac92xx_io_switch_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2536 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2537 struct sigmatel_spec
*spec
= codec
->spec
;
2538 hda_nid_t nid
= kcontrol
->private_value
;
2539 int io_idx
= (nid
== spec
->mic_switch
) ? 1 : 0;
2540 unsigned short val
= !!ucontrol
->value
.enumerated
.item
[0];
2542 spec
->io_switch
[io_idx
] = val
;
2545 stac92xx_auto_set_pinctl(codec
, nid
, AC_PINCTL_OUT_EN
);
2547 unsigned int pinctl
= AC_PINCTL_IN_EN
;
2548 if (io_idx
) /* set VREF for mic */
2549 pinctl
|= stac92xx_get_default_vref(codec
, nid
);
2550 stac92xx_auto_set_pinctl(codec
, nid
, pinctl
);
2553 /* check the auto-mute again: we need to mute/unmute the speaker
2554 * appropriately according to the pin direction
2556 if (spec
->hp_detect
)
2557 stac_issue_unsol_event(codec
, nid
);
2562 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2564 static int stac92xx_clfe_switch_get(struct snd_kcontrol
*kcontrol
,
2565 struct snd_ctl_elem_value
*ucontrol
)
2567 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2568 struct sigmatel_spec
*spec
= codec
->spec
;
2570 ucontrol
->value
.integer
.value
[0] = spec
->clfe_swap
;
2574 static int stac92xx_clfe_switch_put(struct snd_kcontrol
*kcontrol
,
2575 struct snd_ctl_elem_value
*ucontrol
)
2577 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2578 struct sigmatel_spec
*spec
= codec
->spec
;
2579 hda_nid_t nid
= kcontrol
->private_value
& 0xff;
2580 unsigned int val
= !!ucontrol
->value
.integer
.value
[0];
2582 if (spec
->clfe_swap
== val
)
2585 spec
->clfe_swap
= val
;
2587 snd_hda_codec_write_cache(codec
, nid
, 0, AC_VERB_SET_EAPD_BTLENABLE
,
2588 spec
->clfe_swap
? 0x4 : 0x0);
2593 #define STAC_CODEC_HP_SWITCH(xname) \
2594 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2597 .info = stac92xx_hp_switch_info, \
2598 .get = stac92xx_hp_switch_get, \
2599 .put = stac92xx_hp_switch_put, \
2602 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2603 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2606 .info = stac92xx_io_switch_info, \
2607 .get = stac92xx_io_switch_get, \
2608 .put = stac92xx_io_switch_put, \
2609 .private_value = xpval, \
2612 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2613 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2616 .info = stac92xx_clfe_switch_info, \
2617 .get = stac92xx_clfe_switch_get, \
2618 .put = stac92xx_clfe_switch_put, \
2619 .private_value = xpval, \
2623 STAC_CTL_WIDGET_VOL
,
2624 STAC_CTL_WIDGET_MUTE
,
2625 STAC_CTL_WIDGET_MONO_MUX
,
2626 STAC_CTL_WIDGET_HP_SWITCH
,
2627 STAC_CTL_WIDGET_IO_SWITCH
,
2628 STAC_CTL_WIDGET_CLFE_SWITCH
,
2629 STAC_CTL_WIDGET_DC_BIAS
2632 static struct snd_kcontrol_new stac92xx_control_templates
[] = {
2633 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
2634 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
2636 STAC_CODEC_HP_SWITCH(NULL
),
2637 STAC_CODEC_IO_SWITCH(NULL
, 0),
2638 STAC_CODEC_CLFE_SWITCH(NULL
, 0),
2639 DC_BIAS(NULL
, 0, 0),
2642 /* add dynamic controls */
2643 static struct snd_kcontrol_new
*
2644 stac_control_new(struct sigmatel_spec
*spec
,
2645 struct snd_kcontrol_new
*ktemp
,
2648 struct snd_kcontrol_new
*knew
;
2650 snd_array_init(&spec
->kctls
, sizeof(*knew
), 32);
2651 knew
= snd_array_new(&spec
->kctls
);
2655 knew
->name
= kstrdup(name
, GFP_KERNEL
);
2658 memset(knew
, 0, sizeof(*knew
));
2659 spec
->kctls
.alloced
--;
2665 static int stac92xx_add_control_temp(struct sigmatel_spec
*spec
,
2666 struct snd_kcontrol_new
*ktemp
,
2667 int idx
, const char *name
,
2670 struct snd_kcontrol_new
*knew
= stac_control_new(spec
, ktemp
, name
);
2674 knew
->private_value
= val
;
2678 static inline int stac92xx_add_control_idx(struct sigmatel_spec
*spec
,
2679 int type
, int idx
, const char *name
,
2682 return stac92xx_add_control_temp(spec
,
2683 &stac92xx_control_templates
[type
],
2688 /* add dynamic controls */
2689 static inline int stac92xx_add_control(struct sigmatel_spec
*spec
, int type
,
2690 const char *name
, unsigned long val
)
2692 return stac92xx_add_control_idx(spec
, type
, 0, name
, val
);
2695 static struct snd_kcontrol_new stac_input_src_temp
= {
2696 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2697 .name
= "Input Source",
2698 .info
= stac92xx_mux_enum_info
,
2699 .get
= stac92xx_mux_enum_get
,
2700 .put
= stac92xx_mux_enum_put
,
2703 static inline int stac92xx_add_jack_mode_control(struct hda_codec
*codec
,
2704 hda_nid_t nid
, int idx
)
2706 int def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
2708 struct sigmatel_spec
*spec
= codec
->spec
;
2711 if (!((get_defcfg_connect(def_conf
)) & AC_JACK_PORT_FIXED
)) {
2712 if (stac92xx_get_default_vref(codec
, nid
) == AC_PINCTL_VREF_GRD
2713 && nid
== spec
->line_switch
)
2714 control
= STAC_CTL_WIDGET_IO_SWITCH
;
2715 else if (snd_hda_query_pin_caps(codec
, nid
)
2716 & (AC_PINCAP_VREF_GRD
<< AC_PINCAP_VREF_SHIFT
))
2717 control
= STAC_CTL_WIDGET_DC_BIAS
;
2718 else if (nid
== spec
->mic_switch
)
2719 control
= STAC_CTL_WIDGET_IO_SWITCH
;
2723 strcpy(name
, auto_pin_cfg_labels
[idx
]);
2724 return stac92xx_add_control(codec
->spec
, control
,
2725 strcat(name
, " Jack Mode"), nid
);
2731 static int stac92xx_add_input_source(struct sigmatel_spec
*spec
)
2733 struct snd_kcontrol_new
*knew
;
2734 struct hda_input_mux
*imux
= &spec
->private_imux
;
2737 return 0; /* no need for input source */
2738 if (!spec
->num_adcs
|| imux
->num_items
<= 1)
2739 return 0; /* no need for input source control */
2740 knew
= stac_control_new(spec
, &stac_input_src_temp
,
2741 stac_input_src_temp
.name
);
2744 knew
->count
= spec
->num_adcs
;
2748 /* check whether the line-input can be used as line-out */
2749 static hda_nid_t
check_line_out_switch(struct hda_codec
*codec
)
2751 struct sigmatel_spec
*spec
= codec
->spec
;
2752 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2754 unsigned int pincap
;
2756 if (cfg
->line_out_type
!= AUTO_PIN_LINE_OUT
)
2758 nid
= cfg
->input_pins
[AUTO_PIN_LINE
];
2759 pincap
= snd_hda_query_pin_caps(codec
, nid
);
2760 if (pincap
& AC_PINCAP_OUT
)
2765 /* check whether the mic-input can be used as line-out */
2766 static hda_nid_t
check_mic_out_switch(struct hda_codec
*codec
)
2768 struct sigmatel_spec
*spec
= codec
->spec
;
2769 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2770 unsigned int def_conf
, pincap
;
2771 unsigned int mic_pin
;
2773 if (cfg
->line_out_type
!= AUTO_PIN_LINE_OUT
)
2775 mic_pin
= AUTO_PIN_MIC
;
2777 hda_nid_t nid
= cfg
->input_pins
[mic_pin
];
2778 def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
2779 /* some laptops have an internal analog microphone
2780 * which can't be used as a output */
2781 if (get_defcfg_connect(def_conf
) != AC_JACK_PORT_FIXED
) {
2782 pincap
= snd_hda_query_pin_caps(codec
, nid
);
2783 if (pincap
& AC_PINCAP_OUT
)
2786 if (mic_pin
== AUTO_PIN_MIC
)
2787 mic_pin
= AUTO_PIN_FRONT_MIC
;
2794 static int is_in_dac_nids(struct sigmatel_spec
*spec
, hda_nid_t nid
)
2798 for (i
= 0; i
< spec
->multiout
.num_dacs
; i
++) {
2799 if (spec
->multiout
.dac_nids
[i
] == nid
)
2806 static int check_all_dac_nids(struct sigmatel_spec
*spec
, hda_nid_t nid
)
2809 if (is_in_dac_nids(spec
, nid
))
2811 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++)
2812 if (spec
->hp_dacs
[i
] == nid
)
2814 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++)
2815 if (spec
->speaker_dacs
[i
] == nid
)
2820 static hda_nid_t
get_unassigned_dac(struct hda_codec
*codec
, hda_nid_t nid
)
2822 struct sigmatel_spec
*spec
= codec
->spec
;
2824 hda_nid_t conn
[HDA_MAX_CONNECTIONS
];
2825 unsigned int wcaps
, wtype
;
2827 conn_len
= snd_hda_get_connections(codec
, nid
, conn
,
2828 HDA_MAX_CONNECTIONS
);
2829 for (j
= 0; j
< conn_len
; j
++) {
2830 wcaps
= get_wcaps(codec
, conn
[j
]);
2831 wtype
= get_wcaps_type(wcaps
);
2832 /* we check only analog outputs */
2833 if (wtype
!= AC_WID_AUD_OUT
|| (wcaps
& AC_WCAP_DIGITAL
))
2835 /* if this route has a free DAC, assign it */
2836 if (!check_all_dac_nids(spec
, conn
[j
])) {
2838 /* select this DAC in the pin's input mux */
2839 snd_hda_codec_write_cache(codec
, nid
, 0,
2840 AC_VERB_SET_CONNECT_SEL
, j
);
2845 /* if all DACs are already assigned, connect to the primary DAC */
2847 for (j
= 0; j
< conn_len
; j
++) {
2848 if (conn
[j
] == spec
->multiout
.dac_nids
[0]) {
2849 snd_hda_codec_write_cache(codec
, nid
, 0,
2850 AC_VERB_SET_CONNECT_SEL
, j
);
2858 static int add_spec_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
);
2859 static int add_spec_extra_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
);
2862 * Fill in the dac_nids table from the parsed pin configuration
2863 * This function only works when every pin in line_out_pins[]
2864 * contains atleast one DAC in its connection list. Some 92xx
2865 * codecs are not connected directly to a DAC, such as the 9200
2866 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2868 static int stac92xx_auto_fill_dac_nids(struct hda_codec
*codec
)
2870 struct sigmatel_spec
*spec
= codec
->spec
;
2871 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
2875 for (i
= 0; i
< cfg
->line_outs
; i
++) {
2876 nid
= cfg
->line_out_pins
[i
];
2877 dac
= get_unassigned_dac(codec
, nid
);
2879 if (spec
->multiout
.num_dacs
> 0) {
2880 /* we have already working output pins,
2881 * so let's drop the broken ones again
2883 cfg
->line_outs
= spec
->multiout
.num_dacs
;
2886 /* error out, no available DAC found */
2888 "%s: No available DAC for pin 0x%x\n",
2892 add_spec_dacs(spec
, dac
);
2895 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
2896 nid
= cfg
->hp_pins
[i
];
2897 dac
= get_unassigned_dac(codec
, nid
);
2899 if (!spec
->multiout
.hp_nid
)
2900 spec
->multiout
.hp_nid
= dac
;
2902 add_spec_extra_dacs(spec
, dac
);
2904 spec
->hp_dacs
[i
] = dac
;
2907 for (i
= 0; i
< cfg
->speaker_outs
; i
++) {
2908 nid
= cfg
->speaker_pins
[i
];
2909 dac
= get_unassigned_dac(codec
, nid
);
2911 add_spec_extra_dacs(spec
, dac
);
2912 spec
->speaker_dacs
[i
] = dac
;
2915 /* add line-in as output */
2916 nid
= check_line_out_switch(codec
);
2918 dac
= get_unassigned_dac(codec
, nid
);
2920 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2921 nid
, cfg
->line_outs
);
2922 cfg
->line_out_pins
[cfg
->line_outs
] = nid
;
2924 spec
->line_switch
= nid
;
2925 add_spec_dacs(spec
, dac
);
2928 /* add mic as output */
2929 nid
= check_mic_out_switch(codec
);
2931 dac
= get_unassigned_dac(codec
, nid
);
2933 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2934 nid
, cfg
->line_outs
);
2935 cfg
->line_out_pins
[cfg
->line_outs
] = nid
;
2937 spec
->mic_switch
= nid
;
2938 add_spec_dacs(spec
, dac
);
2942 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2943 spec
->multiout
.num_dacs
,
2944 spec
->multiout
.dac_nids
[0],
2945 spec
->multiout
.dac_nids
[1],
2946 spec
->multiout
.dac_nids
[2],
2947 spec
->multiout
.dac_nids
[3],
2948 spec
->multiout
.dac_nids
[4]);
2953 /* create volume control/switch for the given prefx type */
2954 static int create_controls_idx(struct hda_codec
*codec
, const char *pfx
,
2955 int idx
, hda_nid_t nid
, int chs
)
2957 struct sigmatel_spec
*spec
= codec
->spec
;
2961 if (!spec
->check_volume_offset
) {
2962 unsigned int caps
, step
, nums
, db_scale
;
2963 caps
= query_amp_caps(codec
, nid
, HDA_OUTPUT
);
2964 step
= (caps
& AC_AMPCAP_STEP_SIZE
) >>
2965 AC_AMPCAP_STEP_SIZE_SHIFT
;
2966 step
= (step
+ 1) * 25; /* in .01dB unit */
2967 nums
= (caps
& AC_AMPCAP_NUM_STEPS
) >>
2968 AC_AMPCAP_NUM_STEPS_SHIFT
;
2969 db_scale
= nums
* step
;
2970 /* if dB scale is over -64dB, and finer enough,
2971 * let's reduce it to half
2973 if (db_scale
> 6400 && nums
>= 0x1f)
2974 spec
->volume_offset
= nums
/ 2;
2975 spec
->check_volume_offset
= 1;
2978 sprintf(name
, "%s Playback Volume", pfx
);
2979 err
= stac92xx_add_control_idx(spec
, STAC_CTL_WIDGET_VOL
, idx
, name
,
2980 HDA_COMPOSE_AMP_VAL_OFS(nid
, chs
, 0, HDA_OUTPUT
,
2981 spec
->volume_offset
));
2984 sprintf(name
, "%s Playback Switch", pfx
);
2985 err
= stac92xx_add_control_idx(spec
, STAC_CTL_WIDGET_MUTE
, idx
, name
,
2986 HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
));
2992 #define create_controls(codec, pfx, nid, chs) \
2993 create_controls_idx(codec, pfx, 0, nid, chs)
2995 static int add_spec_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
)
2997 if (spec
->multiout
.num_dacs
> 4) {
2998 printk(KERN_WARNING
"stac92xx: No space for DAC 0x%x\n", nid
);
3001 spec
->multiout
.dac_nids
[spec
->multiout
.num_dacs
] = nid
;
3002 spec
->multiout
.num_dacs
++;
3007 static int add_spec_extra_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
)
3010 for (i
= 0; i
< ARRAY_SIZE(spec
->multiout
.extra_out_nid
); i
++) {
3011 if (!spec
->multiout
.extra_out_nid
[i
]) {
3012 spec
->multiout
.extra_out_nid
[i
] = nid
;
3016 printk(KERN_WARNING
"stac92xx: No space for extra DAC 0x%x\n", nid
);
3020 /* Create output controls
3021 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3023 static int create_multi_out_ctls(struct hda_codec
*codec
, int num_outs
,
3024 const hda_nid_t
*pins
,
3025 const hda_nid_t
*dac_nids
,
3028 struct sigmatel_spec
*spec
= codec
->spec
;
3029 static const char *chname
[4] = {
3030 "Front", "Surround", NULL
/*CLFE*/, "Side"
3034 unsigned int wid_caps
;
3036 for (i
= 0; i
< num_outs
&& i
< ARRAY_SIZE(chname
); i
++) {
3037 if (type
== AUTO_PIN_HP_OUT
&& !spec
->hp_detect
) {
3038 wid_caps
= get_wcaps(codec
, pins
[i
]);
3039 if (wid_caps
& AC_WCAP_UNSOL_CAP
)
3040 spec
->hp_detect
= 1;
3045 if (type
!= AUTO_PIN_HP_OUT
&& i
== 2) {
3047 err
= create_controls(codec
, "Center", nid
, 1);
3050 err
= create_controls(codec
, "LFE", nid
, 2);
3054 wid_caps
= get_wcaps(codec
, nid
);
3056 if (wid_caps
& AC_WCAP_LR_SWAP
) {
3057 err
= stac92xx_add_control(spec
,
3058 STAC_CTL_WIDGET_CLFE_SWITCH
,
3059 "Swap Center/LFE Playback Switch", nid
);
3069 case AUTO_PIN_HP_OUT
:
3073 case AUTO_PIN_SPEAKER_OUT
:
3082 err
= create_controls_idx(codec
, name
, idx
, nid
, 3);
3090 static int stac92xx_add_capvol_ctls(struct hda_codec
*codec
, unsigned long vol
,
3091 unsigned long sw
, int idx
)
3094 err
= stac92xx_add_control_idx(codec
->spec
, STAC_CTL_WIDGET_VOL
, idx
,
3095 "Capture Volume", vol
);
3098 err
= stac92xx_add_control_idx(codec
->spec
, STAC_CTL_WIDGET_MUTE
, idx
,
3099 "Capture Switch", sw
);
3105 /* add playback controls from the parsed DAC table */
3106 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec
*codec
,
3107 const struct auto_pin_cfg
*cfg
)
3109 struct sigmatel_spec
*spec
= codec
->spec
;
3114 err
= create_multi_out_ctls(codec
, cfg
->line_outs
, cfg
->line_out_pins
,
3115 spec
->multiout
.dac_nids
,
3116 cfg
->line_out_type
);
3120 if (cfg
->hp_outs
> 1 && cfg
->line_out_type
== AUTO_PIN_LINE_OUT
) {
3121 err
= stac92xx_add_control(spec
,
3122 STAC_CTL_WIDGET_HP_SWITCH
,
3123 "Headphone as Line Out Switch",
3124 cfg
->hp_pins
[cfg
->hp_outs
- 1]);
3129 for (idx
= AUTO_PIN_MIC
; idx
<= AUTO_PIN_FRONT_LINE
; idx
++) {
3130 nid
= cfg
->input_pins
[idx
];
3132 err
= stac92xx_add_jack_mode_control(codec
, nid
, idx
);
3141 /* add playback controls for Speaker and HP outputs */
3142 static int stac92xx_auto_create_hp_ctls(struct hda_codec
*codec
,
3143 struct auto_pin_cfg
*cfg
)
3145 struct sigmatel_spec
*spec
= codec
->spec
;
3148 err
= create_multi_out_ctls(codec
, cfg
->hp_outs
, cfg
->hp_pins
,
3149 spec
->hp_dacs
, AUTO_PIN_HP_OUT
);
3153 err
= create_multi_out_ctls(codec
, cfg
->speaker_outs
, cfg
->speaker_pins
,
3154 spec
->speaker_dacs
, AUTO_PIN_SPEAKER_OUT
);
3161 /* labels for mono mux outputs */
3162 static const char *stac92xx_mono_labels
[4] = {
3163 "DAC0", "DAC1", "Mixer", "DAC2"
3166 /* create mono mux for mono out on capable codecs */
3167 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec
*codec
)
3169 struct sigmatel_spec
*spec
= codec
->spec
;
3170 struct hda_input_mux
*mono_mux
= &spec
->private_mono_mux
;
3172 hda_nid_t con_lst
[ARRAY_SIZE(stac92xx_mono_labels
)];
3174 num_cons
= snd_hda_get_connections(codec
,
3177 HDA_MAX_NUM_INPUTS
);
3178 if (num_cons
<= 0 || num_cons
> ARRAY_SIZE(stac92xx_mono_labels
))
3181 for (i
= 0; i
< num_cons
; i
++) {
3182 mono_mux
->items
[mono_mux
->num_items
].label
=
3183 stac92xx_mono_labels
[i
];
3184 mono_mux
->items
[mono_mux
->num_items
].index
= i
;
3185 mono_mux
->num_items
++;
3188 return stac92xx_add_control(spec
, STAC_CTL_WIDGET_MONO_MUX
,
3189 "Mono Mux", spec
->mono_nid
);
3192 /* create PC beep volume controls */
3193 static int stac92xx_auto_create_beep_ctls(struct hda_codec
*codec
,
3196 struct sigmatel_spec
*spec
= codec
->spec
;
3197 u32 caps
= query_amp_caps(codec
, nid
, HDA_OUTPUT
);
3200 /* check for mute support for the the amp */
3201 if ((caps
& AC_AMPCAP_MUTE
) >> AC_AMPCAP_MUTE_SHIFT
) {
3202 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_MUTE
,
3203 "PC Beep Playback Switch",
3204 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, HDA_OUTPUT
));
3209 /* check to see if there is volume support for the amp */
3210 if ((caps
& AC_AMPCAP_NUM_STEPS
) >> AC_AMPCAP_NUM_STEPS_SHIFT
) {
3211 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_VOL
,
3212 "PC Beep Playback Volume",
3213 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, HDA_OUTPUT
));
3220 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3221 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3223 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol
*kcontrol
,
3224 struct snd_ctl_elem_value
*ucontrol
)
3226 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3227 ucontrol
->value
.integer
.value
[0] = codec
->beep
->enabled
;
3231 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol
*kcontrol
,
3232 struct snd_ctl_elem_value
*ucontrol
)
3234 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
3235 int enabled
= !!ucontrol
->value
.integer
.value
[0];
3236 if (codec
->beep
->enabled
!= enabled
) {
3237 codec
->beep
->enabled
= enabled
;
3243 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl
= {
3244 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
3245 .info
= stac92xx_dig_beep_switch_info
,
3246 .get
= stac92xx_dig_beep_switch_get
,
3247 .put
= stac92xx_dig_beep_switch_put
,
3250 static int stac92xx_beep_switch_ctl(struct hda_codec
*codec
)
3252 return stac92xx_add_control_temp(codec
->spec
, &stac92xx_dig_beep_ctrl
,
3253 0, "PC Beep Playback Switch", 0);
3257 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec
*codec
)
3259 struct sigmatel_spec
*spec
= codec
->spec
;
3262 for (i
= 0; i
< spec
->num_muxes
; i
++) {
3267 nid
= spec
->mux_nids
[i
];
3268 wcaps
= get_wcaps(codec
, nid
);
3269 if (!(wcaps
& AC_WCAP_OUT_AMP
))
3272 /* check whether already the same control was created as
3273 * normal Capture Volume.
3275 val
= HDA_COMPOSE_AMP_VAL(nid
, 3, 0, HDA_OUTPUT
);
3276 for (j
= 0; j
< spec
->num_caps
; j
++) {
3277 if (spec
->capvols
[j
] == val
)
3280 if (j
< spec
->num_caps
)
3283 err
= stac92xx_add_control_idx(spec
, STAC_CTL_WIDGET_VOL
, i
,
3284 "Mux Capture Volume", val
);
3291 static const char *stac92xx_spdif_labels
[3] = {
3292 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3295 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec
*codec
)
3297 struct sigmatel_spec
*spec
= codec
->spec
;
3298 struct hda_input_mux
*spdif_mux
= &spec
->private_smux
;
3299 const char **labels
= spec
->spdif_labels
;
3301 hda_nid_t con_lst
[HDA_MAX_NUM_INPUTS
];
3303 num_cons
= snd_hda_get_connections(codec
,
3306 HDA_MAX_NUM_INPUTS
);
3311 labels
= stac92xx_spdif_labels
;
3313 for (i
= 0; i
< num_cons
; i
++) {
3314 spdif_mux
->items
[spdif_mux
->num_items
].label
= labels
[i
];
3315 spdif_mux
->items
[spdif_mux
->num_items
].index
= i
;
3316 spdif_mux
->num_items
++;
3322 /* labels for dmic mux inputs */
3323 static const char *stac92xx_dmic_labels
[5] = {
3324 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3325 "Digital Mic 3", "Digital Mic 4"
3328 static int get_connection_index(struct hda_codec
*codec
, hda_nid_t mux
,
3331 hda_nid_t conn
[HDA_MAX_NUM_INPUTS
];
3334 nums
= snd_hda_get_connections(codec
, mux
, conn
, ARRAY_SIZE(conn
));
3335 for (i
= 0; i
< nums
; i
++)
3341 /* create a volume assigned to the given pin (only if supported) */
3342 /* return 1 if the volume control is created */
3343 static int create_elem_capture_vol(struct hda_codec
*codec
, hda_nid_t nid
,
3344 const char *label
, int direction
)
3346 unsigned int caps
, nums
;
3350 if (direction
== HDA_OUTPUT
)
3351 caps
= AC_WCAP_OUT_AMP
;
3353 caps
= AC_WCAP_IN_AMP
;
3354 if (!(get_wcaps(codec
, nid
) & caps
))
3356 caps
= query_amp_caps(codec
, nid
, direction
);
3357 nums
= (caps
& AC_AMPCAP_NUM_STEPS
) >> AC_AMPCAP_NUM_STEPS_SHIFT
;
3360 snprintf(name
, sizeof(name
), "%s Capture Volume", label
);
3361 err
= stac92xx_add_control(codec
->spec
, STAC_CTL_WIDGET_VOL
, name
,
3362 HDA_COMPOSE_AMP_VAL(nid
, 3, 0, direction
));
3368 /* create playback/capture controls for input pins on dmic capable codecs */
3369 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec
*codec
,
3370 const struct auto_pin_cfg
*cfg
)
3372 struct sigmatel_spec
*spec
= codec
->spec
;
3373 struct hda_input_mux
*imux
= &spec
->private_imux
;
3374 struct hda_input_mux
*dimux
= &spec
->private_dimux
;
3375 int err
, i
, active_mics
;
3376 unsigned int def_conf
;
3378 dimux
->items
[dimux
->num_items
].label
= stac92xx_dmic_labels
[0];
3379 dimux
->items
[dimux
->num_items
].index
= 0;
3383 for (i
= 0; i
< spec
->num_dmics
; i
++) {
3384 /* check the validity: sometimes it's a dead vendor-spec node */
3385 if (get_wcaps_type(get_wcaps(codec
, spec
->dmic_nids
[i
]))
3388 def_conf
= snd_hda_codec_get_pincfg(codec
, spec
->dmic_nids
[i
]);
3389 if (get_defcfg_connect(def_conf
) != AC_JACK_PORT_NONE
)
3393 for (i
= 0; i
< spec
->num_dmics
; i
++) {
3398 nid
= spec
->dmic_nids
[i
];
3399 if (get_wcaps_type(get_wcaps(codec
, nid
)) != AC_WID_PIN
)
3401 def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
3402 if (get_defcfg_connect(def_conf
) == AC_JACK_PORT_NONE
)
3405 index
= get_connection_index(codec
, spec
->dmux_nids
[0], nid
);
3409 if (active_mics
== 1)
3410 label
= "Digital Mic";
3412 label
= stac92xx_dmic_labels
[dimux
->num_items
];
3414 err
= create_elem_capture_vol(codec
, nid
, label
, HDA_INPUT
);
3418 err
= create_elem_capture_vol(codec
, nid
, label
,
3424 dimux
->items
[dimux
->num_items
].label
= label
;
3425 dimux
->items
[dimux
->num_items
].index
= index
;
3427 if (snd_hda_get_bool_hint(codec
, "separate_dmux") != 1) {
3428 imux
->items
[imux
->num_items
].label
= label
;
3429 imux
->items
[imux
->num_items
].index
= index
;
3437 static int check_mic_pin(struct hda_codec
*codec
, hda_nid_t nid
,
3438 hda_nid_t
*fixed
, hda_nid_t
*ext
)
3444 cfg
= snd_hda_codec_get_pincfg(codec
, nid
);
3445 switch (get_defcfg_connect(cfg
)) {
3446 case AC_JACK_PORT_FIXED
:
3448 return 1; /* already occupied */
3451 case AC_JACK_PORT_COMPLEX
:
3453 return 1; /* already occupied */
3460 static int set_mic_route(struct hda_codec
*codec
,
3461 struct sigmatel_mic_route
*mic
,
3464 struct sigmatel_spec
*spec
= codec
->spec
;
3465 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3469 for (i
= AUTO_PIN_MIC
; i
<= AUTO_PIN_FRONT_MIC
; i
++)
3470 if (pin
== cfg
->input_pins
[i
])
3472 if (i
<= AUTO_PIN_FRONT_MIC
) {
3475 i
= get_connection_index(codec
, spec
->mux_nids
[0], pin
);
3479 } else if (spec
->dmux_nids
) {
3482 i
= get_connection_index(codec
, spec
->dmux_nids
[0], pin
);
3490 /* return non-zero if the device is for automatic mic switch */
3491 static int stac_check_auto_mic(struct hda_codec
*codec
)
3493 struct sigmatel_spec
*spec
= codec
->spec
;
3494 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
3495 hda_nid_t fixed
, ext
;
3498 for (i
= AUTO_PIN_LINE
; i
< AUTO_PIN_LAST
; i
++) {
3499 if (cfg
->input_pins
[i
])
3500 return 0; /* must be exclusively mics */
3503 for (i
= AUTO_PIN_MIC
; i
<= AUTO_PIN_FRONT_MIC
; i
++)
3504 if (check_mic_pin(codec
, cfg
->input_pins
[i
], &fixed
, &ext
))
3506 for (i
= 0; i
< spec
->num_dmics
; i
++)
3507 if (check_mic_pin(codec
, spec
->dmic_nids
[i
], &fixed
, &ext
))
3511 if (!(get_wcaps(codec
, ext
) & AC_WCAP_UNSOL_CAP
))
3512 return 0; /* no unsol support */
3513 if (set_mic_route(codec
, &spec
->ext_mic
, ext
) ||
3514 set_mic_route(codec
, &spec
->int_mic
, fixed
))
3515 return 0; /* something is wrong */
3519 /* create playback/capture controls for input pins */
3520 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec
*codec
, const struct auto_pin_cfg
*cfg
)
3522 struct sigmatel_spec
*spec
= codec
->spec
;
3523 struct hda_input_mux
*imux
= &spec
->private_imux
;
3526 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
3527 hda_nid_t nid
= cfg
->input_pins
[i
];
3533 for (j
= 0; j
< spec
->num_muxes
; j
++) {
3534 index
= get_connection_index(codec
, spec
->mux_nids
[j
],
3542 err
= create_elem_capture_vol(codec
, nid
,
3543 auto_pin_cfg_labels
[i
],
3548 imux
->items
[imux
->num_items
].label
= auto_pin_cfg_labels
[i
];
3549 imux
->items
[imux
->num_items
].index
= index
;
3552 spec
->num_analog_muxes
= imux
->num_items
;
3554 if (imux
->num_items
) {
3556 * Set the current input for the muxes.
3557 * The STAC9221 has two input muxes with identical source
3558 * NID lists. Hopefully this won't get confused.
3560 for (i
= 0; i
< spec
->num_muxes
; i
++) {
3561 snd_hda_codec_write_cache(codec
, spec
->mux_nids
[i
], 0,
3562 AC_VERB_SET_CONNECT_SEL
,
3563 imux
->items
[0].index
);
3570 static void stac92xx_auto_init_multi_out(struct hda_codec
*codec
)
3572 struct sigmatel_spec
*spec
= codec
->spec
;
3575 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
3576 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
3577 stac92xx_auto_set_pinctl(codec
, nid
, AC_PINCTL_OUT_EN
);
3581 static void stac92xx_auto_init_hp_out(struct hda_codec
*codec
)
3583 struct sigmatel_spec
*spec
= codec
->spec
;
3586 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
3588 pin
= spec
->autocfg
.hp_pins
[i
];
3589 if (pin
) /* connect to front */
3590 stac92xx_auto_set_pinctl(codec
, pin
, AC_PINCTL_OUT_EN
| AC_PINCTL_HP_EN
);
3592 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++) {
3594 pin
= spec
->autocfg
.speaker_pins
[i
];
3595 if (pin
) /* connect to front */
3596 stac92xx_auto_set_pinctl(codec
, pin
, AC_PINCTL_OUT_EN
);
3600 static int stac92xx_parse_auto_config(struct hda_codec
*codec
, hda_nid_t dig_out
, hda_nid_t dig_in
)
3602 struct sigmatel_spec
*spec
= codec
->spec
;
3606 if ((err
= snd_hda_parse_pin_def_config(codec
,
3608 spec
->dmic_nids
)) < 0)
3610 if (! spec
->autocfg
.line_outs
)
3611 return 0; /* can't find valid pin config */
3613 /* If we have no real line-out pin and multiple hp-outs, HPs should
3614 * be set up as multi-channel outputs.
3616 if (spec
->autocfg
.line_out_type
== AUTO_PIN_SPEAKER_OUT
&&
3617 spec
->autocfg
.hp_outs
> 1) {
3618 /* Copy hp_outs to line_outs, backup line_outs in
3619 * speaker_outs so that the following routines can handle
3620 * HP pins as primary outputs.
3622 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3623 memcpy(spec
->autocfg
.speaker_pins
, spec
->autocfg
.line_out_pins
,
3624 sizeof(spec
->autocfg
.line_out_pins
));
3625 spec
->autocfg
.speaker_outs
= spec
->autocfg
.line_outs
;
3626 memcpy(spec
->autocfg
.line_out_pins
, spec
->autocfg
.hp_pins
,
3627 sizeof(spec
->autocfg
.hp_pins
));
3628 spec
->autocfg
.line_outs
= spec
->autocfg
.hp_outs
;
3629 spec
->autocfg
.line_out_type
= AUTO_PIN_HP_OUT
;
3630 spec
->autocfg
.hp_outs
= 0;
3633 if (spec
->autocfg
.mono_out_pin
) {
3634 int dir
= get_wcaps(codec
, spec
->autocfg
.mono_out_pin
) &
3635 (AC_WCAP_OUT_AMP
| AC_WCAP_IN_AMP
);
3636 u32 caps
= query_amp_caps(codec
,
3637 spec
->autocfg
.mono_out_pin
, dir
);
3638 hda_nid_t conn_list
[1];
3640 /* get the mixer node and then the mono mux if it exists */
3641 if (snd_hda_get_connections(codec
,
3642 spec
->autocfg
.mono_out_pin
, conn_list
, 1) &&
3643 snd_hda_get_connections(codec
, conn_list
[0],
3644 conn_list
, 1) > 0) {
3646 int wcaps
= get_wcaps(codec
, conn_list
[0]);
3647 int wid_type
= get_wcaps_type(wcaps
);
3648 /* LR swap check, some stac925x have a mux that
3649 * changes the DACs output path instead of the
3652 if (wid_type
== AC_WID_AUD_SEL
&&
3653 !(wcaps
& AC_WCAP_LR_SWAP
))
3654 spec
->mono_nid
= conn_list
[0];
3657 hda_nid_t nid
= spec
->autocfg
.mono_out_pin
;
3659 /* most mono outs have a least a mute/unmute switch */
3660 dir
= (dir
& AC_WCAP_OUT_AMP
) ? HDA_OUTPUT
: HDA_INPUT
;
3661 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_MUTE
,
3662 "Mono Playback Switch",
3663 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, dir
));
3666 /* check for volume support for the amp */
3667 if ((caps
& AC_AMPCAP_NUM_STEPS
)
3668 >> AC_AMPCAP_NUM_STEPS_SHIFT
) {
3669 err
= stac92xx_add_control(spec
,
3670 STAC_CTL_WIDGET_VOL
,
3671 "Mono Playback Volume",
3672 HDA_COMPOSE_AMP_VAL(nid
, 1, 0, dir
));
3678 stac92xx_auto_set_pinctl(codec
, spec
->autocfg
.mono_out_pin
,
3682 if (!spec
->multiout
.num_dacs
) {
3683 err
= stac92xx_auto_fill_dac_nids(codec
);
3686 err
= stac92xx_auto_create_multi_out_ctls(codec
,
3692 /* setup analog beep controls */
3693 if (spec
->anabeep_nid
> 0) {
3694 err
= stac92xx_auto_create_beep_ctls(codec
,
3700 /* setup digital beep controls and input device */
3701 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3702 if (spec
->digbeep_nid
> 0) {
3703 hda_nid_t nid
= spec
->digbeep_nid
;
3706 err
= stac92xx_auto_create_beep_ctls(codec
, nid
);
3709 err
= snd_hda_attach_beep_device(codec
, nid
);
3712 /* IDT/STAC codecs have linear beep tone parameter */
3713 codec
->beep
->linear_tone
= 1;
3714 /* if no beep switch is available, make its own one */
3715 caps
= query_amp_caps(codec
, nid
, HDA_OUTPUT
);
3717 !((caps
& AC_AMPCAP_MUTE
) >> AC_AMPCAP_MUTE_SHIFT
)) {
3718 err
= stac92xx_beep_switch_ctl(codec
);
3725 err
= stac92xx_auto_create_hp_ctls(codec
, &spec
->autocfg
);
3729 /* All output parsing done, now restore the swapped hp pins */
3731 memcpy(spec
->autocfg
.hp_pins
, spec
->autocfg
.line_out_pins
,
3732 sizeof(spec
->autocfg
.hp_pins
));
3733 spec
->autocfg
.hp_outs
= spec
->autocfg
.line_outs
;
3734 spec
->autocfg
.line_out_type
= AUTO_PIN_HP_OUT
;
3735 spec
->autocfg
.line_outs
= 0;
3738 if (stac_check_auto_mic(codec
)) {
3740 /* only one capture for auto-mic */
3743 spec
->num_muxes
= 1;
3746 for (i
= 0; i
< spec
->num_caps
; i
++) {
3747 err
= stac92xx_add_capvol_ctls(codec
, spec
->capvols
[i
],
3748 spec
->capsws
[i
], i
);
3753 err
= stac92xx_auto_create_analog_input_ctls(codec
, &spec
->autocfg
);
3757 if (spec
->mono_nid
> 0) {
3758 err
= stac92xx_auto_create_mono_output_ctls(codec
);
3762 if (spec
->num_dmics
> 0 && !spec
->dinput_mux
)
3763 if ((err
= stac92xx_auto_create_dmic_input_ctls(codec
,
3764 &spec
->autocfg
)) < 0)
3766 if (spec
->num_muxes
> 0) {
3767 err
= stac92xx_auto_create_mux_input_ctls(codec
);
3771 if (spec
->num_smuxes
> 0) {
3772 err
= stac92xx_auto_create_spdif_mux_ctls(codec
);
3777 err
= stac92xx_add_input_source(spec
);
3781 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
3782 if (spec
->multiout
.max_channels
> 2)
3783 spec
->surr_switch
= 1;
3785 if (spec
->autocfg
.dig_outs
)
3786 spec
->multiout
.dig_out_nid
= dig_out
;
3787 if (dig_in
&& spec
->autocfg
.dig_in_pin
)
3788 spec
->dig_in_nid
= dig_in
;
3790 if (spec
->kctls
.list
)
3791 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
3793 spec
->input_mux
= &spec
->private_imux
;
3794 if (!spec
->dinput_mux
)
3795 spec
->dinput_mux
= &spec
->private_dimux
;
3796 spec
->sinput_mux
= &spec
->private_smux
;
3797 spec
->mono_mux
= &spec
->private_mono_mux
;
3801 /* add playback controls for HP output */
3802 static int stac9200_auto_create_hp_ctls(struct hda_codec
*codec
,
3803 struct auto_pin_cfg
*cfg
)
3805 struct sigmatel_spec
*spec
= codec
->spec
;
3806 hda_nid_t pin
= cfg
->hp_pins
[0];
3807 unsigned int wid_caps
;
3812 wid_caps
= get_wcaps(codec
, pin
);
3813 if (wid_caps
& AC_WCAP_UNSOL_CAP
)
3814 spec
->hp_detect
= 1;
3819 /* add playback controls for LFE output */
3820 static int stac9200_auto_create_lfe_ctls(struct hda_codec
*codec
,
3821 struct auto_pin_cfg
*cfg
)
3823 struct sigmatel_spec
*spec
= codec
->spec
;
3825 hda_nid_t lfe_pin
= 0x0;
3829 * search speaker outs and line outs for a mono speaker pin
3830 * with an amp. If one is found, add LFE controls
3833 for (i
= 0; i
< spec
->autocfg
.speaker_outs
&& lfe_pin
== 0x0; i
++) {
3834 hda_nid_t pin
= spec
->autocfg
.speaker_pins
[i
];
3835 unsigned int wcaps
= get_wcaps(codec
, pin
);
3836 wcaps
&= (AC_WCAP_STEREO
| AC_WCAP_OUT_AMP
);
3837 if (wcaps
== AC_WCAP_OUT_AMP
)
3838 /* found a mono speaker with an amp, must be lfe */
3842 /* if speaker_outs is 0, then speakers may be in line_outs */
3843 if (lfe_pin
== 0 && spec
->autocfg
.speaker_outs
== 0) {
3844 for (i
= 0; i
< spec
->autocfg
.line_outs
&& lfe_pin
== 0x0; i
++) {
3845 hda_nid_t pin
= spec
->autocfg
.line_out_pins
[i
];
3846 unsigned int defcfg
;
3847 defcfg
= snd_hda_codec_get_pincfg(codec
, pin
);
3848 if (get_defcfg_device(defcfg
) == AC_JACK_SPEAKER
) {
3849 unsigned int wcaps
= get_wcaps(codec
, pin
);
3850 wcaps
&= (AC_WCAP_STEREO
| AC_WCAP_OUT_AMP
);
3851 if (wcaps
== AC_WCAP_OUT_AMP
)
3852 /* found a mono speaker with an amp,
3860 err
= create_controls(codec
, "LFE", lfe_pin
, 1);
3868 static int stac9200_parse_auto_config(struct hda_codec
*codec
)
3870 struct sigmatel_spec
*spec
= codec
->spec
;
3873 if ((err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
)) < 0)
3876 if ((err
= stac92xx_auto_create_analog_input_ctls(codec
, &spec
->autocfg
)) < 0)
3879 if ((err
= stac9200_auto_create_hp_ctls(codec
, &spec
->autocfg
)) < 0)
3882 if ((err
= stac9200_auto_create_lfe_ctls(codec
, &spec
->autocfg
)) < 0)
3885 if (spec
->num_muxes
> 0) {
3886 err
= stac92xx_auto_create_mux_input_ctls(codec
);
3891 err
= stac92xx_add_input_source(spec
);
3895 if (spec
->autocfg
.dig_outs
)
3896 spec
->multiout
.dig_out_nid
= 0x05;
3897 if (spec
->autocfg
.dig_in_pin
)
3898 spec
->dig_in_nid
= 0x04;
3900 if (spec
->kctls
.list
)
3901 spec
->mixers
[spec
->num_mixers
++] = spec
->kctls
.list
;
3903 spec
->input_mux
= &spec
->private_imux
;
3904 spec
->dinput_mux
= &spec
->private_dimux
;
3910 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3911 * funky external mute control using GPIO pins.
3914 static void stac_gpio_set(struct hda_codec
*codec
, unsigned int mask
,
3915 unsigned int dir_mask
, unsigned int data
)
3917 unsigned int gpiostate
, gpiomask
, gpiodir
;
3919 gpiostate
= snd_hda_codec_read(codec
, codec
->afg
, 0,
3920 AC_VERB_GET_GPIO_DATA
, 0);
3921 gpiostate
= (gpiostate
& ~dir_mask
) | (data
& dir_mask
);
3923 gpiomask
= snd_hda_codec_read(codec
, codec
->afg
, 0,
3924 AC_VERB_GET_GPIO_MASK
, 0);
3927 gpiodir
= snd_hda_codec_read(codec
, codec
->afg
, 0,
3928 AC_VERB_GET_GPIO_DIRECTION
, 0);
3929 gpiodir
|= dir_mask
;
3931 /* Configure GPIOx as CMOS */
3932 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7e7, 0);
3934 snd_hda_codec_write(codec
, codec
->afg
, 0,
3935 AC_VERB_SET_GPIO_MASK
, gpiomask
);
3936 snd_hda_codec_read(codec
, codec
->afg
, 0,
3937 AC_VERB_SET_GPIO_DIRECTION
, gpiodir
); /* sync */
3941 snd_hda_codec_read(codec
, codec
->afg
, 0,
3942 AC_VERB_SET_GPIO_DATA
, gpiostate
); /* sync */
3945 #ifdef CONFIG_SND_HDA_INPUT_JACK
3946 static void stac92xx_free_jack_priv(struct snd_jack
*jack
)
3948 struct sigmatel_jack
*jacks
= jack
->private_data
;
3954 static int stac92xx_add_jack(struct hda_codec
*codec
,
3955 hda_nid_t nid
, int type
)
3957 #ifdef CONFIG_SND_HDA_INPUT_JACK
3958 struct sigmatel_spec
*spec
= codec
->spec
;
3959 struct sigmatel_jack
*jack
;
3960 int def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
3961 int connectivity
= get_defcfg_connect(def_conf
);
3965 if (connectivity
&& connectivity
!= AC_JACK_PORT_FIXED
)
3968 snd_array_init(&spec
->jacks
, sizeof(*jack
), 32);
3969 jack
= snd_array_new(&spec
->jacks
);
3975 snprintf(name
, sizeof(name
), "%s at %s %s Jack",
3976 snd_hda_get_jack_type(def_conf
),
3977 snd_hda_get_jack_connectivity(def_conf
),
3978 snd_hda_get_jack_location(def_conf
));
3980 err
= snd_jack_new(codec
->bus
->card
, name
, type
, &jack
->jack
);
3985 jack
->jack
->private_data
= jack
;
3986 jack
->jack
->private_free
= stac92xx_free_jack_priv
;
3991 static int stac_add_event(struct sigmatel_spec
*spec
, hda_nid_t nid
,
3992 unsigned char type
, int data
)
3994 struct sigmatel_event
*event
;
3996 snd_array_init(&spec
->events
, sizeof(*event
), 32);
3997 event
= snd_array_new(&spec
->events
);
4002 event
->tag
= spec
->events
.used
;
4008 static struct sigmatel_event
*stac_get_event(struct hda_codec
*codec
,
4011 struct sigmatel_spec
*spec
= codec
->spec
;
4012 struct sigmatel_event
*event
= spec
->events
.list
;
4015 for (i
= 0; i
< spec
->events
.used
; i
++, event
++) {
4016 if (event
->nid
== nid
)
4022 static struct sigmatel_event
*stac_get_event_from_tag(struct hda_codec
*codec
,
4025 struct sigmatel_spec
*spec
= codec
->spec
;
4026 struct sigmatel_event
*event
= spec
->events
.list
;
4029 for (i
= 0; i
< spec
->events
.used
; i
++, event
++) {
4030 if (event
->tag
== tag
)
4036 /* check if given nid is a valid pin and no other events are assigned
4037 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4038 * Otherwise, returns zero.
4040 static int enable_pin_detect(struct hda_codec
*codec
, hda_nid_t nid
,
4043 struct sigmatel_event
*event
;
4046 if (!(get_wcaps(codec
, nid
) & AC_WCAP_UNSOL_CAP
))
4048 event
= stac_get_event(codec
, nid
);
4050 if (event
->type
!= type
)
4054 tag
= stac_add_event(codec
->spec
, nid
, type
, 0);
4058 snd_hda_codec_write_cache(codec
, nid
, 0,
4059 AC_VERB_SET_UNSOLICITED_ENABLE
,
4064 static int is_nid_hp_pin(struct auto_pin_cfg
*cfg
, hda_nid_t nid
)
4067 for (i
= 0; i
< cfg
->hp_outs
; i
++)
4068 if (cfg
->hp_pins
[i
] == nid
)
4069 return 1; /* nid is a HP-Out */
4071 return 0; /* nid is not a HP-Out */
4074 static void stac92xx_power_down(struct hda_codec
*codec
)
4076 struct sigmatel_spec
*spec
= codec
->spec
;
4078 /* power down inactive DACs */
4080 for (dac
= spec
->dac_list
; *dac
; dac
++)
4081 if (!check_all_dac_nids(spec
, *dac
))
4082 snd_hda_codec_write(codec
, *dac
, 0,
4083 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
4086 static void stac_toggle_power_map(struct hda_codec
*codec
, hda_nid_t nid
,
4089 /* override some hints from the hwdep entry */
4090 static void stac_store_hints(struct hda_codec
*codec
)
4092 struct sigmatel_spec
*spec
= codec
->spec
;
4096 val
= snd_hda_get_bool_hint(codec
, "hp_detect");
4098 spec
->hp_detect
= val
;
4099 p
= snd_hda_get_hint(codec
, "gpio_mask");
4101 spec
->gpio_mask
= simple_strtoul(p
, NULL
, 0);
4102 spec
->eapd_mask
= spec
->gpio_dir
= spec
->gpio_data
=
4105 p
= snd_hda_get_hint(codec
, "gpio_dir");
4107 spec
->gpio_dir
= simple_strtoul(p
, NULL
, 0) & spec
->gpio_mask
;
4108 p
= snd_hda_get_hint(codec
, "gpio_data");
4110 spec
->gpio_data
= simple_strtoul(p
, NULL
, 0) & spec
->gpio_mask
;
4111 p
= snd_hda_get_hint(codec
, "eapd_mask");
4113 spec
->eapd_mask
= simple_strtoul(p
, NULL
, 0) & spec
->gpio_mask
;
4114 val
= snd_hda_get_bool_hint(codec
, "eapd_switch");
4116 spec
->eapd_switch
= val
;
4119 static int stac92xx_init(struct hda_codec
*codec
)
4121 struct sigmatel_spec
*spec
= codec
->spec
;
4122 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4126 snd_hda_sequence_write(codec
, spec
->init
);
4128 /* power down adcs initially */
4129 if (spec
->powerdown_adcs
)
4130 for (i
= 0; i
< spec
->num_adcs
; i
++)
4131 snd_hda_codec_write(codec
,
4132 spec
->adc_nids
[i
], 0,
4133 AC_VERB_SET_POWER_STATE
, AC_PWRST_D3
);
4135 /* override some hints */
4136 stac_store_hints(codec
);
4139 gpio
= spec
->gpio_data
;
4140 /* turn on EAPD statically when spec->eapd_switch isn't set.
4141 * otherwise, unsol event will turn it on/off dynamically
4143 if (!spec
->eapd_switch
)
4144 gpio
|= spec
->eapd_mask
;
4145 stac_gpio_set(codec
, spec
->gpio_mask
, spec
->gpio_dir
, gpio
);
4148 if (spec
->hp_detect
) {
4149 /* Enable unsolicited responses on the HP widget */
4150 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
4151 hda_nid_t nid
= cfg
->hp_pins
[i
];
4152 enable_pin_detect(codec
, nid
, STAC_HP_EVENT
);
4154 if (cfg
->line_out_type
== AUTO_PIN_LINE_OUT
&&
4155 cfg
->speaker_outs
> 0) {
4156 /* enable pin-detect for line-outs as well */
4157 for (i
= 0; i
< cfg
->line_outs
; i
++) {
4158 hda_nid_t nid
= cfg
->line_out_pins
[i
];
4159 enable_pin_detect(codec
, nid
, STAC_LO_EVENT
);
4163 /* force to enable the first line-out; the others are set up
4166 stac92xx_auto_set_pinctl(codec
, spec
->autocfg
.line_out_pins
[0],
4168 /* fake event to set up pins */
4169 stac_issue_unsol_event(codec
, spec
->autocfg
.hp_pins
[0]);
4171 stac92xx_auto_init_multi_out(codec
);
4172 stac92xx_auto_init_hp_out(codec
);
4173 for (i
= 0; i
< cfg
->hp_outs
; i
++)
4174 stac_toggle_power_map(codec
, cfg
->hp_pins
[i
], 1);
4176 if (spec
->auto_mic
) {
4177 /* initialize connection to analog input */
4178 if (spec
->dmux_nids
)
4179 snd_hda_codec_write_cache(codec
, spec
->dmux_nids
[0], 0,
4180 AC_VERB_SET_CONNECT_SEL
, 0);
4181 if (enable_pin_detect(codec
, spec
->ext_mic
.pin
, STAC_MIC_EVENT
))
4182 stac_issue_unsol_event(codec
, spec
->ext_mic
.pin
);
4184 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
4185 hda_nid_t nid
= cfg
->input_pins
[i
];
4187 unsigned int pinctl
, conf
;
4188 if (i
== AUTO_PIN_MIC
|| i
== AUTO_PIN_FRONT_MIC
) {
4189 /* for mic pins, force to initialize */
4190 pinctl
= stac92xx_get_default_vref(codec
, nid
);
4191 pinctl
|= AC_PINCTL_IN_EN
;
4192 stac92xx_auto_set_pinctl(codec
, nid
, pinctl
);
4194 pinctl
= snd_hda_codec_read(codec
, nid
, 0,
4195 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
4196 /* if PINCTL already set then skip */
4197 /* Also, if both INPUT and OUTPUT are set,
4198 * it must be a BIOS bug; need to override, too
4200 if (!(pinctl
& AC_PINCTL_IN_EN
) ||
4201 (pinctl
& AC_PINCTL_OUT_EN
)) {
4202 pinctl
&= ~AC_PINCTL_OUT_EN
;
4203 pinctl
|= AC_PINCTL_IN_EN
;
4204 stac92xx_auto_set_pinctl(codec
, nid
,
4208 conf
= snd_hda_codec_get_pincfg(codec
, nid
);
4209 if (get_defcfg_connect(conf
) != AC_JACK_PORT_FIXED
) {
4210 if (enable_pin_detect(codec
, nid
,
4212 stac_issue_unsol_event(codec
, nid
);
4216 for (i
= 0; i
< spec
->num_dmics
; i
++)
4217 stac92xx_auto_set_pinctl(codec
, spec
->dmic_nids
[i
],
4219 if (cfg
->dig_out_pins
[0])
4220 stac92xx_auto_set_pinctl(codec
, cfg
->dig_out_pins
[0],
4222 if (cfg
->dig_in_pin
)
4223 stac92xx_auto_set_pinctl(codec
, cfg
->dig_in_pin
,
4225 for (i
= 0; i
< spec
->num_pwrs
; i
++) {
4226 hda_nid_t nid
= spec
->pwr_nids
[i
];
4227 int pinctl
, def_conf
;
4229 /* power on when no jack detection is available */
4230 if (!spec
->hp_detect
) {
4231 stac_toggle_power_map(codec
, nid
, 1);
4235 if (is_nid_hp_pin(cfg
, nid
))
4236 continue; /* already has an unsol event */
4238 pinctl
= snd_hda_codec_read(codec
, nid
, 0,
4239 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
4240 /* outputs are only ports capable of power management
4241 * any attempts on powering down a input port cause the
4242 * referenced VREF to act quirky.
4244 if (pinctl
& AC_PINCTL_IN_EN
) {
4245 stac_toggle_power_map(codec
, nid
, 1);
4248 def_conf
= snd_hda_codec_get_pincfg(codec
, nid
);
4249 def_conf
= get_defcfg_connect(def_conf
);
4250 /* skip any ports that don't have jacks since presence
4251 * detection is useless */
4252 if (def_conf
!= AC_JACK_PORT_COMPLEX
) {
4253 if (def_conf
!= AC_JACK_PORT_NONE
)
4254 stac_toggle_power_map(codec
, nid
, 1);
4257 if (enable_pin_detect(codec
, nid
, STAC_PWR_EVENT
))
4258 stac_issue_unsol_event(codec
, nid
);
4261 stac92xx_power_down(codec
);
4265 static void stac92xx_free_jacks(struct hda_codec
*codec
)
4267 #ifdef CONFIG_SND_HDA_INPUT_JACK
4268 /* free jack instances manually when clearing/reconfiguring */
4269 struct sigmatel_spec
*spec
= codec
->spec
;
4270 if (!codec
->bus
->shutdown
&& spec
->jacks
.list
) {
4271 struct sigmatel_jack
*jacks
= spec
->jacks
.list
;
4273 for (i
= 0; i
< spec
->jacks
.used
; i
++, jacks
++) {
4275 snd_device_free(codec
->bus
->card
, jacks
->jack
);
4278 snd_array_free(&spec
->jacks
);
4282 static void stac92xx_free_kctls(struct hda_codec
*codec
)
4284 struct sigmatel_spec
*spec
= codec
->spec
;
4286 if (spec
->kctls
.list
) {
4287 struct snd_kcontrol_new
*kctl
= spec
->kctls
.list
;
4289 for (i
= 0; i
< spec
->kctls
.used
; i
++)
4290 kfree(kctl
[i
].name
);
4292 snd_array_free(&spec
->kctls
);
4295 static void stac92xx_free(struct hda_codec
*codec
)
4297 struct sigmatel_spec
*spec
= codec
->spec
;
4302 stac92xx_free_jacks(codec
);
4303 snd_array_free(&spec
->events
);
4306 snd_hda_detach_beep_device(codec
);
4309 static void stac92xx_set_pinctl(struct hda_codec
*codec
, hda_nid_t nid
,
4312 unsigned int old_ctl
, pin_ctl
;
4314 pin_ctl
= snd_hda_codec_read(codec
, nid
,
4315 0, AC_VERB_GET_PIN_WIDGET_CONTROL
, 0x00);
4317 if (pin_ctl
& AC_PINCTL_IN_EN
) {
4319 * we need to check the current set-up direction of
4320 * shared input pins since they can be switched via
4321 * "xxx as Output" mixer switch
4323 struct sigmatel_spec
*spec
= codec
->spec
;
4324 if (nid
== spec
->line_switch
|| nid
== spec
->mic_switch
)
4329 /* if setting pin direction bits, clear the current
4330 direction bits first */
4331 if (flag
& (AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
))
4332 pin_ctl
&= ~(AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
);
4335 if (old_ctl
!= pin_ctl
)
4336 snd_hda_codec_write_cache(codec
, nid
, 0,
4337 AC_VERB_SET_PIN_WIDGET_CONTROL
,
4341 static void stac92xx_reset_pinctl(struct hda_codec
*codec
, hda_nid_t nid
,
4344 unsigned int pin_ctl
= snd_hda_codec_read(codec
, nid
,
4345 0, AC_VERB_GET_PIN_WIDGET_CONTROL
, 0x00);
4347 snd_hda_codec_write_cache(codec
, nid
, 0,
4348 AC_VERB_SET_PIN_WIDGET_CONTROL
,
4352 static int get_pin_presence(struct hda_codec
*codec
, hda_nid_t nid
)
4356 if (snd_hda_codec_read(codec
, nid
, 0, AC_VERB_GET_PIN_SENSE
, 0x00)
4362 static void stac92xx_line_out_detect(struct hda_codec
*codec
,
4365 struct sigmatel_spec
*spec
= codec
->spec
;
4366 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4369 for (i
= 0; i
< cfg
->line_outs
; i
++) {
4372 presence
= get_pin_presence(codec
, cfg
->line_out_pins
[i
]);
4374 unsigned int pinctl
;
4375 pinctl
= snd_hda_codec_read(codec
,
4376 cfg
->line_out_pins
[i
], 0,
4377 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
4378 if (pinctl
& AC_PINCTL_IN_EN
)
4379 presence
= 0; /* mic- or line-input */
4384 /* disable speakers */
4385 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
4386 stac92xx_reset_pinctl(codec
, cfg
->speaker_pins
[i
],
4388 if (spec
->eapd_mask
&& spec
->eapd_switch
)
4389 stac_gpio_set(codec
, spec
->gpio_mask
,
4390 spec
->gpio_dir
, spec
->gpio_data
&
4393 /* enable speakers */
4394 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
4395 stac92xx_set_pinctl(codec
, cfg
->speaker_pins
[i
],
4397 if (spec
->eapd_mask
&& spec
->eapd_switch
)
4398 stac_gpio_set(codec
, spec
->gpio_mask
,
4399 spec
->gpio_dir
, spec
->gpio_data
|
4404 /* return non-zero if the hp-pin of the given array index isn't
4405 * a jack-detection target
4407 static int no_hp_sensing(struct sigmatel_spec
*spec
, int i
)
4409 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4411 /* ignore sensing of shared line and mic jacks */
4412 if (cfg
->hp_pins
[i
] == spec
->line_switch
)
4414 if (cfg
->hp_pins
[i
] == spec
->mic_switch
)
4416 /* ignore if the pin is set as line-out */
4417 if (cfg
->hp_pins
[i
] == spec
->hp_switch
)
4422 static void stac92xx_hp_detect(struct hda_codec
*codec
)
4424 struct sigmatel_spec
*spec
= codec
->spec
;
4425 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
4429 if (spec
->gpio_mute
)
4430 presence
= !(snd_hda_codec_read(codec
, codec
->afg
, 0,
4431 AC_VERB_GET_GPIO_DATA
, 0) & spec
->gpio_mute
);
4433 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
4436 if (no_hp_sensing(spec
, i
))
4438 presence
= get_pin_presence(codec
, cfg
->hp_pins
[i
]);
4440 unsigned int pinctl
;
4441 pinctl
= snd_hda_codec_read(codec
, cfg
->hp_pins
[i
], 0,
4442 AC_VERB_GET_PIN_WIDGET_CONTROL
, 0);
4443 if (pinctl
& AC_PINCTL_IN_EN
)
4444 presence
= 0; /* mic- or line-input */
4449 /* disable lineouts */
4450 if (spec
->hp_switch
)
4451 stac92xx_reset_pinctl(codec
, spec
->hp_switch
,
4453 for (i
= 0; i
< cfg
->line_outs
; i
++)
4454 stac92xx_reset_pinctl(codec
, cfg
->line_out_pins
[i
],
4457 /* enable lineouts */
4458 if (spec
->hp_switch
)
4459 stac92xx_set_pinctl(codec
, spec
->hp_switch
,
4461 for (i
= 0; i
< cfg
->line_outs
; i
++)
4462 stac92xx_set_pinctl(codec
, cfg
->line_out_pins
[i
],
4465 stac92xx_line_out_detect(codec
, presence
);
4466 /* toggle hp outs */
4467 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
4468 unsigned int val
= AC_PINCTL_OUT_EN
| AC_PINCTL_HP_EN
;
4469 if (no_hp_sensing(spec
, i
))
4472 stac92xx_set_pinctl(codec
, cfg
->hp_pins
[i
], val
);
4474 /* Resetting the pinctl like below may lead to (a sort of) regressions
4475 * on some devices since they use the HP pin actually for line/speaker
4476 * outs although the default pin config shows a different pin (that is
4477 * wrong and useless).
4479 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4480 * But, disabling the code below just works around it, and I'm too tired of
4481 * bug reports with such devices...
4484 stac92xx_reset_pinctl(codec
, cfg
->hp_pins
[i
], val
);
4489 static void stac_toggle_power_map(struct hda_codec
*codec
, hda_nid_t nid
,
4492 struct sigmatel_spec
*spec
= codec
->spec
;
4493 unsigned int idx
, val
;
4495 for (idx
= 0; idx
< spec
->num_pwrs
; idx
++) {
4496 if (spec
->pwr_nids
[idx
] == nid
)
4499 if (idx
>= spec
->num_pwrs
)
4502 /* several codecs have two power down bits */
4503 if (spec
->pwr_mapping
)
4504 idx
= spec
->pwr_mapping
[idx
];
4508 val
= snd_hda_codec_read(codec
, codec
->afg
, 0, 0x0fec, 0x0) & 0xff;
4514 /* power down unused output ports */
4515 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7ec, val
);
4518 static void stac92xx_pin_sense(struct hda_codec
*codec
, hda_nid_t nid
)
4520 stac_toggle_power_map(codec
, nid
, get_pin_presence(codec
, nid
));
4523 static void stac92xx_report_jack(struct hda_codec
*codec
, hda_nid_t nid
)
4525 struct sigmatel_spec
*spec
= codec
->spec
;
4526 struct sigmatel_jack
*jacks
= spec
->jacks
.list
;
4530 for (i
= 0; i
< spec
->jacks
.used
; i
++) {
4531 if (jacks
->nid
== nid
) {
4532 unsigned int pin_ctl
=
4533 snd_hda_codec_read(codec
, nid
,
4534 0, AC_VERB_GET_PIN_WIDGET_CONTROL
,
4536 int type
= jacks
->type
;
4537 if (type
== (SND_JACK_LINEOUT
4538 | SND_JACK_HEADPHONE
))
4539 type
= (pin_ctl
& AC_PINCTL_HP_EN
)
4540 ? SND_JACK_HEADPHONE
: SND_JACK_LINEOUT
;
4541 snd_jack_report(jacks
->jack
,
4542 get_pin_presence(codec
, nid
)
4550 static void stac92xx_mic_detect(struct hda_codec
*codec
)
4552 struct sigmatel_spec
*spec
= codec
->spec
;
4553 struct sigmatel_mic_route
*mic
;
4555 if (get_pin_presence(codec
, spec
->ext_mic
.pin
))
4556 mic
= &spec
->ext_mic
;
4558 mic
= &spec
->int_mic
;
4560 snd_hda_codec_write_cache(codec
, spec
->dmux_nids
[0], 0,
4561 AC_VERB_SET_CONNECT_SEL
,
4564 snd_hda_codec_write_cache(codec
, spec
->mux_nids
[0], 0,
4565 AC_VERB_SET_CONNECT_SEL
,
4569 static void stac_issue_unsol_event(struct hda_codec
*codec
, hda_nid_t nid
)
4571 struct sigmatel_event
*event
= stac_get_event(codec
, nid
);
4574 codec
->patch_ops
.unsol_event(codec
, (unsigned)event
->tag
<< 26);
4577 static void stac92xx_unsol_event(struct hda_codec
*codec
, unsigned int res
)
4579 struct sigmatel_spec
*spec
= codec
->spec
;
4580 struct sigmatel_event
*event
;
4583 tag
= (res
>> 26) & 0x7f;
4584 event
= stac_get_event_from_tag(codec
, tag
);
4588 switch (event
->type
) {
4591 stac92xx_hp_detect(codec
);
4593 case STAC_MIC_EVENT
:
4594 stac92xx_mic_detect(codec
);
4598 switch (event
->type
) {
4601 case STAC_MIC_EVENT
:
4602 case STAC_INSERT_EVENT
:
4603 case STAC_PWR_EVENT
:
4604 if (spec
->num_pwrs
> 0)
4605 stac92xx_pin_sense(codec
, event
->nid
);
4606 stac92xx_report_jack(codec
, event
->nid
);
4608 switch (codec
->subsystem_id
) {
4610 if (event
->nid
== 0xb) {
4611 int pin
= AC_PINCTL_IN_EN
;
4613 if (get_pin_presence(codec
, 0xa)
4614 && get_pin_presence(codec
, 0xb))
4615 pin
|= AC_PINCTL_VREF_80
;
4616 if (!get_pin_presence(codec
, 0xb))
4617 pin
|= AC_PINCTL_VREF_80
;
4619 /* toggle VREF state based on mic + hp pin
4622 stac92xx_auto_set_pinctl(codec
, 0x0a, pin
);
4626 case STAC_VREF_EVENT
:
4627 data
= snd_hda_codec_read(codec
, codec
->afg
, 0,
4628 AC_VERB_GET_GPIO_DATA
, 0);
4629 /* toggle VREF state based on GPIOx status */
4630 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7e0,
4631 !!(data
& (1 << event
->data
)));
4636 #ifdef CONFIG_PROC_FS
4637 static void stac92hd_proc_hook(struct snd_info_buffer
*buffer
,
4638 struct hda_codec
*codec
, hda_nid_t nid
)
4640 if (nid
== codec
->afg
)
4641 snd_iprintf(buffer
, "Power-Map: 0x%02x\n",
4642 snd_hda_codec_read(codec
, nid
, 0, 0x0fec, 0x0));
4645 static void analog_loop_proc_hook(struct snd_info_buffer
*buffer
,
4646 struct hda_codec
*codec
,
4649 snd_iprintf(buffer
, "Analog Loopback: 0x%02x\n",
4650 snd_hda_codec_read(codec
, codec
->afg
, 0, verb
, 0));
4653 /* stac92hd71bxx, stac92hd73xx */
4654 static void stac92hd7x_proc_hook(struct snd_info_buffer
*buffer
,
4655 struct hda_codec
*codec
, hda_nid_t nid
)
4657 stac92hd_proc_hook(buffer
, codec
, nid
);
4658 if (nid
== codec
->afg
)
4659 analog_loop_proc_hook(buffer
, codec
, 0xfa0);
4662 static void stac9205_proc_hook(struct snd_info_buffer
*buffer
,
4663 struct hda_codec
*codec
, hda_nid_t nid
)
4665 if (nid
== codec
->afg
)
4666 analog_loop_proc_hook(buffer
, codec
, 0xfe0);
4669 static void stac927x_proc_hook(struct snd_info_buffer
*buffer
,
4670 struct hda_codec
*codec
, hda_nid_t nid
)
4672 if (nid
== codec
->afg
)
4673 analog_loop_proc_hook(buffer
, codec
, 0xfeb);
4676 #define stac92hd_proc_hook NULL
4677 #define stac92hd7x_proc_hook NULL
4678 #define stac9205_proc_hook NULL
4679 #define stac927x_proc_hook NULL
4682 #ifdef SND_HDA_NEEDS_RESUME
4683 static int stac92xx_resume(struct hda_codec
*codec
)
4685 struct sigmatel_spec
*spec
= codec
->spec
;
4687 stac92xx_init(codec
);
4688 snd_hda_codec_resume_amp(codec
);
4689 snd_hda_codec_resume_cache(codec
);
4690 /* fake event to set up pins again to override cached values */
4691 if (spec
->hp_detect
)
4692 stac_issue_unsol_event(codec
, spec
->autocfg
.hp_pins
[0]);
4697 * using power check for controlling mute led of HP notebooks
4698 * check for mute state only on Speakers (nid = 0x10)
4700 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4701 * the LED is NOT working properly !
4703 * Changed name to reflect that it now works for any designated
4704 * model, not just HP HDX.
4707 #ifdef CONFIG_SND_HDA_POWER_SAVE
4708 static int stac92xx_hp_check_power_status(struct hda_codec
*codec
,
4711 struct sigmatel_spec
*spec
= codec
->spec
;
4714 if (snd_hda_codec_amp_read(codec
, nid
, 0, HDA_OUTPUT
, 0) &
4716 spec
->gpio_data
&= ~spec
->gpio_led
; /* orange */
4718 spec
->gpio_data
|= spec
->gpio_led
; /* white */
4720 stac_gpio_set(codec
, spec
->gpio_mask
,
4729 static int stac92xx_suspend(struct hda_codec
*codec
, pm_message_t state
)
4731 struct sigmatel_spec
*spec
= codec
->spec
;
4735 /* reset each pin before powering down DAC/ADC to avoid click noise */
4736 nid
= codec
->start_nid
;
4737 for (i
= 0; i
< codec
->num_nodes
; i
++, nid
++) {
4738 unsigned int wcaps
= get_wcaps(codec
, nid
);
4739 unsigned int wid_type
= get_wcaps_type(wcaps
);
4740 if (wid_type
== AC_WID_PIN
)
4741 snd_hda_codec_read(codec
, nid
, 0,
4742 AC_VERB_SET_PIN_WIDGET_CONTROL
, 0);
4745 if (spec
->eapd_mask
)
4746 stac_gpio_set(codec
, spec
->gpio_mask
,
4747 spec
->gpio_dir
, spec
->gpio_data
&
4753 static struct hda_codec_ops stac92xx_patch_ops
= {
4754 .build_controls
= stac92xx_build_controls
,
4755 .build_pcms
= stac92xx_build_pcms
,
4756 .init
= stac92xx_init
,
4757 .free
= stac92xx_free
,
4758 .unsol_event
= stac92xx_unsol_event
,
4759 #ifdef SND_HDA_NEEDS_RESUME
4760 .suspend
= stac92xx_suspend
,
4761 .resume
= stac92xx_resume
,
4765 static int patch_stac9200(struct hda_codec
*codec
)
4767 struct sigmatel_spec
*spec
;
4770 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4775 spec
->num_pins
= ARRAY_SIZE(stac9200_pin_nids
);
4776 spec
->pin_nids
= stac9200_pin_nids
;
4777 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_9200_MODELS
,
4780 if (spec
->board_config
< 0)
4781 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
4784 stac92xx_set_config_regs(codec
,
4785 stac9200_brd_tbl
[spec
->board_config
]);
4787 spec
->multiout
.max_channels
= 2;
4788 spec
->multiout
.num_dacs
= 1;
4789 spec
->multiout
.dac_nids
= stac9200_dac_nids
;
4790 spec
->adc_nids
= stac9200_adc_nids
;
4791 spec
->mux_nids
= stac9200_mux_nids
;
4792 spec
->num_muxes
= 1;
4793 spec
->num_dmics
= 0;
4797 if (spec
->board_config
== STAC_9200_M4
||
4798 spec
->board_config
== STAC_9200_M4_2
||
4799 spec
->board_config
== STAC_9200_OQO
)
4800 spec
->init
= stac9200_eapd_init
;
4802 spec
->init
= stac9200_core_init
;
4803 spec
->mixer
= stac9200_mixer
;
4805 if (spec
->board_config
== STAC_9200_PANASONIC
) {
4806 spec
->gpio_mask
= spec
->gpio_dir
= 0x09;
4807 spec
->gpio_data
= 0x00;
4810 err
= stac9200_parse_auto_config(codec
);
4812 stac92xx_free(codec
);
4816 /* CF-74 has no headphone detection, and the driver should *NOT*
4817 * do detection and HP/speaker toggle because the hardware does it.
4819 if (spec
->board_config
== STAC_9200_PANASONIC
)
4820 spec
->hp_detect
= 0;
4822 codec
->patch_ops
= stac92xx_patch_ops
;
4827 static int patch_stac925x(struct hda_codec
*codec
)
4829 struct sigmatel_spec
*spec
;
4832 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4837 spec
->num_pins
= ARRAY_SIZE(stac925x_pin_nids
);
4838 spec
->pin_nids
= stac925x_pin_nids
;
4840 /* Check first for codec ID */
4841 spec
->board_config
= snd_hda_check_board_codec_sid_config(codec
,
4844 stac925x_codec_id_cfg_tbl
);
4846 /* Now checks for PCI ID, if codec ID is not found */
4847 if (spec
->board_config
< 0)
4848 spec
->board_config
= snd_hda_check_board_config(codec
,
4853 if (spec
->board_config
< 0)
4854 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
4857 stac92xx_set_config_regs(codec
,
4858 stac925x_brd_tbl
[spec
->board_config
]);
4860 spec
->multiout
.max_channels
= 2;
4861 spec
->multiout
.num_dacs
= 1;
4862 spec
->multiout
.dac_nids
= stac925x_dac_nids
;
4863 spec
->adc_nids
= stac925x_adc_nids
;
4864 spec
->mux_nids
= stac925x_mux_nids
;
4865 spec
->num_muxes
= 1;
4868 switch (codec
->vendor_id
) {
4869 case 0x83847632: /* STAC9202 */
4870 case 0x83847633: /* STAC9202D */
4871 case 0x83847636: /* STAC9251 */
4872 case 0x83847637: /* STAC9251D */
4873 spec
->num_dmics
= STAC925X_NUM_DMICS
;
4874 spec
->dmic_nids
= stac925x_dmic_nids
;
4875 spec
->num_dmuxes
= ARRAY_SIZE(stac925x_dmux_nids
);
4876 spec
->dmux_nids
= stac925x_dmux_nids
;
4879 spec
->num_dmics
= 0;
4883 spec
->init
= stac925x_core_init
;
4884 spec
->mixer
= stac925x_mixer
;
4886 spec
->capvols
= stac925x_capvols
;
4887 spec
->capsws
= stac925x_capsws
;
4889 err
= stac92xx_parse_auto_config(codec
, 0x8, 0x7);
4891 if (spec
->board_config
< 0) {
4892 printk(KERN_WARNING
"hda_codec: No auto-config is "
4893 "available, default to model=ref\n");
4894 spec
->board_config
= STAC_925x_REF
;
4900 stac92xx_free(codec
);
4904 codec
->patch_ops
= stac92xx_patch_ops
;
4909 static int patch_stac92hd73xx(struct hda_codec
*codec
)
4911 struct sigmatel_spec
*spec
;
4912 hda_nid_t conn
[STAC92HD73_DAC_COUNT
+ 2];
4916 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
4921 codec
->slave_dig_outs
= stac92hd73xx_slave_dig_outs
;
4922 spec
->num_pins
= ARRAY_SIZE(stac92hd73xx_pin_nids
);
4923 spec
->pin_nids
= stac92hd73xx_pin_nids
;
4924 spec
->board_config
= snd_hda_check_board_config(codec
,
4925 STAC_92HD73XX_MODELS
,
4926 stac92hd73xx_models
,
4927 stac92hd73xx_cfg_tbl
);
4928 /* check codec subsystem id if not found */
4929 if (spec
->board_config
< 0)
4930 spec
->board_config
=
4931 snd_hda_check_board_codec_sid_config(codec
,
4932 STAC_92HD73XX_MODELS
, stac92hd73xx_models
,
4933 stac92hd73xx_codec_id_cfg_tbl
);
4935 if (spec
->board_config
< 0)
4936 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
4939 stac92xx_set_config_regs(codec
,
4940 stac92hd73xx_brd_tbl
[spec
->board_config
]);
4942 num_dacs
= snd_hda_get_connections(codec
, 0x0a,
4943 conn
, STAC92HD73_DAC_COUNT
+ 2) - 1;
4945 if (num_dacs
< 3 || num_dacs
> 5) {
4946 printk(KERN_WARNING
"hda_codec: Could not determine "
4947 "number of channels defaulting to DAC count\n");
4948 num_dacs
= STAC92HD73_DAC_COUNT
;
4950 spec
->init
= stac92hd73xx_core_init
;
4952 case 0x3: /* 6 Channel */
4953 spec
->aloopback_ctl
= stac92hd73xx_6ch_loopback
;
4955 case 0x4: /* 8 Channel */
4956 spec
->aloopback_ctl
= stac92hd73xx_8ch_loopback
;
4958 case 0x5: /* 10 Channel */
4959 spec
->aloopback_ctl
= stac92hd73xx_10ch_loopback
;
4962 spec
->multiout
.dac_nids
= spec
->dac_nids
;
4964 spec
->aloopback_mask
= 0x01;
4965 spec
->aloopback_shift
= 8;
4967 spec
->digbeep_nid
= 0x1c;
4968 spec
->mux_nids
= stac92hd73xx_mux_nids
;
4969 spec
->adc_nids
= stac92hd73xx_adc_nids
;
4970 spec
->dmic_nids
= stac92hd73xx_dmic_nids
;
4971 spec
->dmux_nids
= stac92hd73xx_dmux_nids
;
4972 spec
->smux_nids
= stac92hd73xx_smux_nids
;
4974 spec
->num_muxes
= ARRAY_SIZE(stac92hd73xx_mux_nids
);
4975 spec
->num_adcs
= ARRAY_SIZE(stac92hd73xx_adc_nids
);
4976 spec
->num_dmuxes
= ARRAY_SIZE(stac92hd73xx_dmux_nids
);
4978 spec
->num_caps
= STAC92HD73XX_NUM_CAPS
;
4979 spec
->capvols
= stac92hd73xx_capvols
;
4980 spec
->capsws
= stac92hd73xx_capsws
;
4982 switch (spec
->board_config
) {
4984 spec
->init
= dell_eq_core_init
;
4986 case STAC_DELL_M6_AMIC
:
4987 case STAC_DELL_M6_DMIC
:
4988 case STAC_DELL_M6_BOTH
:
4989 spec
->num_smuxes
= 0;
4990 spec
->eapd_switch
= 0;
4992 switch (spec
->board_config
) {
4993 case STAC_DELL_M6_AMIC
: /* Analog Mics */
4994 snd_hda_codec_set_pincfg(codec
, 0x0b, 0x90A70170);
4995 spec
->num_dmics
= 0;
4997 case STAC_DELL_M6_DMIC
: /* Digital Mics */
4998 snd_hda_codec_set_pincfg(codec
, 0x13, 0x90A60160);
4999 spec
->num_dmics
= 1;
5001 case STAC_DELL_M6_BOTH
: /* Both */
5002 snd_hda_codec_set_pincfg(codec
, 0x0b, 0x90A70170);
5003 snd_hda_codec_set_pincfg(codec
, 0x13, 0x90A60160);
5004 spec
->num_dmics
= 1;
5008 case STAC_ALIENWARE_M17X
:
5009 spec
->num_dmics
= STAC92HD73XX_NUM_DMICS
;
5010 spec
->num_smuxes
= ARRAY_SIZE(stac92hd73xx_smux_nids
);
5011 spec
->eapd_switch
= 0;
5014 spec
->num_dmics
= STAC92HD73XX_NUM_DMICS
;
5015 spec
->num_smuxes
= ARRAY_SIZE(stac92hd73xx_smux_nids
);
5016 spec
->eapd_switch
= 1;
5019 if (spec
->board_config
> STAC_92HD73XX_REF
) {
5020 /* GPIO0 High = Enable EAPD */
5021 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x1;
5022 spec
->gpio_data
= 0x01;
5025 spec
->num_pwrs
= ARRAY_SIZE(stac92hd73xx_pwr_nids
);
5026 spec
->pwr_nids
= stac92hd73xx_pwr_nids
;
5028 err
= stac92xx_parse_auto_config(codec
, 0x25, 0x27);
5031 if (spec
->board_config
< 0) {
5032 printk(KERN_WARNING
"hda_codec: No auto-config is "
5033 "available, default to model=ref\n");
5034 spec
->board_config
= STAC_92HD73XX_REF
;
5041 stac92xx_free(codec
);
5045 if (spec
->board_config
== STAC_92HD73XX_NO_JD
)
5046 spec
->hp_detect
= 0;
5048 codec
->patch_ops
= stac92xx_patch_ops
;
5050 codec
->proc_widget_hook
= stac92hd7x_proc_hook
;
5055 static int patch_stac92hd83xxx(struct hda_codec
*codec
)
5057 struct sigmatel_spec
*spec
;
5058 hda_nid_t conn
[STAC92HD83_DAC_COUNT
+ 1];
5063 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5068 codec
->slave_dig_outs
= stac92hd83xxx_slave_dig_outs
;
5069 spec
->mono_nid
= 0x19;
5070 spec
->digbeep_nid
= 0x21;
5071 spec
->mux_nids
= stac92hd83xxx_mux_nids
;
5072 spec
->num_muxes
= ARRAY_SIZE(stac92hd83xxx_mux_nids
);
5073 spec
->adc_nids
= stac92hd83xxx_adc_nids
;
5074 spec
->num_adcs
= ARRAY_SIZE(stac92hd83xxx_adc_nids
);
5075 spec
->pwr_nids
= stac92hd83xxx_pwr_nids
;
5076 spec
->pwr_mapping
= stac92hd83xxx_pwr_mapping
;
5077 spec
->num_pwrs
= ARRAY_SIZE(stac92hd83xxx_pwr_nids
);
5078 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5080 spec
->init
= stac92hd83xxx_core_init
;
5081 spec
->num_pins
= ARRAY_SIZE(stac92hd83xxx_pin_nids
);
5082 spec
->pin_nids
= stac92hd83xxx_pin_nids
;
5083 spec
->num_caps
= STAC92HD83XXX_NUM_CAPS
;
5084 spec
->capvols
= stac92hd83xxx_capvols
;
5085 spec
->capsws
= stac92hd83xxx_capsws
;
5087 spec
->board_config
= snd_hda_check_board_config(codec
,
5088 STAC_92HD83XXX_MODELS
,
5089 stac92hd83xxx_models
,
5090 stac92hd83xxx_cfg_tbl
);
5092 if (spec
->board_config
< 0)
5093 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
5096 stac92xx_set_config_regs(codec
,
5097 stac92hd83xxx_brd_tbl
[spec
->board_config
]);
5099 switch (codec
->vendor_id
) {
5103 if (spec
->board_config
== STAC_92HD83XXX_PWR_REF
)
5109 err
= stac92xx_parse_auto_config(codec
, 0x1d, 0);
5111 if (spec
->board_config
< 0) {
5112 printk(KERN_WARNING
"hda_codec: No auto-config is "
5113 "available, default to model=ref\n");
5114 spec
->board_config
= STAC_92HD83XXX_REF
;
5121 stac92xx_free(codec
);
5125 switch (spec
->board_config
) {
5134 num_dacs
= snd_hda_get_connections(codec
, nid
,
5135 conn
, STAC92HD83_DAC_COUNT
+ 1) - 1;
5137 num_dacs
= STAC92HD83_DAC_COUNT
;
5139 /* set port X to select the last DAC
5141 snd_hda_codec_write_cache(codec
, nid
, 0,
5142 AC_VERB_SET_CONNECT_SEL
, num_dacs
);
5144 codec
->patch_ops
= stac92xx_patch_ops
;
5146 codec
->proc_widget_hook
= stac92hd_proc_hook
;
5151 /* get the pin connection (fixed, none, etc) */
5152 static unsigned int stac_get_defcfg_connect(struct hda_codec
*codec
, int idx
)
5154 struct sigmatel_spec
*spec
= codec
->spec
;
5157 cfg
= snd_hda_codec_get_pincfg(codec
, spec
->pin_nids
[idx
]);
5158 return get_defcfg_connect(cfg
);
5161 static int stac92hd71bxx_connected_ports(struct hda_codec
*codec
,
5162 hda_nid_t
*nids
, int num_nids
)
5164 struct sigmatel_spec
*spec
= codec
->spec
;
5166 unsigned int def_conf
;
5168 for (num
= 0; num
< num_nids
; num
++) {
5169 for (idx
= 0; idx
< spec
->num_pins
; idx
++)
5170 if (spec
->pin_nids
[idx
] == nids
[num
])
5172 if (idx
>= spec
->num_pins
)
5174 def_conf
= stac_get_defcfg_connect(codec
, idx
);
5175 if (def_conf
== AC_JACK_PORT_NONE
)
5181 static int stac92hd71bxx_connected_smuxes(struct hda_codec
*codec
,
5184 struct sigmatel_spec
*spec
= codec
->spec
;
5187 for (idx
= 0; idx
< spec
->num_pins
; idx
++)
5188 if (spec
->pin_nids
[idx
] == dig0pin
)
5190 if ((idx
+ 2) >= spec
->num_pins
)
5194 if (stac_get_defcfg_connect(codec
, idx
+ 1) != AC_JACK_PORT_NONE
)
5197 /* dig0pin + dig2pin case */
5198 if (stac_get_defcfg_connect(codec
, idx
+ 2) != AC_JACK_PORT_NONE
)
5200 if (stac_get_defcfg_connect(codec
, idx
) != AC_JACK_PORT_NONE
)
5206 static int patch_stac92hd71bxx(struct hda_codec
*codec
)
5208 struct sigmatel_spec
*spec
;
5209 struct hda_verb
*unmute_init
= stac92hd71bxx_unmute_core_init
;
5212 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5217 codec
->patch_ops
= stac92xx_patch_ops
;
5218 spec
->num_pins
= STAC92HD71BXX_NUM_PINS
;
5219 switch (codec
->vendor_id
) {
5222 spec
->pin_nids
= stac92hd71bxx_pin_nids_4port
;
5226 /* On 92HD75Bx 0x27 isn't a pin nid */
5230 spec
->pin_nids
= stac92hd71bxx_pin_nids_6port
;
5232 spec
->num_pwrs
= ARRAY_SIZE(stac92hd71bxx_pwr_nids
);
5233 spec
->board_config
= snd_hda_check_board_config(codec
,
5234 STAC_92HD71BXX_MODELS
,
5235 stac92hd71bxx_models
,
5236 stac92hd71bxx_cfg_tbl
);
5238 if (spec
->board_config
< 0)
5239 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
5242 stac92xx_set_config_regs(codec
,
5243 stac92hd71bxx_brd_tbl
[spec
->board_config
]);
5245 if (spec
->board_config
> STAC_92HD71BXX_REF
) {
5247 spec
->gpio_mask
= 0x01;
5248 spec
->gpio_dir
= 0x01;
5249 spec
->gpio_data
= 0x01;
5252 spec
->dmic_nids
= stac92hd71bxx_dmic_nids
;
5253 spec
->dmux_nids
= stac92hd71bxx_dmux_nids
;
5255 spec
->num_caps
= STAC92HD71BXX_NUM_CAPS
;
5256 spec
->capvols
= stac92hd71bxx_capvols
;
5257 spec
->capsws
= stac92hd71bxx_capsws
;
5259 switch (codec
->vendor_id
) {
5260 case 0x111d76b6: /* 4 Port without Analog Mixer */
5264 case 0x111d76b4: /* 6 Port without Analog Mixer */
5266 spec
->init
= stac92hd71bxx_core_init
;
5267 codec
->slave_dig_outs
= stac92hd71bxx_slave_dig_outs
;
5268 spec
->num_dmics
= stac92hd71bxx_connected_ports(codec
,
5269 stac92hd71bxx_dmic_nids
,
5270 STAC92HD71BXX_NUM_DMICS
);
5272 case 0x111d7608: /* 5 Port with Analog Mixer */
5273 switch (spec
->board_config
) {
5275 /* Enable VREF power saving on GPIO1 detect */
5276 err
= stac_add_event(spec
, codec
->afg
,
5277 STAC_VREF_EVENT
, 0x02);
5280 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
5281 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK
, 0x02);
5282 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
5283 AC_VERB_SET_UNSOLICITED_ENABLE
,
5285 spec
->gpio_mask
|= 0x02;
5288 if ((codec
->revision_id
& 0xf) == 0 ||
5289 (codec
->revision_id
& 0xf) == 1)
5290 spec
->stream_delay
= 40; /* 40 milliseconds */
5292 /* no output amps */
5295 spec
->init
= stac92hd71bxx_core_init
;
5297 snd_hda_codec_set_pincfg(codec
, 0x0f, 0x40f000f0);
5298 snd_hda_codec_set_pincfg(codec
, 0x19, 0x40f000f3);
5299 stac92hd71bxx_dmic_nids
[STAC92HD71BXX_NUM_DMICS
- 1] = 0;
5300 spec
->num_dmics
= stac92hd71bxx_connected_ports(codec
,
5301 stac92hd71bxx_dmic_nids
,
5302 STAC92HD71BXX_NUM_DMICS
- 1);
5304 case 0x111d7603: /* 6 Port with Analog Mixer */
5305 if ((codec
->revision_id
& 0xf) == 1)
5306 spec
->stream_delay
= 40; /* 40 milliseconds */
5308 /* no output amps */
5312 spec
->init
= stac92hd71bxx_core_init
;
5313 codec
->slave_dig_outs
= stac92hd71bxx_slave_dig_outs
;
5314 spec
->num_dmics
= stac92hd71bxx_connected_ports(codec
,
5315 stac92hd71bxx_dmic_nids
,
5316 STAC92HD71BXX_NUM_DMICS
);
5320 if (get_wcaps(codec
, 0xa) & AC_WCAP_IN_AMP
)
5321 snd_hda_sequence_write_cache(codec
, unmute_init
);
5323 /* Some HP machines seem to have unstable codec communications
5324 * especially with ATI fglrx driver. For recovering from the
5325 * CORB/RIRB stall, allow the BUS reset and keep always sync
5327 if (spec
->board_config
== STAC_HP_DV5
) {
5328 codec
->bus
->sync_write
= 1;
5329 codec
->bus
->allow_bus_reset
= 1;
5332 spec
->aloopback_ctl
= stac92hd71bxx_loopback
;
5333 spec
->aloopback_mask
= 0x50;
5334 spec
->aloopback_shift
= 0;
5336 spec
->powerdown_adcs
= 1;
5337 spec
->digbeep_nid
= 0x26;
5338 spec
->mux_nids
= stac92hd71bxx_mux_nids
;
5339 spec
->adc_nids
= stac92hd71bxx_adc_nids
;
5340 spec
->smux_nids
= stac92hd71bxx_smux_nids
;
5341 spec
->pwr_nids
= stac92hd71bxx_pwr_nids
;
5343 spec
->num_muxes
= ARRAY_SIZE(stac92hd71bxx_mux_nids
);
5344 spec
->num_adcs
= ARRAY_SIZE(stac92hd71bxx_adc_nids
);
5345 spec
->num_dmuxes
= ARRAY_SIZE(stac92hd71bxx_dmux_nids
);
5346 spec
->num_smuxes
= stac92hd71bxx_connected_smuxes(codec
, 0x1e);
5348 switch (spec
->board_config
) {
5350 /* enable internal microphone */
5351 snd_hda_codec_set_pincfg(codec
, 0x0e, 0x01813040);
5352 stac92xx_auto_set_pinctl(codec
, 0x0e,
5353 AC_PINCTL_IN_EN
| AC_PINCTL_VREF_80
);
5355 case STAC_DELL_M4_2
:
5356 spec
->num_dmics
= 0;
5357 spec
->num_smuxes
= 0;
5358 spec
->num_dmuxes
= 0;
5360 case STAC_DELL_M4_1
:
5361 case STAC_DELL_M4_3
:
5362 spec
->num_dmics
= 1;
5363 spec
->num_smuxes
= 0;
5364 spec
->num_dmuxes
= 1;
5366 case STAC_HP_DV4_1222NR
:
5367 spec
->num_dmics
= 1;
5368 /* I don't know if it needs 1 or 2 smuxes - will wait for
5369 * bug reports to fix if needed
5371 spec
->num_smuxes
= 1;
5372 spec
->num_dmuxes
= 1;
5373 spec
->gpio_led
= 0x01;
5376 snd_hda_codec_set_pincfg(codec
, 0x0d, 0x90170010);
5377 stac92xx_auto_set_pinctl(codec
, 0x0d, AC_PINCTL_OUT_EN
);
5380 spec
->num_dmics
= 1;
5381 spec
->num_dmuxes
= 1;
5382 spec
->num_smuxes
= 1;
5383 /* orange/white mute led on GPIO3, orange=0, white=1 */
5384 spec
->gpio_led
= 0x08;
5388 #ifdef CONFIG_SND_HDA_POWER_SAVE
5389 if (spec
->gpio_led
) {
5390 spec
->gpio_mask
|= spec
->gpio_led
;
5391 spec
->gpio_dir
|= spec
->gpio_led
;
5392 spec
->gpio_data
|= spec
->gpio_led
;
5393 /* register check_power_status callback. */
5394 codec
->patch_ops
.check_power_status
=
5395 stac92xx_hp_check_power_status
;
5399 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5401 err
= stac92xx_parse_auto_config(codec
, 0x21, 0);
5403 if (spec
->board_config
< 0) {
5404 printk(KERN_WARNING
"hda_codec: No auto-config is "
5405 "available, default to model=ref\n");
5406 spec
->board_config
= STAC_92HD71BXX_REF
;
5413 stac92xx_free(codec
);
5417 codec
->proc_widget_hook
= stac92hd7x_proc_hook
;
5422 static int patch_stac922x(struct hda_codec
*codec
)
5424 struct sigmatel_spec
*spec
;
5427 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5432 spec
->num_pins
= ARRAY_SIZE(stac922x_pin_nids
);
5433 spec
->pin_nids
= stac922x_pin_nids
;
5434 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_922X_MODELS
,
5437 if (spec
->board_config
== STAC_INTEL_MAC_AUTO
) {
5438 spec
->gpio_mask
= spec
->gpio_dir
= 0x03;
5439 spec
->gpio_data
= 0x03;
5440 /* Intel Macs have all same PCI SSID, so we need to check
5441 * codec SSID to distinguish the exact models
5443 printk(KERN_INFO
"hda_codec: STAC922x, Apple subsys_id=%x\n", codec
->subsystem_id
);
5444 switch (codec
->subsystem_id
) {
5447 spec
->board_config
= STAC_INTEL_MAC_V1
;
5451 spec
->board_config
= STAC_INTEL_MAC_V2
;
5459 spec
->board_config
= STAC_INTEL_MAC_V3
;
5463 spec
->board_config
= STAC_INTEL_MAC_V4
;
5467 spec
->board_config
= STAC_INTEL_MAC_V5
;
5470 spec
->board_config
= STAC_INTEL_MAC_V3
;
5476 if (spec
->board_config
< 0)
5477 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
5480 stac92xx_set_config_regs(codec
,
5481 stac922x_brd_tbl
[spec
->board_config
]);
5483 spec
->adc_nids
= stac922x_adc_nids
;
5484 spec
->mux_nids
= stac922x_mux_nids
;
5485 spec
->num_muxes
= ARRAY_SIZE(stac922x_mux_nids
);
5486 spec
->num_adcs
= ARRAY_SIZE(stac922x_adc_nids
);
5487 spec
->num_dmics
= 0;
5490 spec
->init
= stac922x_core_init
;
5492 spec
->num_caps
= STAC922X_NUM_CAPS
;
5493 spec
->capvols
= stac922x_capvols
;
5494 spec
->capsws
= stac922x_capsws
;
5496 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5498 err
= stac92xx_parse_auto_config(codec
, 0x08, 0x09);
5500 if (spec
->board_config
< 0) {
5501 printk(KERN_WARNING
"hda_codec: No auto-config is "
5502 "available, default to model=ref\n");
5503 spec
->board_config
= STAC_D945_REF
;
5509 stac92xx_free(codec
);
5513 codec
->patch_ops
= stac92xx_patch_ops
;
5515 /* Fix Mux capture level; max to 2 */
5516 snd_hda_override_amp_caps(codec
, 0x12, HDA_OUTPUT
,
5517 (0 << AC_AMPCAP_OFFSET_SHIFT
) |
5518 (2 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
5519 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
5520 (0 << AC_AMPCAP_MUTE_SHIFT
));
5525 static int patch_stac927x(struct hda_codec
*codec
)
5527 struct sigmatel_spec
*spec
;
5530 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5535 codec
->slave_dig_outs
= stac927x_slave_dig_outs
;
5536 spec
->num_pins
= ARRAY_SIZE(stac927x_pin_nids
);
5537 spec
->pin_nids
= stac927x_pin_nids
;
5538 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_927X_MODELS
,
5542 if (spec
->board_config
< 0)
5543 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
5546 stac92xx_set_config_regs(codec
,
5547 stac927x_brd_tbl
[spec
->board_config
]);
5549 spec
->digbeep_nid
= 0x23;
5550 spec
->adc_nids
= stac927x_adc_nids
;
5551 spec
->num_adcs
= ARRAY_SIZE(stac927x_adc_nids
);
5552 spec
->mux_nids
= stac927x_mux_nids
;
5553 spec
->num_muxes
= ARRAY_SIZE(stac927x_mux_nids
);
5554 spec
->smux_nids
= stac927x_smux_nids
;
5555 spec
->num_smuxes
= ARRAY_SIZE(stac927x_smux_nids
);
5556 spec
->spdif_labels
= stac927x_spdif_labels
;
5557 spec
->dac_list
= stac927x_dac_nids
;
5558 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5560 switch (spec
->board_config
) {
5563 /* GPIO0 High = Enable EAPD */
5564 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x01;
5565 spec
->gpio_data
= 0x01;
5566 spec
->num_dmics
= 0;
5568 spec
->init
= d965_core_init
;
5570 case STAC_DELL_BIOS
:
5571 switch (codec
->subsystem_id
) {
5574 /* correct the device field to SPDIF out */
5575 snd_hda_codec_set_pincfg(codec
, 0x21, 0x01442070);
5578 /* configure the analog microphone on some laptops */
5579 snd_hda_codec_set_pincfg(codec
, 0x0c, 0x90a79130);
5580 /* correct the front output jack as a hp out */
5581 snd_hda_codec_set_pincfg(codec
, 0x0f, 0x0227011f);
5582 /* correct the front input jack as a mic */
5583 snd_hda_codec_set_pincfg(codec
, 0x0e, 0x02a79130);
5586 /* GPIO2 High = Enable EAPD */
5587 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x04;
5588 spec
->gpio_data
= 0x04;
5589 switch (codec
->subsystem_id
) {
5591 /* correct EAPD to be GPIO0 */
5592 spec
->eapd_mask
= spec
->gpio_mask
= 0x01;
5593 spec
->gpio_dir
= spec
->gpio_data
= 0x01;
5596 spec
->dmic_nids
= stac927x_dmic_nids
;
5597 spec
->num_dmics
= STAC927X_NUM_DMICS
;
5599 spec
->init
= d965_core_init
;
5600 spec
->dmux_nids
= stac927x_dmux_nids
;
5601 spec
->num_dmuxes
= ARRAY_SIZE(stac927x_dmux_nids
);
5604 if (spec
->board_config
> STAC_D965_REF
) {
5605 /* GPIO0 High = Enable EAPD */
5606 spec
->eapd_mask
= spec
->gpio_mask
= 0x01;
5607 spec
->gpio_dir
= spec
->gpio_data
= 0x01;
5609 spec
->num_dmics
= 0;
5611 spec
->init
= stac927x_core_init
;
5614 spec
->num_caps
= STAC927X_NUM_CAPS
;
5615 spec
->capvols
= stac927x_capvols
;
5616 spec
->capsws
= stac927x_capsws
;
5619 spec
->aloopback_ctl
= stac927x_loopback
;
5620 spec
->aloopback_mask
= 0x40;
5621 spec
->aloopback_shift
= 0;
5622 spec
->eapd_switch
= 1;
5624 err
= stac92xx_parse_auto_config(codec
, 0x1e, 0x20);
5626 if (spec
->board_config
< 0) {
5627 printk(KERN_WARNING
"hda_codec: No auto-config is "
5628 "available, default to model=ref\n");
5629 spec
->board_config
= STAC_D965_REF
;
5635 stac92xx_free(codec
);
5639 codec
->patch_ops
= stac92xx_patch_ops
;
5641 codec
->proc_widget_hook
= stac927x_proc_hook
;
5645 * The STAC927x seem to require fairly long delays for certain
5646 * command sequences. With too short delays (even if the answer
5647 * is set to RIRB properly), it results in the silence output
5648 * on some hardwares like Dell.
5650 * The below flag enables the longer delay (see get_response
5653 codec
->bus
->needs_damn_long_delay
= 1;
5655 /* no jack detecion for ref-no-jd model */
5656 if (spec
->board_config
== STAC_D965_REF_NO_JD
)
5657 spec
->hp_detect
= 0;
5662 static int patch_stac9205(struct hda_codec
*codec
)
5664 struct sigmatel_spec
*spec
;
5667 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5672 spec
->num_pins
= ARRAY_SIZE(stac9205_pin_nids
);
5673 spec
->pin_nids
= stac9205_pin_nids
;
5674 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_9205_MODELS
,
5678 if (spec
->board_config
< 0)
5679 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
5682 stac92xx_set_config_regs(codec
,
5683 stac9205_brd_tbl
[spec
->board_config
]);
5685 spec
->digbeep_nid
= 0x23;
5686 spec
->adc_nids
= stac9205_adc_nids
;
5687 spec
->num_adcs
= ARRAY_SIZE(stac9205_adc_nids
);
5688 spec
->mux_nids
= stac9205_mux_nids
;
5689 spec
->num_muxes
= ARRAY_SIZE(stac9205_mux_nids
);
5690 spec
->smux_nids
= stac9205_smux_nids
;
5691 spec
->num_smuxes
= ARRAY_SIZE(stac9205_smux_nids
);
5692 spec
->dmic_nids
= stac9205_dmic_nids
;
5693 spec
->num_dmics
= STAC9205_NUM_DMICS
;
5694 spec
->dmux_nids
= stac9205_dmux_nids
;
5695 spec
->num_dmuxes
= ARRAY_SIZE(stac9205_dmux_nids
);
5698 spec
->init
= stac9205_core_init
;
5699 spec
->aloopback_ctl
= stac9205_loopback
;
5701 spec
->num_caps
= STAC9205_NUM_CAPS
;
5702 spec
->capvols
= stac9205_capvols
;
5703 spec
->capsws
= stac9205_capsws
;
5705 spec
->aloopback_mask
= 0x40;
5706 spec
->aloopback_shift
= 0;
5707 /* Turn on/off EAPD per HP plugging */
5708 if (spec
->board_config
!= STAC_9205_EAPD
)
5709 spec
->eapd_switch
= 1;
5710 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5712 switch (spec
->board_config
){
5713 case STAC_9205_DELL_M43
:
5714 /* Enable SPDIF in/out */
5715 snd_hda_codec_set_pincfg(codec
, 0x1f, 0x01441030);
5716 snd_hda_codec_set_pincfg(codec
, 0x20, 0x1c410030);
5718 /* Enable unsol response for GPIO4/Dock HP connection */
5719 err
= stac_add_event(spec
, codec
->afg
, STAC_VREF_EVENT
, 0x01);
5722 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
5723 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK
, 0x10);
5724 snd_hda_codec_write_cache(codec
, codec
->afg
, 0,
5725 AC_VERB_SET_UNSOLICITED_ENABLE
,
5728 spec
->gpio_dir
= 0x0b;
5729 spec
->eapd_mask
= 0x01;
5730 spec
->gpio_mask
= 0x1b;
5731 spec
->gpio_mute
= 0x10;
5732 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
5735 spec
->gpio_data
= 0x01;
5738 /* SPDIF-In enabled */
5741 /* GPIO0 High = EAPD */
5742 spec
->eapd_mask
= spec
->gpio_mask
= spec
->gpio_dir
= 0x1;
5743 spec
->gpio_data
= 0x01;
5747 err
= stac92xx_parse_auto_config(codec
, 0x1f, 0x20);
5749 if (spec
->board_config
< 0) {
5750 printk(KERN_WARNING
"hda_codec: No auto-config is "
5751 "available, default to model=ref\n");
5752 spec
->board_config
= STAC_9205_REF
;
5758 stac92xx_free(codec
);
5762 codec
->patch_ops
= stac92xx_patch_ops
;
5764 codec
->proc_widget_hook
= stac9205_proc_hook
;
5773 static struct hda_verb stac9872_core_init
[] = {
5774 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x1}, /* mic-sel: 0a,0d,14,02 */
5775 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
}, /* Mic-in -> 0x9 */
5779 static hda_nid_t stac9872_pin_nids
[] = {
5780 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5784 static hda_nid_t stac9872_adc_nids
[] = {
5788 static hda_nid_t stac9872_mux_nids
[] = {
5792 static unsigned long stac9872_capvols
[] = {
5793 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT
),
5795 #define stac9872_capsws stac9872_capvols
5797 static unsigned int stac9872_vaio_pin_configs
[9] = {
5798 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5799 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
5803 static const char *stac9872_models
[STAC_9872_MODELS
] = {
5804 [STAC_9872_AUTO
] = "auto",
5805 [STAC_9872_VAIO
] = "vaio",
5808 static unsigned int *stac9872_brd_tbl
[STAC_9872_MODELS
] = {
5809 [STAC_9872_VAIO
] = stac9872_vaio_pin_configs
,
5812 static struct snd_pci_quirk stac9872_cfg_tbl
[] = {
5813 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
5814 "Sony VAIO F/S", STAC_9872_VAIO
),
5818 static int patch_stac9872(struct hda_codec
*codec
)
5820 struct sigmatel_spec
*spec
;
5823 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
5827 spec
->num_pins
= ARRAY_SIZE(stac9872_pin_nids
);
5828 spec
->pin_nids
= stac9872_pin_nids
;
5830 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_9872_MODELS
,
5833 if (spec
->board_config
< 0)
5834 snd_printdd(KERN_INFO
"hda_codec: %s: BIOS auto-probing.\n",
5837 stac92xx_set_config_regs(codec
,
5838 stac9872_brd_tbl
[spec
->board_config
]);
5840 spec
->multiout
.dac_nids
= spec
->dac_nids
;
5841 spec
->num_adcs
= ARRAY_SIZE(stac9872_adc_nids
);
5842 spec
->adc_nids
= stac9872_adc_nids
;
5843 spec
->num_muxes
= ARRAY_SIZE(stac9872_mux_nids
);
5844 spec
->mux_nids
= stac9872_mux_nids
;
5845 spec
->init
= stac9872_core_init
;
5847 spec
->capvols
= stac9872_capvols
;
5848 spec
->capsws
= stac9872_capsws
;
5850 err
= stac92xx_parse_auto_config(codec
, 0x10, 0x12);
5852 stac92xx_free(codec
);
5855 spec
->input_mux
= &spec
->private_imux
;
5856 codec
->patch_ops
= stac92xx_patch_ops
;
5864 static struct hda_codec_preset snd_hda_preset_sigmatel
[] = {
5865 { .id
= 0x83847690, .name
= "STAC9200", .patch
= patch_stac9200
},
5866 { .id
= 0x83847882, .name
= "STAC9220 A1", .patch
= patch_stac922x
},
5867 { .id
= 0x83847680, .name
= "STAC9221 A1", .patch
= patch_stac922x
},
5868 { .id
= 0x83847880, .name
= "STAC9220 A2", .patch
= patch_stac922x
},
5869 { .id
= 0x83847681, .name
= "STAC9220D/9223D A2", .patch
= patch_stac922x
},
5870 { .id
= 0x83847682, .name
= "STAC9221 A2", .patch
= patch_stac922x
},
5871 { .id
= 0x83847683, .name
= "STAC9221D A2", .patch
= patch_stac922x
},
5872 { .id
= 0x83847618, .name
= "STAC9227", .patch
= patch_stac927x
},
5873 { .id
= 0x83847619, .name
= "STAC9227", .patch
= patch_stac927x
},
5874 { .id
= 0x83847616, .name
= "STAC9228", .patch
= patch_stac927x
},
5875 { .id
= 0x83847617, .name
= "STAC9228", .patch
= patch_stac927x
},
5876 { .id
= 0x83847614, .name
= "STAC9229", .patch
= patch_stac927x
},
5877 { .id
= 0x83847615, .name
= "STAC9229", .patch
= patch_stac927x
},
5878 { .id
= 0x83847620, .name
= "STAC9274", .patch
= patch_stac927x
},
5879 { .id
= 0x83847621, .name
= "STAC9274D", .patch
= patch_stac927x
},
5880 { .id
= 0x83847622, .name
= "STAC9273X", .patch
= patch_stac927x
},
5881 { .id
= 0x83847623, .name
= "STAC9273D", .patch
= patch_stac927x
},
5882 { .id
= 0x83847624, .name
= "STAC9272X", .patch
= patch_stac927x
},
5883 { .id
= 0x83847625, .name
= "STAC9272D", .patch
= patch_stac927x
},
5884 { .id
= 0x83847626, .name
= "STAC9271X", .patch
= patch_stac927x
},
5885 { .id
= 0x83847627, .name
= "STAC9271D", .patch
= patch_stac927x
},
5886 { .id
= 0x83847628, .name
= "STAC9274X5NH", .patch
= patch_stac927x
},
5887 { .id
= 0x83847629, .name
= "STAC9274D5NH", .patch
= patch_stac927x
},
5888 { .id
= 0x83847632, .name
= "STAC9202", .patch
= patch_stac925x
},
5889 { .id
= 0x83847633, .name
= "STAC9202D", .patch
= patch_stac925x
},
5890 { .id
= 0x83847634, .name
= "STAC9250", .patch
= patch_stac925x
},
5891 { .id
= 0x83847635, .name
= "STAC9250D", .patch
= patch_stac925x
},
5892 { .id
= 0x83847636, .name
= "STAC9251", .patch
= patch_stac925x
},
5893 { .id
= 0x83847637, .name
= "STAC9250D", .patch
= patch_stac925x
},
5894 { .id
= 0x83847645, .name
= "92HD206X", .patch
= patch_stac927x
},
5895 { .id
= 0x83847646, .name
= "92HD206D", .patch
= patch_stac927x
},
5896 /* The following does not take into account .id=0x83847661 when subsys =
5897 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5898 * currently not fully supported.
5900 { .id
= 0x83847661, .name
= "CXD9872RD/K", .patch
= patch_stac9872
},
5901 { .id
= 0x83847662, .name
= "STAC9872AK", .patch
= patch_stac9872
},
5902 { .id
= 0x83847664, .name
= "CXD9872AKD", .patch
= patch_stac9872
},
5903 { .id
= 0x83847698, .name
= "STAC9205", .patch
= patch_stac9205
},
5904 { .id
= 0x838476a0, .name
= "STAC9205", .patch
= patch_stac9205
},
5905 { .id
= 0x838476a1, .name
= "STAC9205D", .patch
= patch_stac9205
},
5906 { .id
= 0x838476a2, .name
= "STAC9204", .patch
= patch_stac9205
},
5907 { .id
= 0x838476a3, .name
= "STAC9204D", .patch
= patch_stac9205
},
5908 { .id
= 0x838476a4, .name
= "STAC9255", .patch
= patch_stac9205
},
5909 { .id
= 0x838476a5, .name
= "STAC9255D", .patch
= patch_stac9205
},
5910 { .id
= 0x838476a6, .name
= "STAC9254", .patch
= patch_stac9205
},
5911 { .id
= 0x838476a7, .name
= "STAC9254D", .patch
= patch_stac9205
},
5912 { .id
= 0x111d7603, .name
= "92HD75B3X5", .patch
= patch_stac92hd71bxx
},
5913 { .id
= 0x111d7604, .name
= "92HD83C1X5", .patch
= patch_stac92hd83xxx
},
5914 { .id
= 0x111d7605, .name
= "92HD81B1X5", .patch
= patch_stac92hd83xxx
},
5915 { .id
= 0x111d76d5, .name
= "92HD81B1C5", .patch
= patch_stac92hd83xxx
},
5916 { .id
= 0x111d7608, .name
= "92HD75B2X5", .patch
= patch_stac92hd71bxx
},
5917 { .id
= 0x111d7674, .name
= "92HD73D1X5", .patch
= patch_stac92hd73xx
},
5918 { .id
= 0x111d7675, .name
= "92HD73C1X5", .patch
= patch_stac92hd73xx
},
5919 { .id
= 0x111d7676, .name
= "92HD73E1X5", .patch
= patch_stac92hd73xx
},
5920 { .id
= 0x111d76b0, .name
= "92HD71B8X", .patch
= patch_stac92hd71bxx
},
5921 { .id
= 0x111d76b1, .name
= "92HD71B8X", .patch
= patch_stac92hd71bxx
},
5922 { .id
= 0x111d76b2, .name
= "92HD71B7X", .patch
= patch_stac92hd71bxx
},
5923 { .id
= 0x111d76b3, .name
= "92HD71B7X", .patch
= patch_stac92hd71bxx
},
5924 { .id
= 0x111d76b4, .name
= "92HD71B6X", .patch
= patch_stac92hd71bxx
},
5925 { .id
= 0x111d76b5, .name
= "92HD71B6X", .patch
= patch_stac92hd71bxx
},
5926 { .id
= 0x111d76b6, .name
= "92HD71B5X", .patch
= patch_stac92hd71bxx
},
5927 { .id
= 0x111d76b7, .name
= "92HD71B5X", .patch
= patch_stac92hd71bxx
},
5931 MODULE_ALIAS("snd-hda-codec-id:8384*");
5932 MODULE_ALIAS("snd-hda-codec-id:111d*");
5934 MODULE_LICENSE("GPL");
5935 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5937 static struct hda_codec_preset_list sigmatel_list
= {
5938 .preset
= snd_hda_preset_sigmatel
,
5939 .owner
= THIS_MODULE
,
5942 static int __init
patch_sigmatel_init(void)
5944 return snd_hda_add_codec_preset(&sigmatel_list
);
5947 static void __exit
patch_sigmatel_exit(void)
5949 snd_hda_delete_codec_preset(&sigmatel_list
);
5952 module_init(patch_sigmatel_init
)
5953 module_exit(patch_sigmatel_exit
)