blob: 3653f57b7f69861166656e689d6b8f50cb6f741c [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,
62 STAC_MACMINI,
Takashi Iwai3fc24d82007-02-16 13:27:18 +010063 STAC_MACBOOK,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +010064 STAC_MACBOOK_PRO_V1,
65 STAC_MACBOOK_PRO_V2,
Sylvain FORETf16928f2007-04-27 14:22:36 +020066 STAC_IMAC_INTEL,
Takashi Iwai0dae0f82007-05-21 12:41:29 +020067 STAC_IMAC_INTEL_20,
Takashi Iwaif5fcc132006-11-24 17:07:44 +010068 STAC_922X_MODELS
69};
70
71enum {
72 STAC_D965_REF,
73 STAC_D965_3ST,
74 STAC_D965_5ST,
75 STAC_927X_MODELS
76};
Matt Porter403d1942005-11-29 15:00:51 +010077
Matt2f2f4252005-04-13 14:45:30 +020078struct sigmatel_spec {
Takashi Iwaic8b6bf92005-11-17 14:57:47 +010079 struct snd_kcontrol_new *mixers[4];
Mattc7d4b2f2005-06-27 14:59:41 +020080 unsigned int num_mixers;
81
Matt Porter403d1942005-11-29 15:00:51 +010082 int board_config;
Mattc7d4b2f2005-06-27 14:59:41 +020083 unsigned int surr_switch: 1;
Matt Porter403d1942005-11-29 15:00:51 +010084 unsigned int line_switch: 1;
85 unsigned int mic_switch: 1;
Matt Porter3cc08dc2006-01-23 15:27:49 +010086 unsigned int alt_switch: 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +010087 unsigned int hp_detect: 1;
Sam Revitch62fe78e2006-05-10 15:09:17 +020088 unsigned int gpio_mute: 1;
Mattc7d4b2f2005-06-27 14:59:41 +020089
Matt2f2f4252005-04-13 14:45:30 +020090 /* playback */
91 struct hda_multi_out multiout;
Matt Porter3cc08dc2006-01-23 15:27:49 +010092 hda_nid_t dac_nids[5];
Matt2f2f4252005-04-13 14:45:30 +020093
94 /* capture */
95 hda_nid_t *adc_nids;
Matt2f2f4252005-04-13 14:45:30 +020096 unsigned int num_adcs;
Mattdabbed62005-06-14 10:19:34 +020097 hda_nid_t *mux_nids;
98 unsigned int num_muxes;
Matt Porter8b657272006-10-26 17:12:59 +020099 hda_nid_t *dmic_nids;
100 unsigned int num_dmics;
101 hda_nid_t dmux_nid;
Mattdabbed62005-06-14 10:19:34 +0200102 hda_nid_t dig_in_nid;
Matt2f2f4252005-04-13 14:45:30 +0200103
Matt2f2f4252005-04-13 14:45:30 +0200104 /* pin widgets */
105 hda_nid_t *pin_nids;
106 unsigned int num_pins;
Matt2f2f4252005-04-13 14:45:30 +0200107 unsigned int *pin_configs;
Richard Fish11b44bb2006-08-23 18:31:34 +0200108 unsigned int *bios_pin_configs;
Matt2f2f4252005-04-13 14:45:30 +0200109
110 /* codec specific stuff */
111 struct hda_verb *init;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100112 struct snd_kcontrol_new *mixer;
Matt2f2f4252005-04-13 14:45:30 +0200113
114 /* capture source */
Matt Porter8b657272006-10-26 17:12:59 +0200115 struct hda_input_mux *dinput_mux;
116 unsigned int cur_dmux;
Mattc7d4b2f2005-06-27 14:59:41 +0200117 struct hda_input_mux *input_mux;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100118 unsigned int cur_mux[3];
Matt2f2f4252005-04-13 14:45:30 +0200119
Matt Porter403d1942005-11-29 15:00:51 +0100120 /* i/o switches */
121 unsigned int io_switch[2];
Matt2f2f4252005-04-13 14:45:30 +0200122
Mattc7d4b2f2005-06-27 14:59:41 +0200123 struct hda_pcm pcm_rec[2]; /* PCM information */
124
125 /* dynamic controls and input_mux */
126 struct auto_pin_cfg autocfg;
127 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100128 struct snd_kcontrol_new *kctl_alloc;
Matt Porter8b657272006-10-26 17:12:59 +0200129 struct hda_input_mux private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +0200130 struct hda_input_mux private_imux;
Matt2f2f4252005-04-13 14:45:30 +0200131};
132
133static hda_nid_t stac9200_adc_nids[1] = {
134 0x03,
135};
136
137static hda_nid_t stac9200_mux_nids[1] = {
138 0x0c,
139};
140
141static hda_nid_t stac9200_dac_nids[1] = {
142 0x02,
143};
144
Tobin Davis8e21c342007-01-08 11:04:17 +0100145static hda_nid_t stac925x_adc_nids[1] = {
146 0x03,
147};
148
149static hda_nid_t stac925x_mux_nids[1] = {
150 0x0f,
151};
152
153static hda_nid_t stac925x_dac_nids[1] = {
154 0x02,
155};
156
Tobin Davis2c11f952007-05-17 09:36:34 +0200157static hda_nid_t stac925x_dmic_nids[1] = {
158 0x15,
159};
160
Matt2f2f4252005-04-13 14:45:30 +0200161static hda_nid_t stac922x_adc_nids[2] = {
162 0x06, 0x07,
163};
164
165static hda_nid_t stac922x_mux_nids[2] = {
166 0x12, 0x13,
167};
168
Matt Porter3cc08dc2006-01-23 15:27:49 +0100169static hda_nid_t stac927x_adc_nids[3] = {
170 0x07, 0x08, 0x09
171};
172
173static hda_nid_t stac927x_mux_nids[3] = {
174 0x15, 0x16, 0x17
175};
176
Matt Porterf3302a52006-07-31 12:49:34 +0200177static hda_nid_t stac9205_adc_nids[2] = {
178 0x12, 0x13
179};
180
181static hda_nid_t stac9205_mux_nids[2] = {
182 0x19, 0x1a
183};
184
Takashi Iwai25494132007-03-12 12:36:16 +0100185static hda_nid_t stac9205_dmic_nids[2] = {
186 0x17, 0x18,
Matt Porter8b657272006-10-26 17:12:59 +0200187};
188
Mattc7d4b2f2005-06-27 14:59:41 +0200189static hda_nid_t stac9200_pin_nids[8] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200190 0x08, 0x09, 0x0d, 0x0e,
191 0x0f, 0x10, 0x11, 0x12,
Matt2f2f4252005-04-13 14:45:30 +0200192};
193
Tobin Davis8e21c342007-01-08 11:04:17 +0100194static hda_nid_t stac925x_pin_nids[8] = {
195 0x07, 0x08, 0x0a, 0x0b,
196 0x0c, 0x0d, 0x10, 0x11,
197};
198
Matt2f2f4252005-04-13 14:45:30 +0200199static hda_nid_t stac922x_pin_nids[10] = {
200 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
201 0x0f, 0x10, 0x11, 0x15, 0x1b,
202};
203
Matt Porter3cc08dc2006-01-23 15:27:49 +0100204static hda_nid_t stac927x_pin_nids[14] = {
205 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
206 0x0f, 0x10, 0x11, 0x12, 0x13,
207 0x14, 0x21, 0x22, 0x23,
208};
209
Matt Porterf3302a52006-07-31 12:49:34 +0200210static hda_nid_t stac9205_pin_nids[12] = {
211 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
212 0x0f, 0x14, 0x16, 0x17, 0x18,
213 0x21, 0x22,
214
215};
216
Matt Porter8b657272006-10-26 17:12:59 +0200217static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
218 struct snd_ctl_elem_info *uinfo)
219{
220 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
221 struct sigmatel_spec *spec = codec->spec;
222 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
223}
224
225static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
226 struct snd_ctl_elem_value *ucontrol)
227{
228 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
229 struct sigmatel_spec *spec = codec->spec;
230
231 ucontrol->value.enumerated.item[0] = spec->cur_dmux;
232 return 0;
233}
234
235static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
236 struct snd_ctl_elem_value *ucontrol)
237{
238 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
239 struct sigmatel_spec *spec = codec->spec;
240
241 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
242 spec->dmux_nid, &spec->cur_dmux);
243}
244
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100245static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Matt2f2f4252005-04-13 14:45:30 +0200246{
247 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
248 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +0200249 return snd_hda_input_mux_info(spec->input_mux, uinfo);
Matt2f2f4252005-04-13 14:45:30 +0200250}
251
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100252static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200253{
254 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
255 struct sigmatel_spec *spec = codec->spec;
256 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
257
258 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
259 return 0;
260}
261
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100262static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Matt2f2f4252005-04-13 14:45:30 +0200263{
264 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
265 struct sigmatel_spec *spec = codec->spec;
266 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
267
Mattc7d4b2f2005-06-27 14:59:41 +0200268 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
Matt2f2f4252005-04-13 14:45:30 +0200269 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
270}
271
Mattc7d4b2f2005-06-27 14:59:41 +0200272static struct hda_verb stac9200_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200273 /* set dac0mux for dac converter */
Mattc7d4b2f2005-06-27 14:59:41 +0200274 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Matt2f2f4252005-04-13 14:45:30 +0200275 {}
276};
277
Tobin Davis8e21c342007-01-08 11:04:17 +0100278static struct hda_verb stac925x_core_init[] = {
279 /* set dac0mux for dac converter */
280 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
281 {}
282};
283
Mattc7d4b2f2005-06-27 14:59:41 +0200284static struct hda_verb stac922x_core_init[] = {
Matt2f2f4252005-04-13 14:45:30 +0200285 /* set master volume and direct control */
Mattc7d4b2f2005-06-27 14:59:41 +0200286 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Matt2f2f4252005-04-13 14:45:30 +0200287 {}
288};
289
Tobin Davis93ed1502006-09-01 21:03:12 +0200290static struct hda_verb d965_core_init[] = {
Takashi Iwai19039bd2006-06-28 15:52:16 +0200291 /* set master volume and direct control */
Tobin Davis93ed1502006-09-01 21:03:12 +0200292 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
Takashi Iwai19039bd2006-06-28 15:52:16 +0200293 /* unmute node 0x1b */
294 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
295 /* select node 0x03 as DAC */
296 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
297 {}
298};
299
Matt Porter3cc08dc2006-01-23 15:27:49 +0100300static struct hda_verb stac927x_core_init[] = {
301 /* set master volume and direct control */
302 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
303 {}
304};
305
Matt Porterf3302a52006-07-31 12:49:34 +0200306static struct hda_verb stac9205_core_init[] = {
307 /* set master volume and direct control */
308 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
309 {}
310};
311
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100312static struct snd_kcontrol_new stac9200_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200313 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
314 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
315 {
316 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
317 .name = "Input Source",
318 .count = 1,
319 .info = stac92xx_mux_enum_info,
320 .get = stac92xx_mux_enum_get,
321 .put = stac92xx_mux_enum_put,
322 },
323 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
324 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
Mattc7d4b2f2005-06-27 14:59:41 +0200325 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
Matt2f2f4252005-04-13 14:45:30 +0200326 { } /* end */
327};
328
Tobin Davis8e21c342007-01-08 11:04:17 +0100329static struct snd_kcontrol_new stac925x_mixer[] = {
330 HDA_CODEC_VOLUME("Master Playback Volume", 0xe, 0, HDA_OUTPUT),
331 HDA_CODEC_MUTE("Master Playback Switch", 0xe, 0, HDA_OUTPUT),
332 {
333 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
334 .name = "Input Source",
335 .count = 1,
336 .info = stac92xx_mux_enum_info,
337 .get = stac92xx_mux_enum_get,
338 .put = stac92xx_mux_enum_put,
339 },
340 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
341 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT),
342 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
343 { } /* end */
344};
345
Mattc7d4b2f2005-06-27 14:59:41 +0200346/* This needs to be generated dynamically based on sequence */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100347static struct snd_kcontrol_new stac922x_mixer[] = {
Matt2f2f4252005-04-13 14:45:30 +0200348 {
349 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
350 .name = "Input Source",
351 .count = 1,
352 .info = stac92xx_mux_enum_info,
353 .get = stac92xx_mux_enum_get,
354 .put = stac92xx_mux_enum_put,
355 },
356 HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT),
Takashi Iwai0fd17082006-01-13 18:46:21 +0100357 HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT),
Matt2f2f4252005-04-13 14:45:30 +0200358 HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT),
359 { } /* end */
360};
361
Takashi Iwai19039bd2006-06-28 15:52:16 +0200362/* This needs to be generated dynamically based on sequence */
363static struct snd_kcontrol_new stac9227_mixer[] = {
364 {
365 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
366 .name = "Input Source",
367 .count = 1,
368 .info = stac92xx_mux_enum_info,
369 .get = stac92xx_mux_enum_get,
370 .put = stac92xx_mux_enum_put,
371 },
372 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
373 HDA_CODEC_MUTE("Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
374 { } /* end */
375};
376
Takashi Iwaid1d985f2006-11-23 19:27:12 +0100377static struct snd_kcontrol_new stac927x_mixer[] = {
Matt Porter3cc08dc2006-01-23 15:27:49 +0100378 {
379 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
380 .name = "Input Source",
381 .count = 1,
382 .info = stac92xx_mux_enum_info,
383 .get = stac92xx_mux_enum_get,
384 .put = stac92xx_mux_enum_put,
385 },
386 HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT),
387 HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT),
388 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
389 { } /* end */
390};
391
Takashi Iwaid1d985f2006-11-23 19:27:12 +0100392static struct snd_kcontrol_new stac9205_mixer[] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200393 {
394 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matt Porter8b657272006-10-26 17:12:59 +0200395 .name = "Digital Input Source",
396 .count = 1,
397 .info = stac92xx_dmux_enum_info,
398 .get = stac92xx_dmux_enum_get,
399 .put = stac92xx_dmux_enum_put,
400 },
401 {
402 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Matt Porterf3302a52006-07-31 12:49:34 +0200403 .name = "Input Source",
404 .count = 1,
405 .info = stac92xx_mux_enum_info,
406 .get = stac92xx_mux_enum_get,
407 .put = stac92xx_mux_enum_put,
408 },
409 HDA_CODEC_VOLUME("InMux Capture Volume", 0x19, 0x0, HDA_OUTPUT),
410 HDA_CODEC_VOLUME("InVol Capture Volume", 0x1b, 0x0, HDA_INPUT),
411 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1d, 0x0, HDA_OUTPUT),
412 { } /* end */
413};
414
Matt2f2f4252005-04-13 14:45:30 +0200415static int stac92xx_build_controls(struct hda_codec *codec)
416{
417 struct sigmatel_spec *spec = codec->spec;
418 int err;
Mattc7d4b2f2005-06-27 14:59:41 +0200419 int i;
Matt2f2f4252005-04-13 14:45:30 +0200420
421 err = snd_hda_add_new_ctls(codec, spec->mixer);
422 if (err < 0)
423 return err;
Mattc7d4b2f2005-06-27 14:59:41 +0200424
425 for (i = 0; i < spec->num_mixers; i++) {
426 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
427 if (err < 0)
428 return err;
429 }
430
Mattdabbed62005-06-14 10:19:34 +0200431 if (spec->multiout.dig_out_nid) {
432 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
433 if (err < 0)
434 return err;
435 }
436 if (spec->dig_in_nid) {
437 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
438 if (err < 0)
439 return err;
440 }
441 return 0;
Matt2f2f4252005-04-13 14:45:30 +0200442}
443
Matt Porter403d1942005-11-29 15:00:51 +0100444static unsigned int ref9200_pin_configs[8] = {
Mattdabbed62005-06-14 10:19:34 +0200445 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
Matt2f2f4252005-04-13 14:45:30 +0200446 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
447};
448
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100449static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
450 [STAC_REF] = ref9200_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +0100451};
452
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100453static const char *stac9200_models[STAC_9200_MODELS] = {
454 [STAC_REF] = "ref",
455};
456
457static struct snd_pci_quirk stac9200_cfg_tbl[] = {
458 /* SigmaTel reference board */
459 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
460 "DFI LanParty", STAC_REF),
Matt Portere7377072006-11-06 11:20:38 +0100461 /* Dell laptops have BIOS problem */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100462 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
463 "Dell Inspiron 630m", STAC_REF),
464 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
465 "Dell Latitude D620", STAC_REF),
466 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
467 "Dell Latitude 120L", STAC_REF),
Cory T. Tusar877b8662007-01-30 17:30:55 +0100468 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
469 "Dell Latitude D820", STAC_REF),
Mikael Nilsson46f02ca2007-02-13 12:46:16 +0100470 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
471 "Dell Inspiron E1705/9400", STAC_REF),
472 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
473 "Dell XPS M1710", STAC_REF),
Takashi Iwaif0f96742007-02-14 00:59:17 +0100474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
475 "Dell Precision M90", STAC_REF),
Daniel T Chen8286c532007-05-15 11:46:23 +0200476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
477 "unknown Dell", STAC_REF),
Tobin Davis49c605d2007-05-17 09:38:24 +0200478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
479 "Dell Inspiron 640m", STAC_REF),
480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
481 "Dell Inspiron 1501", STAC_REF),
482
483 /* Panasonic */
484 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF),
485
Matt Porter403d1942005-11-29 15:00:51 +0100486 {} /* terminator */
487};
488
Tobin Davis8e21c342007-01-08 11:04:17 +0100489static unsigned int ref925x_pin_configs[8] = {
490 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
491 0x90a70320, 0x02214210, 0x400003f1, 0x9033032e,
492};
493
494static unsigned int stac925x_MA6_pin_configs[8] = {
495 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
496 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
497};
498
Tobin Davis2c11f952007-05-17 09:36:34 +0200499static unsigned int stac925x_PA6_pin_configs[8] = {
500 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
501 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
502};
503
Tobin Davis8e21c342007-01-08 11:04:17 +0100504static unsigned int stac925xM2_2_pin_configs[8] = {
Steve Longerbeam7353e142007-05-29 14:36:17 +0200505 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
506 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
Tobin Davis8e21c342007-01-08 11:04:17 +0100507};
508
509static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
510 [STAC_REF] = ref925x_pin_configs,
511 [STAC_M2_2] = stac925xM2_2_pin_configs,
512 [STAC_MA6] = stac925x_MA6_pin_configs,
Tobin Davis2c11f952007-05-17 09:36:34 +0200513 [STAC_PA6] = stac925x_PA6_pin_configs,
Tobin Davis8e21c342007-01-08 11:04:17 +0100514};
515
516static const char *stac925x_models[STAC_925x_MODELS] = {
517 [STAC_REF] = "ref",
518 [STAC_M2_2] = "m2-2",
519 [STAC_MA6] = "m6",
Tobin Davis2c11f952007-05-17 09:36:34 +0200520 [STAC_PA6] = "pa6",
Tobin Davis8e21c342007-01-08 11:04:17 +0100521};
522
523static struct snd_pci_quirk stac925x_cfg_tbl[] = {
524 /* SigmaTel reference board */
525 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
Tobin Davis2c11f952007-05-17 09:36:34 +0200526 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
Tobin Davis8e21c342007-01-08 11:04:17 +0100527 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
528 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
529 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
Tobin Davis2c11f952007-05-17 09:36:34 +0200530 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
Tobin Davis8e21c342007-01-08 11:04:17 +0100531 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
532 {} /* terminator */
533};
534
Matt Porter403d1942005-11-29 15:00:51 +0100535static unsigned int ref922x_pin_configs[10] = {
536 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
537 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
Matt2f2f4252005-04-13 14:45:30 +0200538 0x40000100, 0x40000100,
539};
540
Matt Porter403d1942005-11-29 15:00:51 +0100541static unsigned int d945gtp3_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +0100542 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
Matt Porter403d1942005-11-29 15:00:51 +0100543 0x40000100, 0x40000100, 0x40000100, 0x40000100,
544 0x02a19120, 0x40000100,
545};
546
547static unsigned int d945gtp5_pin_configs[10] = {
Matt Porter869264c2006-01-25 19:20:50 +0100548 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
549 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
Matt Porter403d1942005-11-29 15:00:51 +0100550 0x02a19320, 0x40000100,
551};
552
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100553static unsigned int macbook_pro_v1_pin_configs[10] = {
554 0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010,
555 0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e,
556 0x02a19320, 0x400000fb
557};
558
559static unsigned int macbook_pro_v2_pin_configs[10] = {
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100560 0x0221401f, 0x90a70120, 0x01813024, 0x01014010,
561 0x400000fd, 0x01016011, 0x1345e240, 0x13c5e22e,
562 0x400000fc, 0x400000fb,
563};
564
Sylvain FORETf16928f2007-04-27 14:22:36 +0200565static unsigned int imac_intel_pin_configs[10] = {
566 0x0121e230, 0x90a70120, 0x9017e110, 0x400000fe,
567 0x400000fd, 0x0181e021, 0x1145e040, 0x400000fa,
568 0x400000fc, 0x400000fb,
569};
570
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200571static unsigned int imac_intel_20_pin_configs[10] = {
572 0x0121E21F, 0x90A7012E, 0x9017E110, 0x400000FD,
573 0x400000FE, 0x0181E020, 0x1145E230, 0x11C5E240,
574 0x400000FC, 0x400000FB,
575};
576
Takashi Iwai19039bd2006-06-28 15:52:16 +0200577static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100578 [STAC_D945_REF] = ref922x_pin_configs,
Takashi Iwai19039bd2006-06-28 15:52:16 +0200579 [STAC_D945GTP3] = d945gtp3_pin_configs,
580 [STAC_D945GTP5] = d945gtp5_pin_configs,
Takashi Iwai02a50392007-03-19 11:42:18 +0100581 [STAC_MACMINI] = macbook_pro_v1_pin_configs,
582 [STAC_MACBOOK] = macbook_pro_v1_pin_configs,
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100583 [STAC_MACBOOK_PRO_V1] = macbook_pro_v1_pin_configs,
584 [STAC_MACBOOK_PRO_V2] = macbook_pro_v2_pin_configs,
Sylvain FORETf16928f2007-04-27 14:22:36 +0200585 [STAC_IMAC_INTEL] = imac_intel_pin_configs,
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200586 [STAC_IMAC_INTEL_20] = imac_intel_20_pin_configs,
Matt Porter403d1942005-11-29 15:00:51 +0100587};
588
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100589static const char *stac922x_models[STAC_922X_MODELS] = {
590 [STAC_D945_REF] = "ref",
591 [STAC_D945GTP5] = "5stack",
592 [STAC_D945GTP3] = "3stack",
593 [STAC_MACMINI] = "macmini",
Takashi Iwai3fc24d82007-02-16 13:27:18 +0100594 [STAC_MACBOOK] = "macbook",
Nicolas Boichat6f0778d2007-03-15 12:38:15 +0100595 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
596 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
Sylvain FORETf16928f2007-04-27 14:22:36 +0200597 [STAC_IMAC_INTEL] = "imac-intel",
Takashi Iwai0dae0f82007-05-21 12:41:29 +0200598 [STAC_IMAC_INTEL_20] = "imac-intel-20",
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100599};
600
601static struct snd_pci_quirk stac922x_cfg_tbl[] = {
602 /* SigmaTel reference board */
603 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
604 "DFI LanParty", STAC_D945_REF),
605 /* Intel 945G based systems */
606 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
607 "Intel D945G", STAC_D945GTP3),
608 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
609 "Intel D945G", STAC_D945GTP3),
610 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
611 "Intel D945G", STAC_D945GTP3),
612 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
613 "Intel D945G", STAC_D945GTP3),
614 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
615 "Intel D945G", STAC_D945GTP3),
616 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
617 "Intel D945G", STAC_D945GTP3),
618 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
619 "Intel D945G", STAC_D945GTP3),
620 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
621 "Intel D945G", STAC_D945GTP3),
622 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
623 "Intel D945G", STAC_D945GTP3),
624 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
625 "Intel D945G", STAC_D945GTP3),
626 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
627 "Intel D945G", STAC_D945GTP3),
628 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
629 "Intel D945G", STAC_D945GTP3),
630 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
631 "Intel D945G", STAC_D945GTP3),
632 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
633 "Intel D945G", STAC_D945GTP3),
634 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
635 "Intel D945G", STAC_D945GTP3),
636 /* Intel D945G 5-stack systems */
637 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
638 "Intel D945G", STAC_D945GTP5),
639 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
640 "Intel D945G", STAC_D945GTP5),
641 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
642 "Intel D945G", STAC_D945GTP5),
643 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
644 "Intel D945G", STAC_D945GTP5),
645 /* Intel 945P based systems */
646 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
647 "Intel D945P", STAC_D945GTP3),
648 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
649 "Intel D945P", STAC_D945GTP3),
650 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
651 "Intel D945P", STAC_D945GTP3),
652 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
653 "Intel D945P", STAC_D945GTP3),
654 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
655 "Intel D945P", STAC_D945GTP3),
656 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
657 "Intel D945P", STAC_D945GTP5),
658 /* other systems */
659 /* Apple Mac Mini (early 2006) */
660 SND_PCI_QUIRK(0x8384, 0x7680,
661 "Mac Mini", STAC_MACMINI),
Matt Porter403d1942005-11-29 15:00:51 +0100662 {} /* terminator */
663};
664
Matt Porter3cc08dc2006-01-23 15:27:49 +0100665static unsigned int ref927x_pin_configs[14] = {
Tobin Davis93ed1502006-09-01 21:03:12 +0200666 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
667 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
668 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
669 0x01c42190, 0x40000100,
Matt Porter3cc08dc2006-01-23 15:27:49 +0100670};
671
Tobin Davis93ed1502006-09-01 21:03:12 +0200672static unsigned int d965_3st_pin_configs[14] = {
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200673 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
674 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
675 0x40000100, 0x40000100, 0x40000100, 0x40000100,
676 0x40000100, 0x40000100
677};
678
Tobin Davis93ed1502006-09-01 21:03:12 +0200679static unsigned int d965_5st_pin_configs[14] = {
680 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
681 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
682 0x40000100, 0x40000100, 0x40000100, 0x01442070,
683 0x40000100, 0x40000100
684};
685
686static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100687 [STAC_D965_REF] = ref927x_pin_configs,
Tobin Davis93ed1502006-09-01 21:03:12 +0200688 [STAC_D965_3ST] = d965_3st_pin_configs,
689 [STAC_D965_5ST] = d965_5st_pin_configs,
Matt Porter3cc08dc2006-01-23 15:27:49 +0100690};
691
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100692static const char *stac927x_models[STAC_927X_MODELS] = {
693 [STAC_D965_REF] = "ref",
694 [STAC_D965_3ST] = "3stack",
695 [STAC_D965_5ST] = "5stack",
696};
697
698static struct snd_pci_quirk stac927x_cfg_tbl[] = {
699 /* SigmaTel reference board */
700 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
701 "DFI LanParty", STAC_D965_REF),
Tobin Davis81d3dbd2006-08-22 19:44:45 +0200702 /* Intel 946 based systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100703 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
704 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +0200705 /* 965 based 3 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100706 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
707 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
708 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
709 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
710 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
711 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
712 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
713 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
714 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
715 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
716 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
717 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
718 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
719 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
720 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
721 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
Tobin Davis93ed1502006-09-01 21:03:12 +0200722 /* 965 based 5 stack systems */
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100723 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
724 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
725 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
726 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
727 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
728 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
729 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
730 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
731 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
Matt Porter3cc08dc2006-01-23 15:27:49 +0100732 {} /* terminator */
733};
734
Matt Porterf3302a52006-07-31 12:49:34 +0200735static unsigned int ref9205_pin_configs[12] = {
736 0x40000100, 0x40000100, 0x01016011, 0x01014010,
Matt Porter8b657272006-10-26 17:12:59 +0200737 0x01813122, 0x01a19021, 0x40000100, 0x40000100,
738 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
Matt Porterf3302a52006-07-31 12:49:34 +0200739};
740
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100741static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
Matt Porterf3302a52006-07-31 12:49:34 +0200742 ref9205_pin_configs,
743};
744
Takashi Iwaif5fcc132006-11-24 17:07:44 +0100745static const char *stac9205_models[STAC_9205_MODELS] = {
746 [STAC_9205_REF] = "ref",
747};
748
749static struct snd_pci_quirk stac9205_cfg_tbl[] = {
750 /* SigmaTel reference board */
751 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
752 "DFI LanParty", STAC_9205_REF),
Matt Porterf3302a52006-07-31 12:49:34 +0200753 {} /* terminator */
754};
755
Richard Fish11b44bb2006-08-23 18:31:34 +0200756static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
757{
758 int i;
759 struct sigmatel_spec *spec = codec->spec;
760
761 if (! spec->bios_pin_configs) {
762 spec->bios_pin_configs = kcalloc(spec->num_pins,
763 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
764 if (! spec->bios_pin_configs)
765 return -ENOMEM;
766 }
767
768 for (i = 0; i < spec->num_pins; i++) {
769 hda_nid_t nid = spec->pin_nids[i];
770 unsigned int pin_cfg;
771
772 pin_cfg = snd_hda_codec_read(codec, nid, 0,
773 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
774 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
775 nid, pin_cfg);
776 spec->bios_pin_configs[i] = pin_cfg;
777 }
778
779 return 0;
780}
781
Matt2f2f4252005-04-13 14:45:30 +0200782static void stac92xx_set_config_regs(struct hda_codec *codec)
783{
784 int i;
785 struct sigmatel_spec *spec = codec->spec;
786 unsigned int pin_cfg;
787
Richard Fish11b44bb2006-08-23 18:31:34 +0200788 if (! spec->pin_nids || ! spec->pin_configs)
789 return;
790
791 for (i = 0; i < spec->num_pins; i++) {
Matt2f2f4252005-04-13 14:45:30 +0200792 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
793 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
794 spec->pin_configs[i] & 0x000000ff);
795 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
796 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
797 (spec->pin_configs[i] & 0x0000ff00) >> 8);
798 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
799 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
800 (spec->pin_configs[i] & 0x00ff0000) >> 16);
801 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
802 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
803 spec->pin_configs[i] >> 24);
804 pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0,
805 AC_VERB_GET_CONFIG_DEFAULT,
806 0x00);
Matt Porter403d1942005-11-29 15:00:51 +0100807 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 +0200808 }
809}
Matt2f2f4252005-04-13 14:45:30 +0200810
Matt2f2f4252005-04-13 14:45:30 +0200811/*
812 * Analog playback callbacks
813 */
814static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
815 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100816 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200817{
818 struct sigmatel_spec *spec = codec->spec;
819 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
820}
821
822static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
823 struct hda_codec *codec,
824 unsigned int stream_tag,
825 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100826 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200827{
828 struct sigmatel_spec *spec = codec->spec;
Matt Porter403d1942005-11-29 15:00:51 +0100829 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
Matt2f2f4252005-04-13 14:45:30 +0200830}
831
832static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
833 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100834 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200835{
836 struct sigmatel_spec *spec = codec->spec;
837 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
838}
839
840/*
Mattdabbed62005-06-14 10:19:34 +0200841 * Digital playback callbacks
842 */
843static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
844 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100845 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +0200846{
847 struct sigmatel_spec *spec = codec->spec;
848 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
849}
850
851static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
852 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100853 struct snd_pcm_substream *substream)
Mattdabbed62005-06-14 10:19:34 +0200854{
855 struct sigmatel_spec *spec = codec->spec;
856 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
857}
858
Takashi Iwai6b97eb42007-04-05 14:51:48 +0200859static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
860 struct hda_codec *codec,
861 unsigned int stream_tag,
862 unsigned int format,
863 struct snd_pcm_substream *substream)
864{
865 struct sigmatel_spec *spec = codec->spec;
866 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
867 stream_tag, format, substream);
868}
869
Mattdabbed62005-06-14 10:19:34 +0200870
871/*
Matt2f2f4252005-04-13 14:45:30 +0200872 * Analog capture callbacks
873 */
874static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
875 struct hda_codec *codec,
876 unsigned int stream_tag,
877 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100878 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200879{
880 struct sigmatel_spec *spec = codec->spec;
881
882 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
883 stream_tag, 0, format);
884 return 0;
885}
886
887static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
888 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100889 struct snd_pcm_substream *substream)
Matt2f2f4252005-04-13 14:45:30 +0200890{
891 struct sigmatel_spec *spec = codec->spec;
892
893 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
894 return 0;
895}
896
Mattdabbed62005-06-14 10:19:34 +0200897static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
898 .substreams = 1,
899 .channels_min = 2,
900 .channels_max = 2,
901 /* NID is set in stac92xx_build_pcms */
902 .ops = {
903 .open = stac92xx_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +0200904 .close = stac92xx_dig_playback_pcm_close,
905 .prepare = stac92xx_dig_playback_pcm_prepare
Mattdabbed62005-06-14 10:19:34 +0200906 },
907};
908
909static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
910 .substreams = 1,
911 .channels_min = 2,
912 .channels_max = 2,
913 /* NID is set in stac92xx_build_pcms */
914};
915
Matt2f2f4252005-04-13 14:45:30 +0200916static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
917 .substreams = 1,
918 .channels_min = 2,
Mattc7d4b2f2005-06-27 14:59:41 +0200919 .channels_max = 8,
Matt2f2f4252005-04-13 14:45:30 +0200920 .nid = 0x02, /* NID to query formats and rates */
921 .ops = {
922 .open = stac92xx_playback_pcm_open,
923 .prepare = stac92xx_playback_pcm_prepare,
924 .cleanup = stac92xx_playback_pcm_cleanup
925 },
926};
927
Matt Porter3cc08dc2006-01-23 15:27:49 +0100928static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
929 .substreams = 1,
930 .channels_min = 2,
931 .channels_max = 2,
932 .nid = 0x06, /* NID to query formats and rates */
933 .ops = {
934 .open = stac92xx_playback_pcm_open,
935 .prepare = stac92xx_playback_pcm_prepare,
936 .cleanup = stac92xx_playback_pcm_cleanup
937 },
938};
939
Matt2f2f4252005-04-13 14:45:30 +0200940static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
941 .substreams = 2,
942 .channels_min = 2,
943 .channels_max = 2,
Matt Porter3cc08dc2006-01-23 15:27:49 +0100944 /* NID is set in stac92xx_build_pcms */
Matt2f2f4252005-04-13 14:45:30 +0200945 .ops = {
946 .prepare = stac92xx_capture_pcm_prepare,
947 .cleanup = stac92xx_capture_pcm_cleanup
948 },
949};
950
951static int stac92xx_build_pcms(struct hda_codec *codec)
952{
953 struct sigmatel_spec *spec = codec->spec;
954 struct hda_pcm *info = spec->pcm_rec;
955
956 codec->num_pcms = 1;
957 codec->pcm_info = info;
958
Mattc7d4b2f2005-06-27 14:59:41 +0200959 info->name = "STAC92xx Analog";
Matt2f2f4252005-04-13 14:45:30 +0200960 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
Matt2f2f4252005-04-13 14:45:30 +0200961 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
Matt Porter3cc08dc2006-01-23 15:27:49 +0100962 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
963
964 if (spec->alt_switch) {
965 codec->num_pcms++;
966 info++;
967 info->name = "STAC92xx Analog Alt";
968 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
969 }
Matt2f2f4252005-04-13 14:45:30 +0200970
Mattdabbed62005-06-14 10:19:34 +0200971 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
972 codec->num_pcms++;
973 info++;
974 info->name = "STAC92xx Digital";
975 if (spec->multiout.dig_out_nid) {
976 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
977 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
978 }
979 if (spec->dig_in_nid) {
980 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
981 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
982 }
983 }
984
Matt2f2f4252005-04-13 14:45:30 +0200985 return 0;
986}
987
Takashi Iwaic960a032006-03-23 17:06:28 +0100988static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
989{
990 unsigned int pincap = snd_hda_param_read(codec, nid,
991 AC_PAR_PIN_CAP);
992 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
993 if (pincap & AC_PINCAP_VREF_100)
994 return AC_PINCTL_VREF_100;
995 if (pincap & AC_PINCAP_VREF_80)
996 return AC_PINCTL_VREF_80;
997 if (pincap & AC_PINCAP_VREF_50)
998 return AC_PINCTL_VREF_50;
999 if (pincap & AC_PINCAP_VREF_GRD)
1000 return AC_PINCTL_VREF_GRD;
1001 return 0;
1002}
1003
Matt Porter403d1942005-11-29 15:00:51 +01001004static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
1005
1006{
1007 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
1008}
1009
1010static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1011{
1012 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1013 uinfo->count = 1;
1014 uinfo->value.integer.min = 0;
1015 uinfo->value.integer.max = 1;
1016 return 0;
1017}
1018
1019static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1020{
1021 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1022 struct sigmatel_spec *spec = codec->spec;
1023 int io_idx = kcontrol-> private_value & 0xff;
1024
1025 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
1026 return 0;
1027}
1028
1029static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1030{
1031 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1032 struct sigmatel_spec *spec = codec->spec;
1033 hda_nid_t nid = kcontrol->private_value >> 8;
1034 int io_idx = kcontrol-> private_value & 0xff;
1035 unsigned short val = ucontrol->value.integer.value[0];
1036
1037 spec->io_switch[io_idx] = val;
1038
1039 if (val)
1040 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
Takashi Iwaic960a032006-03-23 17:06:28 +01001041 else {
1042 unsigned int pinctl = AC_PINCTL_IN_EN;
1043 if (io_idx) /* set VREF for mic */
1044 pinctl |= stac92xx_get_vref(codec, nid);
1045 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1046 }
Matt Porter403d1942005-11-29 15:00:51 +01001047 return 1;
1048}
1049
1050#define STAC_CODEC_IO_SWITCH(xname, xpval) \
1051 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1052 .name = xname, \
1053 .index = 0, \
1054 .info = stac92xx_io_switch_info, \
1055 .get = stac92xx_io_switch_get, \
1056 .put = stac92xx_io_switch_put, \
1057 .private_value = xpval, \
1058 }
1059
1060
Mattc7d4b2f2005-06-27 14:59:41 +02001061enum {
1062 STAC_CTL_WIDGET_VOL,
1063 STAC_CTL_WIDGET_MUTE,
Matt Porter403d1942005-11-29 15:00:51 +01001064 STAC_CTL_WIDGET_IO_SWITCH,
Mattc7d4b2f2005-06-27 14:59:41 +02001065};
1066
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001067static struct snd_kcontrol_new stac92xx_control_templates[] = {
Mattc7d4b2f2005-06-27 14:59:41 +02001068 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1069 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Matt Porter403d1942005-11-29 15:00:51 +01001070 STAC_CODEC_IO_SWITCH(NULL, 0),
Mattc7d4b2f2005-06-27 14:59:41 +02001071};
1072
1073/* add dynamic controls */
1074static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
1075{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001076 struct snd_kcontrol_new *knew;
Mattc7d4b2f2005-06-27 14:59:41 +02001077
1078 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1079 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1080
1081 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1082 if (! knew)
1083 return -ENOMEM;
1084 if (spec->kctl_alloc) {
1085 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1086 kfree(spec->kctl_alloc);
1087 }
1088 spec->kctl_alloc = knew;
1089 spec->num_kctl_alloc = num;
1090 }
1091
1092 knew = &spec->kctl_alloc[spec->num_kctl_used];
1093 *knew = stac92xx_control_templates[type];
Takashi Iwai82fe0c52005-06-30 10:54:33 +02001094 knew->name = kstrdup(name, GFP_KERNEL);
Mattc7d4b2f2005-06-27 14:59:41 +02001095 if (! knew->name)
1096 return -ENOMEM;
1097 knew->private_value = val;
1098 spec->num_kctl_used++;
1099 return 0;
1100}
1101
Matt Porter403d1942005-11-29 15:00:51 +01001102/* flag inputs as additional dynamic lineouts */
1103static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
1104{
1105 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b0438992007-05-03 20:50:03 +02001106 unsigned int wcaps, wtype;
1107 int i, num_dacs = 0;
1108
1109 /* use the wcaps cache to count all DACs available for line-outs */
1110 for (i = 0; i < codec->num_nodes; i++) {
1111 wcaps = codec->wcaps[i];
1112 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1113 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
1114 num_dacs++;
1115 }
Matt Porter403d1942005-11-29 15:00:51 +01001116
Steve Longerbeam7b0438992007-05-03 20:50:03 +02001117 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
1118
Matt Porter403d1942005-11-29 15:00:51 +01001119 switch (cfg->line_outs) {
1120 case 3:
1121 /* add line-in as side */
Steve Longerbeam7b0438992007-05-03 20:50:03 +02001122 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
Matt Porter403d1942005-11-29 15:00:51 +01001123 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE];
1124 spec->line_switch = 1;
1125 cfg->line_outs++;
1126 }
1127 break;
1128 case 2:
1129 /* add line-in as clfe and mic as side */
Steve Longerbeam7b0438992007-05-03 20:50:03 +02001130 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
Matt Porter403d1942005-11-29 15:00:51 +01001131 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE];
1132 spec->line_switch = 1;
1133 cfg->line_outs++;
1134 }
Steve Longerbeam7b0438992007-05-03 20:50:03 +02001135 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
Matt Porter403d1942005-11-29 15:00:51 +01001136 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC];
1137 spec->mic_switch = 1;
1138 cfg->line_outs++;
1139 }
1140 break;
1141 case 1:
1142 /* add line-in as surr and mic as clfe */
Steve Longerbeam7b0438992007-05-03 20:50:03 +02001143 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
Matt Porter403d1942005-11-29 15:00:51 +01001144 cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE];
1145 spec->line_switch = 1;
1146 cfg->line_outs++;
1147 }
Steve Longerbeam7b0438992007-05-03 20:50:03 +02001148 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
Matt Porter403d1942005-11-29 15:00:51 +01001149 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC];
1150 spec->mic_switch = 1;
1151 cfg->line_outs++;
1152 }
1153 break;
1154 }
1155
1156 return 0;
1157}
1158
Steve Longerbeam7b0438992007-05-03 20:50:03 +02001159
1160static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1161{
1162 int i;
1163
1164 for (i = 0; i < spec->multiout.num_dacs; i++) {
1165 if (spec->multiout.dac_nids[i] == nid)
1166 return 1;
1167 }
1168
1169 return 0;
1170}
1171
Matt Porter3cc08dc2006-01-23 15:27:49 +01001172/*
Steve Longerbeam7b0438992007-05-03 20:50:03 +02001173 * Fill in the dac_nids table from the parsed pin configuration
1174 * This function only works when every pin in line_out_pins[]
1175 * contains atleast one DAC in its connection list. Some 92xx
1176 * codecs are not connected directly to a DAC, such as the 9200
1177 * and 9202/925x. For those, dac_nids[] must be hard-coded.
Matt Porter3cc08dc2006-01-23 15:27:49 +01001178 */
Takashi Iwai19039bd2006-06-28 15:52:16 +02001179static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
1180 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02001181{
1182 struct sigmatel_spec *spec = codec->spec;
Steve Longerbeam7b0438992007-05-03 20:50:03 +02001183 int i, j, conn_len = 0;
1184 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
1185 unsigned int wcaps, wtype;
1186
Mattc7d4b2f2005-06-27 14:59:41 +02001187 for (i = 0; i < cfg->line_outs; i++) {
1188 nid = cfg->line_out_pins[i];
Steve Longerbeam7b0438992007-05-03 20:50:03 +02001189 conn_len = snd_hda_get_connections(codec, nid, conn,
1190 HDA_MAX_CONNECTIONS);
1191 for (j = 0; j < conn_len; j++) {
1192 wcaps = snd_hda_param_read(codec, conn[j],
1193 AC_PAR_AUDIO_WIDGET_CAP);
1194 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1195
1196 if (wtype != AC_WID_AUD_OUT ||
1197 (wcaps & AC_WCAP_DIGITAL))
1198 continue;
1199 /* conn[j] is a DAC routed to this line-out */
1200 if (!is_in_dac_nids(spec, conn[j]))
1201 break;
1202 }
1203
1204 if (j == conn_len) {
1205 /* error out, no available DAC found */
1206 snd_printk(KERN_ERR
1207 "%s: No available DAC for pin 0x%x\n",
1208 __func__, nid);
1209 return -ENODEV;
1210 }
1211
1212 spec->multiout.dac_nids[i] = conn[j];
1213 spec->multiout.num_dacs++;
1214 if (conn_len > 1) {
1215 /* select this DAC in the pin's input mux */
1216 snd_hda_codec_write(codec, nid, 0,
1217 AC_VERB_SET_CONNECT_SEL, j);
1218
1219 }
Mattc7d4b2f2005-06-27 14:59:41 +02001220 }
1221
Steve Longerbeam7b0438992007-05-03 20:50:03 +02001222 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
1223 spec->multiout.num_dacs,
1224 spec->multiout.dac_nids[0],
1225 spec->multiout.dac_nids[1],
1226 spec->multiout.dac_nids[2],
1227 spec->multiout.dac_nids[3],
1228 spec->multiout.dac_nids[4]);
Mattc7d4b2f2005-06-27 14:59:41 +02001229 return 0;
1230}
1231
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001232/* create volume control/switch for the given prefx type */
1233static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
1234{
1235 char name[32];
1236 int err;
1237
1238 sprintf(name, "%s Playback Volume", pfx);
1239 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
1240 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1241 if (err < 0)
1242 return err;
1243 sprintf(name, "%s Playback Switch", pfx);
1244 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
1245 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1246 if (err < 0)
1247 return err;
1248 return 0;
1249}
1250
Mattc7d4b2f2005-06-27 14:59:41 +02001251/* add playback controls from the parsed DAC table */
Takashi Iwai19039bd2006-06-28 15:52:16 +02001252static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec,
1253 const struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02001254{
Takashi Iwai19039bd2006-06-28 15:52:16 +02001255 static const char *chname[4] = {
1256 "Front", "Surround", NULL /*CLFE*/, "Side"
1257 };
Mattc7d4b2f2005-06-27 14:59:41 +02001258 hda_nid_t nid;
1259 int i, err;
1260
1261 for (i = 0; i < cfg->line_outs; i++) {
Matt Porter403d1942005-11-29 15:00:51 +01001262 if (!spec->multiout.dac_nids[i])
Mattc7d4b2f2005-06-27 14:59:41 +02001263 continue;
1264
1265 nid = spec->multiout.dac_nids[i];
1266
1267 if (i == 2) {
1268 /* Center/LFE */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001269 err = create_controls(spec, "Center", nid, 1);
1270 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001271 return err;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001272 err = create_controls(spec, "LFE", nid, 2);
1273 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001274 return err;
1275 } else {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001276 err = create_controls(spec, chname[i], nid, 3);
1277 if (err < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001278 return err;
1279 }
1280 }
1281
Matt Porter403d1942005-11-29 15:00:51 +01001282 if (spec->line_switch)
1283 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
1284 return err;
1285
1286 if (spec->mic_switch)
1287 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
1288 return err;
1289
Mattc7d4b2f2005-06-27 14:59:41 +02001290 return 0;
1291}
1292
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001293static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1294{
Steve Longerbeam7b0438992007-05-03 20:50:03 +02001295 if (is_in_dac_nids(spec, nid))
1296 return 1;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001297 if (spec->multiout.hp_nid == nid)
1298 return 1;
1299 return 0;
1300}
1301
1302static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
1303{
1304 if (!spec->multiout.hp_nid)
1305 spec->multiout.hp_nid = nid;
1306 else if (spec->multiout.num_dacs > 4) {
1307 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
1308 return 1;
1309 } else {
1310 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
1311 spec->multiout.num_dacs++;
1312 }
1313 return 0;
1314}
1315
1316/* add playback controls for Speaker and HP outputs */
1317static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
1318 struct auto_pin_cfg *cfg)
Mattc7d4b2f2005-06-27 14:59:41 +02001319{
1320 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02001321 hda_nid_t nid;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001322 int i, old_num_dacs, err;
Mattc7d4b2f2005-06-27 14:59:41 +02001323
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001324 old_num_dacs = spec->multiout.num_dacs;
1325 for (i = 0; i < cfg->hp_outs; i++) {
1326 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
1327 if (wid_caps & AC_WCAP_UNSOL_CAP)
1328 spec->hp_detect = 1;
1329 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
1330 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1331 if (check_in_dac_nids(spec, nid))
1332 nid = 0;
1333 if (! nid)
Mattc7d4b2f2005-06-27 14:59:41 +02001334 continue;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001335 add_spec_dacs(spec, nid);
1336 }
1337 for (i = 0; i < cfg->speaker_outs; i++) {
Steve Longerbeam7b0438992007-05-03 20:50:03 +02001338 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001339 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1340 if (check_in_dac_nids(spec, nid))
1341 nid = 0;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001342 if (! nid)
1343 continue;
1344 add_spec_dacs(spec, nid);
Mattc7d4b2f2005-06-27 14:59:41 +02001345 }
1346
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001347 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
1348 static const char *pfxs[] = {
1349 "Speaker", "External Speaker", "Speaker2",
1350 };
1351 err = create_controls(spec, pfxs[i - old_num_dacs],
1352 spec->multiout.dac_nids[i], 3);
1353 if (err < 0)
1354 return err;
1355 }
1356 if (spec->multiout.hp_nid) {
1357 const char *pfx;
1358 if (old_num_dacs == spec->multiout.num_dacs)
1359 pfx = "Master";
1360 else
1361 pfx = "Headphone";
1362 err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
1363 if (err < 0)
1364 return err;
1365 }
Mattc7d4b2f2005-06-27 14:59:41 +02001366
1367 return 0;
1368}
1369
Matt Porter8b657272006-10-26 17:12:59 +02001370/* labels for dmic mux inputs */
Adrian Bunkddc2cec2006-11-20 12:03:44 +01001371static const char *stac92xx_dmic_labels[5] = {
Matt Porter8b657272006-10-26 17:12:59 +02001372 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
1373 "Digital Mic 3", "Digital Mic 4"
1374};
1375
1376/* create playback/capture controls for input pins on dmic capable codecs */
1377static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
1378 const struct auto_pin_cfg *cfg)
1379{
1380 struct sigmatel_spec *spec = codec->spec;
1381 struct hda_input_mux *dimux = &spec->private_dimux;
1382 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1383 int i, j;
1384
1385 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
1386 dimux->items[dimux->num_items].index = 0;
1387 dimux->num_items++;
1388
1389 for (i = 0; i < spec->num_dmics; i++) {
1390 int index;
1391 int num_cons;
1392 unsigned int def_conf;
1393
1394 def_conf = snd_hda_codec_read(codec,
1395 spec->dmic_nids[i],
1396 0,
1397 AC_VERB_GET_CONFIG_DEFAULT,
1398 0);
1399 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
1400 continue;
1401
1402 num_cons = snd_hda_get_connections(codec,
1403 spec->dmux_nid,
1404 con_lst,
1405 HDA_MAX_NUM_INPUTS);
1406 for (j = 0; j < num_cons; j++)
1407 if (con_lst[j] == spec->dmic_nids[i]) {
1408 index = j;
1409 goto found;
1410 }
1411 continue;
1412found:
1413 dimux->items[dimux->num_items].label =
1414 stac92xx_dmic_labels[dimux->num_items];
1415 dimux->items[dimux->num_items].index = index;
1416 dimux->num_items++;
1417 }
1418
1419 return 0;
1420}
1421
Mattc7d4b2f2005-06-27 14:59:41 +02001422/* create playback/capture controls for input pins */
1423static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
1424{
1425 struct sigmatel_spec *spec = codec->spec;
Mattc7d4b2f2005-06-27 14:59:41 +02001426 struct hda_input_mux *imux = &spec->private_imux;
1427 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1428 int i, j, k;
1429
1430 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02001431 int index;
Mattc7d4b2f2005-06-27 14:59:41 +02001432
Takashi Iwai314634b2006-09-21 11:56:18 +02001433 if (!cfg->input_pins[i])
1434 continue;
1435 index = -1;
1436 for (j = 0; j < spec->num_muxes; j++) {
1437 int num_cons;
1438 num_cons = snd_hda_get_connections(codec,
1439 spec->mux_nids[j],
1440 con_lst,
1441 HDA_MAX_NUM_INPUTS);
1442 for (k = 0; k < num_cons; k++)
1443 if (con_lst[k] == cfg->input_pins[i]) {
1444 index = k;
1445 goto found;
1446 }
Mattc7d4b2f2005-06-27 14:59:41 +02001447 }
Takashi Iwai314634b2006-09-21 11:56:18 +02001448 continue;
1449 found:
1450 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
1451 imux->items[imux->num_items].index = index;
1452 imux->num_items++;
Mattc7d4b2f2005-06-27 14:59:41 +02001453 }
1454
Steve Longerbeam7b0438992007-05-03 20:50:03 +02001455 if (imux->num_items) {
Sam Revitch62fe78e2006-05-10 15:09:17 +02001456 /*
1457 * Set the current input for the muxes.
1458 * The STAC9221 has two input muxes with identical source
1459 * NID lists. Hopefully this won't get confused.
1460 */
1461 for (i = 0; i < spec->num_muxes; i++) {
1462 snd_hda_codec_write(codec, spec->mux_nids[i], 0,
1463 AC_VERB_SET_CONNECT_SEL,
1464 imux->items[0].index);
1465 }
1466 }
1467
Mattc7d4b2f2005-06-27 14:59:41 +02001468 return 0;
1469}
1470
Mattc7d4b2f2005-06-27 14:59:41 +02001471static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
1472{
1473 struct sigmatel_spec *spec = codec->spec;
1474 int i;
1475
1476 for (i = 0; i < spec->autocfg.line_outs; i++) {
1477 hda_nid_t nid = spec->autocfg.line_out_pins[i];
1478 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
1479 }
1480}
1481
1482static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
1483{
1484 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001485 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02001486
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001487 for (i = 0; i < spec->autocfg.hp_outs; i++) {
1488 hda_nid_t pin;
1489 pin = spec->autocfg.hp_pins[i];
1490 if (pin) /* connect to front */
1491 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
1492 }
1493 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
1494 hda_nid_t pin;
1495 pin = spec->autocfg.speaker_pins[i];
1496 if (pin) /* connect to front */
1497 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
1498 }
Mattc7d4b2f2005-06-27 14:59:41 +02001499}
1500
Matt Porter3cc08dc2006-01-23 15:27:49 +01001501static 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 +02001502{
1503 struct sigmatel_spec *spec = codec->spec;
1504 int err;
1505
Matt Porter8b657272006-10-26 17:12:59 +02001506 if ((err = snd_hda_parse_pin_def_config(codec,
1507 &spec->autocfg,
1508 spec->dmic_nids)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001509 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001510 if (! spec->autocfg.line_outs)
Matt Porter869264c2006-01-25 19:20:50 +01001511 return 0; /* can't find valid pin config */
Takashi Iwai19039bd2006-06-28 15:52:16 +02001512
Matt Porter403d1942005-11-29 15:00:51 +01001513 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
1514 return err;
Takashi Iwai19039bd2006-06-28 15:52:16 +02001515 if (spec->multiout.num_dacs == 0)
1516 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
1517 return err;
Mattc7d4b2f2005-06-27 14:59:41 +02001518
1519 if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
1520 (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 ||
1521 (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
1522 return err;
1523
Matt Porter8b657272006-10-26 17:12:59 +02001524 if (spec->num_dmics > 0)
1525 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
1526 &spec->autocfg)) < 0)
1527 return err;
1528
Mattc7d4b2f2005-06-27 14:59:41 +02001529 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
Matt Porter403d1942005-11-29 15:00:51 +01001530 if (spec->multiout.max_channels > 2)
Mattc7d4b2f2005-06-27 14:59:41 +02001531 spec->surr_switch = 1;
Mattc7d4b2f2005-06-27 14:59:41 +02001532
Takashi Iwai82bc9552006-03-21 11:24:42 +01001533 if (spec->autocfg.dig_out_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01001534 spec->multiout.dig_out_nid = dig_out;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001535 if (spec->autocfg.dig_in_pin)
Matt Porter3cc08dc2006-01-23 15:27:49 +01001536 spec->dig_in_nid = dig_in;
Mattc7d4b2f2005-06-27 14:59:41 +02001537
1538 if (spec->kctl_alloc)
1539 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
1540
1541 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02001542 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02001543
1544 return 1;
1545}
1546
Takashi Iwai82bc9552006-03-21 11:24:42 +01001547/* add playback controls for HP output */
1548static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
1549 struct auto_pin_cfg *cfg)
1550{
1551 struct sigmatel_spec *spec = codec->spec;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001552 hda_nid_t pin = cfg->hp_pins[0];
Takashi Iwai82bc9552006-03-21 11:24:42 +01001553 unsigned int wid_caps;
1554
1555 if (! pin)
1556 return 0;
1557
1558 wid_caps = get_wcaps(codec, pin);
Takashi Iwai505cb342006-03-27 12:51:52 +02001559 if (wid_caps & AC_WCAP_UNSOL_CAP)
Takashi Iwai82bc9552006-03-21 11:24:42 +01001560 spec->hp_detect = 1;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001561
1562 return 0;
1563}
1564
Richard Fish160ea0d2006-09-06 13:58:25 +02001565/* add playback controls for LFE output */
1566static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
1567 struct auto_pin_cfg *cfg)
1568{
1569 struct sigmatel_spec *spec = codec->spec;
1570 int err;
1571 hda_nid_t lfe_pin = 0x0;
1572 int i;
1573
1574 /*
1575 * search speaker outs and line outs for a mono speaker pin
1576 * with an amp. If one is found, add LFE controls
1577 * for it.
1578 */
1579 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
1580 hda_nid_t pin = spec->autocfg.speaker_pins[i];
1581 unsigned long wcaps = get_wcaps(codec, pin);
1582 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
1583 if (wcaps == AC_WCAP_OUT_AMP)
1584 /* found a mono speaker with an amp, must be lfe */
1585 lfe_pin = pin;
1586 }
1587
1588 /* if speaker_outs is 0, then speakers may be in line_outs */
1589 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
1590 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
1591 hda_nid_t pin = spec->autocfg.line_out_pins[i];
1592 unsigned long cfg;
1593 cfg = snd_hda_codec_read(codec, pin, 0,
1594 AC_VERB_GET_CONFIG_DEFAULT,
1595 0x00);
1596 if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) {
1597 unsigned long wcaps = get_wcaps(codec, pin);
1598 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
1599 if (wcaps == AC_WCAP_OUT_AMP)
1600 /* found a mono speaker with an amp,
1601 must be lfe */
1602 lfe_pin = pin;
1603 }
1604 }
1605 }
1606
1607 if (lfe_pin) {
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001608 err = create_controls(spec, "LFE", lfe_pin, 1);
Richard Fish160ea0d2006-09-06 13:58:25 +02001609 if (err < 0)
1610 return err;
1611 }
1612
1613 return 0;
1614}
1615
Mattc7d4b2f2005-06-27 14:59:41 +02001616static int stac9200_parse_auto_config(struct hda_codec *codec)
1617{
1618 struct sigmatel_spec *spec = codec->spec;
1619 int err;
1620
Kailang Yangdf694da2005-12-05 19:42:22 +01001621 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
Mattc7d4b2f2005-06-27 14:59:41 +02001622 return err;
1623
1624 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
1625 return err;
1626
Takashi Iwai82bc9552006-03-21 11:24:42 +01001627 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
1628 return err;
1629
Richard Fish160ea0d2006-09-06 13:58:25 +02001630 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
1631 return err;
1632
Takashi Iwai82bc9552006-03-21 11:24:42 +01001633 if (spec->autocfg.dig_out_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02001634 spec->multiout.dig_out_nid = 0x05;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001635 if (spec->autocfg.dig_in_pin)
Mattc7d4b2f2005-06-27 14:59:41 +02001636 spec->dig_in_nid = 0x04;
Mattc7d4b2f2005-06-27 14:59:41 +02001637
1638 if (spec->kctl_alloc)
1639 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
1640
1641 spec->input_mux = &spec->private_imux;
Matt Porter8b657272006-10-26 17:12:59 +02001642 spec->dinput_mux = &spec->private_dimux;
Mattc7d4b2f2005-06-27 14:59:41 +02001643
1644 return 1;
1645}
1646
Sam Revitch62fe78e2006-05-10 15:09:17 +02001647/*
1648 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
1649 * funky external mute control using GPIO pins.
1650 */
1651
1652static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted)
1653{
1654 unsigned int gpiostate, gpiomask, gpiodir;
1655
1656 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
1657 AC_VERB_GET_GPIO_DATA, 0);
1658
1659 if (!muted)
1660 gpiostate |= (1 << pin);
1661 else
1662 gpiostate &= ~(1 << pin);
1663
1664 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
1665 AC_VERB_GET_GPIO_MASK, 0);
1666 gpiomask |= (1 << pin);
1667
1668 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
1669 AC_VERB_GET_GPIO_DIRECTION, 0);
1670 gpiodir |= (1 << pin);
1671
1672 /* AppleHDA seems to do this -- WTF is this verb?? */
1673 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
1674
1675 snd_hda_codec_write(codec, codec->afg, 0,
1676 AC_VERB_SET_GPIO_MASK, gpiomask);
1677 snd_hda_codec_write(codec, codec->afg, 0,
1678 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
1679
1680 msleep(1);
1681
1682 snd_hda_codec_write(codec, codec->afg, 0,
1683 AC_VERB_SET_GPIO_DATA, gpiostate);
1684}
1685
Takashi Iwai314634b2006-09-21 11:56:18 +02001686static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
1687 unsigned int event)
1688{
1689 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
1690 snd_hda_codec_write(codec, nid, 0,
1691 AC_VERB_SET_UNSOLICITED_ENABLE,
1692 (AC_USRSP_EN | event));
1693}
1694
Mattc7d4b2f2005-06-27 14:59:41 +02001695static int stac92xx_init(struct hda_codec *codec)
1696{
1697 struct sigmatel_spec *spec = codec->spec;
Takashi Iwai82bc9552006-03-21 11:24:42 +01001698 struct auto_pin_cfg *cfg = &spec->autocfg;
1699 int i;
Mattc7d4b2f2005-06-27 14:59:41 +02001700
Mattc7d4b2f2005-06-27 14:59:41 +02001701 snd_hda_sequence_write(codec, spec->init);
1702
Takashi Iwai82bc9552006-03-21 11:24:42 +01001703 /* set up pins */
1704 if (spec->hp_detect) {
Takashi Iwai505cb342006-03-27 12:51:52 +02001705 /* Enable unsolicited responses on the HP widget */
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001706 for (i = 0; i < cfg->hp_outs; i++)
Takashi Iwai314634b2006-09-21 11:56:18 +02001707 enable_pin_detect(codec, cfg->hp_pins[i],
1708 STAC_HP_EVENT);
Takashi Iwai0a07acaf2007-03-13 10:40:23 +01001709 /* force to enable the first line-out; the others are set up
1710 * in unsol_event
1711 */
1712 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
1713 AC_PINCTL_OUT_EN);
Takashi Iwaieb995a82006-09-21 14:28:21 +02001714 stac92xx_auto_init_hp_out(codec);
Takashi Iwai82bc9552006-03-21 11:24:42 +01001715 /* fake event to set up pins */
1716 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
1717 } else {
1718 stac92xx_auto_init_multi_out(codec);
1719 stac92xx_auto_init_hp_out(codec);
1720 }
1721 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaic960a032006-03-23 17:06:28 +01001722 hda_nid_t nid = cfg->input_pins[i];
1723 if (nid) {
1724 unsigned int pinctl = AC_PINCTL_IN_EN;
1725 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
1726 pinctl |= stac92xx_get_vref(codec, nid);
1727 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1728 }
Takashi Iwai82bc9552006-03-21 11:24:42 +01001729 }
Matt Porter8b657272006-10-26 17:12:59 +02001730 if (spec->num_dmics > 0)
1731 for (i = 0; i < spec->num_dmics; i++)
1732 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
1733 AC_PINCTL_IN_EN);
1734
Takashi Iwai82bc9552006-03-21 11:24:42 +01001735 if (cfg->dig_out_pin)
1736 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
1737 AC_PINCTL_OUT_EN);
1738 if (cfg->dig_in_pin)
1739 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
1740 AC_PINCTL_IN_EN);
1741
Sam Revitch62fe78e2006-05-10 15:09:17 +02001742 if (spec->gpio_mute) {
1743 stac922x_gpio_mute(codec, 0, 0);
1744 stac922x_gpio_mute(codec, 1, 0);
1745 }
1746
Mattc7d4b2f2005-06-27 14:59:41 +02001747 return 0;
1748}
1749
Matt2f2f4252005-04-13 14:45:30 +02001750static void stac92xx_free(struct hda_codec *codec)
1751{
Mattc7d4b2f2005-06-27 14:59:41 +02001752 struct sigmatel_spec *spec = codec->spec;
1753 int i;
1754
1755 if (! spec)
1756 return;
1757
1758 if (spec->kctl_alloc) {
1759 for (i = 0; i < spec->num_kctl_used; i++)
1760 kfree(spec->kctl_alloc[i].name);
1761 kfree(spec->kctl_alloc);
1762 }
1763
Richard Fish11b44bb2006-08-23 18:31:34 +02001764 if (spec->bios_pin_configs)
1765 kfree(spec->bios_pin_configs);
1766
Mattc7d4b2f2005-06-27 14:59:41 +02001767 kfree(spec);
Matt2f2f4252005-04-13 14:45:30 +02001768}
1769
Matt4e550962005-07-04 17:51:39 +02001770static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
1771 unsigned int flag)
1772{
1773 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1774 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
Steve Longerbeam7b0438992007-05-03 20:50:03 +02001775
Takashi Iwaif9acba42007-05-29 18:01:06 +02001776 if (pin_ctl & AC_PINCTL_IN_EN) {
1777 /*
1778 * we need to check the current set-up direction of
1779 * shared input pins since they can be switched via
1780 * "xxx as Output" mixer switch
1781 */
1782 struct sigmatel_spec *spec = codec->spec;
1783 struct auto_pin_cfg *cfg = &spec->autocfg;
1784 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
1785 spec->line_switch) ||
1786 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
1787 spec->mic_switch))
1788 return;
1789 }
1790
Steve Longerbeam7b0438992007-05-03 20:50:03 +02001791 /* if setting pin direction bits, clear the current
1792 direction bits first */
1793 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
1794 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
1795
Matt4e550962005-07-04 17:51:39 +02001796 snd_hda_codec_write(codec, nid, 0,
1797 AC_VERB_SET_PIN_WIDGET_CONTROL,
1798 pin_ctl | flag);
1799}
1800
1801static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
1802 unsigned int flag)
1803{
1804 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1805 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
1806 snd_hda_codec_write(codec, nid, 0,
1807 AC_VERB_SET_PIN_WIDGET_CONTROL,
1808 pin_ctl & ~flag);
1809}
1810
Takashi Iwai314634b2006-09-21 11:56:18 +02001811static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
1812{
1813 if (!nid)
1814 return 0;
1815 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
1816 & (1 << 31))
1817 return 1;
1818 return 0;
1819}
1820
1821static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
Matt4e550962005-07-04 17:51:39 +02001822{
1823 struct sigmatel_spec *spec = codec->spec;
1824 struct auto_pin_cfg *cfg = &spec->autocfg;
1825 int i, presence;
1826
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001827 presence = 0;
1828 for (i = 0; i < cfg->hp_outs; i++) {
Takashi Iwai314634b2006-09-21 11:56:18 +02001829 presence = get_pin_presence(codec, cfg->hp_pins[i]);
1830 if (presence)
1831 break;
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001832 }
Matt4e550962005-07-04 17:51:39 +02001833
1834 if (presence) {
1835 /* disable lineouts, enable hp */
1836 for (i = 0; i < cfg->line_outs; i++)
1837 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
1838 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001839 for (i = 0; i < cfg->speaker_outs; i++)
1840 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
1841 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02001842 } else {
1843 /* enable lineouts, disable hp */
1844 for (i = 0; i < cfg->line_outs; i++)
1845 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
1846 AC_PINCTL_OUT_EN);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02001847 for (i = 0; i < cfg->speaker_outs; i++)
1848 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
1849 AC_PINCTL_OUT_EN);
Matt4e550962005-07-04 17:51:39 +02001850 }
1851}
1852
Takashi Iwai314634b2006-09-21 11:56:18 +02001853static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
1854{
1855 switch (res >> 26) {
1856 case STAC_HP_EVENT:
1857 stac92xx_hp_detect(codec, res);
1858 break;
1859 }
1860}
1861
Mattff6fdc32005-06-27 15:06:52 +02001862#ifdef CONFIG_PM
1863static int stac92xx_resume(struct hda_codec *codec)
1864{
1865 struct sigmatel_spec *spec = codec->spec;
1866 int i;
1867
1868 stac92xx_init(codec);
Richard Fish11b44bb2006-08-23 18:31:34 +02001869 stac92xx_set_config_regs(codec);
Takashi Iwai5d403b12007-05-03 12:32:29 +02001870 snd_hda_resume_ctls(codec, spec->mixer);
Mattff6fdc32005-06-27 15:06:52 +02001871 for (i = 0; i < spec->num_mixers; i++)
1872 snd_hda_resume_ctls(codec, spec->mixers[i]);
1873 if (spec->multiout.dig_out_nid)
1874 snd_hda_resume_spdif_out(codec);
1875 if (spec->dig_in_nid)
1876 snd_hda_resume_spdif_in(codec);
1877
1878 return 0;
1879}
1880#endif
1881
Matt2f2f4252005-04-13 14:45:30 +02001882static struct hda_codec_ops stac92xx_patch_ops = {
1883 .build_controls = stac92xx_build_controls,
1884 .build_pcms = stac92xx_build_pcms,
1885 .init = stac92xx_init,
1886 .free = stac92xx_free,
Matt4e550962005-07-04 17:51:39 +02001887 .unsol_event = stac92xx_unsol_event,
Mattff6fdc32005-06-27 15:06:52 +02001888#ifdef CONFIG_PM
1889 .resume = stac92xx_resume,
1890#endif
Matt2f2f4252005-04-13 14:45:30 +02001891};
1892
1893static int patch_stac9200(struct hda_codec *codec)
1894{
1895 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02001896 int err;
Matt2f2f4252005-04-13 14:45:30 +02001897
Takashi Iwaie560d8d2005-09-09 14:21:46 +02001898 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02001899 if (spec == NULL)
1900 return -ENOMEM;
1901
1902 codec->spec = spec;
Richard Fish11b44bb2006-08-23 18:31:34 +02001903 spec->num_pins = 8;
1904 spec->pin_nids = stac9200_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01001905 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
1906 stac9200_models,
1907 stac9200_cfg_tbl);
Richard Fish11b44bb2006-08-23 18:31:34 +02001908 if (spec->board_config < 0) {
1909 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
1910 err = stac92xx_save_bios_config_regs(codec);
1911 if (err < 0) {
1912 stac92xx_free(codec);
1913 return err;
1914 }
1915 spec->pin_configs = spec->bios_pin_configs;
1916 } else {
Matt Porter403d1942005-11-29 15:00:51 +01001917 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
1918 stac92xx_set_config_regs(codec);
1919 }
Matt2f2f4252005-04-13 14:45:30 +02001920
1921 spec->multiout.max_channels = 2;
1922 spec->multiout.num_dacs = 1;
1923 spec->multiout.dac_nids = stac9200_dac_nids;
1924 spec->adc_nids = stac9200_adc_nids;
1925 spec->mux_nids = stac9200_mux_nids;
Mattdabbed62005-06-14 10:19:34 +02001926 spec->num_muxes = 1;
Matt Porter8b657272006-10-26 17:12:59 +02001927 spec->num_dmics = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02001928
1929 spec->init = stac9200_core_init;
Matt2f2f4252005-04-13 14:45:30 +02001930 spec->mixer = stac9200_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02001931
1932 err = stac9200_parse_auto_config(codec);
1933 if (err < 0) {
1934 stac92xx_free(codec);
1935 return err;
1936 }
Matt2f2f4252005-04-13 14:45:30 +02001937
1938 codec->patch_ops = stac92xx_patch_ops;
1939
1940 return 0;
1941}
1942
Tobin Davis8e21c342007-01-08 11:04:17 +01001943static int patch_stac925x(struct hda_codec *codec)
1944{
1945 struct sigmatel_spec *spec;
1946 int err;
1947
1948 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1949 if (spec == NULL)
1950 return -ENOMEM;
1951
1952 codec->spec = spec;
1953 spec->num_pins = 8;
1954 spec->pin_nids = stac925x_pin_nids;
1955 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
1956 stac925x_models,
1957 stac925x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01001958 again:
Tobin Davis8e21c342007-01-08 11:04:17 +01001959 if (spec->board_config < 0) {
Tobin Davis2c11f952007-05-17 09:36:34 +02001960 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
1961 "using BIOS defaults\n");
Tobin Davis8e21c342007-01-08 11:04:17 +01001962 err = stac92xx_save_bios_config_regs(codec);
1963 if (err < 0) {
1964 stac92xx_free(codec);
1965 return err;
1966 }
1967 spec->pin_configs = spec->bios_pin_configs;
1968 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
1969 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
1970 stac92xx_set_config_regs(codec);
1971 }
1972
1973 spec->multiout.max_channels = 2;
1974 spec->multiout.num_dacs = 1;
1975 spec->multiout.dac_nids = stac925x_dac_nids;
1976 spec->adc_nids = stac925x_adc_nids;
1977 spec->mux_nids = stac925x_mux_nids;
1978 spec->num_muxes = 1;
Tobin Davis2c11f952007-05-17 09:36:34 +02001979 switch (codec->vendor_id) {
1980 case 0x83847632: /* STAC9202 */
1981 case 0x83847633: /* STAC9202D */
1982 case 0x83847636: /* STAC9251 */
1983 case 0x83847637: /* STAC9251D */
1984 spec->num_dmics = 1;
1985 spec->dmic_nids = stac925x_dmic_nids;
1986 break;
1987 default:
1988 spec->num_dmics = 0;
1989 break;
1990 }
Tobin Davis8e21c342007-01-08 11:04:17 +01001991
1992 spec->init = stac925x_core_init;
1993 spec->mixer = stac925x_mixer;
1994
1995 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01001996 if (!err) {
1997 if (spec->board_config < 0) {
1998 printk(KERN_WARNING "hda_codec: No auto-config is "
1999 "available, default to model=ref\n");
2000 spec->board_config = STAC_925x_REF;
2001 goto again;
2002 }
2003 err = -EINVAL;
2004 }
Tobin Davis8e21c342007-01-08 11:04:17 +01002005 if (err < 0) {
2006 stac92xx_free(codec);
2007 return err;
2008 }
2009
2010 codec->patch_ops = stac92xx_patch_ops;
2011
2012 return 0;
2013}
2014
Matt2f2f4252005-04-13 14:45:30 +02002015static int patch_stac922x(struct hda_codec *codec)
2016{
2017 struct sigmatel_spec *spec;
Mattc7d4b2f2005-06-27 14:59:41 +02002018 int err;
Matt2f2f4252005-04-13 14:45:30 +02002019
Takashi Iwaie560d8d2005-09-09 14:21:46 +02002020 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Matt2f2f4252005-04-13 14:45:30 +02002021 if (spec == NULL)
2022 return -ENOMEM;
2023
2024 codec->spec = spec;
Richard Fish11b44bb2006-08-23 18:31:34 +02002025 spec->num_pins = 10;
2026 spec->pin_nids = stac922x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002027 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
2028 stac922x_models,
2029 stac922x_cfg_tbl);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002030 if (spec->board_config == STAC_MACMINI) {
2031 spec->gpio_mute = 1;
2032 /* Intel Macs have all same PCI SSID, so we need to check
2033 * codec SSID to distinguish the exact models
2034 */
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01002035 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002036 switch (codec->subsystem_id) {
Abhijit Bhopatkarc45e20e2007-04-17 11:57:16 +02002037 case 0x106b0a00: /* MacBook First generatoin */
2038 spec->board_config = STAC_MACBOOK;
2039 break;
Nicolas Boichat6f0778d2007-03-15 12:38:15 +01002040 case 0x106b0200: /* MacBook Pro first generation */
2041 spec->board_config = STAC_MACBOOK_PRO_V1;
2042 break;
2043 case 0x106b1e00: /* MacBook Pro second generation */
2044 spec->board_config = STAC_MACBOOK_PRO_V2;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002045 break;
Sylvain FORETf16928f2007-04-27 14:22:36 +02002046 case 0x106b0700: /* Intel-based iMac */
2047 spec->board_config = STAC_IMAC_INTEL;
2048 break;
Takashi Iwai0dae0f82007-05-21 12:41:29 +02002049 case 0x106b1700: /* Intel iMac 20 */
2050 spec->board_config = STAC_IMAC_INTEL_20;
2051 break;
Takashi Iwai3fc24d82007-02-16 13:27:18 +01002052 }
2053 }
2054
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002055 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02002056 if (spec->board_config < 0) {
2057 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
2058 "using BIOS defaults\n");
2059 err = stac92xx_save_bios_config_regs(codec);
2060 if (err < 0) {
2061 stac92xx_free(codec);
2062 return err;
2063 }
2064 spec->pin_configs = spec->bios_pin_configs;
2065 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
Matt Porter403d1942005-11-29 15:00:51 +01002066 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
2067 stac92xx_set_config_regs(codec);
2068 }
Matt2f2f4252005-04-13 14:45:30 +02002069
Matt2f2f4252005-04-13 14:45:30 +02002070 spec->adc_nids = stac922x_adc_nids;
2071 spec->mux_nids = stac922x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002072 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002073 spec->num_dmics = 0;
Mattc7d4b2f2005-06-27 14:59:41 +02002074
2075 spec->init = stac922x_core_init;
Matt2f2f4252005-04-13 14:45:30 +02002076 spec->mixer = stac922x_mixer;
Mattc7d4b2f2005-06-27 14:59:41 +02002077
2078 spec->multiout.dac_nids = spec->dac_nids;
Takashi Iwai19039bd2006-06-28 15:52:16 +02002079
Matt Porter3cc08dc2006-01-23 15:27:49 +01002080 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002081 if (!err) {
2082 if (spec->board_config < 0) {
2083 printk(KERN_WARNING "hda_codec: No auto-config is "
2084 "available, default to model=ref\n");
2085 spec->board_config = STAC_D945_REF;
2086 goto again;
2087 }
2088 err = -EINVAL;
2089 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01002090 if (err < 0) {
2091 stac92xx_free(codec);
2092 return err;
2093 }
2094
2095 codec->patch_ops = stac92xx_patch_ops;
2096
2097 return 0;
2098}
2099
2100static int patch_stac927x(struct hda_codec *codec)
2101{
2102 struct sigmatel_spec *spec;
2103 int err;
2104
2105 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2106 if (spec == NULL)
2107 return -ENOMEM;
2108
2109 codec->spec = spec;
Richard Fish11b44bb2006-08-23 18:31:34 +02002110 spec->num_pins = 14;
2111 spec->pin_nids = stac927x_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002112 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
2113 stac927x_models,
2114 stac927x_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002115 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02002116 if (spec->board_config < 0) {
Matt Porter3cc08dc2006-01-23 15:27:49 +01002117 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
Richard Fish11b44bb2006-08-23 18:31:34 +02002118 err = stac92xx_save_bios_config_regs(codec);
2119 if (err < 0) {
2120 stac92xx_free(codec);
2121 return err;
2122 }
2123 spec->pin_configs = spec->bios_pin_configs;
2124 } else if (stac927x_brd_tbl[spec->board_config] != NULL) {
Matt Porter3cc08dc2006-01-23 15:27:49 +01002125 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
2126 stac92xx_set_config_regs(codec);
2127 }
2128
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002129 switch (spec->board_config) {
Tobin Davis93ed1502006-09-01 21:03:12 +02002130 case STAC_D965_3ST:
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002131 spec->adc_nids = stac927x_adc_nids;
2132 spec->mux_nids = stac927x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002133 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002134 spec->num_dmics = 0;
Tobin Davis93ed1502006-09-01 21:03:12 +02002135 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002136 spec->mixer = stac9227_mixer;
2137 break;
Tobin Davis93ed1502006-09-01 21:03:12 +02002138 case STAC_D965_5ST:
2139 spec->adc_nids = stac927x_adc_nids;
2140 spec->mux_nids = stac927x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002141 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002142 spec->num_dmics = 0;
Tobin Davis93ed1502006-09-01 21:03:12 +02002143 spec->init = d965_core_init;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002144 spec->mixer = stac9227_mixer;
2145 break;
2146 default:
2147 spec->adc_nids = stac927x_adc_nids;
2148 spec->mux_nids = stac927x_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002149 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002150 spec->num_dmics = 0;
Tobin Davis81d3dbd2006-08-22 19:44:45 +02002151 spec->init = stac927x_core_init;
2152 spec->mixer = stac927x_mixer;
2153 }
Matt Porter3cc08dc2006-01-23 15:27:49 +01002154
2155 spec->multiout.dac_nids = spec->dac_nids;
2156
2157 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002158 if (!err) {
2159 if (spec->board_config < 0) {
2160 printk(KERN_WARNING "hda_codec: No auto-config is "
2161 "available, default to model=ref\n");
2162 spec->board_config = STAC_D965_REF;
2163 goto again;
2164 }
2165 err = -EINVAL;
2166 }
Mattc7d4b2f2005-06-27 14:59:41 +02002167 if (err < 0) {
2168 stac92xx_free(codec);
2169 return err;
2170 }
Matt2f2f4252005-04-13 14:45:30 +02002171
2172 codec->patch_ops = stac92xx_patch_ops;
2173
Takashi Iwai897cc182007-05-29 19:01:37 +02002174 /* Fix Mux capture level; max to 2 */
2175 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
2176 (0 << AC_AMPCAP_OFFSET_SHIFT) |
2177 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
2178 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2179 (0 << AC_AMPCAP_MUTE_SHIFT));
2180
Matt2f2f4252005-04-13 14:45:30 +02002181 return 0;
2182}
2183
Matt Porterf3302a52006-07-31 12:49:34 +02002184static int patch_stac9205(struct hda_codec *codec)
2185{
2186 struct sigmatel_spec *spec;
2187 int err;
2188
2189 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2190 if (spec == NULL)
2191 return -ENOMEM;
2192
2193 codec->spec = spec;
Richard Fish11b44bb2006-08-23 18:31:34 +02002194 spec->num_pins = 14;
2195 spec->pin_nids = stac9205_pin_nids;
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002196 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
2197 stac9205_models,
2198 stac9205_cfg_tbl);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002199 again:
Richard Fish11b44bb2006-08-23 18:31:34 +02002200 if (spec->board_config < 0) {
2201 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
2202 err = stac92xx_save_bios_config_regs(codec);
2203 if (err < 0) {
2204 stac92xx_free(codec);
2205 return err;
2206 }
2207 spec->pin_configs = spec->bios_pin_configs;
2208 } else {
Matt Porterf3302a52006-07-31 12:49:34 +02002209 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
2210 stac92xx_set_config_regs(codec);
2211 }
2212
2213 spec->adc_nids = stac9205_adc_nids;
2214 spec->mux_nids = stac9205_mux_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002215 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002216 spec->dmic_nids = stac9205_dmic_nids;
Takashi Iwai25494132007-03-12 12:36:16 +01002217 spec->num_dmics = ARRAY_SIZE(stac9205_dmic_nids);
Matt Porter8b657272006-10-26 17:12:59 +02002218 spec->dmux_nid = 0x1d;
Matt Porterf3302a52006-07-31 12:49:34 +02002219
2220 spec->init = stac9205_core_init;
2221 spec->mixer = stac9205_mixer;
2222
2223 spec->multiout.dac_nids = spec->dac_nids;
2224
Matt Porter33382402006-12-18 13:17:28 +01002225 /* Configure GPIO0 as EAPD output */
2226 snd_hda_codec_write(codec, codec->afg, 0,
2227 AC_VERB_SET_GPIO_DIRECTION, 0x00000001);
2228 /* Configure GPIO0 as CMOS */
2229 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0x00000000);
2230 /* Assert GPIO0 high */
2231 snd_hda_codec_write(codec, codec->afg, 0,
2232 AC_VERB_SET_GPIO_DATA, 0x00000001);
2233 /* Enable GPIO0 */
2234 snd_hda_codec_write(codec, codec->afg, 0,
2235 AC_VERB_SET_GPIO_MASK, 0x00000001);
2236
Matt Porterf3302a52006-07-31 12:49:34 +02002237 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
Takashi Iwai9e507ab2007-02-08 17:50:10 +01002238 if (!err) {
2239 if (spec->board_config < 0) {
2240 printk(KERN_WARNING "hda_codec: No auto-config is "
2241 "available, default to model=ref\n");
2242 spec->board_config = STAC_9205_REF;
2243 goto again;
2244 }
2245 err = -EINVAL;
2246 }
Matt Porterf3302a52006-07-31 12:49:34 +02002247 if (err < 0) {
2248 stac92xx_free(codec);
2249 return err;
2250 }
2251
2252 codec->patch_ops = stac92xx_patch_ops;
2253
2254 return 0;
2255}
2256
Matt2f2f4252005-04-13 14:45:30 +02002257/*
Guillaume Munch6d859062006-08-22 17:15:47 +02002258 * STAC9872 hack
Takashi Iwaidb064e52006-03-16 16:04:58 +01002259 */
2260
Guillaume Munch99ccc562006-08-16 19:35:12 +02002261/* static config for Sony VAIO FE550G and Sony VAIO AR */
Takashi Iwaidb064e52006-03-16 16:04:58 +01002262static hda_nid_t vaio_dacs[] = { 0x2 };
2263#define VAIO_HP_DAC 0x5
2264static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
2265static hda_nid_t vaio_mux_nids[] = { 0x15 };
2266
2267static struct hda_input_mux vaio_mux = {
2268 .num_items = 2,
2269 .items = {
Takashi Iwaid7737812006-04-25 13:05:43 +02002270 /* { "HP", 0x0 }, */
2271 { "Line", 0x1 },
Takashi Iwaidb064e52006-03-16 16:04:58 +01002272 { "Mic", 0x2 },
2273 { "PCM", 0x3 },
2274 }
2275};
2276
2277static struct hda_verb vaio_init[] = {
2278 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
2279 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
2280 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
2281 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
2282 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
2283 {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
2284 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
2285 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
2286 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
2287 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
2288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
2289 {}
2290};
2291
Guillaume Munch6d859062006-08-22 17:15:47 +02002292static struct hda_verb vaio_ar_init[] = {
2293 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
2294 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
2295 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
2296 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
2297/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
2298 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
2299 {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
2300 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
2301 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
2302/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
2303 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
2304 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
2305 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
2306 {}
2307};
2308
Takashi Iwaidb064e52006-03-16 16:04:58 +01002309/* bind volumes of both NID 0x02 and 0x05 */
2310static int vaio_master_vol_put(struct snd_kcontrol *kcontrol,
2311 struct snd_ctl_elem_value *ucontrol)
2312{
2313 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2314 long *valp = ucontrol->value.integer.value;
2315 int change;
2316
2317 change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
2318 0x7f, valp[0] & 0x7f);
2319 change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
2320 0x7f, valp[1] & 0x7f);
2321 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
2322 0x7f, valp[0] & 0x7f);
2323 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
2324 0x7f, valp[1] & 0x7f);
2325 return change;
2326}
2327
2328/* bind volumes of both NID 0x02 and 0x05 */
2329static int vaio_master_sw_put(struct snd_kcontrol *kcontrol,
2330 struct snd_ctl_elem_value *ucontrol)
2331{
2332 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2333 long *valp = ucontrol->value.integer.value;
2334 int change;
2335
2336 change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
Takashi Iwaia9393d72006-05-03 11:59:03 +02002337 0x80, (valp[0] ? 0 : 0x80));
Takashi Iwaidb064e52006-03-16 16:04:58 +01002338 change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
Takashi Iwaia9393d72006-05-03 11:59:03 +02002339 0x80, (valp[1] ? 0 : 0x80));
Takashi Iwaidb064e52006-03-16 16:04:58 +01002340 snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
Takashi Iwaia9393d72006-05-03 11:59:03 +02002341 0x80, (valp[0] ? 0 : 0x80));
Takashi Iwaidb064e52006-03-16 16:04:58 +01002342 snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
Takashi Iwaia9393d72006-05-03 11:59:03 +02002343 0x80, (valp[1] ? 0 : 0x80));
Takashi Iwaidb064e52006-03-16 16:04:58 +01002344 return change;
2345}
2346
2347static struct snd_kcontrol_new vaio_mixer[] = {
2348 {
2349 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2350 .name = "Master Playback Volume",
2351 .info = snd_hda_mixer_amp_volume_info,
2352 .get = snd_hda_mixer_amp_volume_get,
2353 .put = vaio_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02002354 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwaidb064e52006-03-16 16:04:58 +01002355 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2356 },
2357 {
2358 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2359 .name = "Master Playback Switch",
2360 .info = snd_hda_mixer_amp_switch_info,
2361 .get = snd_hda_mixer_amp_switch_get,
2362 .put = vaio_master_sw_put,
2363 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2364 },
2365 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2366 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
2367 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
2368 {
2369 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2370 .name = "Capture Source",
2371 .count = 1,
2372 .info = stac92xx_mux_enum_info,
2373 .get = stac92xx_mux_enum_get,
2374 .put = stac92xx_mux_enum_put,
2375 },
2376 {}
2377};
2378
Guillaume Munch6d859062006-08-22 17:15:47 +02002379static struct snd_kcontrol_new vaio_ar_mixer[] = {
2380 {
2381 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2382 .name = "Master Playback Volume",
2383 .info = snd_hda_mixer_amp_volume_info,
2384 .get = snd_hda_mixer_amp_volume_get,
2385 .put = vaio_master_vol_put,
2386 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2387 },
2388 {
2389 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2390 .name = "Master Playback Switch",
2391 .info = snd_hda_mixer_amp_switch_info,
2392 .get = snd_hda_mixer_amp_switch_get,
2393 .put = vaio_master_sw_put,
2394 .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2395 },
2396 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2397 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
2398 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
2399 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
2400 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
2401 {
2402 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2403 .name = "Capture Source",
2404 .count = 1,
2405 .info = stac92xx_mux_enum_info,
2406 .get = stac92xx_mux_enum_get,
2407 .put = stac92xx_mux_enum_put,
2408 },
2409 {}
2410};
2411
2412static struct hda_codec_ops stac9872_patch_ops = {
Takashi Iwaidb064e52006-03-16 16:04:58 +01002413 .build_controls = stac92xx_build_controls,
2414 .build_pcms = stac92xx_build_pcms,
2415 .init = stac92xx_init,
2416 .free = stac92xx_free,
2417#ifdef CONFIG_PM
2418 .resume = stac92xx_resume,
2419#endif
2420};
2421
Guillaume Munch6d859062006-08-22 17:15:47 +02002422enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
2423 CXD9872RD_VAIO,
2424 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
2425 STAC9872AK_VAIO,
2426 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
2427 STAC9872K_VAIO,
2428 /* AR Series. id=0x83847664 and subsys=104D1300 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002429 CXD9872AKD_VAIO,
2430 STAC_9872_MODELS,
2431};
Takashi Iwaidb064e52006-03-16 16:04:58 +01002432
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002433static const char *stac9872_models[STAC_9872_MODELS] = {
2434 [CXD9872RD_VAIO] = "vaio",
2435 [CXD9872AKD_VAIO] = "vaio-ar",
2436};
2437
2438static struct snd_pci_quirk stac9872_cfg_tbl[] = {
2439 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
2440 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
2441 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
Tobin Davis68e22542007-03-12 11:36:39 +01002442 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
Takashi Iwaidb064e52006-03-16 16:04:58 +01002443 {}
2444};
2445
Guillaume Munch6d859062006-08-22 17:15:47 +02002446static int patch_stac9872(struct hda_codec *codec)
Takashi Iwaidb064e52006-03-16 16:04:58 +01002447{
2448 struct sigmatel_spec *spec;
2449 int board_config;
2450
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002451 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
2452 stac9872_models,
2453 stac9872_cfg_tbl);
Takashi Iwaidb064e52006-03-16 16:04:58 +01002454 if (board_config < 0)
2455 /* unknown config, let generic-parser do its job... */
2456 return snd_hda_parse_generic_codec(codec);
2457
2458 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2459 if (spec == NULL)
2460 return -ENOMEM;
2461
2462 codec->spec = spec;
2463 switch (board_config) {
Guillaume Munch6d859062006-08-22 17:15:47 +02002464 case CXD9872RD_VAIO:
2465 case STAC9872AK_VAIO:
2466 case STAC9872K_VAIO:
Takashi Iwaidb064e52006-03-16 16:04:58 +01002467 spec->mixer = vaio_mixer;
2468 spec->init = vaio_init;
2469 spec->multiout.max_channels = 2;
2470 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
2471 spec->multiout.dac_nids = vaio_dacs;
2472 spec->multiout.hp_nid = VAIO_HP_DAC;
2473 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
2474 spec->adc_nids = vaio_adcs;
2475 spec->input_mux = &vaio_mux;
2476 spec->mux_nids = vaio_mux_nids;
2477 break;
Guillaume Munch6d859062006-08-22 17:15:47 +02002478
2479 case CXD9872AKD_VAIO:
2480 spec->mixer = vaio_ar_mixer;
2481 spec->init = vaio_ar_init;
2482 spec->multiout.max_channels = 2;
2483 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
2484 spec->multiout.dac_nids = vaio_dacs;
2485 spec->multiout.hp_nid = VAIO_HP_DAC;
2486 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
2487 spec->adc_nids = vaio_adcs;
2488 spec->input_mux = &vaio_mux;
2489 spec->mux_nids = vaio_mux_nids;
2490 break;
Takashi Iwaidb064e52006-03-16 16:04:58 +01002491 }
2492
Guillaume Munch6d859062006-08-22 17:15:47 +02002493 codec->patch_ops = stac9872_patch_ops;
Takashi Iwaidb064e52006-03-16 16:04:58 +01002494 return 0;
2495}
2496
2497
2498/*
Matt2f2f4252005-04-13 14:45:30 +02002499 * patch entries
2500 */
2501struct hda_codec_preset snd_hda_preset_sigmatel[] = {
2502 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
2503 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
2504 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
2505 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
2506 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
2507 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
2508 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
Matt Porter22a27c72006-07-06 18:49:10 +02002509 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
2510 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
2511 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
2512 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
2513 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
2514 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
Matt Porter3cc08dc2006-01-23 15:27:49 +01002515 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
2516 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
2517 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
2518 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
2519 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
2520 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
2521 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
2522 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
2523 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
2524 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
Tobin Davis8e21c342007-01-08 11:04:17 +01002525 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
2526 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
2527 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
2528 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
2529 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
2530 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
Guillaume Munch6d859062006-08-22 17:15:47 +02002531 /* The following does not take into account .id=0x83847661 when subsys =
2532 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
2533 * currently not fully supported.
2534 */
2535 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
2536 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
2537 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
Matt Porterf3302a52006-07-31 12:49:34 +02002538 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
2539 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
2540 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
2541 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
2542 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
2543 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
2544 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
2545 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
Matt2f2f4252005-04-13 14:45:30 +02002546 {} /* terminator */
2547};