]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - sound/pci/hda/patch_sigmatel.c
[ALSA] hda_intel prefer 24bit instead of 20bit
[mirror_ubuntu-zesty-kernel.git] / sound / pci / hda / patch_sigmatel.c
CommitLineData
2f2f4251
M
1/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for SigmaTel STAC92xx
5 *
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
403d1944 7 * Matt Porter <mporter@embeddedalley.com>
2f2f4251
M
8 *
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11 *
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.
16 *
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.
21 *
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
25 */
26
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>
c7d4b2fa 33#include <sound/asoundef.h>
2f2f4251
M
34#include "hda_codec.h"
35#include "hda_local.h"
36
4e55096e
M
37#define NUM_CONTROL_ALLOC 32
38#define STAC_HP_EVENT 0x37
39#define STAC_UNSOL_ENABLE (AC_USRSP_EN | STAC_HP_EVENT)
40
403d1944
MP
41#define STAC_REF 0
42#define STAC_D945GTP3 1
43#define STAC_D945GTP5 2
62fe78e9 44#define STAC_MACMINI 3
93ed1503
TD
45#define STAC_922X_MODELS 4 /* number of 922x models */
46#define STAC_D965_3ST 4
47#define STAC_D965_5ST 5
48#define STAC_927X_MODELS 6 /* number of 922x models */
403d1944 49
2f2f4251 50struct sigmatel_spec {
c8b6bf9b 51 struct snd_kcontrol_new *mixers[4];
c7d4b2fa
M
52 unsigned int num_mixers;
53
403d1944 54 int board_config;
c7d4b2fa 55 unsigned int surr_switch: 1;
403d1944
MP
56 unsigned int line_switch: 1;
57 unsigned int mic_switch: 1;
3cc08dc6 58 unsigned int alt_switch: 1;
82bc955f 59 unsigned int hp_detect: 1;
62fe78e9 60 unsigned int gpio_mute: 1;
c7d4b2fa 61
2f2f4251
M
62 /* playback */
63 struct hda_multi_out multiout;
3cc08dc6 64 hda_nid_t dac_nids[5];
2f2f4251
M
65
66 /* capture */
67 hda_nid_t *adc_nids;
2f2f4251 68 unsigned int num_adcs;
dabbed6f
M
69 hda_nid_t *mux_nids;
70 unsigned int num_muxes;
dabbed6f 71 hda_nid_t dig_in_nid;
2f2f4251 72
2f2f4251
M
73 /* pin widgets */
74 hda_nid_t *pin_nids;
75 unsigned int num_pins;
2f2f4251 76 unsigned int *pin_configs;
11b44bbd 77 unsigned int *bios_pin_configs;
2f2f4251
M
78
79 /* codec specific stuff */
80 struct hda_verb *init;
c8b6bf9b 81 struct snd_kcontrol_new *mixer;
2f2f4251
M
82
83 /* capture source */
c7d4b2fa 84 struct hda_input_mux *input_mux;
3cc08dc6 85 unsigned int cur_mux[3];
2f2f4251 86
403d1944
MP
87 /* i/o switches */
88 unsigned int io_switch[2];
2f2f4251 89
c7d4b2fa
M
90 struct hda_pcm pcm_rec[2]; /* PCM information */
91
92 /* dynamic controls and input_mux */
93 struct auto_pin_cfg autocfg;
94 unsigned int num_kctl_alloc, num_kctl_used;
c8b6bf9b 95 struct snd_kcontrol_new *kctl_alloc;
c7d4b2fa 96 struct hda_input_mux private_imux;
2f2f4251
M
97};
98
99static hda_nid_t stac9200_adc_nids[1] = {
100 0x03,
101};
102
103static hda_nid_t stac9200_mux_nids[1] = {
104 0x0c,
105};
106
107static hda_nid_t stac9200_dac_nids[1] = {
108 0x02,
109};
110
2f2f4251
M
111static hda_nid_t stac922x_adc_nids[2] = {
112 0x06, 0x07,
113};
114
115static hda_nid_t stac922x_mux_nids[2] = {
116 0x12, 0x13,
117};
118
3cc08dc6
MP
119static hda_nid_t stac927x_adc_nids[3] = {
120 0x07, 0x08, 0x09
121};
122
123static hda_nid_t stac927x_mux_nids[3] = {
124 0x15, 0x16, 0x17
125};
126
f3302a59
MP
127static hda_nid_t stac9205_adc_nids[2] = {
128 0x12, 0x13
129};
130
131static hda_nid_t stac9205_mux_nids[2] = {
132 0x19, 0x1a
133};
134
c7d4b2fa 135static hda_nid_t stac9200_pin_nids[8] = {
93ed1503
TD
136 0x08, 0x09, 0x0d, 0x0e,
137 0x0f, 0x10, 0x11, 0x12,
2f2f4251
M
138};
139
140static hda_nid_t stac922x_pin_nids[10] = {
141 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
142 0x0f, 0x10, 0x11, 0x15, 0x1b,
143};
144
3cc08dc6
MP
145static hda_nid_t stac927x_pin_nids[14] = {
146 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
147 0x0f, 0x10, 0x11, 0x12, 0x13,
148 0x14, 0x21, 0x22, 0x23,
149};
150
f3302a59
MP
151static hda_nid_t stac9205_pin_nids[12] = {
152 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
153 0x0f, 0x14, 0x16, 0x17, 0x18,
154 0x21, 0x22,
155
156};
157
c8b6bf9b 158static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
2f2f4251
M
159{
160 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
161 struct sigmatel_spec *spec = codec->spec;
c7d4b2fa 162 return snd_hda_input_mux_info(spec->input_mux, uinfo);
2f2f4251
M
163}
164
c8b6bf9b 165static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2f2f4251
M
166{
167 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
168 struct sigmatel_spec *spec = codec->spec;
169 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
170
171 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
172 return 0;
173}
174
c8b6bf9b 175static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2f2f4251
M
176{
177 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
178 struct sigmatel_spec *spec = codec->spec;
179 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
180
c7d4b2fa 181 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
2f2f4251
M
182 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
183}
184
c7d4b2fa 185static struct hda_verb stac9200_core_init[] = {
2f2f4251 186 /* set dac0mux for dac converter */
c7d4b2fa 187 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2f2f4251
M
188 {}
189};
190
c7d4b2fa 191static struct hda_verb stac922x_core_init[] = {
2f2f4251 192 /* set master volume and direct control */
c7d4b2fa 193 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
2f2f4251
M
194 {}
195};
196
93ed1503 197static struct hda_verb d965_core_init[] = {
19039bd0 198 /* set master volume and direct control */
93ed1503 199 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
19039bd0
TI
200 /* unmute node 0x1b */
201 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
202 /* select node 0x03 as DAC */
203 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
204 {}
205};
206
3cc08dc6
MP
207static struct hda_verb stac927x_core_init[] = {
208 /* set master volume and direct control */
209 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
210 {}
211};
212
f3302a59
MP
213static struct hda_verb stac9205_core_init[] = {
214 /* set master volume and direct control */
215 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
216 {}
217};
218
c8b6bf9b 219static struct snd_kcontrol_new stac9200_mixer[] = {
2f2f4251
M
220 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
221 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
222 {
223 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
224 .name = "Input Source",
225 .count = 1,
226 .info = stac92xx_mux_enum_info,
227 .get = stac92xx_mux_enum_get,
228 .put = stac92xx_mux_enum_put,
229 },
230 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
231 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
c7d4b2fa 232 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
2f2f4251
M
233 { } /* end */
234};
235
c7d4b2fa 236/* This needs to be generated dynamically based on sequence */
c8b6bf9b 237static struct snd_kcontrol_new stac922x_mixer[] = {
2f2f4251
M
238 {
239 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
240 .name = "Input Source",
241 .count = 1,
242 .info = stac92xx_mux_enum_info,
243 .get = stac92xx_mux_enum_get,
244 .put = stac92xx_mux_enum_put,
245 },
246 HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT),
0fd1708a 247 HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT),
2f2f4251
M
248 HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT),
249 { } /* end */
250};
251
19039bd0
TI
252/* This needs to be generated dynamically based on sequence */
253static struct snd_kcontrol_new stac9227_mixer[] = {
254 {
255 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
256 .name = "Input Source",
257 .count = 1,
258 .info = stac92xx_mux_enum_info,
259 .get = stac92xx_mux_enum_get,
260 .put = stac92xx_mux_enum_put,
261 },
262 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
263 HDA_CODEC_MUTE("Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
264 { } /* end */
265};
266
3cc08dc6
MP
267static snd_kcontrol_new_t stac927x_mixer[] = {
268 {
269 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
270 .name = "Input Source",
271 .count = 1,
272 .info = stac92xx_mux_enum_info,
273 .get = stac92xx_mux_enum_get,
274 .put = stac92xx_mux_enum_put,
275 },
276 HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT),
277 HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT),
278 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
279 { } /* end */
280};
281
f3302a59
MP
282static snd_kcontrol_new_t stac9205_mixer[] = {
283 {
284 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
285 .name = "Input Source",
286 .count = 1,
287 .info = stac92xx_mux_enum_info,
288 .get = stac92xx_mux_enum_get,
289 .put = stac92xx_mux_enum_put,
290 },
291 HDA_CODEC_VOLUME("InMux Capture Volume", 0x19, 0x0, HDA_OUTPUT),
292 HDA_CODEC_VOLUME("InVol Capture Volume", 0x1b, 0x0, HDA_INPUT),
293 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1d, 0x0, HDA_OUTPUT),
294 { } /* end */
295};
296
2f2f4251
M
297static int stac92xx_build_controls(struct hda_codec *codec)
298{
299 struct sigmatel_spec *spec = codec->spec;
300 int err;
c7d4b2fa 301 int i;
2f2f4251
M
302
303 err = snd_hda_add_new_ctls(codec, spec->mixer);
304 if (err < 0)
305 return err;
c7d4b2fa
M
306
307 for (i = 0; i < spec->num_mixers; i++) {
308 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
309 if (err < 0)
310 return err;
311 }
312
dabbed6f
M
313 if (spec->multiout.dig_out_nid) {
314 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
315 if (err < 0)
316 return err;
317 }
318 if (spec->dig_in_nid) {
319 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
320 if (err < 0)
321 return err;
322 }
323 return 0;
2f2f4251
M
324}
325
403d1944 326static unsigned int ref9200_pin_configs[8] = {
dabbed6f 327 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
2f2f4251
M
328 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
329};
330
403d1944
MP
331static unsigned int *stac9200_brd_tbl[] = {
332 ref9200_pin_configs,
333};
334
335static struct hda_board_config stac9200_cfg_tbl[] = {
336 { .modelname = "ref",
337 .pci_subvendor = PCI_VENDOR_ID_INTEL,
338 .pci_subdevice = 0x2668, /* DFI LanParty */
339 .config = STAC_REF },
340 {} /* terminator */
341};
342
343static unsigned int ref922x_pin_configs[10] = {
344 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
345 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
2f2f4251
M
346 0x40000100, 0x40000100,
347};
348
403d1944 349static unsigned int d945gtp3_pin_configs[10] = {
869264c4 350 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
403d1944
MP
351 0x40000100, 0x40000100, 0x40000100, 0x40000100,
352 0x02a19120, 0x40000100,
353};
354
355static unsigned int d945gtp5_pin_configs[10] = {
869264c4
MP
356 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
357 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
403d1944
MP
358 0x02a19320, 0x40000100,
359};
360
19039bd0
TI
361static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
362 [STAC_REF] = ref922x_pin_configs,
363 [STAC_D945GTP3] = d945gtp3_pin_configs,
364 [STAC_D945GTP5] = d945gtp5_pin_configs,
7c3dec06 365 [STAC_MACMINI] = d945gtp5_pin_configs,
403d1944
MP
366};
367
368static struct hda_board_config stac922x_cfg_tbl[] = {
93ed1503
TD
369 { .modelname = "5stack", .config = STAC_D945GTP5 },
370 { .modelname = "3stack", .config = STAC_D945GTP3 },
403d1944
MP
371 { .modelname = "ref",
372 .pci_subvendor = PCI_VENDOR_ID_INTEL,
373 .pci_subdevice = 0x2668, /* DFI LanParty */
374 .config = STAC_REF }, /* SigmaTel reference board */
948a4db2 375 /* Intel 945G based systems */
403d1944
MP
376 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
377 .pci_subdevice = 0x0101,
378 .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */
353b9e66
TI
379 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
380 .pci_subdevice = 0x0202,
948a4db2 381 .config = STAC_D945GTP3 }, /* Intel D945GNT - 3 Stack */
353b9e66 382 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
948a4db2
TD
383 .pci_subdevice = 0x0606,
384 .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */
385 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
386 .pci_subdevice = 0x0601,
387 .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */
388 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
389 .pci_subdevice = 0x0111,
390 .config = STAC_D945GTP3 }, /* Intel D945GZP - 3 Stack */
391 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
392 .pci_subdevice = 0x1115,
393 .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */
394 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
395 .pci_subdevice = 0x1116,
396 .config = STAC_D945GTP3 }, /* Intel D945GBO - 3 Stack */
397 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
398 .pci_subdevice = 0x1117,
399 .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */
400 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
401 .pci_subdevice = 0x1118,
402 .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */
403 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
404 .pci_subdevice = 0x1119,
405 .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */
406 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
407 .pci_subdevice = 0x8826,
408 .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */
409 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
410 .pci_subdevice = 0x5049,
411 .config = STAC_D945GTP3 }, /* Intel D945GCZ - 3 Stack */
412 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
413 .pci_subdevice = 0x5055,
414 .config = STAC_D945GTP3 }, /* Intel D945GCZ - 3 Stack */
415 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
416 .pci_subdevice = 0x5048,
417 .config = STAC_D945GTP3 }, /* Intel D945GPB - 3 Stack */
418 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
419 .pci_subdevice = 0x0110,
420 .config = STAC_D945GTP3 }, /* Intel D945GLR - 3 Stack */
403d1944
MP
421 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
422 .pci_subdevice = 0x0404,
423 .config = STAC_D945GTP5 }, /* Intel D945GTP - 5 Stack */
424 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
425 .pci_subdevice = 0x0303,
426 .config = STAC_D945GTP5 }, /* Intel D945GNT - 5 Stack */
427 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
428 .pci_subdevice = 0x0013,
429 .config = STAC_D945GTP5 }, /* Intel D955XBK - 5 Stack */
d62c40e0
MP
430 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
431 .pci_subdevice = 0x0417,
432 .config = STAC_D945GTP5 }, /* Intel D975XBK - 5 Stack */
948a4db2
TD
433 /* Intel 945P based systems */
434 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
435 .pci_subdevice = 0x0b0b,
436 .config = STAC_D945GTP3 }, /* Intel D945PSN - 3 Stack */
437 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
438 .pci_subdevice = 0x0112,
439 .config = STAC_D945GTP3 }, /* Intel D945PLN - 3 Stack */
440 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
441 .pci_subdevice = 0x0d0d,
442 .config = STAC_D945GTP3 }, /* Intel D945PLM - 3 Stack */
443 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
444 .pci_subdevice = 0x0909,
445 .config = STAC_D945GTP3 }, /* Intel D945PAW - 3 Stack */
446 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
447 .pci_subdevice = 0x0505,
448 .config = STAC_D945GTP3 }, /* Intel D945PLM - 3 Stack */
449 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
450 .pci_subdevice = 0x0707,
451 .config = STAC_D945GTP5 }, /* Intel D945PSV - 5 Stack */
452 /* other systems */
62fe78e9
SR
453 { .pci_subvendor = 0x8384,
454 .pci_subdevice = 0x7680,
455 .config = STAC_MACMINI }, /* Apple Mac Mini (early 2006) */
403d1944
MP
456 {} /* terminator */
457};
458
3cc08dc6 459static unsigned int ref927x_pin_configs[14] = {
93ed1503
TD
460 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
461 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
462 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
463 0x01c42190, 0x40000100,
3cc08dc6
MP
464};
465
93ed1503 466static unsigned int d965_3st_pin_configs[14] = {
81d3dbde
TD
467 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
468 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
469 0x40000100, 0x40000100, 0x40000100, 0x40000100,
470 0x40000100, 0x40000100
471};
472
93ed1503
TD
473static unsigned int d965_5st_pin_configs[14] = {
474 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
475 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
476 0x40000100, 0x40000100, 0x40000100, 0x01442070,
477 0x40000100, 0x40000100
478};
479
480static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
81d3dbde 481 [STAC_REF] = ref927x_pin_configs,
93ed1503
TD
482 [STAC_D965_3ST] = d965_3st_pin_configs,
483 [STAC_D965_5ST] = d965_5st_pin_configs,
3cc08dc6
MP
484};
485
486static struct hda_board_config stac927x_cfg_tbl[] = {
93ed1503
TD
487 { .modelname = "5stack", .config = STAC_D965_5ST },
488 { .modelname = "3stack", .config = STAC_D965_3ST },
3cc08dc6
MP
489 { .modelname = "ref",
490 .pci_subvendor = PCI_VENDOR_ID_INTEL,
491 .pci_subdevice = 0x2668, /* DFI LanParty */
492 .config = STAC_REF }, /* SigmaTel reference board */
81d3dbde
TD
493 /* Intel 946 based systems */
494 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
495 .pci_subdevice = 0x3d01,
93ed1503 496 .config = STAC_D965_3ST }, /* D946 configuration */
81d3dbde
TD
497 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
498 .pci_subdevice = 0xa301,
93ed1503
TD
499 .config = STAC_D965_3ST }, /* Intel D946GZT - 3 stack */
500 /* 965 based 3 stack systems */
81d3dbde
TD
501 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
502 .pci_subdevice = 0x2116,
93ed1503 503 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
81d3dbde
TD
504 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
505 .pci_subdevice = 0x2115,
93ed1503 506 .config = STAC_D965_3ST }, /* Intel DQ965WC - 3 Stack */
81d3dbde
TD
507 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
508 .pci_subdevice = 0x2114,
93ed1503 509 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
81d3dbde
TD
510 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
511 .pci_subdevice = 0x2113,
93ed1503 512 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
81d3dbde
TD
513 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
514 .pci_subdevice = 0x2112,
93ed1503 515 .config = STAC_D965_3ST }, /* Intel DG965MS - 3 Stack */
81d3dbde
TD
516 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
517 .pci_subdevice = 0x2111,
93ed1503 518 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
81d3dbde
TD
519 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
520 .pci_subdevice = 0x2110,
93ed1503 521 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
81d3dbde
TD
522 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
523 .pci_subdevice = 0x2009,
93ed1503 524 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
81d3dbde
TD
525 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
526 .pci_subdevice = 0x2008,
93ed1503 527 .config = STAC_D965_3ST }, /* Intel DQ965GF - 3 Stack */
81d3dbde
TD
528 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
529 .pci_subdevice = 0x2007,
93ed1503 530 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
81d3dbde
TD
531 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
532 .pci_subdevice = 0x2006,
93ed1503 533 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
81d3dbde
TD
534 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
535 .pci_subdevice = 0x2005,
93ed1503 536 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
81d3dbde
TD
537 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
538 .pci_subdevice = 0x2004,
93ed1503 539 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
81d3dbde
TD
540 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
541 .pci_subdevice = 0x2003,
93ed1503 542 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
81d3dbde
TD
543 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
544 .pci_subdevice = 0x2002,
93ed1503 545 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
81d3dbde
TD
546 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
547 .pci_subdevice = 0x2001,
93ed1503
TD
548 .config = STAC_D965_3ST }, /* Intel DQ965GF - 3 Stack */
549 /* 965 based 5 stack systems */
550 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
551 .pci_subdevice = 0x2301,
552 .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
553 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
554 .pci_subdevice = 0x2302,
555 .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
556 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
557 .pci_subdevice = 0x2303,
558 .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
559 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
560 .pci_subdevice = 0x2304,
561 .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
562 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
563 .pci_subdevice = 0x2305,
564 .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
565 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
566 .pci_subdevice = 0x2501,
567 .config = STAC_D965_5ST }, /* Intel DG965MQ - 5 Stack */
568 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
569 .pci_subdevice = 0x2502,
570 .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
571 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
572 .pci_subdevice = 0x2503,
573 .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
574 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
575 .pci_subdevice = 0x2504,
576 .config = STAC_D965_5ST }, /* Intel DQ965GF - 5 Stack */
3cc08dc6
MP
577 {} /* terminator */
578};
579
f3302a59
MP
580static unsigned int ref9205_pin_configs[12] = {
581 0x40000100, 0x40000100, 0x01016011, 0x01014010,
582 0x01813122, 0x01a19021, 0x40000100, 0x40000100,
583 0x40000100, 0x40000100, 0x01441030, 0x01c41030
584};
585
586static unsigned int *stac9205_brd_tbl[] = {
587 ref9205_pin_configs,
588};
589
590static struct hda_board_config stac9205_cfg_tbl[] = {
591 { .modelname = "ref",
592 .pci_subvendor = PCI_VENDOR_ID_INTEL,
593 .pci_subdevice = 0x2668, /* DFI LanParty */
594 .config = STAC_REF }, /* SigmaTel reference board */
2c7782b4
TI
595 /* Dell laptops have BIOS problem */
596 { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01b5,
597 .config = STAC_REF }, /* Dell Inspiron 630m */
598 { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01c2,
599 .config = STAC_REF }, /* Dell Latitude D620 */
600 { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01cb,
601 .config = STAC_REF }, /* Dell Latitude 120L */
f3302a59
MP
602 {} /* terminator */
603};
604
11b44bbd
RF
605static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
606{
607 int i;
608 struct sigmatel_spec *spec = codec->spec;
609
610 if (! spec->bios_pin_configs) {
611 spec->bios_pin_configs = kcalloc(spec->num_pins,
612 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
613 if (! spec->bios_pin_configs)
614 return -ENOMEM;
615 }
616
617 for (i = 0; i < spec->num_pins; i++) {
618 hda_nid_t nid = spec->pin_nids[i];
619 unsigned int pin_cfg;
620
621 pin_cfg = snd_hda_codec_read(codec, nid, 0,
622 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
623 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
624 nid, pin_cfg);
625 spec->bios_pin_configs[i] = pin_cfg;
626 }
627
628 return 0;
629}
630
2f2f4251
M
631static void stac92xx_set_config_regs(struct hda_codec *codec)
632{
633 int i;
634 struct sigmatel_spec *spec = codec->spec;
635 unsigned int pin_cfg;
636
11b44bbd
RF
637 if (! spec->pin_nids || ! spec->pin_configs)
638 return;
639
640 for (i = 0; i < spec->num_pins; i++) {
2f2f4251
M
641 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
642 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
643 spec->pin_configs[i] & 0x000000ff);
644 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
645 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
646 (spec->pin_configs[i] & 0x0000ff00) >> 8);
647 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
648 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
649 (spec->pin_configs[i] & 0x00ff0000) >> 16);
650 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
651 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
652 spec->pin_configs[i] >> 24);
653 pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0,
654 AC_VERB_GET_CONFIG_DEFAULT,
655 0x00);
403d1944 656 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg);
2f2f4251
M
657 }
658}
2f2f4251 659
dabbed6f 660/*
c7d4b2fa 661 * Analog playback callbacks
dabbed6f 662 */
c7d4b2fa
M
663static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
664 struct hda_codec *codec,
c8b6bf9b 665 struct snd_pcm_substream *substream)
2f2f4251 666{
dabbed6f 667 struct sigmatel_spec *spec = codec->spec;
c7d4b2fa 668 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2f2f4251
M
669}
670
2f2f4251
M
671static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
672 struct hda_codec *codec,
673 unsigned int stream_tag,
674 unsigned int format,
c8b6bf9b 675 struct snd_pcm_substream *substream)
2f2f4251
M
676{
677 struct sigmatel_spec *spec = codec->spec;
403d1944 678 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2f2f4251
M
679}
680
681static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
682 struct hda_codec *codec,
c8b6bf9b 683 struct snd_pcm_substream *substream)
2f2f4251
M
684{
685 struct sigmatel_spec *spec = codec->spec;
686 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
687}
688
dabbed6f
M
689/*
690 * Digital playback callbacks
691 */
692static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
693 struct hda_codec *codec,
c8b6bf9b 694 struct snd_pcm_substream *substream)
dabbed6f
M
695{
696 struct sigmatel_spec *spec = codec->spec;
697 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
698}
699
700static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
701 struct hda_codec *codec,
c8b6bf9b 702 struct snd_pcm_substream *substream)
dabbed6f
M
703{
704 struct sigmatel_spec *spec = codec->spec;
705 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
706}
707
708
2f2f4251
M
709/*
710 * Analog capture callbacks
711 */
712static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
713 struct hda_codec *codec,
714 unsigned int stream_tag,
715 unsigned int format,
c8b6bf9b 716 struct snd_pcm_substream *substream)
2f2f4251
M
717{
718 struct sigmatel_spec *spec = codec->spec;
719
720 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
721 stream_tag, 0, format);
722 return 0;
723}
724
725static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
726 struct hda_codec *codec,
c8b6bf9b 727 struct snd_pcm_substream *substream)
2f2f4251
M
728{
729 struct sigmatel_spec *spec = codec->spec;
730
731 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
732 return 0;
733}
734
dabbed6f
M
735static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
736 .substreams = 1,
737 .channels_min = 2,
738 .channels_max = 2,
739 /* NID is set in stac92xx_build_pcms */
740 .ops = {
741 .open = stac92xx_dig_playback_pcm_open,
742 .close = stac92xx_dig_playback_pcm_close
743 },
744};
745
746static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
747 .substreams = 1,
748 .channels_min = 2,
749 .channels_max = 2,
750 /* NID is set in stac92xx_build_pcms */
751};
752
2f2f4251
M
753static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
754 .substreams = 1,
755 .channels_min = 2,
c7d4b2fa 756 .channels_max = 8,
2f2f4251
M
757 .nid = 0x02, /* NID to query formats and rates */
758 .ops = {
759 .open = stac92xx_playback_pcm_open,
760 .prepare = stac92xx_playback_pcm_prepare,
761 .cleanup = stac92xx_playback_pcm_cleanup
762 },
763};
764
3cc08dc6
MP
765static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
766 .substreams = 1,
767 .channels_min = 2,
768 .channels_max = 2,
769 .nid = 0x06, /* NID to query formats and rates */
770 .ops = {
771 .open = stac92xx_playback_pcm_open,
772 .prepare = stac92xx_playback_pcm_prepare,
773 .cleanup = stac92xx_playback_pcm_cleanup
774 },
775};
776
2f2f4251
M
777static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
778 .substreams = 2,
779 .channels_min = 2,
780 .channels_max = 2,
3cc08dc6 781 /* NID is set in stac92xx_build_pcms */
2f2f4251
M
782 .ops = {
783 .prepare = stac92xx_capture_pcm_prepare,
784 .cleanup = stac92xx_capture_pcm_cleanup
785 },
786};
787
788static int stac92xx_build_pcms(struct hda_codec *codec)
789{
790 struct sigmatel_spec *spec = codec->spec;
791 struct hda_pcm *info = spec->pcm_rec;
792
793 codec->num_pcms = 1;
794 codec->pcm_info = info;
795
c7d4b2fa 796 info->name = "STAC92xx Analog";
2f2f4251 797 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2f2f4251 798 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
3cc08dc6
MP
799 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
800
801 if (spec->alt_switch) {
802 codec->num_pcms++;
803 info++;
804 info->name = "STAC92xx Analog Alt";
805 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
806 }
2f2f4251 807
dabbed6f
M
808 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
809 codec->num_pcms++;
810 info++;
811 info->name = "STAC92xx Digital";
812 if (spec->multiout.dig_out_nid) {
813 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
814 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
815 }
816 if (spec->dig_in_nid) {
817 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
818 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
819 }
820 }
821
2f2f4251
M
822 return 0;
823}
824
c960a03b
TI
825static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
826{
827 unsigned int pincap = snd_hda_param_read(codec, nid,
828 AC_PAR_PIN_CAP);
829 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
830 if (pincap & AC_PINCAP_VREF_100)
831 return AC_PINCTL_VREF_100;
832 if (pincap & AC_PINCAP_VREF_80)
833 return AC_PINCTL_VREF_80;
834 if (pincap & AC_PINCAP_VREF_50)
835 return AC_PINCTL_VREF_50;
836 if (pincap & AC_PINCAP_VREF_GRD)
837 return AC_PINCTL_VREF_GRD;
838 return 0;
839}
840
403d1944
MP
841static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
842
843{
844 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
845}
846
847static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
848{
849 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
850 uinfo->count = 1;
851 uinfo->value.integer.min = 0;
852 uinfo->value.integer.max = 1;
853 return 0;
854}
855
856static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
857{
858 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
859 struct sigmatel_spec *spec = codec->spec;
860 int io_idx = kcontrol-> private_value & 0xff;
861
862 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
863 return 0;
864}
865
866static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
867{
868 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
869 struct sigmatel_spec *spec = codec->spec;
870 hda_nid_t nid = kcontrol->private_value >> 8;
871 int io_idx = kcontrol-> private_value & 0xff;
872 unsigned short val = ucontrol->value.integer.value[0];
873
874 spec->io_switch[io_idx] = val;
875
876 if (val)
877 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
c960a03b
TI
878 else {
879 unsigned int pinctl = AC_PINCTL_IN_EN;
880 if (io_idx) /* set VREF for mic */
881 pinctl |= stac92xx_get_vref(codec, nid);
882 stac92xx_auto_set_pinctl(codec, nid, pinctl);
883 }
403d1944
MP
884 return 1;
885}
886
887#define STAC_CODEC_IO_SWITCH(xname, xpval) \
888 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
889 .name = xname, \
890 .index = 0, \
891 .info = stac92xx_io_switch_info, \
892 .get = stac92xx_io_switch_get, \
893 .put = stac92xx_io_switch_put, \
894 .private_value = xpval, \
895 }
896
897
c7d4b2fa
M
898enum {
899 STAC_CTL_WIDGET_VOL,
900 STAC_CTL_WIDGET_MUTE,
403d1944 901 STAC_CTL_WIDGET_IO_SWITCH,
c7d4b2fa
M
902};
903
c8b6bf9b 904static struct snd_kcontrol_new stac92xx_control_templates[] = {
c7d4b2fa
M
905 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
906 HDA_CODEC_MUTE(NULL, 0, 0, 0),
403d1944 907 STAC_CODEC_IO_SWITCH(NULL, 0),
c7d4b2fa
M
908};
909
910/* add dynamic controls */
911static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
912{
c8b6bf9b 913 struct snd_kcontrol_new *knew;
c7d4b2fa
M
914
915 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
916 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
917
918 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
919 if (! knew)
920 return -ENOMEM;
921 if (spec->kctl_alloc) {
922 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
923 kfree(spec->kctl_alloc);
924 }
925 spec->kctl_alloc = knew;
926 spec->num_kctl_alloc = num;
927 }
928
929 knew = &spec->kctl_alloc[spec->num_kctl_used];
930 *knew = stac92xx_control_templates[type];
82fe0c58 931 knew->name = kstrdup(name, GFP_KERNEL);
c7d4b2fa
M
932 if (! knew->name)
933 return -ENOMEM;
934 knew->private_value = val;
935 spec->num_kctl_used++;
936 return 0;
937}
938
403d1944
MP
939/* flag inputs as additional dynamic lineouts */
940static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
941{
942 struct sigmatel_spec *spec = codec->spec;
943
944 switch (cfg->line_outs) {
945 case 3:
946 /* add line-in as side */
947 if (cfg->input_pins[AUTO_PIN_LINE]) {
948 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE];
949 spec->line_switch = 1;
950 cfg->line_outs++;
951 }
952 break;
953 case 2:
954 /* add line-in as clfe and mic as side */
955 if (cfg->input_pins[AUTO_PIN_LINE]) {
956 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE];
957 spec->line_switch = 1;
958 cfg->line_outs++;
959 }
960 if (cfg->input_pins[AUTO_PIN_MIC]) {
961 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC];
962 spec->mic_switch = 1;
963 cfg->line_outs++;
964 }
965 break;
966 case 1:
967 /* add line-in as surr and mic as clfe */
968 if (cfg->input_pins[AUTO_PIN_LINE]) {
969 cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE];
970 spec->line_switch = 1;
971 cfg->line_outs++;
972 }
973 if (cfg->input_pins[AUTO_PIN_MIC]) {
974 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC];
975 spec->mic_switch = 1;
976 cfg->line_outs++;
977 }
978 break;
979 }
980
981 return 0;
982}
983
3cc08dc6
MP
984/*
985 * XXX The line_out pin widget connection list may not be set to the
986 * desired DAC nid. This is the case on 927x where ports A and B can
987 * be routed to several DACs.
988 *
989 * This requires an analysis of the line-out/hp pin configuration
990 * to provide a best fit for pin/DAC configurations that are routable.
991 * For now, 927x DAC4 is not supported and 927x DAC1 output to ports
992 * A and B is not supported.
993 */
c7d4b2fa 994/* fill in the dac_nids table from the parsed pin configuration */
19039bd0
TI
995static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
996 const struct auto_pin_cfg *cfg)
c7d4b2fa
M
997{
998 struct sigmatel_spec *spec = codec->spec;
999 hda_nid_t nid;
1000 int i;
1001
1002 /* check the pins hardwired to audio widget */
1003 for (i = 0; i < cfg->line_outs; i++) {
1004 nid = cfg->line_out_pins[i];
1005 spec->multiout.dac_nids[i] = snd_hda_codec_read(codec, nid, 0,
1006 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1007 }
1008
82bc955f 1009 spec->multiout.num_dacs = cfg->line_outs;
c7d4b2fa
M
1010
1011 return 0;
1012}
1013
1014/* add playback controls from the parsed DAC table */
19039bd0
TI
1015static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec,
1016 const struct auto_pin_cfg *cfg)
c7d4b2fa
M
1017{
1018 char name[32];
19039bd0
TI
1019 static const char *chname[4] = {
1020 "Front", "Surround", NULL /*CLFE*/, "Side"
1021 };
c7d4b2fa
M
1022 hda_nid_t nid;
1023 int i, err;
1024
1025 for (i = 0; i < cfg->line_outs; i++) {
403d1944 1026 if (!spec->multiout.dac_nids[i])
c7d4b2fa
M
1027 continue;
1028
1029 nid = spec->multiout.dac_nids[i];
1030
1031 if (i == 2) {
1032 /* Center/LFE */
1033 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Center Playback Volume",
1034 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
1035 return err;
1036 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "LFE Playback Volume",
1037 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
1038 return err;
1039 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Center Playback Switch",
1040 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
1041 return err;
1042 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "LFE Playback Switch",
1043 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
1044 return err;
1045 } else {
1046 sprintf(name, "%s Playback Volume", chname[i]);
1047 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
1048 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
1049 return err;
1050 sprintf(name, "%s Playback Switch", chname[i]);
1051 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
1052 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
1053 return err;
1054 }
1055 }
1056
403d1944
MP
1057 if (spec->line_switch)
1058 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
1059 return err;
1060
1061 if (spec->mic_switch)
1062 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
1063 return err;
1064
c7d4b2fa
M
1065 return 0;
1066}
1067
1068/* add playback controls for HP output */
1069static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, struct auto_pin_cfg *cfg)
1070{
1071 struct sigmatel_spec *spec = codec->spec;
1072 hda_nid_t pin = cfg->hp_pin;
1073 hda_nid_t nid;
1074 int i, err;
4e55096e 1075 unsigned int wid_caps;
c7d4b2fa
M
1076
1077 if (! pin)
1078 return 0;
1079
54d17403 1080 wid_caps = get_wcaps(codec, pin);
505cb341 1081 if (wid_caps & AC_WCAP_UNSOL_CAP)
82bc955f 1082 spec->hp_detect = 1;
4e55096e 1083
c7d4b2fa
M
1084 nid = snd_hda_codec_read(codec, pin, 0, AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1085 for (i = 0; i < cfg->line_outs; i++) {
1086 if (! spec->multiout.dac_nids[i])
1087 continue;
1088 if (spec->multiout.dac_nids[i] == nid)
1089 return 0;
1090 }
1091
1092 spec->multiout.hp_nid = nid;
1093
1094 /* control HP volume/switch on the output mixer amp */
1095 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Headphone Playback Volume",
1096 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
1097 return err;
1098 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
1099 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
1100 return err;
1101
1102 return 0;
1103}
1104
1105/* create playback/capture controls for input pins */
1106static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
1107{
1108 struct sigmatel_spec *spec = codec->spec;
c7d4b2fa
M
1109 struct hda_input_mux *imux = &spec->private_imux;
1110 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1111 int i, j, k;
1112
1113 for (i = 0; i < AUTO_PIN_LAST; i++) {
1114 int index = -1;
1115 if (cfg->input_pins[i]) {
4a471b7d 1116 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
c7d4b2fa
M
1117
1118 for (j=0; j<spec->num_muxes; j++) {
1119 int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS);
1120 for (k=0; k<num_cons; k++)
1121 if (con_lst[k] == cfg->input_pins[i]) {
1122 index = k;
1123 break;
1124 }
1125 if (index >= 0)
1126 break;
1127 }
1128 imux->items[imux->num_items].index = index;
1129 imux->num_items++;
1130 }
1131 }
1132
62fe78e9
SR
1133 if (imux->num_items == 1) {
1134 /*
1135 * Set the current input for the muxes.
1136 * The STAC9221 has two input muxes with identical source
1137 * NID lists. Hopefully this won't get confused.
1138 */
1139 for (i = 0; i < spec->num_muxes; i++) {
1140 snd_hda_codec_write(codec, spec->mux_nids[i], 0,
1141 AC_VERB_SET_CONNECT_SEL,
1142 imux->items[0].index);
1143 }
1144 }
1145
c7d4b2fa
M
1146 return 0;
1147}
1148
c7d4b2fa
M
1149static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
1150{
1151 struct sigmatel_spec *spec = codec->spec;
1152 int i;
1153
1154 for (i = 0; i < spec->autocfg.line_outs; i++) {
1155 hda_nid_t nid = spec->autocfg.line_out_pins[i];
1156 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
1157 }
1158}
1159
1160static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
1161{
1162 struct sigmatel_spec *spec = codec->spec;
1163 hda_nid_t pin;
1164
1165 pin = spec->autocfg.hp_pin;
1166 if (pin) /* connect to front */
1167 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
1168}
1169
3cc08dc6 1170static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
c7d4b2fa
M
1171{
1172 struct sigmatel_spec *spec = codec->spec;
1173 int err;
1174
df694daa 1175 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
c7d4b2fa 1176 return err;
82bc955f 1177 if (! spec->autocfg.line_outs)
869264c4 1178 return 0; /* can't find valid pin config */
19039bd0 1179
403d1944
MP
1180 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
1181 return err;
19039bd0
TI
1182 if (spec->multiout.num_dacs == 0)
1183 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
1184 return err;
c7d4b2fa
M
1185
1186 if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
1187 (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 ||
1188 (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
1189 return err;
1190
1191 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
403d1944 1192 if (spec->multiout.max_channels > 2)
c7d4b2fa 1193 spec->surr_switch = 1;
c7d4b2fa 1194
82bc955f 1195 if (spec->autocfg.dig_out_pin)
3cc08dc6 1196 spec->multiout.dig_out_nid = dig_out;
82bc955f 1197 if (spec->autocfg.dig_in_pin)
3cc08dc6 1198 spec->dig_in_nid = dig_in;
c7d4b2fa
M
1199
1200 if (spec->kctl_alloc)
1201 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
1202
1203 spec->input_mux = &spec->private_imux;
1204
1205 return 1;
1206}
1207
82bc955f
TI
1208/* add playback controls for HP output */
1209static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
1210 struct auto_pin_cfg *cfg)
1211{
1212 struct sigmatel_spec *spec = codec->spec;
1213 hda_nid_t pin = cfg->hp_pin;
1214 unsigned int wid_caps;
1215
1216 if (! pin)
1217 return 0;
1218
1219 wid_caps = get_wcaps(codec, pin);
505cb341 1220 if (wid_caps & AC_WCAP_UNSOL_CAP)
82bc955f 1221 spec->hp_detect = 1;
82bc955f
TI
1222
1223 return 0;
1224}
1225
160ea0dc
RF
1226/* add playback controls for LFE output */
1227static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
1228 struct auto_pin_cfg *cfg)
1229{
1230 struct sigmatel_spec *spec = codec->spec;
1231 int err;
1232 hda_nid_t lfe_pin = 0x0;
1233 int i;
1234
1235 /*
1236 * search speaker outs and line outs for a mono speaker pin
1237 * with an amp. If one is found, add LFE controls
1238 * for it.
1239 */
1240 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
1241 hda_nid_t pin = spec->autocfg.speaker_pins[i];
1242 unsigned long wcaps = get_wcaps(codec, pin);
1243 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
1244 if (wcaps == AC_WCAP_OUT_AMP)
1245 /* found a mono speaker with an amp, must be lfe */
1246 lfe_pin = pin;
1247 }
1248
1249 /* if speaker_outs is 0, then speakers may be in line_outs */
1250 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
1251 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
1252 hda_nid_t pin = spec->autocfg.line_out_pins[i];
1253 unsigned long cfg;
1254 cfg = snd_hda_codec_read(codec, pin, 0,
1255 AC_VERB_GET_CONFIG_DEFAULT,
1256 0x00);
1257 if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) {
1258 unsigned long wcaps = get_wcaps(codec, pin);
1259 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
1260 if (wcaps == AC_WCAP_OUT_AMP)
1261 /* found a mono speaker with an amp,
1262 must be lfe */
1263 lfe_pin = pin;
1264 }
1265 }
1266 }
1267
1268 if (lfe_pin) {
1269 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
1270 "LFE Playback Volume",
1271 HDA_COMPOSE_AMP_VAL(lfe_pin, 1, 0,
1272 HDA_OUTPUT));
1273 if (err < 0)
1274 return err;
1275 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
1276 "LFE Playback Switch",
1277 HDA_COMPOSE_AMP_VAL(lfe_pin, 1, 0,
1278 HDA_OUTPUT));
1279 if (err < 0)
1280 return err;
1281 }
1282
1283 return 0;
1284}
1285
c7d4b2fa
M
1286static int stac9200_parse_auto_config(struct hda_codec *codec)
1287{
1288 struct sigmatel_spec *spec = codec->spec;
1289 int err;
1290
df694daa 1291 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
c7d4b2fa
M
1292 return err;
1293
1294 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
1295 return err;
1296
82bc955f
TI
1297 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
1298 return err;
1299
160ea0dc
RF
1300 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
1301 return err;
1302
82bc955f 1303 if (spec->autocfg.dig_out_pin)
c7d4b2fa 1304 spec->multiout.dig_out_nid = 0x05;
82bc955f 1305 if (spec->autocfg.dig_in_pin)
c7d4b2fa 1306 spec->dig_in_nid = 0x04;
c7d4b2fa
M
1307
1308 if (spec->kctl_alloc)
1309 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
1310
1311 spec->input_mux = &spec->private_imux;
1312
1313 return 1;
1314}
1315
62fe78e9
SR
1316/*
1317 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
1318 * funky external mute control using GPIO pins.
1319 */
1320
1321static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted)
1322{
1323 unsigned int gpiostate, gpiomask, gpiodir;
1324
1325 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
1326 AC_VERB_GET_GPIO_DATA, 0);
1327
1328 if (!muted)
1329 gpiostate |= (1 << pin);
1330 else
1331 gpiostate &= ~(1 << pin);
1332
1333 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
1334 AC_VERB_GET_GPIO_MASK, 0);
1335 gpiomask |= (1 << pin);
1336
1337 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
1338 AC_VERB_GET_GPIO_DIRECTION, 0);
1339 gpiodir |= (1 << pin);
1340
1341 /* AppleHDA seems to do this -- WTF is this verb?? */
1342 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
1343
1344 snd_hda_codec_write(codec, codec->afg, 0,
1345 AC_VERB_SET_GPIO_MASK, gpiomask);
1346 snd_hda_codec_write(codec, codec->afg, 0,
1347 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
1348
1349 msleep(1);
1350
1351 snd_hda_codec_write(codec, codec->afg, 0,
1352 AC_VERB_SET_GPIO_DATA, gpiostate);
1353}
1354
c7d4b2fa
M
1355static int stac92xx_init(struct hda_codec *codec)
1356{
1357 struct sigmatel_spec *spec = codec->spec;
82bc955f
TI
1358 struct auto_pin_cfg *cfg = &spec->autocfg;
1359 int i;
c7d4b2fa 1360
c7d4b2fa
M
1361 snd_hda_sequence_write(codec, spec->init);
1362
82bc955f
TI
1363 /* set up pins */
1364 if (spec->hp_detect) {
505cb341
TI
1365 /* Enable unsolicited responses on the HP widget */
1366 snd_hda_codec_write(codec, cfg->hp_pin, 0,
1367 AC_VERB_SET_UNSOLICITED_ENABLE,
1368 STAC_UNSOL_ENABLE);
82bc955f
TI
1369 /* fake event to set up pins */
1370 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
68a6abd9
TD
1371 /* enable the headphones by default. If/when unsol_event detection works, this will be ignored */
1372 stac92xx_auto_init_hp_out(codec);
82bc955f
TI
1373 } else {
1374 stac92xx_auto_init_multi_out(codec);
1375 stac92xx_auto_init_hp_out(codec);
1376 }
1377 for (i = 0; i < AUTO_PIN_LAST; i++) {
c960a03b
TI
1378 hda_nid_t nid = cfg->input_pins[i];
1379 if (nid) {
1380 unsigned int pinctl = AC_PINCTL_IN_EN;
1381 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
1382 pinctl |= stac92xx_get_vref(codec, nid);
1383 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1384 }
82bc955f
TI
1385 }
1386 if (cfg->dig_out_pin)
1387 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
1388 AC_PINCTL_OUT_EN);
1389 if (cfg->dig_in_pin)
1390 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
1391 AC_PINCTL_IN_EN);
1392
62fe78e9
SR
1393 if (spec->gpio_mute) {
1394 stac922x_gpio_mute(codec, 0, 0);
1395 stac922x_gpio_mute(codec, 1, 0);
1396 }
1397
c7d4b2fa
M
1398 return 0;
1399}
1400
2f2f4251
M
1401static void stac92xx_free(struct hda_codec *codec)
1402{
c7d4b2fa
M
1403 struct sigmatel_spec *spec = codec->spec;
1404 int i;
1405
1406 if (! spec)
1407 return;
1408
1409 if (spec->kctl_alloc) {
1410 for (i = 0; i < spec->num_kctl_used; i++)
1411 kfree(spec->kctl_alloc[i].name);
1412 kfree(spec->kctl_alloc);
1413 }
1414
11b44bbd
RF
1415 if (spec->bios_pin_configs)
1416 kfree(spec->bios_pin_configs);
1417
c7d4b2fa 1418 kfree(spec);
2f2f4251
M
1419}
1420
4e55096e
M
1421static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
1422 unsigned int flag)
1423{
1424 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1425 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
1426 snd_hda_codec_write(codec, nid, 0,
1427 AC_VERB_SET_PIN_WIDGET_CONTROL,
1428 pin_ctl | flag);
1429}
1430
1431static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
1432 unsigned int flag)
1433{
1434 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1435 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
1436 snd_hda_codec_write(codec, nid, 0,
1437 AC_VERB_SET_PIN_WIDGET_CONTROL,
1438 pin_ctl & ~flag);
1439}
1440
1441static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
1442{
1443 struct sigmatel_spec *spec = codec->spec;
1444 struct auto_pin_cfg *cfg = &spec->autocfg;
1445 int i, presence;
1446
1447 if ((res >> 26) != STAC_HP_EVENT)
1448 return;
1449
1450 presence = snd_hda_codec_read(codec, cfg->hp_pin, 0,
1451 AC_VERB_GET_PIN_SENSE, 0x00) >> 31;
1452
1453 if (presence) {
1454 /* disable lineouts, enable hp */
1455 for (i = 0; i < cfg->line_outs; i++)
1456 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
1457 AC_PINCTL_OUT_EN);
1458 stac92xx_set_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
1459 } else {
1460 /* enable lineouts, disable hp */
1461 for (i = 0; i < cfg->line_outs; i++)
1462 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
1463 AC_PINCTL_OUT_EN);
1464 stac92xx_reset_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
1465 }
1466}
1467
ff6fdc37
M
1468#ifdef CONFIG_PM
1469static int stac92xx_resume(struct hda_codec *codec)
1470{
1471 struct sigmatel_spec *spec = codec->spec;
1472 int i;
1473
1474 stac92xx_init(codec);
11b44bbd 1475 stac92xx_set_config_regs(codec);
ff6fdc37
M
1476 for (i = 0; i < spec->num_mixers; i++)
1477 snd_hda_resume_ctls(codec, spec->mixers[i]);
1478 if (spec->multiout.dig_out_nid)
1479 snd_hda_resume_spdif_out(codec);
1480 if (spec->dig_in_nid)
1481 snd_hda_resume_spdif_in(codec);
1482
1483 return 0;
1484}
1485#endif
1486
2f2f4251
M
1487static struct hda_codec_ops stac92xx_patch_ops = {
1488 .build_controls = stac92xx_build_controls,
1489 .build_pcms = stac92xx_build_pcms,
1490 .init = stac92xx_init,
1491 .free = stac92xx_free,
4e55096e 1492 .unsol_event = stac92xx_unsol_event,
ff6fdc37
M
1493#ifdef CONFIG_PM
1494 .resume = stac92xx_resume,
1495#endif
2f2f4251
M
1496};
1497
1498static int patch_stac9200(struct hda_codec *codec)
1499{
1500 struct sigmatel_spec *spec;
c7d4b2fa 1501 int err;
2f2f4251 1502
e560d8d8 1503 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2f2f4251
M
1504 if (spec == NULL)
1505 return -ENOMEM;
1506
1507 codec->spec = spec;
11b44bbd
RF
1508 spec->num_pins = 8;
1509 spec->pin_nids = stac9200_pin_nids;
403d1944 1510 spec->board_config = snd_hda_check_board_config(codec, stac9200_cfg_tbl);
11b44bbd
RF
1511 if (spec->board_config < 0) {
1512 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
1513 err = stac92xx_save_bios_config_regs(codec);
1514 if (err < 0) {
1515 stac92xx_free(codec);
1516 return err;
1517 }
1518 spec->pin_configs = spec->bios_pin_configs;
1519 } else {
403d1944
MP
1520 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
1521 stac92xx_set_config_regs(codec);
1522 }
2f2f4251
M
1523
1524 spec->multiout.max_channels = 2;
1525 spec->multiout.num_dacs = 1;
1526 spec->multiout.dac_nids = stac9200_dac_nids;
1527 spec->adc_nids = stac9200_adc_nids;
1528 spec->mux_nids = stac9200_mux_nids;
dabbed6f 1529 spec->num_muxes = 1;
c7d4b2fa
M
1530
1531 spec->init = stac9200_core_init;
2f2f4251 1532 spec->mixer = stac9200_mixer;
c7d4b2fa
M
1533
1534 err = stac9200_parse_auto_config(codec);
1535 if (err < 0) {
1536 stac92xx_free(codec);
1537 return err;
1538 }
2f2f4251
M
1539
1540 codec->patch_ops = stac92xx_patch_ops;
1541
1542 return 0;
1543}
1544
1545static int patch_stac922x(struct hda_codec *codec)
1546{
1547 struct sigmatel_spec *spec;
c7d4b2fa 1548 int err;
2f2f4251 1549
e560d8d8 1550 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2f2f4251
M
1551 if (spec == NULL)
1552 return -ENOMEM;
1553
1554 codec->spec = spec;
11b44bbd
RF
1555 spec->num_pins = 10;
1556 spec->pin_nids = stac922x_pin_nids;
403d1944 1557 spec->board_config = snd_hda_check_board_config(codec, stac922x_cfg_tbl);
11b44bbd
RF
1558 if (spec->board_config < 0) {
1559 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
1560 "using BIOS defaults\n");
1561 err = stac92xx_save_bios_config_regs(codec);
1562 if (err < 0) {
1563 stac92xx_free(codec);
1564 return err;
1565 }
1566 spec->pin_configs = spec->bios_pin_configs;
1567 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
403d1944
MP
1568 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
1569 stac92xx_set_config_regs(codec);
1570 }
2f2f4251 1571
c7d4b2fa
M
1572 spec->adc_nids = stac922x_adc_nids;
1573 spec->mux_nids = stac922x_mux_nids;
1574 spec->num_muxes = 2;
1575
1576 spec->init = stac922x_core_init;
2f2f4251 1577 spec->mixer = stac922x_mixer;
c7d4b2fa
M
1578
1579 spec->multiout.dac_nids = spec->dac_nids;
19039bd0 1580
3cc08dc6
MP
1581 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
1582 if (err < 0) {
1583 stac92xx_free(codec);
1584 return err;
1585 }
1586
62fe78e9
SR
1587 if (spec->board_config == STAC_MACMINI)
1588 spec->gpio_mute = 1;
1589
3cc08dc6
MP
1590 codec->patch_ops = stac92xx_patch_ops;
1591
1592 return 0;
1593}
1594
1595static int patch_stac927x(struct hda_codec *codec)
1596{
1597 struct sigmatel_spec *spec;
1598 int err;
1599
1600 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1601 if (spec == NULL)
1602 return -ENOMEM;
1603
1604 codec->spec = spec;
11b44bbd
RF
1605 spec->num_pins = 14;
1606 spec->pin_nids = stac927x_pin_nids;
3cc08dc6 1607 spec->board_config = snd_hda_check_board_config(codec, stac927x_cfg_tbl);
11b44bbd 1608 if (spec->board_config < 0) {
3cc08dc6 1609 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
11b44bbd
RF
1610 err = stac92xx_save_bios_config_regs(codec);
1611 if (err < 0) {
1612 stac92xx_free(codec);
1613 return err;
1614 }
1615 spec->pin_configs = spec->bios_pin_configs;
1616 } else if (stac927x_brd_tbl[spec->board_config] != NULL) {
3cc08dc6
MP
1617 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
1618 stac92xx_set_config_regs(codec);
1619 }
1620
81d3dbde 1621 switch (spec->board_config) {
93ed1503 1622 case STAC_D965_3ST:
81d3dbde
TD
1623 spec->adc_nids = stac927x_adc_nids;
1624 spec->mux_nids = stac927x_mux_nids;
1625 spec->num_muxes = 3;
93ed1503 1626 spec->init = d965_core_init;
81d3dbde
TD
1627 spec->mixer = stac9227_mixer;
1628 break;
93ed1503
TD
1629 case STAC_D965_5ST:
1630 spec->adc_nids = stac927x_adc_nids;
1631 spec->mux_nids = stac927x_mux_nids;
1632 spec->num_muxes = 3;
1633 spec->init = d965_core_init;
81d3dbde
TD
1634 spec->mixer = stac9227_mixer;
1635 break;
1636 default:
1637 spec->adc_nids = stac927x_adc_nids;
1638 spec->mux_nids = stac927x_mux_nids;
1639 spec->num_muxes = 3;
1640 spec->init = stac927x_core_init;
1641 spec->mixer = stac927x_mixer;
1642 }
3cc08dc6
MP
1643
1644 spec->multiout.dac_nids = spec->dac_nids;
1645
1646 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
c7d4b2fa
M
1647 if (err < 0) {
1648 stac92xx_free(codec);
1649 return err;
1650 }
2f2f4251
M
1651
1652 codec->patch_ops = stac92xx_patch_ops;
1653
1654 return 0;
1655}
1656
f3302a59
MP
1657static int patch_stac9205(struct hda_codec *codec)
1658{
1659 struct sigmatel_spec *spec;
1660 int err;
1661
1662 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1663 if (spec == NULL)
1664 return -ENOMEM;
1665
1666 codec->spec = spec;
11b44bbd
RF
1667 spec->num_pins = 14;
1668 spec->pin_nids = stac9205_pin_nids;
f3302a59 1669 spec->board_config = snd_hda_check_board_config(codec, stac9205_cfg_tbl);
11b44bbd
RF
1670 if (spec->board_config < 0) {
1671 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
1672 err = stac92xx_save_bios_config_regs(codec);
1673 if (err < 0) {
1674 stac92xx_free(codec);
1675 return err;
1676 }
1677 spec->pin_configs = spec->bios_pin_configs;
1678 } else {
f3302a59
MP
1679 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
1680 stac92xx_set_config_regs(codec);
1681 }
1682
1683 spec->adc_nids = stac9205_adc_nids;
1684 spec->mux_nids = stac9205_mux_nids;
1685 spec->num_muxes = 3;
1686
1687 spec->init = stac9205_core_init;
1688 spec->mixer = stac9205_mixer;
1689
1690 spec->multiout.dac_nids = spec->dac_nids;
1691
1692 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
1693 if (err < 0) {
1694 stac92xx_free(codec);
1695 return err;
1696 }
1697
1698 codec->patch_ops = stac92xx_patch_ops;
1699
1700 return 0;
1701}
1702
db064e50 1703/*
6d859065 1704 * STAC9872 hack
db064e50
TI
1705 */
1706
99ccc560 1707/* static config for Sony VAIO FE550G and Sony VAIO AR */
db064e50
TI
1708static hda_nid_t vaio_dacs[] = { 0x2 };
1709#define VAIO_HP_DAC 0x5
1710static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
1711static hda_nid_t vaio_mux_nids[] = { 0x15 };
1712
1713static struct hda_input_mux vaio_mux = {
1714 .num_items = 2,
1715 .items = {
d773781c
TI
1716 /* { "HP", 0x0 }, */
1717 { "Line", 0x1 },
db064e50
TI
1718 { "Mic", 0x2 },
1719 { "PCM", 0x3 },
1720 }
1721};
1722
1723static struct hda_verb vaio_init[] = {
1724 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
1725 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
1726 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
1727 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
1728 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
1729 {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
1730 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
1731 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
1732 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
1733 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
1734 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
1735 {}
1736};
1737
6d859065
GM
1738static struct hda_verb vaio_ar_init[] = {
1739 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
1740 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
1741 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
1742 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
1743/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
1744 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
1745 {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
1746 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
1747 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
1748/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
1749 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
1750 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
1751 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
1752 {}
1753};
1754
db064e50
TI
1755/* bind volumes of both NID 0x02 and 0x05 */
1756static int vaio_master_vol_put(struct snd_kcontrol *kcontrol,
1757 struct snd_ctl_elem_value *ucontrol)
1758{
1759 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1760 long *valp = ucontrol->value.integer.value;
1761 int change;
1762
1763 change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
1764 0x7f, valp[0] & 0x7f);
1765 change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
1766 0x7f, valp[1] & 0x7f);
1767 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
1768 0x7f, valp[0] & 0x7f);
1769 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
1770 0x7f, valp[1] & 0x7f);
1771 return change;
1772}
1773
1774/* bind volumes of both NID 0x02 and 0x05 */
1775static int vaio_master_sw_put(struct snd_kcontrol *kcontrol,
1776 struct snd_ctl_elem_value *ucontrol)
1777{
1778 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1779 long *valp = ucontrol->value.integer.value;
1780 int change;
1781
1782 change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
a9393d70 1783 0x80, (valp[0] ? 0 : 0x80));
db064e50 1784 change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
a9393d70 1785 0x80, (valp[1] ? 0 : 0x80));
db064e50 1786 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
a9393d70 1787 0x80, (valp[0] ? 0 : 0x80));
db064e50 1788 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
a9393d70 1789 0x80, (valp[1] ? 0 : 0x80));
db064e50
TI
1790 return change;
1791}
1792
1793static struct snd_kcontrol_new vaio_mixer[] = {
1794 {
1795 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1796 .name = "Master Playback Volume",
1797 .info = snd_hda_mixer_amp_volume_info,
1798 .get = snd_hda_mixer_amp_volume_get,
1799 .put = vaio_master_vol_put,
c2566524 1800 .tlv = { .c = snd_hda_mixer_amp_tlv },
db064e50
TI
1801 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
1802 },
1803 {
1804 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1805 .name = "Master Playback Switch",
1806 .info = snd_hda_mixer_amp_switch_info,
1807 .get = snd_hda_mixer_amp_switch_get,
1808 .put = vaio_master_sw_put,
1809 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
1810 },
1811 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
1812 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
1813 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
1814 {
1815 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1816 .name = "Capture Source",
1817 .count = 1,
1818 .info = stac92xx_mux_enum_info,
1819 .get = stac92xx_mux_enum_get,
1820 .put = stac92xx_mux_enum_put,
1821 },
1822 {}
1823};
1824
6d859065
GM
1825static struct snd_kcontrol_new vaio_ar_mixer[] = {
1826 {
1827 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1828 .name = "Master Playback Volume",
1829 .info = snd_hda_mixer_amp_volume_info,
1830 .get = snd_hda_mixer_amp_volume_get,
1831 .put = vaio_master_vol_put,
1832 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
1833 },
1834 {
1835 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1836 .name = "Master Playback Switch",
1837 .info = snd_hda_mixer_amp_switch_info,
1838 .get = snd_hda_mixer_amp_switch_get,
1839 .put = vaio_master_sw_put,
1840 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
1841 },
1842 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
1843 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
1844 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
1845 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
1846 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
1847 {
1848 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1849 .name = "Capture Source",
1850 .count = 1,
1851 .info = stac92xx_mux_enum_info,
1852 .get = stac92xx_mux_enum_get,
1853 .put = stac92xx_mux_enum_put,
1854 },
1855 {}
1856};
1857
1858static struct hda_codec_ops stac9872_patch_ops = {
db064e50
TI
1859 .build_controls = stac92xx_build_controls,
1860 .build_pcms = stac92xx_build_pcms,
1861 .init = stac92xx_init,
1862 .free = stac92xx_free,
1863#ifdef CONFIG_PM
1864 .resume = stac92xx_resume,
1865#endif
1866};
1867
6d859065
GM
1868enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
1869 CXD9872RD_VAIO,
1870 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
1871 STAC9872AK_VAIO,
1872 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
1873 STAC9872K_VAIO,
1874 /* AR Series. id=0x83847664 and subsys=104D1300 */
1875 CXD9872AKD_VAIO
1876 };
1877
1878static struct hda_board_config stac9872_cfg_tbl[] = {
1879 { .modelname = "vaio", .config = CXD9872RD_VAIO },
1880 { .modelname = "vaio-ar", .config = CXD9872AKD_VAIO },
db064e50 1881 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81e6,
6d859065 1882 .config = CXD9872RD_VAIO },
db064e50 1883 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81ef,
6d859065 1884 .config = CXD9872RD_VAIO },
99ccc560 1885 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81fd,
6d859065 1886 .config = CXD9872AKD_VAIO },
db064e50
TI
1887 {}
1888};
1889
6d859065 1890static int patch_stac9872(struct hda_codec *codec)
db064e50
TI
1891{
1892 struct sigmatel_spec *spec;
1893 int board_config;
1894
6d859065 1895 board_config = snd_hda_check_board_config(codec, stac9872_cfg_tbl);
db064e50
TI
1896 if (board_config < 0)
1897 /* unknown config, let generic-parser do its job... */
1898 return snd_hda_parse_generic_codec(codec);
1899
1900 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1901 if (spec == NULL)
1902 return -ENOMEM;
1903
1904 codec->spec = spec;
1905 switch (board_config) {
6d859065
GM
1906 case CXD9872RD_VAIO:
1907 case STAC9872AK_VAIO:
1908 case STAC9872K_VAIO:
db064e50
TI
1909 spec->mixer = vaio_mixer;
1910 spec->init = vaio_init;
1911 spec->multiout.max_channels = 2;
1912 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
1913 spec->multiout.dac_nids = vaio_dacs;
1914 spec->multiout.hp_nid = VAIO_HP_DAC;
1915 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
1916 spec->adc_nids = vaio_adcs;
1917 spec->input_mux = &vaio_mux;
1918 spec->mux_nids = vaio_mux_nids;
1919 break;
6d859065
GM
1920
1921 case CXD9872AKD_VAIO:
1922 spec->mixer = vaio_ar_mixer;
1923 spec->init = vaio_ar_init;
1924 spec->multiout.max_channels = 2;
1925 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
1926 spec->multiout.dac_nids = vaio_dacs;
1927 spec->multiout.hp_nid = VAIO_HP_DAC;
1928 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
1929 spec->adc_nids = vaio_adcs;
1930 spec->input_mux = &vaio_mux;
1931 spec->mux_nids = vaio_mux_nids;
1932 break;
db064e50
TI
1933 }
1934
6d859065 1935 codec->patch_ops = stac9872_patch_ops;
db064e50
TI
1936 return 0;
1937}
1938
1939
2f2f4251
M
1940/*
1941 * patch entries
1942 */
1943struct hda_codec_preset snd_hda_preset_sigmatel[] = {
1944 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
1945 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
1946 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
1947 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
1948 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
1949 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
1950 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
22a27c7f
MP
1951 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
1952 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
1953 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
1954 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
1955 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
1956 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
3cc08dc6
MP
1957 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
1958 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
1959 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
1960 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
1961 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
1962 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
1963 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
1964 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
1965 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
1966 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
6d859065
GM
1967 /* The following does not take into account .id=0x83847661 when subsys =
1968 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
1969 * currently not fully supported.
1970 */
1971 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
1972 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
1973 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
f3302a59
MP
1974 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
1975 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
1976 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
1977 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
1978 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
1979 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
1980 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
1981 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
2f2f4251
M
1982 {} /* terminator */
1983};