blob: 36423ca693e78a3a4956b0c534b21010cc3394ef [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
Takashi Iwaif5fcc132006-11-24 17:07:44 +010040enum {
41 STAC_REF,
42 STAC_9200_MODELS
43};
44
45enum {
46 STAC_9205_REF,
47 STAC_9205_MODELS
48};
49
50enum {
Tobin Davis8e21c342007-01-08 11:04:17 +010051 STAC_925x_REF,
52 STAC_M2_2,
53 STAC_MA6,
Tobin Davis2c11f952007-05-17 09:36:34 +020054 STAC_PA6,
Tobin Davis8e21c342007-01-08 11:04:17 +010055 STAC_925x_MODELS
56};
57
58enum {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010059 STAC_D945_REF,
60 STAC_D945GTP3,
61 STAC_D945GTP5,
Takashi Iwai76c08822007-06-19 12:17:42 +020062 STAC_922X_DELL,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +020063 STAC_INTEL_MAC_V1,
64 STAC_INTEL_MAC_V2,
65 STAC_INTEL_MAC_V3,
66 STAC_INTEL_MAC_V4,
67 STAC_INTEL_MAC_V5,
68 /* for backward compitability */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010069 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +010070 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +010071 STAC_MACBOOK_PRO_V1,
72 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +020073 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +020074 STAC_IMAC_INTEL_20,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010075 STAC_922X_MODELS
76};
77
78enum {
79 STAC_D965_REF,
80 STAC_D965_3ST,
81 STAC_D965_5ST,
82 STAC_927X_MODELS
83};
Matt Porter403d1942005-11-29 15:00:51 +010084
Matt2f2f4252005-04-13 14:45:30 +020085struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +010086 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +020087 unsigned int num_mixers;
88
Matt Porter403d1942005-11-29 15:00:51 +010089 int board_config;
Mattc7d4b2f2005-06-27 14:59:41 +020090 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +010091 unsigned int line_switch: 1;
92 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +010093 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +010094 unsigned int hp_detect: 1;
Sam Revitch62fe78e2006-05-10 15:09:17 +020095 unsigned int gpio_mute: 1;
Mattc7d4b2f2005-06-27 14:59:41 +020096
Matt2f2f4252005-04-13 14:45:30 +020097 /* playback */
98 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +010099 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +0200100
101 /* capture */
102 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +0200103 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +0200104 hda_nid_t *mux_nids;
105 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +0200106 hda_nid_t *dmic_nids;
107 unsigned int num_dmics;
108 hda_nid_t dmux_nid;
Mattdabbed62005-06-14 10:19:34 +0200109 hda_nid_t dig_in_nid;
Matt2f2f4252005-04-13 14:45:30 +0200110
Matt2f2f4252005-04-13 14:45:30 +0200111 /* pin widgets */
112 hda_nid_t *pin_nids;
113 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200114 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200115 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200116
117 /* codec specific stuff */
118 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100119 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200120
121 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200122 struct hda_input_mux *dinput_mux;
123 unsigned int cur_dmux;
Mattc7d4b2f2005-06-27 14:59:41 +0200124 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100125 unsigned int cur_mux[3];
Matt2f2f4252005-04-13 14:45:30 +0200126
Matt Porter403d1942005-11-29 15:00:51 +0100127 /* i/o switches */
128 unsigned int io_switch[2];
Matt2f2f4252005-04-13 14:45:30 +0200129
Mattc7d4b2f2005-06-27 14:59:41 +0200130 struct hda_pcm pcm_rec[2]; /* PCM information */
131
132 /* dynamic controls and input_mux */
133 struct auto_pin_cfg autocfg;
134 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100135 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200136 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200137 struct hda_input_mux private_imux;
Matt2f2f4252005-04-13 14:45:30 +0200138};
139
140static hda_nid_t stac9200_adc_nids[1] = {
141 0x03,
142};
143
144static hda_nid_t stac9200_mux_nids[1] = {
145 0x0c,
146};
147
148static hda_nid_t stac9200_dac_nids[1] = {
149 0x02,
150};
151
Tobin Davis8e21c342007-01-08 11:04:17 +0100152static hda_nid_t stac925x_adc_nids[1] = {
153 0x03,
154};
155
156static hda_nid_t stac925x_mux_nids[1] = {
157 0x0f,
158};
159
160static hda_nid_t stac925x_dac_nids[1] = {
161 0x02,
162};
163
Tobin Davis2c11f952007-05-17 09:36:34 +0200164static hda_nid_t stac925x_dmic_nids[1] = {
165 0x15,
166};
167
Matt2f2f4252005-04-13 14:45:30 +0200168static hda_nid_t stac922x_adc_nids[2] = {
169 0x06, 0x07,
170};
171
172static hda_nid_t stac922x_mux_nids[2] = {
173 0x12, 0x13,
174};
175
Matt Porter3cc08dc2006-01-23 15:27:49 +0100176static hda_nid_t stac927x_adc_nids[3] = {
177 0x07, 0x08, 0x09
178};
179
180static hda_nid_t stac927x_mux_nids[3] = {
181 0x15, 0x16, 0x17
182};
183
Matt Porterf3302a52006-07-31 12:49:34 +0200184static hda_nid_t stac9205_adc_nids[2] = {
185 0x12, 0x13
186};
187
188static hda_nid_t stac9205_mux_nids[2] = {
189 0x19, 0x1a
190};
191
Takashi Iwai25494132007-03-12 12:36:16 +0100192static hda_nid_t stac9205_dmic_nids[2] = {
193 0x17, 0x18,
Matt Porter8b657272006-10-26 17:12:59 +0200194};
195
Mattc7d4b2f2005-06-27 14:59:41 +0200196static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200197 0x08, 0x09, 0x0d, 0x0e,
198 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200199};
200
Tobin Davis8e21c342007-01-08 11:04:17 +0100201static hda_nid_t stac925x_pin_nids[8] = {
202 0x07, 0x08, 0x0a, 0x0b,
203 0x0c, 0x0d, 0x10, 0x11,
204};
205
Matt2f2f4252005-04-13 14:45:30 +0200206static hda_nid_t stac922x_pin_nids[10] = {
207 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
208 0x0f, 0x10, 0x11, 0x15, 0x1b,
209};
210
Matt Porter3cc08dc2006-01-23 15:27:49 +0100211static hda_nid_t stac927x_pin_nids[14] = {
212 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
213 0x0f, 0x10, 0x11, 0x12, 0x13,
214 0x14, 0x21, 0x22, 0x23,
215};
216
Matt Porterf3302a52006-07-31 12:49:34 +0200217static hda_nid_t stac9205_pin_nids[12] = {
218 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
219 0x0f, 0x14, 0x16, 0x17, 0x18,
220 0x21, 0x22,
221
222};
223
Matt Porter8b657272006-10-26 17:12:59 +0200224static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
225 struct snd_ctl_elem_info *uinfo)
226{
227 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
228 struct sigmatel_spec *spec = codec->spec;
229 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
230}
231
232static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
233 struct snd_ctl_elem_value *ucontrol)
234{
235 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
236 struct sigmatel_spec *spec = codec->spec;
237
238 ucontrol->value.enumerated.item[0] = spec->cur_dmux;
239 return 0;
240}
241
242static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
243 struct snd_ctl_elem_value *ucontrol)
244{
245 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
246 struct sigmatel_spec *spec = codec->spec;
247
248 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
249 spec->dmux_nid, &spec->cur_dmux);
250}
251
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100252static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200253{
254 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
255 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200256 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200257}
258
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100259static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200260{
261 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
262 struct sigmatel_spec *spec = codec->spec;
263 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
264
265 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
266 return 0;
267}
268
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100269static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200270{
271 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
272 struct sigmatel_spec *spec = codec->spec;
273 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
274
Mattc7d4b2f2005-06-27 14:59:41 +0200275 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200276 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
277}
278
Mattc7d4b2f2005-06-27 14:59:41 +0200279static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200280 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200281 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200282 {}
283};
284
Tobin Davis8e21c342007-01-08 11:04:17 +0100285static struct hda_verb stac925x_core_init[] = {
286 /* set dac0mux for dac converter */
287 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
288 {}
289};
290
Mattc7d4b2f2005-06-27 14:59:41 +0200291static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200292 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200293 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200294 {}
295};
296
Tobin Davis93ed1502006-09-01 21:03:12 +0200297static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200298 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200299 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200300 /* unmute node 0x1b */
301 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
302 /* select node 0x03 as DAC */
303 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
304 {}
305};
306
Matt Porter3cc08dc2006-01-23 15:27:49 +0100307static struct hda_verb stac927x_core_init[] = {
308 /* set master volume and direct control */
309 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
310 {}
311};
312
Matt Porterf3302a52006-07-31 12:49:34 +0200313static struct hda_verb stac9205_core_init[] = {
314 /* set master volume and direct control */
315 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
316 {}
317};
318
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100319static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200320 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
321 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
322 {
323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
324 .name = "Input Source",
325 .count = 1,
326 .info = stac92xx_mux_enum_info,
327 .get = stac92xx_mux_enum_get,
328 .put = stac92xx_mux_enum_put,
329 },
330 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
331 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Mattc7d4b2f2005-06-27 14:59:41 +0200332 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200333 { } /* end */
334};
335
Tobin Davis8e21c342007-01-08 11:04:17 +0100336static struct snd_kcontrol_new stac925x_mixer[] = {
337 HDA_CODEC_VOLUME("Master Playback Volume", 0xe, 0, HDA_OUTPUT),
338 HDA_CODEC_MUTE("Master Playback Switch", 0xe, 0, HDA_OUTPUT),
339 {
340 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
341 .name = "Input Source",
342 .count = 1,
343 .info = stac92xx_mux_enum_info,
344 .get = stac92xx_mux_enum_get,
345 .put = stac92xx_mux_enum_put,
346 },
347 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
348 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT),
349 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
350 { } /* end */
351};
352
Mattc7d4b2f2005-06-27 14:59:41 +0200353/* This needs to be generated dynamically based on sequence */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100354static struct snd_kcontrol_new stac922x_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200355 {
356 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
357 .name = "Input Source",
358 .count = 1,
359 .info = stac92xx_mux_enum_info,
360 .get = stac92xx_mux_enum_get,
361 .put = stac92xx_mux_enum_put,
362 },
363 HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT),
Takashi Iwai0fd17082006-01-13 18:46:21 +0100364 HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT),
Matt2f2f4252005-04-13 14:45:30 +0200365 HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT),
366 { } /* end */
367};
368
Takashi Iwai19039bd2006-06-28 15:52:16 +0200369/* This needs to be generated dynamically based on sequence */
370static struct snd_kcontrol_new stac9227_mixer[] = {
371 {
372 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
373 .name = "Input Source",
374 .count = 1,
375 .info = stac92xx_mux_enum_info,
376 .get = stac92xx_mux_enum_get,
377 .put = stac92xx_mux_enum_put,
378 },
379 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
380 HDA_CODEC_MUTE("Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
381 { } /* end */
382};
383
Takashi Iwaid1d985f2006-11-23 19:27:12 +0100384static struct snd_kcontrol_new stac927x_mixer[] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100385 {
386 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
387 .name = "Input Source",
388 .count = 1,
389 .info = stac92xx_mux_enum_info,
390 .get = stac92xx_mux_enum_get,
391 .put = stac92xx_mux_enum_put,
392 },
393 HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT),
394 HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT),
395 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
396 { } /* end */
397};
398
Takashi Iwaid1d985f2006-11-23 19:27:12 +0100399static struct snd_kcontrol_new stac9205_mixer[] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200400 {
401 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matt Porter8b657272006-10-26 17:12:59 +0200402 .name = "Digital Input Source",
403 .count = 1,
404 .info = stac92xx_dmux_enum_info,
405 .get = stac92xx_dmux_enum_get,
406 .put = stac92xx_dmux_enum_put,
407 },
408 {
409 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matt Porterf3302a52006-07-31 12:49:34 +0200410 .name = "Input Source",
411 .count = 1,
412 .info = stac92xx_mux_enum_info,
413 .get = stac92xx_mux_enum_get,
414 .put = stac92xx_mux_enum_put,
415 },
416 HDA_CODEC_VOLUME("InMux Capture Volume", 0x19, 0x0, HDA_OUTPUT),
417 HDA_CODEC_VOLUME("InVol Capture Volume", 0x1b, 0x0, HDA_INPUT),
418 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1d, 0x0, HDA_OUTPUT),
419 { } /* end */
420};
421
Matt2f2f4252005-04-13 14:45:30 +0200422static int stac92xx_build_controls(struct hda_codec *codec)
423{
424 struct sigmatel_spec *spec = codec->spec;
425 int err;
Mattc7d4b2f2005-06-27 14:59:41 +0200426 int i;
Matt2f2f4252005-04-13 14:45:30 +0200427
428 err = snd_hda_add_new_ctls(codec, spec->mixer);
429 if (err < 0)
430 return err;
Mattc7d4b2f2005-06-27 14:59:41 +0200431
432 for (i = 0; i < spec->num_mixers; i++) {
433 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
434 if (err < 0)
435 return err;
436 }
437
Mattdabbed62005-06-14 10:19:34 +0200438 if (spec->multiout.dig_out_nid) {
439 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
440 if (err < 0)
441 return err;
442 }
443 if (spec->dig_in_nid) {
444 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
445 if (err < 0)
446 return err;
447 }
448 return 0;
Matt2f2f4252005-04-13 14:45:30 +0200449}
450
Matt Porter403d1942005-11-29 15:00:51 +0100451static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +0200452 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +0200453 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
454};
455
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100456static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
457 [STAC_REF] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +0100458};
459
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100460static const char *stac9200_models[STAC_9200_MODELS] = {
461 [STAC_REF] = "ref",
462};
463
464static struct snd_pci_quirk stac9200_cfg_tbl[] = {
465 /* SigmaTel reference board */
466 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
467 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +0100468 /* Dell laptops have BIOS problem */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100469 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
470 "Dell Inspiron 630m", STAC_REF),
471 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
472 "Dell Latitude D620", STAC_REF),
473 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
474 "Dell Latitude 120L", STAC_REF),
Cory T. Tusar877b8662007-01-30 17:30:55 +0100475 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
476 "Dell Latitude D820", STAC_REF),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +0100477 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
478 "Dell Inspiron E1705/9400", STAC_REF),
479 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
480 "Dell XPS M1710", STAC_REF),
Takashi Iwaif0f96742007-02-14 00:59:17 +0100481 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
482 "Dell Precision M90", STAC_REF),
Daniel T Chen8286c532007-05-15 11:46:23 +0200483 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
484 "unknown Dell", STAC_REF),
Tobin Davis49c605d2007-05-17 09:38:24 +0200485 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
486 "Dell Inspiron 640m", STAC_REF),
487 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
488 "Dell Inspiron 1501", STAC_REF),
489
490 /* Panasonic */
491 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF),
492
Matt Porter403d1942005-11-29 15:00:51 +0100493 {} /* terminator */
494};
495
Tobin Davis8e21c342007-01-08 11:04:17 +0100496static unsigned int ref925x_pin_configs[8] = {
497 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
498 0x90a70320, 0x02214210, 0x400003f1, 0x9033032e,
499};
500
501static unsigned int stac925x_MA6_pin_configs[8] = {
502 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
503 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
504};
505
Tobin Davis2c11f952007-05-17 09:36:34 +0200506static unsigned int stac925x_PA6_pin_configs[8] = {
507 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
508 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
509};
510
Tobin Davis8e21c342007-01-08 11:04:17 +0100511static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +0200512 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
513 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +0100514};
515
516static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
517 [STAC_REF] = ref925x_pin_configs,
518 [STAC_M2_2] = stac925xM2_2_pin_configs,
519 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +0200520 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +0100521};
522
523static const char *stac925x_models[STAC_925x_MODELS] = {
524 [STAC_REF] = "ref",
525 [STAC_M2_2] = "m2-2",
526 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +0200527 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +0100528};
529
530static struct snd_pci_quirk stac925x_cfg_tbl[] = {
531 /* SigmaTel reference board */
532 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +0200533 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +0100534 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
535 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
536 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +0200537 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +0100538 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
539 {} /* terminator */
540};
541
Matt Porter403d1942005-11-29 15:00:51 +0100542static unsigned int ref922x_pin_configs[10] = {
543 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
544 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +0200545 0x40000100, 0x40000100,
546};
547
Matt Porter403d1942005-11-29 15:00:51 +0100548static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +0100549 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +0100550 0x40000100, 0x40000100, 0x40000100, 0x40000100,
551 0x02a19120, 0x40000100,
552};
553
554static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +0100555 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
556 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +0100557 0x02a19320, 0x40000100,
558};
559
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200560static unsigned int intel_mac_v1_pin_configs[10] = {
561 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
562 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100563 0x400000fc, 0x400000fb,
564};
565
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200566static unsigned int intel_mac_v2_pin_configs[10] = {
567 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
568 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200569 0x400000fc, 0x400000fb,
570};
571
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200572static unsigned int intel_mac_v3_pin_configs[10] = {
573 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
574 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
575 0x400000fc, 0x400000fb,
576};
577
578static unsigned int intel_mac_v4_pin_configs[10] = {
579 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
580 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
581 0x400000fc, 0x400000fb,
582};
583
584static unsigned int intel_mac_v5_pin_configs[10] = {
585 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
586 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
587 0x400000fc, 0x400000fb,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200588};
589
Takashi Iwai76c08822007-06-19 12:17:42 +0200590static unsigned int stac922x_dell_pin_configs[10] = {
591 0x0221121e, 0x408103ff, 0x02a1123e, 0x90100310,
592 0x408003f1, 0x0221122f, 0x03451340, 0x40c003f2,
593 0x50a003f3, 0x405003f4
594};
595
Takashi Iwai19039bd2006-06-28 15:52:16 +0200596static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100597 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +0200598 [STAC_D945GTP3] = d945gtp3_pin_configs,
599 [STAC_D945GTP5] = d945gtp5_pin_configs,
Takashi Iwai76c08822007-06-19 12:17:42 +0200600 [STAC_922X_DELL] = stac922x_dell_pin_configs,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200601 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
602 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
603 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
604 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
605 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
606 /* for backward compitability */
607 [STAC_MACMINI] = intel_mac_v3_pin_configs,
608 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
609 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
610 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
611 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
612 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +0100613};
614
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100615static const char *stac922x_models[STAC_922X_MODELS] = {
616 [STAC_D945_REF] = "ref",
617 [STAC_D945GTP5] = "5stack",
618 [STAC_D945GTP3] = "3stack",
Takashi Iwai76c08822007-06-19 12:17:42 +0200619 [STAC_922X_DELL] = "dell",
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200620 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
621 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
622 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
623 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
624 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
625 /* for backward compitability */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100626 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100627 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100628 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
629 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +0200630 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200631 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100632};
633
634static struct snd_pci_quirk stac922x_cfg_tbl[] = {
635 /* SigmaTel reference board */
636 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
637 "DFI LanParty", STAC_D945_REF),
638 /* Intel 945G based systems */
639 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
640 "Intel D945G", STAC_D945GTP3),
641 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
642 "Intel D945G", STAC_D945GTP3),
643 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
644 "Intel D945G", STAC_D945GTP3),
645 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
646 "Intel D945G", STAC_D945GTP3),
647 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
648 "Intel D945G", STAC_D945GTP3),
649 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
650 "Intel D945G", STAC_D945GTP3),
651 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
652 "Intel D945G", STAC_D945GTP3),
653 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
654 "Intel D945G", STAC_D945GTP3),
655 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
656 "Intel D945G", STAC_D945GTP3),
657 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
658 "Intel D945G", STAC_D945GTP3),
659 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
660 "Intel D945G", STAC_D945GTP3),
661 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
662 "Intel D945G", STAC_D945GTP3),
663 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
664 "Intel D945G", STAC_D945GTP3),
665 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
666 "Intel D945G", STAC_D945GTP3),
667 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
668 "Intel D945G", STAC_D945GTP3),
669 /* Intel D945G 5-stack systems */
670 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
671 "Intel D945G", STAC_D945GTP5),
672 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
673 "Intel D945G", STAC_D945GTP5),
674 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
675 "Intel D945G", STAC_D945GTP5),
676 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
677 "Intel D945G", STAC_D945GTP5),
678 /* Intel 945P based systems */
679 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
680 "Intel D945P", STAC_D945GTP3),
681 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
682 "Intel D945P", STAC_D945GTP3),
683 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
684 "Intel D945P", STAC_D945GTP3),
685 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
686 "Intel D945P", STAC_D945GTP3),
687 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
688 "Intel D945P", STAC_D945GTP3),
689 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
690 "Intel D945P", STAC_D945GTP5),
691 /* other systems */
692 /* Apple Mac Mini (early 2006) */
693 SND_PCI_QUIRK(0x8384, 0x7680,
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +0200694 "Mac Mini", STAC_INTEL_MAC_V3),
Takashi Iwai76c08822007-06-19 12:17:42 +0200695 /* Dell */
696 SND_PCI_QUIRK(0x1028, 0x01d7, "Dell XPS M1210", STAC_922X_DELL),
697
Matt Porter403d1942005-11-29 15:00:51 +0100698 {} /* terminator */
699};
700
Matt Porter3cc08dc2006-01-23 15:27:49 +0100701static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200702 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
703 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
704 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
705 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +0100706};
707
Tobin Davis93ed1502006-09-01 21:03:12 +0200708static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200709 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
710 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
711 0x40000100, 0x40000100, 0x40000100, 0x40000100,
712 0x40000100, 0x40000100
713};
714
Tobin Davis93ed1502006-09-01 21:03:12 +0200715static unsigned int d965_5st_pin_configs[14] = {
716 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
717 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
718 0x40000100, 0x40000100, 0x40000100, 0x01442070,
719 0x40000100, 0x40000100
720};
721
722static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100723 [STAC_D965_REF] = ref927x_pin_configs,
Tobin Davis93ed1502006-09-01 21:03:12 +0200724 [STAC_D965_3ST] = d965_3st_pin_configs,
725 [STAC_D965_5ST] = d965_5st_pin_configs,
Matt Porter3cc08dc2006-01-23 15:27:49 +0100726};
727
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100728static const char *stac927x_models[STAC_927X_MODELS] = {
729 [STAC_D965_REF] = "ref",
730 [STAC_D965_3ST] = "3stack",
731 [STAC_D965_5ST] = "5stack",
732};
733
734static struct snd_pci_quirk stac927x_cfg_tbl[] = {
735 /* SigmaTel reference board */
736 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
737 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200738 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100739 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
740 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +0200741 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100742 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
743 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
744 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
745 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
746 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
747 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
748 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
749 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
750 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
751 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
752 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
753 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
754 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
755 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
756 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
757 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +0200758 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100759 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
760 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
761 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
762 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
763 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
764 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
765 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
766 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
767 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +0100768 {} /* terminator */
769};
770
Matt Porterf3302a52006-07-31 12:49:34 +0200771static unsigned int ref9205_pin_configs[12] = {
772 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matt Porter8b657272006-10-26 17:12:59 +0200773 0x01813122, 0x01a19021, 0x40000100, 0x40000100,
774 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +0200775};
776
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100777static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200778 ref9205_pin_configs,
779};
780
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100781static const char *stac9205_models[STAC_9205_MODELS] = {
782 [STAC_9205_REF] = "ref",
783};
784
785static struct snd_pci_quirk stac9205_cfg_tbl[] = {
786 /* SigmaTel reference board */
787 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
788 "DFI LanParty", STAC_9205_REF),
Matt Porterf3302a52006-07-31 12:49:34 +0200789 {} /* terminator */
790};
791
Richard Fish11b44bb2006-08-23 18:31:34 +0200792static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
793{
794 int i;
795 struct sigmatel_spec *spec = codec->spec;
796
797 if (! spec->bios_pin_configs) {
798 spec->bios_pin_configs = kcalloc(spec->num_pins,
799 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
800 if (! spec->bios_pin_configs)
801 return -ENOMEM;
802 }
803
804 for (i = 0; i < spec->num_pins; i++) {
805 hda_nid_t nid = spec->pin_nids[i];
806 unsigned int pin_cfg;
807
808 pin_cfg = snd_hda_codec_read(codec, nid, 0,
809 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
810 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
811 nid, pin_cfg);
812 spec->bios_pin_configs[i] = pin_cfg;
813 }
814
815 return 0;
816}
817
Matt2f2f4252005-04-13 14:45:30 +0200818static void stac92xx_set_config_regs(struct hda_codec *codec)
819{
820 int i;
821 struct sigmatel_spec *spec = codec->spec;
822 unsigned int pin_cfg;
823
Richard Fish11b44bb2006-08-23 18:31:34 +0200824 if (! spec->pin_nids || ! spec->pin_configs)
825 return;
826
827 for (i = 0; i < spec->num_pins; i++) {
Matt2f2f4252005-04-13 14:45:30 +0200828 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
829 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
830 spec->pin_configs[i] & 0x000000ff);
831 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
832 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
833 (spec->pin_configs[i] & 0x0000ff00) >> 8);
834 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
835 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
836 (spec->pin_configs[i] & 0x00ff0000) >> 16);
837 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
838 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
839 spec->pin_configs[i] >> 24);
840 pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0,
841 AC_VERB_GET_CONFIG_DEFAULT,
842 0x00);
Matt Porter403d1942005-11-29 15:00:51 +0100843 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 +0200844 }
845}
Matt2f2f4252005-04-13 14:45:30 +0200846
Matt2f2f4252005-04-13 14:45:30 +0200847/*
848 * Analog playback callbacks
849 */
850static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
851 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100852 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200853{
854 struct sigmatel_spec *spec = codec->spec;
855 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
856}
857
858static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
859 struct hda_codec *codec,
860 unsigned int stream_tag,
861 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100862 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200863{
864 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +0100865 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +0200866}
867
868static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
869 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100870 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200871{
872 struct sigmatel_spec *spec = codec->spec;
873 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
874}
875
876/*
Mattdabbed62005-06-14 10:19:34 +0200877 * Digital playback callbacks
878 */
879static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
880 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100881 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +0200882{
883 struct sigmatel_spec *spec = codec->spec;
884 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
885}
886
887static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
888 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100889 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +0200890{
891 struct sigmatel_spec *spec = codec->spec;
892 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
893}
894
Takashi Iwai6b97eb42007-04-05 14:51:48 +0200895static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
896 struct hda_codec *codec,
897 unsigned int stream_tag,
898 unsigned int format,
899 struct snd_pcm_substream *substream)
900{
901 struct sigmatel_spec *spec = codec->spec;
902 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
903 stream_tag, format, substream);
904}
905
Mattdabbed62005-06-14 10:19:34 +0200906
907/*
Matt2f2f4252005-04-13 14:45:30 +0200908 * Analog capture callbacks
909 */
910static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
911 struct hda_codec *codec,
912 unsigned int stream_tag,
913 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100914 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200915{
916 struct sigmatel_spec *spec = codec->spec;
917
918 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
919 stream_tag, 0, format);
920 return 0;
921}
922
923static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
924 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100925 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200926{
927 struct sigmatel_spec *spec = codec->spec;
928
929 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
930 return 0;
931}
932
Mattdabbed62005-06-14 10:19:34 +0200933static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
934 .substreams = 1,
935 .channels_min = 2,
936 .channels_max = 2,
937 /* NID is set in stac92xx_build_pcms */
938 .ops = {
939 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +0200940 .close = stac92xx_dig_playback_pcm_close,
941 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +0200942 },
943};
944
945static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
946 .substreams = 1,
947 .channels_min = 2,
948 .channels_max = 2,
949 /* NID is set in stac92xx_build_pcms */
950};
951
Matt2f2f4252005-04-13 14:45:30 +0200952static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
953 .substreams = 1,
954 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +0200955 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +0200956 .nid = 0x02, /* NID to query formats and rates */
957 .ops = {
958 .open = stac92xx_playback_pcm_open,
959 .prepare = stac92xx_playback_pcm_prepare,
960 .cleanup = stac92xx_playback_pcm_cleanup
961 },
962};
963
Matt Porter3cc08dc2006-01-23 15:27:49 +0100964static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
965 .substreams = 1,
966 .channels_min = 2,
967 .channels_max = 2,
968 .nid = 0x06, /* NID to query formats and rates */
969 .ops = {
970 .open = stac92xx_playback_pcm_open,
971 .prepare = stac92xx_playback_pcm_prepare,
972 .cleanup = stac92xx_playback_pcm_cleanup
973 },
974};
975
Matt2f2f4252005-04-13 14:45:30 +0200976static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
977 .substreams = 2,
978 .channels_min = 2,
979 .channels_max = 2,
Matt Porter3cc08dc2006-01-23 15:27:49 +0100980 /* NID is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +0200981 .ops = {
982 .prepare = stac92xx_capture_pcm_prepare,
983 .cleanup = stac92xx_capture_pcm_cleanup
984 },
985};
986
987static int stac92xx_build_pcms(struct hda_codec *codec)
988{
989 struct sigmatel_spec *spec = codec->spec;
990 struct hda_pcm *info = spec->pcm_rec;
991
992 codec->num_pcms = 1;
993 codec->pcm_info = info;
994
Mattc7d4b2f2005-06-27 14:59:41 +0200995 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +0200996 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +0200997 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100998 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
999
1000 if (spec->alt_switch) {
1001 codec->num_pcms++;
1002 info++;
1003 info->name = "STAC92xx Analog Alt";
1004 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
1005 }
Matt2f2f4252005-04-13 14:45:30 +02001006
Mattdabbed62005-06-14 10:19:34 +02001007 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1008 codec->num_pcms++;
1009 info++;
1010 info->name = "STAC92xx Digital";
1011 if (spec->multiout.dig_out_nid) {
1012 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
1013 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1014 }
1015 if (spec->dig_in_nid) {
1016 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
1017 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1018 }
1019 }
1020
Matt2f2f4252005-04-13 14:45:30 +02001021 return 0;
1022}
1023
Takashi Iwaic960a032006-03-23 17:06:28 +01001024static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
1025{
1026 unsigned int pincap = snd_hda_param_read(codec, nid,
1027 AC_PAR_PIN_CAP);
1028 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
1029 if (pincap & AC_PINCAP_VREF_100)
1030 return AC_PINCTL_VREF_100;
1031 if (pincap & AC_PINCAP_VREF_80)
1032 return AC_PINCTL_VREF_80;
1033 if (pincap & AC_PINCAP_VREF_50)
1034 return AC_PINCTL_VREF_50;
1035 if (pincap & AC_PINCAP_VREF_GRD)
1036 return AC_PINCTL_VREF_GRD;
1037 return 0;
1038}
1039
Matt Porter403d1942005-11-29 15:00:51 +01001040static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
1041
1042{
1043 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
1044}
1045
1046static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1047{
1048 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1049 uinfo->count = 1;
1050 uinfo->value.integer.min = 0;
1051 uinfo->value.integer.max = 1;
1052 return 0;
1053}
1054
1055static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1056{
1057 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1058 struct sigmatel_spec *spec = codec->spec;
1059 int io_idx = kcontrol-> private_value & 0xff;
1060
1061 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
1062 return 0;
1063}
1064
1065static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1066{
1067 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1068 struct sigmatel_spec *spec = codec->spec;
1069 hda_nid_t nid = kcontrol->private_value >> 8;
1070 int io_idx = kcontrol-> private_value & 0xff;
1071 unsigned short val = ucontrol->value.integer.value[0];
1072
1073 spec->io_switch[io_idx] = val;
1074
1075 if (val)
1076 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01001077 else {
1078 unsigned int pinctl = AC_PINCTL_IN_EN;
1079 if (io_idx) /* set VREF for mic */
1080 pinctl |= stac92xx_get_vref(codec, nid);
1081 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1082 }
Matt Porter403d1942005-11-29 15:00:51 +01001083 return 1;
1084}
1085
1086#define STAC_CODEC_IO_SWITCH(xname, xpval) \
1087 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1088 .name = xname, \
1089 .index = 0, \
1090 .info = stac92xx_io_switch_info, \
1091 .get = stac92xx_io_switch_get, \
1092 .put = stac92xx_io_switch_put, \
1093 .private_value = xpval, \
1094 }
1095
1096
Mattc7d4b2f2005-06-27 14:59:41 +02001097enum {
1098 STAC_CTL_WIDGET_VOL,
1099 STAC_CTL_WIDGET_MUTE,
Matt Porter403d1942005-11-29 15:00:51 +01001100 STAC_CTL_WIDGET_IO_SWITCH,
Mattc7d4b2f2005-06-27 14:59:41 +02001101};
1102
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001103static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02001104 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1105 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matt Porter403d1942005-11-29 15:00:51 +01001106 STAC_CODEC_IO_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02001107};
1108
1109/* add dynamic controls */
1110static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
1111{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001112 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02001113
1114 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1115 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1116
1117 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1118 if (! knew)
1119 return -ENOMEM;
1120 if (spec->kctl_alloc) {
1121 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1122 kfree(spec->kctl_alloc);
1123 }
1124 spec->kctl_alloc = knew;
1125 spec->num_kctl_alloc = num;
1126 }
1127
1128 knew = &spec->kctl_alloc[spec->num_kctl_used];
1129 *knew = stac92xx_control_templates[type];
Takashi Iwai82fe0c52005-06-30 10:54:33 +02001130 knew->name = kstrdup(name, GFP_KERNEL);
Mattc7d4b2f2005-06-27 14:59:41 +02001131 if (! knew->name)
1132 return -ENOMEM;
1133 knew->private_value = val;
1134 spec->num_kctl_used++;
1135 return 0;
1136}
1137
Matt Porter403d1942005-11-29 15:00:51 +01001138/* flag inputs as additional dynamic lineouts */
1139static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
1140{
1141 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02001142 unsigned int wcaps, wtype;
1143 int i, num_dacs = 0;
1144
1145 /* use the wcaps cache to count all DACs available for line-outs */
1146 for (i = 0; i < codec->num_nodes; i++) {
1147 wcaps = codec->wcaps[i];
1148 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1149 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
1150 num_dacs++;
1151 }
Matt Porter403d1942005-11-29 15:00:51 +01001152
Steve Longerbeam7b043892007-05-03 20:50:03 +02001153 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
1154
Matt Porter403d1942005-11-29 15:00:51 +01001155 switch (cfg->line_outs) {
1156 case 3:
1157 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02001158 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Matt Porter403d1942005-11-29 15:00:51 +01001159 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE];
1160 spec->line_switch = 1;
1161 cfg->line_outs++;
1162 }
1163 break;
1164 case 2:
1165 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02001166 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Matt Porter403d1942005-11-29 15:00:51 +01001167 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE];
1168 spec->line_switch = 1;
1169 cfg->line_outs++;
1170 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02001171 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Matt Porter403d1942005-11-29 15:00:51 +01001172 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC];
1173 spec->mic_switch = 1;
1174 cfg->line_outs++;
1175 }
1176 break;
1177 case 1:
1178 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02001179 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Matt Porter403d1942005-11-29 15:00:51 +01001180 cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE];
1181 spec->line_switch = 1;
1182 cfg->line_outs++;
1183 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02001184 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Matt Porter403d1942005-11-29 15:00:51 +01001185 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC];
1186 spec->mic_switch = 1;
1187 cfg->line_outs++;
1188 }
1189 break;
1190 }
1191
1192 return 0;
1193}
1194
Steve Longerbeam7b043892007-05-03 20:50:03 +02001195
1196static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1197{
1198 int i;
1199
1200 for (i = 0; i < spec->multiout.num_dacs; i++) {
1201 if (spec->multiout.dac_nids[i] == nid)
1202 return 1;
1203 }
1204
1205 return 0;
1206}
1207
Matt Porter3cc08dc2006-01-23 15:27:49 +01001208/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02001209 * Fill in the dac_nids table from the parsed pin configuration
1210 * This function only works when every pin in line_out_pins[]
1211 * contains atleast one DAC in its connection list. Some 92xx
1212 * codecs are not connected directly to a DAC, such as the 9200
1213 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01001214 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02001215static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
1216 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02001217{
1218 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02001219 int i, j, conn_len = 0;
1220 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
1221 unsigned int wcaps, wtype;
1222
Mattc7d4b2f2005-06-27 14:59:41 +02001223 for (i = 0; i < cfg->line_outs; i++) {
1224 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02001225 conn_len = snd_hda_get_connections(codec, nid, conn,
1226 HDA_MAX_CONNECTIONS);
1227 for (j = 0; j < conn_len; j++) {
1228 wcaps = snd_hda_param_read(codec, conn[j],
1229 AC_PAR_AUDIO_WIDGET_CAP);
1230 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1231
1232 if (wtype != AC_WID_AUD_OUT ||
1233 (wcaps & AC_WCAP_DIGITAL))
1234 continue;
1235 /* conn[j] is a DAC routed to this line-out */
1236 if (!is_in_dac_nids(spec, conn[j]))
1237 break;
1238 }
1239
1240 if (j == conn_len) {
1241 /* error out, no available DAC found */
1242 snd_printk(KERN_ERR
1243 "%s: No available DAC for pin 0x%x\n",
1244 __func__, nid);
1245 return -ENODEV;
1246 }
1247
1248 spec->multiout.dac_nids[i] = conn[j];
1249 spec->multiout.num_dacs++;
1250 if (conn_len > 1) {
1251 /* select this DAC in the pin's input mux */
1252 snd_hda_codec_write(codec, nid, 0,
1253 AC_VERB_SET_CONNECT_SEL, j);
1254
1255 }
Mattc7d4b2f2005-06-27 14:59:41 +02001256 }
1257
Steve Longerbeam7b043892007-05-03 20:50:03 +02001258 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
1259 spec->multiout.num_dacs,
1260 spec->multiout.dac_nids[0],
1261 spec->multiout.dac_nids[1],
1262 spec->multiout.dac_nids[2],
1263 spec->multiout.dac_nids[3],
1264 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02001265 return 0;
1266}
1267
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001268/* create volume control/switch for the given prefx type */
1269static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
1270{
1271 char name[32];
1272 int err;
1273
1274 sprintf(name, "%s Playback Volume", pfx);
1275 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
1276 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1277 if (err < 0)
1278 return err;
1279 sprintf(name, "%s Playback Switch", pfx);
1280 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
1281 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1282 if (err < 0)
1283 return err;
1284 return 0;
1285}
1286
Mattc7d4b2f2005-06-27 14:59:41 +02001287/* add playback controls from the parsed DAC table */
Takashi Iwai19039bd2006-06-28 15:52:16 +02001288static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec,
1289 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02001290{
Takashi Iwai19039bd2006-06-28 15:52:16 +02001291 static const char *chname[4] = {
1292 "Front", "Surround", NULL /*CLFE*/, "Side"
1293 };
Mattc7d4b2f2005-06-27 14:59:41 +02001294 hda_nid_t nid;
1295 int i, err;
1296
1297 for (i = 0; i < cfg->line_outs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01001298 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02001299 continue;
1300
1301 nid = spec->multiout.dac_nids[i];
1302
1303 if (i == 2) {
1304 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001305 err = create_controls(spec, "Center", nid, 1);
1306 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001307 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001308 err = create_controls(spec, "LFE", nid, 2);
1309 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001310 return err;
1311 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001312 err = create_controls(spec, chname[i], nid, 3);
1313 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001314 return err;
1315 }
1316 }
1317
Matt Porter403d1942005-11-29 15:00:51 +01001318 if (spec->line_switch)
1319 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
1320 return err;
1321
1322 if (spec->mic_switch)
1323 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
1324 return err;
1325
Mattc7d4b2f2005-06-27 14:59:41 +02001326 return 0;
1327}
1328
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001329static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1330{
Steve Longerbeam7b043892007-05-03 20:50:03 +02001331 if (is_in_dac_nids(spec, nid))
1332 return 1;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001333 if (spec->multiout.hp_nid == nid)
1334 return 1;
1335 return 0;
1336}
1337
1338static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
1339{
1340 if (!spec->multiout.hp_nid)
1341 spec->multiout.hp_nid = nid;
1342 else if (spec->multiout.num_dacs > 4) {
1343 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
1344 return 1;
1345 } else {
1346 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
1347 spec->multiout.num_dacs++;
1348 }
1349 return 0;
1350}
1351
1352/* add playback controls for Speaker and HP outputs */
1353static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
1354 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02001355{
1356 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02001357 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001358 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02001359
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001360 old_num_dacs = spec->multiout.num_dacs;
1361 for (i = 0; i < cfg->hp_outs; i++) {
1362 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
1363 if (wid_caps & AC_WCAP_UNSOL_CAP)
1364 spec->hp_detect = 1;
1365 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
1366 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1367 if (check_in_dac_nids(spec, nid))
1368 nid = 0;
1369 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02001370 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001371 add_spec_dacs(spec, nid);
1372 }
1373 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02001374 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001375 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1376 if (check_in_dac_nids(spec, nid))
1377 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001378 if (! nid)
1379 continue;
1380 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02001381 }
1382
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001383 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
1384 static const char *pfxs[] = {
1385 "Speaker", "External Speaker", "Speaker2",
1386 };
1387 err = create_controls(spec, pfxs[i - old_num_dacs],
1388 spec->multiout.dac_nids[i], 3);
1389 if (err < 0)
1390 return err;
1391 }
1392 if (spec->multiout.hp_nid) {
1393 const char *pfx;
1394 if (old_num_dacs == spec->multiout.num_dacs)
1395 pfx = "Master";
1396 else
1397 pfx = "Headphone";
1398 err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
1399 if (err < 0)
1400 return err;
1401 }
Mattc7d4b2f2005-06-27 14:59:41 +02001402
1403 return 0;
1404}
1405
Matt Porter8b657272006-10-26 17:12:59 +02001406/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01001407static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02001408 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
1409 "Digital Mic 3", "Digital Mic 4"
1410};
1411
1412/* create playback/capture controls for input pins on dmic capable codecs */
1413static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
1414 const struct auto_pin_cfg *cfg)
1415{
1416 struct sigmatel_spec *spec = codec->spec;
1417 struct hda_input_mux *dimux = &spec->private_dimux;
1418 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1419 int i, j;
1420
1421 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
1422 dimux->items[dimux->num_items].index = 0;
1423 dimux->num_items++;
1424
1425 for (i = 0; i < spec->num_dmics; i++) {
1426 int index;
1427 int num_cons;
1428 unsigned int def_conf;
1429
1430 def_conf = snd_hda_codec_read(codec,
1431 spec->dmic_nids[i],
1432 0,
1433 AC_VERB_GET_CONFIG_DEFAULT,
1434 0);
1435 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
1436 continue;
1437
1438 num_cons = snd_hda_get_connections(codec,
1439 spec->dmux_nid,
1440 con_lst,
1441 HDA_MAX_NUM_INPUTS);
1442 for (j = 0; j < num_cons; j++)
1443 if (con_lst[j] == spec->dmic_nids[i]) {
1444 index = j;
1445 goto found;
1446 }
1447 continue;
1448found:
1449 dimux->items[dimux->num_items].label =
1450 stac92xx_dmic_labels[dimux->num_items];
1451 dimux->items[dimux->num_items].index = index;
1452 dimux->num_items++;
1453 }
1454
1455 return 0;
1456}
1457
Mattc7d4b2f2005-06-27 14:59:41 +02001458/* create playback/capture controls for input pins */
1459static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
1460{
1461 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02001462 struct hda_input_mux *imux = &spec->private_imux;
1463 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1464 int i, j, k;
1465
1466 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02001467 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02001468
Takashi Iwai314634b2006-09-21 11:56:18 +02001469 if (!cfg->input_pins[i])
1470 continue;
1471 index = -1;
1472 for (j = 0; j < spec->num_muxes; j++) {
1473 int num_cons;
1474 num_cons = snd_hda_get_connections(codec,
1475 spec->mux_nids[j],
1476 con_lst,
1477 HDA_MAX_NUM_INPUTS);
1478 for (k = 0; k < num_cons; k++)
1479 if (con_lst[k] == cfg->input_pins[i]) {
1480 index = k;
1481 goto found;
1482 }
Mattc7d4b2f2005-06-27 14:59:41 +02001483 }
Takashi Iwai314634b2006-09-21 11:56:18 +02001484 continue;
1485 found:
1486 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
1487 imux->items[imux->num_items].index = index;
1488 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02001489 }
1490
Steve Longerbeam7b043892007-05-03 20:50:03 +02001491 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02001492 /*
1493 * Set the current input for the muxes.
1494 * The STAC9221 has two input muxes with identical source
1495 * NID lists. Hopefully this won't get confused.
1496 */
1497 for (i = 0; i < spec->num_muxes; i++) {
1498 snd_hda_codec_write(codec, spec->mux_nids[i], 0,
1499 AC_VERB_SET_CONNECT_SEL,
1500 imux->items[0].index);
1501 }
1502 }
1503
Mattc7d4b2f2005-06-27 14:59:41 +02001504 return 0;
1505}
1506
Mattc7d4b2f2005-06-27 14:59:41 +02001507static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
1508{
1509 struct sigmatel_spec *spec = codec->spec;
1510 int i;
1511
1512 for (i = 0; i < spec->autocfg.line_outs; i++) {
1513 hda_nid_t nid = spec->autocfg.line_out_pins[i];
1514 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
1515 }
1516}
1517
1518static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
1519{
1520 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001521 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02001522
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001523 for (i = 0; i < spec->autocfg.hp_outs; i++) {
1524 hda_nid_t pin;
1525 pin = spec->autocfg.hp_pins[i];
1526 if (pin) /* connect to front */
1527 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
1528 }
1529 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
1530 hda_nid_t pin;
1531 pin = spec->autocfg.speaker_pins[i];
1532 if (pin) /* connect to front */
1533 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
1534 }
Mattc7d4b2f2005-06-27 14:59:41 +02001535}
1536
Matt Porter3cc08dc2006-01-23 15:27:49 +01001537static 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 +02001538{
1539 struct sigmatel_spec *spec = codec->spec;
1540 int err;
1541
Matt Porter8b657272006-10-26 17:12:59 +02001542 if ((err = snd_hda_parse_pin_def_config(codec,
1543 &spec->autocfg,
1544 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001545 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001546 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01001547 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02001548
Matt Porter403d1942005-11-29 15:00:51 +01001549 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
1550 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02001551 if (spec->multiout.num_dacs == 0)
1552 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
1553 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001554
1555 if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
1556 (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 ||
1557 (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
1558 return err;
1559
Matt Porter8b657272006-10-26 17:12:59 +02001560 if (spec->num_dmics > 0)
1561 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
1562 &spec->autocfg)) < 0)
1563 return err;
1564
Mattc7d4b2f2005-06-27 14:59:41 +02001565 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01001566 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02001567 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02001568
Takashi Iwai82bc9552006-03-21 11:24:42 +01001569 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01001570 spec->multiout.dig_out_nid = dig_out;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001571 if (spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01001572 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02001573
1574 if (spec->kctl_alloc)
1575 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
1576
1577 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02001578 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02001579
1580 return 1;
1581}
1582
Takashi Iwai82bc9552006-03-21 11:24:42 +01001583/* add playback controls for HP output */
1584static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
1585 struct auto_pin_cfg *cfg)
1586{
1587 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001588 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01001589 unsigned int wid_caps;
1590
1591 if (! pin)
1592 return 0;
1593
1594 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02001595 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01001596 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001597
1598 return 0;
1599}
1600
Richard Fish160ea0d2006-09-06 13:58:25 +02001601/* add playback controls for LFE output */
1602static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
1603 struct auto_pin_cfg *cfg)
1604{
1605 struct sigmatel_spec *spec = codec->spec;
1606 int err;
1607 hda_nid_t lfe_pin = 0x0;
1608 int i;
1609
1610 /*
1611 * search speaker outs and line outs for a mono speaker pin
1612 * with an amp. If one is found, add LFE controls
1613 * for it.
1614 */
1615 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
1616 hda_nid_t pin = spec->autocfg.speaker_pins[i];
1617 unsigned long wcaps = get_wcaps(codec, pin);
1618 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
1619 if (wcaps == AC_WCAP_OUT_AMP)
1620 /* found a mono speaker with an amp, must be lfe */
1621 lfe_pin = pin;
1622 }
1623
1624 /* if speaker_outs is 0, then speakers may be in line_outs */
1625 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
1626 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
1627 hda_nid_t pin = spec->autocfg.line_out_pins[i];
1628 unsigned long cfg;
1629 cfg = snd_hda_codec_read(codec, pin, 0,
1630 AC_VERB_GET_CONFIG_DEFAULT,
1631 0x00);
1632 if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) {
1633 unsigned long wcaps = get_wcaps(codec, pin);
1634 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
1635 if (wcaps == AC_WCAP_OUT_AMP)
1636 /* found a mono speaker with an amp,
1637 must be lfe */
1638 lfe_pin = pin;
1639 }
1640 }
1641 }
1642
1643 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001644 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02001645 if (err < 0)
1646 return err;
1647 }
1648
1649 return 0;
1650}
1651
Mattc7d4b2f2005-06-27 14:59:41 +02001652static int stac9200_parse_auto_config(struct hda_codec *codec)
1653{
1654 struct sigmatel_spec *spec = codec->spec;
1655 int err;
1656
Kailang Yangdf694da2005-12-05 19:42:22 +01001657 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001658 return err;
1659
1660 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
1661 return err;
1662
Takashi Iwai82bc9552006-03-21 11:24:42 +01001663 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
1664 return err;
1665
Richard Fish160ea0d2006-09-06 13:58:25 +02001666 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
1667 return err;
1668
Takashi Iwai82bc9552006-03-21 11:24:42 +01001669 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02001670 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001671 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02001672 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02001673
1674 if (spec->kctl_alloc)
1675 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
1676
1677 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02001678 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02001679
1680 return 1;
1681}
1682
Sam Revitch62fe78e2006-05-10 15:09:17 +02001683/*
1684 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
1685 * funky external mute control using GPIO pins.
1686 */
1687
1688static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted)
1689{
1690 unsigned int gpiostate, gpiomask, gpiodir;
1691
1692 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
1693 AC_VERB_GET_GPIO_DATA, 0);
1694
1695 if (!muted)
1696 gpiostate |= (1 << pin);
1697 else
1698 gpiostate &= ~(1 << pin);
1699
1700 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
1701 AC_VERB_GET_GPIO_MASK, 0);
1702 gpiomask |= (1 << pin);
1703
1704 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
1705 AC_VERB_GET_GPIO_DIRECTION, 0);
1706 gpiodir |= (1 << pin);
1707
1708 /* AppleHDA seems to do this -- WTF is this verb?? */
1709 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
1710
1711 snd_hda_codec_write(codec, codec->afg, 0,
1712 AC_VERB_SET_GPIO_MASK, gpiomask);
1713 snd_hda_codec_write(codec, codec->afg, 0,
1714 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
1715
1716 msleep(1);
1717
1718 snd_hda_codec_write(codec, codec->afg, 0,
1719 AC_VERB_SET_GPIO_DATA, gpiostate);
1720}
1721
Takashi Iwai314634b2006-09-21 11:56:18 +02001722static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
1723 unsigned int event)
1724{
1725 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
1726 snd_hda_codec_write(codec, nid, 0,
1727 AC_VERB_SET_UNSOLICITED_ENABLE,
1728 (AC_USRSP_EN | event));
1729}
1730
Mattc7d4b2f2005-06-27 14:59:41 +02001731static int stac92xx_init(struct hda_codec *codec)
1732{
1733 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001734 struct auto_pin_cfg *cfg = &spec->autocfg;
1735 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02001736
Mattc7d4b2f2005-06-27 14:59:41 +02001737 snd_hda_sequence_write(codec, spec->init);
1738
Takashi Iwai82bc9552006-03-21 11:24:42 +01001739 /* set up pins */
1740 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02001741 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001742 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02001743 enable_pin_detect(codec, cfg->hp_pins[i],
1744 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01001745 /* force to enable the first line-out; the others are set up
1746 * in unsol_event
1747 */
1748 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
1749 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02001750 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01001751 /* fake event to set up pins */
1752 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
1753 } else {
1754 stac92xx_auto_init_multi_out(codec);
1755 stac92xx_auto_init_hp_out(codec);
1756 }
1757 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01001758 hda_nid_t nid = cfg->input_pins[i];
1759 if (nid) {
1760 unsigned int pinctl = AC_PINCTL_IN_EN;
1761 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
1762 pinctl |= stac92xx_get_vref(codec, nid);
1763 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1764 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01001765 }
Matt Porter8b657272006-10-26 17:12:59 +02001766 if (spec->num_dmics > 0)
1767 for (i = 0; i < spec->num_dmics; i++)
1768 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
1769 AC_PINCTL_IN_EN);
1770
Takashi Iwai82bc9552006-03-21 11:24:42 +01001771 if (cfg->dig_out_pin)
1772 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
1773 AC_PINCTL_OUT_EN);
1774 if (cfg->dig_in_pin)
1775 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
1776 AC_PINCTL_IN_EN);
1777
Sam Revitch62fe78e2006-05-10 15:09:17 +02001778 if (spec->gpio_mute) {
1779 stac922x_gpio_mute(codec, 0, 0);
1780 stac922x_gpio_mute(codec, 1, 0);
1781 }
1782
Mattc7d4b2f2005-06-27 14:59:41 +02001783 return 0;
1784}
1785
Matt2f2f4252005-04-13 14:45:30 +02001786static void stac92xx_free(struct hda_codec *codec)
1787{
Mattc7d4b2f2005-06-27 14:59:41 +02001788 struct sigmatel_spec *spec = codec->spec;
1789 int i;
1790
1791 if (! spec)
1792 return;
1793
1794 if (spec->kctl_alloc) {
1795 for (i = 0; i < spec->num_kctl_used; i++)
1796 kfree(spec->kctl_alloc[i].name);
1797 kfree(spec->kctl_alloc);
1798 }
1799
Richard Fish11b44bb2006-08-23 18:31:34 +02001800 if (spec->bios_pin_configs)
1801 kfree(spec->bios_pin_configs);
1802
Mattc7d4b2f2005-06-27 14:59:41 +02001803 kfree(spec);
Matt2f2f4252005-04-13 14:45:30 +02001804}
1805
Matt4e550962005-07-04 17:51:39 +02001806static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
1807 unsigned int flag)
1808{
1809 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1810 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02001811
Takashi Iwaif9acba42007-05-29 18:01:06 +02001812 if (pin_ctl & AC_PINCTL_IN_EN) {
1813 /*
1814 * we need to check the current set-up direction of
1815 * shared input pins since they can be switched via
1816 * "xxx as Output" mixer switch
1817 */
1818 struct sigmatel_spec *spec = codec->spec;
1819 struct auto_pin_cfg *cfg = &spec->autocfg;
1820 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
1821 spec->line_switch) ||
1822 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
1823 spec->mic_switch))
1824 return;
1825 }
1826
Steve Longerbeam7b043892007-05-03 20:50:03 +02001827 /* if setting pin direction bits, clear the current
1828 direction bits first */
1829 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
1830 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
1831
Matt4e550962005-07-04 17:51:39 +02001832 snd_hda_codec_write(codec, nid, 0,
1833 AC_VERB_SET_PIN_WIDGET_CONTROL,
1834 pin_ctl | flag);
1835}
1836
1837static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
1838 unsigned int flag)
1839{
1840 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1841 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
1842 snd_hda_codec_write(codec, nid, 0,
1843 AC_VERB_SET_PIN_WIDGET_CONTROL,
1844 pin_ctl & ~flag);
1845}
1846
Takashi Iwai314634b2006-09-21 11:56:18 +02001847static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
1848{
1849 if (!nid)
1850 return 0;
1851 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
1852 & (1 << 31))
1853 return 1;
1854 return 0;
1855}
1856
1857static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02001858{
1859 struct sigmatel_spec *spec = codec->spec;
1860 struct auto_pin_cfg *cfg = &spec->autocfg;
1861 int i, presence;
1862
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001863 presence = 0;
1864 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02001865 presence = get_pin_presence(codec, cfg->hp_pins[i]);
1866 if (presence)
1867 break;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001868 }
Matt4e550962005-07-04 17:51:39 +02001869
1870 if (presence) {
1871 /* disable lineouts, enable hp */
1872 for (i = 0; i < cfg->line_outs; i++)
1873 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
1874 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001875 for (i = 0; i < cfg->speaker_outs; i++)
1876 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
1877 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02001878 } else {
1879 /* enable lineouts, disable hp */
1880 for (i = 0; i < cfg->line_outs; i++)
1881 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
1882 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001883 for (i = 0; i < cfg->speaker_outs; i++)
1884 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
1885 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02001886 }
1887}
1888
Takashi Iwai314634b2006-09-21 11:56:18 +02001889static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
1890{
1891 switch (res >> 26) {
1892 case STAC_HP_EVENT:
1893 stac92xx_hp_detect(codec, res);
1894 break;
1895 }
1896}
1897
Mattff6fdc32005-06-27 15:06:52 +02001898#ifdef CONFIG_PM
1899static int stac92xx_resume(struct hda_codec *codec)
1900{
1901 struct sigmatel_spec *spec = codec->spec;
1902 int i;
1903
1904 stac92xx_init(codec);
Richard Fish11b44bb2006-08-23 18:31:34 +02001905 stac92xx_set_config_regs(codec);
Takashi Iwai5d403b12007-05-03 12:32:29 +02001906 snd_hda_resume_ctls(codec, spec->mixer);
Mattff6fdc32005-06-27 15:06:52 +02001907 for (i = 0; i < spec->num_mixers; i++)
1908 snd_hda_resume_ctls(codec, spec->mixers[i]);
1909 if (spec->multiout.dig_out_nid)
1910 snd_hda_resume_spdif_out(codec);
1911 if (spec->dig_in_nid)
1912 snd_hda_resume_spdif_in(codec);
1913
1914 return 0;
1915}
1916#endif
1917
Matt2f2f4252005-04-13 14:45:30 +02001918static struct hda_codec_ops stac92xx_patch_ops = {
1919 .build_controls = stac92xx_build_controls,
1920 .build_pcms = stac92xx_build_pcms,
1921 .init = stac92xx_init,
1922 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02001923 .unsol_event = stac92xx_unsol_event,
Mattff6fdc32005-06-27 15:06:52 +02001924#ifdef CONFIG_PM
1925 .resume = stac92xx_resume,
1926#endif
Matt2f2f4252005-04-13 14:45:30 +02001927};
1928
1929static int patch_stac9200(struct hda_codec *codec)
1930{
1931 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02001932 int err;
Matt2f2f4252005-04-13 14:45:30 +02001933
Takashi Iwaie560d8d2005-09-09 14:21:46 +02001934 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02001935 if (spec == NULL)
1936 return -ENOMEM;
1937
1938 codec->spec = spec;
Richard Fish11b44bb2006-08-23 18:31:34 +02001939 spec->num_pins = 8;
1940 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001941 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
1942 stac9200_models,
1943 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02001944 if (spec->board_config < 0) {
1945 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
1946 err = stac92xx_save_bios_config_regs(codec);
1947 if (err < 0) {
1948 stac92xx_free(codec);
1949 return err;
1950 }
1951 spec->pin_configs = spec->bios_pin_configs;
1952 } else {
Matt Porter403d1942005-11-29 15:00:51 +01001953 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
1954 stac92xx_set_config_regs(codec);
1955 }
Matt2f2f4252005-04-13 14:45:30 +02001956
1957 spec->multiout.max_channels = 2;
1958 spec->multiout.num_dacs = 1;
1959 spec->multiout.dac_nids = stac9200_dac_nids;
1960 spec->adc_nids = stac9200_adc_nids;
1961 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02001962 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02001963 spec->num_dmics = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02001964
1965 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02001966 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02001967
1968 err = stac9200_parse_auto_config(codec);
1969 if (err < 0) {
1970 stac92xx_free(codec);
1971 return err;
1972 }
Matt2f2f4252005-04-13 14:45:30 +02001973
1974 codec->patch_ops = stac92xx_patch_ops;
1975
1976 return 0;
1977}
1978
Tobin Davis8e21c342007-01-08 11:04:17 +01001979static int patch_stac925x(struct hda_codec *codec)
1980{
1981 struct sigmatel_spec *spec;
1982 int err;
1983
1984 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1985 if (spec == NULL)
1986 return -ENOMEM;
1987
1988 codec->spec = spec;
1989 spec->num_pins = 8;
1990 spec->pin_nids = stac925x_pin_nids;
1991 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
1992 stac925x_models,
1993 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01001994 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01001995 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02001996 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
1997 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01001998 err = stac92xx_save_bios_config_regs(codec);
1999 if (err < 0) {
2000 stac92xx_free(codec);
2001 return err;
2002 }
2003 spec->pin_configs = spec->bios_pin_configs;
2004 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
2005 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
2006 stac92xx_set_config_regs(codec);
2007 }
2008
2009 spec->multiout.max_channels = 2;
2010 spec->multiout.num_dacs = 1;
2011 spec->multiout.dac_nids = stac925x_dac_nids;
2012 spec->adc_nids = stac925x_adc_nids;
2013 spec->mux_nids = stac925x_mux_nids;
2014 spec->num_muxes = 1;
Tobin Davis2c11f952007-05-17 09:36:34 +02002015 switch (codec->vendor_id) {
2016 case 0x83847632: /* STAC9202 */
2017 case 0x83847633: /* STAC9202D */
2018 case 0x83847636: /* STAC9251 */
2019 case 0x83847637: /* STAC9251D */
2020 spec->num_dmics = 1;
2021 spec->dmic_nids = stac925x_dmic_nids;
2022 break;
2023 default:
2024 spec->num_dmics = 0;
2025 break;
2026 }
Tobin Davis8e21c342007-01-08 11:04:17 +01002027
2028 spec->init = stac925x_core_init;
2029 spec->mixer = stac925x_mixer;
2030
2031 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002032 if (!err) {
2033 if (spec->board_config < 0) {
2034 printk(KERN_WARNING "hda_codec: No auto-config is "
2035 "available, default to model=ref\n");
2036 spec->board_config = STAC_925x_REF;
2037 goto again;
2038 }
2039 err = -EINVAL;
2040 }
Tobin Davis8e21c342007-01-08 11:04:17 +01002041 if (err < 0) {
2042 stac92xx_free(codec);
2043 return err;
2044 }
2045
2046 codec->patch_ops = stac92xx_patch_ops;
2047
2048 return 0;
2049}
2050
Matt2f2f4252005-04-13 14:45:30 +02002051static int patch_stac922x(struct hda_codec *codec)
2052{
2053 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002054 int err;
Matt2f2f4252005-04-13 14:45:30 +02002055
Takashi Iwaie560d8d2005-09-09 14:21:46 +02002056 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02002057 if (spec == NULL)
2058 return -ENOMEM;
2059
2060 codec->spec = spec;
Richard Fish11b44bb2006-08-23 18:31:34 +02002061 spec->num_pins = 10;
2062 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002063 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
2064 stac922x_models,
2065 stac922x_cfg_tbl);
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002066 if (spec->board_config == STAC_INTEL_MAC_V3) {
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002067 spec->gpio_mute = 1;
2068 /* Intel Macs have all same PCI SSID, so we need to check
2069 * codec SSID to distinguish the exact models
2070 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01002071 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002072 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002073
2074 case 0x106b0800:
2075 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02002076 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002077 case 0x106b0600:
2078 case 0x106b0700:
2079 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01002080 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002081 case 0x106b0e00:
2082 case 0x106b0f00:
2083 case 0x106b1600:
2084 case 0x106b1700:
2085 case 0x106b0200:
2086 case 0x106b1e00:
2087 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002088 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002089 case 0x106b1a00:
2090 case 0x00000100:
2091 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02002092 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002093 case 0x106b0a00:
2094 case 0x106b2200:
2095 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002096 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002097 }
2098 }
2099
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002100 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02002101 if (spec->board_config < 0) {
2102 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
2103 "using BIOS defaults\n");
2104 err = stac92xx_save_bios_config_regs(codec);
2105 if (err < 0) {
2106 stac92xx_free(codec);
2107 return err;
2108 }
2109 spec->pin_configs = spec->bios_pin_configs;
2110 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01002111 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
2112 stac92xx_set_config_regs(codec);
2113 }
Matt2f2f4252005-04-13 14:45:30 +02002114
Matt2f2f4252005-04-13 14:45:30 +02002115 spec->adc_nids = stac922x_adc_nids;
2116 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002117 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002118 spec->num_dmics = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002119
2120 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02002121 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02002122
2123 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02002124
Matt Porter3cc08dc2006-01-23 15:27:49 +01002125 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002126 if (!err) {
2127 if (spec->board_config < 0) {
2128 printk(KERN_WARNING "hda_codec: No auto-config is "
2129 "available, default to model=ref\n");
2130 spec->board_config = STAC_D945_REF;
2131 goto again;
2132 }
2133 err = -EINVAL;
2134 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01002135 if (err < 0) {
2136 stac92xx_free(codec);
2137 return err;
2138 }
2139
2140 codec->patch_ops = stac92xx_patch_ops;
2141
Takashi Iwai807a46362007-05-29 19:01:37 +02002142 /* Fix Mux capture level; max to 2 */
2143 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
2144 (0 << AC_AMPCAP_OFFSET_SHIFT) |
2145 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
2146 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2147 (0 << AC_AMPCAP_MUTE_SHIFT));
2148
Matt Porter3cc08dc2006-01-23 15:27:49 +01002149 return 0;
2150}
2151
2152static int patch_stac927x(struct hda_codec *codec)
2153{
2154 struct sigmatel_spec *spec;
2155 int err;
2156
2157 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2158 if (spec == NULL)
2159 return -ENOMEM;
2160
2161 codec->spec = spec;
Richard Fish11b44bb2006-08-23 18:31:34 +02002162 spec->num_pins = 14;
2163 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002164 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
2165 stac927x_models,
2166 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002167 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02002168 if (spec->board_config < 0) {
Matt Porter3cc08dc2006-01-23 15:27:49 +01002169 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02002170 err = stac92xx_save_bios_config_regs(codec);
2171 if (err < 0) {
2172 stac92xx_free(codec);
2173 return err;
2174 }
2175 spec->pin_configs = spec->bios_pin_configs;
2176 } else if (stac927x_brd_tbl[spec->board_config] != NULL) {
Matt Porter3cc08dc2006-01-23 15:27:49 +01002177 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
2178 stac92xx_set_config_regs(codec);
2179 }
2180
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002181 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02002182 case STAC_D965_3ST:
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002183 spec->adc_nids = stac927x_adc_nids;
2184 spec->mux_nids = stac927x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002185 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002186 spec->num_dmics = 0;
Tobin Davis93ed1502006-09-01 21:03:12 +02002187 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002188 spec->mixer = stac9227_mixer;
2189 break;
Tobin Davis93ed1502006-09-01 21:03:12 +02002190 case STAC_D965_5ST:
2191 spec->adc_nids = stac927x_adc_nids;
2192 spec->mux_nids = stac927x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002193 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002194 spec->num_dmics = 0;
Tobin Davis93ed1502006-09-01 21:03:12 +02002195 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002196 spec->mixer = stac9227_mixer;
2197 break;
2198 default:
2199 spec->adc_nids = stac927x_adc_nids;
2200 spec->mux_nids = stac927x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002201 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002202 spec->num_dmics = 0;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002203 spec->init = stac927x_core_init;
2204 spec->mixer = stac927x_mixer;
2205 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01002206
2207 spec->multiout.dac_nids = spec->dac_nids;
2208
2209 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002210 if (!err) {
2211 if (spec->board_config < 0) {
2212 printk(KERN_WARNING "hda_codec: No auto-config is "
2213 "available, default to model=ref\n");
2214 spec->board_config = STAC_D965_REF;
2215 goto again;
2216 }
2217 err = -EINVAL;
2218 }
Mattc7d4b2f2005-06-27 14:59:41 +02002219 if (err < 0) {
2220 stac92xx_free(codec);
2221 return err;
2222 }
Matt2f2f4252005-04-13 14:45:30 +02002223
2224 codec->patch_ops = stac92xx_patch_ops;
2225
Takashi Iwai897cc182007-05-29 19:01:37 +02002226 /* Fix Mux capture level; max to 2 */
2227 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
2228 (0 << AC_AMPCAP_OFFSET_SHIFT) |
2229 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
2230 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2231 (0 << AC_AMPCAP_MUTE_SHIFT));
2232
Matt2f2f4252005-04-13 14:45:30 +02002233 return 0;
2234}
2235
Matt Porterf3302a52006-07-31 12:49:34 +02002236static int patch_stac9205(struct hda_codec *codec)
2237{
2238 struct sigmatel_spec *spec;
2239 int err;
2240
2241 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2242 if (spec == NULL)
2243 return -ENOMEM;
2244
2245 codec->spec = spec;
Richard Fish11b44bb2006-08-23 18:31:34 +02002246 spec->num_pins = 14;
2247 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002248 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
2249 stac9205_models,
2250 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002251 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02002252 if (spec->board_config < 0) {
2253 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
2254 err = stac92xx_save_bios_config_regs(codec);
2255 if (err < 0) {
2256 stac92xx_free(codec);
2257 return err;
2258 }
2259 spec->pin_configs = spec->bios_pin_configs;
2260 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02002261 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
2262 stac92xx_set_config_regs(codec);
2263 }
2264
2265 spec->adc_nids = stac9205_adc_nids;
2266 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002267 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002268 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002269 spec->num_dmics = ARRAY_SIZE(stac9205_dmic_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002270 spec->dmux_nid = 0x1d;
Matt Porterf3302a52006-07-31 12:49:34 +02002271
2272 spec->init = stac9205_core_init;
2273 spec->mixer = stac9205_mixer;
2274
2275 spec->multiout.dac_nids = spec->dac_nids;
2276
Matt Porter33382402006-12-18 13:17:28 +01002277 /* Configure GPIO0 as EAPD output */
2278 snd_hda_codec_write(codec, codec->afg, 0,
2279 AC_VERB_SET_GPIO_DIRECTION, 0x00000001);
2280 /* Configure GPIO0 as CMOS */
2281 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0x00000000);
2282 /* Assert GPIO0 high */
2283 snd_hda_codec_write(codec, codec->afg, 0,
2284 AC_VERB_SET_GPIO_DATA, 0x00000001);
2285 /* Enable GPIO0 */
2286 snd_hda_codec_write(codec, codec->afg, 0,
2287 AC_VERB_SET_GPIO_MASK, 0x00000001);
2288
Matt Porterf3302a52006-07-31 12:49:34 +02002289 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002290 if (!err) {
2291 if (spec->board_config < 0) {
2292 printk(KERN_WARNING "hda_codec: No auto-config is "
2293 "available, default to model=ref\n");
2294 spec->board_config = STAC_9205_REF;
2295 goto again;
2296 }
2297 err = -EINVAL;
2298 }
Matt Porterf3302a52006-07-31 12:49:34 +02002299 if (err < 0) {
2300 stac92xx_free(codec);
2301 return err;
2302 }
2303
2304 codec->patch_ops = stac92xx_patch_ops;
2305
2306 return 0;
2307}
2308
Matt2f2f4252005-04-13 14:45:30 +02002309/*
Guillaume Munch6d859062006-08-22 17:15:47 +02002310 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01002311 */
2312
Guillaume Munch99ccc562006-08-16 19:35:12 +02002313/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01002314static hda_nid_t vaio_dacs[] = { 0x2 };
2315#define VAIO_HP_DAC 0x5
2316static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
2317static hda_nid_t vaio_mux_nids[] = { 0x15 };
2318
2319static struct hda_input_mux vaio_mux = {
2320 .num_items = 2,
2321 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02002322 /* { "HP", 0x0 }, */
2323 { "Line", 0x1 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01002324 { "Mic", 0x2 },
2325 { "PCM", 0x3 },
2326 }
2327};
2328
2329static struct hda_verb vaio_init[] = {
2330 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
2331 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
2332 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
2333 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
2334 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
2335 {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
2336 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
2337 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
2338 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
2339 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
2340 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
2341 {}
2342};
2343
Guillaume Munch6d859062006-08-22 17:15:47 +02002344static struct hda_verb vaio_ar_init[] = {
2345 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
2346 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
2347 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
2348 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
2349/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
2350 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
2351 {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
2352 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
2353 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
2354/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
2355 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
2356 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
2357 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
2358 {}
2359};
2360
Takashi Iwaidb064e52006-03-16 16:04:58 +01002361/* bind volumes of both NID 0x02 and 0x05 */
2362static int vaio_master_vol_put(struct snd_kcontrol *kcontrol,
2363 struct snd_ctl_elem_value *ucontrol)
2364{
2365 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2366 long *valp = ucontrol->value.integer.value;
2367 int change;
2368
2369 change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
2370 0x7f, valp[0] & 0x7f);
2371 change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
2372 0x7f, valp[1] & 0x7f);
2373 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
2374 0x7f, valp[0] & 0x7f);
2375 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
2376 0x7f, valp[1] & 0x7f);
2377 return change;
2378}
2379
2380/* bind volumes of both NID 0x02 and 0x05 */
2381static int vaio_master_sw_put(struct snd_kcontrol *kcontrol,
2382 struct snd_ctl_elem_value *ucontrol)
2383{
2384 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2385 long *valp = ucontrol->value.integer.value;
2386 int change;
2387
2388 change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
Takashi Iwaia9393d72006-05-03 11:59:03 +02002389 0x80, (valp[0] ? 0 : 0x80));
Takashi Iwaidb064e52006-03-16 16:04:58 +01002390 change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
Takashi Iwaia9393d72006-05-03 11:59:03 +02002391 0x80, (valp[1] ? 0 : 0x80));
Takashi Iwaidb064e52006-03-16 16:04:58 +01002392 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
Takashi Iwaia9393d72006-05-03 11:59:03 +02002393 0x80, (valp[0] ? 0 : 0x80));
Takashi Iwaidb064e52006-03-16 16:04:58 +01002394 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
Takashi Iwaia9393d72006-05-03 11:59:03 +02002395 0x80, (valp[1] ? 0 : 0x80));
Takashi Iwaidb064e52006-03-16 16:04:58 +01002396 return change;
2397}
2398
2399static struct snd_kcontrol_new vaio_mixer[] = {
2400 {
2401 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2402 .name = "Master Playback Volume",
2403 .info = snd_hda_mixer_amp_volume_info,
2404 .get = snd_hda_mixer_amp_volume_get,
2405 .put = vaio_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02002406 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwaidb064e52006-03-16 16:04:58 +01002407 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2408 },
2409 {
2410 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2411 .name = "Master Playback Switch",
2412 .info = snd_hda_mixer_amp_switch_info,
2413 .get = snd_hda_mixer_amp_switch_get,
2414 .put = vaio_master_sw_put,
2415 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2416 },
2417 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2418 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
2419 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
2420 {
2421 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2422 .name = "Capture Source",
2423 .count = 1,
2424 .info = stac92xx_mux_enum_info,
2425 .get = stac92xx_mux_enum_get,
2426 .put = stac92xx_mux_enum_put,
2427 },
2428 {}
2429};
2430
Guillaume Munch6d859062006-08-22 17:15:47 +02002431static struct snd_kcontrol_new vaio_ar_mixer[] = {
2432 {
2433 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2434 .name = "Master Playback Volume",
2435 .info = snd_hda_mixer_amp_volume_info,
2436 .get = snd_hda_mixer_amp_volume_get,
2437 .put = vaio_master_vol_put,
2438 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2439 },
2440 {
2441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2442 .name = "Master Playback Switch",
2443 .info = snd_hda_mixer_amp_switch_info,
2444 .get = snd_hda_mixer_amp_switch_get,
2445 .put = vaio_master_sw_put,
2446 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2447 },
2448 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2449 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
2450 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
2451 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
2452 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
2453 {
2454 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2455 .name = "Capture Source",
2456 .count = 1,
2457 .info = stac92xx_mux_enum_info,
2458 .get = stac92xx_mux_enum_get,
2459 .put = stac92xx_mux_enum_put,
2460 },
2461 {}
2462};
2463
2464static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01002465 .build_controls = stac92xx_build_controls,
2466 .build_pcms = stac92xx_build_pcms,
2467 .init = stac92xx_init,
2468 .free = stac92xx_free,
2469#ifdef CONFIG_PM
2470 .resume = stac92xx_resume,
2471#endif
2472};
2473
Guillaume Munch6d859062006-08-22 17:15:47 +02002474enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
2475 CXD9872RD_VAIO,
2476 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
2477 STAC9872AK_VAIO,
2478 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
2479 STAC9872K_VAIO,
2480 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002481 CXD9872AKD_VAIO,
2482 STAC_9872_MODELS,
2483};
Takashi Iwaidb064e52006-03-16 16:04:58 +01002484
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002485static const char *stac9872_models[STAC_9872_MODELS] = {
2486 [CXD9872RD_VAIO] = "vaio",
2487 [CXD9872AKD_VAIO] = "vaio-ar",
2488};
2489
2490static struct snd_pci_quirk stac9872_cfg_tbl[] = {
2491 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
2492 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
2493 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01002494 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01002495 {}
2496};
2497
Guillaume Munch6d859062006-08-22 17:15:47 +02002498static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01002499{
2500 struct sigmatel_spec *spec;
2501 int board_config;
2502
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002503 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
2504 stac9872_models,
2505 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01002506 if (board_config < 0)
2507 /* unknown config, let generic-parser do its job... */
2508 return snd_hda_parse_generic_codec(codec);
2509
2510 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2511 if (spec == NULL)
2512 return -ENOMEM;
2513
2514 codec->spec = spec;
2515 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02002516 case CXD9872RD_VAIO:
2517 case STAC9872AK_VAIO:
2518 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01002519 spec->mixer = vaio_mixer;
2520 spec->init = vaio_init;
2521 spec->multiout.max_channels = 2;
2522 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
2523 spec->multiout.dac_nids = vaio_dacs;
2524 spec->multiout.hp_nid = VAIO_HP_DAC;
2525 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
2526 spec->adc_nids = vaio_adcs;
2527 spec->input_mux = &vaio_mux;
2528 spec->mux_nids = vaio_mux_nids;
2529 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02002530
2531 case CXD9872AKD_VAIO:
2532 spec->mixer = vaio_ar_mixer;
2533 spec->init = vaio_ar_init;
2534 spec->multiout.max_channels = 2;
2535 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
2536 spec->multiout.dac_nids = vaio_dacs;
2537 spec->multiout.hp_nid = VAIO_HP_DAC;
2538 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
2539 spec->adc_nids = vaio_adcs;
2540 spec->input_mux = &vaio_mux;
2541 spec->mux_nids = vaio_mux_nids;
2542 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01002543 }
2544
Guillaume Munch6d859062006-08-22 17:15:47 +02002545 codec->patch_ops = stac9872_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01002546 return 0;
2547}
2548
2549
2550/*
Matt2f2f4252005-04-13 14:45:30 +02002551 * patch entries
2552 */
2553struct hda_codec_preset snd_hda_preset_sigmatel[] = {
2554 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
2555 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
2556 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
2557 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
2558 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
2559 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
2560 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02002561 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
2562 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
2563 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
2564 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
2565 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
2566 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01002567 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
2568 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
2569 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
2570 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
2571 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
2572 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
2573 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
2574 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
2575 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
2576 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01002577 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
2578 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
2579 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
2580 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
2581 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
2582 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Guillaume Munch6d859062006-08-22 17:15:47 +02002583 /* The following does not take into account .id=0x83847661 when subsys =
2584 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
2585 * currently not fully supported.
2586 */
2587 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
2588 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
2589 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02002590 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
2591 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
2592 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
2593 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
2594 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
2595 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
2596 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
2597 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matt2f2f4252005-04-13 14:45:30 +02002598 {} /* terminator */
2599};