blob: 1b428a1eafd0fc79ae11b4af3b9a3edf3634ac52 [file] [log] [blame]
Matt2f2f4252005-04-13 14:45:30 +02001/*
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.
Matt Porter403d1942005-11-29 15:00:51 +01007 * Matt Porter <mporter@embeddedalley.com>
Matt2f2f4252005-04-13 14:45:30 +02008 *
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>
Mattc7d4b2f2005-06-27 14:59:41 +020033#include <sound/asoundef.h>
Matt2f2f4252005-04-13 14:45:30 +020034#include "hda_codec.h"
35#include "hda_local.h"
36
Matt4e550962005-07-04 17:51:39 +020037#define NUM_CONTROL_ALLOC 32
38#define STAC_HP_EVENT 0x37
Matt4e550962005-07-04 17:51:39 +020039
Matt Porter403d1942005-11-29 15:00:51 +010040#define STAC_REF 0
41#define STAC_D945GTP3 1
42#define STAC_D945GTP5 2
Sam Revitch62fe78e2006-05-10 15:09:17 +020043#define STAC_MACMINI 3
Tobin Davis93ed1502006-09-01 21:03:12 +020044#define STAC_922X_MODELS 4 /* number of 922x models */
45#define STAC_D965_3ST 4
46#define STAC_D965_5ST 5
Matt Porter8b657272006-10-26 17:12:59 +020047#define STAC_927X_MODELS 6 /* number of 927x models */
Matt Porter403d1942005-11-29 15:00:51 +010048
Matt2f2f4252005-04-13 14:45:30 +020049struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +010050 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +020051 unsigned int num_mixers;
52
Matt Porter403d1942005-11-29 15:00:51 +010053 int board_config;
Mattc7d4b2f2005-06-27 14:59:41 +020054 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +010055 unsigned int line_switch: 1;
56 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +010057 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +010058 unsigned int hp_detect: 1;
Sam Revitch62fe78e2006-05-10 15:09:17 +020059 unsigned int gpio_mute: 1;
Mattc7d4b2f2005-06-27 14:59:41 +020060
Matt2f2f4252005-04-13 14:45:30 +020061 /* playback */
62 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +010063 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +020064
65 /* capture */
66 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +020067 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +020068 hda_nid_t *mux_nids;
69 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +020070 hda_nid_t *dmic_nids;
71 unsigned int num_dmics;
72 hda_nid_t dmux_nid;
Mattdabbed62005-06-14 10:19:34 +020073 hda_nid_t dig_in_nid;
Matt2f2f4252005-04-13 14:45:30 +020074
Matt2f2f4252005-04-13 14:45:30 +020075 /* pin widgets */
76 hda_nid_t *pin_nids;
77 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +020078 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +020079 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +020080
81 /* codec specific stuff */
82 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +010083 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +020084
85 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +020086 struct hda_input_mux *dinput_mux;
87 unsigned int cur_dmux;
Mattc7d4b2f2005-06-27 14:59:41 +020088 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +010089 unsigned int cur_mux[3];
Matt2f2f4252005-04-13 14:45:30 +020090
Matt Porter403d1942005-11-29 15:00:51 +010091 /* i/o switches */
92 unsigned int io_switch[2];
Matt2f2f4252005-04-13 14:45:30 +020093
Mattc7d4b2f2005-06-27 14:59:41 +020094 struct hda_pcm pcm_rec[2]; /* PCM information */
95
96 /* dynamic controls and input_mux */
97 struct auto_pin_cfg autocfg;
98 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +010099 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200100 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200101 struct hda_input_mux private_imux;
Matt2f2f4252005-04-13 14:45:30 +0200102};
103
104static hda_nid_t stac9200_adc_nids[1] = {
105 0x03,
106};
107
108static hda_nid_t stac9200_mux_nids[1] = {
109 0x0c,
110};
111
112static hda_nid_t stac9200_dac_nids[1] = {
113 0x02,
114};
115
Matt2f2f4252005-04-13 14:45:30 +0200116static hda_nid_t stac922x_adc_nids[2] = {
117 0x06, 0x07,
118};
119
120static hda_nid_t stac922x_mux_nids[2] = {
121 0x12, 0x13,
122};
123
Matt Porter3cc08dc2006-01-23 15:27:49 +0100124static hda_nid_t stac927x_adc_nids[3] = {
125 0x07, 0x08, 0x09
126};
127
128static hda_nid_t stac927x_mux_nids[3] = {
129 0x15, 0x16, 0x17
130};
131
Matt Porterf3302a52006-07-31 12:49:34 +0200132static hda_nid_t stac9205_adc_nids[2] = {
133 0x12, 0x13
134};
135
136static hda_nid_t stac9205_mux_nids[2] = {
137 0x19, 0x1a
138};
139
Matt Porter8b657272006-10-26 17:12:59 +0200140static hda_nid_t stac9205_dmic_nids[3] = {
141 0x17, 0x18, 0
142};
143
Mattc7d4b2f2005-06-27 14:59:41 +0200144static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200145 0x08, 0x09, 0x0d, 0x0e,
146 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200147};
148
149static hda_nid_t stac922x_pin_nids[10] = {
150 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
151 0x0f, 0x10, 0x11, 0x15, 0x1b,
152};
153
Matt Porter3cc08dc2006-01-23 15:27:49 +0100154static hda_nid_t stac927x_pin_nids[14] = {
155 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
156 0x0f, 0x10, 0x11, 0x12, 0x13,
157 0x14, 0x21, 0x22, 0x23,
158};
159
Matt Porterf3302a52006-07-31 12:49:34 +0200160static hda_nid_t stac9205_pin_nids[12] = {
161 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
162 0x0f, 0x14, 0x16, 0x17, 0x18,
163 0x21, 0x22,
164
165};
166
Matt Porter8b657272006-10-26 17:12:59 +0200167static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
168 struct snd_ctl_elem_info *uinfo)
169{
170 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
171 struct sigmatel_spec *spec = codec->spec;
172 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
173}
174
175static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
176 struct snd_ctl_elem_value *ucontrol)
177{
178 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
179 struct sigmatel_spec *spec = codec->spec;
180
181 ucontrol->value.enumerated.item[0] = spec->cur_dmux;
182 return 0;
183}
184
185static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
186 struct snd_ctl_elem_value *ucontrol)
187{
188 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
189 struct sigmatel_spec *spec = codec->spec;
190
191 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
192 spec->dmux_nid, &spec->cur_dmux);
193}
194
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100195static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200196{
197 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
198 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200199 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200200}
201
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100202static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200203{
204 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
205 struct sigmatel_spec *spec = codec->spec;
206 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
207
208 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
209 return 0;
210}
211
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100212static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200213{
214 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
215 struct sigmatel_spec *spec = codec->spec;
216 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
217
Mattc7d4b2f2005-06-27 14:59:41 +0200218 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200219 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
220}
221
Mattc7d4b2f2005-06-27 14:59:41 +0200222static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200223 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200224 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200225 {}
226};
227
Mattc7d4b2f2005-06-27 14:59:41 +0200228static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200229 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200230 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200231 {}
232};
233
Tobin Davis93ed1502006-09-01 21:03:12 +0200234static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200235 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200236 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200237 /* unmute node 0x1b */
238 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
239 /* select node 0x03 as DAC */
240 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
241 {}
242};
243
Matt Porter3cc08dc2006-01-23 15:27:49 +0100244static struct hda_verb stac927x_core_init[] = {
245 /* set master volume and direct control */
246 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
247 {}
248};
249
Matt Porterf3302a52006-07-31 12:49:34 +0200250static struct hda_verb stac9205_core_init[] = {
251 /* set master volume and direct control */
252 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
253 {}
254};
255
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100256static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200257 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
258 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
259 {
260 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
261 .name = "Input Source",
262 .count = 1,
263 .info = stac92xx_mux_enum_info,
264 .get = stac92xx_mux_enum_get,
265 .put = stac92xx_mux_enum_put,
266 },
267 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
268 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Mattc7d4b2f2005-06-27 14:59:41 +0200269 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200270 { } /* end */
271};
272
Mattc7d4b2f2005-06-27 14:59:41 +0200273/* This needs to be generated dynamically based on sequence */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100274static struct snd_kcontrol_new stac922x_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200275 {
276 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
277 .name = "Input Source",
278 .count = 1,
279 .info = stac92xx_mux_enum_info,
280 .get = stac92xx_mux_enum_get,
281 .put = stac92xx_mux_enum_put,
282 },
283 HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT),
Takashi Iwai0fd17082006-01-13 18:46:21 +0100284 HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT),
Matt2f2f4252005-04-13 14:45:30 +0200285 HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT),
286 { } /* end */
287};
288
Takashi Iwai19039bd2006-06-28 15:52:16 +0200289/* This needs to be generated dynamically based on sequence */
290static struct snd_kcontrol_new stac9227_mixer[] = {
291 {
292 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
293 .name = "Input Source",
294 .count = 1,
295 .info = stac92xx_mux_enum_info,
296 .get = stac92xx_mux_enum_get,
297 .put = stac92xx_mux_enum_put,
298 },
299 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
300 HDA_CODEC_MUTE("Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
301 { } /* end */
302};
303
Matt Porter3cc08dc2006-01-23 15:27:49 +0100304static snd_kcontrol_new_t stac927x_mixer[] = {
305 {
306 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
307 .name = "Input Source",
308 .count = 1,
309 .info = stac92xx_mux_enum_info,
310 .get = stac92xx_mux_enum_get,
311 .put = stac92xx_mux_enum_put,
312 },
313 HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT),
314 HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT),
315 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
316 { } /* end */
317};
318
Matt Porterf3302a52006-07-31 12:49:34 +0200319static snd_kcontrol_new_t stac9205_mixer[] = {
320 {
321 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matt Porter8b657272006-10-26 17:12:59 +0200322 .name = "Digital Input Source",
323 .count = 1,
324 .info = stac92xx_dmux_enum_info,
325 .get = stac92xx_dmux_enum_get,
326 .put = stac92xx_dmux_enum_put,
327 },
328 {
329 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matt Porterf3302a52006-07-31 12:49:34 +0200330 .name = "Input Source",
331 .count = 1,
332 .info = stac92xx_mux_enum_info,
333 .get = stac92xx_mux_enum_get,
334 .put = stac92xx_mux_enum_put,
335 },
336 HDA_CODEC_VOLUME("InMux Capture Volume", 0x19, 0x0, HDA_OUTPUT),
337 HDA_CODEC_VOLUME("InVol Capture Volume", 0x1b, 0x0, HDA_INPUT),
338 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1d, 0x0, HDA_OUTPUT),
339 { } /* end */
340};
341
Matt2f2f4252005-04-13 14:45:30 +0200342static int stac92xx_build_controls(struct hda_codec *codec)
343{
344 struct sigmatel_spec *spec = codec->spec;
345 int err;
Mattc7d4b2f2005-06-27 14:59:41 +0200346 int i;
Matt2f2f4252005-04-13 14:45:30 +0200347
348 err = snd_hda_add_new_ctls(codec, spec->mixer);
349 if (err < 0)
350 return err;
Mattc7d4b2f2005-06-27 14:59:41 +0200351
352 for (i = 0; i < spec->num_mixers; i++) {
353 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
354 if (err < 0)
355 return err;
356 }
357
Mattdabbed62005-06-14 10:19:34 +0200358 if (spec->multiout.dig_out_nid) {
359 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
360 if (err < 0)
361 return err;
362 }
363 if (spec->dig_in_nid) {
364 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
365 if (err < 0)
366 return err;
367 }
368 return 0;
Matt2f2f4252005-04-13 14:45:30 +0200369}
370
Matt Porter403d1942005-11-29 15:00:51 +0100371static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +0200372 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +0200373 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
374};
375
Matt Porter403d1942005-11-29 15:00:51 +0100376static unsigned int *stac9200_brd_tbl[] = {
377 ref9200_pin_configs,
378};
379
380static struct hda_board_config stac9200_cfg_tbl[] = {
381 { .modelname = "ref",
382 .pci_subvendor = PCI_VENDOR_ID_INTEL,
383 .pci_subdevice = 0x2668, /* DFI LanParty */
384 .config = STAC_REF },
Matt Portere7377072006-11-06 11:20:38 +0100385 /* Dell laptops have BIOS problem */
386 { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01b5,
387 .config = STAC_REF }, /* Dell Inspiron 630m */
388 { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01c2,
389 .config = STAC_REF }, /* Dell Latitude D620 */
390 { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01cb,
391 .config = STAC_REF }, /* Dell Latitude 120L */
Matt Porter403d1942005-11-29 15:00:51 +0100392 {} /* terminator */
393};
394
395static unsigned int ref922x_pin_configs[10] = {
396 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
397 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +0200398 0x40000100, 0x40000100,
399};
400
Matt Porter403d1942005-11-29 15:00:51 +0100401static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +0100402 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +0100403 0x40000100, 0x40000100, 0x40000100, 0x40000100,
404 0x02a19120, 0x40000100,
405};
406
407static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +0100408 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
409 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +0100410 0x02a19320, 0x40000100,
411};
412
Takashi Iwai19039bd2006-06-28 15:52:16 +0200413static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
414 [STAC_REF] = ref922x_pin_configs,
415 [STAC_D945GTP3] = d945gtp3_pin_configs,
416 [STAC_D945GTP5] = d945gtp5_pin_configs,
Linus Torvalds7c3dec02006-07-10 22:21:43 -0700417 [STAC_MACMINI] = d945gtp5_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +0100418};
419
420static struct hda_board_config stac922x_cfg_tbl[] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200421 { .modelname = "5stack", .config = STAC_D945GTP5 },
422 { .modelname = "3stack", .config = STAC_D945GTP3 },
Matt Porter403d1942005-11-29 15:00:51 +0100423 { .modelname = "ref",
424 .pci_subvendor = PCI_VENDOR_ID_INTEL,
425 .pci_subdevice = 0x2668, /* DFI LanParty */
426 .config = STAC_REF }, /* SigmaTel reference board */
Tobin Davis948a4db2006-08-22 19:43:46 +0200427 /* Intel 945G based systems */
Matt Porter403d1942005-11-29 15:00:51 +0100428 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
429 .pci_subdevice = 0x0101,
430 .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */
431 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
Takashi Iwai353b9e62006-02-16 18:16:17 +0100432 .pci_subdevice = 0x0202,
Tobin Davis948a4db2006-08-22 19:43:46 +0200433 .config = STAC_D945GTP3 }, /* Intel D945GNT - 3 Stack */
Takashi Iwai353b9e62006-02-16 18:16:17 +0100434 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
Tobin Davis948a4db2006-08-22 19:43:46 +0200435 .pci_subdevice = 0x0606,
436 .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */
Takashi Iwai353b9e62006-02-16 18:16:17 +0100437 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
Tobin Davis948a4db2006-08-22 19:43:46 +0200438 .pci_subdevice = 0x0601,
439 .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */
440 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
441 .pci_subdevice = 0x0111,
442 .config = STAC_D945GTP3 }, /* Intel D945GZP - 3 Stack */
443 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
444 .pci_subdevice = 0x1115,
445 .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */
446 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
447 .pci_subdevice = 0x1116,
448 .config = STAC_D945GTP3 }, /* Intel D945GBO - 3 Stack */
449 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
450 .pci_subdevice = 0x1117,
451 .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */
452 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
453 .pci_subdevice = 0x1118,
454 .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */
455 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
456 .pci_subdevice = 0x1119,
457 .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */
458 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
459 .pci_subdevice = 0x8826,
460 .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */
461 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
462 .pci_subdevice = 0x5049,
463 .config = STAC_D945GTP3 }, /* Intel D945GCZ - 3 Stack */
464 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
465 .pci_subdevice = 0x5055,
466 .config = STAC_D945GTP3 }, /* Intel D945GCZ - 3 Stack */
467 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
468 .pci_subdevice = 0x5048,
469 .config = STAC_D945GTP3 }, /* Intel D945GPB - 3 Stack */
470 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
471 .pci_subdevice = 0x0110,
472 .config = STAC_D945GTP3 }, /* Intel D945GLR - 3 Stack */
473 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
Matt Porter403d1942005-11-29 15:00:51 +0100474 .pci_subdevice = 0x0404,
475 .config = STAC_D945GTP5 }, /* Intel D945GTP - 5 Stack */
476 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
477 .pci_subdevice = 0x0303,
478 .config = STAC_D945GTP5 }, /* Intel D945GNT - 5 Stack */
479 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
480 .pci_subdevice = 0x0013,
481 .config = STAC_D945GTP5 }, /* Intel D955XBK - 5 Stack */
Matt Porterd62c40e2006-01-23 15:26:27 +0100482 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
483 .pci_subdevice = 0x0417,
484 .config = STAC_D945GTP5 }, /* Intel D975XBK - 5 Stack */
Tobin Davis948a4db2006-08-22 19:43:46 +0200485 /* Intel 945P based systems */
486 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
487 .pci_subdevice = 0x0b0b,
488 .config = STAC_D945GTP3 }, /* Intel D945PSN - 3 Stack */
489 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
490 .pci_subdevice = 0x0112,
491 .config = STAC_D945GTP3 }, /* Intel D945PLN - 3 Stack */
492 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
493 .pci_subdevice = 0x0d0d,
494 .config = STAC_D945GTP3 }, /* Intel D945PLM - 3 Stack */
495 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
496 .pci_subdevice = 0x0909,
497 .config = STAC_D945GTP3 }, /* Intel D945PAW - 3 Stack */
498 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
499 .pci_subdevice = 0x0505,
500 .config = STAC_D945GTP3 }, /* Intel D945PLM - 3 Stack */
501 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
502 .pci_subdevice = 0x0707,
503 .config = STAC_D945GTP5 }, /* Intel D945PSV - 5 Stack */
504 /* other systems */
Sam Revitch62fe78e2006-05-10 15:09:17 +0200505 { .pci_subvendor = 0x8384,
506 .pci_subdevice = 0x7680,
507 .config = STAC_MACMINI }, /* Apple Mac Mini (early 2006) */
Matt Porter403d1942005-11-29 15:00:51 +0100508 {} /* terminator */
509};
510
Matt Porter3cc08dc2006-01-23 15:27:49 +0100511static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200512 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
513 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
514 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
515 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +0100516};
517
Tobin Davis93ed1502006-09-01 21:03:12 +0200518static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200519 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
520 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
521 0x40000100, 0x40000100, 0x40000100, 0x40000100,
522 0x40000100, 0x40000100
523};
524
Tobin Davis93ed1502006-09-01 21:03:12 +0200525static unsigned int d965_5st_pin_configs[14] = {
526 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
527 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
528 0x40000100, 0x40000100, 0x40000100, 0x01442070,
529 0x40000100, 0x40000100
530};
531
532static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200533 [STAC_REF] = ref927x_pin_configs,
Tobin Davis93ed1502006-09-01 21:03:12 +0200534 [STAC_D965_3ST] = d965_3st_pin_configs,
535 [STAC_D965_5ST] = d965_5st_pin_configs,
Matt Porter3cc08dc2006-01-23 15:27:49 +0100536};
537
538static struct hda_board_config stac927x_cfg_tbl[] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200539 { .modelname = "5stack", .config = STAC_D965_5ST },
540 { .modelname = "3stack", .config = STAC_D965_3ST },
Matt Porter3cc08dc2006-01-23 15:27:49 +0100541 { .modelname = "ref",
542 .pci_subvendor = PCI_VENDOR_ID_INTEL,
543 .pci_subdevice = 0x2668, /* DFI LanParty */
544 .config = STAC_REF }, /* SigmaTel reference board */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200545 /* Intel 946 based systems */
546 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
547 .pci_subdevice = 0x3d01,
Tobin Davis93ed1502006-09-01 21:03:12 +0200548 .config = STAC_D965_3ST }, /* D946 configuration */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200549 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
550 .pci_subdevice = 0xa301,
Tobin Davis93ed1502006-09-01 21:03:12 +0200551 .config = STAC_D965_3ST }, /* Intel D946GZT - 3 stack */
552 /* 965 based 3 stack systems */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200553 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
554 .pci_subdevice = 0x2116,
Tobin Davis93ed1502006-09-01 21:03:12 +0200555 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200556 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
557 .pci_subdevice = 0x2115,
Tobin Davis93ed1502006-09-01 21:03:12 +0200558 .config = STAC_D965_3ST }, /* Intel DQ965WC - 3 Stack */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200559 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
560 .pci_subdevice = 0x2114,
Tobin Davis93ed1502006-09-01 21:03:12 +0200561 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200562 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
563 .pci_subdevice = 0x2113,
Tobin Davis93ed1502006-09-01 21:03:12 +0200564 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200565 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
566 .pci_subdevice = 0x2112,
Tobin Davis93ed1502006-09-01 21:03:12 +0200567 .config = STAC_D965_3ST }, /* Intel DG965MS - 3 Stack */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200568 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
569 .pci_subdevice = 0x2111,
Tobin Davis93ed1502006-09-01 21:03:12 +0200570 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200571 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
572 .pci_subdevice = 0x2110,
Tobin Davis93ed1502006-09-01 21:03:12 +0200573 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200574 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
575 .pci_subdevice = 0x2009,
Tobin Davis93ed1502006-09-01 21:03:12 +0200576 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200577 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
578 .pci_subdevice = 0x2008,
Tobin Davis93ed1502006-09-01 21:03:12 +0200579 .config = STAC_D965_3ST }, /* Intel DQ965GF - 3 Stack */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200580 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
581 .pci_subdevice = 0x2007,
Tobin Davis93ed1502006-09-01 21:03:12 +0200582 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200583 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
584 .pci_subdevice = 0x2006,
Tobin Davis93ed1502006-09-01 21:03:12 +0200585 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200586 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
587 .pci_subdevice = 0x2005,
Tobin Davis93ed1502006-09-01 21:03:12 +0200588 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200589 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
590 .pci_subdevice = 0x2004,
Tobin Davis93ed1502006-09-01 21:03:12 +0200591 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200592 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
593 .pci_subdevice = 0x2003,
Tobin Davis93ed1502006-09-01 21:03:12 +0200594 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200595 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
596 .pci_subdevice = 0x2002,
Tobin Davis93ed1502006-09-01 21:03:12 +0200597 .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200598 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
599 .pci_subdevice = 0x2001,
Tobin Davis93ed1502006-09-01 21:03:12 +0200600 .config = STAC_D965_3ST }, /* Intel DQ965GF - 3 Stack */
601 /* 965 based 5 stack systems */
602 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
603 .pci_subdevice = 0x2301,
604 .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
605 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
606 .pci_subdevice = 0x2302,
607 .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
608 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
609 .pci_subdevice = 0x2303,
610 .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
611 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
612 .pci_subdevice = 0x2304,
613 .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
614 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
615 .pci_subdevice = 0x2305,
616 .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
617 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
618 .pci_subdevice = 0x2501,
619 .config = STAC_D965_5ST }, /* Intel DG965MQ - 5 Stack */
620 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
621 .pci_subdevice = 0x2502,
622 .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
623 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
624 .pci_subdevice = 0x2503,
625 .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
626 { .pci_subvendor = PCI_VENDOR_ID_INTEL,
627 .pci_subdevice = 0x2504,
628 .config = STAC_D965_5ST }, /* Intel DQ965GF - 5 Stack */
Matt Porter3cc08dc2006-01-23 15:27:49 +0100629 {} /* terminator */
630};
631
Matt Porterf3302a52006-07-31 12:49:34 +0200632static unsigned int ref9205_pin_configs[12] = {
633 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matt Porter8b657272006-10-26 17:12:59 +0200634 0x01813122, 0x01a19021, 0x40000100, 0x40000100,
635 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +0200636};
637
638static unsigned int *stac9205_brd_tbl[] = {
639 ref9205_pin_configs,
640};
641
642static struct hda_board_config stac9205_cfg_tbl[] = {
643 { .modelname = "ref",
644 .pci_subvendor = PCI_VENDOR_ID_INTEL,
645 .pci_subdevice = 0x2668, /* DFI LanParty */
646 .config = STAC_REF }, /* SigmaTel reference board */
647 {} /* terminator */
648};
649
Richard Fish11b44bb2006-08-23 18:31:34 +0200650static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
651{
652 int i;
653 struct sigmatel_spec *spec = codec->spec;
654
655 if (! spec->bios_pin_configs) {
656 spec->bios_pin_configs = kcalloc(spec->num_pins,
657 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
658 if (! spec->bios_pin_configs)
659 return -ENOMEM;
660 }
661
662 for (i = 0; i < spec->num_pins; i++) {
663 hda_nid_t nid = spec->pin_nids[i];
664 unsigned int pin_cfg;
665
666 pin_cfg = snd_hda_codec_read(codec, nid, 0,
667 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
668 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
669 nid, pin_cfg);
670 spec->bios_pin_configs[i] = pin_cfg;
671 }
672
673 return 0;
674}
675
Matt2f2f4252005-04-13 14:45:30 +0200676static void stac92xx_set_config_regs(struct hda_codec *codec)
677{
678 int i;
679 struct sigmatel_spec *spec = codec->spec;
680 unsigned int pin_cfg;
681
Richard Fish11b44bb2006-08-23 18:31:34 +0200682 if (! spec->pin_nids || ! spec->pin_configs)
683 return;
684
685 for (i = 0; i < spec->num_pins; i++) {
Matt2f2f4252005-04-13 14:45:30 +0200686 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
687 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
688 spec->pin_configs[i] & 0x000000ff);
689 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
690 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
691 (spec->pin_configs[i] & 0x0000ff00) >> 8);
692 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
693 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
694 (spec->pin_configs[i] & 0x00ff0000) >> 16);
695 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
696 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
697 spec->pin_configs[i] >> 24);
698 pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0,
699 AC_VERB_GET_CONFIG_DEFAULT,
700 0x00);
Matt Porter403d1942005-11-29 15:00:51 +0100701 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg);
Matt2f2f4252005-04-13 14:45:30 +0200702 }
703}
Matt2f2f4252005-04-13 14:45:30 +0200704
Matt2f2f4252005-04-13 14:45:30 +0200705/*
706 * Analog playback callbacks
707 */
708static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
709 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100710 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200711{
712 struct sigmatel_spec *spec = codec->spec;
713 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
714}
715
716static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
717 struct hda_codec *codec,
718 unsigned int stream_tag,
719 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100720 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200721{
722 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +0100723 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +0200724}
725
726static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
727 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100728 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200729{
730 struct sigmatel_spec *spec = codec->spec;
731 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
732}
733
734/*
Mattdabbed62005-06-14 10:19:34 +0200735 * Digital playback callbacks
736 */
737static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
738 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100739 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +0200740{
741 struct sigmatel_spec *spec = codec->spec;
742 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
743}
744
745static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
746 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100747 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +0200748{
749 struct sigmatel_spec *spec = codec->spec;
750 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
751}
752
753
754/*
Matt2f2f4252005-04-13 14:45:30 +0200755 * Analog capture callbacks
756 */
757static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
758 struct hda_codec *codec,
759 unsigned int stream_tag,
760 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100761 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200762{
763 struct sigmatel_spec *spec = codec->spec;
764
765 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
766 stream_tag, 0, format);
767 return 0;
768}
769
770static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
771 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100772 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200773{
774 struct sigmatel_spec *spec = codec->spec;
775
776 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
777 return 0;
778}
779
Mattdabbed62005-06-14 10:19:34 +0200780static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
781 .substreams = 1,
782 .channels_min = 2,
783 .channels_max = 2,
784 /* NID is set in stac92xx_build_pcms */
785 .ops = {
786 .open = stac92xx_dig_playback_pcm_open,
787 .close = stac92xx_dig_playback_pcm_close
788 },
789};
790
791static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
792 .substreams = 1,
793 .channels_min = 2,
794 .channels_max = 2,
795 /* NID is set in stac92xx_build_pcms */
796};
797
Matt2f2f4252005-04-13 14:45:30 +0200798static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
799 .substreams = 1,
800 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +0200801 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +0200802 .nid = 0x02, /* NID to query formats and rates */
803 .ops = {
804 .open = stac92xx_playback_pcm_open,
805 .prepare = stac92xx_playback_pcm_prepare,
806 .cleanup = stac92xx_playback_pcm_cleanup
807 },
808};
809
Matt Porter3cc08dc2006-01-23 15:27:49 +0100810static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
811 .substreams = 1,
812 .channels_min = 2,
813 .channels_max = 2,
814 .nid = 0x06, /* NID to query formats and rates */
815 .ops = {
816 .open = stac92xx_playback_pcm_open,
817 .prepare = stac92xx_playback_pcm_prepare,
818 .cleanup = stac92xx_playback_pcm_cleanup
819 },
820};
821
Matt2f2f4252005-04-13 14:45:30 +0200822static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
823 .substreams = 2,
824 .channels_min = 2,
825 .channels_max = 2,
Matt Porter3cc08dc2006-01-23 15:27:49 +0100826 /* NID is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +0200827 .ops = {
828 .prepare = stac92xx_capture_pcm_prepare,
829 .cleanup = stac92xx_capture_pcm_cleanup
830 },
831};
832
833static int stac92xx_build_pcms(struct hda_codec *codec)
834{
835 struct sigmatel_spec *spec = codec->spec;
836 struct hda_pcm *info = spec->pcm_rec;
837
838 codec->num_pcms = 1;
839 codec->pcm_info = info;
840
Mattc7d4b2f2005-06-27 14:59:41 +0200841 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +0200842 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +0200843 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100844 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
845
846 if (spec->alt_switch) {
847 codec->num_pcms++;
848 info++;
849 info->name = "STAC92xx Analog Alt";
850 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
851 }
Matt2f2f4252005-04-13 14:45:30 +0200852
Mattdabbed62005-06-14 10:19:34 +0200853 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
854 codec->num_pcms++;
855 info++;
856 info->name = "STAC92xx Digital";
857 if (spec->multiout.dig_out_nid) {
858 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
859 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
860 }
861 if (spec->dig_in_nid) {
862 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
863 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
864 }
865 }
866
Matt2f2f4252005-04-13 14:45:30 +0200867 return 0;
868}
869
Takashi Iwaic960a032006-03-23 17:06:28 +0100870static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
871{
872 unsigned int pincap = snd_hda_param_read(codec, nid,
873 AC_PAR_PIN_CAP);
874 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
875 if (pincap & AC_PINCAP_VREF_100)
876 return AC_PINCTL_VREF_100;
877 if (pincap & AC_PINCAP_VREF_80)
878 return AC_PINCTL_VREF_80;
879 if (pincap & AC_PINCAP_VREF_50)
880 return AC_PINCTL_VREF_50;
881 if (pincap & AC_PINCAP_VREF_GRD)
882 return AC_PINCTL_VREF_GRD;
883 return 0;
884}
885
Matt Porter403d1942005-11-29 15:00:51 +0100886static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
887
888{
889 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
890}
891
892static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
893{
894 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
895 uinfo->count = 1;
896 uinfo->value.integer.min = 0;
897 uinfo->value.integer.max = 1;
898 return 0;
899}
900
901static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
902{
903 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
904 struct sigmatel_spec *spec = codec->spec;
905 int io_idx = kcontrol-> private_value & 0xff;
906
907 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
908 return 0;
909}
910
911static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
912{
913 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
914 struct sigmatel_spec *spec = codec->spec;
915 hda_nid_t nid = kcontrol->private_value >> 8;
916 int io_idx = kcontrol-> private_value & 0xff;
917 unsigned short val = ucontrol->value.integer.value[0];
918
919 spec->io_switch[io_idx] = val;
920
921 if (val)
922 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +0100923 else {
924 unsigned int pinctl = AC_PINCTL_IN_EN;
925 if (io_idx) /* set VREF for mic */
926 pinctl |= stac92xx_get_vref(codec, nid);
927 stac92xx_auto_set_pinctl(codec, nid, pinctl);
928 }
Matt Porter403d1942005-11-29 15:00:51 +0100929 return 1;
930}
931
932#define STAC_CODEC_IO_SWITCH(xname, xpval) \
933 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
934 .name = xname, \
935 .index = 0, \
936 .info = stac92xx_io_switch_info, \
937 .get = stac92xx_io_switch_get, \
938 .put = stac92xx_io_switch_put, \
939 .private_value = xpval, \
940 }
941
942
Mattc7d4b2f2005-06-27 14:59:41 +0200943enum {
944 STAC_CTL_WIDGET_VOL,
945 STAC_CTL_WIDGET_MUTE,
Matt Porter403d1942005-11-29 15:00:51 +0100946 STAC_CTL_WIDGET_IO_SWITCH,
Mattc7d4b2f2005-06-27 14:59:41 +0200947};
948
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100949static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +0200950 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
951 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matt Porter403d1942005-11-29 15:00:51 +0100952 STAC_CODEC_IO_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +0200953};
954
955/* add dynamic controls */
956static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
957{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100958 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +0200959
960 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
961 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
962
963 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
964 if (! knew)
965 return -ENOMEM;
966 if (spec->kctl_alloc) {
967 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
968 kfree(spec->kctl_alloc);
969 }
970 spec->kctl_alloc = knew;
971 spec->num_kctl_alloc = num;
972 }
973
974 knew = &spec->kctl_alloc[spec->num_kctl_used];
975 *knew = stac92xx_control_templates[type];
Takashi Iwai82fe0c52005-06-30 10:54:33 +0200976 knew->name = kstrdup(name, GFP_KERNEL);
Mattc7d4b2f2005-06-27 14:59:41 +0200977 if (! knew->name)
978 return -ENOMEM;
979 knew->private_value = val;
980 spec->num_kctl_used++;
981 return 0;
982}
983
Matt Porter403d1942005-11-29 15:00:51 +0100984/* flag inputs as additional dynamic lineouts */
985static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
986{
987 struct sigmatel_spec *spec = codec->spec;
988
989 switch (cfg->line_outs) {
990 case 3:
991 /* add line-in as side */
992 if (cfg->input_pins[AUTO_PIN_LINE]) {
993 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE];
994 spec->line_switch = 1;
995 cfg->line_outs++;
996 }
997 break;
998 case 2:
999 /* add line-in as clfe and mic as side */
1000 if (cfg->input_pins[AUTO_PIN_LINE]) {
1001 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE];
1002 spec->line_switch = 1;
1003 cfg->line_outs++;
1004 }
1005 if (cfg->input_pins[AUTO_PIN_MIC]) {
1006 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC];
1007 spec->mic_switch = 1;
1008 cfg->line_outs++;
1009 }
1010 break;
1011 case 1:
1012 /* add line-in as surr and mic as clfe */
1013 if (cfg->input_pins[AUTO_PIN_LINE]) {
1014 cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE];
1015 spec->line_switch = 1;
1016 cfg->line_outs++;
1017 }
1018 if (cfg->input_pins[AUTO_PIN_MIC]) {
1019 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC];
1020 spec->mic_switch = 1;
1021 cfg->line_outs++;
1022 }
1023 break;
1024 }
1025
1026 return 0;
1027}
1028
Matt Porter3cc08dc2006-01-23 15:27:49 +01001029/*
1030 * XXX The line_out pin widget connection list may not be set to the
1031 * desired DAC nid. This is the case on 927x where ports A and B can
1032 * be routed to several DACs.
1033 *
1034 * This requires an analysis of the line-out/hp pin configuration
1035 * to provide a best fit for pin/DAC configurations that are routable.
1036 * For now, 927x DAC4 is not supported and 927x DAC1 output to ports
1037 * A and B is not supported.
1038 */
Mattc7d4b2f2005-06-27 14:59:41 +02001039/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai19039bd2006-06-28 15:52:16 +02001040static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
1041 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02001042{
1043 struct sigmatel_spec *spec = codec->spec;
1044 hda_nid_t nid;
1045 int i;
1046
1047 /* check the pins hardwired to audio widget */
1048 for (i = 0; i < cfg->line_outs; i++) {
1049 nid = cfg->line_out_pins[i];
1050 spec->multiout.dac_nids[i] = snd_hda_codec_read(codec, nid, 0,
1051 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1052 }
1053
Takashi Iwai82bc9552006-03-21 11:24:42 +01001054 spec->multiout.num_dacs = cfg->line_outs;
Mattc7d4b2f2005-06-27 14:59:41 +02001055
1056 return 0;
1057}
1058
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001059/* create volume control/switch for the given prefx type */
1060static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
1061{
1062 char name[32];
1063 int err;
1064
1065 sprintf(name, "%s Playback Volume", pfx);
1066 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
1067 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1068 if (err < 0)
1069 return err;
1070 sprintf(name, "%s Playback Switch", pfx);
1071 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
1072 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1073 if (err < 0)
1074 return err;
1075 return 0;
1076}
1077
Mattc7d4b2f2005-06-27 14:59:41 +02001078/* add playback controls from the parsed DAC table */
Takashi Iwai19039bd2006-06-28 15:52:16 +02001079static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec,
1080 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02001081{
Takashi Iwai19039bd2006-06-28 15:52:16 +02001082 static const char *chname[4] = {
1083 "Front", "Surround", NULL /*CLFE*/, "Side"
1084 };
Mattc7d4b2f2005-06-27 14:59:41 +02001085 hda_nid_t nid;
1086 int i, err;
1087
1088 for (i = 0; i < cfg->line_outs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01001089 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02001090 continue;
1091
1092 nid = spec->multiout.dac_nids[i];
1093
1094 if (i == 2) {
1095 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001096 err = create_controls(spec, "Center", nid, 1);
1097 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001098 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001099 err = create_controls(spec, "LFE", nid, 2);
1100 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001101 return err;
1102 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001103 err = create_controls(spec, chname[i], nid, 3);
1104 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001105 return err;
1106 }
1107 }
1108
Matt Porter403d1942005-11-29 15:00:51 +01001109 if (spec->line_switch)
1110 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
1111 return err;
1112
1113 if (spec->mic_switch)
1114 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
1115 return err;
1116
Mattc7d4b2f2005-06-27 14:59:41 +02001117 return 0;
1118}
1119
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001120static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1121{
1122 int i;
1123
1124 for (i = 0; i < spec->multiout.num_dacs; i++) {
1125 if (spec->multiout.dac_nids[i] == nid)
1126 return 1;
1127 }
1128 if (spec->multiout.hp_nid == nid)
1129 return 1;
1130 return 0;
1131}
1132
1133static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
1134{
1135 if (!spec->multiout.hp_nid)
1136 spec->multiout.hp_nid = nid;
1137 else if (spec->multiout.num_dacs > 4) {
1138 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
1139 return 1;
1140 } else {
1141 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
1142 spec->multiout.num_dacs++;
1143 }
1144 return 0;
1145}
1146
1147/* add playback controls for Speaker and HP outputs */
1148static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
1149 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02001150{
1151 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02001152 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001153 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02001154
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001155 old_num_dacs = spec->multiout.num_dacs;
1156 for (i = 0; i < cfg->hp_outs; i++) {
1157 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
1158 if (wid_caps & AC_WCAP_UNSOL_CAP)
1159 spec->hp_detect = 1;
1160 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
1161 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1162 if (check_in_dac_nids(spec, nid))
1163 nid = 0;
1164 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02001165 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001166 add_spec_dacs(spec, nid);
1167 }
1168 for (i = 0; i < cfg->speaker_outs; i++) {
1169 nid = snd_hda_codec_read(codec, cfg->speaker_pins[0], 0,
1170 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1171 if (check_in_dac_nids(spec, nid))
1172 nid = 0;
1173 if (check_in_dac_nids(spec, nid))
1174 nid = 0;
1175 if (! nid)
1176 continue;
1177 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02001178 }
1179
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001180 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
1181 static const char *pfxs[] = {
1182 "Speaker", "External Speaker", "Speaker2",
1183 };
1184 err = create_controls(spec, pfxs[i - old_num_dacs],
1185 spec->multiout.dac_nids[i], 3);
1186 if (err < 0)
1187 return err;
1188 }
1189 if (spec->multiout.hp_nid) {
1190 const char *pfx;
1191 if (old_num_dacs == spec->multiout.num_dacs)
1192 pfx = "Master";
1193 else
1194 pfx = "Headphone";
1195 err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
1196 if (err < 0)
1197 return err;
1198 }
Mattc7d4b2f2005-06-27 14:59:41 +02001199
1200 return 0;
1201}
1202
Matt Porter8b657272006-10-26 17:12:59 +02001203/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01001204static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02001205 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
1206 "Digital Mic 3", "Digital Mic 4"
1207};
1208
1209/* create playback/capture controls for input pins on dmic capable codecs */
1210static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
1211 const struct auto_pin_cfg *cfg)
1212{
1213 struct sigmatel_spec *spec = codec->spec;
1214 struct hda_input_mux *dimux = &spec->private_dimux;
1215 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1216 int i, j;
1217
1218 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
1219 dimux->items[dimux->num_items].index = 0;
1220 dimux->num_items++;
1221
1222 for (i = 0; i < spec->num_dmics; i++) {
1223 int index;
1224 int num_cons;
1225 unsigned int def_conf;
1226
1227 def_conf = snd_hda_codec_read(codec,
1228 spec->dmic_nids[i],
1229 0,
1230 AC_VERB_GET_CONFIG_DEFAULT,
1231 0);
1232 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
1233 continue;
1234
1235 num_cons = snd_hda_get_connections(codec,
1236 spec->dmux_nid,
1237 con_lst,
1238 HDA_MAX_NUM_INPUTS);
1239 for (j = 0; j < num_cons; j++)
1240 if (con_lst[j] == spec->dmic_nids[i]) {
1241 index = j;
1242 goto found;
1243 }
1244 continue;
1245found:
1246 dimux->items[dimux->num_items].label =
1247 stac92xx_dmic_labels[dimux->num_items];
1248 dimux->items[dimux->num_items].index = index;
1249 dimux->num_items++;
1250 }
1251
1252 return 0;
1253}
1254
Mattc7d4b2f2005-06-27 14:59:41 +02001255/* create playback/capture controls for input pins */
1256static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
1257{
1258 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02001259 struct hda_input_mux *imux = &spec->private_imux;
1260 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1261 int i, j, k;
1262
1263 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02001264 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02001265
Takashi Iwai314634b2006-09-21 11:56:18 +02001266 if (!cfg->input_pins[i])
1267 continue;
1268 index = -1;
1269 for (j = 0; j < spec->num_muxes; j++) {
1270 int num_cons;
1271 num_cons = snd_hda_get_connections(codec,
1272 spec->mux_nids[j],
1273 con_lst,
1274 HDA_MAX_NUM_INPUTS);
1275 for (k = 0; k < num_cons; k++)
1276 if (con_lst[k] == cfg->input_pins[i]) {
1277 index = k;
1278 goto found;
1279 }
Mattc7d4b2f2005-06-27 14:59:41 +02001280 }
Takashi Iwai314634b2006-09-21 11:56:18 +02001281 continue;
1282 found:
1283 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
1284 imux->items[imux->num_items].index = index;
1285 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02001286 }
1287
Sam Revitch62fe78e2006-05-10 15:09:17 +02001288 if (imux->num_items == 1) {
1289 /*
1290 * Set the current input for the muxes.
1291 * The STAC9221 has two input muxes with identical source
1292 * NID lists. Hopefully this won't get confused.
1293 */
1294 for (i = 0; i < spec->num_muxes; i++) {
1295 snd_hda_codec_write(codec, spec->mux_nids[i], 0,
1296 AC_VERB_SET_CONNECT_SEL,
1297 imux->items[0].index);
1298 }
1299 }
1300
Mattc7d4b2f2005-06-27 14:59:41 +02001301 return 0;
1302}
1303
Mattc7d4b2f2005-06-27 14:59:41 +02001304static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
1305{
1306 struct sigmatel_spec *spec = codec->spec;
1307 int i;
1308
1309 for (i = 0; i < spec->autocfg.line_outs; i++) {
1310 hda_nid_t nid = spec->autocfg.line_out_pins[i];
1311 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
1312 }
1313}
1314
1315static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
1316{
1317 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001318 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02001319
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001320 for (i = 0; i < spec->autocfg.hp_outs; i++) {
1321 hda_nid_t pin;
1322 pin = spec->autocfg.hp_pins[i];
1323 if (pin) /* connect to front */
1324 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
1325 }
1326 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
1327 hda_nid_t pin;
1328 pin = spec->autocfg.speaker_pins[i];
1329 if (pin) /* connect to front */
1330 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
1331 }
Mattc7d4b2f2005-06-27 14:59:41 +02001332}
1333
Matt Porter3cc08dc2006-01-23 15:27:49 +01001334static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
Mattc7d4b2f2005-06-27 14:59:41 +02001335{
1336 struct sigmatel_spec *spec = codec->spec;
1337 int err;
1338
Matt Porter8b657272006-10-26 17:12:59 +02001339 if ((err = snd_hda_parse_pin_def_config(codec,
1340 &spec->autocfg,
1341 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001342 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001343 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01001344 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02001345
Matt Porter403d1942005-11-29 15:00:51 +01001346 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
1347 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02001348 if (spec->multiout.num_dacs == 0)
1349 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
1350 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001351
1352 if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
1353 (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 ||
1354 (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
1355 return err;
1356
Matt Porter8b657272006-10-26 17:12:59 +02001357 if (spec->num_dmics > 0)
1358 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
1359 &spec->autocfg)) < 0)
1360 return err;
1361
Mattc7d4b2f2005-06-27 14:59:41 +02001362 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01001363 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02001364 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02001365
Takashi Iwai82bc9552006-03-21 11:24:42 +01001366 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01001367 spec->multiout.dig_out_nid = dig_out;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001368 if (spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01001369 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02001370
1371 if (spec->kctl_alloc)
1372 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
1373
1374 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02001375 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02001376
1377 return 1;
1378}
1379
Takashi Iwai82bc9552006-03-21 11:24:42 +01001380/* add playback controls for HP output */
1381static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
1382 struct auto_pin_cfg *cfg)
1383{
1384 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001385 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01001386 unsigned int wid_caps;
1387
1388 if (! pin)
1389 return 0;
1390
1391 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02001392 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01001393 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001394
1395 return 0;
1396}
1397
Richard Fish160ea0d2006-09-06 13:58:25 +02001398/* add playback controls for LFE output */
1399static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
1400 struct auto_pin_cfg *cfg)
1401{
1402 struct sigmatel_spec *spec = codec->spec;
1403 int err;
1404 hda_nid_t lfe_pin = 0x0;
1405 int i;
1406
1407 /*
1408 * search speaker outs and line outs for a mono speaker pin
1409 * with an amp. If one is found, add LFE controls
1410 * for it.
1411 */
1412 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
1413 hda_nid_t pin = spec->autocfg.speaker_pins[i];
1414 unsigned long wcaps = get_wcaps(codec, pin);
1415 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
1416 if (wcaps == AC_WCAP_OUT_AMP)
1417 /* found a mono speaker with an amp, must be lfe */
1418 lfe_pin = pin;
1419 }
1420
1421 /* if speaker_outs is 0, then speakers may be in line_outs */
1422 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
1423 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
1424 hda_nid_t pin = spec->autocfg.line_out_pins[i];
1425 unsigned long cfg;
1426 cfg = snd_hda_codec_read(codec, pin, 0,
1427 AC_VERB_GET_CONFIG_DEFAULT,
1428 0x00);
1429 if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) {
1430 unsigned long wcaps = get_wcaps(codec, pin);
1431 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
1432 if (wcaps == AC_WCAP_OUT_AMP)
1433 /* found a mono speaker with an amp,
1434 must be lfe */
1435 lfe_pin = pin;
1436 }
1437 }
1438 }
1439
1440 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001441 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02001442 if (err < 0)
1443 return err;
1444 }
1445
1446 return 0;
1447}
1448
Mattc7d4b2f2005-06-27 14:59:41 +02001449static int stac9200_parse_auto_config(struct hda_codec *codec)
1450{
1451 struct sigmatel_spec *spec = codec->spec;
1452 int err;
1453
Kailang Yangdf694da2005-12-05 19:42:22 +01001454 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001455 return err;
1456
1457 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
1458 return err;
1459
Takashi Iwai82bc9552006-03-21 11:24:42 +01001460 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
1461 return err;
1462
Richard Fish160ea0d2006-09-06 13:58:25 +02001463 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
1464 return err;
1465
Takashi Iwai82bc9552006-03-21 11:24:42 +01001466 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02001467 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001468 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02001469 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02001470
1471 if (spec->kctl_alloc)
1472 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
1473
1474 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02001475 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02001476
1477 return 1;
1478}
1479
Sam Revitch62fe78e2006-05-10 15:09:17 +02001480/*
1481 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
1482 * funky external mute control using GPIO pins.
1483 */
1484
1485static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted)
1486{
1487 unsigned int gpiostate, gpiomask, gpiodir;
1488
1489 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
1490 AC_VERB_GET_GPIO_DATA, 0);
1491
1492 if (!muted)
1493 gpiostate |= (1 << pin);
1494 else
1495 gpiostate &= ~(1 << pin);
1496
1497 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
1498 AC_VERB_GET_GPIO_MASK, 0);
1499 gpiomask |= (1 << pin);
1500
1501 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
1502 AC_VERB_GET_GPIO_DIRECTION, 0);
1503 gpiodir |= (1 << pin);
1504
1505 /* AppleHDA seems to do this -- WTF is this verb?? */
1506 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
1507
1508 snd_hda_codec_write(codec, codec->afg, 0,
1509 AC_VERB_SET_GPIO_MASK, gpiomask);
1510 snd_hda_codec_write(codec, codec->afg, 0,
1511 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
1512
1513 msleep(1);
1514
1515 snd_hda_codec_write(codec, codec->afg, 0,
1516 AC_VERB_SET_GPIO_DATA, gpiostate);
1517}
1518
Takashi Iwai314634b2006-09-21 11:56:18 +02001519static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
1520 unsigned int event)
1521{
1522 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
1523 snd_hda_codec_write(codec, nid, 0,
1524 AC_VERB_SET_UNSOLICITED_ENABLE,
1525 (AC_USRSP_EN | event));
1526}
1527
Mattc7d4b2f2005-06-27 14:59:41 +02001528static int stac92xx_init(struct hda_codec *codec)
1529{
1530 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001531 struct auto_pin_cfg *cfg = &spec->autocfg;
1532 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02001533
Mattc7d4b2f2005-06-27 14:59:41 +02001534 snd_hda_sequence_write(codec, spec->init);
1535
Takashi Iwai82bc9552006-03-21 11:24:42 +01001536 /* set up pins */
1537 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02001538 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001539 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02001540 enable_pin_detect(codec, cfg->hp_pins[i],
1541 STAC_HP_EVENT);
Takashi Iwaieb995a82006-09-21 14:28:21 +02001542 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01001543 /* fake event to set up pins */
1544 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
1545 } else {
1546 stac92xx_auto_init_multi_out(codec);
1547 stac92xx_auto_init_hp_out(codec);
1548 }
1549 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01001550 hda_nid_t nid = cfg->input_pins[i];
1551 if (nid) {
1552 unsigned int pinctl = AC_PINCTL_IN_EN;
1553 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
1554 pinctl |= stac92xx_get_vref(codec, nid);
1555 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1556 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01001557 }
Matt Porter8b657272006-10-26 17:12:59 +02001558 if (spec->num_dmics > 0)
1559 for (i = 0; i < spec->num_dmics; i++)
1560 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
1561 AC_PINCTL_IN_EN);
1562
Takashi Iwai82bc9552006-03-21 11:24:42 +01001563 if (cfg->dig_out_pin)
1564 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
1565 AC_PINCTL_OUT_EN);
1566 if (cfg->dig_in_pin)
1567 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
1568 AC_PINCTL_IN_EN);
1569
Sam Revitch62fe78e2006-05-10 15:09:17 +02001570 if (spec->gpio_mute) {
1571 stac922x_gpio_mute(codec, 0, 0);
1572 stac922x_gpio_mute(codec, 1, 0);
1573 }
1574
Mattc7d4b2f2005-06-27 14:59:41 +02001575 return 0;
1576}
1577
Matt2f2f4252005-04-13 14:45:30 +02001578static void stac92xx_free(struct hda_codec *codec)
1579{
Mattc7d4b2f2005-06-27 14:59:41 +02001580 struct sigmatel_spec *spec = codec->spec;
1581 int i;
1582
1583 if (! spec)
1584 return;
1585
1586 if (spec->kctl_alloc) {
1587 for (i = 0; i < spec->num_kctl_used; i++)
1588 kfree(spec->kctl_alloc[i].name);
1589 kfree(spec->kctl_alloc);
1590 }
1591
Richard Fish11b44bb2006-08-23 18:31:34 +02001592 if (spec->bios_pin_configs)
1593 kfree(spec->bios_pin_configs);
1594
Mattc7d4b2f2005-06-27 14:59:41 +02001595 kfree(spec);
Matt2f2f4252005-04-13 14:45:30 +02001596}
1597
Matt4e550962005-07-04 17:51:39 +02001598static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
1599 unsigned int flag)
1600{
1601 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1602 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Takashi Iwai314634b2006-09-21 11:56:18 +02001603 if (flag == AC_PINCTL_OUT_EN && (pin_ctl & AC_PINCTL_IN_EN))
1604 return;
Matt4e550962005-07-04 17:51:39 +02001605 snd_hda_codec_write(codec, nid, 0,
1606 AC_VERB_SET_PIN_WIDGET_CONTROL,
1607 pin_ctl | flag);
1608}
1609
1610static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
1611 unsigned int flag)
1612{
1613 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1614 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
1615 snd_hda_codec_write(codec, nid, 0,
1616 AC_VERB_SET_PIN_WIDGET_CONTROL,
1617 pin_ctl & ~flag);
1618}
1619
Takashi Iwai314634b2006-09-21 11:56:18 +02001620static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
1621{
1622 if (!nid)
1623 return 0;
1624 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
1625 & (1 << 31))
1626 return 1;
1627 return 0;
1628}
1629
1630static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02001631{
1632 struct sigmatel_spec *spec = codec->spec;
1633 struct auto_pin_cfg *cfg = &spec->autocfg;
1634 int i, presence;
1635
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001636 presence = 0;
1637 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02001638 presence = get_pin_presence(codec, cfg->hp_pins[i]);
1639 if (presence)
1640 break;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001641 }
Matt4e550962005-07-04 17:51:39 +02001642
1643 if (presence) {
1644 /* disable lineouts, enable hp */
1645 for (i = 0; i < cfg->line_outs; i++)
1646 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
1647 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001648 for (i = 0; i < cfg->speaker_outs; i++)
1649 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
1650 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02001651 } else {
1652 /* enable lineouts, disable hp */
1653 for (i = 0; i < cfg->line_outs; i++)
1654 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
1655 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001656 for (i = 0; i < cfg->speaker_outs; i++)
1657 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
1658 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02001659 }
1660}
1661
Takashi Iwai314634b2006-09-21 11:56:18 +02001662static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
1663{
1664 switch (res >> 26) {
1665 case STAC_HP_EVENT:
1666 stac92xx_hp_detect(codec, res);
1667 break;
1668 }
1669}
1670
Mattff6fdc32005-06-27 15:06:52 +02001671#ifdef CONFIG_PM
1672static int stac92xx_resume(struct hda_codec *codec)
1673{
1674 struct sigmatel_spec *spec = codec->spec;
1675 int i;
1676
1677 stac92xx_init(codec);
Richard Fish11b44bb2006-08-23 18:31:34 +02001678 stac92xx_set_config_regs(codec);
Mattff6fdc32005-06-27 15:06:52 +02001679 for (i = 0; i < spec->num_mixers; i++)
1680 snd_hda_resume_ctls(codec, spec->mixers[i]);
1681 if (spec->multiout.dig_out_nid)
1682 snd_hda_resume_spdif_out(codec);
1683 if (spec->dig_in_nid)
1684 snd_hda_resume_spdif_in(codec);
1685
1686 return 0;
1687}
1688#endif
1689
Matt2f2f4252005-04-13 14:45:30 +02001690static struct hda_codec_ops stac92xx_patch_ops = {
1691 .build_controls = stac92xx_build_controls,
1692 .build_pcms = stac92xx_build_pcms,
1693 .init = stac92xx_init,
1694 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02001695 .unsol_event = stac92xx_unsol_event,
Mattff6fdc32005-06-27 15:06:52 +02001696#ifdef CONFIG_PM
1697 .resume = stac92xx_resume,
1698#endif
Matt2f2f4252005-04-13 14:45:30 +02001699};
1700
1701static int patch_stac9200(struct hda_codec *codec)
1702{
1703 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02001704 int err;
Matt2f2f4252005-04-13 14:45:30 +02001705
Takashi Iwaie560d8d2005-09-09 14:21:46 +02001706 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02001707 if (spec == NULL)
1708 return -ENOMEM;
1709
1710 codec->spec = spec;
Richard Fish11b44bb2006-08-23 18:31:34 +02001711 spec->num_pins = 8;
1712 spec->pin_nids = stac9200_pin_nids;
Matt Porter403d1942005-11-29 15:00:51 +01001713 spec->board_config = snd_hda_check_board_config(codec, stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02001714 if (spec->board_config < 0) {
1715 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
1716 err = stac92xx_save_bios_config_regs(codec);
1717 if (err < 0) {
1718 stac92xx_free(codec);
1719 return err;
1720 }
1721 spec->pin_configs = spec->bios_pin_configs;
1722 } else {
Matt Porter403d1942005-11-29 15:00:51 +01001723 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
1724 stac92xx_set_config_regs(codec);
1725 }
Matt2f2f4252005-04-13 14:45:30 +02001726
1727 spec->multiout.max_channels = 2;
1728 spec->multiout.num_dacs = 1;
1729 spec->multiout.dac_nids = stac9200_dac_nids;
1730 spec->adc_nids = stac9200_adc_nids;
1731 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02001732 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02001733 spec->num_dmics = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02001734
1735 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02001736 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02001737
1738 err = stac9200_parse_auto_config(codec);
1739 if (err < 0) {
1740 stac92xx_free(codec);
1741 return err;
1742 }
Matt2f2f4252005-04-13 14:45:30 +02001743
1744 codec->patch_ops = stac92xx_patch_ops;
1745
1746 return 0;
1747}
1748
1749static int patch_stac922x(struct hda_codec *codec)
1750{
1751 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02001752 int err;
Matt2f2f4252005-04-13 14:45:30 +02001753
Takashi Iwaie560d8d2005-09-09 14:21:46 +02001754 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02001755 if (spec == NULL)
1756 return -ENOMEM;
1757
1758 codec->spec = spec;
Richard Fish11b44bb2006-08-23 18:31:34 +02001759 spec->num_pins = 10;
1760 spec->pin_nids = stac922x_pin_nids;
Matt Porter403d1942005-11-29 15:00:51 +01001761 spec->board_config = snd_hda_check_board_config(codec, stac922x_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02001762 if (spec->board_config < 0) {
1763 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
1764 "using BIOS defaults\n");
1765 err = stac92xx_save_bios_config_regs(codec);
1766 if (err < 0) {
1767 stac92xx_free(codec);
1768 return err;
1769 }
1770 spec->pin_configs = spec->bios_pin_configs;
1771 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01001772 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
1773 stac92xx_set_config_regs(codec);
1774 }
Matt2f2f4252005-04-13 14:45:30 +02001775
Matt2f2f4252005-04-13 14:45:30 +02001776 spec->adc_nids = stac922x_adc_nids;
1777 spec->mux_nids = stac922x_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02001778 spec->num_muxes = 2;
Matt Porter8b657272006-10-26 17:12:59 +02001779 spec->num_dmics = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02001780
1781 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02001782 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02001783
1784 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02001785
Matt Porter3cc08dc2006-01-23 15:27:49 +01001786 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
1787 if (err < 0) {
1788 stac92xx_free(codec);
1789 return err;
1790 }
1791
Sam Revitch62fe78e2006-05-10 15:09:17 +02001792 if (spec->board_config == STAC_MACMINI)
1793 spec->gpio_mute = 1;
1794
Matt Porter3cc08dc2006-01-23 15:27:49 +01001795 codec->patch_ops = stac92xx_patch_ops;
1796
1797 return 0;
1798}
1799
1800static int patch_stac927x(struct hda_codec *codec)
1801{
1802 struct sigmatel_spec *spec;
1803 int err;
1804
1805 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1806 if (spec == NULL)
1807 return -ENOMEM;
1808
1809 codec->spec = spec;
Richard Fish11b44bb2006-08-23 18:31:34 +02001810 spec->num_pins = 14;
1811 spec->pin_nids = stac927x_pin_nids;
Matt Porter3cc08dc2006-01-23 15:27:49 +01001812 spec->board_config = snd_hda_check_board_config(codec, stac927x_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02001813 if (spec->board_config < 0) {
Matt Porter3cc08dc2006-01-23 15:27:49 +01001814 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02001815 err = stac92xx_save_bios_config_regs(codec);
1816 if (err < 0) {
1817 stac92xx_free(codec);
1818 return err;
1819 }
1820 spec->pin_configs = spec->bios_pin_configs;
1821 } else if (stac927x_brd_tbl[spec->board_config] != NULL) {
Matt Porter3cc08dc2006-01-23 15:27:49 +01001822 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
1823 stac92xx_set_config_regs(codec);
1824 }
1825
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001826 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02001827 case STAC_D965_3ST:
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001828 spec->adc_nids = stac927x_adc_nids;
1829 spec->mux_nids = stac927x_mux_nids;
1830 spec->num_muxes = 3;
Matt Porter8b657272006-10-26 17:12:59 +02001831 spec->num_dmics = 0;
Tobin Davis93ed1502006-09-01 21:03:12 +02001832 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001833 spec->mixer = stac9227_mixer;
1834 break;
Tobin Davis93ed1502006-09-01 21:03:12 +02001835 case STAC_D965_5ST:
1836 spec->adc_nids = stac927x_adc_nids;
1837 spec->mux_nids = stac927x_mux_nids;
1838 spec->num_muxes = 3;
Matt Porter8b657272006-10-26 17:12:59 +02001839 spec->num_dmics = 0;
Tobin Davis93ed1502006-09-01 21:03:12 +02001840 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001841 spec->mixer = stac9227_mixer;
1842 break;
1843 default:
1844 spec->adc_nids = stac927x_adc_nids;
1845 spec->mux_nids = stac927x_mux_nids;
1846 spec->num_muxes = 3;
Matt Porter8b657272006-10-26 17:12:59 +02001847 spec->num_dmics = 0;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02001848 spec->init = stac927x_core_init;
1849 spec->mixer = stac927x_mixer;
1850 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01001851
1852 spec->multiout.dac_nids = spec->dac_nids;
1853
1854 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Mattc7d4b2f2005-06-27 14:59:41 +02001855 if (err < 0) {
1856 stac92xx_free(codec);
1857 return err;
1858 }
Matt2f2f4252005-04-13 14:45:30 +02001859
1860 codec->patch_ops = stac92xx_patch_ops;
1861
1862 return 0;
1863}
1864
Matt Porterf3302a52006-07-31 12:49:34 +02001865static int patch_stac9205(struct hda_codec *codec)
1866{
1867 struct sigmatel_spec *spec;
1868 int err;
1869
1870 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1871 if (spec == NULL)
1872 return -ENOMEM;
1873
1874 codec->spec = spec;
Richard Fish11b44bb2006-08-23 18:31:34 +02001875 spec->num_pins = 14;
1876 spec->pin_nids = stac9205_pin_nids;
Matt Porterf3302a52006-07-31 12:49:34 +02001877 spec->board_config = snd_hda_check_board_config(codec, stac9205_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02001878 if (spec->board_config < 0) {
1879 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
1880 err = stac92xx_save_bios_config_regs(codec);
1881 if (err < 0) {
1882 stac92xx_free(codec);
1883 return err;
1884 }
1885 spec->pin_configs = spec->bios_pin_configs;
1886 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02001887 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
1888 stac92xx_set_config_regs(codec);
1889 }
1890
1891 spec->adc_nids = stac9205_adc_nids;
1892 spec->mux_nids = stac9205_mux_nids;
Matt Porter8b657272006-10-26 17:12:59 +02001893 spec->num_muxes = 2;
1894 spec->dmic_nids = stac9205_dmic_nids;
1895 spec->num_dmics = 2;
1896 spec->dmux_nid = 0x1d;
Matt Porterf3302a52006-07-31 12:49:34 +02001897
1898 spec->init = stac9205_core_init;
1899 spec->mixer = stac9205_mixer;
1900
1901 spec->multiout.dac_nids = spec->dac_nids;
1902
1903 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
1904 if (err < 0) {
1905 stac92xx_free(codec);
1906 return err;
1907 }
1908
1909 codec->patch_ops = stac92xx_patch_ops;
1910
1911 return 0;
1912}
1913
Matt2f2f4252005-04-13 14:45:30 +02001914/*
Guillaume Munch6d859062006-08-22 17:15:47 +02001915 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01001916 */
1917
Guillaume Munch99ccc562006-08-16 19:35:12 +02001918/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01001919static hda_nid_t vaio_dacs[] = { 0x2 };
1920#define VAIO_HP_DAC 0x5
1921static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
1922static hda_nid_t vaio_mux_nids[] = { 0x15 };
1923
1924static struct hda_input_mux vaio_mux = {
1925 .num_items = 2,
1926 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02001927 /* { "HP", 0x0 }, */
1928 { "Line", 0x1 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01001929 { "Mic", 0x2 },
1930 { "PCM", 0x3 },
1931 }
1932};
1933
1934static struct hda_verb vaio_init[] = {
1935 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
1936 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
1937 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
1938 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
1939 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
1940 {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
1941 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
1942 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
1943 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
1944 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
1945 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
1946 {}
1947};
1948
Guillaume Munch6d859062006-08-22 17:15:47 +02001949static struct hda_verb vaio_ar_init[] = {
1950 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
1951 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
1952 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
1953 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
1954/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
1955 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
1956 {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
1957 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
1958 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
1959/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
1960 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
1961 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
1962 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
1963 {}
1964};
1965
Takashi Iwaidb064e52006-03-16 16:04:58 +01001966/* bind volumes of both NID 0x02 and 0x05 */
1967static int vaio_master_vol_put(struct snd_kcontrol *kcontrol,
1968 struct snd_ctl_elem_value *ucontrol)
1969{
1970 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1971 long *valp = ucontrol->value.integer.value;
1972 int change;
1973
1974 change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
1975 0x7f, valp[0] & 0x7f);
1976 change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
1977 0x7f, valp[1] & 0x7f);
1978 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
1979 0x7f, valp[0] & 0x7f);
1980 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
1981 0x7f, valp[1] & 0x7f);
1982 return change;
1983}
1984
1985/* bind volumes of both NID 0x02 and 0x05 */
1986static int vaio_master_sw_put(struct snd_kcontrol *kcontrol,
1987 struct snd_ctl_elem_value *ucontrol)
1988{
1989 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1990 long *valp = ucontrol->value.integer.value;
1991 int change;
1992
1993 change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
Takashi Iwaia9393d72006-05-03 11:59:03 +02001994 0x80, (valp[0] ? 0 : 0x80));
Takashi Iwaidb064e52006-03-16 16:04:58 +01001995 change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
Takashi Iwaia9393d72006-05-03 11:59:03 +02001996 0x80, (valp[1] ? 0 : 0x80));
Takashi Iwaidb064e52006-03-16 16:04:58 +01001997 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
Takashi Iwaia9393d72006-05-03 11:59:03 +02001998 0x80, (valp[0] ? 0 : 0x80));
Takashi Iwaidb064e52006-03-16 16:04:58 +01001999 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
Takashi Iwaia9393d72006-05-03 11:59:03 +02002000 0x80, (valp[1] ? 0 : 0x80));
Takashi Iwaidb064e52006-03-16 16:04:58 +01002001 return change;
2002}
2003
2004static struct snd_kcontrol_new vaio_mixer[] = {
2005 {
2006 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2007 .name = "Master Playback Volume",
2008 .info = snd_hda_mixer_amp_volume_info,
2009 .get = snd_hda_mixer_amp_volume_get,
2010 .put = vaio_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02002011 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwaidb064e52006-03-16 16:04:58 +01002012 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2013 },
2014 {
2015 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2016 .name = "Master Playback Switch",
2017 .info = snd_hda_mixer_amp_switch_info,
2018 .get = snd_hda_mixer_amp_switch_get,
2019 .put = vaio_master_sw_put,
2020 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2021 },
2022 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2023 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
2024 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
2025 {
2026 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2027 .name = "Capture Source",
2028 .count = 1,
2029 .info = stac92xx_mux_enum_info,
2030 .get = stac92xx_mux_enum_get,
2031 .put = stac92xx_mux_enum_put,
2032 },
2033 {}
2034};
2035
Guillaume Munch6d859062006-08-22 17:15:47 +02002036static struct snd_kcontrol_new vaio_ar_mixer[] = {
2037 {
2038 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2039 .name = "Master Playback Volume",
2040 .info = snd_hda_mixer_amp_volume_info,
2041 .get = snd_hda_mixer_amp_volume_get,
2042 .put = vaio_master_vol_put,
2043 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2044 },
2045 {
2046 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2047 .name = "Master Playback Switch",
2048 .info = snd_hda_mixer_amp_switch_info,
2049 .get = snd_hda_mixer_amp_switch_get,
2050 .put = vaio_master_sw_put,
2051 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2052 },
2053 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2054 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
2055 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
2056 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
2057 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
2058 {
2059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2060 .name = "Capture Source",
2061 .count = 1,
2062 .info = stac92xx_mux_enum_info,
2063 .get = stac92xx_mux_enum_get,
2064 .put = stac92xx_mux_enum_put,
2065 },
2066 {}
2067};
2068
2069static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01002070 .build_controls = stac92xx_build_controls,
2071 .build_pcms = stac92xx_build_pcms,
2072 .init = stac92xx_init,
2073 .free = stac92xx_free,
2074#ifdef CONFIG_PM
2075 .resume = stac92xx_resume,
2076#endif
2077};
2078
Guillaume Munch6d859062006-08-22 17:15:47 +02002079enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
2080 CXD9872RD_VAIO,
2081 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
2082 STAC9872AK_VAIO,
2083 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
2084 STAC9872K_VAIO,
2085 /* AR Series. id=0x83847664 and subsys=104D1300 */
2086 CXD9872AKD_VAIO
2087 };
Takashi Iwaidb064e52006-03-16 16:04:58 +01002088
Guillaume Munch6d859062006-08-22 17:15:47 +02002089static struct hda_board_config stac9872_cfg_tbl[] = {
2090 { .modelname = "vaio", .config = CXD9872RD_VAIO },
2091 { .modelname = "vaio-ar", .config = CXD9872AKD_VAIO },
Takashi Iwaidb064e52006-03-16 16:04:58 +01002092 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81e6,
Guillaume Munch6d859062006-08-22 17:15:47 +02002093 .config = CXD9872RD_VAIO },
Takashi Iwaidb064e52006-03-16 16:04:58 +01002094 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81ef,
Guillaume Munch6d859062006-08-22 17:15:47 +02002095 .config = CXD9872RD_VAIO },
Guillaume Munch99ccc562006-08-16 19:35:12 +02002096 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81fd,
Guillaume Munch6d859062006-08-22 17:15:47 +02002097 .config = CXD9872AKD_VAIO },
Takashi Iwaidb064e52006-03-16 16:04:58 +01002098 {}
2099};
2100
Guillaume Munch6d859062006-08-22 17:15:47 +02002101static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01002102{
2103 struct sigmatel_spec *spec;
2104 int board_config;
2105
Guillaume Munch6d859062006-08-22 17:15:47 +02002106 board_config = snd_hda_check_board_config(codec, stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01002107 if (board_config < 0)
2108 /* unknown config, let generic-parser do its job... */
2109 return snd_hda_parse_generic_codec(codec);
2110
2111 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2112 if (spec == NULL)
2113 return -ENOMEM;
2114
2115 codec->spec = spec;
2116 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02002117 case CXD9872RD_VAIO:
2118 case STAC9872AK_VAIO:
2119 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01002120 spec->mixer = vaio_mixer;
2121 spec->init = vaio_init;
2122 spec->multiout.max_channels = 2;
2123 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
2124 spec->multiout.dac_nids = vaio_dacs;
2125 spec->multiout.hp_nid = VAIO_HP_DAC;
2126 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
2127 spec->adc_nids = vaio_adcs;
2128 spec->input_mux = &vaio_mux;
2129 spec->mux_nids = vaio_mux_nids;
2130 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02002131
2132 case CXD9872AKD_VAIO:
2133 spec->mixer = vaio_ar_mixer;
2134 spec->init = vaio_ar_init;
2135 spec->multiout.max_channels = 2;
2136 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
2137 spec->multiout.dac_nids = vaio_dacs;
2138 spec->multiout.hp_nid = VAIO_HP_DAC;
2139 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
2140 spec->adc_nids = vaio_adcs;
2141 spec->input_mux = &vaio_mux;
2142 spec->mux_nids = vaio_mux_nids;
2143 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01002144 }
2145
Guillaume Munch6d859062006-08-22 17:15:47 +02002146 codec->patch_ops = stac9872_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01002147 return 0;
2148}
2149
2150
2151/*
Matt2f2f4252005-04-13 14:45:30 +02002152 * patch entries
2153 */
2154struct hda_codec_preset snd_hda_preset_sigmatel[] = {
2155 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
2156 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
2157 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
2158 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
2159 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
2160 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
2161 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02002162 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
2163 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
2164 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
2165 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
2166 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
2167 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01002168 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
2169 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
2170 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
2171 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
2172 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
2173 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
2174 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
2175 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
2176 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
2177 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Guillaume Munch6d859062006-08-22 17:15:47 +02002178 /* The following does not take into account .id=0x83847661 when subsys =
2179 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
2180 * currently not fully supported.
2181 */
2182 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
2183 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
2184 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02002185 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
2186 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
2187 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
2188 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
2189 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
2190 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
2191 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
2192 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matt2f2f4252005-04-13 14:45:30 +02002193 {} /* terminator */
2194};