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