]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/suse-2.6.27.39/patches.drivers/alsa-post-ga-hda-stac-automic
Imported linux-2.6.27.39 suse/xen patches.
[ipfire-2.x.git] / src / patches / suse-2.6.27.39 / 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 @@ enum {
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 @@ enum {
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 @@ enum {
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 @@ enum {
88 };
89
90 enum {
91 + STAC_922X_AUTO,
92 STAC_D945_REF,
93 STAC_D945GTP3,
94 STAC_D945GTP5,
95 @@ -136,10 +148,12 @@ enum {
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 @@ struct sigmatel_event {
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 @@ struct sigmatel_spec {
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 @@ struct sigmatel_spec {
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 @@ struct sigmatel_spec {
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 @@ struct sigmatel_spec {
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 @@ static hda_nid_t stac92hd73xx_smux_nids[
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 @@ static hda_nid_t stac92hd83xxx_amp_nids[
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 @@ static hda_nid_t stac92hd71bxx_slave_dig
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 @@ static hda_nid_t stac925x_dmux_nids[1] =
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 @@ static hda_nid_t stac922x_mux_nids[2] =
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 @@ static hda_nid_t stac927x_dmic_nids[STAC
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 @@ static hda_nid_t stac9205_dmic_nids[STAC
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 @@ static hda_nid_t stac92hd73xx_pin_nids[1
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 @@ static int stac92xx_amp_volume_put(struc
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 @@ static int stac92xx_smux_enum_put(struct
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 @@ static int stac92xx_mux_enum_put(struct
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 @@ static int stac92xx_amp_mux_enum_put(str
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 @@ static struct hda_verb stac92hd73xx_10ch
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 @@ static struct hda_verb stac92hd83xxx_cor
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 @@ static struct hda_verb stac9205_core_ini
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 @@ static struct snd_kcontrol_new stac92hd7
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 @@ static struct snd_kcontrol_new stac92hd7
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 @@ static struct snd_kcontrol_new stac92hd7
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 @@ static struct snd_kcontrol_new stac92hd8
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 @@ static const char *slave_vols[] = {
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 @@ static const char *slave_sws[] = {
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 @@ static int stac92xx_build_controls(struc
804 return err;
805 }
806
807 + stac92xx_free_kctls(codec); /* no longer needed */
808 +
809 return 0;
810 }
811
812 @@ -1454,6 +1376,7 @@ static unsigned int *stac9200_brd_tbl[ST
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 @@ static const char *stac9200_models[STAC_
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 @@ static unsigned int *stac925x_brd_tbl[ST
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 @@ static struct snd_pci_quirk stac925x_cod
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 @@ static unsigned int *stac92hd73xx_brd_tb
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 @@ static struct snd_pci_quirk stac92hd73xx
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 @@ static struct snd_pci_quirk stac92hd73xx
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 @@ static unsigned int *stac92hd71bxx_brd_t
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 @@ static unsigned int *stac922x_brd_tbl[ST
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 @@ static struct snd_pci_quirk stac922x_cfg
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 @@ static struct snd_pci_quirk stac922x_cfg
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 @@ static unsigned int d965_5st_pin_configs
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 @@ static unsigned int *stac927x_brd_tbl[ST
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 @@ static struct snd_pci_quirk stac927x_cfg
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 @@ static struct snd_pci_quirk stac927x_cfg
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 @@ static unsigned int *stac9205_brd_tbl[ST
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 @@ static struct snd_pci_quirk stac9205_cfg
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 @@ static struct snd_pci_quirk stac9205_cfg
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 @@ static int stac92xx_build_pcms(struct hd
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 @@ static int stac92xx_hp_switch_get(struct
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 @@ -2565,19 +2507,113 @@ static int stac92xx_hp_switch_put(struct
1216 /* check to be sure that the ports are upto date with
1217 * switch changes
1218 */
1219 - stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
1220 + stac_issue_unsol_event(codec, nid);
1221 +
1222 return 1;
1223 }
1224
1225 -#define stac92xx_io_switch_info snd_ctl_boolean_mono_info
1226 +static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
1227 + struct snd_ctl_elem_info *uinfo)
1228 +{
1229 + int i;
1230 + static char *texts[] = {
1231 + "Mic In", "Line In", "Line Out"
1232 + };
1233 +
1234 + struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1235 + struct sigmatel_spec *spec = codec->spec;
1236 + hda_nid_t nid = kcontrol->private_value;
1237 +
1238 + if (nid == spec->mic_switch || nid == spec->line_switch)
1239 + i = 3;
1240 + else
1241 + i = 2;
1242 +
1243 + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1244 + uinfo->value.enumerated.items = i;
1245 + uinfo->count = 1;
1246 + if (uinfo->value.enumerated.item >= i)
1247 + uinfo->value.enumerated.item = i-1;
1248 + strcpy(uinfo->value.enumerated.name,
1249 + texts[uinfo->value.enumerated.item]);
1250 +
1251 + return 0;
1252 +}
1253 +
1254 +static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
1255 + struct snd_ctl_elem_value *ucontrol)
1256 +{
1257 + struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1258 + hda_nid_t nid = kcontrol->private_value;
1259 + unsigned int vref = stac92xx_vref_get(codec, nid);
1260 +
1261 + if (vref == stac92xx_get_default_vref(codec, nid))
1262 + ucontrol->value.enumerated.item[0] = 0;
1263 + else if (vref == AC_PINCTL_VREF_GRD)
1264 + ucontrol->value.enumerated.item[0] = 1;
1265 + else if (vref == AC_PINCTL_VREF_HIZ)
1266 + ucontrol->value.enumerated.item[0] = 2;
1267 +
1268 + return 0;
1269 +}
1270 +
1271 +static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
1272 + struct snd_ctl_elem_value *ucontrol)
1273 +{
1274 + struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1275 + unsigned int new_vref = 0;
1276 + int error;
1277 + hda_nid_t nid = kcontrol->private_value;
1278 +
1279 + if (ucontrol->value.enumerated.item[0] == 0)
1280 + new_vref = stac92xx_get_default_vref(codec, nid);
1281 + else if (ucontrol->value.enumerated.item[0] == 1)
1282 + new_vref = AC_PINCTL_VREF_GRD;
1283 + else if (ucontrol->value.enumerated.item[0] == 2)
1284 + new_vref = AC_PINCTL_VREF_HIZ;
1285 + else
1286 + return 0;
1287 +
1288 + if (new_vref != stac92xx_vref_get(codec, nid)) {
1289 + error = stac92xx_vref_set(codec, nid, new_vref);
1290 + return error;
1291 + }
1292 +
1293 + return 0;
1294 +}
1295 +
1296 +static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
1297 + struct snd_ctl_elem_info *uinfo)
1298 +{
1299 + static char *texts[2];
1300 + struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1301 + struct sigmatel_spec *spec = codec->spec;
1302 +
1303 + if (kcontrol->private_value == spec->line_switch)
1304 + texts[0] = "Line In";
1305 + else
1306 + texts[0] = "Mic In";
1307 + texts[1] = "Line Out";
1308 + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1309 + uinfo->value.enumerated.items = 2;
1310 + uinfo->count = 1;
1311 +
1312 + if (uinfo->value.enumerated.item >= 2)
1313 + uinfo->value.enumerated.item = 1;
1314 + strcpy(uinfo->value.enumerated.name,
1315 + texts[uinfo->value.enumerated.item]);
1316 +
1317 + return 0;
1318 +}
1319
1320 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1321 {
1322 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1323 struct sigmatel_spec *spec = codec->spec;
1324 - int io_idx = kcontrol-> private_value & 0xff;
1325 + hda_nid_t nid = kcontrol->private_value;
1326 + int io_idx = (nid == spec->mic_switch) ? 1 : 0;
1327
1328 - ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
1329 + ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
1330 return 0;
1331 }
1332
1333 @@ -2585,9 +2621,9 @@ static int stac92xx_io_switch_put(struct
1334 {
1335 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1336 struct sigmatel_spec *spec = codec->spec;
1337 - hda_nid_t nid = kcontrol->private_value >> 8;
1338 - int io_idx = kcontrol-> private_value & 0xff;
1339 - unsigned short val = !!ucontrol->value.integer.value[0];
1340 + hda_nid_t nid = kcontrol->private_value;
1341 + int io_idx = (nid == spec->mic_switch) ? 1 : 0;
1342 + unsigned short val = !!ucontrol->value.enumerated.item[0];
1343
1344 spec->io_switch[io_idx] = val;
1345
1346 @@ -2596,7 +2632,7 @@ static int stac92xx_io_switch_put(struct
1347 else {
1348 unsigned int pinctl = AC_PINCTL_IN_EN;
1349 if (io_idx) /* set VREF for mic */
1350 - pinctl |= stac92xx_get_vref(codec, nid);
1351 + pinctl |= stac92xx_get_default_vref(codec, nid);
1352 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1353 }
1354
1355 @@ -2604,7 +2640,7 @@ static int stac92xx_io_switch_put(struct
1356 * appropriately according to the pin direction
1357 */
1358 if (spec->hp_detect)
1359 - stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
1360 + stac_issue_unsol_event(codec, nid);
1361
1362 return 1;
1363 }
1364 @@ -2677,7 +2713,8 @@ enum {
1365 STAC_CTL_WIDGET_AMP_VOL,
1366 STAC_CTL_WIDGET_HP_SWITCH,
1367 STAC_CTL_WIDGET_IO_SWITCH,
1368 - STAC_CTL_WIDGET_CLFE_SWITCH
1369 + STAC_CTL_WIDGET_CLFE_SWITCH,
1370 + STAC_CTL_WIDGET_DC_BIAS
1371 };
1372
1373 static struct snd_kcontrol_new stac92xx_control_templates[] = {
1374 @@ -2689,38 +2726,42 @@ static struct snd_kcontrol_new stac92xx_
1375 STAC_CODEC_HP_SWITCH(NULL),
1376 STAC_CODEC_IO_SWITCH(NULL, 0),
1377 STAC_CODEC_CLFE_SWITCH(NULL, 0),
1378 + DC_BIAS(NULL, 0, 0),
1379 };
1380
1381 /* add dynamic controls */
1382 -static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
1383 - struct snd_kcontrol_new *ktemp,
1384 - int idx, const char *name,
1385 - unsigned long val)
1386 +static struct snd_kcontrol_new *
1387 +stac_control_new(struct sigmatel_spec *spec,
1388 + struct snd_kcontrol_new *ktemp,
1389 + const char *name)
1390 {
1391 struct snd_kcontrol_new *knew;
1392
1393 - if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1394 - int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1395 -
1396 - knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1397 - if (! knew)
1398 - return -ENOMEM;
1399 - if (spec->kctl_alloc) {
1400 - memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1401 - kfree(spec->kctl_alloc);
1402 - }
1403 - spec->kctl_alloc = knew;
1404 - spec->num_kctl_alloc = num;
1405 - }
1406 -
1407 - knew = &spec->kctl_alloc[spec->num_kctl_used];
1408 + snd_array_init(&spec->kctls, sizeof(*knew), 32);
1409 + knew = snd_array_new(&spec->kctls);
1410 + if (!knew)
1411 + return NULL;
1412 *knew = *ktemp;
1413 - knew->index = idx;
1414 knew->name = kstrdup(name, GFP_KERNEL);
1415 - if (!knew->name)
1416 + if (!knew->name) {
1417 + /* roolback */
1418 + memset(knew, 0, sizeof(*knew));
1419 + spec->kctls.alloced--;
1420 + return NULL;
1421 + }
1422 + return knew;
1423 +}
1424 +
1425 +static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
1426 + struct snd_kcontrol_new *ktemp,
1427 + int idx, const char *name,
1428 + unsigned long val)
1429 +{
1430 + struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
1431 + if (!knew)
1432 return -ENOMEM;
1433 + knew->index = idx;
1434 knew->private_value = val;
1435 - spec->num_kctl_used++;
1436 return 0;
1437 }
1438
1439 @@ -2741,8 +2782,61 @@ static inline int stac92xx_add_control(s
1440 return stac92xx_add_control_idx(spec, type, 0, name, val);
1441 }
1442
1443 -/* check whether the line-input can be used as line-out */
1444 -static hda_nid_t check_line_out_switch(struct hda_codec *codec)
1445 +static struct snd_kcontrol_new stac_input_src_temp = {
1446 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1447 + .name = "Input Source",
1448 + .info = stac92xx_mux_enum_info,
1449 + .get = stac92xx_mux_enum_get,
1450 + .put = stac92xx_mux_enum_put,
1451 +};
1452 +
1453 +static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
1454 + hda_nid_t nid, int idx)
1455 +{
1456 + int def_conf = snd_hda_codec_get_pincfg(codec, nid);
1457 + int control = 0;
1458 + struct sigmatel_spec *spec = codec->spec;
1459 + char name[22];
1460 +
1461 + if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
1462 + if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
1463 + && nid == spec->line_switch)
1464 + control = STAC_CTL_WIDGET_IO_SWITCH;
1465 + else if (snd_hda_query_pin_caps(codec, nid)
1466 + & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
1467 + control = STAC_CTL_WIDGET_DC_BIAS;
1468 + else if (nid == spec->mic_switch)
1469 + control = STAC_CTL_WIDGET_IO_SWITCH;
1470 + }
1471 +
1472 + if (control) {
1473 + strcpy(name, auto_pin_cfg_labels[idx]);
1474 + return stac92xx_add_control(codec->spec, control,
1475 + strcat(name, " Jack Mode"), nid);
1476 + }
1477 +
1478 + return 0;
1479 +}
1480 +
1481 +static int stac92xx_add_input_source(struct sigmatel_spec *spec)
1482 +{
1483 + struct snd_kcontrol_new *knew;
1484 + struct hda_input_mux *imux = &spec->private_imux;
1485 +
1486 + if (spec->auto_mic)
1487 + return 0; /* no need for input source */
1488 + if (!spec->num_adcs || imux->num_items <= 1)
1489 + return 0; /* no need for input source control */
1490 + knew = stac_control_new(spec, &stac_input_src_temp,
1491 + stac_input_src_temp.name);
1492 + if (!knew)
1493 + return -ENOMEM;
1494 + knew->count = spec->num_adcs;
1495 + return 0;
1496 +}
1497 +
1498 +/* check whether the line-input can be used as line-out */
1499 +static hda_nid_t check_line_out_switch(struct hda_codec *codec)
1500 {
1501 struct sigmatel_spec *spec = codec->spec;
1502 struct auto_pin_cfg *cfg = &spec->autocfg;
1503 @@ -2752,7 +2846,7 @@ static hda_nid_t check_line_out_switch(s
1504 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
1505 return 0;
1506 nid = cfg->input_pins[AUTO_PIN_LINE];
1507 - pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
1508 + pincap = snd_hda_query_pin_caps(codec, nid);
1509 if (pincap & AC_PINCAP_OUT)
1510 return nid;
1511 return 0;
1512 @@ -2771,12 +2865,11 @@ static hda_nid_t check_mic_out_switch(st
1513 mic_pin = AUTO_PIN_MIC;
1514 for (;;) {
1515 hda_nid_t nid = cfg->input_pins[mic_pin];
1516 - def_conf = snd_hda_codec_read(codec, nid, 0,
1517 - AC_VERB_GET_CONFIG_DEFAULT, 0);
1518 + def_conf = snd_hda_codec_get_pincfg(codec, nid);
1519 /* some laptops have an internal analog microphone
1520 * which can't be used as a output */
1521 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
1522 - pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
1523 + pincap = snd_hda_query_pin_caps(codec, nid);
1524 if (pincap & AC_PINCAP_OUT)
1525 return nid;
1526 }
1527 @@ -2824,9 +2917,8 @@ static hda_nid_t get_unassigned_dac(stru
1528 conn_len = snd_hda_get_connections(codec, nid, conn,
1529 HDA_MAX_CONNECTIONS);
1530 for (j = 0; j < conn_len; j++) {
1531 - wcaps = snd_hda_param_read(codec, conn[j],
1532 - AC_PAR_AUDIO_WIDGET_CAP);
1533 - wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1534 + wcaps = get_wcaps(codec, conn[j]);
1535 + wtype = get_wcaps_type(wcaps);
1536 /* we check only analog outputs */
1537 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
1538 continue;
1539 @@ -2840,6 +2932,16 @@ static hda_nid_t get_unassigned_dac(stru
1540 return conn[j];
1541 }
1542 }
1543 + /* if all DACs are already assigned, connect to the primary DAC */
1544 + if (conn_len > 1) {
1545 + for (j = 0; j < conn_len; j++) {
1546 + if (conn[j] == spec->multiout.dac_nids[0]) {
1547 + snd_hda_codec_write_cache(codec, nid, 0,
1548 + AC_VERB_SET_CONNECT_SEL, j);
1549 + break;
1550 + }
1551 + }
1552 + }
1553 return 0;
1554 }
1555
1556 @@ -2880,6 +2982,26 @@ static int stac92xx_auto_fill_dac_nids(s
1557 add_spec_dacs(spec, dac);
1558 }
1559
1560 + for (i = 0; i < cfg->hp_outs; i++) {
1561 + nid = cfg->hp_pins[i];
1562 + dac = get_unassigned_dac(codec, nid);
1563 + if (dac) {
1564 + if (!spec->multiout.hp_nid)
1565 + spec->multiout.hp_nid = dac;
1566 + else
1567 + add_spec_extra_dacs(spec, dac);
1568 + }
1569 + spec->hp_dacs[i] = dac;
1570 + }
1571 +
1572 + for (i = 0; i < cfg->speaker_outs; i++) {
1573 + nid = cfg->speaker_pins[i];
1574 + dac = get_unassigned_dac(codec, nid);
1575 + if (dac)
1576 + add_spec_extra_dacs(spec, dac);
1577 + spec->speaker_dacs[i] = dac;
1578 + }
1579 +
1580 /* add line-in as output */
1581 nid = check_line_out_switch(codec);
1582 if (nid) {
1583 @@ -2907,26 +3029,6 @@ static int stac92xx_auto_fill_dac_nids(s
1584 }
1585 }
1586
1587 - for (i = 0; i < cfg->hp_outs; i++) {
1588 - nid = cfg->hp_pins[i];
1589 - dac = get_unassigned_dac(codec, nid);
1590 - if (dac) {
1591 - if (!spec->multiout.hp_nid)
1592 - spec->multiout.hp_nid = dac;
1593 - else
1594 - add_spec_extra_dacs(spec, dac);
1595 - }
1596 - spec->hp_dacs[i] = dac;
1597 - }
1598 -
1599 - for (i = 0; i < cfg->speaker_outs; i++) {
1600 - nid = cfg->speaker_pins[i];
1601 - dac = get_unassigned_dac(codec, nid);
1602 - if (dac)
1603 - add_spec_extra_dacs(spec, dac);
1604 - spec->speaker_dacs[i] = dac;
1605 - }
1606 -
1607 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
1608 spec->multiout.num_dacs,
1609 spec->multiout.dac_nids[0],
1610 @@ -2939,8 +3041,8 @@ static int stac92xx_auto_fill_dac_nids(s
1611 }
1612
1613 /* create volume control/switch for the given prefx type */
1614 -static int create_controls(struct hda_codec *codec, const char *pfx,
1615 - hda_nid_t nid, int chs)
1616 +static int create_controls_idx(struct hda_codec *codec, const char *pfx,
1617 + int idx, hda_nid_t nid, int chs)
1618 {
1619 struct sigmatel_spec *spec = codec->spec;
1620 char name[32];
1621 @@ -2964,19 +3066,22 @@ static int create_controls(struct hda_co
1622 }
1623
1624 sprintf(name, "%s Playback Volume", pfx);
1625 - err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
1626 + err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
1627 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
1628 spec->volume_offset));
1629 if (err < 0)
1630 return err;
1631 sprintf(name, "%s Playback Switch", pfx);
1632 - err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
1633 + err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
1634 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1635 if (err < 0)
1636 return err;
1637 return 0;
1638 }
1639
1640 +#define create_controls(codec, pfx, nid, chs) \
1641 + create_controls_idx(codec, pfx, 0, nid, chs)
1642 +
1643 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
1644 {
1645 if (spec->multiout.num_dacs > 4) {
1646 @@ -3014,12 +3119,6 @@ static int create_multi_out_ctls(struct
1647 static const char *chname[4] = {
1648 "Front", "Surround", NULL /*CLFE*/, "Side"
1649 };
1650 - static const char *hp_pfxs[] = {
1651 - "Headphone", "Headphone2", "Headphone3", "Headphone4"
1652 - };
1653 - static const char *speaker_pfxs[] = {
1654 - "Speaker", "External Speaker", "Speaker2", "Speaker3"
1655 - };
1656 hda_nid_t nid;
1657 int i, err;
1658 unsigned int wid_caps;
1659 @@ -3055,18 +3154,22 @@ static int create_multi_out_ctls(struct
1660
1661 } else {
1662 const char *name;
1663 + int idx;
1664 switch (type) {
1665 case AUTO_PIN_HP_OUT:
1666 - name = hp_pfxs[i];
1667 + name = "Headphone";
1668 + idx = i;
1669 break;
1670 case AUTO_PIN_SPEAKER_OUT:
1671 - name = speaker_pfxs[i];
1672 + name = "Speaker";
1673 + idx = i;
1674 break;
1675 default:
1676 name = chname[i];
1677 + idx = 0;
1678 break;
1679 }
1680 - err = create_controls(codec, name, nid, 3);
1681 + err = create_controls_idx(codec, name, idx, nid, 3);
1682 if (err < 0)
1683 return err;
1684 }
1685 @@ -3074,12 +3177,29 @@ static int create_multi_out_ctls(struct
1686 return 0;
1687 }
1688
1689 +static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
1690 + unsigned long sw, int idx)
1691 +{
1692 + int err;
1693 + err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
1694 + "Capture Volume", vol);
1695 + if (err < 0)
1696 + return err;
1697 + err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
1698 + "Capture Switch", sw);
1699 + if (err < 0)
1700 + return err;
1701 + return 0;
1702 +}
1703 +
1704 /* add playback controls from the parsed DAC table */
1705 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
1706 const struct auto_pin_cfg *cfg)
1707 {
1708 struct sigmatel_spec *spec = codec->spec;
1709 + hda_nid_t nid;
1710 int err;
1711 + int idx;
1712
1713 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
1714 spec->multiout.dac_nids,
1715 @@ -3096,20 +3216,13 @@ static int stac92xx_auto_create_multi_ou
1716 return err;
1717 }
1718
1719 - if (spec->line_switch) {
1720 - err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
1721 - "Line In as Output Switch",
1722 - spec->line_switch << 8);
1723 - if (err < 0)
1724 - return err;
1725 - }
1726 -
1727 - if (spec->mic_switch) {
1728 - err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
1729 - "Mic as Output Switch",
1730 - (spec->mic_switch << 8) | 1);
1731 - if (err < 0)
1732 - return err;
1733 + for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
1734 + nid = cfg->input_pins[idx];
1735 + if (nid) {
1736 + err = stac92xx_add_jack_mode_control(codec, nid, idx);
1737 + if (err < 0)
1738 + return err;
1739 + }
1740 }
1741
1742 return 0;
1743 @@ -3152,7 +3265,7 @@ static int stac92xx_auto_create_mono_out
1744 spec->mono_nid,
1745 con_lst,
1746 HDA_MAX_NUM_INPUTS);
1747 - if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
1748 + if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
1749 return -EINVAL;
1750
1751 for (i = 0; i < num_cons; i++) {
1752 @@ -3298,7 +3411,7 @@ static int stac92xx_auto_create_spdif_mu
1753 spec->smux_nids[0],
1754 con_lst,
1755 HDA_MAX_NUM_INPUTS);
1756 - if (!num_cons)
1757 + if (num_cons <= 0)
1758 return -EINVAL;
1759
1760 if (!labels)
1761 @@ -3319,53 +3432,66 @@ static const char *stac92xx_dmic_labels[
1762 "Digital Mic 3", "Digital Mic 4"
1763 };
1764
1765 +static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1766 + hda_nid_t nid)
1767 +{
1768 + hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1769 + int i, nums;
1770 +
1771 + nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1772 + for (i = 0; i < nums; i++)
1773 + if (conn[i] == nid)
1774 + return i;
1775 + return -1;
1776 +}
1777 +
1778 /* create playback/capture controls for input pins on dmic capable codecs */
1779 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
1780 const struct auto_pin_cfg *cfg)
1781 {
1782 struct sigmatel_spec *spec = codec->spec;
1783 + struct hda_input_mux *imux = &spec->private_imux;
1784 struct hda_input_mux *dimux = &spec->private_dimux;
1785 - hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1786 - int err, i, j;
1787 + int err, i, active_mics;
1788 + unsigned int def_conf;
1789 char name[32];
1790
1791 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
1792 dimux->items[dimux->num_items].index = 0;
1793 dimux->num_items++;
1794
1795 + active_mics = 0;
1796 + for (i = 0; i < spec->num_dmics; i++) {
1797 + def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
1798 + if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
1799 + active_mics++;
1800 + }
1801 +
1802 for (i = 0; i < spec->num_dmics; i++) {
1803 hda_nid_t nid;
1804 int index;
1805 - int num_cons;
1806 unsigned int wcaps;
1807 - unsigned int def_conf;
1808 + const char *label;
1809
1810 - def_conf = snd_hda_codec_read(codec,
1811 - spec->dmic_nids[i],
1812 - 0,
1813 - AC_VERB_GET_CONFIG_DEFAULT,
1814 - 0);
1815 + def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
1816 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
1817 continue;
1818
1819 nid = spec->dmic_nids[i];
1820 - num_cons = snd_hda_get_connections(codec,
1821 - spec->dmux_nids[0],
1822 - con_lst,
1823 - HDA_MAX_NUM_INPUTS);
1824 - for (j = 0; j < num_cons; j++)
1825 - if (con_lst[j] == nid) {
1826 - index = j;
1827 - goto found;
1828 - }
1829 - continue;
1830 -found:
1831 + index = get_connection_index(codec, spec->dmux_nids[0], nid);
1832 + if (index < 0)
1833 + continue;
1834 +
1835 + if (active_mics == 1)
1836 + label = "Digital Mic";
1837 + else
1838 + label = stac92xx_dmic_labels[dimux->num_items];
1839 +
1840 wcaps = get_wcaps(codec, nid) &
1841 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
1842
1843 if (wcaps) {
1844 - sprintf(name, "%s Capture Volume",
1845 - stac92xx_dmic_labels[dimux->num_items]);
1846 + sprintf(name, "%s Capture Volume", label);
1847
1848 err = stac92xx_add_control(spec,
1849 STAC_CTL_WIDGET_VOL,
1850 @@ -3377,15 +3503,100 @@ found:
1851 return err;
1852 }
1853
1854 - dimux->items[dimux->num_items].label =
1855 - stac92xx_dmic_labels[dimux->num_items];
1856 + dimux->items[dimux->num_items].label = label;
1857 dimux->items[dimux->num_items].index = index;
1858 dimux->num_items++;
1859 +
1860 + imux->items[imux->num_items].label = label;
1861 + imux->items[imux->num_items].index = index;
1862 + imux->num_items++;
1863 }
1864
1865 return 0;
1866 }
1867
1868 +static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
1869 + hda_nid_t *fixed, hda_nid_t *ext)
1870 +{
1871 + unsigned int cfg;
1872 +
1873 + if (!nid)
1874 + return 0;
1875 + cfg = snd_hda_codec_get_pincfg(codec, nid);
1876 + switch (get_defcfg_connect(cfg)) {
1877 + case AC_JACK_PORT_FIXED:
1878 + if (*fixed)
1879 + return 1; /* already occupied */
1880 + *fixed = nid;
1881 + break;
1882 + case AC_JACK_PORT_COMPLEX:
1883 + if (*ext)
1884 + return 1; /* already occupied */
1885 + *ext = nid;
1886 + break;
1887 + }
1888 + return 0;
1889 +}
1890 +
1891 +static int set_mic_route(struct hda_codec *codec,
1892 + struct sigmatel_mic_route *mic,
1893 + hda_nid_t pin)
1894 +{
1895 + struct sigmatel_spec *spec = codec->spec;
1896 + struct auto_pin_cfg *cfg = &spec->autocfg;
1897 + int i;
1898 +
1899 + mic->pin = pin;
1900 + for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
1901 + if (pin == cfg->input_pins[i])
1902 + break;
1903 + if (i <= AUTO_PIN_FRONT_MIC) {
1904 + /* analog pin */
1905 + mic->dmux_idx = 0;
1906 + i = get_connection_index(codec, spec->mux_nids[0], pin);
1907 + if (i < 0)
1908 + return -1;
1909 + mic->mux_idx = i;
1910 + } else if (spec->dmux_nids) {
1911 + /* digital pin */
1912 + mic->mux_idx = 0;
1913 + i = get_connection_index(codec, spec->dmux_nids[0], pin);
1914 + if (i < 0)
1915 + return -1;
1916 + mic->dmux_idx = i;
1917 + }
1918 + return 0;
1919 +}
1920 +
1921 +/* return non-zero if the device is for automatic mic switch */
1922 +static int stac_check_auto_mic(struct hda_codec *codec)
1923 +{
1924 + struct sigmatel_spec *spec = codec->spec;
1925 + struct auto_pin_cfg *cfg = &spec->autocfg;
1926 + hda_nid_t fixed, ext;
1927 + int i;
1928 +
1929 + for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) {
1930 + if (cfg->input_pins[i])
1931 + return 0; /* must be exclusively mics */
1932 + }
1933 + fixed = ext = 0;
1934 + for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
1935 + if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext))
1936 + return 0;
1937 + for (i = 0; i < spec->num_dmics; i++)
1938 + if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext))
1939 + return 0;
1940 + if (!fixed || !ext)
1941 + return 0;
1942 + if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1943 + return 0; /* no unsol support */
1944 + if (set_mic_route(codec, &spec->ext_mic, ext) ||
1945 + set_mic_route(codec, &spec->int_mic, fixed))
1946 + return 0; /* something is wrong */
1947 + return 1;
1948 +}
1949 +
1950 /* create playback/capture controls for input pins */
1951 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
1952 {
1953 @@ -3418,6 +3629,7 @@ static int stac92xx_auto_create_analog_i
1954 imux->items[imux->num_items].index = index;
1955 imux->num_items++;
1956 }
1957 + spec->num_analog_muxes = imux->num_items;
1958
1959 if (imux->num_items) {
1960 /*
1961 @@ -3469,7 +3681,7 @@ static int stac92xx_parse_auto_config(st
1962 {
1963 struct sigmatel_spec *spec = codec->spec;
1964 int hp_swap = 0;
1965 - int err;
1966 + int i, err;
1967
1968 if ((err = snd_hda_parse_pin_def_config(codec,
1969 &spec->autocfg,
1970 @@ -3509,11 +3721,10 @@ static int stac92xx_parse_auto_config(st
1971 if (snd_hda_get_connections(codec,
1972 spec->autocfg.mono_out_pin, conn_list, 1) &&
1973 snd_hda_get_connections(codec, conn_list[0],
1974 - conn_list, 1)) {
1975 + conn_list, 1) > 0) {
1976
1977 int wcaps = get_wcaps(codec, conn_list[0]);
1978 - int wid_type = (wcaps & AC_WCAP_TYPE)
1979 - >> AC_WCAP_TYPE_SHIFT;
1980 + int wid_type = get_wcaps_type(wcaps);
1981 /* LR swap check, some stac925x have a mux that
1982 * changes the DACs output path instead of the
1983 * mono-mux path.
1984 @@ -3578,6 +3789,8 @@ static int stac92xx_parse_auto_config(st
1985 err = snd_hda_attach_beep_device(codec, nid);
1986 if (err < 0)
1987 return err;
1988 + /* IDT/STAC codecs have linear beep tone parameter */
1989 + /*codec->beep->linear_tone = 1;*/
1990 /* if no beep switch is available, make its own one */
1991 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
1992 if (codec->beep &&
1993 @@ -3602,6 +3815,21 @@ static int stac92xx_parse_auto_config(st
1994 spec->autocfg.line_outs = 0;
1995 }
1996
1997 + if (stac_check_auto_mic(codec)) {
1998 + spec->auto_mic = 1;
1999 + /* only one capture for auto-mic */
2000 + spec->num_adcs = 1;
2001 + spec->num_caps = 1;
2002 + spec->num_muxes = 1;
2003 + }
2004 +
2005 + for (i = 0; i < spec->num_caps; i++) {
2006 + err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
2007 + spec->capsws[i], i);
2008 + if (err < 0)
2009 + return err;
2010 + }
2011 +
2012 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
2013 if (err < 0)
2014 return err;
2015 @@ -3631,6 +3859,10 @@ static int stac92xx_parse_auto_config(st
2016 return err;
2017 }
2018
2019 + err = stac92xx_add_input_source(spec);
2020 + if (err < 0)
2021 + return err;
2022 +
2023 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2024 if (spec->multiout.max_channels > 2)
2025 spec->surr_switch = 1;
2026 @@ -3640,8 +3872,8 @@ static int stac92xx_parse_auto_config(st
2027 if (dig_in && spec->autocfg.dig_in_pin)
2028 spec->dig_in_nid = dig_in;
2029
2030 - if (spec->kctl_alloc)
2031 - spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2032 + if (spec->kctls.list)
2033 + spec->mixers[spec->num_mixers++] = spec->kctls.list;
2034
2035 spec->input_mux = &spec->private_imux;
2036 if (!spec->dinput_mux)
2037 @@ -3698,9 +3930,7 @@ static int stac9200_auto_create_lfe_ctls
2038 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
2039 hda_nid_t pin = spec->autocfg.line_out_pins[i];
2040 unsigned int defcfg;
2041 - defcfg = snd_hda_codec_read(codec, pin, 0,
2042 - AC_VERB_GET_CONFIG_DEFAULT,
2043 - 0x00);
2044 + defcfg = snd_hda_codec_get_pincfg(codec, pin);
2045 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
2046 unsigned int wcaps = get_wcaps(codec, pin);
2047 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2048 @@ -3744,13 +3974,17 @@ static int stac9200_parse_auto_config(st
2049 return err;
2050 }
2051
2052 + err = stac92xx_add_input_source(spec);
2053 + if (err < 0)
2054 + return err;
2055 +
2056 if (spec->autocfg.dig_out_pin)
2057 spec->multiout.dig_out_nid = 0x05;
2058 if (spec->autocfg.dig_in_pin)
2059 spec->dig_in_nid = 0x04;
2060
2061 - if (spec->kctl_alloc)
2062 - spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2063 + if (spec->kctls.list)
2064 + spec->mixers[spec->num_mixers++] = spec->kctls.list;
2065
2066 spec->input_mux = &spec->private_imux;
2067 spec->dinput_mux = &spec->private_dimux;
2068 @@ -3799,26 +4033,27 @@ static int stac_add_event(struct sigmate
2069 {
2070 struct sigmatel_event *event;
2071
2072 - if (spec->num_events >= ARRAY_SIZE(spec->events))
2073 + snd_array_init(&spec->events, sizeof(*event), 32);
2074 + event = snd_array_new(&spec->events);
2075 + if (!event)
2076 return -ENOMEM;
2077 - event = &spec->events[spec->num_events++];
2078 event->nid = nid;
2079 event->type = type;
2080 - event->tag = spec->num_events;
2081 + event->tag = spec->events.used;
2082 event->data = data;
2083
2084 return event->tag;
2085 }
2086
2087 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
2088 - hda_nid_t nid, unsigned char type)
2089 + hda_nid_t nid)
2090 {
2091 struct sigmatel_spec *spec = codec->spec;
2092 - struct sigmatel_event *event = spec->events;
2093 + struct sigmatel_event *event = spec->events.list;
2094 int i;
2095
2096 - for (i = 0; i < spec->num_events; i++, event++) {
2097 - if (event->nid == nid && event->type == type)
2098 + for (i = 0; i < spec->events.used; i++, event++) {
2099 + if (event->nid == nid)
2100 return event;
2101 }
2102 return NULL;
2103 @@ -3828,34 +4063,42 @@ static struct sigmatel_event *stac_get_e
2104 unsigned char tag)
2105 {
2106 struct sigmatel_spec *spec = codec->spec;
2107 - struct sigmatel_event *event = spec->events;
2108 + struct sigmatel_event *event = spec->events.list;
2109 int i;
2110
2111 - for (i = 0; i < spec->num_events; i++, event++) {
2112 + for (i = 0; i < spec->events.used; i++, event++) {
2113 if (event->tag == tag)
2114 return event;
2115 }
2116 return NULL;
2117 }
2118
2119 -static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
2120 - unsigned int type)
2121 +/* check if given nid is a valid pin and no other events are assigned
2122 + * to it. If OK, assign the event, set the unsol flag, and returns 1.
2123 + * Otherwise, returns zero.
2124 + */
2125 +static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
2126 + unsigned int type)
2127 {
2128 struct sigmatel_event *event;
2129 int tag;
2130
2131 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
2132 - return;
2133 - event = stac_get_event(codec, nid, type);
2134 - if (event)
2135 + return 0;
2136 + event = stac_get_event(codec, nid);
2137 + if (event) {
2138 + if (event->type != type)
2139 + return 0;
2140 tag = event->tag;
2141 - else
2142 + } else {
2143 tag = stac_add_event(codec->spec, nid, type, 0);
2144 - if (tag < 0)
2145 - return;
2146 + if (tag < 0)
2147 + return 0;
2148 + }
2149 snd_hda_codec_write_cache(codec, nid, 0,
2150 AC_VERB_SET_UNSOLICITED_ENABLE,
2151 AC_USRSP_EN | tag);
2152 + return 1;
2153 }
2154
2155 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
2156 @@ -3915,46 +4158,64 @@ static int stac92xx_init(struct hda_code
2157 hda_nid_t nid = cfg->hp_pins[i];
2158 enable_pin_detect(codec, nid, STAC_HP_EVENT);
2159 }
2160 + if (cfg->line_out_type == AUTO_PIN_LINE_OUT) {
2161 + /* enable pin-detect for line-outs as well */
2162 + for (i = 0; i < cfg->line_outs; i++) {
2163 + hda_nid_t nid = cfg->line_out_pins[i];
2164 + enable_pin_detect(codec, nid, STAC_LO_EVENT);
2165 + }
2166 + }
2167 +
2168 /* force to enable the first line-out; the others are set up
2169 * in unsol_event
2170 */
2171 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
2172 - AC_PINCTL_OUT_EN);
2173 + AC_PINCTL_OUT_EN);
2174 /* fake event to set up pins */
2175 - stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
2176 - STAC_HP_EVENT);
2177 + stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
2178 } else {
2179 stac92xx_auto_init_multi_out(codec);
2180 stac92xx_auto_init_hp_out(codec);
2181 for (i = 0; i < cfg->hp_outs; i++)
2182 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
2183 }
2184 + if (spec->auto_mic) {
2185 + /* initialize connection to analog input */
2186 + if (spec->dmux_nids)
2187 + snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
2188 + AC_VERB_SET_CONNECT_SEL, 0);
2189 + if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
2190 + stac_issue_unsol_event(codec, spec->ext_mic.pin);
2191 + }
2192 for (i = 0; i < AUTO_PIN_LAST; i++) {
2193 hda_nid_t nid = cfg->input_pins[i];
2194 if (nid) {
2195 unsigned int pinctl, conf;
2196 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
2197 /* for mic pins, force to initialize */
2198 - pinctl = stac92xx_get_vref(codec, nid);
2199 + pinctl = stac92xx_get_default_vref(codec, nid);
2200 pinctl |= AC_PINCTL_IN_EN;
2201 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2202 } else {
2203 pinctl = snd_hda_codec_read(codec, nid, 0,
2204 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2205 /* if PINCTL already set then skip */
2206 - if (!(pinctl & AC_PINCTL_IN_EN)) {
2207 + /* Also, if both INPUT and OUTPUT are set,
2208 + * it must be a BIOS bug; need to override, too
2209 + */
2210 + if (!(pinctl & AC_PINCTL_IN_EN) ||
2211 + (pinctl & AC_PINCTL_OUT_EN)) {
2212 + pinctl &= ~AC_PINCTL_OUT_EN;
2213 pinctl |= AC_PINCTL_IN_EN;
2214 stac92xx_auto_set_pinctl(codec, nid,
2215 pinctl);
2216 }
2217 }
2218 - conf = snd_hda_codec_read(codec, nid, 0,
2219 - AC_VERB_GET_CONFIG_DEFAULT, 0);
2220 + conf = snd_hda_codec_get_pincfg(codec, nid);
2221 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
2222 - enable_pin_detect(codec, nid,
2223 - STAC_INSERT_EVENT);
2224 - stac_issue_unsol_event(codec, nid,
2225 - STAC_INSERT_EVENT);
2226 + if (enable_pin_detect(codec, nid,
2227 + STAC_INSERT_EVENT))
2228 + stac_issue_unsol_event(codec, nid);
2229 }
2230 }
2231 }
2232 @@ -3990,8 +4251,7 @@ static int stac92xx_init(struct hda_code
2233 stac_toggle_power_map(codec, nid, 1);
2234 continue;
2235 }
2236 - def_conf = snd_hda_codec_read(codec, nid, 0,
2237 - AC_VERB_GET_CONFIG_DEFAULT, 0);
2238 + def_conf = snd_hda_codec_get_pincfg(codec, nid);
2239 def_conf = get_defcfg_connect(def_conf);
2240 /* skip any ports that don't have jacks since presence
2241 * detection is useless */
2242 @@ -4000,32 +4260,35 @@ static int stac92xx_init(struct hda_code
2243 stac_toggle_power_map(codec, nid, 1);
2244 continue;
2245 }
2246 - if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
2247 - enable_pin_detect(codec, nid, STAC_PWR_EVENT);
2248 - stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
2249 - }
2250 + if (enable_pin_detect(codec, nid, STAC_PWR_EVENT))
2251 + stac_issue_unsol_event(codec, nid);
2252 }
2253 if (spec->dac_list)
2254 stac92xx_power_down(codec);
2255 return 0;
2256 }
2257
2258 +static void stac92xx_free_kctls(struct hda_codec *codec)
2259 +{
2260 + struct sigmatel_spec *spec = codec->spec;
2261 +
2262 + if (spec->kctls.list) {
2263 + struct snd_kcontrol_new *kctl = spec->kctls.list;
2264 + int i;
2265 + for (i = 0; i < spec->kctls.used; i++)
2266 + kfree(kctl[i].name);
2267 + }
2268 + snd_array_free(&spec->kctls);
2269 +}
2270 +
2271 static void stac92xx_free(struct hda_codec *codec)
2272 {
2273 struct sigmatel_spec *spec = codec->spec;
2274 - int i;
2275
2276 if (! spec)
2277 return;
2278
2279 - if (spec->kctl_alloc) {
2280 - for (i = 0; i < spec->num_kctl_used; i++)
2281 - kfree(spec->kctl_alloc[i].name);
2282 - kfree(spec->kctl_alloc);
2283 - }
2284 -
2285 - if (spec->bios_pin_configs)
2286 - kfree(spec->bios_pin_configs);
2287 + snd_array_free(&spec->events);
2288
2289 kfree(spec);
2290 snd_hda_detach_beep_device(codec);
2291 @@ -4034,7 +4297,9 @@ static void stac92xx_free(struct hda_cod
2292 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
2293 unsigned int flag)
2294 {
2295 - unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
2296 + unsigned int old_ctl, pin_ctl;
2297 +
2298 + pin_ctl = snd_hda_codec_read(codec, nid,
2299 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
2300
2301 if (pin_ctl & AC_PINCTL_IN_EN) {
2302 @@ -4048,14 +4313,17 @@ static void stac92xx_set_pinctl(struct h
2303 return;
2304 }
2305
2306 + old_ctl = pin_ctl;
2307 /* if setting pin direction bits, clear the current
2308 direction bits first */
2309 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
2310 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
2311
2312 - snd_hda_codec_write_cache(codec, nid, 0,
2313 - AC_VERB_SET_PIN_WIDGET_CONTROL,
2314 - pin_ctl | flag);
2315 + pin_ctl |= flag;
2316 + if (old_ctl != pin_ctl)
2317 + snd_hda_codec_write_cache(codec, nid, 0,
2318 + AC_VERB_SET_PIN_WIDGET_CONTROL,
2319 + pin_ctl);
2320 }
2321
2322 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
2323 @@ -4063,9 +4331,10 @@ static void stac92xx_reset_pinctl(struct
2324 {
2325 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
2326 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
2327 - snd_hda_codec_write_cache(codec, nid, 0,
2328 - AC_VERB_SET_PIN_WIDGET_CONTROL,
2329 - pin_ctl & ~flag);
2330 + if (pin_ctl & flag)
2331 + snd_hda_codec_write_cache(codec, nid, 0,
2332 + AC_VERB_SET_PIN_WIDGET_CONTROL,
2333 + pin_ctl & ~flag);
2334 }
2335
2336 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
2337 @@ -4078,6 +4347,48 @@ static int get_pin_presence(struct hda_c
2338 return 0;
2339 }
2340
2341 +static void stac92xx_line_out_detect(struct hda_codec *codec,
2342 + int presence)
2343 +{
2344 + struct sigmatel_spec *spec = codec->spec;
2345 + struct auto_pin_cfg *cfg = &spec->autocfg;
2346 + int i;
2347 +
2348 + for (i = 0; i < cfg->line_outs; i++) {
2349 + if (presence)
2350 + break;
2351 + presence = get_pin_presence(codec, cfg->line_out_pins[i]);
2352 + if (presence) {
2353 + unsigned int pinctl;
2354 + pinctl = snd_hda_codec_read(codec,
2355 + cfg->line_out_pins[i], 0,
2356 + AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2357 + if (pinctl & AC_PINCTL_IN_EN)
2358 + presence = 0; /* mic- or line-input */
2359 + }
2360 + }
2361 +
2362 + if (presence) {
2363 + /* disable speakers */
2364 + for (i = 0; i < cfg->speaker_outs; i++)
2365 + stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
2366 + AC_PINCTL_OUT_EN);
2367 + if (spec->eapd_mask && spec->eapd_switch)
2368 + stac_gpio_set(codec, spec->gpio_mask,
2369 + spec->gpio_dir, spec->gpio_data &
2370 + ~spec->eapd_mask);
2371 + } else {
2372 + /* enable speakers */
2373 + for (i = 0; i < cfg->speaker_outs; i++)
2374 + stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
2375 + AC_PINCTL_OUT_EN);
2376 + if (spec->eapd_mask && spec->eapd_switch)
2377 + stac_gpio_set(codec, spec->gpio_mask,
2378 + spec->gpio_dir, spec->gpio_data |
2379 + spec->eapd_mask);
2380 + }
2381 +}
2382 +
2383 /* return non-zero if the hp-pin of the given array index isn't
2384 * a jack-detection target
2385 */
2386 @@ -4130,13 +4441,6 @@ static void stac92xx_hp_detect(struct hd
2387 for (i = 0; i < cfg->line_outs; i++)
2388 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
2389 AC_PINCTL_OUT_EN);
2390 - for (i = 0; i < cfg->speaker_outs; i++)
2391 - stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
2392 - AC_PINCTL_OUT_EN);
2393 - if (spec->eapd_mask && spec->eapd_switch)
2394 - stac_gpio_set(codec, spec->gpio_mask,
2395 - spec->gpio_dir, spec->gpio_data &
2396 - ~spec->eapd_mask);
2397 } else {
2398 /* enable lineouts */
2399 if (spec->hp_switch)
2400 @@ -4145,14 +4449,8 @@ static void stac92xx_hp_detect(struct hd
2401 for (i = 0; i < cfg->line_outs; i++)
2402 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
2403 AC_PINCTL_OUT_EN);
2404 - for (i = 0; i < cfg->speaker_outs; i++)
2405 - stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
2406 - AC_PINCTL_OUT_EN);
2407 - if (spec->eapd_mask && spec->eapd_switch)
2408 - stac_gpio_set(codec, spec->gpio_mask,
2409 - spec->gpio_dir, spec->gpio_data |
2410 - spec->eapd_mask);
2411 }
2412 + stac92xx_line_out_detect(codec, presence);
2413 /* toggle hp outs */
2414 for (i = 0; i < cfg->hp_outs; i++) {
2415 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
2416 @@ -4210,10 +4508,28 @@ static void stac92xx_pin_sense(struct hd
2417 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
2418 }
2419
2420 -static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2421 - unsigned char type)
2422 +static void stac92xx_mic_detect(struct hda_codec *codec)
2423 +{
2424 + struct sigmatel_spec *spec = codec->spec;
2425 + struct sigmatel_mic_route *mic;
2426 +
2427 + if (get_pin_presence(codec, spec->ext_mic.pin))
2428 + mic = &spec->ext_mic;
2429 + else
2430 + mic = &spec->int_mic;
2431 + if (mic->dmux_idx)
2432 + snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
2433 + AC_VERB_SET_CONNECT_SEL,
2434 + mic->dmux_idx);
2435 + else
2436 + snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
2437 + AC_VERB_SET_CONNECT_SEL,
2438 + mic->mux_idx);
2439 +}
2440 +
2441 +static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
2442 {
2443 - struct sigmatel_event *event = stac_get_event(codec, nid, type);
2444 + struct sigmatel_event *event = stac_get_event(codec, nid);
2445 if (!event)
2446 return;
2447 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
2448 @@ -4232,12 +4548,40 @@ static void stac92xx_unsol_event(struct
2449
2450 switch (event->type) {
2451 case STAC_HP_EVENT:
2452 + case STAC_LO_EVENT:
2453 stac92xx_hp_detect(codec);
2454 - /* fallthru */
2455 + break;
2456 + case STAC_MIC_EVENT:
2457 + stac92xx_mic_detect(codec);
2458 + break;
2459 + }
2460 +
2461 + switch (event->type) {
2462 + case STAC_HP_EVENT:
2463 + case STAC_LO_EVENT:
2464 + case STAC_MIC_EVENT:
2465 case STAC_INSERT_EVENT:
2466 case STAC_PWR_EVENT:
2467 if (spec->num_pwrs > 0)
2468 stac92xx_pin_sense(codec, event->nid);
2469 +
2470 + switch (codec->subsystem_id) {
2471 + case 0x103c308f:
2472 + if (event->nid == 0xb) {
2473 + int pin = AC_PINCTL_IN_EN;
2474 +
2475 + if (get_pin_presence(codec, 0xa)
2476 + && get_pin_presence(codec, 0xb))
2477 + pin |= AC_PINCTL_VREF_80;
2478 + if (!get_pin_presence(codec, 0xb))
2479 + pin |= AC_PINCTL_VREF_80;
2480 +
2481 + /* toggle VREF state based on mic + hp pin
2482 + * status
2483 + */
2484 + stac92xx_auto_set_pinctl(codec, 0x0a, pin);
2485 + }
2486 + }
2487 break;
2488 case STAC_VREF_EVENT:
2489 data = snd_hda_codec_read(codec, codec->afg, 0,
2490 @@ -4254,17 +4598,48 @@ static int stac92xx_resume(struct hda_co
2491 {
2492 struct sigmatel_spec *spec = codec->spec;
2493
2494 - stac92xx_set_config_regs(codec);
2495 stac92xx_init(codec);
2496 snd_hda_codec_resume_amp(codec);
2497 snd_hda_codec_resume_cache(codec);
2498 /* fake event to set up pins again to override cached values */
2499 if (spec->hp_detect)
2500 - stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
2501 - STAC_HP_EVENT);
2502 + stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
2503 return 0;
2504 }
2505
2506 +/*
2507 + * using power check for controlling mute led of HP notebooks
2508 + * check for mute state only on Speakers (nid = 0x10)
2509 + *
2510 + * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
2511 + * the LED is NOT working properly !
2512 + *
2513 + * Changed name to reflect that it now works for any designated
2514 + * model, not just HP HDX.
2515 + */
2516 +
2517 +#ifdef CONFIG_SND_HDA_POWER_SAVE
2518 +static int stac92xx_hp_check_power_status(struct hda_codec *codec,
2519 + hda_nid_t nid)
2520 +{
2521 + struct sigmatel_spec *spec = codec->spec;
2522 +
2523 + if (nid == 0x10) {
2524 + if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
2525 + HDA_AMP_MUTE)
2526 + spec->gpio_data &= ~spec->gpio_led; /* orange */
2527 + else
2528 + spec->gpio_data |= spec->gpio_led; /* white */
2529 +
2530 + stac_gpio_set(codec, spec->gpio_mask,
2531 + spec->gpio_dir,
2532 + spec->gpio_data);
2533 + }
2534 +
2535 + return 0;
2536 +}
2537 +#endif
2538 +
2539 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
2540 {
2541 struct sigmatel_spec *spec = codec->spec;
2542 @@ -4275,8 +4650,7 @@ static int stac92xx_suspend(struct hda_c
2543 nid = codec->start_nid;
2544 for (i = 0; i < codec->num_nodes; i++, nid++) {
2545 unsigned int wcaps = get_wcaps(codec, nid);
2546 - unsigned int wid_type = (wcaps & AC_WCAP_TYPE) >>
2547 - AC_WCAP_TYPE_SHIFT;
2548 + unsigned int wid_type = get_wcaps_type(wcaps);
2549 if (wid_type == AC_WID_PIN)
2550 snd_hda_codec_read(codec, nid, 0,
2551 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
2552 @@ -4435,6 +4809,9 @@ static int patch_stac925x(struct hda_cod
2553
2554 spec->init = stac925x_core_init;
2555 spec->mixer = stac925x_mixer;
2556 + spec->num_caps = 1;
2557 + spec->capvols = stac925x_capvols;
2558 + spec->capsws = stac925x_capsws;
2559
2560 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
2561 if (!err) {
2562 @@ -4456,16 +4833,6 @@ static int patch_stac925x(struct hda_cod
2563 return 0;
2564 }
2565
2566 -static struct hda_input_mux stac92hd73xx_dmux = {
2567 - .num_items = 4,
2568 - .items = {
2569 - { "Analog Inputs", 0x0b },
2570 - { "Digital Mic 1", 0x09 },
2571 - { "Digital Mic 2", 0x0a },
2572 - { "CD", 0x08 },
2573 - }
2574 -};
2575 -
2576 static int patch_stac92hd73xx(struct hda_codec *codec)
2577 {
2578 struct sigmatel_spec *spec;
2579 @@ -4520,12 +4887,10 @@ again:
2580 case 0x5: /* 10 Channel */
2581 spec->mixer = stac92hd73xx_10ch_mixer;
2582 spec->init = stac92hd73xx_10ch_core_init;
2583 + break;
2584 }
2585 spec->multiout.dac_nids = spec->dac_nids;
2586
2587 - spec->aloopback_mask = 0x01;
2588 - spec->aloopback_shift = 8;
2589 -
2590 spec->digbeep_nid = 0x1c;
2591 spec->mux_nids = stac92hd73xx_mux_nids;
2592 spec->adc_nids = stac92hd73xx_adc_nids;
2593 @@ -4538,8 +4903,10 @@ again:
2594 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
2595 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
2596 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
2597 - memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
2598 - sizeof(stac92hd73xx_dmux));
2599 +
2600 + spec->num_caps = STAC92HD73XX_NUM_CAPS;
2601 + spec->capvols = stac92hd73xx_capvols;
2602 + spec->capsws = stac92hd73xx_capsws;
2603
2604 switch (spec->board_config) {
2605 case STAC_DELL_EQ:
2606 @@ -4558,20 +4925,17 @@ again:
2607 spec->init = dell_m6_core_init;
2608 switch (spec->board_config) {
2609 case STAC_DELL_M6_AMIC: /* Analog Mics */
2610 - stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
2611 + snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
2612 spec->num_dmics = 0;
2613 - spec->private_dimux.num_items = 1;
2614 break;
2615 case STAC_DELL_M6_DMIC: /* Digital Mics */
2616 - stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
2617 + snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
2618 spec->num_dmics = 1;
2619 - spec->private_dimux.num_items = 2;
2620 break;
2621 case STAC_DELL_M6_BOTH: /* Both */
2622 - stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
2623 - stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
2624 + snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
2625 + snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
2626 spec->num_dmics = 1;
2627 - spec->private_dimux.num_items = 2;
2628 break;
2629 }
2630 break;
2631 @@ -4579,13 +4943,13 @@ again:
2632 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
2633 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
2634 spec->eapd_switch = 1;
2635 + break;
2636 }
2637 if (spec->board_config > STAC_92HD73XX_REF) {
2638 /* GPIO0 High = Enable EAPD */
2639 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
2640 spec->gpio_data = 0x01;
2641 }
2642 - spec->dinput_mux = &spec->private_dimux;
2643
2644 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
2645 spec->pwr_nids = stac92hd73xx_pwr_nids;
2646 @@ -4615,21 +4979,13 @@ again:
2647 return 0;
2648 }
2649
2650 -static struct hda_input_mux stac92hd83xxx_dmux = {
2651 - .num_items = 3,
2652 - .items = {
2653 - { "Analog Inputs", 0x03 },
2654 - { "Digital Mic 1", 0x04 },
2655 - { "Digital Mic 2", 0x05 },
2656 - }
2657 -};
2658 -
2659 static int patch_stac92hd83xxx(struct hda_codec *codec)
2660 {
2661 struct sigmatel_spec *spec;
2662 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
2663 int err;
2664 int num_dacs;
2665 + hda_nid_t nid;
2666
2667 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2668 if (spec == NULL)
2669 @@ -4648,14 +5004,6 @@ static int patch_stac92hd83xxx(struct hd
2670 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
2671 spec->multiout.dac_nids = spec->dac_nids;
2672
2673 - /* set port 0xe to select the last DAC
2674 - */
2675 - num_dacs = snd_hda_get_connections(codec, 0x0e,
2676 - conn, STAC92HD83_DAC_COUNT + 1) - 1;
2677 -
2678 - snd_hda_codec_write_cache(codec, 0xe, 0,
2679 - AC_VERB_SET_CONNECT_SEL, num_dacs);
2680 -
2681 spec->init = stac92hd83xxx_core_init;
2682 spec->mixer = stac92hd83xxx_mixer;
2683 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
2684 @@ -4663,8 +5011,11 @@ static int patch_stac92hd83xxx(struct hd
2685 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
2686 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
2687 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
2688 - spec->dinput_mux = &stac92hd83xxx_dmux;
2689 spec->pin_nids = stac92hd83xxx_pin_nids;
2690 + spec->num_caps = STAC92HD83XXX_NUM_CAPS;
2691 + spec->capvols = stac92hd83xxx_capvols;
2692 + spec->capsws = stac92hd83xxx_capsws;
2693 +
2694 spec->board_config = snd_hda_check_board_config(codec,
2695 STAC_92HD83XXX_MODELS,
2696 stac92hd83xxx_models,
2697 @@ -4687,6 +5038,7 @@ again:
2698 switch (codec->vendor_id) {
2699 case 0x111d7604:
2700 case 0x111d7605:
2701 + case 0x111d76d5:
2702 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
2703 break;
2704 spec->num_pwrs = 0;
2705 @@ -4709,24 +5061,89 @@ again:
2706 return err;
2707 }
2708
2709 + switch (spec->board_config) {
2710 + case STAC_DELL_S14:
2711 + nid = 0xf;
2712 + break;
2713 + default:
2714 + nid = 0xe;
2715 + break;
2716 + }
2717 +
2718 + num_dacs = snd_hda_get_connections(codec, nid,
2719 + conn, STAC92HD83_DAC_COUNT + 1) - 1;
2720 + if (num_dacs < 0)
2721 + num_dacs = STAC92HD83_DAC_COUNT;
2722 +
2723 + /* set port X to select the last DAC
2724 + */
2725 + snd_hda_codec_write_cache(codec, nid, 0,
2726 + AC_VERB_SET_CONNECT_SEL, num_dacs);
2727 +
2728 codec->patch_ops = stac92xx_patch_ops;
2729
2730 return 0;
2731 }
2732
2733 -static struct hda_input_mux stac92hd71bxx_dmux = {
2734 - .num_items = 4,
2735 - .items = {
2736 - { "Analog Inputs", 0x00 },
2737 - { "Mixer", 0x01 },
2738 - { "Digital Mic 1", 0x02 },
2739 - { "Digital Mic 2", 0x03 },
2740 +/* get the pin connection (fixed, none, etc) */
2741 +static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
2742 +{
2743 + struct sigmatel_spec *spec = codec->spec;
2744 + unsigned int cfg;
2745 +
2746 + cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
2747 + return get_defcfg_connect(cfg);
2748 +}
2749 +
2750 +static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
2751 + hda_nid_t *nids, int num_nids)
2752 +{
2753 + struct sigmatel_spec *spec = codec->spec;
2754 + int idx, num;
2755 + unsigned int def_conf;
2756 +
2757 + for (num = 0; num < num_nids; num++) {
2758 + for (idx = 0; idx < spec->num_pins; idx++)
2759 + if (spec->pin_nids[idx] == nids[num])
2760 + break;
2761 + if (idx >= spec->num_pins)
2762 + break;
2763 + def_conf = stac_get_defcfg_connect(codec, idx);
2764 + if (def_conf == AC_JACK_PORT_NONE)
2765 + break;
2766 }
2767 -};
2768 + return num;
2769 +}
2770 +
2771 +static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
2772 + hda_nid_t dig0pin)
2773 +{
2774 + struct sigmatel_spec *spec = codec->spec;
2775 + int idx;
2776 +
2777 + for (idx = 0; idx < spec->num_pins; idx++)
2778 + if (spec->pin_nids[idx] == dig0pin)
2779 + break;
2780 + if ((idx + 2) >= spec->num_pins)
2781 + return 0;
2782 +
2783 + /* dig1pin case */
2784 + if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
2785 + return 2;
2786 +
2787 + /* dig0pin + dig2pin case */
2788 + if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
2789 + return 2;
2790 + if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
2791 + return 1;
2792 + else
2793 + return 0;
2794 +}
2795
2796 static int patch_stac92hd71bxx(struct hda_codec *codec)
2797 {
2798 struct sigmatel_spec *spec;
2799 + struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
2800 int err = 0;
2801
2802 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2803 @@ -4735,11 +5152,21 @@ static int patch_stac92hd71bxx(struct hd
2804
2805 codec->spec = spec;
2806 codec->patch_ops = stac92xx_patch_ops;
2807 - spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
2808 + spec->num_pins = STAC92HD71BXX_NUM_PINS;
2809 + switch (codec->vendor_id) {
2810 + case 0x111d76b6:
2811 + case 0x111d76b7:
2812 + spec->pin_nids = stac92hd71bxx_pin_nids_4port;
2813 + break;
2814 + case 0x111d7603:
2815 + case 0x111d7608:
2816 + /* On 92HD75Bx 0x27 isn't a pin nid */
2817 + spec->num_pins--;
2818 + /* fallthrough */
2819 + default:
2820 + spec->pin_nids = stac92hd71bxx_pin_nids_6port;
2821 + }
2822 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
2823 - spec->pin_nids = stac92hd71bxx_pin_nids;
2824 - memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
2825 - sizeof(stac92hd71bxx_dmux));
2826 spec->board_config = snd_hda_check_board_config(codec,
2827 STAC_92HD71BXX_MODELS,
2828 stac92hd71bxx_models,
2829 @@ -4766,14 +5193,25 @@ again:
2830 spec->gpio_data = 0x01;
2831 }
2832
2833 + spec->dmic_nids = stac92hd71bxx_dmic_nids;
2834 + spec->dmux_nids = stac92hd71bxx_dmux_nids;
2835 +
2836 + spec->num_caps = STAC92HD71BXX_NUM_CAPS;
2837 + spec->capvols = stac92hd71bxx_capvols;
2838 + spec->capsws = stac92hd71bxx_capsws;
2839 +
2840 switch (codec->vendor_id) {
2841 case 0x111d76b6: /* 4 Port without Analog Mixer */
2842 case 0x111d76b7:
2843 + unmute_init++;
2844 + /* fallthru */
2845 case 0x111d76b4: /* 6 Port without Analog Mixer */
2846 case 0x111d76b5:
2847 - spec->mixer = stac92hd71bxx_mixer;
2848 spec->init = stac92hd71bxx_core_init;
2849 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
2850 + spec->num_dmics = stac92hd71bxx_connected_ports(codec,
2851 + stac92hd71bxx_dmic_nids,
2852 + STAC92HD71BXX_NUM_DMICS);
2853 break;
2854 case 0x111d7608: /* 5 Port with Analog Mixer */
2855 switch (spec->board_config) {
2856 @@ -4797,12 +5235,15 @@ again:
2857
2858 /* no output amps */
2859 spec->num_pwrs = 0;
2860 - spec->mixer = stac92hd71bxx_analog_mixer;
2861 - spec->dinput_mux = &spec->private_dimux;
2862 -
2863 /* disable VSW */
2864 - spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
2865 - stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
2866 + spec->init = stac92hd71bxx_core_init;
2867 + unmute_init++;
2868 + snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
2869 + snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
2870 + stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
2871 + spec->num_dmics = stac92hd71bxx_connected_ports(codec,
2872 + stac92hd71bxx_dmic_nids,
2873 + STAC92HD71BXX_NUM_DMICS - 1);
2874 break;
2875 case 0x111d7603: /* 6 Port with Analog Mixer */
2876 if ((codec->revision_id & 0xf) == 1)
2877 @@ -4812,12 +5253,17 @@ again:
2878 spec->num_pwrs = 0;
2879 /* fallthru */
2880 default:
2881 - spec->dinput_mux = &spec->private_dimux;
2882 - spec->mixer = stac92hd71bxx_analog_mixer;
2883 - spec->init = stac92hd71bxx_analog_core_init;
2884 + spec->init = stac92hd71bxx_core_init;
2885 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
2886 + spec->num_dmics = stac92hd71bxx_connected_ports(codec,
2887 + stac92hd71bxx_dmic_nids,
2888 + STAC92HD71BXX_NUM_DMICS);
2889 + break;
2890 }
2891
2892 + if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
2893 + snd_hda_sequence_write_cache(codec, unmute_init);
2894 +
2895 /* Some HP machines seem to have unstable codec communications
2896 * especially with ATI fglrx driver. For recovering from the
2897 * CORB/RIRB stall, allow the BUS reset and keep always sync
2898 @@ -4827,25 +5273,22 @@ again:
2899 codec->bus->allow_bus_reset = 1;
2900 }
2901
2902 - spec->aloopback_mask = 0x50;
2903 - spec->aloopback_shift = 0;
2904 -
2905 spec->powerdown_adcs = 1;
2906 spec->digbeep_nid = 0x26;
2907 spec->mux_nids = stac92hd71bxx_mux_nids;
2908 spec->adc_nids = stac92hd71bxx_adc_nids;
2909 - spec->dmic_nids = stac92hd71bxx_dmic_nids;
2910 - spec->dmux_nids = stac92hd71bxx_dmux_nids;
2911 spec->smux_nids = stac92hd71bxx_smux_nids;
2912 spec->pwr_nids = stac92hd71bxx_pwr_nids;
2913
2914 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
2915 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
2916 + spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
2917 + spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
2918
2919 switch (spec->board_config) {
2920 case STAC_HP_M4:
2921 /* enable internal microphone */
2922 - stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
2923 + snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
2924 stac92xx_auto_set_pinctl(codec, 0x0e,
2925 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
2926 /* fallthru */
2927 @@ -4860,19 +5303,42 @@ again:
2928 spec->num_smuxes = 0;
2929 spec->num_dmuxes = 1;
2930 break;
2931 - default:
2932 - spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
2933 - spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
2934 - spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
2935 - };
2936 + case STAC_HP_DV4_1222NR:
2937 + spec->num_dmics = 1;
2938 + /* I don't know if it needs 1 or 2 smuxes - will wait for
2939 + * bug reports to fix if needed
2940 + */
2941 + spec->num_smuxes = 1;
2942 + spec->num_dmuxes = 1;
2943 + spec->gpio_led = 0x01;
2944 + /* fallthrough */
2945 + case STAC_HP_DV5:
2946 + snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
2947 + stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
2948 + break;
2949 + case STAC_HP_HDX:
2950 + spec->num_dmics = 1;
2951 + spec->num_dmuxes = 1;
2952 + spec->num_smuxes = 1;
2953 + /* orange/white mute led on GPIO3, orange=0, white=1 */
2954 + spec->gpio_led = 0x08;
2955 + break;
2956 + }
2957 +
2958 +#ifdef CONFIG_SND_HDA_POWER_SAVE
2959 + if (spec->gpio_led) {
2960 + spec->gpio_mask |= spec->gpio_led;
2961 + spec->gpio_dir |= spec->gpio_led;
2962 + spec->gpio_data |= spec->gpio_led;
2963 + /* register check_power_status callback. */
2964 + codec->patch_ops.check_power_status =
2965 + stac92xx_hp_check_power_status;
2966 + }
2967 +#endif
2968
2969 spec->multiout.dac_nids = spec->dac_nids;
2970 - if (spec->dinput_mux)
2971 - spec->private_dimux.num_items +=
2972 - spec->num_dmics -
2973 - (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
2974
2975 - err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
2976 + err = stac92xx_parse_auto_config(codec, 0x21, 0);
2977 if (!err) {
2978 if (spec->board_config < 0) {
2979 printk(KERN_WARNING "hda_codec: No auto-config is "
2980 @@ -4889,7 +5355,7 @@ again:
2981 }
2982
2983 return 0;
2984 -};
2985 +}
2986
2987 static int patch_stac922x(struct hda_codec *codec)
2988 {
2989 @@ -4967,7 +5433,10 @@ static int patch_stac922x(struct hda_cod
2990 spec->num_pwrs = 0;
2991
2992 spec->init = stac922x_core_init;
2993 - spec->mixer = stac922x_mixer;
2994 +
2995 + spec->num_caps = STAC922X_NUM_CAPS;
2996 + spec->capvols = stac922x_capvols;
2997 + spec->capsws = stac922x_capsws;
2998
2999 spec->multiout.dac_nids = spec->dac_nids;
3000
3001 @@ -5008,6 +5477,7 @@ static int patch_stac927x(struct hda_cod
3002 return -ENOMEM;
3003
3004 codec->spec = spec;
3005 + codec->slave_dig_outs = stac927x_slave_dig_outs;
3006 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
3007 spec->pin_nids = stac927x_pin_nids;
3008 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
3009 @@ -5049,32 +5519,37 @@ static int patch_stac927x(struct hda_cod
3010 spec->num_dmics = 0;
3011
3012 spec->init = d965_core_init;
3013 - spec->mixer = stac927x_mixer;
3014 break;
3015 case STAC_DELL_BIOS:
3016 switch (codec->subsystem_id) {
3017 case 0x10280209:
3018 case 0x1028022e:
3019 /* correct the device field to SPDIF out */
3020 - stac92xx_set_config_reg(codec, 0x21, 0x01442070);
3021 + snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
3022 break;
3023 - };
3024 + }
3025 /* configure the analog microphone on some laptops */
3026 - stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
3027 + snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
3028 /* correct the front output jack as a hp out */
3029 - stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
3030 + snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
3031 /* correct the front input jack as a mic */
3032 - stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
3033 + snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
3034 /* fallthru */
3035 case STAC_DELL_3ST:
3036 /* GPIO2 High = Enable EAPD */
3037 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
3038 spec->gpio_data = 0x04;
3039 + switch (codec->subsystem_id) {
3040 + case 0x1028022f:
3041 + /* correct EAPD to be GPIO0 */
3042 + spec->eapd_mask = spec->gpio_mask = 0x01;
3043 + spec->gpio_dir = spec->gpio_data = 0x01;
3044 + break;
3045 + };
3046 spec->dmic_nids = stac927x_dmic_nids;
3047 spec->num_dmics = STAC927X_NUM_DMICS;
3048
3049 spec->init = d965_core_init;
3050 - spec->mixer = stac927x_mixer;
3051 spec->dmux_nids = stac927x_dmux_nids;
3052 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
3053 break;
3054 @@ -5087,12 +5562,13 @@ static int patch_stac927x(struct hda_cod
3055 spec->num_dmics = 0;
3056
3057 spec->init = stac927x_core_init;
3058 - spec->mixer = stac927x_mixer;
3059 }
3060
3061 + spec->num_caps = STAC927X_NUM_CAPS;
3062 + spec->capvols = stac927x_capvols;
3063 + spec->capsws = stac927x_capsws;
3064 +
3065 spec->num_pwrs = 0;
3066 - spec->aloopback_mask = 0x40;
3067 - spec->aloopback_shift = 0;
3068 spec->eapd_switch = 1;
3069
3070 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
3071 @@ -5174,10 +5650,11 @@ static int patch_stac9205(struct hda_cod
3072 spec->num_pwrs = 0;
3073
3074 spec->init = stac9205_core_init;
3075 - spec->mixer = stac9205_mixer;
3076
3077 - spec->aloopback_mask = 0x40;
3078 - spec->aloopback_shift = 0;
3079 + spec->num_caps = STAC9205_NUM_CAPS;
3080 + spec->capvols = stac9205_capvols;
3081 + spec->capsws = stac9205_capsws;
3082 +
3083 /* Turn on/off EAPD per HP plugging */
3084 if (spec->board_config != STAC_9205_EAPD)
3085 spec->eapd_switch = 1;
3086 @@ -5186,8 +5663,8 @@ static int patch_stac9205(struct hda_cod
3087 switch (spec->board_config){
3088 case STAC_9205_DELL_M43:
3089 /* Enable SPDIF in/out */
3090 - stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
3091 - stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
3092 + snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
3093 + snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
3094
3095 /* Enable unsol response for GPIO4/Dock HP connection */
3096 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
3097 @@ -5521,6 +5998,7 @@ struct hda_codec_preset snd_hda_preset_s
3098 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
3099 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
3100 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
3101 + { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
3102 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
3103 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
3104 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
3105 @@ -5532,6 +6010,7 @@ struct hda_codec_preset snd_hda_preset_s
3106 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
3107 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
3108 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
3109 + { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
3110 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
3111 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
3112 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },