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
39 #define STAC_UNSOL_ENABLE (AC_USRSP_EN | STAC_HP_EVENT)
42 #define STAC_D945GTP3 1
43 #define STAC_D945GTP5 2
44 #define STAC_MACMINI 3
46 struct sigmatel_spec {
47 struct snd_kcontrol_new *mixers[4];
48 unsigned int num_mixers;
51 unsigned int surr_switch: 1;
52 unsigned int line_switch: 1;
53 unsigned int mic_switch: 1;
54 unsigned int alt_switch: 1;
55 unsigned int hp_detect: 1;
56 unsigned int gpio_mute: 1;
59 struct hda_multi_out multiout;
60 hda_nid_t dac_nids[5];
64 unsigned int num_adcs;
66 unsigned int num_muxes;
71 unsigned int num_pins;
72 unsigned int *pin_configs;
74 /* codec specific stuff */
75 struct hda_verb *init;
76 struct snd_kcontrol_new *mixer;
79 struct hda_input_mux *input_mux;
80 unsigned int cur_mux[3];
83 unsigned int io_switch[2];
85 struct hda_pcm pcm_rec[2]; /* PCM information */
87 /* dynamic controls and input_mux */
88 struct auto_pin_cfg autocfg;
89 unsigned int num_kctl_alloc, num_kctl_used;
90 struct snd_kcontrol_new *kctl_alloc;
91 struct hda_input_mux private_imux;
94 static hda_nid_t stac9200_adc_nids[1] = {
98 static hda_nid_t stac9200_mux_nids[1] = {
102 static hda_nid_t stac9200_dac_nids[1] = {
106 static hda_nid_t stac922x_adc_nids[2] = {
110 static hda_nid_t stac922x_mux_nids[2] = {
114 static hda_nid_t stac927x_adc_nids[3] = {
118 static hda_nid_t stac927x_mux_nids[3] = {
122 static hda_nid_t stac9200_pin_nids[8] = {
123 0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
126 static hda_nid_t stac922x_pin_nids[10] = {
127 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
128 0x0f, 0x10, 0x11, 0x15, 0x1b,
131 static hda_nid_t stac927x_pin_nids[14] = {
132 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
133 0x0f, 0x10, 0x11, 0x12, 0x13,
134 0x14, 0x21, 0x22, 0x23,
137 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
139 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
140 struct sigmatel_spec *spec = codec->spec;
141 return snd_hda_input_mux_info(spec->input_mux, uinfo);
144 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
146 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
147 struct sigmatel_spec *spec = codec->spec;
148 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
150 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
154 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
156 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
157 struct sigmatel_spec *spec = codec->spec;
158 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
160 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
161 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
164 static struct hda_verb stac9200_core_init[] = {
165 /* set dac0mux for dac converter */
166 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
170 static struct hda_verb stac922x_core_init[] = {
171 /* set master volume and direct control */
172 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
176 static struct hda_verb stac927x_core_init[] = {
177 /* set master volume and direct control */
178 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
182 static struct snd_kcontrol_new stac9200_mixer[] = {
183 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
184 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
186 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
187 .name = "Input Source",
189 .info = stac92xx_mux_enum_info,
190 .get = stac92xx_mux_enum_get,
191 .put = stac92xx_mux_enum_put,
193 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
194 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
195 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
199 /* This needs to be generated dynamically based on sequence */
200 static struct snd_kcontrol_new stac922x_mixer[] = {
202 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
203 .name = "Input Source",
205 .info = stac92xx_mux_enum_info,
206 .get = stac92xx_mux_enum_get,
207 .put = stac92xx_mux_enum_put,
209 HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT),
210 HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT),
211 HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT),
215 static snd_kcontrol_new_t stac927x_mixer[] = {
217 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
218 .name = "Input Source",
220 .info = stac92xx_mux_enum_info,
221 .get = stac92xx_mux_enum_get,
222 .put = stac92xx_mux_enum_put,
224 HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT),
225 HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT),
226 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
230 static int stac92xx_build_controls(struct hda_codec *codec)
232 struct sigmatel_spec *spec = codec->spec;
236 err = snd_hda_add_new_ctls(codec, spec->mixer);
240 for (i = 0; i < spec->num_mixers; i++) {
241 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
246 if (spec->multiout.dig_out_nid) {
247 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
251 if (spec->dig_in_nid) {
252 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
259 static unsigned int ref9200_pin_configs[8] = {
260 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
261 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
264 static unsigned int *stac9200_brd_tbl[] = {
268 static struct hda_board_config stac9200_cfg_tbl[] = {
269 { .modelname = "ref",
270 .pci_subvendor = PCI_VENDOR_ID_INTEL,
271 .pci_subdevice = 0x2668, /* DFI LanParty */
272 .config = STAC_REF },
276 static unsigned int ref922x_pin_configs[10] = {
277 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
278 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
279 0x40000100, 0x40000100,
282 static unsigned int d945gtp3_pin_configs[10] = {
283 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
284 0x40000100, 0x40000100, 0x40000100, 0x40000100,
285 0x02a19120, 0x40000100,
288 static unsigned int d945gtp5_pin_configs[10] = {
289 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
290 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
291 0x02a19320, 0x40000100,
294 static unsigned int *stac922x_brd_tbl[] = {
296 d945gtp3_pin_configs,
297 d945gtp5_pin_configs,
298 NULL, /* STAC_MACMINI */
301 static struct hda_board_config stac922x_cfg_tbl[] = {
302 { .modelname = "ref",
303 .pci_subvendor = PCI_VENDOR_ID_INTEL,
304 .pci_subdevice = 0x2668, /* DFI LanParty */
305 .config = STAC_REF }, /* SigmaTel reference board */
306 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
307 .pci_subdevice = 0x0101,
308 .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */
309 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
310 .pci_subdevice = 0x0202,
311 .config = STAC_D945GTP3 }, /* Intel D945GNT - 3 Stack, 9221 A1 */
312 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
313 .pci_subdevice = 0x0b0b,
314 .config = STAC_D945GTP3 }, /* Intel D945PSN - 3 Stack, 9221 A1 */
315 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
316 .pci_subdevice = 0x0707,
317 .config = STAC_D945GTP5 }, /* Intel D945PSV - 5 Stack */
318 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
319 .pci_subdevice = 0x0404,
320 .config = STAC_D945GTP5 }, /* Intel D945GTP - 5 Stack */
321 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
322 .pci_subdevice = 0x0303,
323 .config = STAC_D945GTP5 }, /* Intel D945GNT - 5 Stack */
324 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
325 .pci_subdevice = 0x0013,
326 .config = STAC_D945GTP5 }, /* Intel D955XBK - 5 Stack */
327 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
328 .pci_subdevice = 0x0417,
329 .config = STAC_D945GTP5 }, /* Intel D975XBK - 5 Stack */
330 { .pci_subvendor = 0x8384,
331 .pci_subdevice = 0x7680,
332 .config = STAC_MACMINI }, /* Apple Mac Mini (early 2006) */
336 static unsigned int ref927x_pin_configs[14] = {
337 0x01813122, 0x01a19021, 0x01014010, 0x01016011,
338 0x01012012, 0x01011014, 0x40000100, 0x40000100,
339 0x40000100, 0x40000100, 0x40000100, 0x01441030,
340 0x01c41030, 0x40000100,
343 static unsigned int *stac927x_brd_tbl[] = {
347 static struct hda_board_config stac927x_cfg_tbl[] = {
348 { .modelname = "ref",
349 .pci_subvendor = PCI_VENDOR_ID_INTEL,
350 .pci_subdevice = 0x2668, /* DFI LanParty */
351 .config = STAC_REF }, /* SigmaTel reference board */
355 static void stac92xx_set_config_regs(struct hda_codec *codec)
358 struct sigmatel_spec *spec = codec->spec;
359 unsigned int pin_cfg;
361 for (i=0; i < spec->num_pins; i++) {
362 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
363 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
364 spec->pin_configs[i] & 0x000000ff);
365 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
366 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
367 (spec->pin_configs[i] & 0x0000ff00) >> 8);
368 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
369 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
370 (spec->pin_configs[i] & 0x00ff0000) >> 16);
371 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
372 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
373 spec->pin_configs[i] >> 24);
374 pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0,
375 AC_VERB_GET_CONFIG_DEFAULT,
377 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg);
382 * Analog playback callbacks
384 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
385 struct hda_codec *codec,
386 struct snd_pcm_substream *substream)
388 struct sigmatel_spec *spec = codec->spec;
389 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
392 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
393 struct hda_codec *codec,
394 unsigned int stream_tag,
396 struct snd_pcm_substream *substream)
398 struct sigmatel_spec *spec = codec->spec;
399 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
402 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
403 struct hda_codec *codec,
404 struct snd_pcm_substream *substream)
406 struct sigmatel_spec *spec = codec->spec;
407 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
411 * Digital playback callbacks
413 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
414 struct hda_codec *codec,
415 struct snd_pcm_substream *substream)
417 struct sigmatel_spec *spec = codec->spec;
418 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
421 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
422 struct hda_codec *codec,
423 struct snd_pcm_substream *substream)
425 struct sigmatel_spec *spec = codec->spec;
426 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
431 * Analog capture callbacks
433 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
434 struct hda_codec *codec,
435 unsigned int stream_tag,
437 struct snd_pcm_substream *substream)
439 struct sigmatel_spec *spec = codec->spec;
441 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
442 stream_tag, 0, format);
446 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
447 struct hda_codec *codec,
448 struct snd_pcm_substream *substream)
450 struct sigmatel_spec *spec = codec->spec;
452 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
456 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
460 /* NID is set in stac92xx_build_pcms */
462 .open = stac92xx_dig_playback_pcm_open,
463 .close = stac92xx_dig_playback_pcm_close
467 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
471 /* NID is set in stac92xx_build_pcms */
474 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
478 .nid = 0x02, /* NID to query formats and rates */
480 .open = stac92xx_playback_pcm_open,
481 .prepare = stac92xx_playback_pcm_prepare,
482 .cleanup = stac92xx_playback_pcm_cleanup
486 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
490 .nid = 0x06, /* NID to query formats and rates */
492 .open = stac92xx_playback_pcm_open,
493 .prepare = stac92xx_playback_pcm_prepare,
494 .cleanup = stac92xx_playback_pcm_cleanup
498 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
502 /* NID is set in stac92xx_build_pcms */
504 .prepare = stac92xx_capture_pcm_prepare,
505 .cleanup = stac92xx_capture_pcm_cleanup
509 static int stac92xx_build_pcms(struct hda_codec *codec)
511 struct sigmatel_spec *spec = codec->spec;
512 struct hda_pcm *info = spec->pcm_rec;
515 codec->pcm_info = info;
517 info->name = "STAC92xx Analog";
518 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
519 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
520 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
522 if (spec->alt_switch) {
525 info->name = "STAC92xx Analog Alt";
526 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
529 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
532 info->name = "STAC92xx Digital";
533 if (spec->multiout.dig_out_nid) {
534 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
535 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
537 if (spec->dig_in_nid) {
538 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
539 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
546 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
548 unsigned int pincap = snd_hda_param_read(codec, nid,
550 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
551 if (pincap & AC_PINCAP_VREF_100)
552 return AC_PINCTL_VREF_100;
553 if (pincap & AC_PINCAP_VREF_80)
554 return AC_PINCTL_VREF_80;
555 if (pincap & AC_PINCAP_VREF_50)
556 return AC_PINCTL_VREF_50;
557 if (pincap & AC_PINCAP_VREF_GRD)
558 return AC_PINCTL_VREF_GRD;
562 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
565 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
568 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
570 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
572 uinfo->value.integer.min = 0;
573 uinfo->value.integer.max = 1;
577 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
579 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
580 struct sigmatel_spec *spec = codec->spec;
581 int io_idx = kcontrol-> private_value & 0xff;
583 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
587 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
589 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
590 struct sigmatel_spec *spec = codec->spec;
591 hda_nid_t nid = kcontrol->private_value >> 8;
592 int io_idx = kcontrol-> private_value & 0xff;
593 unsigned short val = ucontrol->value.integer.value[0];
595 spec->io_switch[io_idx] = val;
598 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
600 unsigned int pinctl = AC_PINCTL_IN_EN;
601 if (io_idx) /* set VREF for mic */
602 pinctl |= stac92xx_get_vref(codec, nid);
603 stac92xx_auto_set_pinctl(codec, nid, pinctl);
608 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
609 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
612 .info = stac92xx_io_switch_info, \
613 .get = stac92xx_io_switch_get, \
614 .put = stac92xx_io_switch_put, \
615 .private_value = xpval, \
621 STAC_CTL_WIDGET_MUTE,
622 STAC_CTL_WIDGET_IO_SWITCH,
625 static struct snd_kcontrol_new stac92xx_control_templates[] = {
626 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
627 HDA_CODEC_MUTE(NULL, 0, 0, 0),
628 STAC_CODEC_IO_SWITCH(NULL, 0),
631 /* add dynamic controls */
632 static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
634 struct snd_kcontrol_new *knew;
636 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
637 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
639 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
642 if (spec->kctl_alloc) {
643 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
644 kfree(spec->kctl_alloc);
646 spec->kctl_alloc = knew;
647 spec->num_kctl_alloc = num;
650 knew = &spec->kctl_alloc[spec->num_kctl_used];
651 *knew = stac92xx_control_templates[type];
652 knew->name = kstrdup(name, GFP_KERNEL);
655 knew->private_value = val;
656 spec->num_kctl_used++;
660 /* flag inputs as additional dynamic lineouts */
661 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
663 struct sigmatel_spec *spec = codec->spec;
665 switch (cfg->line_outs) {
667 /* add line-in as side */
668 if (cfg->input_pins[AUTO_PIN_LINE]) {
669 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE];
670 spec->line_switch = 1;
675 /* add line-in as clfe and mic as side */
676 if (cfg->input_pins[AUTO_PIN_LINE]) {
677 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE];
678 spec->line_switch = 1;
681 if (cfg->input_pins[AUTO_PIN_MIC]) {
682 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC];
683 spec->mic_switch = 1;
688 /* add line-in as surr and mic as clfe */
689 if (cfg->input_pins[AUTO_PIN_LINE]) {
690 cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE];
691 spec->line_switch = 1;
694 if (cfg->input_pins[AUTO_PIN_MIC]) {
695 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC];
696 spec->mic_switch = 1;
706 * XXX The line_out pin widget connection list may not be set to the
707 * desired DAC nid. This is the case on 927x where ports A and B can
708 * be routed to several DACs.
710 * This requires an analysis of the line-out/hp pin configuration
711 * to provide a best fit for pin/DAC configurations that are routable.
712 * For now, 927x DAC4 is not supported and 927x DAC1 output to ports
713 * A and B is not supported.
715 /* fill in the dac_nids table from the parsed pin configuration */
716 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
718 struct sigmatel_spec *spec = codec->spec;
722 /* check the pins hardwired to audio widget */
723 for (i = 0; i < cfg->line_outs; i++) {
724 nid = cfg->line_out_pins[i];
725 spec->multiout.dac_nids[i] = snd_hda_codec_read(codec, nid, 0,
726 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
729 spec->multiout.num_dacs = cfg->line_outs;
734 /* add playback controls from the parsed DAC table */
735 static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec, const struct auto_pin_cfg *cfg)
738 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
742 for (i = 0; i < cfg->line_outs; i++) {
743 if (!spec->multiout.dac_nids[i])
746 nid = spec->multiout.dac_nids[i];
750 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Center Playback Volume",
751 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
753 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "LFE Playback Volume",
754 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
756 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Center Playback Switch",
757 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
759 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "LFE Playback Switch",
760 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
763 sprintf(name, "%s Playback Volume", chname[i]);
764 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
765 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
767 sprintf(name, "%s Playback Switch", chname[i]);
768 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
769 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
774 if (spec->line_switch)
775 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
778 if (spec->mic_switch)
779 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
785 /* add playback controls for HP output */
786 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, struct auto_pin_cfg *cfg)
788 struct sigmatel_spec *spec = codec->spec;
789 hda_nid_t pin = cfg->hp_pin;
792 unsigned int wid_caps;
797 wid_caps = get_wcaps(codec, pin);
798 if (wid_caps & AC_WCAP_UNSOL_CAP)
801 nid = snd_hda_codec_read(codec, pin, 0, AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
802 for (i = 0; i < cfg->line_outs; i++) {
803 if (! spec->multiout.dac_nids[i])
805 if (spec->multiout.dac_nids[i] == nid)
809 spec->multiout.hp_nid = nid;
811 /* control HP volume/switch on the output mixer amp */
812 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Headphone Playback Volume",
813 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
815 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
816 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
822 /* create playback/capture controls for input pins */
823 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
825 struct sigmatel_spec *spec = codec->spec;
826 struct hda_input_mux *imux = &spec->private_imux;
827 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
830 for (i = 0; i < AUTO_PIN_LAST; i++) {
832 if (cfg->input_pins[i]) {
833 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
835 for (j=0; j<spec->num_muxes; j++) {
836 int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS);
837 for (k=0; k<num_cons; k++)
838 if (con_lst[k] == cfg->input_pins[i]) {
845 imux->items[imux->num_items].index = index;
850 if (imux->num_items == 1) {
852 * Set the current input for the muxes.
853 * The STAC9221 has two input muxes with identical source
854 * NID lists. Hopefully this won't get confused.
856 for (i = 0; i < spec->num_muxes; i++) {
857 snd_hda_codec_write(codec, spec->mux_nids[i], 0,
858 AC_VERB_SET_CONNECT_SEL,
859 imux->items[0].index);
866 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
868 struct sigmatel_spec *spec = codec->spec;
871 for (i = 0; i < spec->autocfg.line_outs; i++) {
872 hda_nid_t nid = spec->autocfg.line_out_pins[i];
873 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
877 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
879 struct sigmatel_spec *spec = codec->spec;
882 pin = spec->autocfg.hp_pin;
883 if (pin) /* connect to front */
884 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
887 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
889 struct sigmatel_spec *spec = codec->spec;
892 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
894 if (! spec->autocfg.line_outs)
895 return 0; /* can't find valid pin config */
896 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
898 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
901 if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
902 (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 ||
903 (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
906 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
907 if (spec->multiout.max_channels > 2)
908 spec->surr_switch = 1;
910 if (spec->autocfg.dig_out_pin)
911 spec->multiout.dig_out_nid = dig_out;
912 if (spec->autocfg.dig_in_pin)
913 spec->dig_in_nid = dig_in;
915 if (spec->kctl_alloc)
916 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
918 spec->input_mux = &spec->private_imux;
923 /* add playback controls for HP output */
924 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
925 struct auto_pin_cfg *cfg)
927 struct sigmatel_spec *spec = codec->spec;
928 hda_nid_t pin = cfg->hp_pin;
929 unsigned int wid_caps;
934 wid_caps = get_wcaps(codec, pin);
935 if (wid_caps & AC_WCAP_UNSOL_CAP)
941 static int stac9200_parse_auto_config(struct hda_codec *codec)
943 struct sigmatel_spec *spec = codec->spec;
946 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
949 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
952 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
955 if (spec->autocfg.dig_out_pin)
956 spec->multiout.dig_out_nid = 0x05;
957 if (spec->autocfg.dig_in_pin)
958 spec->dig_in_nid = 0x04;
960 if (spec->kctl_alloc)
961 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
963 spec->input_mux = &spec->private_imux;
969 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
970 * funky external mute control using GPIO pins.
973 static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted)
975 unsigned int gpiostate, gpiomask, gpiodir;
977 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
978 AC_VERB_GET_GPIO_DATA, 0);
981 gpiostate |= (1 << pin);
983 gpiostate &= ~(1 << pin);
985 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
986 AC_VERB_GET_GPIO_MASK, 0);
987 gpiomask |= (1 << pin);
989 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
990 AC_VERB_GET_GPIO_DIRECTION, 0);
991 gpiodir |= (1 << pin);
993 /* AppleHDA seems to do this -- WTF is this verb?? */
994 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
996 snd_hda_codec_write(codec, codec->afg, 0,
997 AC_VERB_SET_GPIO_MASK, gpiomask);
998 snd_hda_codec_write(codec, codec->afg, 0,
999 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
1003 snd_hda_codec_write(codec, codec->afg, 0,
1004 AC_VERB_SET_GPIO_DATA, gpiostate);
1007 static int stac92xx_init(struct hda_codec *codec)
1009 struct sigmatel_spec *spec = codec->spec;
1010 struct auto_pin_cfg *cfg = &spec->autocfg;
1013 snd_hda_sequence_write(codec, spec->init);
1016 if (spec->hp_detect) {
1017 /* Enable unsolicited responses on the HP widget */
1018 snd_hda_codec_write(codec, cfg->hp_pin, 0,
1019 AC_VERB_SET_UNSOLICITED_ENABLE,
1021 /* fake event to set up pins */
1022 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
1024 stac92xx_auto_init_multi_out(codec);
1025 stac92xx_auto_init_hp_out(codec);
1027 for (i = 0; i < AUTO_PIN_LAST; i++) {
1028 hda_nid_t nid = cfg->input_pins[i];
1030 unsigned int pinctl = AC_PINCTL_IN_EN;
1031 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
1032 pinctl |= stac92xx_get_vref(codec, nid);
1033 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1036 if (cfg->dig_out_pin)
1037 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
1039 if (cfg->dig_in_pin)
1040 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
1043 if (spec->gpio_mute) {
1044 stac922x_gpio_mute(codec, 0, 0);
1045 stac922x_gpio_mute(codec, 1, 0);
1051 static void stac92xx_free(struct hda_codec *codec)
1053 struct sigmatel_spec *spec = codec->spec;
1059 if (spec->kctl_alloc) {
1060 for (i = 0; i < spec->num_kctl_used; i++)
1061 kfree(spec->kctl_alloc[i].name);
1062 kfree(spec->kctl_alloc);
1068 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
1071 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1072 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
1073 snd_hda_codec_write(codec, nid, 0,
1074 AC_VERB_SET_PIN_WIDGET_CONTROL,
1078 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
1081 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1082 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
1083 snd_hda_codec_write(codec, nid, 0,
1084 AC_VERB_SET_PIN_WIDGET_CONTROL,
1088 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
1090 struct sigmatel_spec *spec = codec->spec;
1091 struct auto_pin_cfg *cfg = &spec->autocfg;
1094 if ((res >> 26) != STAC_HP_EVENT)
1097 presence = snd_hda_codec_read(codec, cfg->hp_pin, 0,
1098 AC_VERB_GET_PIN_SENSE, 0x00) >> 31;
1101 /* disable lineouts, enable hp */
1102 for (i = 0; i < cfg->line_outs; i++)
1103 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
1105 stac92xx_set_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
1107 /* enable lineouts, disable hp */
1108 for (i = 0; i < cfg->line_outs; i++)
1109 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
1111 stac92xx_reset_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
1116 static int stac92xx_resume(struct hda_codec *codec)
1118 struct sigmatel_spec *spec = codec->spec;
1121 stac92xx_init(codec);
1122 for (i = 0; i < spec->num_mixers; i++)
1123 snd_hda_resume_ctls(codec, spec->mixers[i]);
1124 if (spec->multiout.dig_out_nid)
1125 snd_hda_resume_spdif_out(codec);
1126 if (spec->dig_in_nid)
1127 snd_hda_resume_spdif_in(codec);
1133 static struct hda_codec_ops stac92xx_patch_ops = {
1134 .build_controls = stac92xx_build_controls,
1135 .build_pcms = stac92xx_build_pcms,
1136 .init = stac92xx_init,
1137 .free = stac92xx_free,
1138 .unsol_event = stac92xx_unsol_event,
1140 .resume = stac92xx_resume,
1144 static int patch_stac9200(struct hda_codec *codec)
1146 struct sigmatel_spec *spec;
1149 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1154 spec->board_config = snd_hda_check_board_config(codec, stac9200_cfg_tbl);
1155 if (spec->board_config < 0)
1156 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
1159 spec->pin_nids = stac9200_pin_nids;
1160 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
1161 stac92xx_set_config_regs(codec);
1164 spec->multiout.max_channels = 2;
1165 spec->multiout.num_dacs = 1;
1166 spec->multiout.dac_nids = stac9200_dac_nids;
1167 spec->adc_nids = stac9200_adc_nids;
1168 spec->mux_nids = stac9200_mux_nids;
1169 spec->num_muxes = 1;
1171 spec->init = stac9200_core_init;
1172 spec->mixer = stac9200_mixer;
1174 err = stac9200_parse_auto_config(codec);
1176 stac92xx_free(codec);
1180 codec->patch_ops = stac92xx_patch_ops;
1185 static int patch_stac922x(struct hda_codec *codec)
1187 struct sigmatel_spec *spec;
1190 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1195 spec->board_config = snd_hda_check_board_config(codec, stac922x_cfg_tbl);
1196 if (spec->board_config < 0)
1197 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, using BIOS defaults\n");
1198 else if (stac922x_brd_tbl[spec->board_config] != NULL) {
1199 spec->num_pins = 10;
1200 spec->pin_nids = stac922x_pin_nids;
1201 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
1202 stac92xx_set_config_regs(codec);
1205 spec->adc_nids = stac922x_adc_nids;
1206 spec->mux_nids = stac922x_mux_nids;
1207 spec->num_muxes = 2;
1209 spec->init = stac922x_core_init;
1210 spec->mixer = stac922x_mixer;
1212 spec->multiout.dac_nids = spec->dac_nids;
1214 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
1216 stac92xx_free(codec);
1220 if (spec->board_config == STAC_MACMINI)
1221 spec->gpio_mute = 1;
1223 codec->patch_ops = stac92xx_patch_ops;
1228 static int patch_stac927x(struct hda_codec *codec)
1230 struct sigmatel_spec *spec;
1233 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1238 spec->board_config = snd_hda_check_board_config(codec, stac927x_cfg_tbl);
1239 if (spec->board_config < 0)
1240 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
1242 spec->num_pins = 14;
1243 spec->pin_nids = stac927x_pin_nids;
1244 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
1245 stac92xx_set_config_regs(codec);
1248 spec->adc_nids = stac927x_adc_nids;
1249 spec->mux_nids = stac927x_mux_nids;
1250 spec->num_muxes = 3;
1252 spec->init = stac927x_core_init;
1253 spec->mixer = stac927x_mixer;
1255 spec->multiout.dac_nids = spec->dac_nids;
1257 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
1259 stac92xx_free(codec);
1263 codec->patch_ops = stac92xx_patch_ops;
1272 /* static config for Sony VAIO FE550G */
1273 static hda_nid_t vaio_dacs[] = { 0x2 };
1274 #define VAIO_HP_DAC 0x5
1275 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
1276 static hda_nid_t vaio_mux_nids[] = { 0x15 };
1278 static struct hda_input_mux vaio_mux = {
1281 /* { "HP", 0x0 }, */
1288 static struct hda_verb vaio_init[] = {
1289 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
1290 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
1291 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
1292 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
1293 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
1294 {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
1295 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
1296 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
1297 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
1298 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
1299 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
1303 /* bind volumes of both NID 0x02 and 0x05 */
1304 static int vaio_master_vol_put(struct snd_kcontrol *kcontrol,
1305 struct snd_ctl_elem_value *ucontrol)
1307 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1308 long *valp = ucontrol->value.integer.value;
1311 change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
1312 0x7f, valp[0] & 0x7f);
1313 change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
1314 0x7f, valp[1] & 0x7f);
1315 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
1316 0x7f, valp[0] & 0x7f);
1317 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
1318 0x7f, valp[1] & 0x7f);
1322 /* bind volumes of both NID 0x02 and 0x05 */
1323 static int vaio_master_sw_put(struct snd_kcontrol *kcontrol,
1324 struct snd_ctl_elem_value *ucontrol)
1326 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1327 long *valp = ucontrol->value.integer.value;
1330 change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
1331 0x80, (valp[0] ? 0 : 0x80));
1332 change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
1333 0x80, (valp[1] ? 0 : 0x80));
1334 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
1335 0x80, (valp[0] ? 0 : 0x80));
1336 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
1337 0x80, (valp[1] ? 0 : 0x80));
1341 static struct snd_kcontrol_new vaio_mixer[] = {
1343 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1344 .name = "Master Playback Volume",
1345 .info = snd_hda_mixer_amp_volume_info,
1346 .get = snd_hda_mixer_amp_volume_get,
1347 .put = vaio_master_vol_put,
1348 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
1351 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1352 .name = "Master Playback Switch",
1353 .info = snd_hda_mixer_amp_switch_info,
1354 .get = snd_hda_mixer_amp_switch_get,
1355 .put = vaio_master_sw_put,
1356 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
1358 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
1359 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
1360 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
1362 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1363 .name = "Capture Source",
1365 .info = stac92xx_mux_enum_info,
1366 .get = stac92xx_mux_enum_get,
1367 .put = stac92xx_mux_enum_put,
1372 static struct hda_codec_ops stac7661_patch_ops = {
1373 .build_controls = stac92xx_build_controls,
1374 .build_pcms = stac92xx_build_pcms,
1375 .init = stac92xx_init,
1376 .free = stac92xx_free,
1378 .resume = stac92xx_resume,
1382 enum { STAC7661_VAIO };
1384 static struct hda_board_config stac7661_cfg_tbl[] = {
1385 { .modelname = "vaio", .config = STAC7661_VAIO },
1386 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81e6,
1387 .config = STAC7661_VAIO },
1388 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81ef,
1389 .config = STAC7661_VAIO },
1393 static int patch_stac7661(struct hda_codec *codec)
1395 struct sigmatel_spec *spec;
1398 board_config = snd_hda_check_board_config(codec, stac7661_cfg_tbl);
1399 if (board_config < 0)
1400 /* unknown config, let generic-parser do its job... */
1401 return snd_hda_parse_generic_codec(codec);
1403 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1408 switch (board_config) {
1410 spec->mixer = vaio_mixer;
1411 spec->init = vaio_init;
1412 spec->multiout.max_channels = 2;
1413 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
1414 spec->multiout.dac_nids = vaio_dacs;
1415 spec->multiout.hp_nid = VAIO_HP_DAC;
1416 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
1417 spec->adc_nids = vaio_adcs;
1418 spec->input_mux = &vaio_mux;
1419 spec->mux_nids = vaio_mux_nids;
1423 codec->patch_ops = stac7661_patch_ops;
1431 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
1432 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
1433 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
1434 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
1435 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
1436 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
1437 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
1438 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
1439 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac922x },
1440 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac922x },
1441 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac922x },
1442 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac922x },
1443 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac922x },
1444 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac922x },
1445 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
1446 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
1447 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
1448 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
1449 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
1450 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
1451 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
1452 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
1453 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
1454 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
1455 { .id = 0x83847661, .name = "STAC7661", .patch = patch_stac7661 },