blob: 270539a2bbc9bde98820fbeb404977404636fb82 [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
Matthew Ranostay92a22be2007-06-19 16:48:28 +0200847static void stac92xx_enable_eapd(struct hda_codec *codec)
848{
849 /* Configure GPIO0 as output */
850 snd_hda_codec_write(codec, codec->afg, 0,
851 AC_VERB_SET_GPIO_DIRECTION, 0x00000001);
852 /* Configure GPIO0 as CMOS */
853 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0x00000000);
854 /* Assert GPIO0 high */
855 snd_hda_codec_write(codec, codec->afg, 0,
856 AC_VERB_SET_GPIO_DATA, 0x00000001);
857 /* Enable GPIO0 */
858 snd_hda_codec_write(codec, codec->afg, 0,
859 AC_VERB_SET_GPIO_MASK, 0x00000001);
860}
861
Matt2f2f4252005-04-13 14:45:30 +0200862/*
863 * Analog playback callbacks
864 */
865static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
866 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100867 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200868{
869 struct sigmatel_spec *spec = codec->spec;
870 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
871}
872
873static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
874 struct hda_codec *codec,
875 unsigned int stream_tag,
876 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100877 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200878{
879 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +0100880 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +0200881}
882
883static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
884 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100885 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200886{
887 struct sigmatel_spec *spec = codec->spec;
888 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
889}
890
891/*
Mattdabbed62005-06-14 10:19:34 +0200892 * Digital playback callbacks
893 */
894static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
895 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100896 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +0200897{
898 struct sigmatel_spec *spec = codec->spec;
899 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
900}
901
902static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
903 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100904 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +0200905{
906 struct sigmatel_spec *spec = codec->spec;
907 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
908}
909
Takashi Iwai6b97eb42007-04-05 14:51:48 +0200910static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
911 struct hda_codec *codec,
912 unsigned int stream_tag,
913 unsigned int format,
914 struct snd_pcm_substream *substream)
915{
916 struct sigmatel_spec *spec = codec->spec;
917 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
918 stream_tag, format, substream);
919}
920
Mattdabbed62005-06-14 10:19:34 +0200921
922/*
Matt2f2f4252005-04-13 14:45:30 +0200923 * Analog capture callbacks
924 */
925static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
926 struct hda_codec *codec,
927 unsigned int stream_tag,
928 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100929 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200930{
931 struct sigmatel_spec *spec = codec->spec;
932
933 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
934 stream_tag, 0, format);
935 return 0;
936}
937
938static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
939 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100940 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200941{
942 struct sigmatel_spec *spec = codec->spec;
943
944 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
945 return 0;
946}
947
Mattdabbed62005-06-14 10:19:34 +0200948static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
949 .substreams = 1,
950 .channels_min = 2,
951 .channels_max = 2,
952 /* NID is set in stac92xx_build_pcms */
953 .ops = {
954 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +0200955 .close = stac92xx_dig_playback_pcm_close,
956 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +0200957 },
958};
959
960static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
961 .substreams = 1,
962 .channels_min = 2,
963 .channels_max = 2,
964 /* NID is set in stac92xx_build_pcms */
965};
966
Matt2f2f4252005-04-13 14:45:30 +0200967static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
968 .substreams = 1,
969 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +0200970 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +0200971 .nid = 0x02, /* NID to query formats and rates */
972 .ops = {
973 .open = stac92xx_playback_pcm_open,
974 .prepare = stac92xx_playback_pcm_prepare,
975 .cleanup = stac92xx_playback_pcm_cleanup
976 },
977};
978
Matt Porter3cc08dc2006-01-23 15:27:49 +0100979static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
980 .substreams = 1,
981 .channels_min = 2,
982 .channels_max = 2,
983 .nid = 0x06, /* NID to query formats and rates */
984 .ops = {
985 .open = stac92xx_playback_pcm_open,
986 .prepare = stac92xx_playback_pcm_prepare,
987 .cleanup = stac92xx_playback_pcm_cleanup
988 },
989};
990
Matt2f2f4252005-04-13 14:45:30 +0200991static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
992 .substreams = 2,
993 .channels_min = 2,
994 .channels_max = 2,
Matt Porter3cc08dc2006-01-23 15:27:49 +0100995 /* NID is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +0200996 .ops = {
997 .prepare = stac92xx_capture_pcm_prepare,
998 .cleanup = stac92xx_capture_pcm_cleanup
999 },
1000};
1001
1002static int stac92xx_build_pcms(struct hda_codec *codec)
1003{
1004 struct sigmatel_spec *spec = codec->spec;
1005 struct hda_pcm *info = spec->pcm_rec;
1006
1007 codec->num_pcms = 1;
1008 codec->pcm_info = info;
1009
Mattc7d4b2f2005-06-27 14:59:41 +02001010 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +02001011 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +02001012 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +01001013 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1014
1015 if (spec->alt_switch) {
1016 codec->num_pcms++;
1017 info++;
1018 info->name = "STAC92xx Analog Alt";
1019 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
1020 }
Matt2f2f4252005-04-13 14:45:30 +02001021
Mattdabbed62005-06-14 10:19:34 +02001022 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1023 codec->num_pcms++;
1024 info++;
1025 info->name = "STAC92xx Digital";
1026 if (spec->multiout.dig_out_nid) {
1027 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
1028 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1029 }
1030 if (spec->dig_in_nid) {
1031 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
1032 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1033 }
1034 }
1035
Matt2f2f4252005-04-13 14:45:30 +02001036 return 0;
1037}
1038
Takashi Iwaic960a032006-03-23 17:06:28 +01001039static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
1040{
1041 unsigned int pincap = snd_hda_param_read(codec, nid,
1042 AC_PAR_PIN_CAP);
1043 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
1044 if (pincap & AC_PINCAP_VREF_100)
1045 return AC_PINCTL_VREF_100;
1046 if (pincap & AC_PINCAP_VREF_80)
1047 return AC_PINCTL_VREF_80;
1048 if (pincap & AC_PINCAP_VREF_50)
1049 return AC_PINCTL_VREF_50;
1050 if (pincap & AC_PINCAP_VREF_GRD)
1051 return AC_PINCTL_VREF_GRD;
1052 return 0;
1053}
1054
Matt Porter403d1942005-11-29 15:00:51 +01001055static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
1056
1057{
1058 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
1059}
1060
1061static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1062{
1063 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1064 uinfo->count = 1;
1065 uinfo->value.integer.min = 0;
1066 uinfo->value.integer.max = 1;
1067 return 0;
1068}
1069
1070static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1071{
1072 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1073 struct sigmatel_spec *spec = codec->spec;
1074 int io_idx = kcontrol-> private_value & 0xff;
1075
1076 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
1077 return 0;
1078}
1079
1080static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1081{
1082 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1083 struct sigmatel_spec *spec = codec->spec;
1084 hda_nid_t nid = kcontrol->private_value >> 8;
1085 int io_idx = kcontrol-> private_value & 0xff;
1086 unsigned short val = ucontrol->value.integer.value[0];
1087
1088 spec->io_switch[io_idx] = val;
1089
1090 if (val)
1091 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01001092 else {
1093 unsigned int pinctl = AC_PINCTL_IN_EN;
1094 if (io_idx) /* set VREF for mic */
1095 pinctl |= stac92xx_get_vref(codec, nid);
1096 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1097 }
Matt Porter403d1942005-11-29 15:00:51 +01001098 return 1;
1099}
1100
1101#define STAC_CODEC_IO_SWITCH(xname, xpval) \
1102 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1103 .name = xname, \
1104 .index = 0, \
1105 .info = stac92xx_io_switch_info, \
1106 .get = stac92xx_io_switch_get, \
1107 .put = stac92xx_io_switch_put, \
1108 .private_value = xpval, \
1109 }
1110
1111
Mattc7d4b2f2005-06-27 14:59:41 +02001112enum {
1113 STAC_CTL_WIDGET_VOL,
1114 STAC_CTL_WIDGET_MUTE,
Matt Porter403d1942005-11-29 15:00:51 +01001115 STAC_CTL_WIDGET_IO_SWITCH,
Mattc7d4b2f2005-06-27 14:59:41 +02001116};
1117
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001118static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02001119 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1120 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matt Porter403d1942005-11-29 15:00:51 +01001121 STAC_CODEC_IO_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02001122};
1123
1124/* add dynamic controls */
1125static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
1126{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001127 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02001128
1129 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1130 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1131
1132 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1133 if (! knew)
1134 return -ENOMEM;
1135 if (spec->kctl_alloc) {
1136 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1137 kfree(spec->kctl_alloc);
1138 }
1139 spec->kctl_alloc = knew;
1140 spec->num_kctl_alloc = num;
1141 }
1142
1143 knew = &spec->kctl_alloc[spec->num_kctl_used];
1144 *knew = stac92xx_control_templates[type];
Takashi Iwai82fe0c52005-06-30 10:54:33 +02001145 knew->name = kstrdup(name, GFP_KERNEL);
Mattc7d4b2f2005-06-27 14:59:41 +02001146 if (! knew->name)
1147 return -ENOMEM;
1148 knew->private_value = val;
1149 spec->num_kctl_used++;
1150 return 0;
1151}
1152
Matt Porter403d1942005-11-29 15:00:51 +01001153/* flag inputs as additional dynamic lineouts */
1154static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
1155{
1156 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02001157 unsigned int wcaps, wtype;
1158 int i, num_dacs = 0;
1159
1160 /* use the wcaps cache to count all DACs available for line-outs */
1161 for (i = 0; i < codec->num_nodes; i++) {
1162 wcaps = codec->wcaps[i];
1163 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1164 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
1165 num_dacs++;
1166 }
Matt Porter403d1942005-11-29 15:00:51 +01001167
Steve Longerbeam7b043892007-05-03 20:50:03 +02001168 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
1169
Matt Porter403d1942005-11-29 15:00:51 +01001170 switch (cfg->line_outs) {
1171 case 3:
1172 /* add line-in as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02001173 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Matt Porter403d1942005-11-29 15:00:51 +01001174 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE];
1175 spec->line_switch = 1;
1176 cfg->line_outs++;
1177 }
1178 break;
1179 case 2:
1180 /* add line-in as clfe and mic as side */
Steve Longerbeam7b043892007-05-03 20:50:03 +02001181 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Matt Porter403d1942005-11-29 15:00:51 +01001182 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE];
1183 spec->line_switch = 1;
1184 cfg->line_outs++;
1185 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02001186 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Matt Porter403d1942005-11-29 15:00:51 +01001187 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC];
1188 spec->mic_switch = 1;
1189 cfg->line_outs++;
1190 }
1191 break;
1192 case 1:
1193 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b043892007-05-03 20:50:03 +02001194 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Matt Porter403d1942005-11-29 15:00:51 +01001195 cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE];
1196 spec->line_switch = 1;
1197 cfg->line_outs++;
1198 }
Steve Longerbeam7b043892007-05-03 20:50:03 +02001199 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Matt Porter403d1942005-11-29 15:00:51 +01001200 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC];
1201 spec->mic_switch = 1;
1202 cfg->line_outs++;
1203 }
1204 break;
1205 }
1206
1207 return 0;
1208}
1209
Steve Longerbeam7b043892007-05-03 20:50:03 +02001210
1211static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1212{
1213 int i;
1214
1215 for (i = 0; i < spec->multiout.num_dacs; i++) {
1216 if (spec->multiout.dac_nids[i] == nid)
1217 return 1;
1218 }
1219
1220 return 0;
1221}
1222
Matt Porter3cc08dc2006-01-23 15:27:49 +01001223/*
Steve Longerbeam7b043892007-05-03 20:50:03 +02001224 * Fill in the dac_nids table from the parsed pin configuration
1225 * This function only works when every pin in line_out_pins[]
1226 * contains atleast one DAC in its connection list. Some 92xx
1227 * codecs are not connected directly to a DAC, such as the 9200
1228 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01001229 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02001230static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
1231 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02001232{
1233 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b043892007-05-03 20:50:03 +02001234 int i, j, conn_len = 0;
1235 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
1236 unsigned int wcaps, wtype;
1237
Mattc7d4b2f2005-06-27 14:59:41 +02001238 for (i = 0; i < cfg->line_outs; i++) {
1239 nid = cfg->line_out_pins[i];
Steve Longerbeam7b043892007-05-03 20:50:03 +02001240 conn_len = snd_hda_get_connections(codec, nid, conn,
1241 HDA_MAX_CONNECTIONS);
1242 for (j = 0; j < conn_len; j++) {
1243 wcaps = snd_hda_param_read(codec, conn[j],
1244 AC_PAR_AUDIO_WIDGET_CAP);
1245 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1246
1247 if (wtype != AC_WID_AUD_OUT ||
1248 (wcaps & AC_WCAP_DIGITAL))
1249 continue;
1250 /* conn[j] is a DAC routed to this line-out */
1251 if (!is_in_dac_nids(spec, conn[j]))
1252 break;
1253 }
1254
1255 if (j == conn_len) {
1256 /* error out, no available DAC found */
1257 snd_printk(KERN_ERR
1258 "%s: No available DAC for pin 0x%x\n",
1259 __func__, nid);
1260 return -ENODEV;
1261 }
1262
1263 spec->multiout.dac_nids[i] = conn[j];
1264 spec->multiout.num_dacs++;
1265 if (conn_len > 1) {
1266 /* select this DAC in the pin's input mux */
1267 snd_hda_codec_write(codec, nid, 0,
1268 AC_VERB_SET_CONNECT_SEL, j);
1269
1270 }
Mattc7d4b2f2005-06-27 14:59:41 +02001271 }
1272
Steve Longerbeam7b043892007-05-03 20:50:03 +02001273 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
1274 spec->multiout.num_dacs,
1275 spec->multiout.dac_nids[0],
1276 spec->multiout.dac_nids[1],
1277 spec->multiout.dac_nids[2],
1278 spec->multiout.dac_nids[3],
1279 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02001280 return 0;
1281}
1282
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001283/* create volume control/switch for the given prefx type */
1284static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
1285{
1286 char name[32];
1287 int err;
1288
1289 sprintf(name, "%s Playback Volume", pfx);
1290 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
1291 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1292 if (err < 0)
1293 return err;
1294 sprintf(name, "%s Playback Switch", pfx);
1295 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
1296 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1297 if (err < 0)
1298 return err;
1299 return 0;
1300}
1301
Mattc7d4b2f2005-06-27 14:59:41 +02001302/* add playback controls from the parsed DAC table */
Takashi Iwai19039bd2006-06-28 15:52:16 +02001303static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec,
1304 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02001305{
Takashi Iwai19039bd2006-06-28 15:52:16 +02001306 static const char *chname[4] = {
1307 "Front", "Surround", NULL /*CLFE*/, "Side"
1308 };
Mattc7d4b2f2005-06-27 14:59:41 +02001309 hda_nid_t nid;
1310 int i, err;
1311
1312 for (i = 0; i < cfg->line_outs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01001313 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02001314 continue;
1315
1316 nid = spec->multiout.dac_nids[i];
1317
1318 if (i == 2) {
1319 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001320 err = create_controls(spec, "Center", nid, 1);
1321 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001322 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001323 err = create_controls(spec, "LFE", nid, 2);
1324 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001325 return err;
1326 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001327 err = create_controls(spec, chname[i], nid, 3);
1328 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001329 return err;
1330 }
1331 }
1332
Matt Porter403d1942005-11-29 15:00:51 +01001333 if (spec->line_switch)
1334 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
1335 return err;
1336
1337 if (spec->mic_switch)
1338 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
1339 return err;
1340
Mattc7d4b2f2005-06-27 14:59:41 +02001341 return 0;
1342}
1343
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001344static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1345{
Steve Longerbeam7b043892007-05-03 20:50:03 +02001346 if (is_in_dac_nids(spec, nid))
1347 return 1;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001348 if (spec->multiout.hp_nid == nid)
1349 return 1;
1350 return 0;
1351}
1352
1353static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
1354{
1355 if (!spec->multiout.hp_nid)
1356 spec->multiout.hp_nid = nid;
1357 else if (spec->multiout.num_dacs > 4) {
1358 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
1359 return 1;
1360 } else {
1361 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
1362 spec->multiout.num_dacs++;
1363 }
1364 return 0;
1365}
1366
1367/* add playback controls for Speaker and HP outputs */
1368static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
1369 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02001370{
1371 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02001372 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001373 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02001374
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001375 old_num_dacs = spec->multiout.num_dacs;
1376 for (i = 0; i < cfg->hp_outs; i++) {
1377 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
1378 if (wid_caps & AC_WCAP_UNSOL_CAP)
1379 spec->hp_detect = 1;
1380 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
1381 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1382 if (check_in_dac_nids(spec, nid))
1383 nid = 0;
1384 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02001385 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001386 add_spec_dacs(spec, nid);
1387 }
1388 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b043892007-05-03 20:50:03 +02001389 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001390 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1391 if (check_in_dac_nids(spec, nid))
1392 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001393 if (! nid)
1394 continue;
1395 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02001396 }
1397
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001398 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
1399 static const char *pfxs[] = {
1400 "Speaker", "External Speaker", "Speaker2",
1401 };
1402 err = create_controls(spec, pfxs[i - old_num_dacs],
1403 spec->multiout.dac_nids[i], 3);
1404 if (err < 0)
1405 return err;
1406 }
1407 if (spec->multiout.hp_nid) {
1408 const char *pfx;
1409 if (old_num_dacs == spec->multiout.num_dacs)
1410 pfx = "Master";
1411 else
1412 pfx = "Headphone";
1413 err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
1414 if (err < 0)
1415 return err;
1416 }
Mattc7d4b2f2005-06-27 14:59:41 +02001417
1418 return 0;
1419}
1420
Matt Porter8b657272006-10-26 17:12:59 +02001421/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01001422static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02001423 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
1424 "Digital Mic 3", "Digital Mic 4"
1425};
1426
1427/* create playback/capture controls for input pins on dmic capable codecs */
1428static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
1429 const struct auto_pin_cfg *cfg)
1430{
1431 struct sigmatel_spec *spec = codec->spec;
1432 struct hda_input_mux *dimux = &spec->private_dimux;
1433 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1434 int i, j;
1435
1436 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
1437 dimux->items[dimux->num_items].index = 0;
1438 dimux->num_items++;
1439
1440 for (i = 0; i < spec->num_dmics; i++) {
1441 int index;
1442 int num_cons;
1443 unsigned int def_conf;
1444
1445 def_conf = snd_hda_codec_read(codec,
1446 spec->dmic_nids[i],
1447 0,
1448 AC_VERB_GET_CONFIG_DEFAULT,
1449 0);
1450 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
1451 continue;
1452
1453 num_cons = snd_hda_get_connections(codec,
1454 spec->dmux_nid,
1455 con_lst,
1456 HDA_MAX_NUM_INPUTS);
1457 for (j = 0; j < num_cons; j++)
1458 if (con_lst[j] == spec->dmic_nids[i]) {
1459 index = j;
1460 goto found;
1461 }
1462 continue;
1463found:
1464 dimux->items[dimux->num_items].label =
1465 stac92xx_dmic_labels[dimux->num_items];
1466 dimux->items[dimux->num_items].index = index;
1467 dimux->num_items++;
1468 }
1469
1470 return 0;
1471}
1472
Mattc7d4b2f2005-06-27 14:59:41 +02001473/* create playback/capture controls for input pins */
1474static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
1475{
1476 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02001477 struct hda_input_mux *imux = &spec->private_imux;
1478 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1479 int i, j, k;
1480
1481 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02001482 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02001483
Takashi Iwai314634b2006-09-21 11:56:18 +02001484 if (!cfg->input_pins[i])
1485 continue;
1486 index = -1;
1487 for (j = 0; j < spec->num_muxes; j++) {
1488 int num_cons;
1489 num_cons = snd_hda_get_connections(codec,
1490 spec->mux_nids[j],
1491 con_lst,
1492 HDA_MAX_NUM_INPUTS);
1493 for (k = 0; k < num_cons; k++)
1494 if (con_lst[k] == cfg->input_pins[i]) {
1495 index = k;
1496 goto found;
1497 }
Mattc7d4b2f2005-06-27 14:59:41 +02001498 }
Takashi Iwai314634b2006-09-21 11:56:18 +02001499 continue;
1500 found:
1501 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
1502 imux->items[imux->num_items].index = index;
1503 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02001504 }
1505
Steve Longerbeam7b043892007-05-03 20:50:03 +02001506 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02001507 /*
1508 * Set the current input for the muxes.
1509 * The STAC9221 has two input muxes with identical source
1510 * NID lists. Hopefully this won't get confused.
1511 */
1512 for (i = 0; i < spec->num_muxes; i++) {
1513 snd_hda_codec_write(codec, spec->mux_nids[i], 0,
1514 AC_VERB_SET_CONNECT_SEL,
1515 imux->items[0].index);
1516 }
1517 }
1518
Mattc7d4b2f2005-06-27 14:59:41 +02001519 return 0;
1520}
1521
Mattc7d4b2f2005-06-27 14:59:41 +02001522static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
1523{
1524 struct sigmatel_spec *spec = codec->spec;
1525 int i;
1526
1527 for (i = 0; i < spec->autocfg.line_outs; i++) {
1528 hda_nid_t nid = spec->autocfg.line_out_pins[i];
1529 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
1530 }
1531}
1532
1533static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
1534{
1535 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001536 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02001537
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001538 for (i = 0; i < spec->autocfg.hp_outs; i++) {
1539 hda_nid_t pin;
1540 pin = spec->autocfg.hp_pins[i];
1541 if (pin) /* connect to front */
1542 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
1543 }
1544 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
1545 hda_nid_t pin;
1546 pin = spec->autocfg.speaker_pins[i];
1547 if (pin) /* connect to front */
1548 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
1549 }
Mattc7d4b2f2005-06-27 14:59:41 +02001550}
1551
Matt Porter3cc08dc2006-01-23 15:27:49 +01001552static 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 +02001553{
1554 struct sigmatel_spec *spec = codec->spec;
1555 int err;
1556
Matt Porter8b657272006-10-26 17:12:59 +02001557 if ((err = snd_hda_parse_pin_def_config(codec,
1558 &spec->autocfg,
1559 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001560 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001561 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01001562 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02001563
Matt Porter403d1942005-11-29 15:00:51 +01001564 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
1565 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02001566 if (spec->multiout.num_dacs == 0)
1567 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
1568 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001569
1570 if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
1571 (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 ||
1572 (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
1573 return err;
1574
Matt Porter8b657272006-10-26 17:12:59 +02001575 if (spec->num_dmics > 0)
1576 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
1577 &spec->autocfg)) < 0)
1578 return err;
1579
Mattc7d4b2f2005-06-27 14:59:41 +02001580 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01001581 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02001582 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02001583
Takashi Iwai82bc9552006-03-21 11:24:42 +01001584 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01001585 spec->multiout.dig_out_nid = dig_out;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001586 if (spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01001587 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02001588
1589 if (spec->kctl_alloc)
1590 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
1591
1592 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02001593 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02001594
1595 return 1;
1596}
1597
Takashi Iwai82bc9552006-03-21 11:24:42 +01001598/* add playback controls for HP output */
1599static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
1600 struct auto_pin_cfg *cfg)
1601{
1602 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001603 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01001604 unsigned int wid_caps;
1605
1606 if (! pin)
1607 return 0;
1608
1609 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02001610 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01001611 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001612
1613 return 0;
1614}
1615
Richard Fish160ea0d2006-09-06 13:58:25 +02001616/* add playback controls for LFE output */
1617static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
1618 struct auto_pin_cfg *cfg)
1619{
1620 struct sigmatel_spec *spec = codec->spec;
1621 int err;
1622 hda_nid_t lfe_pin = 0x0;
1623 int i;
1624
1625 /*
1626 * search speaker outs and line outs for a mono speaker pin
1627 * with an amp. If one is found, add LFE controls
1628 * for it.
1629 */
1630 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
1631 hda_nid_t pin = spec->autocfg.speaker_pins[i];
1632 unsigned long wcaps = get_wcaps(codec, pin);
1633 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
1634 if (wcaps == AC_WCAP_OUT_AMP)
1635 /* found a mono speaker with an amp, must be lfe */
1636 lfe_pin = pin;
1637 }
1638
1639 /* if speaker_outs is 0, then speakers may be in line_outs */
1640 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
1641 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
1642 hda_nid_t pin = spec->autocfg.line_out_pins[i];
1643 unsigned long cfg;
1644 cfg = snd_hda_codec_read(codec, pin, 0,
1645 AC_VERB_GET_CONFIG_DEFAULT,
1646 0x00);
1647 if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) {
1648 unsigned long wcaps = get_wcaps(codec, pin);
1649 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
1650 if (wcaps == AC_WCAP_OUT_AMP)
1651 /* found a mono speaker with an amp,
1652 must be lfe */
1653 lfe_pin = pin;
1654 }
1655 }
1656 }
1657
1658 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001659 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02001660 if (err < 0)
1661 return err;
1662 }
1663
1664 return 0;
1665}
1666
Mattc7d4b2f2005-06-27 14:59:41 +02001667static int stac9200_parse_auto_config(struct hda_codec *codec)
1668{
1669 struct sigmatel_spec *spec = codec->spec;
1670 int err;
1671
Kailang Yangdf694da2005-12-05 19:42:22 +01001672 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001673 return err;
1674
1675 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
1676 return err;
1677
Takashi Iwai82bc9552006-03-21 11:24:42 +01001678 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
1679 return err;
1680
Richard Fish160ea0d2006-09-06 13:58:25 +02001681 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
1682 return err;
1683
Takashi Iwai82bc9552006-03-21 11:24:42 +01001684 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02001685 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001686 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02001687 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02001688
1689 if (spec->kctl_alloc)
1690 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
1691
1692 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02001693 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02001694
1695 return 1;
1696}
1697
Sam Revitch62fe78e2006-05-10 15:09:17 +02001698/*
1699 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
1700 * funky external mute control using GPIO pins.
1701 */
1702
1703static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted)
1704{
1705 unsigned int gpiostate, gpiomask, gpiodir;
1706
1707 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
1708 AC_VERB_GET_GPIO_DATA, 0);
1709
1710 if (!muted)
1711 gpiostate |= (1 << pin);
1712 else
1713 gpiostate &= ~(1 << pin);
1714
1715 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
1716 AC_VERB_GET_GPIO_MASK, 0);
1717 gpiomask |= (1 << pin);
1718
1719 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
1720 AC_VERB_GET_GPIO_DIRECTION, 0);
1721 gpiodir |= (1 << pin);
1722
1723 /* AppleHDA seems to do this -- WTF is this verb?? */
1724 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
1725
1726 snd_hda_codec_write(codec, codec->afg, 0,
1727 AC_VERB_SET_GPIO_MASK, gpiomask);
1728 snd_hda_codec_write(codec, codec->afg, 0,
1729 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
1730
1731 msleep(1);
1732
1733 snd_hda_codec_write(codec, codec->afg, 0,
1734 AC_VERB_SET_GPIO_DATA, gpiostate);
1735}
1736
Takashi Iwai314634b2006-09-21 11:56:18 +02001737static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
1738 unsigned int event)
1739{
1740 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
1741 snd_hda_codec_write(codec, nid, 0,
1742 AC_VERB_SET_UNSOLICITED_ENABLE,
1743 (AC_USRSP_EN | event));
1744}
1745
Mattc7d4b2f2005-06-27 14:59:41 +02001746static int stac92xx_init(struct hda_codec *codec)
1747{
1748 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001749 struct auto_pin_cfg *cfg = &spec->autocfg;
1750 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02001751
Mattc7d4b2f2005-06-27 14:59:41 +02001752 snd_hda_sequence_write(codec, spec->init);
1753
Takashi Iwai82bc9552006-03-21 11:24:42 +01001754 /* set up pins */
1755 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02001756 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001757 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02001758 enable_pin_detect(codec, cfg->hp_pins[i],
1759 STAC_HP_EVENT);
Takashi Iwai0a07aca2007-03-13 10:40:23 +01001760 /* force to enable the first line-out; the others are set up
1761 * in unsol_event
1762 */
1763 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
1764 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02001765 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01001766 /* fake event to set up pins */
1767 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
1768 } else {
1769 stac92xx_auto_init_multi_out(codec);
1770 stac92xx_auto_init_hp_out(codec);
1771 }
1772 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01001773 hda_nid_t nid = cfg->input_pins[i];
1774 if (nid) {
1775 unsigned int pinctl = AC_PINCTL_IN_EN;
1776 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
1777 pinctl |= stac92xx_get_vref(codec, nid);
1778 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1779 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01001780 }
Matt Porter8b657272006-10-26 17:12:59 +02001781 if (spec->num_dmics > 0)
1782 for (i = 0; i < spec->num_dmics; i++)
1783 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
1784 AC_PINCTL_IN_EN);
1785
Takashi Iwai82bc9552006-03-21 11:24:42 +01001786 if (cfg->dig_out_pin)
1787 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
1788 AC_PINCTL_OUT_EN);
1789 if (cfg->dig_in_pin)
1790 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
1791 AC_PINCTL_IN_EN);
1792
Sam Revitch62fe78e2006-05-10 15:09:17 +02001793 if (spec->gpio_mute) {
1794 stac922x_gpio_mute(codec, 0, 0);
1795 stac922x_gpio_mute(codec, 1, 0);
1796 }
1797
Mattc7d4b2f2005-06-27 14:59:41 +02001798 return 0;
1799}
1800
Matt2f2f4252005-04-13 14:45:30 +02001801static void stac92xx_free(struct hda_codec *codec)
1802{
Mattc7d4b2f2005-06-27 14:59:41 +02001803 struct sigmatel_spec *spec = codec->spec;
1804 int i;
1805
1806 if (! spec)
1807 return;
1808
1809 if (spec->kctl_alloc) {
1810 for (i = 0; i < spec->num_kctl_used; i++)
1811 kfree(spec->kctl_alloc[i].name);
1812 kfree(spec->kctl_alloc);
1813 }
1814
Richard Fish11b44bb2006-08-23 18:31:34 +02001815 if (spec->bios_pin_configs)
1816 kfree(spec->bios_pin_configs);
1817
Mattc7d4b2f2005-06-27 14:59:41 +02001818 kfree(spec);
Matt2f2f4252005-04-13 14:45:30 +02001819}
1820
Matt4e550962005-07-04 17:51:39 +02001821static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
1822 unsigned int flag)
1823{
1824 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1825 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b043892007-05-03 20:50:03 +02001826
Takashi Iwaif9acba42007-05-29 18:01:06 +02001827 if (pin_ctl & AC_PINCTL_IN_EN) {
1828 /*
1829 * we need to check the current set-up direction of
1830 * shared input pins since they can be switched via
1831 * "xxx as Output" mixer switch
1832 */
1833 struct sigmatel_spec *spec = codec->spec;
1834 struct auto_pin_cfg *cfg = &spec->autocfg;
1835 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
1836 spec->line_switch) ||
1837 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
1838 spec->mic_switch))
1839 return;
1840 }
1841
Steve Longerbeam7b043892007-05-03 20:50:03 +02001842 /* if setting pin direction bits, clear the current
1843 direction bits first */
1844 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
1845 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
1846
Matt4e550962005-07-04 17:51:39 +02001847 snd_hda_codec_write(codec, nid, 0,
1848 AC_VERB_SET_PIN_WIDGET_CONTROL,
1849 pin_ctl | flag);
1850}
1851
1852static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
1853 unsigned int flag)
1854{
1855 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1856 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
1857 snd_hda_codec_write(codec, nid, 0,
1858 AC_VERB_SET_PIN_WIDGET_CONTROL,
1859 pin_ctl & ~flag);
1860}
1861
Takashi Iwai314634b2006-09-21 11:56:18 +02001862static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
1863{
1864 if (!nid)
1865 return 0;
1866 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
1867 & (1 << 31))
1868 return 1;
1869 return 0;
1870}
1871
1872static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02001873{
1874 struct sigmatel_spec *spec = codec->spec;
1875 struct auto_pin_cfg *cfg = &spec->autocfg;
1876 int i, presence;
1877
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001878 presence = 0;
1879 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02001880 presence = get_pin_presence(codec, cfg->hp_pins[i]);
1881 if (presence)
1882 break;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001883 }
Matt4e550962005-07-04 17:51:39 +02001884
1885 if (presence) {
1886 /* disable lineouts, enable hp */
1887 for (i = 0; i < cfg->line_outs; i++)
1888 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
1889 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001890 for (i = 0; i < cfg->speaker_outs; i++)
1891 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
1892 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02001893 } else {
1894 /* enable lineouts, disable hp */
1895 for (i = 0; i < cfg->line_outs; i++)
1896 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
1897 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001898 for (i = 0; i < cfg->speaker_outs; i++)
1899 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
1900 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02001901 }
1902}
1903
Takashi Iwai314634b2006-09-21 11:56:18 +02001904static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
1905{
1906 switch (res >> 26) {
1907 case STAC_HP_EVENT:
1908 stac92xx_hp_detect(codec, res);
1909 break;
1910 }
1911}
1912
Mattff6fdc32005-06-27 15:06:52 +02001913#ifdef CONFIG_PM
1914static int stac92xx_resume(struct hda_codec *codec)
1915{
1916 struct sigmatel_spec *spec = codec->spec;
1917 int i;
1918
1919 stac92xx_init(codec);
Richard Fish11b44bb2006-08-23 18:31:34 +02001920 stac92xx_set_config_regs(codec);
Takashi Iwai5d403b12007-05-03 12:32:29 +02001921 snd_hda_resume_ctls(codec, spec->mixer);
Mattff6fdc32005-06-27 15:06:52 +02001922 for (i = 0; i < spec->num_mixers; i++)
1923 snd_hda_resume_ctls(codec, spec->mixers[i]);
1924 if (spec->multiout.dig_out_nid)
1925 snd_hda_resume_spdif_out(codec);
1926 if (spec->dig_in_nid)
1927 snd_hda_resume_spdif_in(codec);
1928
1929 return 0;
1930}
1931#endif
1932
Matt2f2f4252005-04-13 14:45:30 +02001933static struct hda_codec_ops stac92xx_patch_ops = {
1934 .build_controls = stac92xx_build_controls,
1935 .build_pcms = stac92xx_build_pcms,
1936 .init = stac92xx_init,
1937 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02001938 .unsol_event = stac92xx_unsol_event,
Mattff6fdc32005-06-27 15:06:52 +02001939#ifdef CONFIG_PM
1940 .resume = stac92xx_resume,
1941#endif
Matt2f2f4252005-04-13 14:45:30 +02001942};
1943
1944static int patch_stac9200(struct hda_codec *codec)
1945{
1946 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02001947 int err;
Matt2f2f4252005-04-13 14:45:30 +02001948
Takashi Iwaie560d8d2005-09-09 14:21:46 +02001949 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02001950 if (spec == NULL)
1951 return -ENOMEM;
1952
1953 codec->spec = spec;
Richard Fish11b44bb2006-08-23 18:31:34 +02001954 spec->num_pins = 8;
1955 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001956 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
1957 stac9200_models,
1958 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02001959 if (spec->board_config < 0) {
1960 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
1961 err = stac92xx_save_bios_config_regs(codec);
1962 if (err < 0) {
1963 stac92xx_free(codec);
1964 return err;
1965 }
1966 spec->pin_configs = spec->bios_pin_configs;
1967 } else {
Matt Porter403d1942005-11-29 15:00:51 +01001968 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
1969 stac92xx_set_config_regs(codec);
1970 }
Matt2f2f4252005-04-13 14:45:30 +02001971
1972 spec->multiout.max_channels = 2;
1973 spec->multiout.num_dacs = 1;
1974 spec->multiout.dac_nids = stac9200_dac_nids;
1975 spec->adc_nids = stac9200_adc_nids;
1976 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02001977 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02001978 spec->num_dmics = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02001979
1980 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02001981 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02001982
1983 err = stac9200_parse_auto_config(codec);
1984 if (err < 0) {
1985 stac92xx_free(codec);
1986 return err;
1987 }
Matt2f2f4252005-04-13 14:45:30 +02001988
1989 codec->patch_ops = stac92xx_patch_ops;
1990
1991 return 0;
1992}
1993
Tobin Davis8e21c342007-01-08 11:04:17 +01001994static int patch_stac925x(struct hda_codec *codec)
1995{
1996 struct sigmatel_spec *spec;
1997 int err;
1998
1999 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2000 if (spec == NULL)
2001 return -ENOMEM;
2002
2003 codec->spec = spec;
2004 spec->num_pins = 8;
2005 spec->pin_nids = stac925x_pin_nids;
2006 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
2007 stac925x_models,
2008 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002009 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01002010 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02002011 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
2012 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01002013 err = stac92xx_save_bios_config_regs(codec);
2014 if (err < 0) {
2015 stac92xx_free(codec);
2016 return err;
2017 }
2018 spec->pin_configs = spec->bios_pin_configs;
2019 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
2020 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
2021 stac92xx_set_config_regs(codec);
2022 }
2023
2024 spec->multiout.max_channels = 2;
2025 spec->multiout.num_dacs = 1;
2026 spec->multiout.dac_nids = stac925x_dac_nids;
2027 spec->adc_nids = stac925x_adc_nids;
2028 spec->mux_nids = stac925x_mux_nids;
2029 spec->num_muxes = 1;
Tobin Davis2c11f952007-05-17 09:36:34 +02002030 switch (codec->vendor_id) {
2031 case 0x83847632: /* STAC9202 */
2032 case 0x83847633: /* STAC9202D */
2033 case 0x83847636: /* STAC9251 */
2034 case 0x83847637: /* STAC9251D */
2035 spec->num_dmics = 1;
2036 spec->dmic_nids = stac925x_dmic_nids;
2037 break;
2038 default:
2039 spec->num_dmics = 0;
2040 break;
2041 }
Tobin Davis8e21c342007-01-08 11:04:17 +01002042
2043 spec->init = stac925x_core_init;
2044 spec->mixer = stac925x_mixer;
2045
2046 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002047 if (!err) {
2048 if (spec->board_config < 0) {
2049 printk(KERN_WARNING "hda_codec: No auto-config is "
2050 "available, default to model=ref\n");
2051 spec->board_config = STAC_925x_REF;
2052 goto again;
2053 }
2054 err = -EINVAL;
2055 }
Tobin Davis8e21c342007-01-08 11:04:17 +01002056 if (err < 0) {
2057 stac92xx_free(codec);
2058 return err;
2059 }
2060
2061 codec->patch_ops = stac92xx_patch_ops;
2062
2063 return 0;
2064}
2065
Matt2f2f4252005-04-13 14:45:30 +02002066static int patch_stac922x(struct hda_codec *codec)
2067{
2068 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002069 int err;
Matt2f2f4252005-04-13 14:45:30 +02002070
Takashi Iwaie560d8d2005-09-09 14:21:46 +02002071 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02002072 if (spec == NULL)
2073 return -ENOMEM;
2074
2075 codec->spec = spec;
Richard Fish11b44bb2006-08-23 18:31:34 +02002076 spec->num_pins = 10;
2077 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002078 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
2079 stac922x_models,
2080 stac922x_cfg_tbl);
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002081 if (spec->board_config == STAC_INTEL_MAC_V3) {
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002082 spec->gpio_mute = 1;
2083 /* Intel Macs have all same PCI SSID, so we need to check
2084 * codec SSID to distinguish the exact models
2085 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01002086 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002087 switch (codec->subsystem_id) {
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002088
2089 case 0x106b0800:
2090 spec->board_config = STAC_INTEL_MAC_V1;
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02002091 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002092 case 0x106b0600:
2093 case 0x106b0700:
2094 spec->board_config = STAC_INTEL_MAC_V2;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01002095 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002096 case 0x106b0e00:
2097 case 0x106b0f00:
2098 case 0x106b1600:
2099 case 0x106b1700:
2100 case 0x106b0200:
2101 case 0x106b1e00:
2102 spec->board_config = STAC_INTEL_MAC_V3;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002103 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002104 case 0x106b1a00:
2105 case 0x00000100:
2106 spec->board_config = STAC_INTEL_MAC_V4;
Sylvain FORETf16928f2007-04-27 14:22:36 +02002107 break;
Ivan N. Zlatev5d5d3bc2007-05-29 16:03:00 +02002108 case 0x106b0a00:
2109 case 0x106b2200:
2110 spec->board_config = STAC_INTEL_MAC_V5;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002111 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002112 }
2113 }
2114
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002115 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02002116 if (spec->board_config < 0) {
2117 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
2118 "using BIOS defaults\n");
2119 err = stac92xx_save_bios_config_regs(codec);
2120 if (err < 0) {
2121 stac92xx_free(codec);
2122 return err;
2123 }
2124 spec->pin_configs = spec->bios_pin_configs;
2125 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01002126 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
2127 stac92xx_set_config_regs(codec);
2128 }
Matt2f2f4252005-04-13 14:45:30 +02002129
Matt2f2f4252005-04-13 14:45:30 +02002130 spec->adc_nids = stac922x_adc_nids;
2131 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002132 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002133 spec->num_dmics = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002134
2135 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02002136 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02002137
2138 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02002139
Matt Porter3cc08dc2006-01-23 15:27:49 +01002140 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002141 if (!err) {
2142 if (spec->board_config < 0) {
2143 printk(KERN_WARNING "hda_codec: No auto-config is "
2144 "available, default to model=ref\n");
2145 spec->board_config = STAC_D945_REF;
2146 goto again;
2147 }
2148 err = -EINVAL;
2149 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01002150 if (err < 0) {
2151 stac92xx_free(codec);
2152 return err;
2153 }
2154
2155 codec->patch_ops = stac92xx_patch_ops;
2156
Takashi Iwai807a46362007-05-29 19:01:37 +02002157 /* Fix Mux capture level; max to 2 */
2158 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
2159 (0 << AC_AMPCAP_OFFSET_SHIFT) |
2160 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
2161 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2162 (0 << AC_AMPCAP_MUTE_SHIFT));
2163
Matt Porter3cc08dc2006-01-23 15:27:49 +01002164 return 0;
2165}
2166
2167static int patch_stac927x(struct hda_codec *codec)
2168{
2169 struct sigmatel_spec *spec;
2170 int err;
2171
2172 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2173 if (spec == NULL)
2174 return -ENOMEM;
2175
2176 codec->spec = spec;
Richard Fish11b44bb2006-08-23 18:31:34 +02002177 spec->num_pins = 14;
2178 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002179 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
2180 stac927x_models,
2181 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002182 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02002183 if (spec->board_config < 0) {
Matt Porter3cc08dc2006-01-23 15:27:49 +01002184 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02002185 err = stac92xx_save_bios_config_regs(codec);
2186 if (err < 0) {
2187 stac92xx_free(codec);
2188 return err;
2189 }
2190 spec->pin_configs = spec->bios_pin_configs;
2191 } else if (stac927x_brd_tbl[spec->board_config] != NULL) {
Matt Porter3cc08dc2006-01-23 15:27:49 +01002192 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
2193 stac92xx_set_config_regs(codec);
2194 }
2195
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002196 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02002197 case STAC_D965_3ST:
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002198 spec->adc_nids = stac927x_adc_nids;
2199 spec->mux_nids = stac927x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002200 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002201 spec->num_dmics = 0;
Tobin Davis93ed1502006-09-01 21:03:12 +02002202 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002203 spec->mixer = stac9227_mixer;
2204 break;
Tobin Davis93ed1502006-09-01 21:03:12 +02002205 case STAC_D965_5ST:
2206 spec->adc_nids = stac927x_adc_nids;
2207 spec->mux_nids = stac927x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002208 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002209 spec->num_dmics = 0;
Tobin Davis93ed1502006-09-01 21:03:12 +02002210 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002211 spec->mixer = stac9227_mixer;
2212 break;
2213 default:
2214 spec->adc_nids = stac927x_adc_nids;
2215 spec->mux_nids = stac927x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002216 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002217 spec->num_dmics = 0;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002218 spec->init = stac927x_core_init;
2219 spec->mixer = stac927x_mixer;
2220 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01002221
2222 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay92a22be2007-06-19 16:48:28 +02002223 stac92xx_enable_eapd(codec);
2224
Matt Porter3cc08dc2006-01-23 15:27:49 +01002225 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002226 if (!err) {
2227 if (spec->board_config < 0) {
2228 printk(KERN_WARNING "hda_codec: No auto-config is "
2229 "available, default to model=ref\n");
2230 spec->board_config = STAC_D965_REF;
2231 goto again;
2232 }
2233 err = -EINVAL;
2234 }
Mattc7d4b2f2005-06-27 14:59:41 +02002235 if (err < 0) {
2236 stac92xx_free(codec);
2237 return err;
2238 }
Matt2f2f4252005-04-13 14:45:30 +02002239
2240 codec->patch_ops = stac92xx_patch_ops;
2241
Takashi Iwai897cc182007-05-29 19:01:37 +02002242 /* Fix Mux capture level; max to 2 */
2243 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
2244 (0 << AC_AMPCAP_OFFSET_SHIFT) |
2245 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
2246 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2247 (0 << AC_AMPCAP_MUTE_SHIFT));
2248
Matt2f2f4252005-04-13 14:45:30 +02002249 return 0;
2250}
2251
Matt Porterf3302a52006-07-31 12:49:34 +02002252static int patch_stac9205(struct hda_codec *codec)
2253{
2254 struct sigmatel_spec *spec;
2255 int err;
2256
2257 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2258 if (spec == NULL)
2259 return -ENOMEM;
2260
2261 codec->spec = spec;
Richard Fish11b44bb2006-08-23 18:31:34 +02002262 spec->num_pins = 14;
2263 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002264 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
2265 stac9205_models,
2266 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002267 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02002268 if (spec->board_config < 0) {
2269 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
2270 err = stac92xx_save_bios_config_regs(codec);
2271 if (err < 0) {
2272 stac92xx_free(codec);
2273 return err;
2274 }
2275 spec->pin_configs = spec->bios_pin_configs;
2276 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02002277 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
2278 stac92xx_set_config_regs(codec);
2279 }
2280
2281 spec->adc_nids = stac9205_adc_nids;
2282 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002283 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002284 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002285 spec->num_dmics = ARRAY_SIZE(stac9205_dmic_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002286 spec->dmux_nid = 0x1d;
Matt Porterf3302a52006-07-31 12:49:34 +02002287
2288 spec->init = stac9205_core_init;
2289 spec->mixer = stac9205_mixer;
2290
2291 spec->multiout.dac_nids = spec->dac_nids;
Matthew Ranostay92a22be2007-06-19 16:48:28 +02002292 stac92xx_enable_eapd(codec);
Matt Porter33382402006-12-18 13:17:28 +01002293
Matt Porterf3302a52006-07-31 12:49:34 +02002294 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002295 if (!err) {
2296 if (spec->board_config < 0) {
2297 printk(KERN_WARNING "hda_codec: No auto-config is "
2298 "available, default to model=ref\n");
2299 spec->board_config = STAC_9205_REF;
2300 goto again;
2301 }
2302 err = -EINVAL;
2303 }
Matt Porterf3302a52006-07-31 12:49:34 +02002304 if (err < 0) {
2305 stac92xx_free(codec);
2306 return err;
2307 }
2308
2309 codec->patch_ops = stac92xx_patch_ops;
2310
2311 return 0;
2312}
2313
Matt2f2f4252005-04-13 14:45:30 +02002314/*
Guillaume Munch6d859062006-08-22 17:15:47 +02002315 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01002316 */
2317
Guillaume Munch99ccc562006-08-16 19:35:12 +02002318/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01002319static hda_nid_t vaio_dacs[] = { 0x2 };
2320#define VAIO_HP_DAC 0x5
2321static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
2322static hda_nid_t vaio_mux_nids[] = { 0x15 };
2323
2324static struct hda_input_mux vaio_mux = {
2325 .num_items = 2,
2326 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02002327 /* { "HP", 0x0 }, */
2328 { "Line", 0x1 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01002329 { "Mic", 0x2 },
2330 { "PCM", 0x3 },
2331 }
2332};
2333
2334static struct hda_verb vaio_init[] = {
2335 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
2336 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
2337 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
2338 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
2339 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
2340 {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
2341 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
2342 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
2343 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
2344 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
2345 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
2346 {}
2347};
2348
Guillaume Munch6d859062006-08-22 17:15:47 +02002349static struct hda_verb vaio_ar_init[] = {
2350 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
2351 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
2352 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
2353 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
2354/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
2355 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
2356 {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
2357 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
2358 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
2359/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
2360 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
2361 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
2362 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
2363 {}
2364};
2365
Takashi Iwaidb064e52006-03-16 16:04:58 +01002366/* bind volumes of both NID 0x02 and 0x05 */
2367static int vaio_master_vol_put(struct snd_kcontrol *kcontrol,
2368 struct snd_ctl_elem_value *ucontrol)
2369{
2370 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2371 long *valp = ucontrol->value.integer.value;
2372 int change;
2373
2374 change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
2375 0x7f, valp[0] & 0x7f);
2376 change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
2377 0x7f, valp[1] & 0x7f);
2378 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
2379 0x7f, valp[0] & 0x7f);
2380 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
2381 0x7f, valp[1] & 0x7f);
2382 return change;
2383}
2384
2385/* bind volumes of both NID 0x02 and 0x05 */
2386static int vaio_master_sw_put(struct snd_kcontrol *kcontrol,
2387 struct snd_ctl_elem_value *ucontrol)
2388{
2389 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2390 long *valp = ucontrol->value.integer.value;
2391 int change;
2392
2393 change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
Takashi Iwaia9393d72006-05-03 11:59:03 +02002394 0x80, (valp[0] ? 0 : 0x80));
Takashi Iwaidb064e52006-03-16 16:04:58 +01002395 change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
Takashi Iwaia9393d72006-05-03 11:59:03 +02002396 0x80, (valp[1] ? 0 : 0x80));
Takashi Iwaidb064e52006-03-16 16:04:58 +01002397 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
Takashi Iwaia9393d72006-05-03 11:59:03 +02002398 0x80, (valp[0] ? 0 : 0x80));
Takashi Iwaidb064e52006-03-16 16:04:58 +01002399 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
Takashi Iwaia9393d72006-05-03 11:59:03 +02002400 0x80, (valp[1] ? 0 : 0x80));
Takashi Iwaidb064e52006-03-16 16:04:58 +01002401 return change;
2402}
2403
2404static struct snd_kcontrol_new vaio_mixer[] = {
2405 {
2406 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2407 .name = "Master Playback Volume",
2408 .info = snd_hda_mixer_amp_volume_info,
2409 .get = snd_hda_mixer_amp_volume_get,
2410 .put = vaio_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02002411 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwaidb064e52006-03-16 16:04:58 +01002412 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2413 },
2414 {
2415 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2416 .name = "Master Playback Switch",
2417 .info = snd_hda_mixer_amp_switch_info,
2418 .get = snd_hda_mixer_amp_switch_get,
2419 .put = vaio_master_sw_put,
2420 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2421 },
2422 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2423 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
2424 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
2425 {
2426 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2427 .name = "Capture Source",
2428 .count = 1,
2429 .info = stac92xx_mux_enum_info,
2430 .get = stac92xx_mux_enum_get,
2431 .put = stac92xx_mux_enum_put,
2432 },
2433 {}
2434};
2435
Guillaume Munch6d859062006-08-22 17:15:47 +02002436static struct snd_kcontrol_new vaio_ar_mixer[] = {
2437 {
2438 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2439 .name = "Master Playback Volume",
2440 .info = snd_hda_mixer_amp_volume_info,
2441 .get = snd_hda_mixer_amp_volume_get,
2442 .put = vaio_master_vol_put,
2443 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2444 },
2445 {
2446 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2447 .name = "Master Playback Switch",
2448 .info = snd_hda_mixer_amp_switch_info,
2449 .get = snd_hda_mixer_amp_switch_get,
2450 .put = vaio_master_sw_put,
2451 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2452 },
2453 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2454 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
2455 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
2456 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
2457 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
2458 {
2459 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2460 .name = "Capture Source",
2461 .count = 1,
2462 .info = stac92xx_mux_enum_info,
2463 .get = stac92xx_mux_enum_get,
2464 .put = stac92xx_mux_enum_put,
2465 },
2466 {}
2467};
2468
2469static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01002470 .build_controls = stac92xx_build_controls,
2471 .build_pcms = stac92xx_build_pcms,
2472 .init = stac92xx_init,
2473 .free = stac92xx_free,
2474#ifdef CONFIG_PM
2475 .resume = stac92xx_resume,
2476#endif
2477};
2478
Guillaume Munch6d859062006-08-22 17:15:47 +02002479enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
2480 CXD9872RD_VAIO,
2481 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
2482 STAC9872AK_VAIO,
2483 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
2484 STAC9872K_VAIO,
2485 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002486 CXD9872AKD_VAIO,
2487 STAC_9872_MODELS,
2488};
Takashi Iwaidb064e52006-03-16 16:04:58 +01002489
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002490static const char *stac9872_models[STAC_9872_MODELS] = {
2491 [CXD9872RD_VAIO] = "vaio",
2492 [CXD9872AKD_VAIO] = "vaio-ar",
2493};
2494
2495static struct snd_pci_quirk stac9872_cfg_tbl[] = {
2496 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
2497 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
2498 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01002499 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01002500 {}
2501};
2502
Guillaume Munch6d859062006-08-22 17:15:47 +02002503static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01002504{
2505 struct sigmatel_spec *spec;
2506 int board_config;
2507
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002508 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
2509 stac9872_models,
2510 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01002511 if (board_config < 0)
2512 /* unknown config, let generic-parser do its job... */
2513 return snd_hda_parse_generic_codec(codec);
2514
2515 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2516 if (spec == NULL)
2517 return -ENOMEM;
2518
2519 codec->spec = spec;
2520 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02002521 case CXD9872RD_VAIO:
2522 case STAC9872AK_VAIO:
2523 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01002524 spec->mixer = vaio_mixer;
2525 spec->init = vaio_init;
2526 spec->multiout.max_channels = 2;
2527 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
2528 spec->multiout.dac_nids = vaio_dacs;
2529 spec->multiout.hp_nid = VAIO_HP_DAC;
2530 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
2531 spec->adc_nids = vaio_adcs;
2532 spec->input_mux = &vaio_mux;
2533 spec->mux_nids = vaio_mux_nids;
2534 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02002535
2536 case CXD9872AKD_VAIO:
2537 spec->mixer = vaio_ar_mixer;
2538 spec->init = vaio_ar_init;
2539 spec->multiout.max_channels = 2;
2540 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
2541 spec->multiout.dac_nids = vaio_dacs;
2542 spec->multiout.hp_nid = VAIO_HP_DAC;
2543 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
2544 spec->adc_nids = vaio_adcs;
2545 spec->input_mux = &vaio_mux;
2546 spec->mux_nids = vaio_mux_nids;
2547 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01002548 }
2549
Guillaume Munch6d859062006-08-22 17:15:47 +02002550 codec->patch_ops = stac9872_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01002551 return 0;
2552}
2553
2554
2555/*
Matt2f2f4252005-04-13 14:45:30 +02002556 * patch entries
2557 */
2558struct hda_codec_preset snd_hda_preset_sigmatel[] = {
2559 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
2560 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
2561 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
2562 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
2563 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
2564 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
2565 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02002566 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
2567 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
2568 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
2569 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
2570 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
2571 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01002572 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
2573 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
2574 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
2575 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
2576 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
2577 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
2578 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
2579 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
2580 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
2581 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01002582 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
2583 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
2584 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
2585 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
2586 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
2587 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Guillaume Munch6d859062006-08-22 17:15:47 +02002588 /* The following does not take into account .id=0x83847661 when subsys =
2589 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
2590 * currently not fully supported.
2591 */
2592 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
2593 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
2594 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02002595 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
2596 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
2597 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
2598 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
2599 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
2600 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
2601 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
2602 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matt2f2f4252005-04-13 14:45:30 +02002603 {} /* terminator */
2604};