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 <sound/driver.h>
28 #include <linux/init.h>
29 #include <linux/delay.h>
30 #include <linux/slab.h>
31 #include <linux/pci.h>
32 #include <sound/core.h>
33 #include <sound/asoundef.h>
34 #include "hda_codec.h"
35 #include "hda_local.h"
37 #define NUM_CONTROL_ALLOC 32
38 #define STAC_HP_EVENT 0x37
77 struct sigmatel_spec
{
78 struct snd_kcontrol_new
*mixers
[4];
79 unsigned int num_mixers
;
82 unsigned int surr_switch
: 1;
83 unsigned int line_switch
: 1;
84 unsigned int mic_switch
: 1;
85 unsigned int alt_switch
: 1;
86 unsigned int hp_detect
: 1;
87 unsigned int gpio_mute
: 1;
90 struct hda_multi_out multiout
;
91 hda_nid_t dac_nids
[5];
95 unsigned int num_adcs
;
97 unsigned int num_muxes
;
99 unsigned int num_dmics
;
101 hda_nid_t dig_in_nid
;
105 unsigned int num_pins
;
106 unsigned int *pin_configs
;
107 unsigned int *bios_pin_configs
;
109 /* codec specific stuff */
110 struct hda_verb
*init
;
111 struct snd_kcontrol_new
*mixer
;
114 struct hda_input_mux
*dinput_mux
;
115 unsigned int cur_dmux
;
116 struct hda_input_mux
*input_mux
;
117 unsigned int cur_mux
[3];
120 unsigned int io_switch
[2];
122 struct hda_pcm pcm_rec
[2]; /* PCM information */
124 /* dynamic controls and input_mux */
125 struct auto_pin_cfg autocfg
;
126 unsigned int num_kctl_alloc
, num_kctl_used
;
127 struct snd_kcontrol_new
*kctl_alloc
;
128 struct hda_input_mux private_dimux
;
129 struct hda_input_mux private_imux
;
132 static hda_nid_t stac9200_adc_nids
[1] = {
136 static hda_nid_t stac9200_mux_nids
[1] = {
140 static hda_nid_t stac9200_dac_nids
[1] = {
144 static hda_nid_t stac925x_adc_nids
[1] = {
148 static hda_nid_t stac925x_mux_nids
[1] = {
152 static hda_nid_t stac925x_dac_nids
[1] = {
156 #define STAC925X_NUM_DMICS 1
157 static hda_nid_t stac925x_dmic_nids
[STAC925X_NUM_DMICS
+ 1] = {
161 static hda_nid_t stac922x_adc_nids
[2] = {
165 static hda_nid_t stac922x_mux_nids
[2] = {
169 static hda_nid_t stac927x_adc_nids
[3] = {
173 static hda_nid_t stac927x_mux_nids
[3] = {
177 static hda_nid_t stac9205_adc_nids
[2] = {
181 static hda_nid_t stac9205_mux_nids
[2] = {
185 #define STAC9205_NUM_DMICS 2
186 static hda_nid_t stac9205_dmic_nids
[STAC9205_NUM_DMICS
+ 1] = {
190 static hda_nid_t stac9200_pin_nids
[8] = {
191 0x08, 0x09, 0x0d, 0x0e,
192 0x0f, 0x10, 0x11, 0x12,
195 static hda_nid_t stac925x_pin_nids
[8] = {
196 0x07, 0x08, 0x0a, 0x0b,
197 0x0c, 0x0d, 0x10, 0x11,
200 static hda_nid_t stac922x_pin_nids
[10] = {
201 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
202 0x0f, 0x10, 0x11, 0x15, 0x1b,
205 static hda_nid_t stac927x_pin_nids
[14] = {
206 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
207 0x0f, 0x10, 0x11, 0x12, 0x13,
208 0x14, 0x21, 0x22, 0x23,
211 static hda_nid_t stac9205_pin_nids
[12] = {
212 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
213 0x0f, 0x14, 0x16, 0x17, 0x18,
218 static int stac92xx_dmux_enum_info(struct snd_kcontrol
*kcontrol
,
219 struct snd_ctl_elem_info
*uinfo
)
221 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
222 struct sigmatel_spec
*spec
= codec
->spec
;
223 return snd_hda_input_mux_info(spec
->dinput_mux
, uinfo
);
226 static int stac92xx_dmux_enum_get(struct snd_kcontrol
*kcontrol
,
227 struct snd_ctl_elem_value
*ucontrol
)
229 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
230 struct sigmatel_spec
*spec
= codec
->spec
;
232 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_dmux
;
236 static int stac92xx_dmux_enum_put(struct snd_kcontrol
*kcontrol
,
237 struct snd_ctl_elem_value
*ucontrol
)
239 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
240 struct sigmatel_spec
*spec
= codec
->spec
;
242 return snd_hda_input_mux_put(codec
, spec
->dinput_mux
, ucontrol
,
243 spec
->dmux_nid
, &spec
->cur_dmux
);
246 static int stac92xx_mux_enum_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
248 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
249 struct sigmatel_spec
*spec
= codec
->spec
;
250 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
253 static int stac92xx_mux_enum_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
255 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
256 struct sigmatel_spec
*spec
= codec
->spec
;
257 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
259 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
263 static int stac92xx_mux_enum_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
265 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
266 struct sigmatel_spec
*spec
= codec
->spec
;
267 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
269 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
270 spec
->mux_nids
[adc_idx
], &spec
->cur_mux
[adc_idx
]);
273 static struct hda_verb stac9200_core_init
[] = {
274 /* set dac0mux for dac converter */
275 { 0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
279 static struct hda_verb stac925x_core_init
[] = {
280 /* set dac0mux for dac converter */
281 { 0x06, AC_VERB_SET_CONNECT_SEL
, 0x00},
285 static struct hda_verb stac922x_core_init
[] = {
286 /* set master volume and direct control */
287 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
291 static struct hda_verb d965_core_init
[] = {
292 /* set master volume and direct control */
293 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
294 /* unmute node 0x1b */
295 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
296 /* select node 0x03 as DAC */
297 { 0x0b, AC_VERB_SET_CONNECT_SEL
, 0x01},
301 static struct hda_verb stac927x_core_init
[] = {
302 /* set master volume and direct control */
303 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
307 static struct hda_verb stac9205_core_init
[] = {
308 /* set master volume and direct control */
309 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
313 static struct snd_kcontrol_new stac9200_mixer
[] = {
314 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT
),
315 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT
),
317 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
318 .name
= "Input Source",
320 .info
= stac92xx_mux_enum_info
,
321 .get
= stac92xx_mux_enum_get
,
322 .put
= stac92xx_mux_enum_put
,
324 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT
),
325 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT
),
326 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT
),
330 static struct snd_kcontrol_new stac925x_mixer
[] = {
331 HDA_CODEC_VOLUME("Master Playback Volume", 0xe, 0, HDA_OUTPUT
),
332 HDA_CODEC_MUTE("Master Playback Switch", 0xe, 0, HDA_OUTPUT
),
334 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
335 .name
= "Input Source",
337 .info
= stac92xx_mux_enum_info
,
338 .get
= stac92xx_mux_enum_get
,
339 .put
= stac92xx_mux_enum_put
,
341 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT
),
342 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT
),
343 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT
),
347 /* This needs to be generated dynamically based on sequence */
348 static struct snd_kcontrol_new stac922x_mixer
[] = {
350 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
351 .name
= "Input Source",
353 .info
= stac92xx_mux_enum_info
,
354 .get
= stac92xx_mux_enum_get
,
355 .put
= stac92xx_mux_enum_put
,
357 HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT
),
358 HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT
),
359 HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
363 /* This needs to be generated dynamically based on sequence */
364 static struct snd_kcontrol_new stac9227_mixer
[] = {
366 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
367 .name
= "Input Source",
369 .info
= stac92xx_mux_enum_info
,
370 .get
= stac92xx_mux_enum_get
,
371 .put
= stac92xx_mux_enum_put
,
373 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
374 HDA_CODEC_MUTE("Capture Switch", 0x1b, 0x0, HDA_OUTPUT
),
378 static struct snd_kcontrol_new stac927x_mixer
[] = {
380 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
381 .name
= "Input Source",
383 .info
= stac92xx_mux_enum_info
,
384 .get
= stac92xx_mux_enum_get
,
385 .put
= stac92xx_mux_enum_put
,
387 HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
388 HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT
),
389 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT
),
393 static struct snd_kcontrol_new stac9205_mixer
[] = {
395 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
396 .name
= "Digital Input Source",
398 .info
= stac92xx_dmux_enum_info
,
399 .get
= stac92xx_dmux_enum_get
,
400 .put
= stac92xx_dmux_enum_put
,
403 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
404 .name
= "Input Source",
406 .info
= stac92xx_mux_enum_info
,
407 .get
= stac92xx_mux_enum_get
,
408 .put
= stac92xx_mux_enum_put
,
410 HDA_CODEC_VOLUME("InMux Capture Volume", 0x19, 0x0, HDA_OUTPUT
),
411 HDA_CODEC_VOLUME("InVol Capture Volume", 0x1b, 0x0, HDA_INPUT
),
412 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1d, 0x0, HDA_OUTPUT
),
416 static int stac92xx_build_controls(struct hda_codec
*codec
)
418 struct sigmatel_spec
*spec
= codec
->spec
;
422 err
= snd_hda_add_new_ctls(codec
, spec
->mixer
);
426 for (i
= 0; i
< spec
->num_mixers
; i
++) {
427 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
432 if (spec
->multiout
.dig_out_nid
) {
433 err
= snd_hda_create_spdif_out_ctls(codec
, spec
->multiout
.dig_out_nid
);
437 if (spec
->dig_in_nid
) {
438 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
445 static unsigned int ref9200_pin_configs
[8] = {
446 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
447 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
450 static unsigned int *stac9200_brd_tbl
[STAC_9200_MODELS
] = {
451 [STAC_REF
] = ref9200_pin_configs
,
454 static const char *stac9200_models
[STAC_9200_MODELS
] = {
458 static struct snd_pci_quirk stac9200_cfg_tbl
[] = {
459 /* SigmaTel reference board */
460 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
461 "DFI LanParty", STAC_REF
),
462 /* Dell laptops have BIOS problem */
463 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01b5,
464 "Dell Inspiron 630m", STAC_REF
),
465 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c2,
466 "Dell Latitude D620", STAC_REF
),
467 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cb,
468 "Dell Latitude 120L", STAC_REF
),
469 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cc,
470 "Dell Latitude D820", STAC_REF
),
471 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cd,
472 "Dell Inspiron E1705/9400", STAC_REF
),
473 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ce,
474 "Dell XPS M1710", STAC_REF
),
475 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cf,
476 "Dell Precision M90", STAC_REF
),
477 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d6,
478 "unknown Dell", STAC_REF
),
479 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d8,
480 "Dell Inspiron 640m", STAC_REF
),
481 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f5,
482 "Dell Inspiron 1501", STAC_REF
),
485 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF
),
490 static unsigned int ref925x_pin_configs
[8] = {
491 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
492 0x90a70320, 0x02214210, 0x400003f1, 0x9033032e,
495 static unsigned int stac925x_MA6_pin_configs
[8] = {
496 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
497 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
500 static unsigned int stac925x_PA6_pin_configs
[8] = {
501 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
502 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
505 static unsigned int stac925xM2_2_pin_configs
[8] = {
506 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
507 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
510 static unsigned int *stac925x_brd_tbl
[STAC_925x_MODELS
] = {
511 [STAC_REF
] = ref925x_pin_configs
,
512 [STAC_M2_2
] = stac925xM2_2_pin_configs
,
513 [STAC_MA6
] = stac925x_MA6_pin_configs
,
514 [STAC_PA6
] = stac925x_PA6_pin_configs
,
517 static const char *stac925x_models
[STAC_925x_MODELS
] = {
519 [STAC_M2_2
] = "m2-2",
524 static struct snd_pci_quirk stac925x_cfg_tbl
[] = {
525 /* SigmaTel reference board */
526 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668, "DFI LanParty", STAC_REF
),
527 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF
),
528 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF
),
529 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF
),
530 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6
),
531 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6
),
532 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2
),
536 static unsigned int ref922x_pin_configs
[10] = {
537 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
538 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
539 0x40000100, 0x40000100,
542 static unsigned int d945gtp3_pin_configs
[10] = {
543 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
544 0x40000100, 0x40000100, 0x40000100, 0x40000100,
545 0x02a19120, 0x40000100,
548 static unsigned int d945gtp5_pin_configs
[10] = {
549 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
550 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
551 0x02a19320, 0x40000100,
554 static unsigned int macbook_pro_v1_pin_configs
[10] = {
555 0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010,
556 0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e,
557 0x02a19320, 0x400000fb
560 static unsigned int macbook_pro_v2_pin_configs
[10] = {
561 0x0221401f, 0x90a70120, 0x01813024, 0x01014010,
562 0x400000fd, 0x01016011, 0x1345e240, 0x13c5e22e,
563 0x400000fc, 0x400000fb,
566 static unsigned int imac_intel_pin_configs
[10] = {
567 0x0121e230, 0x90a70120, 0x9017e110, 0x400000fe,
568 0x400000fd, 0x0181e021, 0x1145e040, 0x400000fa,
569 0x400000fc, 0x400000fb,
572 static unsigned int *stac922x_brd_tbl
[STAC_922X_MODELS
] = {
573 [STAC_D945_REF
] = ref922x_pin_configs
,
574 [STAC_D945GTP3
] = d945gtp3_pin_configs
,
575 [STAC_D945GTP5
] = d945gtp5_pin_configs
,
576 [STAC_MACMINI
] = macbook_pro_v1_pin_configs
,
577 [STAC_MACBOOK
] = macbook_pro_v1_pin_configs
,
578 [STAC_MACBOOK_PRO_V1
] = macbook_pro_v1_pin_configs
,
579 [STAC_MACBOOK_PRO_V2
] = macbook_pro_v2_pin_configs
,
580 [STAC_IMAC_INTEL
] = imac_intel_pin_configs
,
583 static const char *stac922x_models
[STAC_922X_MODELS
] = {
584 [STAC_D945_REF
] = "ref",
585 [STAC_D945GTP5
] = "5stack",
586 [STAC_D945GTP3
] = "3stack",
587 [STAC_MACMINI
] = "macmini",
588 [STAC_MACBOOK
] = "macbook",
589 [STAC_MACBOOK_PRO_V1
] = "macbook-pro-v1",
590 [STAC_MACBOOK_PRO_V2
] = "macbook-pro",
591 [STAC_IMAC_INTEL
] = "imac-intel",
594 static struct snd_pci_quirk stac922x_cfg_tbl
[] = {
595 /* SigmaTel reference board */
596 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
597 "DFI LanParty", STAC_D945_REF
),
598 /* Intel 945G based systems */
599 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0101,
600 "Intel D945G", STAC_D945GTP3
),
601 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0202,
602 "Intel D945G", STAC_D945GTP3
),
603 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0606,
604 "Intel D945G", STAC_D945GTP3
),
605 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0601,
606 "Intel D945G", STAC_D945GTP3
),
607 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0111,
608 "Intel D945G", STAC_D945GTP3
),
609 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1115,
610 "Intel D945G", STAC_D945GTP3
),
611 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1116,
612 "Intel D945G", STAC_D945GTP3
),
613 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1117,
614 "Intel D945G", STAC_D945GTP3
),
615 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1118,
616 "Intel D945G", STAC_D945GTP3
),
617 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1119,
618 "Intel D945G", STAC_D945GTP3
),
619 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x8826,
620 "Intel D945G", STAC_D945GTP3
),
621 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5049,
622 "Intel D945G", STAC_D945GTP3
),
623 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5055,
624 "Intel D945G", STAC_D945GTP3
),
625 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5048,
626 "Intel D945G", STAC_D945GTP3
),
627 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0110,
628 "Intel D945G", STAC_D945GTP3
),
629 /* Intel D945G 5-stack systems */
630 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0404,
631 "Intel D945G", STAC_D945GTP5
),
632 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0303,
633 "Intel D945G", STAC_D945GTP5
),
634 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0013,
635 "Intel D945G", STAC_D945GTP5
),
636 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0417,
637 "Intel D945G", STAC_D945GTP5
),
638 /* Intel 945P based systems */
639 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0b0b,
640 "Intel D945P", STAC_D945GTP3
),
641 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0112,
642 "Intel D945P", STAC_D945GTP3
),
643 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0d0d,
644 "Intel D945P", STAC_D945GTP3
),
645 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0909,
646 "Intel D945P", STAC_D945GTP3
),
647 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0505,
648 "Intel D945P", STAC_D945GTP3
),
649 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0707,
650 "Intel D945P", STAC_D945GTP5
),
652 /* Apple Mac Mini (early 2006) */
653 SND_PCI_QUIRK(0x8384, 0x7680,
654 "Mac Mini", STAC_MACMINI
),
658 static unsigned int ref927x_pin_configs
[14] = {
659 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
660 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
661 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
662 0x01c42190, 0x40000100,
665 static unsigned int d965_3st_pin_configs
[14] = {
666 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
667 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
668 0x40000100, 0x40000100, 0x40000100, 0x40000100,
669 0x40000100, 0x40000100
672 static unsigned int d965_5st_pin_configs
[14] = {
673 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
674 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
675 0x40000100, 0x40000100, 0x40000100, 0x01442070,
676 0x40000100, 0x40000100
679 static unsigned int *stac927x_brd_tbl
[STAC_927X_MODELS
] = {
680 [STAC_D965_REF
] = ref927x_pin_configs
,
681 [STAC_D965_3ST
] = d965_3st_pin_configs
,
682 [STAC_D965_5ST
] = d965_5st_pin_configs
,
685 static const char *stac927x_models
[STAC_927X_MODELS
] = {
686 [STAC_D965_REF
] = "ref",
687 [STAC_D965_3ST
] = "3stack",
688 [STAC_D965_5ST
] = "5stack",
691 static struct snd_pci_quirk stac927x_cfg_tbl
[] = {
692 /* SigmaTel reference board */
693 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
694 "DFI LanParty", STAC_D965_REF
),
695 /* Intel 946 based systems */
696 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x3d01, "Intel D946", STAC_D965_3ST
),
697 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0xa301, "Intel D946", STAC_D965_3ST
),
698 /* 965 based 3 stack systems */
699 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2116, "Intel D965", STAC_D965_3ST
),
700 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2115, "Intel D965", STAC_D965_3ST
),
701 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2114, "Intel D965", STAC_D965_3ST
),
702 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2113, "Intel D965", STAC_D965_3ST
),
703 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2112, "Intel D965", STAC_D965_3ST
),
704 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2111, "Intel D965", STAC_D965_3ST
),
705 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2110, "Intel D965", STAC_D965_3ST
),
706 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2009, "Intel D965", STAC_D965_3ST
),
707 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2008, "Intel D965", STAC_D965_3ST
),
708 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2007, "Intel D965", STAC_D965_3ST
),
709 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2006, "Intel D965", STAC_D965_3ST
),
710 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2005, "Intel D965", STAC_D965_3ST
),
711 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2004, "Intel D965", STAC_D965_3ST
),
712 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2003, "Intel D965", STAC_D965_3ST
),
713 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2002, "Intel D965", STAC_D965_3ST
),
714 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2001, "Intel D965", STAC_D965_3ST
),
715 /* 965 based 5 stack systems */
716 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2301, "Intel D965", STAC_D965_5ST
),
717 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2302, "Intel D965", STAC_D965_5ST
),
718 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2303, "Intel D965", STAC_D965_5ST
),
719 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2304, "Intel D965", STAC_D965_5ST
),
720 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2305, "Intel D965", STAC_D965_5ST
),
721 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2501, "Intel D965", STAC_D965_5ST
),
722 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2502, "Intel D965", STAC_D965_5ST
),
723 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2503, "Intel D965", STAC_D965_5ST
),
724 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2504, "Intel D965", STAC_D965_5ST
),
728 static unsigned int ref9205_pin_configs
[12] = {
729 0x40000100, 0x40000100, 0x01016011, 0x01014010,
730 0x01813122, 0x01a19021, 0x40000100, 0x40000100,
731 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
734 static unsigned int *stac9205_brd_tbl
[STAC_9205_MODELS
] = {
738 static const char *stac9205_models
[STAC_9205_MODELS
] = {
739 [STAC_9205_REF
] = "ref",
742 static struct snd_pci_quirk stac9205_cfg_tbl
[] = {
743 /* SigmaTel reference board */
744 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
745 "DFI LanParty", STAC_9205_REF
),
749 static int stac92xx_save_bios_config_regs(struct hda_codec
*codec
)
752 struct sigmatel_spec
*spec
= codec
->spec
;
754 if (! spec
->bios_pin_configs
) {
755 spec
->bios_pin_configs
= kcalloc(spec
->num_pins
,
756 sizeof(*spec
->bios_pin_configs
), GFP_KERNEL
);
757 if (! spec
->bios_pin_configs
)
761 for (i
= 0; i
< spec
->num_pins
; i
++) {
762 hda_nid_t nid
= spec
->pin_nids
[i
];
763 unsigned int pin_cfg
;
765 pin_cfg
= snd_hda_codec_read(codec
, nid
, 0,
766 AC_VERB_GET_CONFIG_DEFAULT
, 0x00);
767 snd_printdd(KERN_INFO
"hda_codec: pin nid %2.2x bios pin config %8.8x\n",
769 spec
->bios_pin_configs
[i
] = pin_cfg
;
775 static void stac92xx_set_config_regs(struct hda_codec
*codec
)
778 struct sigmatel_spec
*spec
= codec
->spec
;
779 unsigned int pin_cfg
;
781 if (! spec
->pin_nids
|| ! spec
->pin_configs
)
784 for (i
= 0; i
< spec
->num_pins
; i
++) {
785 snd_hda_codec_write(codec
, spec
->pin_nids
[i
], 0,
786 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0
,
787 spec
->pin_configs
[i
] & 0x000000ff);
788 snd_hda_codec_write(codec
, spec
->pin_nids
[i
], 0,
789 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1
,
790 (spec
->pin_configs
[i
] & 0x0000ff00) >> 8);
791 snd_hda_codec_write(codec
, spec
->pin_nids
[i
], 0,
792 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2
,
793 (spec
->pin_configs
[i
] & 0x00ff0000) >> 16);
794 snd_hda_codec_write(codec
, spec
->pin_nids
[i
], 0,
795 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3
,
796 spec
->pin_configs
[i
] >> 24);
797 pin_cfg
= snd_hda_codec_read(codec
, spec
->pin_nids
[i
], 0,
798 AC_VERB_GET_CONFIG_DEFAULT
,
800 snd_printdd(KERN_INFO
"hda_codec: pin nid %2.2x pin config %8.8x\n", spec
->pin_nids
[i
], pin_cfg
);
805 * Analog playback callbacks
807 static int stac92xx_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
808 struct hda_codec
*codec
,
809 struct snd_pcm_substream
*substream
)
811 struct sigmatel_spec
*spec
= codec
->spec
;
812 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
);
815 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
816 struct hda_codec
*codec
,
817 unsigned int stream_tag
,
819 struct snd_pcm_substream
*substream
)
821 struct sigmatel_spec
*spec
= codec
->spec
;
822 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
, stream_tag
, format
, substream
);
825 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
826 struct hda_codec
*codec
,
827 struct snd_pcm_substream
*substream
)
829 struct sigmatel_spec
*spec
= codec
->spec
;
830 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
834 * Digital playback callbacks
836 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
837 struct hda_codec
*codec
,
838 struct snd_pcm_substream
*substream
)
840 struct sigmatel_spec
*spec
= codec
->spec
;
841 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
844 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
845 struct hda_codec
*codec
,
846 struct snd_pcm_substream
*substream
)
848 struct sigmatel_spec
*spec
= codec
->spec
;
849 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
852 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
853 struct hda_codec
*codec
,
854 unsigned int stream_tag
,
856 struct snd_pcm_substream
*substream
)
858 struct sigmatel_spec
*spec
= codec
->spec
;
859 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
860 stream_tag
, format
, substream
);
865 * Analog capture callbacks
867 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
868 struct hda_codec
*codec
,
869 unsigned int stream_tag
,
871 struct snd_pcm_substream
*substream
)
873 struct sigmatel_spec
*spec
= codec
->spec
;
875 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
876 stream_tag
, 0, format
);
880 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
881 struct hda_codec
*codec
,
882 struct snd_pcm_substream
*substream
)
884 struct sigmatel_spec
*spec
= codec
->spec
;
886 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
], 0, 0, 0);
890 static struct hda_pcm_stream stac92xx_pcm_digital_playback
= {
894 /* NID is set in stac92xx_build_pcms */
896 .open
= stac92xx_dig_playback_pcm_open
,
897 .close
= stac92xx_dig_playback_pcm_close
,
898 .prepare
= stac92xx_dig_playback_pcm_prepare
902 static struct hda_pcm_stream stac92xx_pcm_digital_capture
= {
906 /* NID is set in stac92xx_build_pcms */
909 static struct hda_pcm_stream stac92xx_pcm_analog_playback
= {
913 .nid
= 0x02, /* NID to query formats and rates */
915 .open
= stac92xx_playback_pcm_open
,
916 .prepare
= stac92xx_playback_pcm_prepare
,
917 .cleanup
= stac92xx_playback_pcm_cleanup
921 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback
= {
925 .nid
= 0x06, /* NID to query formats and rates */
927 .open
= stac92xx_playback_pcm_open
,
928 .prepare
= stac92xx_playback_pcm_prepare
,
929 .cleanup
= stac92xx_playback_pcm_cleanup
933 static struct hda_pcm_stream stac92xx_pcm_analog_capture
= {
937 /* NID is set in stac92xx_build_pcms */
939 .prepare
= stac92xx_capture_pcm_prepare
,
940 .cleanup
= stac92xx_capture_pcm_cleanup
944 static int stac92xx_build_pcms(struct hda_codec
*codec
)
946 struct sigmatel_spec
*spec
= codec
->spec
;
947 struct hda_pcm
*info
= spec
->pcm_rec
;
950 codec
->pcm_info
= info
;
952 info
->name
= "STAC92xx Analog";
953 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_analog_playback
;
954 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = stac92xx_pcm_analog_capture
;
955 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
957 if (spec
->alt_switch
) {
960 info
->name
= "STAC92xx Analog Alt";
961 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_analog_alt_playback
;
964 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
967 info
->name
= "STAC92xx Digital";
968 if (spec
->multiout
.dig_out_nid
) {
969 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_digital_playback
;
970 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
972 if (spec
->dig_in_nid
) {
973 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = stac92xx_pcm_digital_capture
;
974 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
981 static unsigned int stac92xx_get_vref(struct hda_codec
*codec
, hda_nid_t nid
)
983 unsigned int pincap
= snd_hda_param_read(codec
, nid
,
985 pincap
= (pincap
& AC_PINCAP_VREF
) >> AC_PINCAP_VREF_SHIFT
;
986 if (pincap
& AC_PINCAP_VREF_100
)
987 return AC_PINCTL_VREF_100
;
988 if (pincap
& AC_PINCAP_VREF_80
)
989 return AC_PINCTL_VREF_80
;
990 if (pincap
& AC_PINCAP_VREF_50
)
991 return AC_PINCTL_VREF_50
;
992 if (pincap
& AC_PINCAP_VREF_GRD
)
993 return AC_PINCTL_VREF_GRD
;
997 static void stac92xx_auto_set_pinctl(struct hda_codec
*codec
, hda_nid_t nid
, int pin_type
)
1000 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, pin_type
);
1003 static int stac92xx_io_switch_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
1005 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
1007 uinfo
->value
.integer
.min
= 0;
1008 uinfo
->value
.integer
.max
= 1;
1012 static int stac92xx_io_switch_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1014 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1015 struct sigmatel_spec
*spec
= codec
->spec
;
1016 int io_idx
= kcontrol
-> private_value
& 0xff;
1018 ucontrol
->value
.integer
.value
[0] = spec
->io_switch
[io_idx
];
1022 static int stac92xx_io_switch_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1024 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1025 struct sigmatel_spec
*spec
= codec
->spec
;
1026 hda_nid_t nid
= kcontrol
->private_value
>> 8;
1027 int io_idx
= kcontrol
-> private_value
& 0xff;
1028 unsigned short val
= ucontrol
->value
.integer
.value
[0];
1030 spec
->io_switch
[io_idx
] = val
;
1033 stac92xx_auto_set_pinctl(codec
, nid
, AC_PINCTL_OUT_EN
);
1035 unsigned int pinctl
= AC_PINCTL_IN_EN
;
1036 if (io_idx
) /* set VREF for mic */
1037 pinctl
|= stac92xx_get_vref(codec
, nid
);
1038 stac92xx_auto_set_pinctl(codec
, nid
, pinctl
);
1043 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
1044 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1047 .info = stac92xx_io_switch_info, \
1048 .get = stac92xx_io_switch_get, \
1049 .put = stac92xx_io_switch_put, \
1050 .private_value = xpval, \
1055 STAC_CTL_WIDGET_VOL
,
1056 STAC_CTL_WIDGET_MUTE
,
1057 STAC_CTL_WIDGET_IO_SWITCH
,
1060 static struct snd_kcontrol_new stac92xx_control_templates
[] = {
1061 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
1062 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
1063 STAC_CODEC_IO_SWITCH(NULL
, 0),
1066 /* add dynamic controls */
1067 static int stac92xx_add_control(struct sigmatel_spec
*spec
, int type
, const char *name
, unsigned long val
)
1069 struct snd_kcontrol_new
*knew
;
1071 if (spec
->num_kctl_used
>= spec
->num_kctl_alloc
) {
1072 int num
= spec
->num_kctl_alloc
+ NUM_CONTROL_ALLOC
;
1074 knew
= kcalloc(num
+ 1, sizeof(*knew
), GFP_KERNEL
); /* array + terminator */
1077 if (spec
->kctl_alloc
) {
1078 memcpy(knew
, spec
->kctl_alloc
, sizeof(*knew
) * spec
->num_kctl_alloc
);
1079 kfree(spec
->kctl_alloc
);
1081 spec
->kctl_alloc
= knew
;
1082 spec
->num_kctl_alloc
= num
;
1085 knew
= &spec
->kctl_alloc
[spec
->num_kctl_used
];
1086 *knew
= stac92xx_control_templates
[type
];
1087 knew
->name
= kstrdup(name
, GFP_KERNEL
);
1090 knew
->private_value
= val
;
1091 spec
->num_kctl_used
++;
1095 /* flag inputs as additional dynamic lineouts */
1096 static int stac92xx_add_dyn_out_pins(struct hda_codec
*codec
, struct auto_pin_cfg
*cfg
)
1098 struct sigmatel_spec
*spec
= codec
->spec
;
1099 unsigned int wcaps
, wtype
;
1100 int i
, num_dacs
= 0;
1102 /* use the wcaps cache to count all DACs available for line-outs */
1103 for (i
= 0; i
< codec
->num_nodes
; i
++) {
1104 wcaps
= codec
->wcaps
[i
];
1105 wtype
= (wcaps
& AC_WCAP_TYPE
) >> AC_WCAP_TYPE_SHIFT
;
1106 if (wtype
== AC_WID_AUD_OUT
&& !(wcaps
& AC_WCAP_DIGITAL
))
1110 snd_printdd("%s: total dac count=%d\n", __func__
, num_dacs
);
1112 switch (cfg
->line_outs
) {
1114 /* add line-in as side */
1115 if (cfg
->input_pins
[AUTO_PIN_LINE
] && num_dacs
> 3) {
1116 cfg
->line_out_pins
[3] = cfg
->input_pins
[AUTO_PIN_LINE
];
1117 spec
->line_switch
= 1;
1122 /* add line-in as clfe and mic as side */
1123 if (cfg
->input_pins
[AUTO_PIN_LINE
] && num_dacs
> 2) {
1124 cfg
->line_out_pins
[2] = cfg
->input_pins
[AUTO_PIN_LINE
];
1125 spec
->line_switch
= 1;
1128 if (cfg
->input_pins
[AUTO_PIN_MIC
] && num_dacs
> 3) {
1129 cfg
->line_out_pins
[3] = cfg
->input_pins
[AUTO_PIN_MIC
];
1130 spec
->mic_switch
= 1;
1135 /* add line-in as surr and mic as clfe */
1136 if (cfg
->input_pins
[AUTO_PIN_LINE
] && num_dacs
> 1) {
1137 cfg
->line_out_pins
[1] = cfg
->input_pins
[AUTO_PIN_LINE
];
1138 spec
->line_switch
= 1;
1141 if (cfg
->input_pins
[AUTO_PIN_MIC
] && num_dacs
> 2) {
1142 cfg
->line_out_pins
[2] = cfg
->input_pins
[AUTO_PIN_MIC
];
1143 spec
->mic_switch
= 1;
1153 static int is_in_dac_nids(struct sigmatel_spec
*spec
, hda_nid_t nid
)
1157 for (i
= 0; i
< spec
->multiout
.num_dacs
; i
++) {
1158 if (spec
->multiout
.dac_nids
[i
] == nid
)
1166 * Fill in the dac_nids table from the parsed pin configuration
1167 * This function only works when every pin in line_out_pins[]
1168 * contains atleast one DAC in its connection list. Some 92xx
1169 * codecs are not connected directly to a DAC, such as the 9200
1170 * and 9202/925x. For those, dac_nids[] must be hard-coded.
1172 static int stac92xx_auto_fill_dac_nids(struct hda_codec
*codec
,
1173 const struct auto_pin_cfg
*cfg
)
1175 struct sigmatel_spec
*spec
= codec
->spec
;
1176 int i
, j
, conn_len
= 0;
1177 hda_nid_t nid
, conn
[HDA_MAX_CONNECTIONS
];
1178 unsigned int wcaps
, wtype
;
1180 for (i
= 0; i
< cfg
->line_outs
; i
++) {
1181 nid
= cfg
->line_out_pins
[i
];
1182 conn_len
= snd_hda_get_connections(codec
, nid
, conn
,
1183 HDA_MAX_CONNECTIONS
);
1184 for (j
= 0; j
< conn_len
; j
++) {
1185 wcaps
= snd_hda_param_read(codec
, conn
[j
],
1186 AC_PAR_AUDIO_WIDGET_CAP
);
1187 wtype
= (wcaps
& AC_WCAP_TYPE
) >> AC_WCAP_TYPE_SHIFT
;
1189 if (wtype
!= AC_WID_AUD_OUT
||
1190 (wcaps
& AC_WCAP_DIGITAL
))
1192 /* conn[j] is a DAC routed to this line-out */
1193 if (!is_in_dac_nids(spec
, conn
[j
]))
1197 if (j
== conn_len
) {
1198 /* error out, no available DAC found */
1200 "%s: No available DAC for pin 0x%x\n",
1205 spec
->multiout
.dac_nids
[i
] = conn
[j
];
1206 spec
->multiout
.num_dacs
++;
1208 /* select this DAC in the pin's input mux */
1209 snd_hda_codec_write(codec
, nid
, 0,
1210 AC_VERB_SET_CONNECT_SEL
, j
);
1215 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
1216 spec
->multiout
.num_dacs
,
1217 spec
->multiout
.dac_nids
[0],
1218 spec
->multiout
.dac_nids
[1],
1219 spec
->multiout
.dac_nids
[2],
1220 spec
->multiout
.dac_nids
[3],
1221 spec
->multiout
.dac_nids
[4]);
1225 /* create volume control/switch for the given prefx type */
1226 static int create_controls(struct sigmatel_spec
*spec
, const char *pfx
, hda_nid_t nid
, int chs
)
1231 sprintf(name
, "%s Playback Volume", pfx
);
1232 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_VOL
, name
,
1233 HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
));
1236 sprintf(name
, "%s Playback Switch", pfx
);
1237 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_MUTE
, name
,
1238 HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
));
1244 /* add playback controls from the parsed DAC table */
1245 static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec
*spec
,
1246 const struct auto_pin_cfg
*cfg
)
1248 static const char *chname
[4] = {
1249 "Front", "Surround", NULL
/*CLFE*/, "Side"
1254 for (i
= 0; i
< cfg
->line_outs
; i
++) {
1255 if (!spec
->multiout
.dac_nids
[i
])
1258 nid
= spec
->multiout
.dac_nids
[i
];
1262 err
= create_controls(spec
, "Center", nid
, 1);
1265 err
= create_controls(spec
, "LFE", nid
, 2);
1269 err
= create_controls(spec
, chname
[i
], nid
, 3);
1275 if (spec
->line_switch
)
1276 if ((err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_IO_SWITCH
, "Line In as Output Switch", cfg
->input_pins
[AUTO_PIN_LINE
] << 8)) < 0)
1279 if (spec
->mic_switch
)
1280 if ((err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_IO_SWITCH
, "Mic as Output Switch", (cfg
->input_pins
[AUTO_PIN_MIC
] << 8) | 1)) < 0)
1286 static int check_in_dac_nids(struct sigmatel_spec
*spec
, hda_nid_t nid
)
1288 if (is_in_dac_nids(spec
, nid
))
1290 if (spec
->multiout
.hp_nid
== nid
)
1295 static int add_spec_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
)
1297 if (!spec
->multiout
.hp_nid
)
1298 spec
->multiout
.hp_nid
= nid
;
1299 else if (spec
->multiout
.num_dacs
> 4) {
1300 printk(KERN_WARNING
"stac92xx: No space for DAC 0x%x\n", nid
);
1303 spec
->multiout
.dac_nids
[spec
->multiout
.num_dacs
] = nid
;
1304 spec
->multiout
.num_dacs
++;
1309 /* add playback controls for Speaker and HP outputs */
1310 static int stac92xx_auto_create_hp_ctls(struct hda_codec
*codec
,
1311 struct auto_pin_cfg
*cfg
)
1313 struct sigmatel_spec
*spec
= codec
->spec
;
1315 int i
, old_num_dacs
, err
;
1317 old_num_dacs
= spec
->multiout
.num_dacs
;
1318 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
1319 unsigned int wid_caps
= get_wcaps(codec
, cfg
->hp_pins
[i
]);
1320 if (wid_caps
& AC_WCAP_UNSOL_CAP
)
1321 spec
->hp_detect
= 1;
1322 nid
= snd_hda_codec_read(codec
, cfg
->hp_pins
[i
], 0,
1323 AC_VERB_GET_CONNECT_LIST
, 0) & 0xff;
1324 if (check_in_dac_nids(spec
, nid
))
1328 add_spec_dacs(spec
, nid
);
1330 for (i
= 0; i
< cfg
->speaker_outs
; i
++) {
1331 nid
= snd_hda_codec_read(codec
, cfg
->speaker_pins
[i
], 0,
1332 AC_VERB_GET_CONNECT_LIST
, 0) & 0xff;
1333 if (check_in_dac_nids(spec
, nid
))
1337 add_spec_dacs(spec
, nid
);
1340 for (i
= old_num_dacs
; i
< spec
->multiout
.num_dacs
; i
++) {
1341 static const char *pfxs
[] = {
1342 "Speaker", "External Speaker", "Speaker2",
1344 err
= create_controls(spec
, pfxs
[i
- old_num_dacs
],
1345 spec
->multiout
.dac_nids
[i
], 3);
1349 if (spec
->multiout
.hp_nid
) {
1351 if (old_num_dacs
== spec
->multiout
.num_dacs
)
1355 err
= create_controls(spec
, pfx
, spec
->multiout
.hp_nid
, 3);
1363 /* labels for dmic mux inputs */
1364 static const char *stac92xx_dmic_labels
[5] = {
1365 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
1366 "Digital Mic 3", "Digital Mic 4"
1369 /* create playback/capture controls for input pins on dmic capable codecs */
1370 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec
*codec
,
1371 const struct auto_pin_cfg
*cfg
)
1373 struct sigmatel_spec
*spec
= codec
->spec
;
1374 struct hda_input_mux
*dimux
= &spec
->private_dimux
;
1375 hda_nid_t con_lst
[HDA_MAX_NUM_INPUTS
];
1378 dimux
->items
[dimux
->num_items
].label
= stac92xx_dmic_labels
[0];
1379 dimux
->items
[dimux
->num_items
].index
= 0;
1382 for (i
= 0; i
< spec
->num_dmics
; i
++) {
1385 unsigned int def_conf
;
1387 def_conf
= snd_hda_codec_read(codec
,
1390 AC_VERB_GET_CONFIG_DEFAULT
,
1392 if (get_defcfg_connect(def_conf
) == AC_JACK_PORT_NONE
)
1395 num_cons
= snd_hda_get_connections(codec
,
1398 HDA_MAX_NUM_INPUTS
);
1399 for (j
= 0; j
< num_cons
; j
++)
1400 if (con_lst
[j
] == spec
->dmic_nids
[i
]) {
1406 dimux
->items
[dimux
->num_items
].label
=
1407 stac92xx_dmic_labels
[dimux
->num_items
];
1408 dimux
->items
[dimux
->num_items
].index
= index
;
1415 /* create playback/capture controls for input pins */
1416 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec
*codec
, const struct auto_pin_cfg
*cfg
)
1418 struct sigmatel_spec
*spec
= codec
->spec
;
1419 struct hda_input_mux
*imux
= &spec
->private_imux
;
1420 hda_nid_t con_lst
[HDA_MAX_NUM_INPUTS
];
1423 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
1426 if (!cfg
->input_pins
[i
])
1429 for (j
= 0; j
< spec
->num_muxes
; j
++) {
1431 num_cons
= snd_hda_get_connections(codec
,
1434 HDA_MAX_NUM_INPUTS
);
1435 for (k
= 0; k
< num_cons
; k
++)
1436 if (con_lst
[k
] == cfg
->input_pins
[i
]) {
1443 imux
->items
[imux
->num_items
].label
= auto_pin_cfg_labels
[i
];
1444 imux
->items
[imux
->num_items
].index
= index
;
1448 if (imux
->num_items
) {
1450 * Set the current input for the muxes.
1451 * The STAC9221 has two input muxes with identical source
1452 * NID lists. Hopefully this won't get confused.
1454 for (i
= 0; i
< spec
->num_muxes
; i
++) {
1455 snd_hda_codec_write(codec
, spec
->mux_nids
[i
], 0,
1456 AC_VERB_SET_CONNECT_SEL
,
1457 imux
->items
[0].index
);
1464 static void stac92xx_auto_init_multi_out(struct hda_codec
*codec
)
1466 struct sigmatel_spec
*spec
= codec
->spec
;
1469 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
1470 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
1471 stac92xx_auto_set_pinctl(codec
, nid
, AC_PINCTL_OUT_EN
);
1475 static void stac92xx_auto_init_hp_out(struct hda_codec
*codec
)
1477 struct sigmatel_spec
*spec
= codec
->spec
;
1480 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
1482 pin
= spec
->autocfg
.hp_pins
[i
];
1483 if (pin
) /* connect to front */
1484 stac92xx_auto_set_pinctl(codec
, pin
, AC_PINCTL_OUT_EN
| AC_PINCTL_HP_EN
);
1486 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++) {
1488 pin
= spec
->autocfg
.speaker_pins
[i
];
1489 if (pin
) /* connect to front */
1490 stac92xx_auto_set_pinctl(codec
, pin
, AC_PINCTL_OUT_EN
);
1494 static int stac92xx_parse_auto_config(struct hda_codec
*codec
, hda_nid_t dig_out
, hda_nid_t dig_in
)
1496 struct sigmatel_spec
*spec
= codec
->spec
;
1499 if ((err
= snd_hda_parse_pin_def_config(codec
,
1501 spec
->dmic_nids
)) < 0)
1503 if (! spec
->autocfg
.line_outs
)
1504 return 0; /* can't find valid pin config */
1506 if ((err
= stac92xx_add_dyn_out_pins(codec
, &spec
->autocfg
)) < 0)
1508 if (spec
->multiout
.num_dacs
== 0)
1509 if ((err
= stac92xx_auto_fill_dac_nids(codec
, &spec
->autocfg
)) < 0)
1512 if ((err
= stac92xx_auto_create_multi_out_ctls(spec
, &spec
->autocfg
)) < 0 ||
1513 (err
= stac92xx_auto_create_hp_ctls(codec
, &spec
->autocfg
)) < 0 ||
1514 (err
= stac92xx_auto_create_analog_input_ctls(codec
, &spec
->autocfg
)) < 0)
1517 if (spec
->num_dmics
> 0)
1518 if ((err
= stac92xx_auto_create_dmic_input_ctls(codec
,
1519 &spec
->autocfg
)) < 0)
1522 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
1523 if (spec
->multiout
.max_channels
> 2)
1524 spec
->surr_switch
= 1;
1526 if (spec
->autocfg
.dig_out_pin
)
1527 spec
->multiout
.dig_out_nid
= dig_out
;
1528 if (spec
->autocfg
.dig_in_pin
)
1529 spec
->dig_in_nid
= dig_in
;
1531 if (spec
->kctl_alloc
)
1532 spec
->mixers
[spec
->num_mixers
++] = spec
->kctl_alloc
;
1534 spec
->input_mux
= &spec
->private_imux
;
1535 spec
->dinput_mux
= &spec
->private_dimux
;
1540 /* add playback controls for HP output */
1541 static int stac9200_auto_create_hp_ctls(struct hda_codec
*codec
,
1542 struct auto_pin_cfg
*cfg
)
1544 struct sigmatel_spec
*spec
= codec
->spec
;
1545 hda_nid_t pin
= cfg
->hp_pins
[0];
1546 unsigned int wid_caps
;
1551 wid_caps
= get_wcaps(codec
, pin
);
1552 if (wid_caps
& AC_WCAP_UNSOL_CAP
)
1553 spec
->hp_detect
= 1;
1558 /* add playback controls for LFE output */
1559 static int stac9200_auto_create_lfe_ctls(struct hda_codec
*codec
,
1560 struct auto_pin_cfg
*cfg
)
1562 struct sigmatel_spec
*spec
= codec
->spec
;
1564 hda_nid_t lfe_pin
= 0x0;
1568 * search speaker outs and line outs for a mono speaker pin
1569 * with an amp. If one is found, add LFE controls
1572 for (i
= 0; i
< spec
->autocfg
.speaker_outs
&& lfe_pin
== 0x0; i
++) {
1573 hda_nid_t pin
= spec
->autocfg
.speaker_pins
[i
];
1574 unsigned long wcaps
= get_wcaps(codec
, pin
);
1575 wcaps
&= (AC_WCAP_STEREO
| AC_WCAP_OUT_AMP
);
1576 if (wcaps
== AC_WCAP_OUT_AMP
)
1577 /* found a mono speaker with an amp, must be lfe */
1581 /* if speaker_outs is 0, then speakers may be in line_outs */
1582 if (lfe_pin
== 0 && spec
->autocfg
.speaker_outs
== 0) {
1583 for (i
= 0; i
< spec
->autocfg
.line_outs
&& lfe_pin
== 0x0; i
++) {
1584 hda_nid_t pin
= spec
->autocfg
.line_out_pins
[i
];
1586 cfg
= snd_hda_codec_read(codec
, pin
, 0,
1587 AC_VERB_GET_CONFIG_DEFAULT
,
1589 if (get_defcfg_device(cfg
) == AC_JACK_SPEAKER
) {
1590 unsigned long wcaps
= get_wcaps(codec
, pin
);
1591 wcaps
&= (AC_WCAP_STEREO
| AC_WCAP_OUT_AMP
);
1592 if (wcaps
== AC_WCAP_OUT_AMP
)
1593 /* found a mono speaker with an amp,
1601 err
= create_controls(spec
, "LFE", lfe_pin
, 1);
1609 static int stac9200_parse_auto_config(struct hda_codec
*codec
)
1611 struct sigmatel_spec
*spec
= codec
->spec
;
1614 if ((err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
)) < 0)
1617 if ((err
= stac92xx_auto_create_analog_input_ctls(codec
, &spec
->autocfg
)) < 0)
1620 if ((err
= stac9200_auto_create_hp_ctls(codec
, &spec
->autocfg
)) < 0)
1623 if ((err
= stac9200_auto_create_lfe_ctls(codec
, &spec
->autocfg
)) < 0)
1626 if (spec
->autocfg
.dig_out_pin
)
1627 spec
->multiout
.dig_out_nid
= 0x05;
1628 if (spec
->autocfg
.dig_in_pin
)
1629 spec
->dig_in_nid
= 0x04;
1631 if (spec
->kctl_alloc
)
1632 spec
->mixers
[spec
->num_mixers
++] = spec
->kctl_alloc
;
1634 spec
->input_mux
= &spec
->private_imux
;
1635 spec
->dinput_mux
= &spec
->private_dimux
;
1641 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
1642 * funky external mute control using GPIO pins.
1645 static void stac922x_gpio_mute(struct hda_codec
*codec
, int pin
, int muted
)
1647 unsigned int gpiostate
, gpiomask
, gpiodir
;
1649 gpiostate
= snd_hda_codec_read(codec
, codec
->afg
, 0,
1650 AC_VERB_GET_GPIO_DATA
, 0);
1653 gpiostate
|= (1 << pin
);
1655 gpiostate
&= ~(1 << pin
);
1657 gpiomask
= snd_hda_codec_read(codec
, codec
->afg
, 0,
1658 AC_VERB_GET_GPIO_MASK
, 0);
1659 gpiomask
|= (1 << pin
);
1661 gpiodir
= snd_hda_codec_read(codec
, codec
->afg
, 0,
1662 AC_VERB_GET_GPIO_DIRECTION
, 0);
1663 gpiodir
|= (1 << pin
);
1665 /* AppleHDA seems to do this -- WTF is this verb?? */
1666 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7e7, 0);
1668 snd_hda_codec_write(codec
, codec
->afg
, 0,
1669 AC_VERB_SET_GPIO_MASK
, gpiomask
);
1670 snd_hda_codec_write(codec
, codec
->afg
, 0,
1671 AC_VERB_SET_GPIO_DIRECTION
, gpiodir
);
1675 snd_hda_codec_write(codec
, codec
->afg
, 0,
1676 AC_VERB_SET_GPIO_DATA
, gpiostate
);
1679 static void enable_pin_detect(struct hda_codec
*codec
, hda_nid_t nid
,
1682 if (get_wcaps(codec
, nid
) & AC_WCAP_UNSOL_CAP
)
1683 snd_hda_codec_write(codec
, nid
, 0,
1684 AC_VERB_SET_UNSOLICITED_ENABLE
,
1685 (AC_USRSP_EN
| event
));
1688 static int stac92xx_init(struct hda_codec
*codec
)
1690 struct sigmatel_spec
*spec
= codec
->spec
;
1691 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1694 snd_hda_sequence_write(codec
, spec
->init
);
1697 if (spec
->hp_detect
) {
1698 /* Enable unsolicited responses on the HP widget */
1699 for (i
= 0; i
< cfg
->hp_outs
; i
++)
1700 enable_pin_detect(codec
, cfg
->hp_pins
[i
],
1702 /* force to enable the first line-out; the others are set up
1705 stac92xx_auto_set_pinctl(codec
, spec
->autocfg
.line_out_pins
[0],
1707 stac92xx_auto_init_hp_out(codec
);
1708 /* fake event to set up pins */
1709 codec
->patch_ops
.unsol_event(codec
, STAC_HP_EVENT
<< 26);
1711 stac92xx_auto_init_multi_out(codec
);
1712 stac92xx_auto_init_hp_out(codec
);
1714 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
1715 hda_nid_t nid
= cfg
->input_pins
[i
];
1717 unsigned int pinctl
= AC_PINCTL_IN_EN
;
1718 if (i
== AUTO_PIN_MIC
|| i
== AUTO_PIN_FRONT_MIC
)
1719 pinctl
|= stac92xx_get_vref(codec
, nid
);
1720 stac92xx_auto_set_pinctl(codec
, nid
, pinctl
);
1723 if (spec
->num_dmics
> 0)
1724 for (i
= 0; i
< spec
->num_dmics
; i
++)
1725 stac92xx_auto_set_pinctl(codec
, spec
->dmic_nids
[i
],
1728 if (cfg
->dig_out_pin
)
1729 stac92xx_auto_set_pinctl(codec
, cfg
->dig_out_pin
,
1731 if (cfg
->dig_in_pin
)
1732 stac92xx_auto_set_pinctl(codec
, cfg
->dig_in_pin
,
1735 if (spec
->gpio_mute
) {
1736 stac922x_gpio_mute(codec
, 0, 0);
1737 stac922x_gpio_mute(codec
, 1, 0);
1743 static void stac92xx_free(struct hda_codec
*codec
)
1745 struct sigmatel_spec
*spec
= codec
->spec
;
1751 if (spec
->kctl_alloc
) {
1752 for (i
= 0; i
< spec
->num_kctl_used
; i
++)
1753 kfree(spec
->kctl_alloc
[i
].name
);
1754 kfree(spec
->kctl_alloc
);
1757 if (spec
->bios_pin_configs
)
1758 kfree(spec
->bios_pin_configs
);
1763 static void stac92xx_set_pinctl(struct hda_codec
*codec
, hda_nid_t nid
,
1766 unsigned int pin_ctl
= snd_hda_codec_read(codec
, nid
,
1767 0, AC_VERB_GET_PIN_WIDGET_CONTROL
, 0x00);
1769 if (pin_ctl
& AC_PINCTL_IN_EN
) {
1771 * we need to check the current set-up direction of
1772 * shared input pins since they can be switched via
1773 * "xxx as Output" mixer switch
1775 struct sigmatel_spec
*spec
= codec
->spec
;
1776 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1777 if ((nid
== cfg
->input_pins
[AUTO_PIN_LINE
] &&
1778 spec
->line_switch
) ||
1779 (nid
== cfg
->input_pins
[AUTO_PIN_MIC
] &&
1784 /* if setting pin direction bits, clear the current
1785 direction bits first */
1786 if (flag
& (AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
))
1787 pin_ctl
&= ~(AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
);
1789 snd_hda_codec_write(codec
, nid
, 0,
1790 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1794 static void stac92xx_reset_pinctl(struct hda_codec
*codec
, hda_nid_t nid
,
1797 unsigned int pin_ctl
= snd_hda_codec_read(codec
, nid
,
1798 0, AC_VERB_GET_PIN_WIDGET_CONTROL
, 0x00);
1799 snd_hda_codec_write(codec
, nid
, 0,
1800 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1804 static int get_pin_presence(struct hda_codec
*codec
, hda_nid_t nid
)
1808 if (snd_hda_codec_read(codec
, nid
, 0, AC_VERB_GET_PIN_SENSE
, 0x00)
1814 static void stac92xx_hp_detect(struct hda_codec
*codec
, unsigned int res
)
1816 struct sigmatel_spec
*spec
= codec
->spec
;
1817 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1821 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
1822 presence
= get_pin_presence(codec
, cfg
->hp_pins
[i
]);
1828 /* disable lineouts, enable hp */
1829 for (i
= 0; i
< cfg
->line_outs
; i
++)
1830 stac92xx_reset_pinctl(codec
, cfg
->line_out_pins
[i
],
1832 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
1833 stac92xx_reset_pinctl(codec
, cfg
->speaker_pins
[i
],
1836 /* enable lineouts, disable hp */
1837 for (i
= 0; i
< cfg
->line_outs
; i
++)
1838 stac92xx_set_pinctl(codec
, cfg
->line_out_pins
[i
],
1840 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
1841 stac92xx_set_pinctl(codec
, cfg
->speaker_pins
[i
],
1846 static void stac92xx_unsol_event(struct hda_codec
*codec
, unsigned int res
)
1848 switch (res
>> 26) {
1850 stac92xx_hp_detect(codec
, res
);
1856 static int stac92xx_resume(struct hda_codec
*codec
)
1858 struct sigmatel_spec
*spec
= codec
->spec
;
1861 stac92xx_init(codec
);
1862 stac92xx_set_config_regs(codec
);
1863 snd_hda_resume_ctls(codec
, spec
->mixer
);
1864 for (i
= 0; i
< spec
->num_mixers
; i
++)
1865 snd_hda_resume_ctls(codec
, spec
->mixers
[i
]);
1866 if (spec
->multiout
.dig_out_nid
)
1867 snd_hda_resume_spdif_out(codec
);
1868 if (spec
->dig_in_nid
)
1869 snd_hda_resume_spdif_in(codec
);
1875 static struct hda_codec_ops stac92xx_patch_ops
= {
1876 .build_controls
= stac92xx_build_controls
,
1877 .build_pcms
= stac92xx_build_pcms
,
1878 .init
= stac92xx_init
,
1879 .free
= stac92xx_free
,
1880 .unsol_event
= stac92xx_unsol_event
,
1882 .resume
= stac92xx_resume
,
1886 static int patch_stac9200(struct hda_codec
*codec
)
1888 struct sigmatel_spec
*spec
;
1891 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1897 spec
->pin_nids
= stac9200_pin_nids
;
1898 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_9200_MODELS
,
1901 if (spec
->board_config
< 0) {
1902 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
1903 err
= stac92xx_save_bios_config_regs(codec
);
1905 stac92xx_free(codec
);
1908 spec
->pin_configs
= spec
->bios_pin_configs
;
1910 spec
->pin_configs
= stac9200_brd_tbl
[spec
->board_config
];
1911 stac92xx_set_config_regs(codec
);
1914 spec
->multiout
.max_channels
= 2;
1915 spec
->multiout
.num_dacs
= 1;
1916 spec
->multiout
.dac_nids
= stac9200_dac_nids
;
1917 spec
->adc_nids
= stac9200_adc_nids
;
1918 spec
->mux_nids
= stac9200_mux_nids
;
1919 spec
->num_muxes
= 1;
1920 spec
->num_dmics
= 0;
1922 spec
->init
= stac9200_core_init
;
1923 spec
->mixer
= stac9200_mixer
;
1925 err
= stac9200_parse_auto_config(codec
);
1927 stac92xx_free(codec
);
1931 codec
->patch_ops
= stac92xx_patch_ops
;
1936 static int patch_stac925x(struct hda_codec
*codec
)
1938 struct sigmatel_spec
*spec
;
1941 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1947 spec
->pin_nids
= stac925x_pin_nids
;
1948 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_925x_MODELS
,
1952 if (spec
->board_config
< 0) {
1953 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC925x,"
1954 "using BIOS defaults\n");
1955 err
= stac92xx_save_bios_config_regs(codec
);
1957 stac92xx_free(codec
);
1960 spec
->pin_configs
= spec
->bios_pin_configs
;
1961 } else if (stac925x_brd_tbl
[spec
->board_config
] != NULL
){
1962 spec
->pin_configs
= stac925x_brd_tbl
[spec
->board_config
];
1963 stac92xx_set_config_regs(codec
);
1966 spec
->multiout
.max_channels
= 2;
1967 spec
->multiout
.num_dacs
= 1;
1968 spec
->multiout
.dac_nids
= stac925x_dac_nids
;
1969 spec
->adc_nids
= stac925x_adc_nids
;
1970 spec
->mux_nids
= stac925x_mux_nids
;
1971 spec
->num_muxes
= 1;
1972 switch (codec
->vendor_id
) {
1973 case 0x83847632: /* STAC9202 */
1974 case 0x83847633: /* STAC9202D */
1975 case 0x83847636: /* STAC9251 */
1976 case 0x83847637: /* STAC9251D */
1977 spec
->num_dmics
= STAC925X_NUM_DMICS
;
1978 spec
->dmic_nids
= stac925x_dmic_nids
;
1981 spec
->num_dmics
= 0;
1985 spec
->init
= stac925x_core_init
;
1986 spec
->mixer
= stac925x_mixer
;
1988 err
= stac92xx_parse_auto_config(codec
, 0x8, 0x7);
1990 if (spec
->board_config
< 0) {
1991 printk(KERN_WARNING
"hda_codec: No auto-config is "
1992 "available, default to model=ref\n");
1993 spec
->board_config
= STAC_925x_REF
;
1999 stac92xx_free(codec
);
2003 codec
->patch_ops
= stac92xx_patch_ops
;
2008 static int patch_stac922x(struct hda_codec
*codec
)
2010 struct sigmatel_spec
*spec
;
2013 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2018 spec
->num_pins
= 10;
2019 spec
->pin_nids
= stac922x_pin_nids
;
2020 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_922X_MODELS
,
2023 if (spec
->board_config
== STAC_MACMINI
) {
2024 spec
->gpio_mute
= 1;
2025 /* Intel Macs have all same PCI SSID, so we need to check
2026 * codec SSID to distinguish the exact models
2028 printk(KERN_INFO
"hda_codec: STAC922x, Apple subsys_id=%x\n", codec
->subsystem_id
);
2029 switch (codec
->subsystem_id
) {
2030 case 0x106b0a00: /* MacBook First generatoin */
2031 spec
->board_config
= STAC_MACBOOK
;
2033 case 0x106b0200: /* MacBook Pro first generation */
2034 spec
->board_config
= STAC_MACBOOK_PRO_V1
;
2036 case 0x106b1e00: /* MacBook Pro second generation */
2037 spec
->board_config
= STAC_MACBOOK_PRO_V2
;
2039 case 0x106b0700: /* Intel-based iMac */
2040 spec
->board_config
= STAC_IMAC_INTEL
;
2046 if (spec
->board_config
< 0) {
2047 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC922x, "
2048 "using BIOS defaults\n");
2049 err
= stac92xx_save_bios_config_regs(codec
);
2051 stac92xx_free(codec
);
2054 spec
->pin_configs
= spec
->bios_pin_configs
;
2055 } else if (stac922x_brd_tbl
[spec
->board_config
] != NULL
) {
2056 spec
->pin_configs
= stac922x_brd_tbl
[spec
->board_config
];
2057 stac92xx_set_config_regs(codec
);
2060 spec
->adc_nids
= stac922x_adc_nids
;
2061 spec
->mux_nids
= stac922x_mux_nids
;
2062 spec
->num_muxes
= ARRAY_SIZE(stac922x_mux_nids
);
2063 spec
->num_dmics
= 0;
2065 spec
->init
= stac922x_core_init
;
2066 spec
->mixer
= stac922x_mixer
;
2068 spec
->multiout
.dac_nids
= spec
->dac_nids
;
2070 err
= stac92xx_parse_auto_config(codec
, 0x08, 0x09);
2072 if (spec
->board_config
< 0) {
2073 printk(KERN_WARNING
"hda_codec: No auto-config is "
2074 "available, default to model=ref\n");
2075 spec
->board_config
= STAC_D945_REF
;
2081 stac92xx_free(codec
);
2085 codec
->patch_ops
= stac92xx_patch_ops
;
2090 static int patch_stac927x(struct hda_codec
*codec
)
2092 struct sigmatel_spec
*spec
;
2095 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2100 spec
->num_pins
= 14;
2101 spec
->pin_nids
= stac927x_pin_nids
;
2102 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_927X_MODELS
,
2106 if (spec
->board_config
< 0) {
2107 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
2108 err
= stac92xx_save_bios_config_regs(codec
);
2110 stac92xx_free(codec
);
2113 spec
->pin_configs
= spec
->bios_pin_configs
;
2114 } else if (stac927x_brd_tbl
[spec
->board_config
] != NULL
) {
2115 spec
->pin_configs
= stac927x_brd_tbl
[spec
->board_config
];
2116 stac92xx_set_config_regs(codec
);
2119 switch (spec
->board_config
) {
2121 spec
->adc_nids
= stac927x_adc_nids
;
2122 spec
->mux_nids
= stac927x_mux_nids
;
2123 spec
->num_muxes
= ARRAY_SIZE(stac927x_mux_nids
);
2124 spec
->num_dmics
= 0;
2125 spec
->init
= d965_core_init
;
2126 spec
->mixer
= stac9227_mixer
;
2129 spec
->adc_nids
= stac927x_adc_nids
;
2130 spec
->mux_nids
= stac927x_mux_nids
;
2131 spec
->num_muxes
= ARRAY_SIZE(stac927x_mux_nids
);
2132 spec
->num_dmics
= 0;
2133 spec
->init
= d965_core_init
;
2134 spec
->mixer
= stac9227_mixer
;
2137 spec
->adc_nids
= stac927x_adc_nids
;
2138 spec
->mux_nids
= stac927x_mux_nids
;
2139 spec
->num_muxes
= ARRAY_SIZE(stac927x_mux_nids
);
2140 spec
->num_dmics
= 0;
2141 spec
->init
= stac927x_core_init
;
2142 spec
->mixer
= stac927x_mixer
;
2145 spec
->multiout
.dac_nids
= spec
->dac_nids
;
2147 err
= stac92xx_parse_auto_config(codec
, 0x1e, 0x20);
2149 if (spec
->board_config
< 0) {
2150 printk(KERN_WARNING
"hda_codec: No auto-config is "
2151 "available, default to model=ref\n");
2152 spec
->board_config
= STAC_D965_REF
;
2158 stac92xx_free(codec
);
2162 codec
->patch_ops
= stac92xx_patch_ops
;
2164 /* Fix Mux capture level; max to 2 */
2165 snd_hda_override_amp_caps(codec
, 0x12, HDA_OUTPUT
,
2166 (0 << AC_AMPCAP_OFFSET_SHIFT
) |
2167 (2 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
2168 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
2169 (0 << AC_AMPCAP_MUTE_SHIFT
));
2174 static int patch_stac9205(struct hda_codec
*codec
)
2176 struct sigmatel_spec
*spec
;
2179 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2184 spec
->num_pins
= 14;
2185 spec
->pin_nids
= stac9205_pin_nids
;
2186 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_9205_MODELS
,
2190 if (spec
->board_config
< 0) {
2191 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
2192 err
= stac92xx_save_bios_config_regs(codec
);
2194 stac92xx_free(codec
);
2197 spec
->pin_configs
= spec
->bios_pin_configs
;
2199 spec
->pin_configs
= stac9205_brd_tbl
[spec
->board_config
];
2200 stac92xx_set_config_regs(codec
);
2203 spec
->adc_nids
= stac9205_adc_nids
;
2204 spec
->mux_nids
= stac9205_mux_nids
;
2205 spec
->num_muxes
= ARRAY_SIZE(stac9205_mux_nids
);
2206 spec
->dmic_nids
= stac9205_dmic_nids
;
2207 spec
->num_dmics
= STAC9205_NUM_DMICS
;
2208 spec
->dmux_nid
= 0x1d;
2210 spec
->init
= stac9205_core_init
;
2211 spec
->mixer
= stac9205_mixer
;
2213 spec
->multiout
.dac_nids
= spec
->dac_nids
;
2215 /* Configure GPIO0 as EAPD output */
2216 snd_hda_codec_write(codec
, codec
->afg
, 0,
2217 AC_VERB_SET_GPIO_DIRECTION
, 0x00000001);
2218 /* Configure GPIO0 as CMOS */
2219 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7e7, 0x00000000);
2220 /* Assert GPIO0 high */
2221 snd_hda_codec_write(codec
, codec
->afg
, 0,
2222 AC_VERB_SET_GPIO_DATA
, 0x00000001);
2224 snd_hda_codec_write(codec
, codec
->afg
, 0,
2225 AC_VERB_SET_GPIO_MASK
, 0x00000001);
2227 err
= stac92xx_parse_auto_config(codec
, 0x1f, 0x20);
2229 if (spec
->board_config
< 0) {
2230 printk(KERN_WARNING
"hda_codec: No auto-config is "
2231 "available, default to model=ref\n");
2232 spec
->board_config
= STAC_9205_REF
;
2238 stac92xx_free(codec
);
2242 codec
->patch_ops
= stac92xx_patch_ops
;
2251 /* static config for Sony VAIO FE550G and Sony VAIO AR */
2252 static hda_nid_t vaio_dacs
[] = { 0x2 };
2253 #define VAIO_HP_DAC 0x5
2254 static hda_nid_t vaio_adcs
[] = { 0x8 /*,0x6*/ };
2255 static hda_nid_t vaio_mux_nids
[] = { 0x15 };
2257 static struct hda_input_mux vaio_mux
= {
2260 /* { "HP", 0x0 }, */
2267 static struct hda_verb vaio_init
[] = {
2268 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
}, /* HP <- 0x2 */
2269 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* Speaker <- 0x5 */
2270 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Mic? (<- 0x2) */
2271 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* CD */
2272 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Mic? */
2273 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x2}, /* mic-sel: 0a,0d,14,02 */
2274 {0x02, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
}, /* HP */
2275 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
}, /* Speaker */
2276 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
2277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
2278 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
}, /* Mic-in -> 0x9 */
2282 static struct hda_verb vaio_ar_init
[] = {
2283 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
}, /* HP <- 0x2 */
2284 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* Speaker <- 0x5 */
2285 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Mic? (<- 0x2) */
2286 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* CD */
2287 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
2288 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Mic? */
2289 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x2}, /* mic-sel: 0a,0d,14,02 */
2290 {0x02, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
}, /* HP */
2291 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
}, /* Speaker */
2292 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
2293 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
2294 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
2295 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
}, /* Mic-in -> 0x9 */
2299 /* bind volumes of both NID 0x02 and 0x05 */
2300 static int vaio_master_vol_put(struct snd_kcontrol
*kcontrol
,
2301 struct snd_ctl_elem_value
*ucontrol
)
2303 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2304 long *valp
= ucontrol
->value
.integer
.value
;
2307 change
= snd_hda_codec_amp_update(codec
, 0x02, 0, HDA_OUTPUT
, 0,
2308 0x7f, valp
[0] & 0x7f);
2309 change
|= snd_hda_codec_amp_update(codec
, 0x02, 1, HDA_OUTPUT
, 0,
2310 0x7f, valp
[1] & 0x7f);
2311 snd_hda_codec_amp_update(codec
, 0x05, 0, HDA_OUTPUT
, 0,
2312 0x7f, valp
[0] & 0x7f);
2313 snd_hda_codec_amp_update(codec
, 0x05, 1, HDA_OUTPUT
, 0,
2314 0x7f, valp
[1] & 0x7f);
2318 /* bind volumes of both NID 0x02 and 0x05 */
2319 static int vaio_master_sw_put(struct snd_kcontrol
*kcontrol
,
2320 struct snd_ctl_elem_value
*ucontrol
)
2322 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2323 long *valp
= ucontrol
->value
.integer
.value
;
2326 change
= snd_hda_codec_amp_update(codec
, 0x02, 0, HDA_OUTPUT
, 0,
2327 0x80, (valp
[0] ? 0 : 0x80));
2328 change
|= snd_hda_codec_amp_update(codec
, 0x02, 1, HDA_OUTPUT
, 0,
2329 0x80, (valp
[1] ? 0 : 0x80));
2330 snd_hda_codec_amp_update(codec
, 0x05, 0, HDA_OUTPUT
, 0,
2331 0x80, (valp
[0] ? 0 : 0x80));
2332 snd_hda_codec_amp_update(codec
, 0x05, 1, HDA_OUTPUT
, 0,
2333 0x80, (valp
[1] ? 0 : 0x80));
2337 static struct snd_kcontrol_new vaio_mixer
[] = {
2339 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2340 .name
= "Master Playback Volume",
2341 .info
= snd_hda_mixer_amp_volume_info
,
2342 .get
= snd_hda_mixer_amp_volume_get
,
2343 .put
= vaio_master_vol_put
,
2344 .tlv
= { .c
= snd_hda_mixer_amp_tlv
},
2345 .private_value
= HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT
),
2348 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2349 .name
= "Master Playback Switch",
2350 .info
= snd_hda_mixer_amp_switch_info
,
2351 .get
= snd_hda_mixer_amp_switch_get
,
2352 .put
= vaio_master_sw_put
,
2353 .private_value
= HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT
),
2355 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2356 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT
),
2357 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT
),
2359 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2360 .name
= "Capture Source",
2362 .info
= stac92xx_mux_enum_info
,
2363 .get
= stac92xx_mux_enum_get
,
2364 .put
= stac92xx_mux_enum_put
,
2369 static struct snd_kcontrol_new vaio_ar_mixer
[] = {
2371 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2372 .name
= "Master Playback Volume",
2373 .info
= snd_hda_mixer_amp_volume_info
,
2374 .get
= snd_hda_mixer_amp_volume_get
,
2375 .put
= vaio_master_vol_put
,
2376 .private_value
= HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT
),
2379 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2380 .name
= "Master Playback Switch",
2381 .info
= snd_hda_mixer_amp_switch_info
,
2382 .get
= snd_hda_mixer_amp_switch_get
,
2383 .put
= vaio_master_sw_put
,
2384 .private_value
= HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT
),
2386 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2387 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT
),
2388 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT
),
2389 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
2390 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
2392 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2393 .name
= "Capture Source",
2395 .info
= stac92xx_mux_enum_info
,
2396 .get
= stac92xx_mux_enum_get
,
2397 .put
= stac92xx_mux_enum_put
,
2402 static struct hda_codec_ops stac9872_patch_ops
= {
2403 .build_controls
= stac92xx_build_controls
,
2404 .build_pcms
= stac92xx_build_pcms
,
2405 .init
= stac92xx_init
,
2406 .free
= stac92xx_free
,
2408 .resume
= stac92xx_resume
,
2412 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
2414 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
2416 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
2418 /* AR Series. id=0x83847664 and subsys=104D1300 */
2423 static const char *stac9872_models
[STAC_9872_MODELS
] = {
2424 [CXD9872RD_VAIO
] = "vaio",
2425 [CXD9872AKD_VAIO
] = "vaio-ar",
2428 static struct snd_pci_quirk stac9872_cfg_tbl
[] = {
2429 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO
),
2430 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO
),
2431 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO
),
2432 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO
),
2436 static int patch_stac9872(struct hda_codec
*codec
)
2438 struct sigmatel_spec
*spec
;
2441 board_config
= snd_hda_check_board_config(codec
, STAC_9872_MODELS
,
2444 if (board_config
< 0)
2445 /* unknown config, let generic-parser do its job... */
2446 return snd_hda_parse_generic_codec(codec
);
2448 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2453 switch (board_config
) {
2454 case CXD9872RD_VAIO
:
2455 case STAC9872AK_VAIO
:
2456 case STAC9872K_VAIO
:
2457 spec
->mixer
= vaio_mixer
;
2458 spec
->init
= vaio_init
;
2459 spec
->multiout
.max_channels
= 2;
2460 spec
->multiout
.num_dacs
= ARRAY_SIZE(vaio_dacs
);
2461 spec
->multiout
.dac_nids
= vaio_dacs
;
2462 spec
->multiout
.hp_nid
= VAIO_HP_DAC
;
2463 spec
->num_adcs
= ARRAY_SIZE(vaio_adcs
);
2464 spec
->adc_nids
= vaio_adcs
;
2465 spec
->input_mux
= &vaio_mux
;
2466 spec
->mux_nids
= vaio_mux_nids
;
2469 case CXD9872AKD_VAIO
:
2470 spec
->mixer
= vaio_ar_mixer
;
2471 spec
->init
= vaio_ar_init
;
2472 spec
->multiout
.max_channels
= 2;
2473 spec
->multiout
.num_dacs
= ARRAY_SIZE(vaio_dacs
);
2474 spec
->multiout
.dac_nids
= vaio_dacs
;
2475 spec
->multiout
.hp_nid
= VAIO_HP_DAC
;
2476 spec
->num_adcs
= ARRAY_SIZE(vaio_adcs
);
2477 spec
->adc_nids
= vaio_adcs
;
2478 spec
->input_mux
= &vaio_mux
;
2479 spec
->mux_nids
= vaio_mux_nids
;
2483 codec
->patch_ops
= stac9872_patch_ops
;
2491 struct hda_codec_preset snd_hda_preset_sigmatel
[] = {
2492 { .id
= 0x83847690, .name
= "STAC9200", .patch
= patch_stac9200
},
2493 { .id
= 0x83847882, .name
= "STAC9220 A1", .patch
= patch_stac922x
},
2494 { .id
= 0x83847680, .name
= "STAC9221 A1", .patch
= patch_stac922x
},
2495 { .id
= 0x83847880, .name
= "STAC9220 A2", .patch
= patch_stac922x
},
2496 { .id
= 0x83847681, .name
= "STAC9220D/9223D A2", .patch
= patch_stac922x
},
2497 { .id
= 0x83847682, .name
= "STAC9221 A2", .patch
= patch_stac922x
},
2498 { .id
= 0x83847683, .name
= "STAC9221D A2", .patch
= patch_stac922x
},
2499 { .id
= 0x83847618, .name
= "STAC9227", .patch
= patch_stac927x
},
2500 { .id
= 0x83847619, .name
= "STAC9227", .patch
= patch_stac927x
},
2501 { .id
= 0x83847616, .name
= "STAC9228", .patch
= patch_stac927x
},
2502 { .id
= 0x83847617, .name
= "STAC9228", .patch
= patch_stac927x
},
2503 { .id
= 0x83847614, .name
= "STAC9229", .patch
= patch_stac927x
},
2504 { .id
= 0x83847615, .name
= "STAC9229", .patch
= patch_stac927x
},
2505 { .id
= 0x83847620, .name
= "STAC9274", .patch
= patch_stac927x
},
2506 { .id
= 0x83847621, .name
= "STAC9274D", .patch
= patch_stac927x
},
2507 { .id
= 0x83847622, .name
= "STAC9273X", .patch
= patch_stac927x
},
2508 { .id
= 0x83847623, .name
= "STAC9273D", .patch
= patch_stac927x
},
2509 { .id
= 0x83847624, .name
= "STAC9272X", .patch
= patch_stac927x
},
2510 { .id
= 0x83847625, .name
= "STAC9272D", .patch
= patch_stac927x
},
2511 { .id
= 0x83847626, .name
= "STAC9271X", .patch
= patch_stac927x
},
2512 { .id
= 0x83847627, .name
= "STAC9271D", .patch
= patch_stac927x
},
2513 { .id
= 0x83847628, .name
= "STAC9274X5NH", .patch
= patch_stac927x
},
2514 { .id
= 0x83847629, .name
= "STAC9274D5NH", .patch
= patch_stac927x
},
2515 { .id
= 0x83847632, .name
= "STAC9202", .patch
= patch_stac925x
},
2516 { .id
= 0x83847633, .name
= "STAC9202D", .patch
= patch_stac925x
},
2517 { .id
= 0x83847634, .name
= "STAC9250", .patch
= patch_stac925x
},
2518 { .id
= 0x83847635, .name
= "STAC9250D", .patch
= patch_stac925x
},
2519 { .id
= 0x83847636, .name
= "STAC9251", .patch
= patch_stac925x
},
2520 { .id
= 0x83847637, .name
= "STAC9250D", .patch
= patch_stac925x
},
2521 /* The following does not take into account .id=0x83847661 when subsys =
2522 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
2523 * currently not fully supported.
2525 { .id
= 0x83847661, .name
= "CXD9872RD/K", .patch
= patch_stac9872
},
2526 { .id
= 0x83847662, .name
= "STAC9872AK", .patch
= patch_stac9872
},
2527 { .id
= 0x83847664, .name
= "CXD9872AKD", .patch
= patch_stac9872
},
2528 { .id
= 0x838476a0, .name
= "STAC9205", .patch
= patch_stac9205
},
2529 { .id
= 0x838476a1, .name
= "STAC9205D", .patch
= patch_stac9205
},
2530 { .id
= 0x838476a2, .name
= "STAC9204", .patch
= patch_stac9205
},
2531 { .id
= 0x838476a3, .name
= "STAC9204D", .patch
= patch_stac9205
},
2532 { .id
= 0x838476a4, .name
= "STAC9255", .patch
= patch_stac9205
},
2533 { .id
= 0x838476a5, .name
= "STAC9255D", .patch
= patch_stac9205
},
2534 { .id
= 0x838476a6, .name
= "STAC9254", .patch
= patch_stac9205
},
2535 { .id
= 0x838476a7, .name
= "STAC9254D", .patch
= patch_stac9205
},