Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target...
[cascardo/linux.git] / sound / pci / hda / patch_analog.c
1 /*
2  * HD audio interface patch for AD1882, AD1884, AD1981HD, AD1983, AD1984,
3  *   AD1986A, AD1988
4  *
5  * Copyright (c) 2005-2007 Takashi Iwai <tiwai@suse.de>
6  *
7  *  This driver is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This driver is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20  */
21
22 #include <linux/init.h>
23 #include <linux/slab.h>
24 #include <linux/module.h>
25
26 #include <sound/core.h>
27 #include "hda_codec.h"
28 #include "hda_local.h"
29 #include "hda_auto_parser.h"
30 #include "hda_beep.h"
31 #include "hda_jack.h"
32 #include "hda_generic.h"
33
34
35 struct ad198x_spec {
36         struct hda_gen_spec gen;
37
38         /* for auto parser */
39         int smux_paths[4];
40         unsigned int cur_smux;
41         hda_nid_t eapd_nid;
42
43         unsigned int beep_amp;  /* beep amp value, set via set_beep_amp() */
44 };
45
46
47 #ifdef CONFIG_SND_HDA_INPUT_BEEP
48 /* additional beep mixers; the actual parameters are overwritten at build */
49 static const struct snd_kcontrol_new ad_beep_mixer[] = {
50         HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_OUTPUT),
51         HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_OUTPUT),
52         { } /* end */
53 };
54
55 #define set_beep_amp(spec, nid, idx, dir) \
56         ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */
57 #else
58 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
59 #endif
60
61 #ifdef CONFIG_SND_HDA_INPUT_BEEP
62 static int create_beep_ctls(struct hda_codec *codec)
63 {
64         struct ad198x_spec *spec = codec->spec;
65         const struct snd_kcontrol_new *knew;
66
67         if (!spec->beep_amp)
68                 return 0;
69
70         for (knew = ad_beep_mixer ; knew->name; knew++) {
71                 int err;
72                 struct snd_kcontrol *kctl;
73                 kctl = snd_ctl_new1(knew, codec);
74                 if (!kctl)
75                         return -ENOMEM;
76                 kctl->private_value = spec->beep_amp;
77                 err = snd_hda_ctl_add(codec, 0, kctl);
78                 if (err < 0)
79                         return err;
80         }
81         return 0;
82 }
83 #else
84 #define create_beep_ctls(codec)         0
85 #endif
86
87
88 static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front,
89                                 hda_nid_t hp)
90 {
91         if (snd_hda_query_pin_caps(codec, front) & AC_PINCAP_EAPD)
92                 snd_hda_codec_write(codec, front, 0, AC_VERB_SET_EAPD_BTLENABLE,
93                             !codec->inv_eapd ? 0x00 : 0x02);
94         if (snd_hda_query_pin_caps(codec, hp) & AC_PINCAP_EAPD)
95                 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_EAPD_BTLENABLE,
96                             !codec->inv_eapd ? 0x00 : 0x02);
97 }
98
99 static void ad198x_power_eapd(struct hda_codec *codec)
100 {
101         /* We currently only handle front, HP */
102         switch (codec->vendor_id) {
103         case 0x11d41882:
104         case 0x11d4882a:
105         case 0x11d41884:
106         case 0x11d41984:
107         case 0x11d41883:
108         case 0x11d4184a:
109         case 0x11d4194a:
110         case 0x11d4194b:
111         case 0x11d41988:
112         case 0x11d4198b:
113         case 0x11d4989a:
114         case 0x11d4989b:
115                 ad198x_power_eapd_write(codec, 0x12, 0x11);
116                 break;
117         case 0x11d41981:
118         case 0x11d41983:
119                 ad198x_power_eapd_write(codec, 0x05, 0x06);
120                 break;
121         case 0x11d41986:
122                 ad198x_power_eapd_write(codec, 0x1b, 0x1a);
123                 break;
124         }
125 }
126
127 static void ad198x_shutup(struct hda_codec *codec)
128 {
129         snd_hda_shutup_pins(codec);
130         ad198x_power_eapd(codec);
131 }
132
133 #ifdef CONFIG_PM
134 static int ad198x_suspend(struct hda_codec *codec)
135 {
136         ad198x_shutup(codec);
137         return 0;
138 }
139 #endif
140
141 /* follow EAPD via vmaster hook */
142 static void ad_vmaster_eapd_hook(void *private_data, int enabled)
143 {
144         struct hda_codec *codec = private_data;
145         struct ad198x_spec *spec = codec->spec;
146
147         if (!spec->eapd_nid)
148                 return;
149         if (codec->inv_eapd)
150                 enabled = !enabled;
151         snd_hda_codec_update_cache(codec, spec->eapd_nid, 0,
152                                    AC_VERB_SET_EAPD_BTLENABLE,
153                                    enabled ? 0x02 : 0x00);
154 }
155
156 /*
157  * Automatic parse of I/O pins from the BIOS configuration
158  */
159
160 static int ad198x_auto_build_controls(struct hda_codec *codec)
161 {
162         int err;
163
164         err = snd_hda_gen_build_controls(codec);
165         if (err < 0)
166                 return err;
167         err = create_beep_ctls(codec);
168         if (err < 0)
169                 return err;
170         return 0;
171 }
172
173 static const struct hda_codec_ops ad198x_auto_patch_ops = {
174         .build_controls = ad198x_auto_build_controls,
175         .build_pcms = snd_hda_gen_build_pcms,
176         .init = snd_hda_gen_init,
177         .free = snd_hda_gen_free,
178         .unsol_event = snd_hda_jack_unsol_event,
179 #ifdef CONFIG_PM
180         .check_power_status = snd_hda_gen_check_power_status,
181         .suspend = ad198x_suspend,
182 #endif
183         .reboot_notify = ad198x_shutup,
184 };
185
186
187 static int ad198x_parse_auto_config(struct hda_codec *codec, bool indep_hp)
188 {
189         struct ad198x_spec *spec = codec->spec;
190         struct auto_pin_cfg *cfg = &spec->gen.autocfg;
191         int err;
192
193         codec->spdif_status_reset = 1;
194         codec->no_trigger_sense = 1;
195         codec->no_sticky_stream = 1;
196
197         spec->gen.indep_hp = indep_hp;
198         spec->gen.add_stereo_mix_input = 1;
199
200         err = snd_hda_parse_pin_defcfg(codec, cfg, NULL, 0);
201         if (err < 0)
202                 return err;
203         err = snd_hda_gen_parse_auto_config(codec, cfg);
204         if (err < 0)
205                 return err;
206
207         codec->patch_ops = ad198x_auto_patch_ops;
208
209         return 0;
210 }
211
212 /*
213  * AD1986A specific
214  */
215
216 static int alloc_ad_spec(struct hda_codec *codec)
217 {
218         struct ad198x_spec *spec;
219
220         spec = kzalloc(sizeof(*spec), GFP_KERNEL);
221         if (!spec)
222                 return -ENOMEM;
223         codec->spec = spec;
224         snd_hda_gen_spec_init(&spec->gen);
225         return 0;
226 }
227
228 /*
229  * AD1986A fixup codes
230  */
231
232 /* Lenovo N100 seems to report the reversed bit for HP jack-sensing */
233 static void ad_fixup_inv_jack_detect(struct hda_codec *codec,
234                                      const struct hda_fixup *fix, int action)
235 {
236         struct ad198x_spec *spec = codec->spec;
237
238         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
239                 codec->inv_jack_detect = 1;
240                 spec->gen.keep_eapd_on = 1;
241                 spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook;
242                 spec->eapd_nid = 0x1b;
243         }
244 }
245
246 /* Toshiba Satellite L40 implements EAPD in a standard way unlike others */
247 static void ad1986a_fixup_eapd(struct hda_codec *codec,
248                                const struct hda_fixup *fix, int action)
249 {
250         struct ad198x_spec *spec = codec->spec;
251
252         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
253                 codec->inv_eapd = 0;
254                 spec->gen.keep_eapd_on = 1;
255                 spec->eapd_nid = 0x1b;
256         }
257 }
258
259 enum {
260         AD1986A_FIXUP_INV_JACK_DETECT,
261         AD1986A_FIXUP_ULTRA,
262         AD1986A_FIXUP_SAMSUNG,
263         AD1986A_FIXUP_3STACK,
264         AD1986A_FIXUP_LAPTOP,
265         AD1986A_FIXUP_LAPTOP_IMIC,
266         AD1986A_FIXUP_EAPD,
267 };
268
269 static const struct hda_fixup ad1986a_fixups[] = {
270         [AD1986A_FIXUP_INV_JACK_DETECT] = {
271                 .type = HDA_FIXUP_FUNC,
272                 .v.func = ad_fixup_inv_jack_detect,
273         },
274         [AD1986A_FIXUP_ULTRA] = {
275                 .type = HDA_FIXUP_PINS,
276                 .v.pins = (const struct hda_pintbl[]) {
277                         { 0x1b, 0x90170110 }, /* speaker */
278                         { 0x1d, 0x90a7013e }, /* int mic */
279                         {}
280                 },
281         },
282         [AD1986A_FIXUP_SAMSUNG] = {
283                 .type = HDA_FIXUP_PINS,
284                 .v.pins = (const struct hda_pintbl[]) {
285                         { 0x1b, 0x90170110 }, /* speaker */
286                         { 0x1d, 0x90a7013e }, /* int mic */
287                         { 0x20, 0x411111f0 }, /* N/A */
288                         { 0x24, 0x411111f0 }, /* N/A */
289                         {}
290                 },
291         },
292         [AD1986A_FIXUP_3STACK] = {
293                 .type = HDA_FIXUP_PINS,
294                 .v.pins = (const struct hda_pintbl[]) {
295                         { 0x1a, 0x02214021 }, /* headphone */
296                         { 0x1b, 0x01014011 }, /* front */
297                         { 0x1c, 0x01813030 }, /* line-in */
298                         { 0x1d, 0x01a19020 }, /* rear mic */
299                         { 0x1e, 0x411111f0 }, /* N/A */
300                         { 0x1f, 0x02a190f0 }, /* mic */
301                         { 0x20, 0x411111f0 }, /* N/A */
302                         {}
303                 },
304         },
305         [AD1986A_FIXUP_LAPTOP] = {
306                 .type = HDA_FIXUP_PINS,
307                 .v.pins = (const struct hda_pintbl[]) {
308                         { 0x1a, 0x02214021 }, /* headphone */
309                         { 0x1b, 0x90170110 }, /* speaker */
310                         { 0x1c, 0x411111f0 }, /* N/A */
311                         { 0x1d, 0x411111f0 }, /* N/A */
312                         { 0x1e, 0x411111f0 }, /* N/A */
313                         { 0x1f, 0x02a191f0 }, /* mic */
314                         { 0x20, 0x411111f0 }, /* N/A */
315                         {}
316                 },
317         },
318         [AD1986A_FIXUP_LAPTOP_IMIC] = {
319                 .type = HDA_FIXUP_PINS,
320                 .v.pins = (const struct hda_pintbl[]) {
321                         { 0x1d, 0x90a7013e }, /* int mic */
322                         {}
323                 },
324                 .chained_before = 1,
325                 .chain_id = AD1986A_FIXUP_LAPTOP,
326         },
327         [AD1986A_FIXUP_EAPD] = {
328                 .type = HDA_FIXUP_FUNC,
329                 .v.func = ad1986a_fixup_eapd,
330         },
331 };
332
333 static const struct snd_pci_quirk ad1986a_fixup_tbl[] = {
334         SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_FIXUP_LAPTOP_IMIC),
335         SND_PCI_QUIRK(0x1043, 0x1443, "ASUS Z99He", AD1986A_FIXUP_EAPD),
336         SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8JN", AD1986A_FIXUP_EAPD),
337         SND_PCI_QUIRK_MASK(0x1043, 0xff00, 0x8100, "ASUS P5", AD1986A_FIXUP_3STACK),
338         SND_PCI_QUIRK_MASK(0x1043, 0xff00, 0x8200, "ASUS M2", AD1986A_FIXUP_3STACK),
339         SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_FIXUP_3STACK),
340         SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba Satellite L40", AD1986A_FIXUP_EAPD),
341         SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_FIXUP_LAPTOP),
342         SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_FIXUP_SAMSUNG),
343         SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_FIXUP_ULTRA),
344         SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_FIXUP_INV_JACK_DETECT),
345         SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_FIXUP_3STACK),
346         SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_FIXUP_3STACK),
347         {}
348 };
349
350 static const struct hda_model_fixup ad1986a_fixup_models[] = {
351         { .id = AD1986A_FIXUP_3STACK, .name = "3stack" },
352         { .id = AD1986A_FIXUP_LAPTOP, .name = "laptop" },
353         { .id = AD1986A_FIXUP_LAPTOP_IMIC, .name = "laptop-imic" },
354         { .id = AD1986A_FIXUP_LAPTOP_IMIC, .name = "laptop-eapd" }, /* alias */
355         { .id = AD1986A_FIXUP_EAPD, .name = "eapd" },
356         {}
357 };
358
359 /*
360  */
361 static int patch_ad1986a(struct hda_codec *codec)
362 {
363         int err;
364         struct ad198x_spec *spec;
365         static hda_nid_t preferred_pairs[] = {
366                 0x1a, 0x03,
367                 0x1b, 0x03,
368                 0x1c, 0x04,
369                 0x1d, 0x05,
370                 0x1e, 0x03,
371                 0
372         };
373
374         err = alloc_ad_spec(codec);
375         if (err < 0)
376                 return err;
377         spec = codec->spec;
378
379         /* AD1986A has the inverted EAPD implementation */
380         codec->inv_eapd = 1;
381
382         spec->gen.mixer_nid = 0x07;
383         spec->gen.beep_nid = 0x19;
384         set_beep_amp(spec, 0x18, 0, HDA_OUTPUT);
385
386         /* AD1986A has a hardware problem that it can't share a stream
387          * with multiple output pins.  The copy of front to surrounds
388          * causes noisy or silent outputs at a certain timing, e.g.
389          * changing the volume.
390          * So, let's disable the shared stream.
391          */
392         spec->gen.multiout.no_share_stream = 1;
393         /* give fixed DAC/pin pairs */
394         spec->gen.preferred_dacs = preferred_pairs;
395
396         /* AD1986A can't manage the dynamic pin on/off smoothly */
397         spec->gen.auto_mute_via_amp = 1;
398
399         snd_hda_pick_fixup(codec, ad1986a_fixup_models, ad1986a_fixup_tbl,
400                            ad1986a_fixups);
401         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
402
403         err = ad198x_parse_auto_config(codec, false);
404         if (err < 0) {
405                 snd_hda_gen_free(codec);
406                 return err;
407         }
408
409         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
410
411         return 0;
412 }
413
414
415 /*
416  * AD1983 specific
417  */
418
419 /*
420  * SPDIF mux control for AD1983 auto-parser
421  */
422 static int ad1983_auto_smux_enum_info(struct snd_kcontrol *kcontrol,
423                                       struct snd_ctl_elem_info *uinfo)
424 {
425         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
426         struct ad198x_spec *spec = codec->spec;
427         static const char * const texts2[] = { "PCM", "ADC" };
428         static const char * const texts3[] = { "PCM", "ADC1", "ADC2" };
429         hda_nid_t dig_out = spec->gen.multiout.dig_out_nid;
430         int num_conns = snd_hda_get_num_conns(codec, dig_out);
431
432         if (num_conns == 2)
433                 return snd_hda_enum_helper_info(kcontrol, uinfo, 2, texts2);
434         else if (num_conns == 3)
435                 return snd_hda_enum_helper_info(kcontrol, uinfo, 3, texts3);
436         else
437                 return -EINVAL;
438 }
439
440 static int ad1983_auto_smux_enum_get(struct snd_kcontrol *kcontrol,
441                                      struct snd_ctl_elem_value *ucontrol)
442 {
443         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
444         struct ad198x_spec *spec = codec->spec;
445
446         ucontrol->value.enumerated.item[0] = spec->cur_smux;
447         return 0;
448 }
449
450 static int ad1983_auto_smux_enum_put(struct snd_kcontrol *kcontrol,
451                                      struct snd_ctl_elem_value *ucontrol)
452 {
453         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
454         struct ad198x_spec *spec = codec->spec;
455         unsigned int val = ucontrol->value.enumerated.item[0];
456         hda_nid_t dig_out = spec->gen.multiout.dig_out_nid;
457         int num_conns = snd_hda_get_num_conns(codec, dig_out);
458
459         if (val >= num_conns)
460                 return -EINVAL;
461         if (spec->cur_smux == val)
462                 return 0;
463         spec->cur_smux = val;
464         snd_hda_codec_write_cache(codec, dig_out, 0,
465                                   AC_VERB_SET_CONNECT_SEL, val);
466         return 1;
467 }
468
469 static struct snd_kcontrol_new ad1983_auto_smux_mixer = {
470         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
471         .name = "IEC958 Playback Source",
472         .info = ad1983_auto_smux_enum_info,
473         .get = ad1983_auto_smux_enum_get,
474         .put = ad1983_auto_smux_enum_put,
475 };
476
477 static int ad1983_add_spdif_mux_ctl(struct hda_codec *codec)
478 {
479         struct ad198x_spec *spec = codec->spec;
480         hda_nid_t dig_out = spec->gen.multiout.dig_out_nid;
481         int num_conns;
482
483         if (!dig_out)
484                 return 0;
485         num_conns = snd_hda_get_num_conns(codec, dig_out);
486         if (num_conns != 2 && num_conns != 3)
487                 return 0;
488         if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &ad1983_auto_smux_mixer))
489                 return -ENOMEM;
490         return 0;
491 }
492
493 static int patch_ad1983(struct hda_codec *codec)
494 {
495         struct ad198x_spec *spec;
496         static hda_nid_t conn_0c[] = { 0x08 };
497         static hda_nid_t conn_0d[] = { 0x09 };
498         int err;
499
500         err = alloc_ad_spec(codec);
501         if (err < 0)
502                 return err;
503         spec = codec->spec;
504
505         spec->gen.mixer_nid = 0x0e;
506         spec->gen.beep_nid = 0x10;
507         set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
508
509         /* limit the loopback routes not to confuse the parser */
510         snd_hda_override_conn_list(codec, 0x0c, ARRAY_SIZE(conn_0c), conn_0c);
511         snd_hda_override_conn_list(codec, 0x0d, ARRAY_SIZE(conn_0d), conn_0d);
512
513         err = ad198x_parse_auto_config(codec, false);
514         if (err < 0)
515                 goto error;
516         err = ad1983_add_spdif_mux_ctl(codec);
517         if (err < 0)
518                 goto error;
519         return 0;
520
521  error:
522         snd_hda_gen_free(codec);
523         return err;
524 }
525
526
527 /*
528  * AD1981 HD specific
529  */
530
531 static void ad1981_fixup_hp_eapd(struct hda_codec *codec,
532                                  const struct hda_fixup *fix, int action)
533 {
534         struct ad198x_spec *spec = codec->spec;
535
536         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
537                 spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook;
538                 spec->eapd_nid = 0x05;
539         }
540 }
541
542 /* set the upper-limit for mixer amp to 0dB for avoiding the possible
543  * damage by overloading
544  */
545 static void ad1981_fixup_amp_override(struct hda_codec *codec,
546                                       const struct hda_fixup *fix, int action)
547 {
548         if (action == HDA_FIXUP_ACT_PRE_PROBE)
549                 snd_hda_override_amp_caps(codec, 0x11, HDA_INPUT,
550                                           (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
551                                           (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
552                                           (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
553                                           (1 << AC_AMPCAP_MUTE_SHIFT));
554 }
555
556 enum {
557         AD1981_FIXUP_AMP_OVERRIDE,
558         AD1981_FIXUP_HP_EAPD,
559 };
560
561 static const struct hda_fixup ad1981_fixups[] = {
562         [AD1981_FIXUP_AMP_OVERRIDE] = {
563                 .type = HDA_FIXUP_FUNC,
564                 .v.func = ad1981_fixup_amp_override,
565         },
566         [AD1981_FIXUP_HP_EAPD] = {
567                 .type = HDA_FIXUP_FUNC,
568                 .v.func = ad1981_fixup_hp_eapd,
569                 .chained = true,
570                 .chain_id = AD1981_FIXUP_AMP_OVERRIDE,
571         },
572 };
573
574 static const struct snd_pci_quirk ad1981_fixup_tbl[] = {
575         SND_PCI_QUIRK_VENDOR(0x1014, "Lenovo", AD1981_FIXUP_AMP_OVERRIDE),
576         SND_PCI_QUIRK_VENDOR(0x103c, "HP", AD1981_FIXUP_HP_EAPD),
577         SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", AD1981_FIXUP_AMP_OVERRIDE),
578         /* HP nx6320 (reversed SSID, H/W bug) */
579         SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_FIXUP_HP_EAPD),
580         {}
581 };
582
583 static int patch_ad1981(struct hda_codec *codec)
584 {
585         struct ad198x_spec *spec;
586         int err;
587
588         err = alloc_ad_spec(codec);
589         if (err < 0)
590                 return -ENOMEM;
591         spec = codec->spec;
592
593         spec->gen.mixer_nid = 0x0e;
594         spec->gen.beep_nid = 0x10;
595         set_beep_amp(spec, 0x0d, 0, HDA_OUTPUT);
596
597         snd_hda_pick_fixup(codec, NULL, ad1981_fixup_tbl, ad1981_fixups);
598         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
599
600         err = ad198x_parse_auto_config(codec, false);
601         if (err < 0)
602                 goto error;
603         err = ad1983_add_spdif_mux_ctl(codec);
604         if (err < 0)
605                 goto error;
606
607         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
608
609         return 0;
610
611  error:
612         snd_hda_gen_free(codec);
613         return err;
614 }
615
616
617 /*
618  * AD1988
619  *
620  * Output pins and routes
621  *
622  *        Pin               Mix     Sel     DAC (*)
623  * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
624  * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
625  * port-C 0x15 (mute)    <- 0x2c <- 0x31 <- 05/0a
626  * port-D 0x12 (mute/hp) <- 0x29         <- 04
627  * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
628  * port-F 0x16 (mute)    <- 0x2a         <- 06
629  * port-G 0x24 (mute)    <- 0x27         <- 05
630  * port-H 0x25 (mute)    <- 0x28         <- 0a
631  * mono   0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
632  *
633  * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
634  * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
635  *
636  * Input pins and routes
637  *
638  *        pin     boost   mix input # / adc input #
639  * port-A 0x11 -> 0x38 -> mix 2, ADC 0
640  * port-B 0x14 -> 0x39 -> mix 0, ADC 1
641  * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
642  * port-D 0x12 -> 0x3d -> mix 3, ADC 8
643  * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
644  * port-F 0x16 -> 0x3b -> mix 5, ADC 3
645  * port-G 0x24 -> N/A  -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
646  * port-H 0x25 -> N/A  -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
647  *
648  *
649  * DAC assignment
650  *   6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
651  *   3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
652  *
653  * Inputs of Analog Mix (0x20)
654  *   0:Port-B (front mic)
655  *   1:Port-C/G/H (line-in)
656  *   2:Port-A
657  *   3:Port-D (line-in/2)
658  *   4:Port-E/G/H (mic-in)
659  *   5:Port-F (mic2-in)
660  *   6:CD
661  *   7:Beep
662  *
663  * ADC selection
664  *   0:Port-A
665  *   1:Port-B (front mic-in)
666  *   2:Port-C (line-in)
667  *   3:Port-F (mic2-in)
668  *   4:Port-E (mic-in)
669  *   5:CD
670  *   6:Port-G
671  *   7:Port-H
672  *   8:Port-D (line-in/2)
673  *   9:Mix
674  *
675  * Proposed pin assignments by the datasheet
676  *
677  * 6-stack
678  * Port-A front headphone
679  *      B front mic-in
680  *      C rear line-in
681  *      D rear front-out
682  *      E rear mic-in
683  *      F rear surround
684  *      G rear CLFE
685  *      H rear side
686  *
687  * 3-stack
688  * Port-A front headphone
689  *      B front mic
690  *      C rear line-in/surround
691  *      D rear front-out
692  *      E rear mic-in/CLFE
693  *
694  * laptop
695  * Port-A headphone
696  *      B mic-in
697  *      C docking station
698  *      D internal speaker (with EAPD)
699  *      E/F quad mic array
700  */
701
702 #ifdef ENABLE_AD_STATIC_QUIRKS
703 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
704                                struct snd_ctl_elem_info *uinfo)
705 {
706         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
707         struct ad198x_spec *spec = codec->spec;
708         return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
709                                     spec->num_channel_mode);
710 }
711
712 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
713                               struct snd_ctl_elem_value *ucontrol)
714 {
715         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
716         struct ad198x_spec *spec = codec->spec;
717         return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
718                                    spec->num_channel_mode, spec->multiout.max_channels);
719 }
720
721 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
722                               struct snd_ctl_elem_value *ucontrol)
723 {
724         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
725         struct ad198x_spec *spec = codec->spec;
726         int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
727                                       spec->num_channel_mode,
728                                       &spec->multiout.max_channels);
729         if (err >= 0 && spec->need_dac_fix)
730                 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
731         return err;
732 }
733 #endif /* ENABLE_AD_STATIC_QUIRKS */
734
735 static int ad1988_auto_smux_enum_info(struct snd_kcontrol *kcontrol,
736                                       struct snd_ctl_elem_info *uinfo)
737 {
738         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
739         static const char * const texts[] = {
740                 "PCM", "ADC1", "ADC2", "ADC3",
741         };
742         int num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1;
743         if (num_conns > 4)
744                 num_conns = 4;
745         return snd_hda_enum_helper_info(kcontrol, uinfo, num_conns, texts);
746 }
747
748 static int ad1988_auto_smux_enum_get(struct snd_kcontrol *kcontrol,
749                                      struct snd_ctl_elem_value *ucontrol)
750 {
751         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
752         struct ad198x_spec *spec = codec->spec;
753
754         ucontrol->value.enumerated.item[0] = spec->cur_smux;
755         return 0;
756 }
757
758 static int ad1988_auto_smux_enum_put(struct snd_kcontrol *kcontrol,
759                                      struct snd_ctl_elem_value *ucontrol)
760 {
761         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
762         struct ad198x_spec *spec = codec->spec;
763         unsigned int val = ucontrol->value.enumerated.item[0];
764         struct nid_path *path;
765         int num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1;
766
767         if (val >= num_conns)
768                 return -EINVAL;
769         if (spec->cur_smux == val)
770                 return 0;
771
772         mutex_lock(&codec->control_mutex);
773         codec->cached_write = 1;
774         path = snd_hda_get_path_from_idx(codec,
775                                          spec->smux_paths[spec->cur_smux]);
776         if (path)
777                 snd_hda_activate_path(codec, path, false, true);
778         path = snd_hda_get_path_from_idx(codec, spec->smux_paths[val]);
779         if (path)
780                 snd_hda_activate_path(codec, path, true, true);
781         spec->cur_smux = val;
782         codec->cached_write = 0;
783         mutex_unlock(&codec->control_mutex);
784         snd_hda_codec_flush_cache(codec); /* flush the updates */
785         return 1;
786 }
787
788 static struct snd_kcontrol_new ad1988_auto_smux_mixer = {
789         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
790         .name = "IEC958 Playback Source",
791         .info = ad1988_auto_smux_enum_info,
792         .get = ad1988_auto_smux_enum_get,
793         .put = ad1988_auto_smux_enum_put,
794 };
795
796 static int ad1988_auto_init(struct hda_codec *codec)
797 {
798         struct ad198x_spec *spec = codec->spec;
799         int i, err;
800
801         err = snd_hda_gen_init(codec);
802         if (err < 0)
803                 return err;
804         if (!spec->gen.autocfg.dig_outs)
805                 return 0;
806
807         for (i = 0; i < 4; i++) {
808                 struct nid_path *path;
809                 path = snd_hda_get_path_from_idx(codec, spec->smux_paths[i]);
810                 if (path)
811                         snd_hda_activate_path(codec, path, path->active, false);
812         }
813
814         return 0;
815 }
816
817 static int ad1988_add_spdif_mux_ctl(struct hda_codec *codec)
818 {
819         struct ad198x_spec *spec = codec->spec;
820         int i, num_conns;
821         /* we create four static faked paths, since AD codecs have odd
822          * widget connections regarding the SPDIF out source
823          */
824         static struct nid_path fake_paths[4] = {
825                 {
826                         .depth = 3,
827                         .path = { 0x02, 0x1d, 0x1b },
828                         .idx = { 0, 0, 0 },
829                         .multi = { 0, 0, 0 },
830                 },
831                 {
832                         .depth = 4,
833                         .path = { 0x08, 0x0b, 0x1d, 0x1b },
834                         .idx = { 0, 0, 1, 0 },
835                         .multi = { 0, 1, 0, 0 },
836                 },
837                 {
838                         .depth = 4,
839                         .path = { 0x09, 0x0b, 0x1d, 0x1b },
840                         .idx = { 0, 1, 1, 0 },
841                         .multi = { 0, 1, 0, 0 },
842                 },
843                 {
844                         .depth = 4,
845                         .path = { 0x0f, 0x0b, 0x1d, 0x1b },
846                         .idx = { 0, 2, 1, 0 },
847                         .multi = { 0, 1, 0, 0 },
848                 },
849         };
850
851         /* SPDIF source mux appears to be present only on AD1988A */
852         if (!spec->gen.autocfg.dig_outs ||
853             get_wcaps_type(get_wcaps(codec, 0x1d)) != AC_WID_AUD_MIX)
854                 return 0;
855
856         num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1;
857         if (num_conns != 3 && num_conns != 4)
858                 return 0;
859
860         for (i = 0; i < num_conns; i++) {
861                 struct nid_path *path = snd_array_new(&spec->gen.paths);
862                 if (!path)
863                         return -ENOMEM;
864                 *path = fake_paths[i];
865                 if (!i)
866                         path->active = 1;
867                 spec->smux_paths[i] = snd_hda_get_path_idx(codec, path);
868         }
869
870         if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &ad1988_auto_smux_mixer))
871                 return -ENOMEM;
872
873         codec->patch_ops.init = ad1988_auto_init;
874
875         return 0;
876 }
877
878 /*
879  */
880
881 enum {
882         AD1988_FIXUP_6STACK_DIG,
883 };
884
885 static const struct hda_fixup ad1988_fixups[] = {
886         [AD1988_FIXUP_6STACK_DIG] = {
887                 .type = HDA_FIXUP_PINS,
888                 .v.pins = (const struct hda_pintbl[]) {
889                         { 0x11, 0x02214130 }, /* front-hp */
890                         { 0x12, 0x01014010 }, /* line-out */
891                         { 0x14, 0x02a19122 }, /* front-mic */
892                         { 0x15, 0x01813021 }, /* line-in */
893                         { 0x16, 0x01011012 }, /* line-out */
894                         { 0x17, 0x01a19020 }, /* mic */
895                         { 0x1b, 0x0145f1f0 }, /* SPDIF */
896                         { 0x24, 0x01016011 }, /* line-out */
897                         { 0x25, 0x01012013 }, /* line-out */
898                         { }
899                 }
900         },
901 };
902
903 static const struct hda_model_fixup ad1988_fixup_models[] = {
904         { .id = AD1988_FIXUP_6STACK_DIG, .name = "6stack-dig" },
905         {}
906 };
907
908 static int patch_ad1988(struct hda_codec *codec)
909 {
910         struct ad198x_spec *spec;
911         int err;
912
913         err = alloc_ad_spec(codec);
914         if (err < 0)
915                 return err;
916         spec = codec->spec;
917
918         spec->gen.mixer_nid = 0x20;
919         spec->gen.mixer_merge_nid = 0x21;
920         spec->gen.beep_nid = 0x10;
921         set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
922
923         snd_hda_pick_fixup(codec, ad1988_fixup_models, NULL, ad1988_fixups);
924         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
925
926         err = ad198x_parse_auto_config(codec, true);
927         if (err < 0)
928                 goto error;
929         err = ad1988_add_spdif_mux_ctl(codec);
930         if (err < 0)
931                 goto error;
932
933         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
934
935         return 0;
936
937  error:
938         snd_hda_gen_free(codec);
939         return err;
940 }
941
942
943 /*
944  * AD1884 / AD1984
945  *
946  * port-B - front line/mic-in
947  * port-E - aux in/out
948  * port-F - aux in/out
949  * port-C - rear line/mic-in
950  * port-D - rear line/hp-out
951  * port-A - front line/hp-out
952  *
953  * AD1984 = AD1884 + two digital mic-ins
954  *
955  * AD1883 / AD1884A / AD1984A / AD1984B
956  *
957  * port-B (0x14) - front mic-in
958  * port-E (0x1c) - rear mic-in
959  * port-F (0x16) - CD / ext out
960  * port-C (0x15) - rear line-in
961  * port-D (0x12) - rear line-out
962  * port-A (0x11) - front hp-out
963  *
964  * AD1984A = AD1884A + digital-mic
965  * AD1883 = equivalent with AD1984A
966  * AD1984B = AD1984A + extra SPDIF-out
967  */
968
969 /* set the upper-limit for mixer amp to 0dB for avoiding the possible
970  * damage by overloading
971  */
972 static void ad1884_fixup_amp_override(struct hda_codec *codec,
973                                       const struct hda_fixup *fix, int action)
974 {
975         if (action == HDA_FIXUP_ACT_PRE_PROBE)
976                 snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
977                                           (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
978                                           (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
979                                           (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
980                                           (1 << AC_AMPCAP_MUTE_SHIFT));
981 }
982
983 /* toggle GPIO1 according to the mute state */
984 static void ad1884_vmaster_hp_gpio_hook(void *private_data, int enabled)
985 {
986         struct hda_codec *codec = private_data;
987         struct ad198x_spec *spec = codec->spec;
988
989         if (spec->eapd_nid)
990                 ad_vmaster_eapd_hook(private_data, enabled);
991         snd_hda_codec_update_cache(codec, 0x01, 0,
992                                    AC_VERB_SET_GPIO_DATA,
993                                    enabled ? 0x00 : 0x02);
994 }
995
996 static void ad1884_fixup_hp_eapd(struct hda_codec *codec,
997                                  const struct hda_fixup *fix, int action)
998 {
999         struct ad198x_spec *spec = codec->spec;
1000         static const struct hda_verb gpio_init_verbs[] = {
1001                 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1002                 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1003                 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1004                 {},
1005         };
1006
1007         switch (action) {
1008         case HDA_FIXUP_ACT_PRE_PROBE:
1009                 spec->gen.vmaster_mute.hook = ad1884_vmaster_hp_gpio_hook;
1010                 spec->gen.own_eapd_ctl = 1;
1011                 snd_hda_sequence_write_cache(codec, gpio_init_verbs);
1012                 break;
1013         case HDA_FIXUP_ACT_PROBE:
1014                 if (spec->gen.autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
1015                         spec->eapd_nid = spec->gen.autocfg.line_out_pins[0];
1016                 else
1017                         spec->eapd_nid = spec->gen.autocfg.speaker_pins[0];
1018                 break;
1019         }
1020 }
1021
1022 static void ad1884_fixup_thinkpad(struct hda_codec *codec,
1023                                   const struct hda_fixup *fix, int action)
1024 {
1025         struct ad198x_spec *spec = codec->spec;
1026
1027         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1028                 spec->gen.keep_eapd_on = 1;
1029                 spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook;
1030                 spec->eapd_nid = 0x12;
1031                 /* Analog PC Beeper - allow firmware/ACPI beeps */
1032                 spec->beep_amp = HDA_COMPOSE_AMP_VAL(0x20, 3, 3, HDA_INPUT);
1033                 spec->gen.beep_nid = 0; /* no digital beep */
1034         }
1035 }
1036
1037 /* set magic COEFs for dmic */
1038 static const struct hda_verb ad1884_dmic_init_verbs[] = {
1039         {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7},
1040         {0x01, AC_VERB_SET_PROC_COEF, 0x08},
1041         {}
1042 };
1043
1044 enum {
1045         AD1884_FIXUP_AMP_OVERRIDE,
1046         AD1884_FIXUP_HP_EAPD,
1047         AD1884_FIXUP_DMIC_COEF,
1048         AD1884_FIXUP_THINKPAD,
1049         AD1884_FIXUP_HP_TOUCHSMART,
1050 };
1051
1052 static const struct hda_fixup ad1884_fixups[] = {
1053         [AD1884_FIXUP_AMP_OVERRIDE] = {
1054                 .type = HDA_FIXUP_FUNC,
1055                 .v.func = ad1884_fixup_amp_override,
1056         },
1057         [AD1884_FIXUP_HP_EAPD] = {
1058                 .type = HDA_FIXUP_FUNC,
1059                 .v.func = ad1884_fixup_hp_eapd,
1060                 .chained = true,
1061                 .chain_id = AD1884_FIXUP_AMP_OVERRIDE,
1062         },
1063         [AD1884_FIXUP_DMIC_COEF] = {
1064                 .type = HDA_FIXUP_VERBS,
1065                 .v.verbs = ad1884_dmic_init_verbs,
1066         },
1067         [AD1884_FIXUP_THINKPAD] = {
1068                 .type = HDA_FIXUP_FUNC,
1069                 .v.func = ad1884_fixup_thinkpad,
1070                 .chained = true,
1071                 .chain_id = AD1884_FIXUP_DMIC_COEF,
1072         },
1073         [AD1884_FIXUP_HP_TOUCHSMART] = {
1074                 .type = HDA_FIXUP_VERBS,
1075                 .v.verbs = ad1884_dmic_init_verbs,
1076                 .chained = true,
1077                 .chain_id = AD1884_FIXUP_HP_EAPD,
1078         },
1079 };
1080
1081 static const struct snd_pci_quirk ad1884_fixup_tbl[] = {
1082         SND_PCI_QUIRK(0x103c, 0x2a82, "HP Touchsmart", AD1884_FIXUP_HP_TOUCHSMART),
1083         SND_PCI_QUIRK_VENDOR(0x103c, "HP", AD1884_FIXUP_HP_EAPD),
1084         SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1884_FIXUP_THINKPAD),
1085         {}
1086 };
1087
1088
1089 static int patch_ad1884(struct hda_codec *codec)
1090 {
1091         struct ad198x_spec *spec;
1092         int err;
1093
1094         err = alloc_ad_spec(codec);
1095         if (err < 0)
1096                 return err;
1097         spec = codec->spec;
1098
1099         spec->gen.mixer_nid = 0x20;
1100         spec->gen.mixer_merge_nid = 0x21;
1101         spec->gen.beep_nid = 0x10;
1102         set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
1103
1104         snd_hda_pick_fixup(codec, NULL, ad1884_fixup_tbl, ad1884_fixups);
1105         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1106
1107         err = ad198x_parse_auto_config(codec, true);
1108         if (err < 0)
1109                 goto error;
1110         err = ad1983_add_spdif_mux_ctl(codec);
1111         if (err < 0)
1112                 goto error;
1113
1114         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1115
1116         return 0;
1117
1118  error:
1119         snd_hda_gen_free(codec);
1120         return err;
1121 }
1122
1123 /*
1124  * AD1882 / AD1882A
1125  *
1126  * port-A - front hp-out
1127  * port-B - front mic-in
1128  * port-C - rear line-in, shared surr-out (3stack)
1129  * port-D - rear line-out
1130  * port-E - rear mic-in, shared clfe-out (3stack)
1131  * port-F - rear surr-out (6stack)
1132  * port-G - rear clfe-out (6stack)
1133  */
1134
1135 static int patch_ad1882(struct hda_codec *codec)
1136 {
1137         struct ad198x_spec *spec;
1138         int err;
1139
1140         err = alloc_ad_spec(codec);
1141         if (err < 0)
1142                 return err;
1143         spec = codec->spec;
1144
1145         spec->gen.mixer_nid = 0x20;
1146         spec->gen.mixer_merge_nid = 0x21;
1147         spec->gen.beep_nid = 0x10;
1148         set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
1149         err = ad198x_parse_auto_config(codec, true);
1150         if (err < 0)
1151                 goto error;
1152         err = ad1988_add_spdif_mux_ctl(codec);
1153         if (err < 0)
1154                 goto error;
1155         return 0;
1156
1157  error:
1158         snd_hda_gen_free(codec);
1159         return err;
1160 }
1161
1162
1163 /*
1164  * patch entries
1165  */
1166 static const struct hda_codec_preset snd_hda_preset_analog[] = {
1167         { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884 },
1168         { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
1169         { .id = 0x11d41883, .name = "AD1883", .patch = patch_ad1884 },
1170         { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 },
1171         { .id = 0x11d4194a, .name = "AD1984A", .patch = patch_ad1884 },
1172         { .id = 0x11d4194b, .name = "AD1984B", .patch = patch_ad1884 },
1173         { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
1174         { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
1175         { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1884 },
1176         { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
1177         { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
1178         { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },
1179         { .id = 0x11d4882a, .name = "AD1882A", .patch = patch_ad1882 },
1180         { .id = 0x11d4989a, .name = "AD1989A", .patch = patch_ad1988 },
1181         { .id = 0x11d4989b, .name = "AD1989B", .patch = patch_ad1988 },
1182         {} /* terminator */
1183 };
1184
1185 MODULE_ALIAS("snd-hda-codec-id:11d4*");
1186
1187 MODULE_LICENSE("GPL");
1188 MODULE_DESCRIPTION("Analog Devices HD-audio codec");
1189
1190 static struct hda_codec_preset_list analog_list = {
1191         .preset = snd_hda_preset_analog,
1192         .owner = THIS_MODULE,
1193 };
1194
1195 static int __init patch_analog_init(void)
1196 {
1197         return snd_hda_add_codec_preset(&analog_list);
1198 }
1199
1200 static void __exit patch_analog_exit(void)
1201 {
1202         snd_hda_delete_codec_preset(&analog_list);
1203 }
1204
1205 module_init(patch_analog_init)
1206 module_exit(patch_analog_exit)