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
78 struct sigmatel_spec
{
79 struct snd_kcontrol_new
*mixers
[4];
80 unsigned int num_mixers
;
83 unsigned int surr_switch
: 1;
84 unsigned int line_switch
: 1;
85 unsigned int mic_switch
: 1;
86 unsigned int alt_switch
: 1;
87 unsigned int hp_detect
: 1;
88 unsigned int gpio_mute
: 1;
91 struct hda_multi_out multiout
;
92 hda_nid_t dac_nids
[5];
96 unsigned int num_adcs
;
98 unsigned int num_muxes
;
100 unsigned int num_dmics
;
102 hda_nid_t dig_in_nid
;
106 unsigned int num_pins
;
107 unsigned int *pin_configs
;
108 unsigned int *bios_pin_configs
;
110 /* codec specific stuff */
111 struct hda_verb
*init
;
112 struct snd_kcontrol_new
*mixer
;
115 struct hda_input_mux
*dinput_mux
;
116 unsigned int cur_dmux
;
117 struct hda_input_mux
*input_mux
;
118 unsigned int cur_mux
[3];
121 unsigned int io_switch
[2];
123 struct hda_pcm pcm_rec
[2]; /* PCM information */
125 /* dynamic controls and input_mux */
126 struct auto_pin_cfg autocfg
;
127 unsigned int num_kctl_alloc
, num_kctl_used
;
128 struct snd_kcontrol_new
*kctl_alloc
;
129 struct hda_input_mux private_dimux
;
130 struct hda_input_mux private_imux
;
133 static hda_nid_t stac9200_adc_nids
[1] = {
137 static hda_nid_t stac9200_mux_nids
[1] = {
141 static hda_nid_t stac9200_dac_nids
[1] = {
145 static hda_nid_t stac925x_adc_nids
[1] = {
149 static hda_nid_t stac925x_mux_nids
[1] = {
153 static hda_nid_t stac925x_dac_nids
[1] = {
157 static hda_nid_t stac925x_dmic_nids
[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 static hda_nid_t stac9205_dmic_nids
[2] = {
189 static hda_nid_t stac9200_pin_nids
[8] = {
190 0x08, 0x09, 0x0d, 0x0e,
191 0x0f, 0x10, 0x11, 0x12,
194 static hda_nid_t stac925x_pin_nids
[8] = {
195 0x07, 0x08, 0x0a, 0x0b,
196 0x0c, 0x0d, 0x10, 0x11,
199 static hda_nid_t stac922x_pin_nids
[10] = {
200 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
201 0x0f, 0x10, 0x11, 0x15, 0x1b,
204 static hda_nid_t stac927x_pin_nids
[14] = {
205 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
206 0x0f, 0x10, 0x11, 0x12, 0x13,
207 0x14, 0x21, 0x22, 0x23,
210 static hda_nid_t stac9205_pin_nids
[12] = {
211 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
212 0x0f, 0x14, 0x16, 0x17, 0x18,
217 static int stac92xx_dmux_enum_info(struct snd_kcontrol
*kcontrol
,
218 struct snd_ctl_elem_info
*uinfo
)
220 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
221 struct sigmatel_spec
*spec
= codec
->spec
;
222 return snd_hda_input_mux_info(spec
->dinput_mux
, uinfo
);
225 static int stac92xx_dmux_enum_get(struct snd_kcontrol
*kcontrol
,
226 struct snd_ctl_elem_value
*ucontrol
)
228 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
229 struct sigmatel_spec
*spec
= codec
->spec
;
231 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_dmux
;
235 static int stac92xx_dmux_enum_put(struct snd_kcontrol
*kcontrol
,
236 struct snd_ctl_elem_value
*ucontrol
)
238 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
239 struct sigmatel_spec
*spec
= codec
->spec
;
241 return snd_hda_input_mux_put(codec
, spec
->dinput_mux
, ucontrol
,
242 spec
->dmux_nid
, &spec
->cur_dmux
);
245 static int stac92xx_mux_enum_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
247 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
248 struct sigmatel_spec
*spec
= codec
->spec
;
249 return snd_hda_input_mux_info(spec
->input_mux
, uinfo
);
252 static int stac92xx_mux_enum_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
254 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
255 struct sigmatel_spec
*spec
= codec
->spec
;
256 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
258 ucontrol
->value
.enumerated
.item
[0] = spec
->cur_mux
[adc_idx
];
262 static int stac92xx_mux_enum_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
264 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
265 struct sigmatel_spec
*spec
= codec
->spec
;
266 unsigned int adc_idx
= snd_ctl_get_ioffidx(kcontrol
, &ucontrol
->id
);
268 return snd_hda_input_mux_put(codec
, spec
->input_mux
, ucontrol
,
269 spec
->mux_nids
[adc_idx
], &spec
->cur_mux
[adc_idx
]);
272 static struct hda_verb stac9200_core_init
[] = {
273 /* set dac0mux for dac converter */
274 { 0x07, AC_VERB_SET_CONNECT_SEL
, 0x00},
278 static struct hda_verb stac925x_core_init
[] = {
279 /* set dac0mux for dac converter */
280 { 0x06, AC_VERB_SET_CONNECT_SEL
, 0x00},
284 static struct hda_verb stac922x_core_init
[] = {
285 /* set master volume and direct control */
286 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
290 static struct hda_verb d965_core_init
[] = {
291 /* set master volume and direct control */
292 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
293 /* unmute node 0x1b */
294 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE
, 0xb000},
295 /* select node 0x03 as DAC */
296 { 0x0b, AC_VERB_SET_CONNECT_SEL
, 0x01},
300 static struct hda_verb stac927x_core_init
[] = {
301 /* set master volume and direct control */
302 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
306 static struct hda_verb stac9205_core_init
[] = {
307 /* set master volume and direct control */
308 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL
, 0xff},
312 static struct snd_kcontrol_new stac9200_mixer
[] = {
313 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT
),
314 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT
),
316 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
317 .name
= "Input Source",
319 .info
= stac92xx_mux_enum_info
,
320 .get
= stac92xx_mux_enum_get
,
321 .put
= stac92xx_mux_enum_put
,
323 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT
),
324 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT
),
325 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT
),
329 static struct snd_kcontrol_new stac925x_mixer
[] = {
330 HDA_CODEC_VOLUME("Master Playback Volume", 0xe, 0, HDA_OUTPUT
),
331 HDA_CODEC_MUTE("Master Playback Switch", 0xe, 0, HDA_OUTPUT
),
333 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
334 .name
= "Input Source",
336 .info
= stac92xx_mux_enum_info
,
337 .get
= stac92xx_mux_enum_get
,
338 .put
= stac92xx_mux_enum_put
,
340 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT
),
341 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT
),
342 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT
),
346 /* This needs to be generated dynamically based on sequence */
347 static struct snd_kcontrol_new stac922x_mixer
[] = {
349 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
350 .name
= "Input Source",
352 .info
= stac92xx_mux_enum_info
,
353 .get
= stac92xx_mux_enum_get
,
354 .put
= stac92xx_mux_enum_put
,
356 HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT
),
357 HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT
),
358 HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT
),
362 /* This needs to be generated dynamically based on sequence */
363 static struct snd_kcontrol_new stac9227_mixer
[] = {
365 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
366 .name
= "Input Source",
368 .info
= stac92xx_mux_enum_info
,
369 .get
= stac92xx_mux_enum_get
,
370 .put
= stac92xx_mux_enum_put
,
372 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
373 HDA_CODEC_MUTE("Capture Switch", 0x1b, 0x0, HDA_OUTPUT
),
377 static struct snd_kcontrol_new stac927x_mixer
[] = {
379 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
380 .name
= "Input Source",
382 .info
= stac92xx_mux_enum_info
,
383 .get
= stac92xx_mux_enum_get
,
384 .put
= stac92xx_mux_enum_put
,
386 HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT
),
387 HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT
),
388 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT
),
392 static struct snd_kcontrol_new stac9205_mixer
[] = {
394 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
395 .name
= "Digital Input Source",
397 .info
= stac92xx_dmux_enum_info
,
398 .get
= stac92xx_dmux_enum_get
,
399 .put
= stac92xx_dmux_enum_put
,
402 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
403 .name
= "Input Source",
405 .info
= stac92xx_mux_enum_info
,
406 .get
= stac92xx_mux_enum_get
,
407 .put
= stac92xx_mux_enum_put
,
409 HDA_CODEC_VOLUME("InMux Capture Volume", 0x19, 0x0, HDA_OUTPUT
),
410 HDA_CODEC_VOLUME("InVol Capture Volume", 0x1b, 0x0, HDA_INPUT
),
411 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1d, 0x0, HDA_OUTPUT
),
415 static int stac92xx_build_controls(struct hda_codec
*codec
)
417 struct sigmatel_spec
*spec
= codec
->spec
;
421 err
= snd_hda_add_new_ctls(codec
, spec
->mixer
);
425 for (i
= 0; i
< spec
->num_mixers
; i
++) {
426 err
= snd_hda_add_new_ctls(codec
, spec
->mixers
[i
]);
431 if (spec
->multiout
.dig_out_nid
) {
432 err
= snd_hda_create_spdif_out_ctls(codec
, spec
->multiout
.dig_out_nid
);
436 if (spec
->dig_in_nid
) {
437 err
= snd_hda_create_spdif_in_ctls(codec
, spec
->dig_in_nid
);
444 static unsigned int ref9200_pin_configs
[8] = {
445 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
446 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
449 static unsigned int *stac9200_brd_tbl
[STAC_9200_MODELS
] = {
450 [STAC_REF
] = ref9200_pin_configs
,
453 static const char *stac9200_models
[STAC_9200_MODELS
] = {
457 static struct snd_pci_quirk stac9200_cfg_tbl
[] = {
458 /* SigmaTel reference board */
459 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
460 "DFI LanParty", STAC_REF
),
461 /* Dell laptops have BIOS problem */
462 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01b5,
463 "Dell Inspiron 630m", STAC_REF
),
464 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01c2,
465 "Dell Latitude D620", STAC_REF
),
466 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cb,
467 "Dell Latitude 120L", STAC_REF
),
468 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cc,
469 "Dell Latitude D820", STAC_REF
),
470 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cd,
471 "Dell Inspiron E1705/9400", STAC_REF
),
472 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01ce,
473 "Dell XPS M1710", STAC_REF
),
474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01cf,
475 "Dell Precision M90", STAC_REF
),
476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d6,
477 "unknown Dell", STAC_REF
),
478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01d8,
479 "Dell Inspiron 640m", STAC_REF
),
480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL
, 0x01f5,
481 "Dell Inspiron 1501", STAC_REF
),
484 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF
),
489 static unsigned int ref925x_pin_configs
[8] = {
490 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
491 0x90a70320, 0x02214210, 0x400003f1, 0x9033032e,
494 static unsigned int stac925x_MA6_pin_configs
[8] = {
495 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
496 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
499 static unsigned int stac925x_PA6_pin_configs
[8] = {
500 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
501 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
504 static unsigned int stac925xM2_2_pin_configs
[8] = {
505 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
506 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
509 static unsigned int *stac925x_brd_tbl
[STAC_925x_MODELS
] = {
510 [STAC_REF
] = ref925x_pin_configs
,
511 [STAC_M2_2
] = stac925xM2_2_pin_configs
,
512 [STAC_MA6
] = stac925x_MA6_pin_configs
,
513 [STAC_PA6
] = stac925x_PA6_pin_configs
,
516 static const char *stac925x_models
[STAC_925x_MODELS
] = {
518 [STAC_M2_2
] = "m2-2",
523 static struct snd_pci_quirk stac925x_cfg_tbl
[] = {
524 /* SigmaTel reference board */
525 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668, "DFI LanParty", STAC_REF
),
526 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF
),
527 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF
),
528 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF
),
529 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6
),
530 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6
),
531 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2
),
535 static unsigned int ref922x_pin_configs
[10] = {
536 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
537 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
538 0x40000100, 0x40000100,
541 static unsigned int d945gtp3_pin_configs
[10] = {
542 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
543 0x40000100, 0x40000100, 0x40000100, 0x40000100,
544 0x02a19120, 0x40000100,
547 static unsigned int d945gtp5_pin_configs
[10] = {
548 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
549 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
550 0x02a19320, 0x40000100,
553 static unsigned int macbook_pro_v1_pin_configs
[10] = {
554 0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010,
555 0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e,
556 0x02a19320, 0x400000fb
559 static unsigned int macbook_pro_v2_pin_configs
[10] = {
560 0x0221401f, 0x90a70120, 0x01813024, 0x01014010,
561 0x400000fd, 0x01016011, 0x1345e240, 0x13c5e22e,
562 0x400000fc, 0x400000fb,
565 static unsigned int imac_intel_pin_configs
[10] = {
566 0x0121e230, 0x90a70120, 0x9017e110, 0x400000fe,
567 0x400000fd, 0x0181e021, 0x1145e040, 0x400000fa,
568 0x400000fc, 0x400000fb,
571 static unsigned int imac_intel_20_pin_configs
[10] = {
572 0x0121E21F, 0x90A7012E, 0x9017E110, 0x400000FD,
573 0x400000FE, 0x0181E020, 0x1145E230, 0x11C5E240,
574 0x400000FC, 0x400000FB,
577 static unsigned int *stac922x_brd_tbl
[STAC_922X_MODELS
] = {
578 [STAC_D945_REF
] = ref922x_pin_configs
,
579 [STAC_D945GTP3
] = d945gtp3_pin_configs
,
580 [STAC_D945GTP5
] = d945gtp5_pin_configs
,
581 [STAC_MACMINI
] = macbook_pro_v1_pin_configs
,
582 [STAC_MACBOOK
] = macbook_pro_v1_pin_configs
,
583 [STAC_MACBOOK_PRO_V1
] = macbook_pro_v1_pin_configs
,
584 [STAC_MACBOOK_PRO_V2
] = macbook_pro_v2_pin_configs
,
585 [STAC_IMAC_INTEL
] = imac_intel_pin_configs
,
586 [STAC_IMAC_INTEL_20
] = imac_intel_20_pin_configs
,
589 static const char *stac922x_models
[STAC_922X_MODELS
] = {
590 [STAC_D945_REF
] = "ref",
591 [STAC_D945GTP5
] = "5stack",
592 [STAC_D945GTP3
] = "3stack",
593 [STAC_MACMINI
] = "macmini",
594 [STAC_MACBOOK
] = "macbook",
595 [STAC_MACBOOK_PRO_V1
] = "macbook-pro-v1",
596 [STAC_MACBOOK_PRO_V2
] = "macbook-pro",
597 [STAC_IMAC_INTEL
] = "imac-intel",
598 [STAC_IMAC_INTEL_20
] = "imac-intel-20",
601 static struct snd_pci_quirk stac922x_cfg_tbl
[] = {
602 /* SigmaTel reference board */
603 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
604 "DFI LanParty", STAC_D945_REF
),
605 /* Intel 945G based systems */
606 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0101,
607 "Intel D945G", STAC_D945GTP3
),
608 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0202,
609 "Intel D945G", STAC_D945GTP3
),
610 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0606,
611 "Intel D945G", STAC_D945GTP3
),
612 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0601,
613 "Intel D945G", STAC_D945GTP3
),
614 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0111,
615 "Intel D945G", STAC_D945GTP3
),
616 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1115,
617 "Intel D945G", STAC_D945GTP3
),
618 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1116,
619 "Intel D945G", STAC_D945GTP3
),
620 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1117,
621 "Intel D945G", STAC_D945GTP3
),
622 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1118,
623 "Intel D945G", STAC_D945GTP3
),
624 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x1119,
625 "Intel D945G", STAC_D945GTP3
),
626 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x8826,
627 "Intel D945G", STAC_D945GTP3
),
628 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5049,
629 "Intel D945G", STAC_D945GTP3
),
630 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5055,
631 "Intel D945G", STAC_D945GTP3
),
632 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x5048,
633 "Intel D945G", STAC_D945GTP3
),
634 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0110,
635 "Intel D945G", STAC_D945GTP3
),
636 /* Intel D945G 5-stack systems */
637 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0404,
638 "Intel D945G", STAC_D945GTP5
),
639 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0303,
640 "Intel D945G", STAC_D945GTP5
),
641 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0013,
642 "Intel D945G", STAC_D945GTP5
),
643 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0417,
644 "Intel D945G", STAC_D945GTP5
),
645 /* Intel 945P based systems */
646 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0b0b,
647 "Intel D945P", STAC_D945GTP3
),
648 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0112,
649 "Intel D945P", STAC_D945GTP3
),
650 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0d0d,
651 "Intel D945P", STAC_D945GTP3
),
652 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0909,
653 "Intel D945P", STAC_D945GTP3
),
654 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0505,
655 "Intel D945P", STAC_D945GTP3
),
656 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x0707,
657 "Intel D945P", STAC_D945GTP5
),
659 /* Apple Mac Mini (early 2006) */
660 SND_PCI_QUIRK(0x8384, 0x7680,
661 "Mac Mini", STAC_MACMINI
),
665 static unsigned int ref927x_pin_configs
[14] = {
666 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
667 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
668 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
669 0x01c42190, 0x40000100,
672 static unsigned int d965_3st_pin_configs
[14] = {
673 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
674 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
675 0x40000100, 0x40000100, 0x40000100, 0x40000100,
676 0x40000100, 0x40000100
679 static unsigned int d965_5st_pin_configs
[14] = {
680 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
681 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
682 0x40000100, 0x40000100, 0x40000100, 0x01442070,
683 0x40000100, 0x40000100
686 static unsigned int *stac927x_brd_tbl
[STAC_927X_MODELS
] = {
687 [STAC_D965_REF
] = ref927x_pin_configs
,
688 [STAC_D965_3ST
] = d965_3st_pin_configs
,
689 [STAC_D965_5ST
] = d965_5st_pin_configs
,
692 static const char *stac927x_models
[STAC_927X_MODELS
] = {
693 [STAC_D965_REF
] = "ref",
694 [STAC_D965_3ST
] = "3stack",
695 [STAC_D965_5ST
] = "5stack",
698 static struct snd_pci_quirk stac927x_cfg_tbl
[] = {
699 /* SigmaTel reference board */
700 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
701 "DFI LanParty", STAC_D965_REF
),
702 /* Intel 946 based systems */
703 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x3d01, "Intel D946", STAC_D965_3ST
),
704 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0xa301, "Intel D946", STAC_D965_3ST
),
705 /* 965 based 3 stack systems */
706 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2116, "Intel D965", STAC_D965_3ST
),
707 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2115, "Intel D965", STAC_D965_3ST
),
708 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2114, "Intel D965", STAC_D965_3ST
),
709 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2113, "Intel D965", STAC_D965_3ST
),
710 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2112, "Intel D965", STAC_D965_3ST
),
711 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2111, "Intel D965", STAC_D965_3ST
),
712 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2110, "Intel D965", STAC_D965_3ST
),
713 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2009, "Intel D965", STAC_D965_3ST
),
714 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2008, "Intel D965", STAC_D965_3ST
),
715 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2007, "Intel D965", STAC_D965_3ST
),
716 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2006, "Intel D965", STAC_D965_3ST
),
717 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2005, "Intel D965", STAC_D965_3ST
),
718 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2004, "Intel D965", STAC_D965_3ST
),
719 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2003, "Intel D965", STAC_D965_3ST
),
720 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2002, "Intel D965", STAC_D965_3ST
),
721 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2001, "Intel D965", STAC_D965_3ST
),
722 /* 965 based 5 stack systems */
723 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2301, "Intel D965", STAC_D965_5ST
),
724 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2302, "Intel D965", STAC_D965_5ST
),
725 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2303, "Intel D965", STAC_D965_5ST
),
726 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2304, "Intel D965", STAC_D965_5ST
),
727 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2305, "Intel D965", STAC_D965_5ST
),
728 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2501, "Intel D965", STAC_D965_5ST
),
729 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2502, "Intel D965", STAC_D965_5ST
),
730 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2503, "Intel D965", STAC_D965_5ST
),
731 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2504, "Intel D965", STAC_D965_5ST
),
735 static unsigned int ref9205_pin_configs
[12] = {
736 0x40000100, 0x40000100, 0x01016011, 0x01014010,
737 0x01813122, 0x01a19021, 0x40000100, 0x40000100,
738 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
741 static unsigned int *stac9205_brd_tbl
[STAC_9205_MODELS
] = {
745 static const char *stac9205_models
[STAC_9205_MODELS
] = {
746 [STAC_9205_REF
] = "ref",
749 static struct snd_pci_quirk stac9205_cfg_tbl
[] = {
750 /* SigmaTel reference board */
751 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL
, 0x2668,
752 "DFI LanParty", STAC_9205_REF
),
756 static int stac92xx_save_bios_config_regs(struct hda_codec
*codec
)
759 struct sigmatel_spec
*spec
= codec
->spec
;
761 if (! spec
->bios_pin_configs
) {
762 spec
->bios_pin_configs
= kcalloc(spec
->num_pins
,
763 sizeof(*spec
->bios_pin_configs
), GFP_KERNEL
);
764 if (! spec
->bios_pin_configs
)
768 for (i
= 0; i
< spec
->num_pins
; i
++) {
769 hda_nid_t nid
= spec
->pin_nids
[i
];
770 unsigned int pin_cfg
;
772 pin_cfg
= snd_hda_codec_read(codec
, nid
, 0,
773 AC_VERB_GET_CONFIG_DEFAULT
, 0x00);
774 snd_printdd(KERN_INFO
"hda_codec: pin nid %2.2x bios pin config %8.8x\n",
776 spec
->bios_pin_configs
[i
] = pin_cfg
;
782 static void stac92xx_set_config_regs(struct hda_codec
*codec
)
785 struct sigmatel_spec
*spec
= codec
->spec
;
786 unsigned int pin_cfg
;
788 if (! spec
->pin_nids
|| ! spec
->pin_configs
)
791 for (i
= 0; i
< spec
->num_pins
; i
++) {
792 snd_hda_codec_write(codec
, spec
->pin_nids
[i
], 0,
793 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0
,
794 spec
->pin_configs
[i
] & 0x000000ff);
795 snd_hda_codec_write(codec
, spec
->pin_nids
[i
], 0,
796 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1
,
797 (spec
->pin_configs
[i
] & 0x0000ff00) >> 8);
798 snd_hda_codec_write(codec
, spec
->pin_nids
[i
], 0,
799 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2
,
800 (spec
->pin_configs
[i
] & 0x00ff0000) >> 16);
801 snd_hda_codec_write(codec
, spec
->pin_nids
[i
], 0,
802 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3
,
803 spec
->pin_configs
[i
] >> 24);
804 pin_cfg
= snd_hda_codec_read(codec
, spec
->pin_nids
[i
], 0,
805 AC_VERB_GET_CONFIG_DEFAULT
,
807 snd_printdd(KERN_INFO
"hda_codec: pin nid %2.2x pin config %8.8x\n", spec
->pin_nids
[i
], pin_cfg
);
812 * Analog playback callbacks
814 static int stac92xx_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
815 struct hda_codec
*codec
,
816 struct snd_pcm_substream
*substream
)
818 struct sigmatel_spec
*spec
= codec
->spec
;
819 return snd_hda_multi_out_analog_open(codec
, &spec
->multiout
, substream
);
822 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
823 struct hda_codec
*codec
,
824 unsigned int stream_tag
,
826 struct snd_pcm_substream
*substream
)
828 struct sigmatel_spec
*spec
= codec
->spec
;
829 return snd_hda_multi_out_analog_prepare(codec
, &spec
->multiout
, stream_tag
, format
, substream
);
832 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
833 struct hda_codec
*codec
,
834 struct snd_pcm_substream
*substream
)
836 struct sigmatel_spec
*spec
= codec
->spec
;
837 return snd_hda_multi_out_analog_cleanup(codec
, &spec
->multiout
);
841 * Digital playback callbacks
843 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream
*hinfo
,
844 struct hda_codec
*codec
,
845 struct snd_pcm_substream
*substream
)
847 struct sigmatel_spec
*spec
= codec
->spec
;
848 return snd_hda_multi_out_dig_open(codec
, &spec
->multiout
);
851 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream
*hinfo
,
852 struct hda_codec
*codec
,
853 struct snd_pcm_substream
*substream
)
855 struct sigmatel_spec
*spec
= codec
->spec
;
856 return snd_hda_multi_out_dig_close(codec
, &spec
->multiout
);
859 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream
*hinfo
,
860 struct hda_codec
*codec
,
861 unsigned int stream_tag
,
863 struct snd_pcm_substream
*substream
)
865 struct sigmatel_spec
*spec
= codec
->spec
;
866 return snd_hda_multi_out_dig_prepare(codec
, &spec
->multiout
,
867 stream_tag
, format
, substream
);
872 * Analog capture callbacks
874 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream
*hinfo
,
875 struct hda_codec
*codec
,
876 unsigned int stream_tag
,
878 struct snd_pcm_substream
*substream
)
880 struct sigmatel_spec
*spec
= codec
->spec
;
882 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
],
883 stream_tag
, 0, format
);
887 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream
*hinfo
,
888 struct hda_codec
*codec
,
889 struct snd_pcm_substream
*substream
)
891 struct sigmatel_spec
*spec
= codec
->spec
;
893 snd_hda_codec_setup_stream(codec
, spec
->adc_nids
[substream
->number
], 0, 0, 0);
897 static struct hda_pcm_stream stac92xx_pcm_digital_playback
= {
901 /* NID is set in stac92xx_build_pcms */
903 .open
= stac92xx_dig_playback_pcm_open
,
904 .close
= stac92xx_dig_playback_pcm_close
,
905 .prepare
= stac92xx_dig_playback_pcm_prepare
909 static struct hda_pcm_stream stac92xx_pcm_digital_capture
= {
913 /* NID is set in stac92xx_build_pcms */
916 static struct hda_pcm_stream stac92xx_pcm_analog_playback
= {
920 .nid
= 0x02, /* NID to query formats and rates */
922 .open
= stac92xx_playback_pcm_open
,
923 .prepare
= stac92xx_playback_pcm_prepare
,
924 .cleanup
= stac92xx_playback_pcm_cleanup
928 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback
= {
932 .nid
= 0x06, /* NID to query formats and rates */
934 .open
= stac92xx_playback_pcm_open
,
935 .prepare
= stac92xx_playback_pcm_prepare
,
936 .cleanup
= stac92xx_playback_pcm_cleanup
940 static struct hda_pcm_stream stac92xx_pcm_analog_capture
= {
944 /* NID is set in stac92xx_build_pcms */
946 .prepare
= stac92xx_capture_pcm_prepare
,
947 .cleanup
= stac92xx_capture_pcm_cleanup
951 static int stac92xx_build_pcms(struct hda_codec
*codec
)
953 struct sigmatel_spec
*spec
= codec
->spec
;
954 struct hda_pcm
*info
= spec
->pcm_rec
;
957 codec
->pcm_info
= info
;
959 info
->name
= "STAC92xx Analog";
960 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_analog_playback
;
961 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = stac92xx_pcm_analog_capture
;
962 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->adc_nids
[0];
964 if (spec
->alt_switch
) {
967 info
->name
= "STAC92xx Analog Alt";
968 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_analog_alt_playback
;
971 if (spec
->multiout
.dig_out_nid
|| spec
->dig_in_nid
) {
974 info
->name
= "STAC92xx Digital";
975 if (spec
->multiout
.dig_out_nid
) {
976 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
] = stac92xx_pcm_digital_playback
;
977 info
->stream
[SNDRV_PCM_STREAM_PLAYBACK
].nid
= spec
->multiout
.dig_out_nid
;
979 if (spec
->dig_in_nid
) {
980 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
] = stac92xx_pcm_digital_capture
;
981 info
->stream
[SNDRV_PCM_STREAM_CAPTURE
].nid
= spec
->dig_in_nid
;
988 static unsigned int stac92xx_get_vref(struct hda_codec
*codec
, hda_nid_t nid
)
990 unsigned int pincap
= snd_hda_param_read(codec
, nid
,
992 pincap
= (pincap
& AC_PINCAP_VREF
) >> AC_PINCAP_VREF_SHIFT
;
993 if (pincap
& AC_PINCAP_VREF_100
)
994 return AC_PINCTL_VREF_100
;
995 if (pincap
& AC_PINCAP_VREF_80
)
996 return AC_PINCTL_VREF_80
;
997 if (pincap
& AC_PINCAP_VREF_50
)
998 return AC_PINCTL_VREF_50
;
999 if (pincap
& AC_PINCAP_VREF_GRD
)
1000 return AC_PINCTL_VREF_GRD
;
1004 static void stac92xx_auto_set_pinctl(struct hda_codec
*codec
, hda_nid_t nid
, int pin_type
)
1007 snd_hda_codec_write(codec
, nid
, 0, AC_VERB_SET_PIN_WIDGET_CONTROL
, pin_type
);
1010 static int stac92xx_io_switch_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
1012 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
1014 uinfo
->value
.integer
.min
= 0;
1015 uinfo
->value
.integer
.max
= 1;
1019 static int stac92xx_io_switch_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1021 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1022 struct sigmatel_spec
*spec
= codec
->spec
;
1023 int io_idx
= kcontrol
-> private_value
& 0xff;
1025 ucontrol
->value
.integer
.value
[0] = spec
->io_switch
[io_idx
];
1029 static int stac92xx_io_switch_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1031 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
1032 struct sigmatel_spec
*spec
= codec
->spec
;
1033 hda_nid_t nid
= kcontrol
->private_value
>> 8;
1034 int io_idx
= kcontrol
-> private_value
& 0xff;
1035 unsigned short val
= ucontrol
->value
.integer
.value
[0];
1037 spec
->io_switch
[io_idx
] = val
;
1040 stac92xx_auto_set_pinctl(codec
, nid
, AC_PINCTL_OUT_EN
);
1042 unsigned int pinctl
= AC_PINCTL_IN_EN
;
1043 if (io_idx
) /* set VREF for mic */
1044 pinctl
|= stac92xx_get_vref(codec
, nid
);
1045 stac92xx_auto_set_pinctl(codec
, nid
, pinctl
);
1050 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
1051 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1054 .info = stac92xx_io_switch_info, \
1055 .get = stac92xx_io_switch_get, \
1056 .put = stac92xx_io_switch_put, \
1057 .private_value = xpval, \
1062 STAC_CTL_WIDGET_VOL
,
1063 STAC_CTL_WIDGET_MUTE
,
1064 STAC_CTL_WIDGET_IO_SWITCH
,
1067 static struct snd_kcontrol_new stac92xx_control_templates
[] = {
1068 HDA_CODEC_VOLUME(NULL
, 0, 0, 0),
1069 HDA_CODEC_MUTE(NULL
, 0, 0, 0),
1070 STAC_CODEC_IO_SWITCH(NULL
, 0),
1073 /* add dynamic controls */
1074 static int stac92xx_add_control(struct sigmatel_spec
*spec
, int type
, const char *name
, unsigned long val
)
1076 struct snd_kcontrol_new
*knew
;
1078 if (spec
->num_kctl_used
>= spec
->num_kctl_alloc
) {
1079 int num
= spec
->num_kctl_alloc
+ NUM_CONTROL_ALLOC
;
1081 knew
= kcalloc(num
+ 1, sizeof(*knew
), GFP_KERNEL
); /* array + terminator */
1084 if (spec
->kctl_alloc
) {
1085 memcpy(knew
, spec
->kctl_alloc
, sizeof(*knew
) * spec
->num_kctl_alloc
);
1086 kfree(spec
->kctl_alloc
);
1088 spec
->kctl_alloc
= knew
;
1089 spec
->num_kctl_alloc
= num
;
1092 knew
= &spec
->kctl_alloc
[spec
->num_kctl_used
];
1093 *knew
= stac92xx_control_templates
[type
];
1094 knew
->name
= kstrdup(name
, GFP_KERNEL
);
1097 knew
->private_value
= val
;
1098 spec
->num_kctl_used
++;
1102 /* flag inputs as additional dynamic lineouts */
1103 static int stac92xx_add_dyn_out_pins(struct hda_codec
*codec
, struct auto_pin_cfg
*cfg
)
1105 struct sigmatel_spec
*spec
= codec
->spec
;
1106 unsigned int wcaps
, wtype
;
1107 int i
, num_dacs
= 0;
1109 /* use the wcaps cache to count all DACs available for line-outs */
1110 for (i
= 0; i
< codec
->num_nodes
; i
++) {
1111 wcaps
= codec
->wcaps
[i
];
1112 wtype
= (wcaps
& AC_WCAP_TYPE
) >> AC_WCAP_TYPE_SHIFT
;
1113 if (wtype
== AC_WID_AUD_OUT
&& !(wcaps
& AC_WCAP_DIGITAL
))
1117 snd_printdd("%s: total dac count=%d\n", __func__
, num_dacs
);
1119 switch (cfg
->line_outs
) {
1121 /* add line-in as side */
1122 if (cfg
->input_pins
[AUTO_PIN_LINE
] && num_dacs
> 3) {
1123 cfg
->line_out_pins
[3] = cfg
->input_pins
[AUTO_PIN_LINE
];
1124 spec
->line_switch
= 1;
1129 /* add line-in as clfe and mic as side */
1130 if (cfg
->input_pins
[AUTO_PIN_LINE
] && num_dacs
> 2) {
1131 cfg
->line_out_pins
[2] = cfg
->input_pins
[AUTO_PIN_LINE
];
1132 spec
->line_switch
= 1;
1135 if (cfg
->input_pins
[AUTO_PIN_MIC
] && num_dacs
> 3) {
1136 cfg
->line_out_pins
[3] = cfg
->input_pins
[AUTO_PIN_MIC
];
1137 spec
->mic_switch
= 1;
1142 /* add line-in as surr and mic as clfe */
1143 if (cfg
->input_pins
[AUTO_PIN_LINE
] && num_dacs
> 1) {
1144 cfg
->line_out_pins
[1] = cfg
->input_pins
[AUTO_PIN_LINE
];
1145 spec
->line_switch
= 1;
1148 if (cfg
->input_pins
[AUTO_PIN_MIC
] && num_dacs
> 2) {
1149 cfg
->line_out_pins
[2] = cfg
->input_pins
[AUTO_PIN_MIC
];
1150 spec
->mic_switch
= 1;
1160 static int is_in_dac_nids(struct sigmatel_spec
*spec
, hda_nid_t nid
)
1164 for (i
= 0; i
< spec
->multiout
.num_dacs
; i
++) {
1165 if (spec
->multiout
.dac_nids
[i
] == nid
)
1173 * Fill in the dac_nids table from the parsed pin configuration
1174 * This function only works when every pin in line_out_pins[]
1175 * contains atleast one DAC in its connection list. Some 92xx
1176 * codecs are not connected directly to a DAC, such as the 9200
1177 * and 9202/925x. For those, dac_nids[] must be hard-coded.
1179 static int stac92xx_auto_fill_dac_nids(struct hda_codec
*codec
,
1180 const struct auto_pin_cfg
*cfg
)
1182 struct sigmatel_spec
*spec
= codec
->spec
;
1183 int i
, j
, conn_len
= 0;
1184 hda_nid_t nid
, conn
[HDA_MAX_CONNECTIONS
];
1185 unsigned int wcaps
, wtype
;
1187 for (i
= 0; i
< cfg
->line_outs
; i
++) {
1188 nid
= cfg
->line_out_pins
[i
];
1189 conn_len
= snd_hda_get_connections(codec
, nid
, conn
,
1190 HDA_MAX_CONNECTIONS
);
1191 for (j
= 0; j
< conn_len
; j
++) {
1192 wcaps
= snd_hda_param_read(codec
, conn
[j
],
1193 AC_PAR_AUDIO_WIDGET_CAP
);
1194 wtype
= (wcaps
& AC_WCAP_TYPE
) >> AC_WCAP_TYPE_SHIFT
;
1196 if (wtype
!= AC_WID_AUD_OUT
||
1197 (wcaps
& AC_WCAP_DIGITAL
))
1199 /* conn[j] is a DAC routed to this line-out */
1200 if (!is_in_dac_nids(spec
, conn
[j
]))
1204 if (j
== conn_len
) {
1205 /* error out, no available DAC found */
1207 "%s: No available DAC for pin 0x%x\n",
1212 spec
->multiout
.dac_nids
[i
] = conn
[j
];
1213 spec
->multiout
.num_dacs
++;
1215 /* select this DAC in the pin's input mux */
1216 snd_hda_codec_write(codec
, nid
, 0,
1217 AC_VERB_SET_CONNECT_SEL
, j
);
1222 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
1223 spec
->multiout
.num_dacs
,
1224 spec
->multiout
.dac_nids
[0],
1225 spec
->multiout
.dac_nids
[1],
1226 spec
->multiout
.dac_nids
[2],
1227 spec
->multiout
.dac_nids
[3],
1228 spec
->multiout
.dac_nids
[4]);
1232 /* create volume control/switch for the given prefx type */
1233 static int create_controls(struct sigmatel_spec
*spec
, const char *pfx
, hda_nid_t nid
, int chs
)
1238 sprintf(name
, "%s Playback Volume", pfx
);
1239 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_VOL
, name
,
1240 HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
));
1243 sprintf(name
, "%s Playback Switch", pfx
);
1244 err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_MUTE
, name
,
1245 HDA_COMPOSE_AMP_VAL(nid
, chs
, 0, HDA_OUTPUT
));
1251 /* add playback controls from the parsed DAC table */
1252 static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec
*spec
,
1253 const struct auto_pin_cfg
*cfg
)
1255 static const char *chname
[4] = {
1256 "Front", "Surround", NULL
/*CLFE*/, "Side"
1261 for (i
= 0; i
< cfg
->line_outs
; i
++) {
1262 if (!spec
->multiout
.dac_nids
[i
])
1265 nid
= spec
->multiout
.dac_nids
[i
];
1269 err
= create_controls(spec
, "Center", nid
, 1);
1272 err
= create_controls(spec
, "LFE", nid
, 2);
1276 err
= create_controls(spec
, chname
[i
], nid
, 3);
1282 if (spec
->line_switch
)
1283 if ((err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_IO_SWITCH
, "Line In as Output Switch", cfg
->input_pins
[AUTO_PIN_LINE
] << 8)) < 0)
1286 if (spec
->mic_switch
)
1287 if ((err
= stac92xx_add_control(spec
, STAC_CTL_WIDGET_IO_SWITCH
, "Mic as Output Switch", (cfg
->input_pins
[AUTO_PIN_MIC
] << 8) | 1)) < 0)
1293 static int check_in_dac_nids(struct sigmatel_spec
*spec
, hda_nid_t nid
)
1295 if (is_in_dac_nids(spec
, nid
))
1297 if (spec
->multiout
.hp_nid
== nid
)
1302 static int add_spec_dacs(struct sigmatel_spec
*spec
, hda_nid_t nid
)
1304 if (!spec
->multiout
.hp_nid
)
1305 spec
->multiout
.hp_nid
= nid
;
1306 else if (spec
->multiout
.num_dacs
> 4) {
1307 printk(KERN_WARNING
"stac92xx: No space for DAC 0x%x\n", nid
);
1310 spec
->multiout
.dac_nids
[spec
->multiout
.num_dacs
] = nid
;
1311 spec
->multiout
.num_dacs
++;
1316 /* add playback controls for Speaker and HP outputs */
1317 static int stac92xx_auto_create_hp_ctls(struct hda_codec
*codec
,
1318 struct auto_pin_cfg
*cfg
)
1320 struct sigmatel_spec
*spec
= codec
->spec
;
1322 int i
, old_num_dacs
, err
;
1324 old_num_dacs
= spec
->multiout
.num_dacs
;
1325 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
1326 unsigned int wid_caps
= get_wcaps(codec
, cfg
->hp_pins
[i
]);
1327 if (wid_caps
& AC_WCAP_UNSOL_CAP
)
1328 spec
->hp_detect
= 1;
1329 nid
= snd_hda_codec_read(codec
, cfg
->hp_pins
[i
], 0,
1330 AC_VERB_GET_CONNECT_LIST
, 0) & 0xff;
1331 if (check_in_dac_nids(spec
, nid
))
1335 add_spec_dacs(spec
, nid
);
1337 for (i
= 0; i
< cfg
->speaker_outs
; i
++) {
1338 nid
= snd_hda_codec_read(codec
, cfg
->speaker_pins
[i
], 0,
1339 AC_VERB_GET_CONNECT_LIST
, 0) & 0xff;
1340 if (check_in_dac_nids(spec
, nid
))
1344 add_spec_dacs(spec
, nid
);
1347 for (i
= old_num_dacs
; i
< spec
->multiout
.num_dacs
; i
++) {
1348 static const char *pfxs
[] = {
1349 "Speaker", "External Speaker", "Speaker2",
1351 err
= create_controls(spec
, pfxs
[i
- old_num_dacs
],
1352 spec
->multiout
.dac_nids
[i
], 3);
1356 if (spec
->multiout
.hp_nid
) {
1358 if (old_num_dacs
== spec
->multiout
.num_dacs
)
1362 err
= create_controls(spec
, pfx
, spec
->multiout
.hp_nid
, 3);
1370 /* labels for dmic mux inputs */
1371 static const char *stac92xx_dmic_labels
[5] = {
1372 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
1373 "Digital Mic 3", "Digital Mic 4"
1376 /* create playback/capture controls for input pins on dmic capable codecs */
1377 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec
*codec
,
1378 const struct auto_pin_cfg
*cfg
)
1380 struct sigmatel_spec
*spec
= codec
->spec
;
1381 struct hda_input_mux
*dimux
= &spec
->private_dimux
;
1382 hda_nid_t con_lst
[HDA_MAX_NUM_INPUTS
];
1385 dimux
->items
[dimux
->num_items
].label
= stac92xx_dmic_labels
[0];
1386 dimux
->items
[dimux
->num_items
].index
= 0;
1389 for (i
= 0; i
< spec
->num_dmics
; i
++) {
1392 unsigned int def_conf
;
1394 def_conf
= snd_hda_codec_read(codec
,
1397 AC_VERB_GET_CONFIG_DEFAULT
,
1399 if (get_defcfg_connect(def_conf
) == AC_JACK_PORT_NONE
)
1402 num_cons
= snd_hda_get_connections(codec
,
1405 HDA_MAX_NUM_INPUTS
);
1406 for (j
= 0; j
< num_cons
; j
++)
1407 if (con_lst
[j
] == spec
->dmic_nids
[i
]) {
1413 dimux
->items
[dimux
->num_items
].label
=
1414 stac92xx_dmic_labels
[dimux
->num_items
];
1415 dimux
->items
[dimux
->num_items
].index
= index
;
1422 /* create playback/capture controls for input pins */
1423 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec
*codec
, const struct auto_pin_cfg
*cfg
)
1425 struct sigmatel_spec
*spec
= codec
->spec
;
1426 struct hda_input_mux
*imux
= &spec
->private_imux
;
1427 hda_nid_t con_lst
[HDA_MAX_NUM_INPUTS
];
1430 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
1433 if (!cfg
->input_pins
[i
])
1436 for (j
= 0; j
< spec
->num_muxes
; j
++) {
1438 num_cons
= snd_hda_get_connections(codec
,
1441 HDA_MAX_NUM_INPUTS
);
1442 for (k
= 0; k
< num_cons
; k
++)
1443 if (con_lst
[k
] == cfg
->input_pins
[i
]) {
1450 imux
->items
[imux
->num_items
].label
= auto_pin_cfg_labels
[i
];
1451 imux
->items
[imux
->num_items
].index
= index
;
1455 if (imux
->num_items
) {
1457 * Set the current input for the muxes.
1458 * The STAC9221 has two input muxes with identical source
1459 * NID lists. Hopefully this won't get confused.
1461 for (i
= 0; i
< spec
->num_muxes
; i
++) {
1462 snd_hda_codec_write(codec
, spec
->mux_nids
[i
], 0,
1463 AC_VERB_SET_CONNECT_SEL
,
1464 imux
->items
[0].index
);
1471 static void stac92xx_auto_init_multi_out(struct hda_codec
*codec
)
1473 struct sigmatel_spec
*spec
= codec
->spec
;
1476 for (i
= 0; i
< spec
->autocfg
.line_outs
; i
++) {
1477 hda_nid_t nid
= spec
->autocfg
.line_out_pins
[i
];
1478 stac92xx_auto_set_pinctl(codec
, nid
, AC_PINCTL_OUT_EN
);
1482 static void stac92xx_auto_init_hp_out(struct hda_codec
*codec
)
1484 struct sigmatel_spec
*spec
= codec
->spec
;
1487 for (i
= 0; i
< spec
->autocfg
.hp_outs
; i
++) {
1489 pin
= spec
->autocfg
.hp_pins
[i
];
1490 if (pin
) /* connect to front */
1491 stac92xx_auto_set_pinctl(codec
, pin
, AC_PINCTL_OUT_EN
| AC_PINCTL_HP_EN
);
1493 for (i
= 0; i
< spec
->autocfg
.speaker_outs
; i
++) {
1495 pin
= spec
->autocfg
.speaker_pins
[i
];
1496 if (pin
) /* connect to front */
1497 stac92xx_auto_set_pinctl(codec
, pin
, AC_PINCTL_OUT_EN
);
1501 static int stac92xx_parse_auto_config(struct hda_codec
*codec
, hda_nid_t dig_out
, hda_nid_t dig_in
)
1503 struct sigmatel_spec
*spec
= codec
->spec
;
1506 if ((err
= snd_hda_parse_pin_def_config(codec
,
1508 spec
->dmic_nids
)) < 0)
1510 if (! spec
->autocfg
.line_outs
)
1511 return 0; /* can't find valid pin config */
1513 if ((err
= stac92xx_add_dyn_out_pins(codec
, &spec
->autocfg
)) < 0)
1515 if (spec
->multiout
.num_dacs
== 0)
1516 if ((err
= stac92xx_auto_fill_dac_nids(codec
, &spec
->autocfg
)) < 0)
1519 if ((err
= stac92xx_auto_create_multi_out_ctls(spec
, &spec
->autocfg
)) < 0 ||
1520 (err
= stac92xx_auto_create_hp_ctls(codec
, &spec
->autocfg
)) < 0 ||
1521 (err
= stac92xx_auto_create_analog_input_ctls(codec
, &spec
->autocfg
)) < 0)
1524 if (spec
->num_dmics
> 0)
1525 if ((err
= stac92xx_auto_create_dmic_input_ctls(codec
,
1526 &spec
->autocfg
)) < 0)
1529 spec
->multiout
.max_channels
= spec
->multiout
.num_dacs
* 2;
1530 if (spec
->multiout
.max_channels
> 2)
1531 spec
->surr_switch
= 1;
1533 if (spec
->autocfg
.dig_out_pin
)
1534 spec
->multiout
.dig_out_nid
= dig_out
;
1535 if (spec
->autocfg
.dig_in_pin
)
1536 spec
->dig_in_nid
= dig_in
;
1538 if (spec
->kctl_alloc
)
1539 spec
->mixers
[spec
->num_mixers
++] = spec
->kctl_alloc
;
1541 spec
->input_mux
= &spec
->private_imux
;
1542 spec
->dinput_mux
= &spec
->private_dimux
;
1547 /* add playback controls for HP output */
1548 static int stac9200_auto_create_hp_ctls(struct hda_codec
*codec
,
1549 struct auto_pin_cfg
*cfg
)
1551 struct sigmatel_spec
*spec
= codec
->spec
;
1552 hda_nid_t pin
= cfg
->hp_pins
[0];
1553 unsigned int wid_caps
;
1558 wid_caps
= get_wcaps(codec
, pin
);
1559 if (wid_caps
& AC_WCAP_UNSOL_CAP
)
1560 spec
->hp_detect
= 1;
1565 /* add playback controls for LFE output */
1566 static int stac9200_auto_create_lfe_ctls(struct hda_codec
*codec
,
1567 struct auto_pin_cfg
*cfg
)
1569 struct sigmatel_spec
*spec
= codec
->spec
;
1571 hda_nid_t lfe_pin
= 0x0;
1575 * search speaker outs and line outs for a mono speaker pin
1576 * with an amp. If one is found, add LFE controls
1579 for (i
= 0; i
< spec
->autocfg
.speaker_outs
&& lfe_pin
== 0x0; i
++) {
1580 hda_nid_t pin
= spec
->autocfg
.speaker_pins
[i
];
1581 unsigned long wcaps
= get_wcaps(codec
, pin
);
1582 wcaps
&= (AC_WCAP_STEREO
| AC_WCAP_OUT_AMP
);
1583 if (wcaps
== AC_WCAP_OUT_AMP
)
1584 /* found a mono speaker with an amp, must be lfe */
1588 /* if speaker_outs is 0, then speakers may be in line_outs */
1589 if (lfe_pin
== 0 && spec
->autocfg
.speaker_outs
== 0) {
1590 for (i
= 0; i
< spec
->autocfg
.line_outs
&& lfe_pin
== 0x0; i
++) {
1591 hda_nid_t pin
= spec
->autocfg
.line_out_pins
[i
];
1593 cfg
= snd_hda_codec_read(codec
, pin
, 0,
1594 AC_VERB_GET_CONFIG_DEFAULT
,
1596 if (get_defcfg_device(cfg
) == AC_JACK_SPEAKER
) {
1597 unsigned long wcaps
= get_wcaps(codec
, pin
);
1598 wcaps
&= (AC_WCAP_STEREO
| AC_WCAP_OUT_AMP
);
1599 if (wcaps
== AC_WCAP_OUT_AMP
)
1600 /* found a mono speaker with an amp,
1608 err
= create_controls(spec
, "LFE", lfe_pin
, 1);
1616 static int stac9200_parse_auto_config(struct hda_codec
*codec
)
1618 struct sigmatel_spec
*spec
= codec
->spec
;
1621 if ((err
= snd_hda_parse_pin_def_config(codec
, &spec
->autocfg
, NULL
)) < 0)
1624 if ((err
= stac92xx_auto_create_analog_input_ctls(codec
, &spec
->autocfg
)) < 0)
1627 if ((err
= stac9200_auto_create_hp_ctls(codec
, &spec
->autocfg
)) < 0)
1630 if ((err
= stac9200_auto_create_lfe_ctls(codec
, &spec
->autocfg
)) < 0)
1633 if (spec
->autocfg
.dig_out_pin
)
1634 spec
->multiout
.dig_out_nid
= 0x05;
1635 if (spec
->autocfg
.dig_in_pin
)
1636 spec
->dig_in_nid
= 0x04;
1638 if (spec
->kctl_alloc
)
1639 spec
->mixers
[spec
->num_mixers
++] = spec
->kctl_alloc
;
1641 spec
->input_mux
= &spec
->private_imux
;
1642 spec
->dinput_mux
= &spec
->private_dimux
;
1648 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
1649 * funky external mute control using GPIO pins.
1652 static void stac922x_gpio_mute(struct hda_codec
*codec
, int pin
, int muted
)
1654 unsigned int gpiostate
, gpiomask
, gpiodir
;
1656 gpiostate
= snd_hda_codec_read(codec
, codec
->afg
, 0,
1657 AC_VERB_GET_GPIO_DATA
, 0);
1660 gpiostate
|= (1 << pin
);
1662 gpiostate
&= ~(1 << pin
);
1664 gpiomask
= snd_hda_codec_read(codec
, codec
->afg
, 0,
1665 AC_VERB_GET_GPIO_MASK
, 0);
1666 gpiomask
|= (1 << pin
);
1668 gpiodir
= snd_hda_codec_read(codec
, codec
->afg
, 0,
1669 AC_VERB_GET_GPIO_DIRECTION
, 0);
1670 gpiodir
|= (1 << pin
);
1672 /* AppleHDA seems to do this -- WTF is this verb?? */
1673 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7e7, 0);
1675 snd_hda_codec_write(codec
, codec
->afg
, 0,
1676 AC_VERB_SET_GPIO_MASK
, gpiomask
);
1677 snd_hda_codec_write(codec
, codec
->afg
, 0,
1678 AC_VERB_SET_GPIO_DIRECTION
, gpiodir
);
1682 snd_hda_codec_write(codec
, codec
->afg
, 0,
1683 AC_VERB_SET_GPIO_DATA
, gpiostate
);
1686 static void enable_pin_detect(struct hda_codec
*codec
, hda_nid_t nid
,
1689 if (get_wcaps(codec
, nid
) & AC_WCAP_UNSOL_CAP
)
1690 snd_hda_codec_write(codec
, nid
, 0,
1691 AC_VERB_SET_UNSOLICITED_ENABLE
,
1692 (AC_USRSP_EN
| event
));
1695 static int stac92xx_init(struct hda_codec
*codec
)
1697 struct sigmatel_spec
*spec
= codec
->spec
;
1698 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1701 snd_hda_sequence_write(codec
, spec
->init
);
1704 if (spec
->hp_detect
) {
1705 /* Enable unsolicited responses on the HP widget */
1706 for (i
= 0; i
< cfg
->hp_outs
; i
++)
1707 enable_pin_detect(codec
, cfg
->hp_pins
[i
],
1709 /* force to enable the first line-out; the others are set up
1712 stac92xx_auto_set_pinctl(codec
, spec
->autocfg
.line_out_pins
[0],
1714 stac92xx_auto_init_hp_out(codec
);
1715 /* fake event to set up pins */
1716 codec
->patch_ops
.unsol_event(codec
, STAC_HP_EVENT
<< 26);
1718 stac92xx_auto_init_multi_out(codec
);
1719 stac92xx_auto_init_hp_out(codec
);
1721 for (i
= 0; i
< AUTO_PIN_LAST
; i
++) {
1722 hda_nid_t nid
= cfg
->input_pins
[i
];
1724 unsigned int pinctl
= AC_PINCTL_IN_EN
;
1725 if (i
== AUTO_PIN_MIC
|| i
== AUTO_PIN_FRONT_MIC
)
1726 pinctl
|= stac92xx_get_vref(codec
, nid
);
1727 stac92xx_auto_set_pinctl(codec
, nid
, pinctl
);
1730 if (spec
->num_dmics
> 0)
1731 for (i
= 0; i
< spec
->num_dmics
; i
++)
1732 stac92xx_auto_set_pinctl(codec
, spec
->dmic_nids
[i
],
1735 if (cfg
->dig_out_pin
)
1736 stac92xx_auto_set_pinctl(codec
, cfg
->dig_out_pin
,
1738 if (cfg
->dig_in_pin
)
1739 stac92xx_auto_set_pinctl(codec
, cfg
->dig_in_pin
,
1742 if (spec
->gpio_mute
) {
1743 stac922x_gpio_mute(codec
, 0, 0);
1744 stac922x_gpio_mute(codec
, 1, 0);
1750 static void stac92xx_free(struct hda_codec
*codec
)
1752 struct sigmatel_spec
*spec
= codec
->spec
;
1758 if (spec
->kctl_alloc
) {
1759 for (i
= 0; i
< spec
->num_kctl_used
; i
++)
1760 kfree(spec
->kctl_alloc
[i
].name
);
1761 kfree(spec
->kctl_alloc
);
1764 if (spec
->bios_pin_configs
)
1765 kfree(spec
->bios_pin_configs
);
1770 static void stac92xx_set_pinctl(struct hda_codec
*codec
, hda_nid_t nid
,
1773 unsigned int pin_ctl
= snd_hda_codec_read(codec
, nid
,
1774 0, AC_VERB_GET_PIN_WIDGET_CONTROL
, 0x00);
1776 if (pin_ctl
& AC_PINCTL_IN_EN
) {
1778 * we need to check the current set-up direction of
1779 * shared input pins since they can be switched via
1780 * "xxx as Output" mixer switch
1782 struct sigmatel_spec
*spec
= codec
->spec
;
1783 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1784 if ((nid
== cfg
->input_pins
[AUTO_PIN_LINE
] &&
1785 spec
->line_switch
) ||
1786 (nid
== cfg
->input_pins
[AUTO_PIN_MIC
] &&
1791 /* if setting pin direction bits, clear the current
1792 direction bits first */
1793 if (flag
& (AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
))
1794 pin_ctl
&= ~(AC_PINCTL_IN_EN
| AC_PINCTL_OUT_EN
);
1796 snd_hda_codec_write(codec
, nid
, 0,
1797 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1801 static void stac92xx_reset_pinctl(struct hda_codec
*codec
, hda_nid_t nid
,
1804 unsigned int pin_ctl
= snd_hda_codec_read(codec
, nid
,
1805 0, AC_VERB_GET_PIN_WIDGET_CONTROL
, 0x00);
1806 snd_hda_codec_write(codec
, nid
, 0,
1807 AC_VERB_SET_PIN_WIDGET_CONTROL
,
1811 static int get_pin_presence(struct hda_codec
*codec
, hda_nid_t nid
)
1815 if (snd_hda_codec_read(codec
, nid
, 0, AC_VERB_GET_PIN_SENSE
, 0x00)
1821 static void stac92xx_hp_detect(struct hda_codec
*codec
, unsigned int res
)
1823 struct sigmatel_spec
*spec
= codec
->spec
;
1824 struct auto_pin_cfg
*cfg
= &spec
->autocfg
;
1828 for (i
= 0; i
< cfg
->hp_outs
; i
++) {
1829 presence
= get_pin_presence(codec
, cfg
->hp_pins
[i
]);
1835 /* disable lineouts, enable hp */
1836 for (i
= 0; i
< cfg
->line_outs
; i
++)
1837 stac92xx_reset_pinctl(codec
, cfg
->line_out_pins
[i
],
1839 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
1840 stac92xx_reset_pinctl(codec
, cfg
->speaker_pins
[i
],
1843 /* enable lineouts, disable hp */
1844 for (i
= 0; i
< cfg
->line_outs
; i
++)
1845 stac92xx_set_pinctl(codec
, cfg
->line_out_pins
[i
],
1847 for (i
= 0; i
< cfg
->speaker_outs
; i
++)
1848 stac92xx_set_pinctl(codec
, cfg
->speaker_pins
[i
],
1853 static void stac92xx_unsol_event(struct hda_codec
*codec
, unsigned int res
)
1855 switch (res
>> 26) {
1857 stac92xx_hp_detect(codec
, res
);
1863 static int stac92xx_resume(struct hda_codec
*codec
)
1865 struct sigmatel_spec
*spec
= codec
->spec
;
1868 stac92xx_init(codec
);
1869 stac92xx_set_config_regs(codec
);
1870 snd_hda_resume_ctls(codec
, spec
->mixer
);
1871 for (i
= 0; i
< spec
->num_mixers
; i
++)
1872 snd_hda_resume_ctls(codec
, spec
->mixers
[i
]);
1873 if (spec
->multiout
.dig_out_nid
)
1874 snd_hda_resume_spdif_out(codec
);
1875 if (spec
->dig_in_nid
)
1876 snd_hda_resume_spdif_in(codec
);
1882 static struct hda_codec_ops stac92xx_patch_ops
= {
1883 .build_controls
= stac92xx_build_controls
,
1884 .build_pcms
= stac92xx_build_pcms
,
1885 .init
= stac92xx_init
,
1886 .free
= stac92xx_free
,
1887 .unsol_event
= stac92xx_unsol_event
,
1889 .resume
= stac92xx_resume
,
1893 static int patch_stac9200(struct hda_codec
*codec
)
1895 struct sigmatel_spec
*spec
;
1898 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1904 spec
->pin_nids
= stac9200_pin_nids
;
1905 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_9200_MODELS
,
1908 if (spec
->board_config
< 0) {
1909 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
1910 err
= stac92xx_save_bios_config_regs(codec
);
1912 stac92xx_free(codec
);
1915 spec
->pin_configs
= spec
->bios_pin_configs
;
1917 spec
->pin_configs
= stac9200_brd_tbl
[spec
->board_config
];
1918 stac92xx_set_config_regs(codec
);
1921 spec
->multiout
.max_channels
= 2;
1922 spec
->multiout
.num_dacs
= 1;
1923 spec
->multiout
.dac_nids
= stac9200_dac_nids
;
1924 spec
->adc_nids
= stac9200_adc_nids
;
1925 spec
->mux_nids
= stac9200_mux_nids
;
1926 spec
->num_muxes
= 1;
1927 spec
->num_dmics
= 0;
1929 spec
->init
= stac9200_core_init
;
1930 spec
->mixer
= stac9200_mixer
;
1932 err
= stac9200_parse_auto_config(codec
);
1934 stac92xx_free(codec
);
1938 codec
->patch_ops
= stac92xx_patch_ops
;
1943 static int patch_stac925x(struct hda_codec
*codec
)
1945 struct sigmatel_spec
*spec
;
1948 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
1954 spec
->pin_nids
= stac925x_pin_nids
;
1955 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_925x_MODELS
,
1959 if (spec
->board_config
< 0) {
1960 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC925x,"
1961 "using BIOS defaults\n");
1962 err
= stac92xx_save_bios_config_regs(codec
);
1964 stac92xx_free(codec
);
1967 spec
->pin_configs
= spec
->bios_pin_configs
;
1968 } else if (stac925x_brd_tbl
[spec
->board_config
] != NULL
){
1969 spec
->pin_configs
= stac925x_brd_tbl
[spec
->board_config
];
1970 stac92xx_set_config_regs(codec
);
1973 spec
->multiout
.max_channels
= 2;
1974 spec
->multiout
.num_dacs
= 1;
1975 spec
->multiout
.dac_nids
= stac925x_dac_nids
;
1976 spec
->adc_nids
= stac925x_adc_nids
;
1977 spec
->mux_nids
= stac925x_mux_nids
;
1978 spec
->num_muxes
= 1;
1979 switch (codec
->vendor_id
) {
1980 case 0x83847632: /* STAC9202 */
1981 case 0x83847633: /* STAC9202D */
1982 case 0x83847636: /* STAC9251 */
1983 case 0x83847637: /* STAC9251D */
1984 spec
->num_dmics
= 1;
1985 spec
->dmic_nids
= stac925x_dmic_nids
;
1988 spec
->num_dmics
= 0;
1992 spec
->init
= stac925x_core_init
;
1993 spec
->mixer
= stac925x_mixer
;
1995 err
= stac92xx_parse_auto_config(codec
, 0x8, 0x7);
1997 if (spec
->board_config
< 0) {
1998 printk(KERN_WARNING
"hda_codec: No auto-config is "
1999 "available, default to model=ref\n");
2000 spec
->board_config
= STAC_925x_REF
;
2006 stac92xx_free(codec
);
2010 codec
->patch_ops
= stac92xx_patch_ops
;
2015 static int patch_stac922x(struct hda_codec
*codec
)
2017 struct sigmatel_spec
*spec
;
2020 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2025 spec
->num_pins
= 10;
2026 spec
->pin_nids
= stac922x_pin_nids
;
2027 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_922X_MODELS
,
2030 if (spec
->board_config
== STAC_MACMINI
) {
2031 spec
->gpio_mute
= 1;
2032 /* Intel Macs have all same PCI SSID, so we need to check
2033 * codec SSID to distinguish the exact models
2035 printk(KERN_INFO
"hda_codec: STAC922x, Apple subsys_id=%x\n", codec
->subsystem_id
);
2036 switch (codec
->subsystem_id
) {
2037 case 0x106b0a00: /* MacBook First generatoin */
2038 spec
->board_config
= STAC_MACBOOK
;
2040 case 0x106b0200: /* MacBook Pro first generation */
2041 spec
->board_config
= STAC_MACBOOK_PRO_V1
;
2043 case 0x106b1e00: /* MacBook Pro second generation */
2044 spec
->board_config
= STAC_MACBOOK_PRO_V2
;
2046 case 0x106b0700: /* Intel-based iMac */
2047 spec
->board_config
= STAC_IMAC_INTEL
;
2049 case 0x106b1700: /* Intel iMac 20 */
2050 spec
->board_config
= STAC_IMAC_INTEL_20
;
2056 if (spec
->board_config
< 0) {
2057 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC922x, "
2058 "using BIOS defaults\n");
2059 err
= stac92xx_save_bios_config_regs(codec
);
2061 stac92xx_free(codec
);
2064 spec
->pin_configs
= spec
->bios_pin_configs
;
2065 } else if (stac922x_brd_tbl
[spec
->board_config
] != NULL
) {
2066 spec
->pin_configs
= stac922x_brd_tbl
[spec
->board_config
];
2067 stac92xx_set_config_regs(codec
);
2070 spec
->adc_nids
= stac922x_adc_nids
;
2071 spec
->mux_nids
= stac922x_mux_nids
;
2072 spec
->num_muxes
= ARRAY_SIZE(stac922x_mux_nids
);
2073 spec
->num_dmics
= 0;
2075 spec
->init
= stac922x_core_init
;
2076 spec
->mixer
= stac922x_mixer
;
2078 spec
->multiout
.dac_nids
= spec
->dac_nids
;
2080 err
= stac92xx_parse_auto_config(codec
, 0x08, 0x09);
2082 if (spec
->board_config
< 0) {
2083 printk(KERN_WARNING
"hda_codec: No auto-config is "
2084 "available, default to model=ref\n");
2085 spec
->board_config
= STAC_D945_REF
;
2091 stac92xx_free(codec
);
2095 codec
->patch_ops
= stac92xx_patch_ops
;
2100 static int patch_stac927x(struct hda_codec
*codec
)
2102 struct sigmatel_spec
*spec
;
2105 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2110 spec
->num_pins
= 14;
2111 spec
->pin_nids
= stac927x_pin_nids
;
2112 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_927X_MODELS
,
2116 if (spec
->board_config
< 0) {
2117 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
2118 err
= stac92xx_save_bios_config_regs(codec
);
2120 stac92xx_free(codec
);
2123 spec
->pin_configs
= spec
->bios_pin_configs
;
2124 } else if (stac927x_brd_tbl
[spec
->board_config
] != NULL
) {
2125 spec
->pin_configs
= stac927x_brd_tbl
[spec
->board_config
];
2126 stac92xx_set_config_regs(codec
);
2129 switch (spec
->board_config
) {
2131 spec
->adc_nids
= stac927x_adc_nids
;
2132 spec
->mux_nids
= stac927x_mux_nids
;
2133 spec
->num_muxes
= ARRAY_SIZE(stac927x_mux_nids
);
2134 spec
->num_dmics
= 0;
2135 spec
->init
= d965_core_init
;
2136 spec
->mixer
= stac9227_mixer
;
2139 spec
->adc_nids
= stac927x_adc_nids
;
2140 spec
->mux_nids
= stac927x_mux_nids
;
2141 spec
->num_muxes
= ARRAY_SIZE(stac927x_mux_nids
);
2142 spec
->num_dmics
= 0;
2143 spec
->init
= d965_core_init
;
2144 spec
->mixer
= stac9227_mixer
;
2147 spec
->adc_nids
= stac927x_adc_nids
;
2148 spec
->mux_nids
= stac927x_mux_nids
;
2149 spec
->num_muxes
= ARRAY_SIZE(stac927x_mux_nids
);
2150 spec
->num_dmics
= 0;
2151 spec
->init
= stac927x_core_init
;
2152 spec
->mixer
= stac927x_mixer
;
2155 spec
->multiout
.dac_nids
= spec
->dac_nids
;
2157 err
= stac92xx_parse_auto_config(codec
, 0x1e, 0x20);
2159 if (spec
->board_config
< 0) {
2160 printk(KERN_WARNING
"hda_codec: No auto-config is "
2161 "available, default to model=ref\n");
2162 spec
->board_config
= STAC_D965_REF
;
2168 stac92xx_free(codec
);
2172 codec
->patch_ops
= stac92xx_patch_ops
;
2174 /* Fix Mux capture level; max to 2 */
2175 snd_hda_override_amp_caps(codec
, 0x12, HDA_OUTPUT
,
2176 (0 << AC_AMPCAP_OFFSET_SHIFT
) |
2177 (2 << AC_AMPCAP_NUM_STEPS_SHIFT
) |
2178 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT
) |
2179 (0 << AC_AMPCAP_MUTE_SHIFT
));
2184 static int patch_stac9205(struct hda_codec
*codec
)
2186 struct sigmatel_spec
*spec
;
2189 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2194 spec
->num_pins
= 14;
2195 spec
->pin_nids
= stac9205_pin_nids
;
2196 spec
->board_config
= snd_hda_check_board_config(codec
, STAC_9205_MODELS
,
2200 if (spec
->board_config
< 0) {
2201 snd_printdd(KERN_INFO
"hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
2202 err
= stac92xx_save_bios_config_regs(codec
);
2204 stac92xx_free(codec
);
2207 spec
->pin_configs
= spec
->bios_pin_configs
;
2209 spec
->pin_configs
= stac9205_brd_tbl
[spec
->board_config
];
2210 stac92xx_set_config_regs(codec
);
2213 spec
->adc_nids
= stac9205_adc_nids
;
2214 spec
->mux_nids
= stac9205_mux_nids
;
2215 spec
->num_muxes
= ARRAY_SIZE(stac9205_mux_nids
);
2216 spec
->dmic_nids
= stac9205_dmic_nids
;
2217 spec
->num_dmics
= ARRAY_SIZE(stac9205_dmic_nids
);
2218 spec
->dmux_nid
= 0x1d;
2220 spec
->init
= stac9205_core_init
;
2221 spec
->mixer
= stac9205_mixer
;
2223 spec
->multiout
.dac_nids
= spec
->dac_nids
;
2225 /* Configure GPIO0 as EAPD output */
2226 snd_hda_codec_write(codec
, codec
->afg
, 0,
2227 AC_VERB_SET_GPIO_DIRECTION
, 0x00000001);
2228 /* Configure GPIO0 as CMOS */
2229 snd_hda_codec_write(codec
, codec
->afg
, 0, 0x7e7, 0x00000000);
2230 /* Assert GPIO0 high */
2231 snd_hda_codec_write(codec
, codec
->afg
, 0,
2232 AC_VERB_SET_GPIO_DATA
, 0x00000001);
2234 snd_hda_codec_write(codec
, codec
->afg
, 0,
2235 AC_VERB_SET_GPIO_MASK
, 0x00000001);
2237 err
= stac92xx_parse_auto_config(codec
, 0x1f, 0x20);
2239 if (spec
->board_config
< 0) {
2240 printk(KERN_WARNING
"hda_codec: No auto-config is "
2241 "available, default to model=ref\n");
2242 spec
->board_config
= STAC_9205_REF
;
2248 stac92xx_free(codec
);
2252 codec
->patch_ops
= stac92xx_patch_ops
;
2261 /* static config for Sony VAIO FE550G and Sony VAIO AR */
2262 static hda_nid_t vaio_dacs
[] = { 0x2 };
2263 #define VAIO_HP_DAC 0x5
2264 static hda_nid_t vaio_adcs
[] = { 0x8 /*,0x6*/ };
2265 static hda_nid_t vaio_mux_nids
[] = { 0x15 };
2267 static struct hda_input_mux vaio_mux
= {
2270 /* { "HP", 0x0 }, */
2277 static struct hda_verb vaio_init
[] = {
2278 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
}, /* HP <- 0x2 */
2279 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* Speaker <- 0x5 */
2280 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Mic? (<- 0x2) */
2281 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* CD */
2282 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Mic? */
2283 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x2}, /* mic-sel: 0a,0d,14,02 */
2284 {0x02, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
}, /* HP */
2285 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
}, /* Speaker */
2286 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
2287 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
2288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
}, /* Mic-in -> 0x9 */
2292 static struct hda_verb vaio_ar_init
[] = {
2293 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_HP
}, /* HP <- 0x2 */
2294 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_OUT
}, /* Speaker <- 0x5 */
2295 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Mic? (<- 0x2) */
2296 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_IN
}, /* CD */
2297 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
2298 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL
, PIN_VREF80
}, /* Mic? */
2299 {0x15, AC_VERB_SET_CONNECT_SEL
, 0x2}, /* mic-sel: 0a,0d,14,02 */
2300 {0x02, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
}, /* HP */
2301 {0x05, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_MUTE
}, /* Speaker */
2302 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
2303 {0x09, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
2304 {0x07, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
2305 {0x15, AC_VERB_SET_AMP_GAIN_MUTE
, AMP_OUT_UNMUTE
}, /* Mic-in -> 0x9 */
2309 /* bind volumes of both NID 0x02 and 0x05 */
2310 static int vaio_master_vol_put(struct snd_kcontrol
*kcontrol
,
2311 struct snd_ctl_elem_value
*ucontrol
)
2313 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2314 long *valp
= ucontrol
->value
.integer
.value
;
2317 change
= snd_hda_codec_amp_update(codec
, 0x02, 0, HDA_OUTPUT
, 0,
2318 0x7f, valp
[0] & 0x7f);
2319 change
|= snd_hda_codec_amp_update(codec
, 0x02, 1, HDA_OUTPUT
, 0,
2320 0x7f, valp
[1] & 0x7f);
2321 snd_hda_codec_amp_update(codec
, 0x05, 0, HDA_OUTPUT
, 0,
2322 0x7f, valp
[0] & 0x7f);
2323 snd_hda_codec_amp_update(codec
, 0x05, 1, HDA_OUTPUT
, 0,
2324 0x7f, valp
[1] & 0x7f);
2328 /* bind volumes of both NID 0x02 and 0x05 */
2329 static int vaio_master_sw_put(struct snd_kcontrol
*kcontrol
,
2330 struct snd_ctl_elem_value
*ucontrol
)
2332 struct hda_codec
*codec
= snd_kcontrol_chip(kcontrol
);
2333 long *valp
= ucontrol
->value
.integer
.value
;
2336 change
= snd_hda_codec_amp_update(codec
, 0x02, 0, HDA_OUTPUT
, 0,
2337 0x80, (valp
[0] ? 0 : 0x80));
2338 change
|= snd_hda_codec_amp_update(codec
, 0x02, 1, HDA_OUTPUT
, 0,
2339 0x80, (valp
[1] ? 0 : 0x80));
2340 snd_hda_codec_amp_update(codec
, 0x05, 0, HDA_OUTPUT
, 0,
2341 0x80, (valp
[0] ? 0 : 0x80));
2342 snd_hda_codec_amp_update(codec
, 0x05, 1, HDA_OUTPUT
, 0,
2343 0x80, (valp
[1] ? 0 : 0x80));
2347 static struct snd_kcontrol_new vaio_mixer
[] = {
2349 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2350 .name
= "Master Playback Volume",
2351 .info
= snd_hda_mixer_amp_volume_info
,
2352 .get
= snd_hda_mixer_amp_volume_get
,
2353 .put
= vaio_master_vol_put
,
2354 .tlv
= { .c
= snd_hda_mixer_amp_tlv
},
2355 .private_value
= HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT
),
2358 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2359 .name
= "Master Playback Switch",
2360 .info
= snd_hda_mixer_amp_switch_info
,
2361 .get
= snd_hda_mixer_amp_switch_get
,
2362 .put
= vaio_master_sw_put
,
2363 .private_value
= HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT
),
2365 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2366 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT
),
2367 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT
),
2369 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2370 .name
= "Capture Source",
2372 .info
= stac92xx_mux_enum_info
,
2373 .get
= stac92xx_mux_enum_get
,
2374 .put
= stac92xx_mux_enum_put
,
2379 static struct snd_kcontrol_new vaio_ar_mixer
[] = {
2381 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2382 .name
= "Master Playback Volume",
2383 .info
= snd_hda_mixer_amp_volume_info
,
2384 .get
= snd_hda_mixer_amp_volume_get
,
2385 .put
= vaio_master_vol_put
,
2386 .private_value
= HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT
),
2389 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2390 .name
= "Master Playback Switch",
2391 .info
= snd_hda_mixer_amp_switch_info
,
2392 .get
= snd_hda_mixer_amp_switch_get
,
2393 .put
= vaio_master_sw_put
,
2394 .private_value
= HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT
),
2396 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2397 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT
),
2398 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT
),
2399 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
2400 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
2402 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2403 .name
= "Capture Source",
2405 .info
= stac92xx_mux_enum_info
,
2406 .get
= stac92xx_mux_enum_get
,
2407 .put
= stac92xx_mux_enum_put
,
2412 static struct hda_codec_ops stac9872_patch_ops
= {
2413 .build_controls
= stac92xx_build_controls
,
2414 .build_pcms
= stac92xx_build_pcms
,
2415 .init
= stac92xx_init
,
2416 .free
= stac92xx_free
,
2418 .resume
= stac92xx_resume
,
2422 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
2424 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
2426 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
2428 /* AR Series. id=0x83847664 and subsys=104D1300 */
2433 static const char *stac9872_models
[STAC_9872_MODELS
] = {
2434 [CXD9872RD_VAIO
] = "vaio",
2435 [CXD9872AKD_VAIO
] = "vaio-ar",
2438 static struct snd_pci_quirk stac9872_cfg_tbl
[] = {
2439 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO
),
2440 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO
),
2441 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO
),
2442 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO
),
2446 static int patch_stac9872(struct hda_codec
*codec
)
2448 struct sigmatel_spec
*spec
;
2451 board_config
= snd_hda_check_board_config(codec
, STAC_9872_MODELS
,
2454 if (board_config
< 0)
2455 /* unknown config, let generic-parser do its job... */
2456 return snd_hda_parse_generic_codec(codec
);
2458 spec
= kzalloc(sizeof(*spec
), GFP_KERNEL
);
2463 switch (board_config
) {
2464 case CXD9872RD_VAIO
:
2465 case STAC9872AK_VAIO
:
2466 case STAC9872K_VAIO
:
2467 spec
->mixer
= vaio_mixer
;
2468 spec
->init
= vaio_init
;
2469 spec
->multiout
.max_channels
= 2;
2470 spec
->multiout
.num_dacs
= ARRAY_SIZE(vaio_dacs
);
2471 spec
->multiout
.dac_nids
= vaio_dacs
;
2472 spec
->multiout
.hp_nid
= VAIO_HP_DAC
;
2473 spec
->num_adcs
= ARRAY_SIZE(vaio_adcs
);
2474 spec
->adc_nids
= vaio_adcs
;
2475 spec
->input_mux
= &vaio_mux
;
2476 spec
->mux_nids
= vaio_mux_nids
;
2479 case CXD9872AKD_VAIO
:
2480 spec
->mixer
= vaio_ar_mixer
;
2481 spec
->init
= vaio_ar_init
;
2482 spec
->multiout
.max_channels
= 2;
2483 spec
->multiout
.num_dacs
= ARRAY_SIZE(vaio_dacs
);
2484 spec
->multiout
.dac_nids
= vaio_dacs
;
2485 spec
->multiout
.hp_nid
= VAIO_HP_DAC
;
2486 spec
->num_adcs
= ARRAY_SIZE(vaio_adcs
);
2487 spec
->adc_nids
= vaio_adcs
;
2488 spec
->input_mux
= &vaio_mux
;
2489 spec
->mux_nids
= vaio_mux_nids
;
2493 codec
->patch_ops
= stac9872_patch_ops
;
2501 struct hda_codec_preset snd_hda_preset_sigmatel
[] = {
2502 { .id
= 0x83847690, .name
= "STAC9200", .patch
= patch_stac9200
},
2503 { .id
= 0x83847882, .name
= "STAC9220 A1", .patch
= patch_stac922x
},
2504 { .id
= 0x83847680, .name
= "STAC9221 A1", .patch
= patch_stac922x
},
2505 { .id
= 0x83847880, .name
= "STAC9220 A2", .patch
= patch_stac922x
},
2506 { .id
= 0x83847681, .name
= "STAC9220D/9223D A2", .patch
= patch_stac922x
},
2507 { .id
= 0x83847682, .name
= "STAC9221 A2", .patch
= patch_stac922x
},
2508 { .id
= 0x83847683, .name
= "STAC9221D A2", .patch
= patch_stac922x
},
2509 { .id
= 0x83847618, .name
= "STAC9227", .patch
= patch_stac927x
},
2510 { .id
= 0x83847619, .name
= "STAC9227", .patch
= patch_stac927x
},
2511 { .id
= 0x83847616, .name
= "STAC9228", .patch
= patch_stac927x
},
2512 { .id
= 0x83847617, .name
= "STAC9228", .patch
= patch_stac927x
},
2513 { .id
= 0x83847614, .name
= "STAC9229", .patch
= patch_stac927x
},
2514 { .id
= 0x83847615, .name
= "STAC9229", .patch
= patch_stac927x
},
2515 { .id
= 0x83847620, .name
= "STAC9274", .patch
= patch_stac927x
},
2516 { .id
= 0x83847621, .name
= "STAC9274D", .patch
= patch_stac927x
},
2517 { .id
= 0x83847622, .name
= "STAC9273X", .patch
= patch_stac927x
},
2518 { .id
= 0x83847623, .name
= "STAC9273D", .patch
= patch_stac927x
},
2519 { .id
= 0x83847624, .name
= "STAC9272X", .patch
= patch_stac927x
},
2520 { .id
= 0x83847625, .name
= "STAC9272D", .patch
= patch_stac927x
},
2521 { .id
= 0x83847626, .name
= "STAC9271X", .patch
= patch_stac927x
},
2522 { .id
= 0x83847627, .name
= "STAC9271D", .patch
= patch_stac927x
},
2523 { .id
= 0x83847628, .name
= "STAC9274X5NH", .patch
= patch_stac927x
},
2524 { .id
= 0x83847629, .name
= "STAC9274D5NH", .patch
= patch_stac927x
},
2525 { .id
= 0x83847632, .name
= "STAC9202", .patch
= patch_stac925x
},
2526 { .id
= 0x83847633, .name
= "STAC9202D", .patch
= patch_stac925x
},
2527 { .id
= 0x83847634, .name
= "STAC9250", .patch
= patch_stac925x
},
2528 { .id
= 0x83847635, .name
= "STAC9250D", .patch
= patch_stac925x
},
2529 { .id
= 0x83847636, .name
= "STAC9251", .patch
= patch_stac925x
},
2530 { .id
= 0x83847637, .name
= "STAC9250D", .patch
= patch_stac925x
},
2531 /* The following does not take into account .id=0x83847661 when subsys =
2532 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
2533 * currently not fully supported.
2535 { .id
= 0x83847661, .name
= "CXD9872RD/K", .patch
= patch_stac9872
},
2536 { .id
= 0x83847662, .name
= "STAC9872AK", .patch
= patch_stac9872
},
2537 { .id
= 0x83847664, .name
= "CXD9872AKD", .patch
= patch_stac9872
},
2538 { .id
= 0x838476a0, .name
= "STAC9205", .patch
= patch_stac9205
},
2539 { .id
= 0x838476a1, .name
= "STAC9205D", .patch
= patch_stac9205
},
2540 { .id
= 0x838476a2, .name
= "STAC9204", .patch
= patch_stac9205
},
2541 { .id
= 0x838476a3, .name
= "STAC9204D", .patch
= patch_stac9205
},
2542 { .id
= 0x838476a4, .name
= "STAC9255", .patch
= patch_stac9205
},
2543 { .id
= 0x838476a5, .name
= "STAC9255D", .patch
= patch_stac9205
},
2544 { .id
= 0x838476a6, .name
= "STAC9254", .patch
= patch_stac9205
},
2545 { .id
= 0x838476a7, .name
= "STAC9254D", .patch
= patch_stac9205
},