]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/suse-2.6.27.31/patches.drivers/alsa-post-ga-hda-stac-automic
Add a patch to fix Intel E100 wake-on-lan problems.
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.31 / patches.drivers / alsa-post-ga-hda-stac-automic
1 From: Takashi Iwai <tiwai@suse.de>
2 Subject: ALSA: Update STAC/IDT codec support (auto-mic, etc)
3 Patch-mainline:
4 References: bnc#511306, bnc#520975
5
6 Backport the latest STAC/IDT codec driver to support the automatic
7 mic selection and the proper fix for docking station, etc for HP
8 and Dell laptops/desktops.
9
10 Signed-off-by: Takashi Iwai <tiwai@suse.de>
11
12 ---
13 sound/pci/hda/patch_sigmatel.c | 1791 +++++++++++++++++++++++++----------------
14 1 file changed, 1135 insertions(+), 656 deletions(-)
15
16 --- a/sound/pci/hda/patch_sigmatel.c
17 +++ b/sound/pci/hda/patch_sigmatel.c
18 @@ -35,14 +35,17 @@
19 #include "hda_patch.h"
20 #include "hda_beep.h"
21
22 -#define NUM_CONTROL_ALLOC 32
23 -
24 -#define STAC_VREF_EVENT 0x00
25 -#define STAC_INSERT_EVENT 0x10
26 -#define STAC_PWR_EVENT 0x20
27 -#define STAC_HP_EVENT 0x30
28 +enum {
29 + STAC_VREF_EVENT = 1,
30 + STAC_INSERT_EVENT,
31 + STAC_PWR_EVENT,
32 + STAC_HP_EVENT,
33 + STAC_LO_EVENT,
34 + STAC_MIC_EVENT,
35 +};
36
37 enum {
38 + STAC_AUTO,
39 STAC_REF,
40 STAC_9200_OQO,
41 STAC_9200_DELL_D21,
42 @@ -62,6 +65,7 @@
43 };
44
45 enum {
46 + STAC_9205_AUTO,
47 STAC_9205_REF,
48 STAC_9205_DELL_M42,
49 STAC_9205_DELL_M43,
50 @@ -71,6 +75,7 @@
51 };
52
53 enum {
54 + STAC_92HD73XX_AUTO,
55 STAC_92HD73XX_NO_JD, /* no jack-detection */
56 STAC_92HD73XX_REF,
57 STAC_DELL_M6_AMIC,
58 @@ -81,22 +86,28 @@
59 };
60
61 enum {
62 + STAC_92HD83XXX_AUTO,
63 STAC_92HD83XXX_REF,
64 STAC_92HD83XXX_PWR_REF,
65 + STAC_DELL_S14,
66 STAC_92HD83XXX_MODELS
67 };
68
69 enum {
70 + STAC_92HD71BXX_AUTO,
71 STAC_92HD71BXX_REF,
72 STAC_DELL_M4_1,
73 STAC_DELL_M4_2,
74 STAC_DELL_M4_3,
75 STAC_HP_M4,
76 STAC_HP_DV5,
77 + STAC_HP_HDX,
78 + STAC_HP_DV4_1222NR,
79 STAC_92HD71BXX_MODELS
80 };
81
82 enum {
83 + STAC_925x_AUTO,
84 STAC_925x_REF,
85 STAC_M1,
86 STAC_M1_2,
87 @@ -109,6 +120,7 @@
88 };
89
90 enum {
91 + STAC_922X_AUTO,
92 STAC_D945_REF,
93 STAC_D945GTP3,
94 STAC_D945GTP5,
95 @@ -136,10 +148,12 @@
96 };
97
98 enum {
99 + STAC_927X_AUTO,
100 STAC_D965_REF_NO_JD, /* no jack-detection */
101 STAC_D965_REF,
102 STAC_D965_3ST,
103 STAC_D965_5ST,
104 + STAC_D965_5ST_NO_FP,
105 STAC_DELL_3ST,
106 STAC_DELL_BIOS,
107 STAC_927X_MODELS
108 @@ -152,6 +166,18 @@
109 int data;
110 };
111
112 +struct sigmatel_jack {
113 + hda_nid_t nid;
114 + int type;
115 + struct snd_jack *jack;
116 +};
117 +
118 +struct sigmatel_mic_route {
119 + hda_nid_t pin;
120 + unsigned char mux_idx;
121 + unsigned char dmux_idx;
122 +};
123 +
124 struct sigmatel_spec {
125 struct snd_kcontrol_new *mixers[4];
126 unsigned int num_mixers;
127 @@ -163,6 +189,7 @@
128 unsigned int hp_detect: 1;
129 unsigned int spdif_mute: 1;
130 unsigned int check_volume_offset:1;
131 + unsigned int auto_mic:1;
132
133 /* gpio lines */
134 unsigned int eapd_mask;
135 @@ -170,23 +197,22 @@
136 unsigned int gpio_dir;
137 unsigned int gpio_data;
138 unsigned int gpio_mute;
139 + unsigned int gpio_led;
140
141 /* stream */
142 unsigned int stream_delay;
143
144 - /* analog loopback */
145 - unsigned char aloopback_mask;
146 - unsigned char aloopback_shift;
147 -
148 /* power management */
149 unsigned int num_pwrs;
150 unsigned int *pwr_mapping;
151 hda_nid_t *pwr_nids;
152 hda_nid_t *dac_list;
153
154 + /* jack detection */
155 + struct snd_array jacks;
156 +
157 /* events */
158 - int num_events;
159 - struct sigmatel_event events[32];
160 + struct snd_array events;
161
162 /* playback */
163 struct hda_input_mux *mono_mux;
164 @@ -210,6 +236,15 @@
165 unsigned int num_dmuxes;
166 hda_nid_t *smux_nids;
167 unsigned int num_smuxes;
168 + unsigned int num_analog_muxes;
169 +
170 + unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
171 + unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
172 + unsigned int num_caps; /* number of capture volume/switch elements */
173 +
174 + struct sigmatel_mic_route ext_mic;
175 + struct sigmatel_mic_route int_mic;
176 +
177 const char **spdif_labels;
178
179 hda_nid_t dig_in_nid;
180 @@ -245,14 +280,12 @@
181 hda_nid_t line_switch; /* shared line-in for input and output */
182 hda_nid_t mic_switch; /* shared mic-in for input and output */
183 hda_nid_t hp_switch; /* NID of HP as line-out */
184 - unsigned int aloopback;
185
186 struct hda_pcm pcm_rec[2]; /* PCM information */
187
188 /* dynamic controls and input_mux */
189 struct auto_pin_cfg autocfg;
190 - unsigned int num_kctl_alloc, num_kctl_used;
191 - struct snd_kcontrol_new *kctl_alloc;
192 + struct snd_array kctls;
193 struct hda_input_mux private_dimux;
194 struct hda_input_mux private_imux;
195 struct hda_input_mux private_smux;
196 @@ -309,6 +342,13 @@
197 0x22, 0x23,
198 };
199
200 +#define STAC92HD73XX_NUM_CAPS 2
201 +static unsigned long stac92hd73xx_capvols[] = {
202 + HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
203 + HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
204 +};
205 +#define stac92hd73xx_capsws stac92hd73xx_capvols
206 +
207 #define STAC92HD83XXX_NUM_DMICS 2
208 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
209 0x11, 0x12, 0
210 @@ -340,6 +380,13 @@
211 0xc,
212 };
213
214 +#define STAC92HD83XXX_NUM_CAPS 2
215 +static unsigned long stac92hd83xxx_capvols[] = {
216 + HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
217 + HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
218 +};
219 +#define stac92hd83xxx_capsws stac92hd83xxx_capvols
220 +
221 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
222 0x0a, 0x0d, 0x0f
223 };
224 @@ -369,6 +416,13 @@
225 0x22, 0
226 };
227
228 +#define STAC92HD71BXX_NUM_CAPS 2
229 +static unsigned long stac92hd71bxx_capvols[] = {
230 + HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
231 + HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
232 +};
233 +#define stac92hd71bxx_capsws stac92hd71bxx_capvols
234 +
235 static hda_nid_t stac925x_adc_nids[1] = {
236 0x03,
237 };
238 @@ -390,6 +444,13 @@
239 0x14,
240 };
241
242 +static unsigned long stac925x_capvols[] = {
243 + HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
244 +};
245 +static unsigned long stac925x_capsws[] = {
246 + HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
247 +};
248 +
249 static hda_nid_t stac922x_adc_nids[2] = {
250 0x06, 0x07,
251 };
252 @@ -398,6 +459,17 @@
253 0x12, 0x13,
254 };
255
256 +#define STAC922X_NUM_CAPS 2
257 +static unsigned long stac922x_capvols[] = {
258 + HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
259 + HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
260 +};
261 +#define stac922x_capsws stac922x_capvols
262 +
263 +static hda_nid_t stac927x_slave_dig_outs[2] = {
264 + 0x1f, 0,
265 +};
266 +
267 static hda_nid_t stac927x_adc_nids[3] = {
268 0x07, 0x08, 0x09
269 };
270 @@ -423,6 +495,18 @@
271 0x13, 0x14, 0
272 };
273
274 +#define STAC927X_NUM_CAPS 3
275 +static unsigned long stac927x_capvols[] = {
276 + HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
277 + HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
278 + HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
279 +};
280 +static unsigned long stac927x_capsws[] = {
281 + HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
282 + HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
283 + HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
284 +};
285 +
286 static const char *stac927x_spdif_labels[5] = {
287 "Digital Playback", "ADAT", "Analog Mux 1",
288 "Analog Mux 2", "Analog Mux 3"
289 @@ -449,6 +533,16 @@
290 0x17, 0x18, 0
291 };
292
293 +#define STAC9205_NUM_CAPS 2
294 +static unsigned long stac9205_capvols[] = {
295 + HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
296 + HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
297 +};
298 +static unsigned long stac9205_capsws[] = {
299 + HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
300 + HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
301 +};
302 +
303 static hda_nid_t stac9200_pin_nids[8] = {
304 0x08, 0x09, 0x0d, 0x0e,
305 0x0f, 0x10, 0x11, 0x12,
306 @@ -470,15 +564,21 @@
307 0x14, 0x22, 0x23
308 };
309
310 -static hda_nid_t stac92hd83xxx_pin_nids[14] = {
311 +static hda_nid_t stac92hd83xxx_pin_nids[10] = {
312 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
313 - 0x0f, 0x10, 0x11, 0x12, 0x13,
314 - 0x1d, 0x1e, 0x1f, 0x20
315 + 0x0f, 0x10, 0x11, 0x1f, 0x20,
316 +};
317 +
318 +#define STAC92HD71BXX_NUM_PINS 13
319 +static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
320 + 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
321 + 0x00, 0x14, 0x18, 0x19, 0x1e,
322 + 0x1f, 0x20, 0x27
323 };
324 -static hda_nid_t stac92hd71bxx_pin_nids[11] = {
325 +static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
326 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
327 0x0f, 0x14, 0x18, 0x19, 0x1e,
328 - 0x1f,
329 + 0x1f, 0x20, 0x27
330 };
331
332 static hda_nid_t stac927x_pin_nids[14] = {
333 @@ -521,36 +621,6 @@
334 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
335 }
336
337 -static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
338 - struct snd_ctl_elem_info *uinfo)
339 -{
340 - struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
341 - struct sigmatel_spec *spec = codec->spec;
342 - return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
343 -}
344 -
345 -static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
346 - struct snd_ctl_elem_value *ucontrol)
347 -{
348 - struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
349 - struct sigmatel_spec *spec = codec->spec;
350 - unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
351 -
352 - ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
353 - return 0;
354 -}
355 -
356 -static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
357 - struct snd_ctl_elem_value *ucontrol)
358 -{
359 - struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
360 - struct sigmatel_spec *spec = codec->spec;
361 - unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
362 -
363 - return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
364 - spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
365 -}
366 -
367 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
368 struct snd_ctl_elem_info *uinfo)
369 {
370 @@ -601,6 +671,40 @@
371 return 0;
372 }
373
374 +static unsigned int stac92xx_vref_set(struct hda_codec *codec,
375 + hda_nid_t nid, unsigned int new_vref)
376 +{
377 + int error;
378 + unsigned int pincfg;
379 + pincfg = snd_hda_codec_read(codec, nid, 0,
380 + AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
381 +
382 + pincfg &= 0xff;
383 + pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
384 + pincfg |= new_vref;
385 +
386 + if (new_vref == AC_PINCTL_VREF_HIZ)
387 + pincfg |= AC_PINCTL_OUT_EN;
388 + else
389 + pincfg |= AC_PINCTL_IN_EN;
390 +
391 + error = snd_hda_codec_write_cache(codec, nid, 0,
392 + AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
393 + if (error < 0)
394 + return error;
395 + else
396 + return 1;
397 +}
398 +
399 +static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
400 +{
401 + unsigned int vref;
402 + vref = snd_hda_codec_read(codec, nid, 0,
403 + AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
404 + vref &= AC_PINCTL_VREFEN;
405 + return vref;
406 +}
407 +
408 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
409 {
410 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
411 @@ -623,9 +727,35 @@
412 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
413 struct sigmatel_spec *spec = codec->spec;
414 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
415 + const struct hda_input_mux *imux = spec->input_mux;
416 + unsigned int idx, prev_idx;
417
418 - return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
419 - spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
420 + idx = ucontrol->value.enumerated.item[0];
421 + if (idx >= imux->num_items)
422 + idx = imux->num_items - 1;
423 + prev_idx = spec->cur_mux[adc_idx];
424 + if (prev_idx == idx)
425 + return 0;
426 + if (idx < spec->num_analog_muxes) {
427 + snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
428 + AC_VERB_SET_CONNECT_SEL,
429 + imux->items[idx].index);
430 + if (prev_idx >= spec->num_analog_muxes) {
431 + imux = spec->dinput_mux;
432 + /* 0 = analog */
433 + snd_hda_codec_write_cache(codec,
434 + spec->dmux_nids[adc_idx], 0,
435 + AC_VERB_SET_CONNECT_SEL,
436 + imux->items[0].index);
437 + }
438 + } else {
439 + imux = spec->dinput_mux;
440 + snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
441 + AC_VERB_SET_CONNECT_SEL,
442 + imux->items[idx - 1].index);
443 + }
444 + spec->cur_mux[adc_idx] = idx;
445 + return 1;
446 }
447
448 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
449 @@ -691,60 +821,6 @@
450 0, &spec->cur_amux);
451 }
452
453 -#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
454 -
455 -static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
456 - struct snd_ctl_elem_value *ucontrol)
457 -{
458 - struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
459 - unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
460 - struct sigmatel_spec *spec = codec->spec;
461 -
462 - ucontrol->value.integer.value[0] = !!(spec->aloopback &
463 - (spec->aloopback_mask << idx));
464 - return 0;
465 -}
466 -
467 -static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
468 - struct snd_ctl_elem_value *ucontrol)
469 -{
470 - struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
471 - struct sigmatel_spec *spec = codec->spec;
472 - unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
473 - unsigned int dac_mode;
474 - unsigned int val, idx_val;
475 -
476 - idx_val = spec->aloopback_mask << idx;
477 - if (ucontrol->value.integer.value[0])
478 - val = spec->aloopback | idx_val;
479 - else
480 - val = spec->aloopback & ~idx_val;
481 - if (spec->aloopback == val)
482 - return 0;
483 -
484 - spec->aloopback = val;
485 -
486 - /* Only return the bits defined by the shift value of the
487 - * first two bytes of the mask
488 - */
489 - dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
490 - kcontrol->private_value & 0xFFFF, 0x0);
491 - dac_mode >>= spec->aloopback_shift;
492 -
493 - if (spec->aloopback & idx_val) {
494 - snd_hda_power_up(codec);
495 - dac_mode |= idx_val;
496 - } else {
497 - snd_hda_power_down(codec);
498 - dac_mode &= ~idx_val;
499 - }
500 -
501 - snd_hda_codec_write_cache(codec, codec->afg, 0,
502 - kcontrol->private_value >> 16, dac_mode);
503 -
504 - return 1;
505 -}
506 -
507 static struct hda_verb stac9200_core_init[] = {
508 /* set dac0mux for dac converter */
509 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
510 @@ -840,9 +916,9 @@
511 };
512
513 static struct hda_verb stac92hd83xxx_core_init[] = {
514 - { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
515 - { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
516 - { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
517 + { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
518 + { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
519 + { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
520
521 /* power state controls amps */
522 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
523 @@ -852,26 +928,12 @@
524 static struct hda_verb stac92hd71bxx_core_init[] = {
525 /* set master volume and direct control */
526 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
527 - /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
528 - { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
529 - { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
530 - { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
531 {}
532 };
533
534 -#define HD_DISABLE_PORTF 2
535 -static struct hda_verb stac92hd71bxx_analog_core_init[] = {
536 - /* start of config #1 */
537 -
538 - /* connect port 0f to audio mixer */
539 - { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
540 - /* unmute right and left channels for node 0x0f */
541 +static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
542 + /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
543 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
544 - /* start of config #2 */
545 -
546 - /* set master volume and direct control */
547 - { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
548 - /* unmute right and left channels for nodes 0x0a, 0xd */
549 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
550 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
551 {}
552 @@ -952,31 +1014,20 @@
553 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
554 }
555
556 -#define STAC_INPUT_SOURCE(cnt) \
557 - { \
558 - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
559 - .name = "Input Source", \
560 - .count = cnt, \
561 - .info = stac92xx_mux_enum_info, \
562 - .get = stac92xx_mux_enum_get, \
563 - .put = stac92xx_mux_enum_put, \
564 - }
565 -
566 -#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
567 +#define DC_BIAS(xname, idx, nid) \
568 { \
569 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
570 - .name = "Analog Loopback", \
571 - .count = cnt, \
572 - .info = stac92xx_aloopback_info, \
573 - .get = stac92xx_aloopback_get, \
574 - .put = stac92xx_aloopback_put, \
575 - .private_value = verb_read | (verb_write << 16), \
576 + .name = xname, \
577 + .index = idx, \
578 + .info = stac92xx_dc_bias_info, \
579 + .get = stac92xx_dc_bias_get, \
580 + .put = stac92xx_dc_bias_put, \
581 + .private_value = nid, \
582 }
583
584 static struct snd_kcontrol_new stac9200_mixer[] = {
585 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
586 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
587 - STAC_INPUT_SOURCE(1),
588 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
589 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
590 { } /* end */
591 @@ -1001,26 +1052,10 @@
592 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
593 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
594
595 - STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
596 -
597 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
598 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
599 -
600 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
601 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
602 -
603 { } /* end */
604 };
605
606 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
607 - STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
608 -
609 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
610 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
611 -
612 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
613 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
614 -
615 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
616 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
617
618 @@ -1039,14 +1074,6 @@
619 };
620
621 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
622 - STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
623 -
624 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
625 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
626 -
627 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
628 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
629 -
630 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
631 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
632
633 @@ -1066,12 +1093,6 @@
634
635
636 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
637 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
638 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
639 -
640 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
641 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
642 -
643 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
644 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
645
646 @@ -1091,104 +1112,12 @@
647 { } /* end */
648 };
649
650 -static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
651 - STAC_INPUT_SOURCE(2),
652 - STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
653 -
654 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
655 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
656 -
657 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
658 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
659 - /* analog pc-beep replaced with digital beep support */
660 - /*
661 - HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
662 - HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
663 - */
664 -
665 - HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
666 - HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
667 -
668 - HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
669 - HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
670 -
671 - HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
672 - HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
673 -
674 - HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
675 - HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
676 - { } /* end */
677 -};
678 -
679 -static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
680 - STAC_INPUT_SOURCE(2),
681 - STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
682 -
683 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
684 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
685 -
686 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
687 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
688 - { } /* end */
689 -};
690 -
691 static struct snd_kcontrol_new stac925x_mixer[] = {
692 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
693 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
694 - STAC_INPUT_SOURCE(1),
695 - HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
696 - HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
697 - { } /* end */
698 -};
699 -
700 -static struct snd_kcontrol_new stac9205_mixer[] = {
701 - STAC_INPUT_SOURCE(2),
702 - STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
703 -
704 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
705 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
706 -
707 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
708 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
709 - { } /* end */
710 -};
711 -
712 -/* This needs to be generated dynamically based on sequence */
713 -static struct snd_kcontrol_new stac922x_mixer[] = {
714 - STAC_INPUT_SOURCE(2),
715 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
716 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
717 -
718 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
719 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
720 - { } /* end */
721 -};
722 -
723 -
724 -static struct snd_kcontrol_new stac927x_mixer[] = {
725 - STAC_INPUT_SOURCE(3),
726 - STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
727 -
728 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
729 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
730 -
731 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
732 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
733 -
734 - HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
735 - HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
736 { } /* end */
737 };
738
739 -static struct snd_kcontrol_new stac_dmux_mixer = {
740 - .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
741 - .name = "Digital Input Source",
742 - /* count set later */
743 - .info = stac92xx_dmux_enum_info,
744 - .get = stac92xx_dmux_enum_get,
745 - .put = stac92xx_dmux_enum_put,
746 -};
747 -
748 static struct snd_kcontrol_new stac_smux_mixer = {
749 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
750 .name = "IEC958 Playback Source",
751 @@ -1205,10 +1134,7 @@
752 "LFE Playback Volume",
753 "Side Playback Volume",
754 "Headphone Playback Volume",
755 - "Headphone2 Playback Volume",
756 "Speaker Playback Volume",
757 - "External Speaker Playback Volume",
758 - "Speaker2 Playback Volume",
759 NULL
760 };
761
762 @@ -1219,33 +1145,27 @@
763 "LFE Playback Switch",
764 "Side Playback Switch",
765 "Headphone Playback Switch",
766 - "Headphone2 Playback Switch",
767 "Speaker Playback Switch",
768 - "External Speaker Playback Switch",
769 - "Speaker2 Playback Switch",
770 "IEC958 Playback Switch",
771 NULL
772 };
773
774 +static void stac92xx_free_kctls(struct hda_codec *codec);
775 +
776 static int stac92xx_build_controls(struct hda_codec *codec)
777 {
778 struct sigmatel_spec *spec = codec->spec;
779 int err;
780 int i;
781
782 - err = snd_hda_add_new_ctls(codec, spec->mixer);
783 - if (err < 0)
784 - return err;
785 -
786 - for (i = 0; i < spec->num_mixers; i++) {
787 - err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
788 + if (spec->mixer) {
789 + err = snd_hda_add_new_ctls(codec, spec->mixer);
790 if (err < 0)
791 return err;
792 }
793 - if (spec->num_dmuxes > 0) {
794 - stac_dmux_mixer.count = spec->num_dmuxes;
795 - err = snd_ctl_add(codec->bus->card,
796 - snd_ctl_new1(&stac_dmux_mixer, codec));
797 +
798 + for (i = 0; i < spec->num_mixers; i++) {
799 + err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
800 if (err < 0)
801 return err;
802 }
803 @@ -1301,6 +1221,8 @@
804 return err;
805 }
806
807 + stac92xx_free_kctls(codec); /* no longer needed */
808 +
809 return 0;
810 }
811
812 @@ -1454,6 +1376,7 @@
813 };
814
815 static const char *stac9200_models[STAC_9200_MODELS] = {
816 + [STAC_AUTO] = "auto",
817 [STAC_REF] = "ref",
818 [STAC_9200_OQO] = "oqo",
819 [STAC_9200_DELL_D21] = "dell-d21",
820 @@ -1471,10 +1394,16 @@
821 [STAC_9200_PANASONIC] = "panasonic",
822 };
823
824 +#ifndef PCI_VENDOR_ID_DFI
825 +#define PCI_VENDOR_ID_DFI 0x106e
826 +#endif
827 +
828 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
829 /* SigmaTel reference board */
830 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
831 "DFI LanParty", STAC_REF),
832 + SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
833 + "DFI LanParty", STAC_REF),
834 /* Dell laptops have BIOS problem */
835 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
836 "unknown Dell", STAC_9200_DELL_D21),
837 @@ -1597,6 +1526,7 @@
838 };
839
840 static const char *stac925x_models[STAC_925x_MODELS] = {
841 + [STAC_925x_AUTO] = "auto",
842 [STAC_REF] = "ref",
843 [STAC_M1] = "m1",
844 [STAC_M1_2] = "m1-2",
845 @@ -1624,6 +1554,7 @@
846 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
847 /* SigmaTel reference board */
848 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
849 + SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
850 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
851
852 /* Default table for unknown ID */
853 @@ -1655,6 +1586,7 @@
854 };
855
856 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
857 + [STAC_92HD73XX_AUTO] = "auto",
858 [STAC_92HD73XX_NO_JD] = "no-jd",
859 [STAC_92HD73XX_REF] = "ref",
860 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
861 @@ -1667,6 +1599,8 @@
862 /* SigmaTel reference board */
863 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
864 "DFI LanParty", STAC_92HD73XX_REF),
865 + SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
866 + "DFI LanParty", STAC_92HD73XX_REF),
867 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
868 "Dell Studio 1535", STAC_DELL_M6_DMIC),
869 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
870 @@ -1687,55 +1621,73 @@
871 "Dell Studio 1537", STAC_DELL_M6_DMIC),
872 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
873 "Dell Studio 17", STAC_DELL_M6_DMIC),
874 + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
875 + "Dell Studio 1555", STAC_DELL_M6_DMIC),
876 {} /* terminator */
877 };
878
879 -static unsigned int ref92hd83xxx_pin_configs[14] = {
880 +static unsigned int ref92hd83xxx_pin_configs[10] = {
881 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
882 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
883 - 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
884 0x01451160, 0x98560170,
885 };
886
887 +static unsigned int dell_s14_pin_configs[10] = {
888 + 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
889 + 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
890 + 0x40f000f0, 0x40f000f0,
891 +};
892 +
893 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
894 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
895 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
896 + [STAC_DELL_S14] = dell_s14_pin_configs,
897 };
898
899 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
900 + [STAC_92HD83XXX_AUTO] = "auto",
901 [STAC_92HD83XXX_REF] = "ref",
902 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
903 + [STAC_DELL_S14] = "dell-s14",
904 };
905
906 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
907 /* SigmaTel reference board */
908 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
909 "DFI LanParty", STAC_92HD83XXX_REF),
910 + SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
911 + "DFI LanParty", STAC_92HD83XXX_REF),
912 + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
913 + "unknown Dell", STAC_DELL_S14),
914 {} /* terminator */
915 };
916
917 -static unsigned int ref92hd71bxx_pin_configs[11] = {
918 +static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
919 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
920 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
921 - 0x90a000f0, 0x01452050, 0x01452050,
922 + 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
923 + 0x00000000
924 };
925
926 -static unsigned int dell_m4_1_pin_configs[11] = {
927 +static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
928 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
929 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
930 - 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
931 + 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
932 + 0x00000000
933 };
934
935 -static unsigned int dell_m4_2_pin_configs[11] = {
936 +static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
937 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
938 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
939 - 0x40f000f0, 0x044413b0, 0x044413b0,
940 + 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
941 + 0x00000000
942 };
943
944 -static unsigned int dell_m4_3_pin_configs[11] = {
945 +static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
946 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
947 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
948 - 0x40f000f0, 0x044413b0, 0x044413b0,
949 + 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
950 + 0x00000000
951 };
952
953 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
954 @@ -1745,39 +1697,42 @@
955 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
956 [STAC_HP_M4] = NULL,
957 [STAC_HP_DV5] = NULL,
958 + [STAC_HP_HDX] = NULL,
959 + [STAC_HP_DV4_1222NR] = NULL,
960 };
961
962 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
963 + [STAC_92HD71BXX_AUTO] = "auto",
964 [STAC_92HD71BXX_REF] = "ref",
965 [STAC_DELL_M4_1] = "dell-m4-1",
966 [STAC_DELL_M4_2] = "dell-m4-2",
967 [STAC_DELL_M4_3] = "dell-m4-3",
968 [STAC_HP_M4] = "hp-m4",
969 [STAC_HP_DV5] = "hp-dv5",
970 + [STAC_HP_HDX] = "hp-hdx",
971 + [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
972 };
973
974 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
975 /* SigmaTel reference board */
976 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
977 "DFI LanParty", STAC_92HD71BXX_REF),
978 - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x308c,
979 - "HP", STAC_HP_DV5),
980 - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x308d,
981 + SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
982 + "DFI LanParty", STAC_92HD71BXX_REF),
983 + SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
984 + "HP dv4-1222nr", STAC_HP_DV4_1222NR),
985 + SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
986 "HP", STAC_HP_DV5),
987 - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
988 - "HP dv5", STAC_HP_DV5),
989 - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
990 - "HP dv7", STAC_HP_DV5),
991 - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f7,
992 - "HP dv4", STAC_HP_DV5),
993 - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fc,
994 - "HP dv7", STAC_HP_DV5),
995 - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3600,
996 - "HP dv5", STAC_HP_DV5),
997 - SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3603,
998 - "HP dv5", STAC_HP_DV5),
999 + SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1000 + "HP dv4-7", STAC_HP_DV5),
1001 + SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1002 + "HP dv4-7", STAC_HP_DV5),
1003 + SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1004 + "HP HDX", STAC_HP_HDX), /* HDX18 */
1005 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1006 - "unknown HP", STAC_HP_M4),
1007 + "HP mini 1000", STAC_HP_M4),
1008 + SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1009 + "HP HDX", STAC_HP_HDX), /* HDX16 */
1010 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1011 "unknown Dell", STAC_DELL_M4_1),
1012 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1013 @@ -1929,6 +1884,7 @@
1014 };
1015
1016 static const char *stac922x_models[STAC_922X_MODELS] = {
1017 + [STAC_922X_AUTO] = "auto",
1018 [STAC_D945_REF] = "ref",
1019 [STAC_D945GTP5] = "5stack",
1020 [STAC_D945GTP3] = "3stack",
1021 @@ -1956,6 +1912,8 @@
1022 /* SigmaTel reference board */
1023 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1024 "DFI LanParty", STAC_D945_REF),
1025 + SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1026 + "DFI LanParty", STAC_D945_REF),
1027 /* Intel 945G based systems */
1028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1029 "Intel D945G", STAC_D945GTP3),
1030 @@ -2036,31 +1994,7 @@
1031 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1032 "Dell XPS M1210", STAC_922X_DELL_M82),
1033 /* ECS/PC Chips boards */
1034 - SND_PCI_QUIRK(0x1019, 0x2144,
1035 - "ECS/PC chips", STAC_ECS_202),
1036 - SND_PCI_QUIRK(0x1019, 0x2608,
1037 - "ECS/PC chips", STAC_ECS_202),
1038 - SND_PCI_QUIRK(0x1019, 0x2633,
1039 - "ECS/PC chips P17G/1333", STAC_ECS_202),
1040 - SND_PCI_QUIRK(0x1019, 0x2811,
1041 - "ECS/PC chips", STAC_ECS_202),
1042 - SND_PCI_QUIRK(0x1019, 0x2812,
1043 - "ECS/PC chips", STAC_ECS_202),
1044 - SND_PCI_QUIRK(0x1019, 0x2813,
1045 - "ECS/PC chips", STAC_ECS_202),
1046 - SND_PCI_QUIRK(0x1019, 0x2814,
1047 - "ECS/PC chips", STAC_ECS_202),
1048 - SND_PCI_QUIRK(0x1019, 0x2815,
1049 - "ECS/PC chips", STAC_ECS_202),
1050 - SND_PCI_QUIRK(0x1019, 0x2816,
1051 - "ECS/PC chips", STAC_ECS_202),
1052 - SND_PCI_QUIRK(0x1019, 0x2817,
1053 - "ECS/PC chips", STAC_ECS_202),
1054 - SND_PCI_QUIRK(0x1019, 0x2818,
1055 - "ECS/PC chips", STAC_ECS_202),
1056 - SND_PCI_QUIRK(0x1019, 0x2819,
1057 - "ECS/PC chips", STAC_ECS_202),
1058 - SND_PCI_QUIRK(0x1019, 0x2820,
1059 + SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
1060 "ECS/PC chips", STAC_ECS_202),
1061 {} /* terminator */
1062 };
1063 @@ -2086,6 +2020,13 @@
1064 0x40000100, 0x40000100
1065 };
1066
1067 +static unsigned int d965_5st_no_fp_pin_configs[14] = {
1068 + 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
1069 + 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1070 + 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1071 + 0x40000100, 0x40000100
1072 +};
1073 +
1074 static unsigned int dell_3st_pin_configs[14] = {
1075 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1076 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1077 @@ -2098,15 +2039,18 @@
1078 [STAC_D965_REF] = ref927x_pin_configs,
1079 [STAC_D965_3ST] = d965_3st_pin_configs,
1080 [STAC_D965_5ST] = d965_5st_pin_configs,
1081 + [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
1082 [STAC_DELL_3ST] = dell_3st_pin_configs,
1083 [STAC_DELL_BIOS] = NULL,
1084 };
1085
1086 static const char *stac927x_models[STAC_927X_MODELS] = {
1087 + [STAC_927X_AUTO] = "auto",
1088 [STAC_D965_REF_NO_JD] = "ref-no-jd",
1089 [STAC_D965_REF] = "ref",
1090 [STAC_D965_3ST] = "3stack",
1091 [STAC_D965_5ST] = "5stack",
1092 + [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
1093 [STAC_DELL_3ST] = "dell-3stack",
1094 [STAC_DELL_BIOS] = "dell-bios",
1095 };
1096 @@ -2115,26 +2059,16 @@
1097 /* SigmaTel reference board */
1098 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1099 "DFI LanParty", STAC_D965_REF),
1100 + SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1101 + "DFI LanParty", STAC_D965_REF),
1102 /* Intel 946 based systems */
1103 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1104 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
1105 /* 965 based 3 stack systems */
1106 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1107 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1108 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1109 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1110 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1111 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1112 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1113 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1114 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1115 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1116 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1117 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1118 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1119 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1120 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1121 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
1122 + SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
1123 + "Intel D965", STAC_D965_3ST),
1124 + SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
1125 + "Intel D965", STAC_D965_3ST),
1126 /* Dell 3 stack systems */
1127 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
1128 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
1129 @@ -2144,21 +2078,16 @@
1130 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
1131 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
1132 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
1133 - SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
1134 + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
1135 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
1136 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
1137 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
1138 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
1139 /* 965 based 5 stack systems */
1140 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
1141 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
1142 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
1143 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
1144 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
1145 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
1146 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
1147 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
1148 - SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
1149 + SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
1150 + "Intel D965", STAC_D965_5ST),
1151 + SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
1152 + "Intel D965", STAC_D965_5ST),
1153 {} /* terminator */
1154 };
1155
1156 @@ -2215,6 +2144,7 @@
1157 };
1158
1159 static const char *stac9205_models[STAC_9205_MODELS] = {
1160 + [STAC_9205_AUTO] = "auto",
1161 [STAC_9205_REF] = "ref",
1162 [STAC_9205_DELL_M42] = "dell-m42",
1163 [STAC_9205_DELL_M43] = "dell-m43",
1164 @@ -2226,6 +2156,10 @@
1165 /* SigmaTel reference board */
1166 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1167 "DFI LanParty", STAC_9205_REF),
1168 + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
1169 + "SigmaTel", STAC_9205_REF),
1170 + SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1171 + "DFI LanParty", STAC_9205_REF),
1172 /* Dell */
1173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1174 "unknown Dell", STAC_9205_DELL_M42),
1175 @@ -2258,6 +2192,7 @@
1176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
1177 "Dell Vostro 1500", STAC_9205_DELL_M42),
1178 /* Gateway */
1179 + SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
1180 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
1181 {} /* terminator */
1182 };
1183 @@ -2515,10 +2450,18 @@
1184 return 0;
1185 }
1186
1187 -static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
1188 +#define snd_hda_query_pin_caps(codec, nid) \
1189 + snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP)
1190 +#define snd_hda_codec_get_pincfg(codec, nid) \
1191 + snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0)
1192 +#define snd_hda_codec_set_pincfg(codec, nid, val) \
1193 + stac92xx_set_config_reg(codec, nid, val)
1194 +#define get_wcaps_type(wcaps) (((wcaps) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT)
1195 +
1196 +static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
1197 + hda_nid_t nid)
1198 {
1199 - unsigned int pincap = snd_hda_param_read(codec, nid,
1200 - AC_PAR_PIN_CAP);
1201 + unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
1202 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
1203 if (pincap & AC_PINCAP_VREF_100)
1204 return AC_PINCTL_VREF_100;
1205 @@ -2550,8 +2493,7 @@
1206 return 0;
1207 }
1208
1209 -static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
1210 - unsigned char type);
1211 +static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
1212
1213 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
1214 struct snd_ctl_elem_value *ucontrol)
1215 @@ -2559,25 +2501,119 @@
1216 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1217 struct sigmatel_spec *spec = codec->spec;
1218 int nid = kcontrol->private_value;
1219 -
1220 +
1221 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
1222
1223 /* check to be sure that the ports are upto date with
1224 * switch changes
1225 */
1226 - stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
1227 + stac_issue_unsol_event(codec, nid);
1228 +
1229 return 1;
1230 }
1231
1232 -#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
1233 +static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
1234 + struct snd_ctl_elem_info *uinfo)
1235 +{
1236 + int i;
1237 + static char *texts[] = {
1238 + "Mic In", "Line In", "Line Out"
1239 + };
1240 +
1241 + struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1242 + struct sigmatel_spec *spec = codec->spec;
1243 + hda_nid_t nid = kcontrol->private_value;
1244 +
1245 + if (nid == spec->mic_switch || nid == spec->line_switch)
1246 + i = 3;
1247 + else
1248 + i = 2;
1249 +
1250 + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1251 + uinfo->value.enumerated.items = i;
1252 + uinfo->count = 1;
1253 + if (uinfo->value.enumerated.item >= i)
1254 + uinfo->value.enumerated.item = i-1;
1255 + strcpy(uinfo->value.enumerated.name,
1256 + texts[uinfo->value.enumerated.item]);
1257 +
1258 + return 0;
1259 +}
1260 +
1261 +static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
1262 + struct snd_ctl_elem_value *ucontrol)
1263 +{
1264 + struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1265 + hda_nid_t nid = kcontrol->private_value;
1266 + unsigned int vref = stac92xx_vref_get(codec, nid);
1267 +
1268 + if (vref == stac92xx_get_default_vref(codec, nid))
1269 + ucontrol->value.enumerated.item[0] = 0;
1270 + else if (vref == AC_PINCTL_VREF_GRD)
1271 + ucontrol->value.enumerated.item[0] = 1;
1272 + else if (vref == AC_PINCTL_VREF_HIZ)
1273 + ucontrol->value.enumerated.item[0] = 2;
1274 +
1275 + return 0;
1276 +}
1277 +
1278 +static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
1279 + struct snd_ctl_elem_value *ucontrol)
1280 +{
1281 + struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1282 + unsigned int new_vref = 0;
1283 + int error;
1284 + hda_nid_t nid = kcontrol->private_value;
1285 +
1286 + if (ucontrol->value.enumerated.item[0] == 0)
1287 + new_vref = stac92xx_get_default_vref(codec, nid);
1288 + else if (ucontrol->value.enumerated.item[0] == 1)
1289 + new_vref = AC_PINCTL_VREF_GRD;
1290 + else if (ucontrol->value.enumerated.item[0] == 2)
1291 + new_vref = AC_PINCTL_VREF_HIZ;
1292 + else
1293 + return 0;
1294 +
1295 + if (new_vref != stac92xx_vref_get(codec, nid)) {
1296 + error = stac92xx_vref_set(codec, nid, new_vref);
1297 + return error;
1298 + }
1299 +
1300 + return 0;
1301 +}
1302 +
1303 +static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
1304 + struct snd_ctl_elem_info *uinfo)
1305 +{
1306 + static char *texts[2];
1307 + struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1308 + struct sigmatel_spec *spec = codec->spec;
1309 +
1310 + if (kcontrol->private_value == spec->line_switch)
1311 + texts[0] = "Line In";
1312 + else
1313 + texts[0] = "Mic In";
1314 + texts[1] = "Line Out";
1315 + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1316 + uinfo->value.enumerated.items = 2;
1317 + uinfo->count = 1;
1318 +
1319 + if (uinfo->value.enumerated.item >= 2)
1320 + uinfo->value.enumerated.item = 1;
1321 + strcpy(uinfo->value.enumerated.name,
1322 + texts[uinfo->value.enumerated.item]);
1323 +
1324 + return 0;
1325 +}
1326
1327 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1328 {
1329 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1330 struct sigmatel_spec *spec = codec->spec;
1331 - int io_idx = kcontrol-> private_value & 0xff;
1332 + hda_nid_t nid = kcontrol->private_value;
1333 + int io_idx = (nid == spec->mic_switch) ? 1 : 0;
1334
1335 - ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
1336 + ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
1337 return 0;
1338 }
1339
1340 @@ -2585,9 +2621,9 @@
1341 {
1342 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1343 struct sigmatel_spec *spec = codec->spec;
1344 - hda_nid_t nid = kcontrol->private_value >> 8;
1345 - int io_idx = kcontrol-> private_value & 0xff;
1346 - unsigned short val = !!ucontrol->value.integer.value[0];
1347 + hda_nid_t nid = kcontrol->private_value;
1348 + int io_idx = (nid == spec->mic_switch) ? 1 : 0;
1349 + unsigned short val = !!ucontrol->value.enumerated.item[0];
1350
1351 spec->io_switch[io_idx] = val;
1352
1353 @@ -2596,7 +2632,7 @@
1354 else {
1355 unsigned int pinctl = AC_PINCTL_IN_EN;
1356 if (io_idx) /* set VREF for mic */
1357 - pinctl |= stac92xx_get_vref(codec, nid);
1358 + pinctl |= stac92xx_get_default_vref(codec, nid);
1359 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1360 }
1361
1362 @@ -2604,7 +2640,7 @@
1363 * appropriately according to the pin direction
1364 */
1365 if (spec->hp_detect)
1366 - stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
1367 + stac_issue_unsol_event(codec, nid);
1368
1369 return 1;
1370 }
1371 @@ -2677,7 +2713,8 @@
1372 STAC_CTL_WIDGET_AMP_VOL,
1373 STAC_CTL_WIDGET_HP_SWITCH,
1374 STAC_CTL_WIDGET_IO_SWITCH,
1375 - STAC_CTL_WIDGET_CLFE_SWITCH
1376 + STAC_CTL_WIDGET_CLFE_SWITCH,
1377 + STAC_CTL_WIDGET_DC_BIAS
1378 };
1379
1380 static struct snd_kcontrol_new stac92xx_control_templates[] = {
1381 @@ -2689,38 +2726,42 @@
1382 STAC_CODEC_HP_SWITCH(NULL),
1383 STAC_CODEC_IO_SWITCH(NULL, 0),
1384 STAC_CODEC_CLFE_SWITCH(NULL, 0),
1385 + DC_BIAS(NULL, 0, 0),
1386 };
1387
1388 /* add dynamic controls */
1389 -static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
1390 - struct snd_kcontrol_new *ktemp,
1391 - int idx, const char *name,
1392 - unsigned long val)
1393 +static struct snd_kcontrol_new *
1394 +stac_control_new(struct sigmatel_spec *spec,
1395 + struct snd_kcontrol_new *ktemp,
1396 + const char *name)
1397 {
1398 struct snd_kcontrol_new *knew;
1399
1400 - if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1401 - int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1402 -
1403 - knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1404 - if (! knew)
1405 - return -ENOMEM;
1406 - if (spec->kctl_alloc) {
1407 - memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1408 - kfree(spec->kctl_alloc);
1409 - }
1410 - spec->kctl_alloc = knew;
1411 - spec->num_kctl_alloc = num;
1412 - }
1413 -
1414 - knew = &spec->kctl_alloc[spec->num_kctl_used];
1415 + snd_array_init(&spec->kctls, sizeof(*knew), 32);
1416 + knew = snd_array_new(&spec->kctls);
1417 + if (!knew)
1418 + return NULL;
1419 *knew = *ktemp;
1420 - knew->index = idx;
1421 knew->name = kstrdup(name, GFP_KERNEL);
1422 - if (!knew->name)
1423 + if (!knew->name) {
1424 + /* roolback */
1425 + memset(knew, 0, sizeof(*knew));
1426 + spec->kctls.alloced--;
1427 + return NULL;
1428 + }
1429 + return knew;
1430 +}
1431 +
1432 +static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
1433 + struct snd_kcontrol_new *ktemp,
1434 + int idx, const char *name,
1435 + unsigned long val)
1436 +{
1437 + struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
1438 + if (!knew)
1439 return -ENOMEM;
1440 + knew->index = idx;
1441 knew->private_value = val;
1442 - spec->num_kctl_used++;
1443 return 0;
1444 }
1445
1446 @@ -2741,7 +2782,60 @@
1447 return stac92xx_add_control_idx(spec, type, 0, name, val);
1448 }
1449
1450 -/* check whether the line-input can be used as line-out */
1451 +static struct snd_kcontrol_new stac_input_src_temp = {
1452 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1453 + .name = "Input Source",
1454 + .info = stac92xx_mux_enum_info,
1455 + .get = stac92xx_mux_enum_get,
1456 + .put = stac92xx_mux_enum_put,
1457 +};
1458 +
1459 +static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
1460 + hda_nid_t nid, int idx)
1461 +{
1462 + int def_conf = snd_hda_codec_get_pincfg(codec, nid);
1463 + int control = 0;
1464 + struct sigmatel_spec *spec = codec->spec;
1465 + char name[22];
1466 +
1467 + if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
1468 + if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
1469 + && nid == spec->line_switch)
1470 + control = STAC_CTL_WIDGET_IO_SWITCH;
1471 + else if (snd_hda_query_pin_caps(codec, nid)
1472 + & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
1473 + control = STAC_CTL_WIDGET_DC_BIAS;
1474 + else if (nid == spec->mic_switch)
1475 + control = STAC_CTL_WIDGET_IO_SWITCH;
1476 + }
1477 +
1478 + if (control) {
1479 + strcpy(name, auto_pin_cfg_labels[idx]);
1480 + return stac92xx_add_control(codec->spec, control,
1481 + strcat(name, " Jack Mode"), nid);
1482 + }
1483 +
1484 + return 0;
1485 +}
1486 +
1487 +static int stac92xx_add_input_source(struct sigmatel_spec *spec)
1488 +{
1489 + struct snd_kcontrol_new *knew;
1490 + struct hda_input_mux *imux = &spec->private_imux;
1491 +
1492 + if (spec->auto_mic)
1493 + return 0; /* no need for input source */
1494 + if (!spec->num_adcs || imux->num_items <= 1)
1495 + return 0; /* no need for input source control */
1496 + knew = stac_control_new(spec, &stac_input_src_temp,
1497 + stac_input_src_temp.name);
1498 + if (!knew)
1499 + return -ENOMEM;
1500 + knew->count = spec->num_adcs;
1501 + return 0;
1502 +}
1503 +
1504 +/* check whether the line-input can be used as line-out */
1505 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
1506 {
1507 struct sigmatel_spec *spec = codec->spec;
1508 @@ -2752,7 +2846,7 @@
1509 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
1510 return 0;
1511 nid = cfg->input_pins[AUTO_PIN_LINE];
1512 - pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
1513 + pincap = snd_hda_query_pin_caps(codec, nid);
1514 if (pincap & AC_PINCAP_OUT)
1515 return nid;
1516 return 0;
1517 @@ -2771,12 +2865,11 @@
1518 mic_pin = AUTO_PIN_MIC;
1519 for (;;) {
1520 hda_nid_t nid = cfg->input_pins[mic_pin];
1521 - def_conf = snd_hda_codec_read(codec, nid, 0,
1522 - AC_VERB_GET_CONFIG_DEFAULT, 0);
1523 + def_conf = snd_hda_codec_get_pincfg(codec, nid);
1524 /* some laptops have an internal analog microphone
1525 * which can't be used as a output */
1526 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
1527 - pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
1528 + pincap = snd_hda_query_pin_caps(codec, nid);
1529 if (pincap & AC_PINCAP_OUT)
1530 return nid;
1531 }
1532 @@ -2824,9 +2917,8 @@
1533 conn_len = snd_hda_get_connections(codec, nid, conn,
1534 HDA_MAX_CONNECTIONS);
1535 for (j = 0; j < conn_len; j++) {
1536 - wcaps = snd_hda_param_read(codec, conn[j],
1537 - AC_PAR_AUDIO_WIDGET_CAP);
1538 - wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1539 + wcaps = get_wcaps(codec, conn[j]);
1540 + wtype = get_wcaps_type(wcaps);
1541 /* we check only analog outputs */
1542 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
1543 continue;
1544 @@ -2840,6 +2932,16 @@
1545 return conn[j];
1546 }
1547 }
1548 + /* if all DACs are already assigned, connect to the primary DAC */
1549 + if (conn_len > 1) {
1550 + for (j = 0; j < conn_len; j++) {
1551 + if (conn[j] == spec->multiout.dac_nids[0]) {
1552 + snd_hda_codec_write_cache(codec, nid, 0,
1553 + AC_VERB_SET_CONNECT_SEL, j);
1554 + break;
1555 + }
1556 + }
1557 + }
1558 return 0;
1559 }
1560
1561 @@ -2880,6 +2982,26 @@
1562 add_spec_dacs(spec, dac);
1563 }
1564
1565 + for (i = 0; i < cfg->hp_outs; i++) {
1566 + nid = cfg->hp_pins[i];
1567 + dac = get_unassigned_dac(codec, nid);
1568 + if (dac) {
1569 + if (!spec->multiout.hp_nid)
1570 + spec->multiout.hp_nid = dac;
1571 + else
1572 + add_spec_extra_dacs(spec, dac);
1573 + }
1574 + spec->hp_dacs[i] = dac;
1575 + }
1576 +
1577 + for (i = 0; i < cfg->speaker_outs; i++) {
1578 + nid = cfg->speaker_pins[i];
1579 + dac = get_unassigned_dac(codec, nid);
1580 + if (dac)
1581 + add_spec_extra_dacs(spec, dac);
1582 + spec->speaker_dacs[i] = dac;
1583 + }
1584 +
1585 /* add line-in as output */
1586 nid = check_line_out_switch(codec);
1587 if (nid) {
1588 @@ -2907,26 +3029,6 @@
1589 }
1590 }
1591
1592 - for (i = 0; i < cfg->hp_outs; i++) {
1593 - nid = cfg->hp_pins[i];
1594 - dac = get_unassigned_dac(codec, nid);
1595 - if (dac) {
1596 - if (!spec->multiout.hp_nid)
1597 - spec->multiout.hp_nid = dac;
1598 - else
1599 - add_spec_extra_dacs(spec, dac);
1600 - }
1601 - spec->hp_dacs[i] = dac;
1602 - }
1603 -
1604 - for (i = 0; i < cfg->speaker_outs; i++) {
1605 - nid = cfg->speaker_pins[i];
1606 - dac = get_unassigned_dac(codec, nid);
1607 - if (dac)
1608 - add_spec_extra_dacs(spec, dac);
1609 - spec->speaker_dacs[i] = dac;
1610 - }
1611 -
1612 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
1613 spec->multiout.num_dacs,
1614 spec->multiout.dac_nids[0],
1615 @@ -2939,8 +3041,8 @@
1616 }
1617
1618 /* create volume control/switch for the given prefx type */
1619 -static int create_controls(struct hda_codec *codec, const char *pfx,
1620 - hda_nid_t nid, int chs)
1621 +static int create_controls_idx(struct hda_codec *codec, const char *pfx,
1622 + int idx, hda_nid_t nid, int chs)
1623 {
1624 struct sigmatel_spec *spec = codec->spec;
1625 char name[32];
1626 @@ -2964,19 +3066,22 @@
1627 }
1628
1629 sprintf(name, "%s Playback Volume", pfx);
1630 - err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
1631 + err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
1632 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
1633 spec->volume_offset));
1634 if (err < 0)
1635 return err;
1636 sprintf(name, "%s Playback Switch", pfx);
1637 - err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
1638 + err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
1639 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1640 if (err < 0)
1641 return err;
1642 return 0;
1643 }
1644
1645 +#define create_controls(codec, pfx, nid, chs) \
1646 + create_controls_idx(codec, pfx, 0, nid, chs)
1647 +
1648 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
1649 {
1650 if (spec->multiout.num_dacs > 4) {
1651 @@ -3014,12 +3119,6 @@
1652 static const char *chname[4] = {
1653 "Front", "Surround", NULL /*CLFE*/, "Side"
1654 };
1655 - static const char *hp_pfxs[] = {
1656 - "Headphone", "Headphone2", "Headphone3", "Headphone4"
1657 - };
1658 - static const char *speaker_pfxs[] = {
1659 - "Speaker", "External Speaker", "Speaker2", "Speaker3"
1660 - };
1661 hda_nid_t nid;
1662 int i, err;
1663 unsigned int wid_caps;
1664 @@ -3055,18 +3154,22 @@
1665
1666 } else {
1667 const char *name;
1668 + int idx;
1669 switch (type) {
1670 case AUTO_PIN_HP_OUT:
1671 - name = hp_pfxs[i];
1672 + name = "Headphone";
1673 + idx = i;
1674 break;
1675 case AUTO_PIN_SPEAKER_OUT:
1676 - name = speaker_pfxs[i];
1677 + name = "Speaker";
1678 + idx = i;
1679 break;
1680 default:
1681 name = chname[i];
1682 + idx = 0;
1683 break;
1684 }
1685 - err = create_controls(codec, name, nid, 3);
1686 + err = create_controls_idx(codec, name, idx, nid, 3);
1687 if (err < 0)
1688 return err;
1689 }
1690 @@ -3074,12 +3177,29 @@
1691 return 0;
1692 }
1693
1694 +static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
1695 + unsigned long sw, int idx)
1696 +{
1697 + int err;
1698 + err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
1699 + "Capture Volume", vol);
1700 + if (err < 0)
1701 + return err;
1702 + err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
1703 + "Capture Switch", sw);
1704 + if (err < 0)
1705 + return err;
1706 + return 0;
1707 +}
1708 +
1709 /* add playback controls from the parsed DAC table */
1710 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
1711 const struct auto_pin_cfg *cfg)
1712 {
1713 struct sigmatel_spec *spec = codec->spec;
1714 + hda_nid_t nid;
1715 int err;
1716 + int idx;
1717
1718 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
1719 spec->multiout.dac_nids,
1720 @@ -3096,20 +3216,13 @@
1721 return err;
1722 }
1723
1724 - if (spec->line_switch) {
1725 - err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
1726 - "Line In as Output Switch",
1727 - spec->line_switch << 8);
1728 - if (err < 0)
1729 - return err;
1730 - }
1731 -
1732 - if (spec->mic_switch) {
1733 - err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
1734 - "Mic as Output Switch",
1735 - (spec->mic_switch << 8) | 1);
1736 - if (err < 0)
1737 - return err;
1738 + for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
1739 + nid = cfg->input_pins[idx];
1740 + if (nid) {
1741 + err = stac92xx_add_jack_mode_control(codec, nid, idx);
1742 + if (err < 0)
1743 + return err;
1744 + }
1745 }
1746
1747 return 0;
1748 @@ -3152,7 +3265,7 @@
1749 spec->mono_nid,
1750 con_lst,
1751 HDA_MAX_NUM_INPUTS);
1752 - if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
1753 + if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
1754 return -EINVAL;
1755
1756 for (i = 0; i < num_cons; i++) {
1757 @@ -3298,7 +3411,7 @@
1758 spec->smux_nids[0],
1759 con_lst,
1760 HDA_MAX_NUM_INPUTS);
1761 - if (!num_cons)
1762 + if (num_cons <= 0)
1763 return -EINVAL;
1764
1765 if (!labels)
1766 @@ -3319,53 +3432,66 @@
1767 "Digital Mic 3", "Digital Mic 4"
1768 };
1769
1770 +static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1771 + hda_nid_t nid)
1772 +{
1773 + hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1774 + int i, nums;
1775 +
1776 + nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1777 + for (i = 0; i < nums; i++)
1778 + if (conn[i] == nid)
1779 + return i;
1780 + return -1;
1781 +}
1782 +
1783 /* create playback/capture controls for input pins on dmic capable codecs */
1784 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
1785 const struct auto_pin_cfg *cfg)
1786 {
1787 struct sigmatel_spec *spec = codec->spec;
1788 + struct hda_input_mux *imux = &spec->private_imux;
1789 struct hda_input_mux *dimux = &spec->private_dimux;
1790 - hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1791 - int err, i, j;
1792 + int err, i, active_mics;
1793 + unsigned int def_conf;
1794 char name[32];
1795
1796 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
1797 dimux->items[dimux->num_items].index = 0;
1798 dimux->num_items++;
1799
1800 + active_mics = 0;
1801 + for (i = 0; i < spec->num_dmics; i++) {
1802 + def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
1803 + if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
1804 + active_mics++;
1805 + }
1806 +
1807 for (i = 0; i < spec->num_dmics; i++) {
1808 hda_nid_t nid;
1809 int index;
1810 - int num_cons;
1811 unsigned int wcaps;
1812 - unsigned int def_conf;
1813 + const char *label;
1814
1815 - def_conf = snd_hda_codec_read(codec,
1816 - spec->dmic_nids[i],
1817 - 0,
1818 - AC_VERB_GET_CONFIG_DEFAULT,
1819 - 0);
1820 + def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
1821 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
1822 continue;
1823
1824 nid = spec->dmic_nids[i];
1825 - num_cons = snd_hda_get_connections(codec,
1826 - spec->dmux_nids[0],
1827 - con_lst,
1828 - HDA_MAX_NUM_INPUTS);
1829 - for (j = 0; j < num_cons; j++)
1830 - if (con_lst[j] == nid) {
1831 - index = j;
1832 - goto found;
1833 - }
1834 - continue;
1835 -found:
1836 + index = get_connection_index(codec, spec->dmux_nids[0], nid);
1837 + if (index < 0)
1838 + continue;
1839 +
1840 + if (active_mics == 1)
1841 + label = "Digital Mic";
1842 + else
1843 + label = stac92xx_dmic_labels[dimux->num_items];
1844 +
1845 wcaps = get_wcaps(codec, nid) &
1846 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
1847
1848 if (wcaps) {
1849 - sprintf(name, "%s Capture Volume",
1850 - stac92xx_dmic_labels[dimux->num_items]);
1851 + sprintf(name, "%s Capture Volume", label);
1852
1853 err = stac92xx_add_control(spec,
1854 STAC_CTL_WIDGET_VOL,
1855 @@ -3377,15 +3503,100 @@
1856 return err;
1857 }
1858
1859 - dimux->items[dimux->num_items].label =
1860 - stac92xx_dmic_labels[dimux->num_items];
1861 + dimux->items[dimux->num_items].label = label;
1862 dimux->items[dimux->num_items].index = index;
1863 dimux->num_items++;
1864 +
1865 + imux->items[imux->num_items].label = label;
1866 + imux->items[imux->num_items].index = index;
1867 + imux->num_items++;
1868 }
1869
1870 return 0;
1871 }
1872
1873 +static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
1874 + hda_nid_t *fixed, hda_nid_t *ext)
1875 +{
1876 + unsigned int cfg;
1877 +
1878 + if (!nid)
1879 + return 0;
1880 + cfg = snd_hda_codec_get_pincfg(codec, nid);
1881 + switch (get_defcfg_connect(cfg)) {
1882 + case AC_JACK_PORT_FIXED:
1883 + if (*fixed)
1884 + return 1; /* already occupied */
1885 + *fixed = nid;
1886 + break;
1887 + case AC_JACK_PORT_COMPLEX:
1888 + if (*ext)
1889 + return 1; /* already occupied */
1890 + *ext = nid;
1891 + break;
1892 + }
1893 + return 0;
1894 +}
1895 +
1896 +static int set_mic_route(struct hda_codec *codec,
1897 + struct sigmatel_mic_route *mic,
1898 + hda_nid_t pin)
1899 +{
1900 + struct sigmatel_spec *spec = codec->spec;
1901 + struct auto_pin_cfg *cfg = &spec->autocfg;
1902 + int i;
1903 +
1904 + mic->pin = pin;
1905 + for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
1906 + if (pin == cfg->input_pins[i])
1907 + break;
1908 + if (i <= AUTO_PIN_FRONT_MIC) {
1909 + /* analog pin */
1910 + mic->dmux_idx = 0;
1911 + i = get_connection_index(codec, spec->mux_nids[0], pin);
1912 + if (i < 0)
1913 + return -1;
1914 + mic->mux_idx = i;
1915 + } else if (spec->dmux_nids) {
1916 + /* digital pin */
1917 + mic->mux_idx = 0;
1918 + i = get_connection_index(codec, spec->dmux_nids[0], pin);
1919 + if (i < 0)
1920 + return -1;
1921 + mic->dmux_idx = i;
1922 + }
1923 + return 0;
1924 +}
1925 +
1926 +/* return non-zero if the device is for automatic mic switch */
1927 +static int stac_check_auto_mic(struct hda_codec *codec)
1928 +{
1929 + struct sigmatel_spec *spec = codec->spec;
1930 + struct auto_pin_cfg *cfg = &spec->autocfg;
1931 + hda_nid_t fixed, ext;
1932 + int i;
1933 +
1934 + for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) {
1935 + if (cfg->input_pins[i])
1936 + return 0; /* must be exclusively mics */
1937 + }
1938 + fixed = ext = 0;
1939 + for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
1940 + if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext))
1941 + return 0;
1942 + for (i = 0; i < spec->num_dmics; i++)
1943 + if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext))
1944 + return 0;
1945 + if (!fixed || !ext)
1946 + return 0;
1947 + if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1948 + return 0; /* no unsol support */
1949 + if (set_mic_route(codec, &spec->ext_mic, ext) ||
1950 + set_mic_route(codec, &spec->int_mic, fixed))
1951 + return 0; /* something is wrong */
1952 + return 1;
1953 +}
1954 +
1955 /* create playback/capture controls for input pins */
1956 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
1957 {
1958 @@ -3418,6 +3629,7 @@
1959 imux->items[imux->num_items].index = index;
1960 imux->num_items++;
1961 }
1962 + spec->num_analog_muxes = imux->num_items;
1963
1964 if (imux->num_items) {
1965 /*
1966 @@ -3469,7 +3681,7 @@
1967 {
1968 struct sigmatel_spec *spec = codec->spec;
1969 int hp_swap = 0;
1970 - int err;
1971 + int i, err;
1972
1973 if ((err = snd_hda_parse_pin_def_config(codec,
1974 &spec->autocfg,
1975 @@ -3509,11 +3721,10 @@
1976 if (snd_hda_get_connections(codec,
1977 spec->autocfg.mono_out_pin, conn_list, 1) &&
1978 snd_hda_get_connections(codec, conn_list[0],
1979 - conn_list, 1)) {
1980 + conn_list, 1) > 0) {
1981
1982 int wcaps = get_wcaps(codec, conn_list[0]);
1983 - int wid_type = (wcaps & AC_WCAP_TYPE)
1984 - >> AC_WCAP_TYPE_SHIFT;
1985 + int wid_type = get_wcaps_type(wcaps);
1986 /* LR swap check, some stac925x have a mux that
1987 * changes the DACs output path instead of the
1988 * mono-mux path.
1989 @@ -3578,6 +3789,8 @@
1990 err = snd_hda_attach_beep_device(codec, nid);
1991 if (err < 0)
1992 return err;
1993 + /* IDT/STAC codecs have linear beep tone parameter */
1994 + /*codec->beep->linear_tone = 1;*/
1995 /* if no beep switch is available, make its own one */
1996 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
1997 if (codec->beep &&
1998 @@ -3602,6 +3815,21 @@
1999 spec->autocfg.line_outs = 0;
2000 }
2001
2002 + if (stac_check_auto_mic(codec)) {
2003 + spec->auto_mic = 1;
2004 + /* only one capture for auto-mic */
2005 + spec->num_adcs = 1;
2006 + spec->num_caps = 1;
2007 + spec->num_muxes = 1;
2008 + }
2009 +
2010 + for (i = 0; i < spec->num_caps; i++) {
2011 + err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
2012 + spec->capsws[i], i);
2013 + if (err < 0)
2014 + return err;
2015 + }
2016 +
2017 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
2018 if (err < 0)
2019 return err;
2020 @@ -3631,6 +3859,10 @@
2021 return err;
2022 }
2023
2024 + err = stac92xx_add_input_source(spec);
2025 + if (err < 0)
2026 + return err;
2027 +
2028 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2029 if (spec->multiout.max_channels > 2)
2030 spec->surr_switch = 1;
2031 @@ -3640,8 +3872,8 @@
2032 if (dig_in && spec->autocfg.dig_in_pin)
2033 spec->dig_in_nid = dig_in;
2034
2035 - if (spec->kctl_alloc)
2036 - spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2037 + if (spec->kctls.list)
2038 + spec->mixers[spec->num_mixers++] = spec->kctls.list;
2039
2040 spec->input_mux = &spec->private_imux;
2041 if (!spec->dinput_mux)
2042 @@ -3698,9 +3930,7 @@
2043 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
2044 hda_nid_t pin = spec->autocfg.line_out_pins[i];
2045 unsigned int defcfg;
2046 - defcfg = snd_hda_codec_read(codec, pin, 0,
2047 - AC_VERB_GET_CONFIG_DEFAULT,
2048 - 0x00);
2049 + defcfg = snd_hda_codec_get_pincfg(codec, pin);
2050 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
2051 unsigned int wcaps = get_wcaps(codec, pin);
2052 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2053 @@ -3744,13 +3974,17 @@
2054 return err;
2055 }
2056
2057 + err = stac92xx_add_input_source(spec);
2058 + if (err < 0)
2059 + return err;
2060 +
2061 if (spec->autocfg.dig_out_pin)
2062 spec->multiout.dig_out_nid = 0x05;
2063 if (spec->autocfg.dig_in_pin)
2064 spec->dig_in_nid = 0x04;
2065
2066 - if (spec->kctl_alloc)
2067 - spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2068 + if (spec->kctls.list)
2069 + spec->mixers[spec->num_mixers++] = spec->kctls.list;
2070
2071 spec->input_mux = &spec->private_imux;
2072 spec->dinput_mux = &spec->private_dimux;
2073 @@ -3799,26 +4033,27 @@
2074 {
2075 struct sigmatel_event *event;
2076
2077 - if (spec->num_events >= ARRAY_SIZE(spec->events))
2078 + snd_array_init(&spec->events, sizeof(*event), 32);
2079 + event = snd_array_new(&spec->events);
2080 + if (!event)
2081 return -ENOMEM;
2082 - event = &spec->events[spec->num_events++];
2083 event->nid = nid;
2084 event->type = type;
2085 - event->tag = spec->num_events;
2086 + event->tag = spec->events.used;
2087 event->data = data;
2088
2089 return event->tag;
2090 }
2091
2092 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
2093 - hda_nid_t nid, unsigned char type)
2094 + hda_nid_t nid)
2095 {
2096 struct sigmatel_spec *spec = codec->spec;
2097 - struct sigmatel_event *event = spec->events;
2098 + struct sigmatel_event *event = spec->events.list;
2099 int i;
2100
2101 - for (i = 0; i < spec->num_events; i++, event++) {
2102 - if (event->nid == nid && event->type == type)
2103 + for (i = 0; i < spec->events.used; i++, event++) {
2104 + if (event->nid == nid)
2105 return event;
2106 }
2107 return NULL;
2108 @@ -3828,34 +4063,42 @@
2109 unsigned char tag)
2110 {
2111 struct sigmatel_spec *spec = codec->spec;
2112 - struct sigmatel_event *event = spec->events;
2113 + struct sigmatel_event *event = spec->events.list;
2114 int i;
2115
2116 - for (i = 0; i < spec->num_events; i++, event++) {
2117 + for (i = 0; i < spec->events.used; i++, event++) {
2118 if (event->tag == tag)
2119 return event;
2120 }
2121 return NULL;
2122 }
2123
2124 -static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
2125 - unsigned int type)
2126 +/* check if given nid is a valid pin and no other events are assigned
2127 + * to it. If OK, assign the event, set the unsol flag, and returns 1.
2128 + * Otherwise, returns zero.
2129 + */
2130 +static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
2131 + unsigned int type)
2132 {
2133 struct sigmatel_event *event;
2134 int tag;
2135
2136 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
2137 - return;
2138 - event = stac_get_event(codec, nid, type);
2139 - if (event)
2140 + return 0;
2141 + event = stac_get_event(codec, nid);
2142 + if (event) {
2143 + if (event->type != type)
2144 + return 0;
2145 tag = event->tag;
2146 - else
2147 + } else {
2148 tag = stac_add_event(codec->spec, nid, type, 0);
2149 - if (tag < 0)
2150 - return;
2151 + if (tag < 0)
2152 + return 0;
2153 + }
2154 snd_hda_codec_write_cache(codec, nid, 0,
2155 AC_VERB_SET_UNSOLICITED_ENABLE,
2156 AC_USRSP_EN | tag);
2157 + return 1;
2158 }
2159
2160 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
2161 @@ -3915,46 +4158,64 @@
2162 hda_nid_t nid = cfg->hp_pins[i];
2163 enable_pin_detect(codec, nid, STAC_HP_EVENT);
2164 }
2165 + if (cfg->line_out_type == AUTO_PIN_LINE_OUT) {
2166 + /* enable pin-detect for line-outs as well */
2167 + for (i = 0; i < cfg->line_outs; i++) {
2168 + hda_nid_t nid = cfg->line_out_pins[i];
2169 + enable_pin_detect(codec, nid, STAC_LO_EVENT);
2170 + }
2171 + }
2172 +
2173 /* force to enable the first line-out; the others are set up
2174 * in unsol_event
2175 */
2176 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
2177 - AC_PINCTL_OUT_EN);
2178 + AC_PINCTL_OUT_EN);
2179 /* fake event to set up pins */
2180 - stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
2181 - STAC_HP_EVENT);
2182 + stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
2183 } else {
2184 stac92xx_auto_init_multi_out(codec);
2185 stac92xx_auto_init_hp_out(codec);
2186 for (i = 0; i < cfg->hp_outs; i++)
2187 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
2188 }
2189 + if (spec->auto_mic) {
2190 + /* initialize connection to analog input */
2191 + if (spec->dmux_nids)
2192 + snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
2193 + AC_VERB_SET_CONNECT_SEL, 0);
2194 + if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
2195 + stac_issue_unsol_event(codec, spec->ext_mic.pin);
2196 + }
2197 for (i = 0; i < AUTO_PIN_LAST; i++) {
2198 hda_nid_t nid = cfg->input_pins[i];
2199 if (nid) {
2200 unsigned int pinctl, conf;
2201 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
2202 /* for mic pins, force to initialize */
2203 - pinctl = stac92xx_get_vref(codec, nid);
2204 + pinctl = stac92xx_get_default_vref(codec, nid);
2205 pinctl |= AC_PINCTL_IN_EN;
2206 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2207 } else {
2208 pinctl = snd_hda_codec_read(codec, nid, 0,
2209 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2210 /* if PINCTL already set then skip */
2211 - if (!(pinctl & AC_PINCTL_IN_EN)) {
2212 + /* Also, if both INPUT and OUTPUT are set,
2213 + * it must be a BIOS bug; need to override, too
2214 + */
2215 + if (!(pinctl & AC_PINCTL_IN_EN) ||
2216 + (pinctl & AC_PINCTL_OUT_EN)) {
2217 + pinctl &= ~AC_PINCTL_OUT_EN;
2218 pinctl |= AC_PINCTL_IN_EN;
2219 stac92xx_auto_set_pinctl(codec, nid,
2220 pinctl);
2221 }
2222 }
2223 - conf = snd_hda_codec_read(codec, nid, 0,
2224 - AC_VERB_GET_CONFIG_DEFAULT, 0);
2225 + conf = snd_hda_codec_get_pincfg(codec, nid);
2226 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
2227 - enable_pin_detect(codec, nid,
2228 - STAC_INSERT_EVENT);
2229 - stac_issue_unsol_event(codec, nid,
2230 - STAC_INSERT_EVENT);
2231 + if (enable_pin_detect(codec, nid,
2232 + STAC_INSERT_EVENT))
2233 + stac_issue_unsol_event(codec, nid);
2234 }
2235 }
2236 }
2237 @@ -3990,8 +4251,7 @@
2238 stac_toggle_power_map(codec, nid, 1);
2239 continue;
2240 }
2241 - def_conf = snd_hda_codec_read(codec, nid, 0,
2242 - AC_VERB_GET_CONFIG_DEFAULT, 0);
2243 + def_conf = snd_hda_codec_get_pincfg(codec, nid);
2244 def_conf = get_defcfg_connect(def_conf);
2245 /* skip any ports that don't have jacks since presence
2246 * detection is useless */
2247 @@ -4000,32 +4260,35 @@
2248 stac_toggle_power_map(codec, nid, 1);
2249 continue;
2250 }
2251 - if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
2252 - enable_pin_detect(codec, nid, STAC_PWR_EVENT);
2253 - stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
2254 - }
2255 + if (enable_pin_detect(codec, nid, STAC_PWR_EVENT))
2256 + stac_issue_unsol_event(codec, nid);
2257 }
2258 if (spec->dac_list)
2259 stac92xx_power_down(codec);
2260 return 0;
2261 }
2262
2263 +static void stac92xx_free_kctls(struct hda_codec *codec)
2264 +{
2265 + struct sigmatel_spec *spec = codec->spec;
2266 +
2267 + if (spec->kctls.list) {
2268 + struct snd_kcontrol_new *kctl = spec->kctls.list;
2269 + int i;
2270 + for (i = 0; i < spec->kctls.used; i++)
2271 + kfree(kctl[i].name);
2272 + }
2273 + snd_array_free(&spec->kctls);
2274 +}
2275 +
2276 static void stac92xx_free(struct hda_codec *codec)
2277 {
2278 struct sigmatel_spec *spec = codec->spec;
2279 - int i;
2280
2281 if (! spec)
2282 return;
2283
2284 - if (spec->kctl_alloc) {
2285 - for (i = 0; i < spec->num_kctl_used; i++)
2286 - kfree(spec->kctl_alloc[i].name);
2287 - kfree(spec->kctl_alloc);
2288 - }
2289 -
2290 - if (spec->bios_pin_configs)
2291 - kfree(spec->bios_pin_configs);
2292 + snd_array_free(&spec->events);
2293
2294 kfree(spec);
2295 snd_hda_detach_beep_device(codec);
2296 @@ -4034,7 +4297,9 @@
2297 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
2298 unsigned int flag)
2299 {
2300 - unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
2301 + unsigned int old_ctl, pin_ctl;
2302 +
2303 + pin_ctl = snd_hda_codec_read(codec, nid,
2304 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
2305
2306 if (pin_ctl & AC_PINCTL_IN_EN) {
2307 @@ -4048,14 +4313,17 @@
2308 return;
2309 }
2310
2311 + old_ctl = pin_ctl;
2312 /* if setting pin direction bits, clear the current
2313 direction bits first */
2314 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
2315 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
2316
2317 - snd_hda_codec_write_cache(codec, nid, 0,
2318 - AC_VERB_SET_PIN_WIDGET_CONTROL,
2319 - pin_ctl | flag);
2320 + pin_ctl |= flag;
2321 + if (old_ctl != pin_ctl)
2322 + snd_hda_codec_write_cache(codec, nid, 0,
2323 + AC_VERB_SET_PIN_WIDGET_CONTROL,
2324 + pin_ctl);
2325 }
2326
2327 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
2328 @@ -4063,9 +4331,10 @@
2329 {
2330 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
2331 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
2332 - snd_hda_codec_write_cache(codec, nid, 0,
2333 - AC_VERB_SET_PIN_WIDGET_CONTROL,
2334 - pin_ctl & ~flag);
2335 + if (pin_ctl & flag)
2336 + snd_hda_codec_write_cache(codec, nid, 0,
2337 + AC_VERB_SET_PIN_WIDGET_CONTROL,
2338 + pin_ctl & ~flag);
2339 }
2340
2341 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
2342 @@ -4078,6 +4347,48 @@
2343 return 0;
2344 }
2345
2346 +static void stac92xx_line_out_detect(struct hda_codec *codec,
2347 + int presence)
2348 +{
2349 + struct sigmatel_spec *spec = codec->spec;
2350 + struct auto_pin_cfg *cfg = &spec->autocfg;
2351 + int i;
2352 +
2353 + for (i = 0; i < cfg->line_outs; i++) {
2354 + if (presence)
2355 + break;
2356 + presence = get_pin_presence(codec, cfg->line_out_pins[i]);
2357 + if (presence) {
2358 + unsigned int pinctl;
2359 + pinctl = snd_hda_codec_read(codec,
2360 + cfg->line_out_pins[i], 0,
2361 + AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2362 + if (pinctl & AC_PINCTL_IN_EN)
2363 + presence = 0; /* mic- or line-input */
2364 + }
2365 + }
2366 +
2367 + if (presence) {
2368 + /* disable speakers */
2369 + for (i = 0; i < cfg->speaker_outs; i++)
2370 + stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
2371 + AC_PINCTL_OUT_EN);
2372 + if (spec->eapd_mask && spec->eapd_switch)
2373 + stac_gpio_set(codec, spec->gpio_mask,
2374 + spec->gpio_dir, spec->gpio_data &
2375 + ~spec->eapd_mask);
2376 + } else {
2377 + /* enable speakers */
2378 + for (i = 0; i < cfg->speaker_outs; i++)
2379 + stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
2380 + AC_PINCTL_OUT_EN);
2381 + if (spec->eapd_mask && spec->eapd_switch)
2382 + stac_gpio_set(codec, spec->gpio_mask,
2383 + spec->gpio_dir, spec->gpio_data |
2384 + spec->eapd_mask);
2385 + }
2386 +}
2387 +
2388 /* return non-zero if the hp-pin of the given array index isn't
2389 * a jack-detection target
2390 */
2391 @@ -4130,13 +4441,6 @@
2392 for (i = 0; i < cfg->line_outs; i++)
2393 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
2394 AC_PINCTL_OUT_EN);
2395 - for (i = 0; i < cfg->speaker_outs; i++)
2396 - stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
2397 - AC_PINCTL_OUT_EN);
2398 - if (spec->eapd_mask && spec->eapd_switch)
2399 - stac_gpio_set(codec, spec->gpio_mask,
2400 - spec->gpio_dir, spec->gpio_data &
2401 - ~spec->eapd_mask);
2402 } else {
2403 /* enable lineouts */
2404 if (spec->hp_switch)
2405 @@ -4145,14 +4449,8 @@
2406 for (i = 0; i < cfg->line_outs; i++)
2407 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
2408 AC_PINCTL_OUT_EN);
2409 - for (i = 0; i < cfg->speaker_outs; i++)
2410 - stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
2411 - AC_PINCTL_OUT_EN);
2412 - if (spec->eapd_mask && spec->eapd_switch)
2413 - stac_gpio_set(codec, spec->gpio_mask,
2414 - spec->gpio_dir, spec->gpio_data |
2415 - spec->eapd_mask);
2416 }
2417 + stac92xx_line_out_detect(codec, presence);
2418 /* toggle hp outs */
2419 for (i = 0; i < cfg->hp_outs; i++) {
2420 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
2421 @@ -4210,10 +4508,28 @@
2422 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
2423 }
2424
2425 -static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2426 - unsigned char type)
2427 +static void stac92xx_mic_detect(struct hda_codec *codec)
2428 +{
2429 + struct sigmatel_spec *spec = codec->spec;
2430 + struct sigmatel_mic_route *mic;
2431 +
2432 + if (get_pin_presence(codec, spec->ext_mic.pin))
2433 + mic = &spec->ext_mic;
2434 + else
2435 + mic = &spec->int_mic;
2436 + if (mic->dmux_idx)
2437 + snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
2438 + AC_VERB_SET_CONNECT_SEL,
2439 + mic->dmux_idx);
2440 + else
2441 + snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
2442 + AC_VERB_SET_CONNECT_SEL,
2443 + mic->mux_idx);
2444 +}
2445 +
2446 +static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
2447 {
2448 - struct sigmatel_event *event = stac_get_event(codec, nid, type);
2449 + struct sigmatel_event *event = stac_get_event(codec, nid);
2450 if (!event)
2451 return;
2452 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
2453 @@ -4232,12 +4548,40 @@
2454
2455 switch (event->type) {
2456 case STAC_HP_EVENT:
2457 + case STAC_LO_EVENT:
2458 stac92xx_hp_detect(codec);
2459 - /* fallthru */
2460 + break;
2461 + case STAC_MIC_EVENT:
2462 + stac92xx_mic_detect(codec);
2463 + break;
2464 + }
2465 +
2466 + switch (event->type) {
2467 + case STAC_HP_EVENT:
2468 + case STAC_LO_EVENT:
2469 + case STAC_MIC_EVENT:
2470 case STAC_INSERT_EVENT:
2471 case STAC_PWR_EVENT:
2472 if (spec->num_pwrs > 0)
2473 stac92xx_pin_sense(codec, event->nid);
2474 +
2475 + switch (codec->subsystem_id) {
2476 + case 0x103c308f:
2477 + if (event->nid == 0xb) {
2478 + int pin = AC_PINCTL_IN_EN;
2479 +
2480 + if (get_pin_presence(codec, 0xa)
2481 + && get_pin_presence(codec, 0xb))
2482 + pin |= AC_PINCTL_VREF_80;
2483 + if (!get_pin_presence(codec, 0xb))
2484 + pin |= AC_PINCTL_VREF_80;
2485 +
2486 + /* toggle VREF state based on mic + hp pin
2487 + * status
2488 + */
2489 + stac92xx_auto_set_pinctl(codec, 0x0a, pin);
2490 + }
2491 + }
2492 break;
2493 case STAC_VREF_EVENT:
2494 data = snd_hda_codec_read(codec, codec->afg, 0,
2495 @@ -4254,17 +4598,48 @@
2496 {
2497 struct sigmatel_spec *spec = codec->spec;
2498
2499 - stac92xx_set_config_regs(codec);
2500 stac92xx_init(codec);
2501 snd_hda_codec_resume_amp(codec);
2502 snd_hda_codec_resume_cache(codec);
2503 /* fake event to set up pins again to override cached values */
2504 if (spec->hp_detect)
2505 - stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
2506 - STAC_HP_EVENT);
2507 + stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
2508 return 0;
2509 }
2510
2511 +/*
2512 + * using power check for controlling mute led of HP notebooks
2513 + * check for mute state only on Speakers (nid = 0x10)
2514 + *
2515 + * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
2516 + * the LED is NOT working properly !
2517 + *
2518 + * Changed name to reflect that it now works for any designated
2519 + * model, not just HP HDX.
2520 + */
2521 +
2522 +#ifdef CONFIG_SND_HDA_POWER_SAVE
2523 +static int stac92xx_hp_check_power_status(struct hda_codec *codec,
2524 + hda_nid_t nid)
2525 +{
2526 + struct sigmatel_spec *spec = codec->spec;
2527 +
2528 + if (nid == 0x10) {
2529 + if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
2530 + HDA_AMP_MUTE)
2531 + spec->gpio_data &= ~spec->gpio_led; /* orange */
2532 + else
2533 + spec->gpio_data |= spec->gpio_led; /* white */
2534 +
2535 + stac_gpio_set(codec, spec->gpio_mask,
2536 + spec->gpio_dir,
2537 + spec->gpio_data);
2538 + }
2539 +
2540 + return 0;
2541 +}
2542 +#endif
2543 +
2544 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
2545 {
2546 struct sigmatel_spec *spec = codec->spec;
2547 @@ -4275,8 +4650,7 @@
2548 nid = codec->start_nid;
2549 for (i = 0; i < codec->num_nodes; i++, nid++) {
2550 unsigned int wcaps = get_wcaps(codec, nid);
2551 - unsigned int wid_type = (wcaps & AC_WCAP_TYPE) >>
2552 - AC_WCAP_TYPE_SHIFT;
2553 + unsigned int wid_type = get_wcaps_type(wcaps);
2554 if (wid_type == AC_WID_PIN)
2555 snd_hda_codec_read(codec, nid, 0,
2556 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
2557 @@ -4435,6 +4809,9 @@
2558
2559 spec->init = stac925x_core_init;
2560 spec->mixer = stac925x_mixer;
2561 + spec->num_caps = 1;
2562 + spec->capvols = stac925x_capvols;
2563 + spec->capsws = stac925x_capsws;
2564
2565 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
2566 if (!err) {
2567 @@ -4456,16 +4833,6 @@
2568 return 0;
2569 }
2570
2571 -static struct hda_input_mux stac92hd73xx_dmux = {
2572 - .num_items = 4,
2573 - .items = {
2574 - { "Analog Inputs", 0x0b },
2575 - { "Digital Mic 1", 0x09 },
2576 - { "Digital Mic 2", 0x0a },
2577 - { "CD", 0x08 },
2578 - }
2579 -};
2580 -
2581 static int patch_stac92hd73xx(struct hda_codec *codec)
2582 {
2583 struct sigmatel_spec *spec;
2584 @@ -4520,12 +4887,10 @@
2585 case 0x5: /* 10 Channel */
2586 spec->mixer = stac92hd73xx_10ch_mixer;
2587 spec->init = stac92hd73xx_10ch_core_init;
2588 + break;
2589 }
2590 spec->multiout.dac_nids = spec->dac_nids;
2591
2592 - spec->aloopback_mask = 0x01;
2593 - spec->aloopback_shift = 8;
2594 -
2595 spec->digbeep_nid = 0x1c;
2596 spec->mux_nids = stac92hd73xx_mux_nids;
2597 spec->adc_nids = stac92hd73xx_adc_nids;
2598 @@ -4538,8 +4903,10 @@
2599 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
2600 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
2601 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
2602 - memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
2603 - sizeof(stac92hd73xx_dmux));
2604 +
2605 + spec->num_caps = STAC92HD73XX_NUM_CAPS;
2606 + spec->capvols = stac92hd73xx_capvols;
2607 + spec->capsws = stac92hd73xx_capsws;
2608
2609 switch (spec->board_config) {
2610 case STAC_DELL_EQ:
2611 @@ -4558,20 +4925,17 @@
2612 spec->init = dell_m6_core_init;
2613 switch (spec->board_config) {
2614 case STAC_DELL_M6_AMIC: /* Analog Mics */
2615 - stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
2616 + snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
2617 spec->num_dmics = 0;
2618 - spec->private_dimux.num_items = 1;
2619 break;
2620 case STAC_DELL_M6_DMIC: /* Digital Mics */
2621 - stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
2622 + snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
2623 spec->num_dmics = 1;
2624 - spec->private_dimux.num_items = 2;
2625 break;
2626 case STAC_DELL_M6_BOTH: /* Both */
2627 - stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
2628 - stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
2629 + snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
2630 + snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
2631 spec->num_dmics = 1;
2632 - spec->private_dimux.num_items = 2;
2633 break;
2634 }
2635 break;
2636 @@ -4579,13 +4943,13 @@
2637 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
2638 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
2639 spec->eapd_switch = 1;
2640 + break;
2641 }
2642 if (spec->board_config > STAC_92HD73XX_REF) {
2643 /* GPIO0 High = Enable EAPD */
2644 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
2645 spec->gpio_data = 0x01;
2646 }
2647 - spec->dinput_mux = &spec->private_dimux;
2648
2649 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
2650 spec->pwr_nids = stac92hd73xx_pwr_nids;
2651 @@ -4615,21 +4979,13 @@
2652 return 0;
2653 }
2654
2655 -static struct hda_input_mux stac92hd83xxx_dmux = {
2656 - .num_items = 3,
2657 - .items = {
2658 - { "Analog Inputs", 0x03 },
2659 - { "Digital Mic 1", 0x04 },
2660 - { "Digital Mic 2", 0x05 },
2661 - }
2662 -};
2663 -
2664 static int patch_stac92hd83xxx(struct hda_codec *codec)
2665 {
2666 struct sigmatel_spec *spec;
2667 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
2668 int err;
2669 int num_dacs;
2670 + hda_nid_t nid;
2671
2672 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2673 if (spec == NULL)
2674 @@ -4648,14 +5004,6 @@
2675 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
2676 spec->multiout.dac_nids = spec->dac_nids;
2677
2678 - /* set port 0xe to select the last DAC
2679 - */
2680 - num_dacs = snd_hda_get_connections(codec, 0x0e,
2681 - conn, STAC92HD83_DAC_COUNT + 1) - 1;
2682 -
2683 - snd_hda_codec_write_cache(codec, 0xe, 0,
2684 - AC_VERB_SET_CONNECT_SEL, num_dacs);
2685 -
2686 spec->init = stac92hd83xxx_core_init;
2687 spec->mixer = stac92hd83xxx_mixer;
2688 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
2689 @@ -4663,8 +5011,11 @@
2690 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
2691 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
2692 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
2693 - spec->dinput_mux = &stac92hd83xxx_dmux;
2694 spec->pin_nids = stac92hd83xxx_pin_nids;
2695 + spec->num_caps = STAC92HD83XXX_NUM_CAPS;
2696 + spec->capvols = stac92hd83xxx_capvols;
2697 + spec->capsws = stac92hd83xxx_capsws;
2698 +
2699 spec->board_config = snd_hda_check_board_config(codec,
2700 STAC_92HD83XXX_MODELS,
2701 stac92hd83xxx_models,
2702 @@ -4687,6 +5038,7 @@
2703 switch (codec->vendor_id) {
2704 case 0x111d7604:
2705 case 0x111d7605:
2706 + case 0x111d76d5:
2707 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
2708 break;
2709 spec->num_pwrs = 0;
2710 @@ -4709,24 +5061,89 @@
2711 return err;
2712 }
2713
2714 + switch (spec->board_config) {
2715 + case STAC_DELL_S14:
2716 + nid = 0xf;
2717 + break;
2718 + default:
2719 + nid = 0xe;
2720 + break;
2721 + }
2722 +
2723 + num_dacs = snd_hda_get_connections(codec, nid,
2724 + conn, STAC92HD83_DAC_COUNT + 1) - 1;
2725 + if (num_dacs < 0)
2726 + num_dacs = STAC92HD83_DAC_COUNT;
2727 +
2728 + /* set port X to select the last DAC
2729 + */
2730 + snd_hda_codec_write_cache(codec, nid, 0,
2731 + AC_VERB_SET_CONNECT_SEL, num_dacs);
2732 +
2733 codec->patch_ops = stac92xx_patch_ops;
2734
2735 return 0;
2736 }
2737
2738 -static struct hda_input_mux stac92hd71bxx_dmux = {
2739 - .num_items = 4,
2740 - .items = {
2741 - { "Analog Inputs", 0x00 },
2742 - { "Mixer", 0x01 },
2743 - { "Digital Mic 1", 0x02 },
2744 - { "Digital Mic 2", 0x03 },
2745 +/* get the pin connection (fixed, none, etc) */
2746 +static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
2747 +{
2748 + struct sigmatel_spec *spec = codec->spec;
2749 + unsigned int cfg;
2750 +
2751 + cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
2752 + return get_defcfg_connect(cfg);
2753 +}
2754 +
2755 +static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
2756 + hda_nid_t *nids, int num_nids)
2757 +{
2758 + struct sigmatel_spec *spec = codec->spec;
2759 + int idx, num;
2760 + unsigned int def_conf;
2761 +
2762 + for (num = 0; num < num_nids; num++) {
2763 + for (idx = 0; idx < spec->num_pins; idx++)
2764 + if (spec->pin_nids[idx] == nids[num])
2765 + break;
2766 + if (idx >= spec->num_pins)
2767 + break;
2768 + def_conf = stac_get_defcfg_connect(codec, idx);
2769 + if (def_conf == AC_JACK_PORT_NONE)
2770 + break;
2771 }
2772 -};
2773 + return num;
2774 +}
2775 +
2776 +static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
2777 + hda_nid_t dig0pin)
2778 +{
2779 + struct sigmatel_spec *spec = codec->spec;
2780 + int idx;
2781 +
2782 + for (idx = 0; idx < spec->num_pins; idx++)
2783 + if (spec->pin_nids[idx] == dig0pin)
2784 + break;
2785 + if ((idx + 2) >= spec->num_pins)
2786 + return 0;
2787 +
2788 + /* dig1pin case */
2789 + if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
2790 + return 2;
2791 +
2792 + /* dig0pin + dig2pin case */
2793 + if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
2794 + return 2;
2795 + if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
2796 + return 1;
2797 + else
2798 + return 0;
2799 +}
2800
2801 static int patch_stac92hd71bxx(struct hda_codec *codec)
2802 {
2803 struct sigmatel_spec *spec;
2804 + struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
2805 int err = 0;
2806
2807 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2808 @@ -4735,11 +5152,21 @@
2809
2810 codec->spec = spec;
2811 codec->patch_ops = stac92xx_patch_ops;
2812 - spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
2813 + spec->num_pins = STAC92HD71BXX_NUM_PINS;
2814 + switch (codec->vendor_id) {
2815 + case 0x111d76b6:
2816 + case 0x111d76b7:
2817 + spec->pin_nids = stac92hd71bxx_pin_nids_4port;
2818 + break;
2819 + case 0x111d7603:
2820 + case 0x111d7608:
2821 + /* On 92HD75Bx 0x27 isn't a pin nid */
2822 + spec->num_pins--;
2823 + /* fallthrough */
2824 + default:
2825 + spec->pin_nids = stac92hd71bxx_pin_nids_6port;
2826 + }
2827 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
2828 - spec->pin_nids = stac92hd71bxx_pin_nids;
2829 - memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
2830 - sizeof(stac92hd71bxx_dmux));
2831 spec->board_config = snd_hda_check_board_config(codec,
2832 STAC_92HD71BXX_MODELS,
2833 stac92hd71bxx_models,
2834 @@ -4766,14 +5193,25 @@
2835 spec->gpio_data = 0x01;
2836 }
2837
2838 + spec->dmic_nids = stac92hd71bxx_dmic_nids;
2839 + spec->dmux_nids = stac92hd71bxx_dmux_nids;
2840 +
2841 + spec->num_caps = STAC92HD71BXX_NUM_CAPS;
2842 + spec->capvols = stac92hd71bxx_capvols;
2843 + spec->capsws = stac92hd71bxx_capsws;
2844 +
2845 switch (codec->vendor_id) {
2846 case 0x111d76b6: /* 4 Port without Analog Mixer */
2847 case 0x111d76b7:
2848 + unmute_init++;
2849 + /* fallthru */
2850 case 0x111d76b4: /* 6 Port without Analog Mixer */
2851 case 0x111d76b5:
2852 - spec->mixer = stac92hd71bxx_mixer;
2853 spec->init = stac92hd71bxx_core_init;
2854 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
2855 + spec->num_dmics = stac92hd71bxx_connected_ports(codec,
2856 + stac92hd71bxx_dmic_nids,
2857 + STAC92HD71BXX_NUM_DMICS);
2858 break;
2859 case 0x111d7608: /* 5 Port with Analog Mixer */
2860 switch (spec->board_config) {
2861 @@ -4797,12 +5235,15 @@
2862
2863 /* no output amps */
2864 spec->num_pwrs = 0;
2865 - spec->mixer = stac92hd71bxx_analog_mixer;
2866 - spec->dinput_mux = &spec->private_dimux;
2867 -
2868 /* disable VSW */
2869 - spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
2870 - stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
2871 + spec->init = stac92hd71bxx_core_init;
2872 + unmute_init++;
2873 + snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
2874 + snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
2875 + stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
2876 + spec->num_dmics = stac92hd71bxx_connected_ports(codec,
2877 + stac92hd71bxx_dmic_nids,
2878 + STAC92HD71BXX_NUM_DMICS - 1);
2879 break;
2880 case 0x111d7603: /* 6 Port with Analog Mixer */
2881 if ((codec->revision_id & 0xf) == 1)
2882 @@ -4812,12 +5253,17 @@
2883 spec->num_pwrs = 0;
2884 /* fallthru */
2885 default:
2886 - spec->dinput_mux = &spec->private_dimux;
2887 - spec->mixer = stac92hd71bxx_analog_mixer;
2888 - spec->init = stac92hd71bxx_analog_core_init;
2889 + spec->init = stac92hd71bxx_core_init;
2890 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
2891 + spec->num_dmics = stac92hd71bxx_connected_ports(codec,
2892 + stac92hd71bxx_dmic_nids,
2893 + STAC92HD71BXX_NUM_DMICS);
2894 + break;
2895 }
2896
2897 + if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
2898 + snd_hda_sequence_write_cache(codec, unmute_init);
2899 +
2900 /* Some HP machines seem to have unstable codec communications
2901 * especially with ATI fglrx driver. For recovering from the
2902 * CORB/RIRB stall, allow the BUS reset and keep always sync
2903 @@ -4827,25 +5273,22 @@
2904 codec->bus->allow_bus_reset = 1;
2905 }
2906
2907 - spec->aloopback_mask = 0x50;
2908 - spec->aloopback_shift = 0;
2909 -
2910 spec->powerdown_adcs = 1;
2911 spec->digbeep_nid = 0x26;
2912 spec->mux_nids = stac92hd71bxx_mux_nids;
2913 spec->adc_nids = stac92hd71bxx_adc_nids;
2914 - spec->dmic_nids = stac92hd71bxx_dmic_nids;
2915 - spec->dmux_nids = stac92hd71bxx_dmux_nids;
2916 spec->smux_nids = stac92hd71bxx_smux_nids;
2917 spec->pwr_nids = stac92hd71bxx_pwr_nids;
2918
2919 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
2920 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
2921 + spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
2922 + spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
2923
2924 switch (spec->board_config) {
2925 case STAC_HP_M4:
2926 /* enable internal microphone */
2927 - stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
2928 + snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
2929 stac92xx_auto_set_pinctl(codec, 0x0e,
2930 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
2931 /* fallthru */
2932 @@ -4860,19 +5303,42 @@
2933 spec->num_smuxes = 0;
2934 spec->num_dmuxes = 1;
2935 break;
2936 - default:
2937 - spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
2938 - spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
2939 - spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
2940 - };
2941 + case STAC_HP_DV4_1222NR:
2942 + spec->num_dmics = 1;
2943 + /* I don't know if it needs 1 or 2 smuxes - will wait for
2944 + * bug reports to fix if needed
2945 + */
2946 + spec->num_smuxes = 1;
2947 + spec->num_dmuxes = 1;
2948 + spec->gpio_led = 0x01;
2949 + /* fallthrough */
2950 + case STAC_HP_DV5:
2951 + snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
2952 + stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
2953 + break;
2954 + case STAC_HP_HDX:
2955 + spec->num_dmics = 1;
2956 + spec->num_dmuxes = 1;
2957 + spec->num_smuxes = 1;
2958 + /* orange/white mute led on GPIO3, orange=0, white=1 */
2959 + spec->gpio_led = 0x08;
2960 + break;
2961 + }
2962 +
2963 +#ifdef CONFIG_SND_HDA_POWER_SAVE
2964 + if (spec->gpio_led) {
2965 + spec->gpio_mask |= spec->gpio_led;
2966 + spec->gpio_dir |= spec->gpio_led;
2967 + spec->gpio_data |= spec->gpio_led;
2968 + /* register check_power_status callback. */
2969 + codec->patch_ops.check_power_status =
2970 + stac92xx_hp_check_power_status;
2971 + }
2972 +#endif
2973
2974 spec->multiout.dac_nids = spec->dac_nids;
2975 - if (spec->dinput_mux)
2976 - spec->private_dimux.num_items +=
2977 - spec->num_dmics -
2978 - (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
2979
2980 - err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
2981 + err = stac92xx_parse_auto_config(codec, 0x21, 0);
2982 if (!err) {
2983 if (spec->board_config < 0) {
2984 printk(KERN_WARNING "hda_codec: No auto-config is "
2985 @@ -4889,7 +5355,7 @@
2986 }
2987
2988 return 0;
2989 -};
2990 +}
2991
2992 static int patch_stac922x(struct hda_codec *codec)
2993 {
2994 @@ -4967,7 +5433,10 @@
2995 spec->num_pwrs = 0;
2996
2997 spec->init = stac922x_core_init;
2998 - spec->mixer = stac922x_mixer;
2999 +
3000 + spec->num_caps = STAC922X_NUM_CAPS;
3001 + spec->capvols = stac922x_capvols;
3002 + spec->capsws = stac922x_capsws;
3003
3004 spec->multiout.dac_nids = spec->dac_nids;
3005
3006 @@ -5008,6 +5477,7 @@
3007 return -ENOMEM;
3008
3009 codec->spec = spec;
3010 + codec->slave_dig_outs = stac927x_slave_dig_outs;
3011 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
3012 spec->pin_nids = stac927x_pin_nids;
3013 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
3014 @@ -5049,32 +5519,37 @@
3015 spec->num_dmics = 0;
3016
3017 spec->init = d965_core_init;
3018 - spec->mixer = stac927x_mixer;
3019 break;
3020 case STAC_DELL_BIOS:
3021 switch (codec->subsystem_id) {
3022 case 0x10280209:
3023 case 0x1028022e:
3024 /* correct the device field to SPDIF out */
3025 - stac92xx_set_config_reg(codec, 0x21, 0x01442070);
3026 + snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
3027 break;
3028 - };
3029 + }
3030 /* configure the analog microphone on some laptops */
3031 - stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
3032 + snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
3033 /* correct the front output jack as a hp out */
3034 - stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
3035 + snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
3036 /* correct the front input jack as a mic */
3037 - stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
3038 + snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
3039 /* fallthru */
3040 case STAC_DELL_3ST:
3041 /* GPIO2 High = Enable EAPD */
3042 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
3043 spec->gpio_data = 0x04;
3044 + switch (codec->subsystem_id) {
3045 + case 0x1028022f:
3046 + /* correct EAPD to be GPIO0 */
3047 + spec->eapd_mask = spec->gpio_mask = 0x01;
3048 + spec->gpio_dir = spec->gpio_data = 0x01;
3049 + break;
3050 + };
3051 spec->dmic_nids = stac927x_dmic_nids;
3052 spec->num_dmics = STAC927X_NUM_DMICS;
3053
3054 spec->init = d965_core_init;
3055 - spec->mixer = stac927x_mixer;
3056 spec->dmux_nids = stac927x_dmux_nids;
3057 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
3058 break;
3059 @@ -5087,12 +5562,13 @@
3060 spec->num_dmics = 0;
3061
3062 spec->init = stac927x_core_init;
3063 - spec->mixer = stac927x_mixer;
3064 }
3065
3066 + spec->num_caps = STAC927X_NUM_CAPS;
3067 + spec->capvols = stac927x_capvols;
3068 + spec->capsws = stac927x_capsws;
3069 +
3070 spec->num_pwrs = 0;
3071 - spec->aloopback_mask = 0x40;
3072 - spec->aloopback_shift = 0;
3073 spec->eapd_switch = 1;
3074
3075 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
3076 @@ -5174,10 +5650,11 @@
3077 spec->num_pwrs = 0;
3078
3079 spec->init = stac9205_core_init;
3080 - spec->mixer = stac9205_mixer;
3081
3082 - spec->aloopback_mask = 0x40;
3083 - spec->aloopback_shift = 0;
3084 + spec->num_caps = STAC9205_NUM_CAPS;
3085 + spec->capvols = stac9205_capvols;
3086 + spec->capsws = stac9205_capsws;
3087 +
3088 /* Turn on/off EAPD per HP plugging */
3089 if (spec->board_config != STAC_9205_EAPD)
3090 spec->eapd_switch = 1;
3091 @@ -5186,8 +5663,8 @@
3092 switch (spec->board_config){
3093 case STAC_9205_DELL_M43:
3094 /* Enable SPDIF in/out */
3095 - stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
3096 - stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
3097 + snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
3098 + snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
3099
3100 /* Enable unsol response for GPIO4/Dock HP connection */
3101 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
3102 @@ -5521,6 +5998,7 @@
3103 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
3104 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
3105 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
3106 + { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
3107 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
3108 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
3109 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
3110 @@ -5532,6 +6010,7 @@
3111 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
3112 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
3113 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
3114 + { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
3115 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
3116 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
3117 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },