GNU Linux-libre 4.19.314-gnu1
[releases.git] / sound / pci / hda / patch_via.c
1 /*
2  * Universal Interface for Intel High Definition Audio Codec
3  *
4  * HD audio interface patch for VIA VT17xx/VT18xx/VT20xx codec
5  *
6  *  (C) 2006-2009 VIA Technology, Inc.
7  *  (C) 2006-2008 Takashi Iwai <tiwai@suse.de>
8  *
9  *  This driver is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This driver is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22  */
23
24 /* * * * * * * * * * * * * * Release History * * * * * * * * * * * * * * * * */
25 /*                                                                           */
26 /* 2006-03-03  Lydia Wang  Create the basic patch to support VT1708 codec    */
27 /* 2006-03-14  Lydia Wang  Modify hard code for some pin widget nid          */
28 /* 2006-08-02  Lydia Wang  Add support to VT1709 codec                       */
29 /* 2006-09-08  Lydia Wang  Fix internal loopback recording source select bug */
30 /* 2007-09-12  Lydia Wang  Add EAPD enable during driver initialization      */
31 /* 2007-09-17  Lydia Wang  Add VT1708B codec support                        */
32 /* 2007-11-14  Lydia Wang  Add VT1708A codec HP and CD pin connect config    */
33 /* 2008-02-03  Lydia Wang  Fix Rear channels and Back channels inverse issue */
34 /* 2008-03-06  Lydia Wang  Add VT1702 codec and VT1708S codec support        */
35 /* 2008-04-09  Lydia Wang  Add mute front speaker when HP plugin             */
36 /* 2008-04-09  Lydia Wang  Add Independent HP feature                        */
37 /* 2008-05-28  Lydia Wang  Add second S/PDIF Out support for VT1702          */
38 /* 2008-09-15  Logan Li    Add VT1708S Mic Boost workaround/backdoor         */
39 /* 2009-02-16  Logan Li    Add support for VT1718S                           */
40 /* 2009-03-13  Logan Li    Add support for VT1716S                           */
41 /* 2009-04-14  Lydai Wang  Add support for VT1828S and VT2020                */
42 /* 2009-07-08  Lydia Wang  Add support for VT2002P                           */
43 /* 2009-07-21  Lydia Wang  Add support for VT1812                            */
44 /* 2009-09-19  Lydia Wang  Add support for VT1818S                           */
45 /*                                                                           */
46 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
47
48
49 #include <linux/init.h>
50 #include <linux/delay.h>
51 #include <linux/slab.h>
52 #include <linux/module.h>
53 #include <sound/core.h>
54 #include <sound/asoundef.h>
55 #include "hda_codec.h"
56 #include "hda_local.h"
57 #include "hda_auto_parser.h"
58 #include "hda_jack.h"
59 #include "hda_generic.h"
60
61 /* Pin Widget NID */
62 #define VT1708_HP_PIN_NID       0x20
63 #define VT1708_CD_PIN_NID       0x24
64
65 enum VIA_HDA_CODEC {
66         UNKNOWN = -1,
67         VT1708,
68         VT1709_10CH,
69         VT1709_6CH,
70         VT1708B_8CH,
71         VT1708B_4CH,
72         VT1708S,
73         VT1708BCE,
74         VT1702,
75         VT1718S,
76         VT1716S,
77         VT2002P,
78         VT1812,
79         VT1802,
80         VT1705CF,
81         VT1808,
82         CODEC_TYPES,
83 };
84
85 #define VT2002P_COMPATIBLE(spec) \
86         ((spec)->codec_type == VT2002P ||\
87          (spec)->codec_type == VT1812 ||\
88          (spec)->codec_type == VT1802)
89
90 struct via_spec {
91         struct hda_gen_spec gen;
92
93         /* HP mode source */
94         unsigned int dmic_enabled;
95         enum VIA_HDA_CODEC codec_type;
96
97         /* analog low-power control */
98         bool alc_mode;
99
100         /* work to check hp jack state */
101         int hp_work_active;
102         int vt1708_jack_detect;
103 };
104
105 static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec);
106 static void via_playback_pcm_hook(struct hda_pcm_stream *hinfo,
107                                   struct hda_codec *codec,
108                                   struct snd_pcm_substream *substream,
109                                   int action);
110
111 static const struct hda_codec_ops via_patch_ops; /* defined below */
112
113 static struct via_spec *via_new_spec(struct hda_codec *codec)
114 {
115         struct via_spec *spec;
116
117         spec = kzalloc(sizeof(*spec), GFP_KERNEL);
118         if (spec == NULL)
119                 return NULL;
120
121         codec->spec = spec;
122         snd_hda_gen_spec_init(&spec->gen);
123         spec->codec_type = get_codec_type(codec);
124         /* VT1708BCE & VT1708S are almost same */
125         if (spec->codec_type == VT1708BCE)
126                 spec->codec_type = VT1708S;
127         spec->gen.indep_hp = 1;
128         spec->gen.keep_eapd_on = 1;
129         spec->gen.dac_min_mute = 1;
130         spec->gen.pcm_playback_hook = via_playback_pcm_hook;
131         spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO;
132         codec->power_save_node = 1;
133         spec->gen.power_down_unused = 1;
134         codec->patch_ops = via_patch_ops;
135         return spec;
136 }
137
138 static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec)
139 {
140         u32 vendor_id = codec->core.vendor_id;
141         u16 ven_id = vendor_id >> 16;
142         u16 dev_id = vendor_id & 0xffff;
143         enum VIA_HDA_CODEC codec_type;
144
145         /* get codec type */
146         if (ven_id != 0x1106)
147                 codec_type = UNKNOWN;
148         else if (dev_id >= 0x1708 && dev_id <= 0x170b)
149                 codec_type = VT1708;
150         else if (dev_id >= 0xe710 && dev_id <= 0xe713)
151                 codec_type = VT1709_10CH;
152         else if (dev_id >= 0xe714 && dev_id <= 0xe717)
153                 codec_type = VT1709_6CH;
154         else if (dev_id >= 0xe720 && dev_id <= 0xe723) {
155                 codec_type = VT1708B_8CH;
156                 if (snd_hda_param_read(codec, 0x16, AC_PAR_CONNLIST_LEN) == 0x7)
157                         codec_type = VT1708BCE;
158         } else if (dev_id >= 0xe724 && dev_id <= 0xe727)
159                 codec_type = VT1708B_4CH;
160         else if ((dev_id & 0xfff) == 0x397
161                  && (dev_id >> 12) < 8)
162                 codec_type = VT1708S;
163         else if ((dev_id & 0xfff) == 0x398
164                  && (dev_id >> 12) < 8)
165                 codec_type = VT1702;
166         else if ((dev_id & 0xfff) == 0x428
167                  && (dev_id >> 12) < 8)
168                 codec_type = VT1718S;
169         else if (dev_id == 0x0433 || dev_id == 0xa721)
170                 codec_type = VT1716S;
171         else if (dev_id == 0x0441 || dev_id == 0x4441)
172                 codec_type = VT1718S;
173         else if (dev_id == 0x0438 || dev_id == 0x4438)
174                 codec_type = VT2002P;
175         else if (dev_id == 0x0448)
176                 codec_type = VT1812;
177         else if (dev_id == 0x0440)
178                 codec_type = VT1708S;
179         else if ((dev_id & 0xfff) == 0x446)
180                 codec_type = VT1802;
181         else if (dev_id == 0x4760)
182                 codec_type = VT1705CF;
183         else if (dev_id == 0x4761 || dev_id == 0x4762)
184                 codec_type = VT1808;
185         else
186                 codec_type = UNKNOWN;
187         return codec_type;
188 };
189
190 static void analog_low_current_mode(struct hda_codec *codec);
191 static bool is_aa_path_mute(struct hda_codec *codec);
192
193 #define hp_detect_with_aa(codec) \
194         (snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") == 1 && \
195          !is_aa_path_mute(codec))
196
197 static void vt1708_stop_hp_work(struct hda_codec *codec)
198 {
199         struct via_spec *spec = codec->spec;
200         if (spec->codec_type != VT1708 || !spec->gen.autocfg.hp_outs)
201                 return;
202         if (spec->hp_work_active) {
203                 snd_hda_codec_write(codec, 0x1, 0, 0xf81, 1);
204                 codec->jackpoll_interval = 0;
205                 cancel_delayed_work_sync(&codec->jackpoll_work);
206                 spec->hp_work_active = false;
207         }
208 }
209
210 static void vt1708_update_hp_work(struct hda_codec *codec)
211 {
212         struct via_spec *spec = codec->spec;
213         if (spec->codec_type != VT1708 || !spec->gen.autocfg.hp_outs)
214                 return;
215         if (spec->vt1708_jack_detect) {
216                 if (!spec->hp_work_active) {
217                         codec->jackpoll_interval = msecs_to_jiffies(100);
218                         snd_hda_codec_write(codec, 0x1, 0, 0xf81, 0);
219                         schedule_delayed_work(&codec->jackpoll_work, 0);
220                         spec->hp_work_active = true;
221                 }
222         } else if (!hp_detect_with_aa(codec))
223                 vt1708_stop_hp_work(codec);
224 }
225
226 static int via_pin_power_ctl_info(struct snd_kcontrol *kcontrol,
227                                   struct snd_ctl_elem_info *uinfo)
228 {
229         return snd_hda_enum_bool_helper_info(kcontrol, uinfo);
230 }
231
232 static int via_pin_power_ctl_get(struct snd_kcontrol *kcontrol,
233                                  struct snd_ctl_elem_value *ucontrol)
234 {
235         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
236         struct via_spec *spec = codec->spec;
237
238         ucontrol->value.enumerated.item[0] = spec->gen.power_down_unused;
239         return 0;
240 }
241
242 static int via_pin_power_ctl_put(struct snd_kcontrol *kcontrol,
243                                  struct snd_ctl_elem_value *ucontrol)
244 {
245         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
246         struct via_spec *spec = codec->spec;
247         bool val = !!ucontrol->value.enumerated.item[0];
248
249         if (val == spec->gen.power_down_unused)
250                 return 0;
251         /* codec->power_save_node = val; */ /* widget PM seems yet broken */
252         spec->gen.power_down_unused = val;
253         analog_low_current_mode(codec);
254         return 1;
255 }
256
257 static const struct snd_kcontrol_new via_pin_power_ctl_enum = {
258         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
259         .name = "Dynamic Power-Control",
260         .info = via_pin_power_ctl_info,
261         .get = via_pin_power_ctl_get,
262         .put = via_pin_power_ctl_put,
263 };
264
265 #ifdef CONFIG_SND_HDA_INPUT_BEEP
266 /* additional beep mixers; the actual parameters are overwritten at build */
267 static const struct snd_kcontrol_new via_beep_mixer[] = {
268         HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT),
269         HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT),
270 };
271
272 static int set_beep_amp(struct via_spec *spec, hda_nid_t nid,
273                         int idx, int dir)
274 {
275         struct snd_kcontrol_new *knew;
276         unsigned int beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir);
277         int i;
278
279         spec->gen.beep_nid = nid;
280         for (i = 0; i < ARRAY_SIZE(via_beep_mixer); i++) {
281                 knew = snd_hda_gen_add_kctl(&spec->gen, NULL,
282                                             &via_beep_mixer[i]);
283                 if (!knew)
284                         return -ENOMEM;
285                 knew->private_value = beep_amp;
286         }
287         return 0;
288 }
289
290 static int auto_parse_beep(struct hda_codec *codec)
291 {
292         struct via_spec *spec = codec->spec;
293         hda_nid_t nid;
294
295         for_each_hda_codec_node(nid, codec)
296                 if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP)
297                         return set_beep_amp(spec, nid, 0, HDA_OUTPUT);
298         return 0;
299 }
300 #else
301 #define auto_parse_beep(codec)  0
302 #endif
303
304 /* check AA path's mute status */
305 static bool is_aa_path_mute(struct hda_codec *codec)
306 {
307         struct via_spec *spec = codec->spec;
308         const struct hda_amp_list *p;
309         int ch, v;
310
311         p = spec->gen.loopback.amplist;
312         if (!p)
313                 return true;
314         for (; p->nid; p++) {
315                 for (ch = 0; ch < 2; ch++) {
316                         v = snd_hda_codec_amp_read(codec, p->nid, ch, p->dir,
317                                                    p->idx);
318                         if (!(v & HDA_AMP_MUTE) && v > 0)
319                                 return false;
320                 }
321         }
322         return true;
323 }
324
325 /* enter/exit analog low-current mode */
326 static void __analog_low_current_mode(struct hda_codec *codec, bool force)
327 {
328         struct via_spec *spec = codec->spec;
329         bool enable;
330         unsigned int verb, parm;
331
332         if (!codec->power_save_node)
333                 enable = false;
334         else
335                 enable = is_aa_path_mute(codec) && !spec->gen.active_streams;
336         if (enable == spec->alc_mode && !force)
337                 return;
338         spec->alc_mode = enable;
339
340         /* decide low current mode's verb & parameter */
341         switch (spec->codec_type) {
342         case VT1708B_8CH:
343         case VT1708B_4CH:
344                 verb = 0xf70;
345                 parm = enable ? 0x02 : 0x00; /* 0x02: 2/3x, 0x00: 1x */
346                 break;
347         case VT1708S:
348         case VT1718S:
349         case VT1716S:
350                 verb = 0xf73;
351                 parm = enable ? 0x51 : 0xe1; /* 0x51: 4/28x, 0xe1: 1x */
352                 break;
353         case VT1702:
354                 verb = 0xf73;
355                 parm = enable ? 0x01 : 0x1d; /* 0x01: 4/40x, 0x1d: 1x */
356                 break;
357         case VT2002P:
358         case VT1812:
359         case VT1802:
360                 verb = 0xf93;
361                 parm = enable ? 0x00 : 0xe0; /* 0x00: 4/40x, 0xe0: 1x */
362                 break;
363         case VT1705CF:
364         case VT1808:
365                 verb = 0xf82;
366                 parm = enable ? 0x00 : 0xe0;  /* 0x00: 4/40x, 0xe0: 1x */
367                 break;
368         default:
369                 return;         /* other codecs are not supported */
370         }
371         /* send verb */
372         snd_hda_codec_write(codec, codec->core.afg, 0, verb, parm);
373 }
374
375 static void analog_low_current_mode(struct hda_codec *codec)
376 {
377         return __analog_low_current_mode(codec, false);
378 }
379
380 static void via_playback_pcm_hook(struct hda_pcm_stream *hinfo,
381                                   struct hda_codec *codec,
382                                   struct snd_pcm_substream *substream,
383                                   int action)
384 {
385         analog_low_current_mode(codec);
386         vt1708_update_hp_work(codec);
387 }
388
389 static void via_free(struct hda_codec *codec)
390 {
391         vt1708_stop_hp_work(codec);
392         snd_hda_gen_free(codec);
393 }
394
395 #ifdef CONFIG_PM
396 static int via_suspend(struct hda_codec *codec)
397 {
398         struct via_spec *spec = codec->spec;
399         vt1708_stop_hp_work(codec);
400
401         /* Fix pop noise on headphones */
402         if (spec->codec_type == VT1802)
403                 snd_hda_shutup_pins(codec);
404
405         return 0;
406 }
407
408 static int via_resume(struct hda_codec *codec)
409 {
410         /* some delay here to make jack detection working (bko#98921) */
411         msleep(10);
412         codec->patch_ops.init(codec);
413         regcache_sync(codec->core.regmap);
414         return 0;
415 }
416 #endif
417
418 #ifdef CONFIG_PM
419 static int via_check_power_status(struct hda_codec *codec, hda_nid_t nid)
420 {
421         struct via_spec *spec = codec->spec;
422         analog_low_current_mode(codec);
423         vt1708_update_hp_work(codec);
424         return snd_hda_check_amp_list_power(codec, &spec->gen.loopback, nid);
425 }
426 #endif
427
428 /*
429  */
430
431 static int via_init(struct hda_codec *codec);
432
433 static const struct hda_codec_ops via_patch_ops = {
434         .build_controls = snd_hda_gen_build_controls,
435         .build_pcms = snd_hda_gen_build_pcms,
436         .init = via_init,
437         .free = via_free,
438         .unsol_event = snd_hda_jack_unsol_event,
439 #ifdef CONFIG_PM
440         .suspend = via_suspend,
441         .resume = via_resume,
442         .check_power_status = via_check_power_status,
443 #endif
444 };
445
446
447 static const struct hda_verb vt1708_init_verbs[] = {
448         /* power down jack detect function */
449         {0x1, 0xf81, 0x1},
450         { }
451 };
452 static void vt1708_set_pinconfig_connect(struct hda_codec *codec, hda_nid_t nid)
453 {
454         unsigned int def_conf;
455         unsigned char seqassoc;
456
457         def_conf = snd_hda_codec_get_pincfg(codec, nid);
458         seqassoc = (unsigned char) get_defcfg_association(def_conf);
459         seqassoc = (seqassoc << 4) | get_defcfg_sequence(def_conf);
460         if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE
461             && (seqassoc == 0xf0 || seqassoc == 0xff)) {
462                 def_conf = def_conf & (~(AC_JACK_PORT_BOTH << 30));
463                 snd_hda_codec_set_pincfg(codec, nid, def_conf);
464         }
465
466         return;
467 }
468
469 static int vt1708_jack_detect_get(struct snd_kcontrol *kcontrol,
470                                      struct snd_ctl_elem_value *ucontrol)
471 {
472         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
473         struct via_spec *spec = codec->spec;
474
475         if (spec->codec_type != VT1708)
476                 return 0;
477         ucontrol->value.integer.value[0] = spec->vt1708_jack_detect;
478         return 0;
479 }
480
481 static int vt1708_jack_detect_put(struct snd_kcontrol *kcontrol,
482                                      struct snd_ctl_elem_value *ucontrol)
483 {
484         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
485         struct via_spec *spec = codec->spec;
486         int val;
487
488         if (spec->codec_type != VT1708)
489                 return 0;
490         val = !!ucontrol->value.integer.value[0];
491         if (spec->vt1708_jack_detect == val)
492                 return 0;
493         spec->vt1708_jack_detect = val;
494         vt1708_update_hp_work(codec);
495         return 1;
496 }
497
498 static const struct snd_kcontrol_new vt1708_jack_detect_ctl = {
499         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
500         .name = "Jack Detect",
501         .count = 1,
502         .info = snd_ctl_boolean_mono_info,
503         .get = vt1708_jack_detect_get,
504         .put = vt1708_jack_detect_put,
505 };
506
507 static const struct badness_table via_main_out_badness = {
508         .no_primary_dac = 0x10000,
509         .no_dac = 0x4000,
510         .shared_primary = 0x10000,
511         .shared_surr = 0x20,
512         .shared_clfe = 0x20,
513         .shared_surr_main = 0x20,
514 };
515 static const struct badness_table via_extra_out_badness = {
516         .no_primary_dac = 0x4000,
517         .no_dac = 0x4000,
518         .shared_primary = 0x12,
519         .shared_surr = 0x20,
520         .shared_clfe = 0x20,
521         .shared_surr_main = 0x10,
522 };
523
524 static int via_parse_auto_config(struct hda_codec *codec)
525 {
526         struct via_spec *spec = codec->spec;
527         int err;
528
529         spec->gen.main_out_badness = &via_main_out_badness;
530         spec->gen.extra_out_badness = &via_extra_out_badness;
531
532         err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0);
533         if (err < 0)
534                 return err;
535
536         err = auto_parse_beep(codec);
537         if (err < 0)
538                 return err;
539
540         err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
541         if (err < 0)
542                 return err;
543
544         if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &via_pin_power_ctl_enum))
545                 return -ENOMEM;
546
547         /* disable widget PM at start for compatibility */
548         codec->power_save_node = 0;
549         spec->gen.power_down_unused = 0;
550         return 0;
551 }
552
553 static int via_init(struct hda_codec *codec)
554 {
555         /* init power states */
556         __analog_low_current_mode(codec, true);
557
558         snd_hda_gen_init(codec);
559
560         vt1708_update_hp_work(codec);
561
562         return 0;
563 }
564
565 static int vt1708_build_controls(struct hda_codec *codec)
566 {
567         /* In order not to create "Phantom Jack" controls,
568            temporary enable jackpoll */
569         int err;
570         int old_interval = codec->jackpoll_interval;
571         codec->jackpoll_interval = msecs_to_jiffies(100);
572         err = snd_hda_gen_build_controls(codec);
573         codec->jackpoll_interval = old_interval;
574         return err;
575 }
576
577 static int vt1708_build_pcms(struct hda_codec *codec)
578 {
579         struct via_spec *spec = codec->spec;
580         int i, err;
581
582         err = snd_hda_gen_build_pcms(codec);
583         if (err < 0 || codec->core.vendor_id != 0x11061708)
584                 return err;
585
586         /* We got noisy outputs on the right channel on VT1708 when
587          * 24bit samples are used.  Until any workaround is found,
588          * disable the 24bit format, so far.
589          */
590         for (i = 0; i < ARRAY_SIZE(spec->gen.pcm_rec); i++) {
591                 struct hda_pcm *info = spec->gen.pcm_rec[i];
592                 if (!info)
593                         continue;
594                 if (!info->stream[SNDRV_PCM_STREAM_PLAYBACK].substreams ||
595                     info->pcm_type != HDA_PCM_TYPE_AUDIO)
596                         continue;
597                 info->stream[SNDRV_PCM_STREAM_PLAYBACK].formats =
598                         SNDRV_PCM_FMTBIT_S16_LE;
599         }
600
601         return 0;
602 }
603
604 static int patch_vt1708(struct hda_codec *codec)
605 {
606         struct via_spec *spec;
607         int err;
608
609         /* create a codec specific record */
610         spec = via_new_spec(codec);
611         if (spec == NULL)
612                 return -ENOMEM;
613
614         /* override some patch_ops */
615         codec->patch_ops.build_controls = vt1708_build_controls;
616         codec->patch_ops.build_pcms = vt1708_build_pcms;
617         spec->gen.mixer_nid = 0x17;
618
619         /* set jackpoll_interval while parsing the codec */
620         codec->jackpoll_interval = msecs_to_jiffies(100);
621         spec->vt1708_jack_detect = 1;
622
623         /* don't support the input jack switching due to lack of unsol event */
624         /* (it may work with polling, though, but it needs testing) */
625         spec->gen.suppress_auto_mic = 1;
626         /* Some machines show the broken speaker mute */
627         spec->gen.auto_mute_via_amp = 1;
628
629         /* Add HP and CD pin config connect bit re-config action */
630         vt1708_set_pinconfig_connect(codec, VT1708_HP_PIN_NID);
631         vt1708_set_pinconfig_connect(codec, VT1708_CD_PIN_NID);
632
633         err = snd_hda_add_verbs(codec, vt1708_init_verbs);
634         if (err < 0)
635                 goto error;
636
637         /* automatic parse from the BIOS config */
638         err = via_parse_auto_config(codec);
639         if (err < 0)
640                 goto error;
641
642         /* add jack detect on/off control */
643         if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &vt1708_jack_detect_ctl)) {
644                 err = -ENOMEM;
645                 goto error;
646         }
647
648         /* clear jackpoll_interval again; it's set dynamically */
649         codec->jackpoll_interval = 0;
650
651         return 0;
652
653  error:
654         via_free(codec);
655         return err;
656 }
657
658 static int patch_vt1709(struct hda_codec *codec)
659 {
660         struct via_spec *spec;
661         int err;
662
663         /* create a codec specific record */
664         spec = via_new_spec(codec);
665         if (spec == NULL)
666                 return -ENOMEM;
667
668         spec->gen.mixer_nid = 0x18;
669
670         err = via_parse_auto_config(codec);
671         if (err < 0)
672                 goto error;
673
674         return 0;
675
676  error:
677         via_free(codec);
678         return err;
679 }
680
681 static int patch_vt1708S(struct hda_codec *codec);
682 static int patch_vt1708B(struct hda_codec *codec)
683 {
684         struct via_spec *spec;
685         int err;
686
687         if (get_codec_type(codec) == VT1708BCE)
688                 return patch_vt1708S(codec);
689
690         /* create a codec specific record */
691         spec = via_new_spec(codec);
692         if (spec == NULL)
693                 return -ENOMEM;
694
695         spec->gen.mixer_nid = 0x16;
696
697         /* automatic parse from the BIOS config */
698         err = via_parse_auto_config(codec);
699         if (err < 0)
700                 goto error;
701
702         return 0;
703
704  error:
705         via_free(codec);
706         return err;
707 }
708
709 /* Patch for VT1708S */
710 static const struct hda_verb vt1708S_init_verbs[] = {
711         /* Enable Mic Boost Volume backdoor */
712         {0x1, 0xf98, 0x1},
713         /* don't bybass mixer */
714         {0x1, 0xf88, 0xc0},
715         { }
716 };
717
718 static void override_mic_boost(struct hda_codec *codec, hda_nid_t pin,
719                                int offset, int num_steps, int step_size)
720 {
721         snd_hda_override_wcaps(codec, pin,
722                                get_wcaps(codec, pin) | AC_WCAP_IN_AMP);
723         snd_hda_override_amp_caps(codec, pin, HDA_INPUT,
724                                   (offset << AC_AMPCAP_OFFSET_SHIFT) |
725                                   (num_steps << AC_AMPCAP_NUM_STEPS_SHIFT) |
726                                   (step_size << AC_AMPCAP_STEP_SIZE_SHIFT) |
727                                   (0 << AC_AMPCAP_MUTE_SHIFT));
728 }
729
730 static int patch_vt1708S(struct hda_codec *codec)
731 {
732         struct via_spec *spec;
733         int err;
734
735         /* create a codec specific record */
736         spec = via_new_spec(codec);
737         if (spec == NULL)
738                 return -ENOMEM;
739
740         spec->gen.mixer_nid = 0x16;
741         override_mic_boost(codec, 0x1a, 0, 3, 40);
742         override_mic_boost(codec, 0x1e, 0, 3, 40);
743
744         /* correct names for VT1708BCE */
745         if (get_codec_type(codec) == VT1708BCE)
746                 snd_hda_codec_set_name(codec, "VT1708BCE");
747         /* correct names for VT1705 */
748         if (codec->core.vendor_id == 0x11064397)
749                 snd_hda_codec_set_name(codec, "VT1705");
750
751         err = snd_hda_add_verbs(codec, vt1708S_init_verbs);
752         if (err < 0)
753                 goto error;
754
755         /* automatic parse from the BIOS config */
756         err = via_parse_auto_config(codec);
757         if (err < 0)
758                 goto error;
759
760         return 0;
761
762  error:
763         via_free(codec);
764         return err;
765 }
766
767 /* Patch for VT1702 */
768
769 static const struct hda_verb vt1702_init_verbs[] = {
770         /* mixer enable */
771         {0x1, 0xF88, 0x3},
772         /* GPIO 0~2 */
773         {0x1, 0xF82, 0x3F},
774         { }
775 };
776
777 static int patch_vt1702(struct hda_codec *codec)
778 {
779         struct via_spec *spec;
780         int err;
781
782         /* create a codec specific record */
783         spec = via_new_spec(codec);
784         if (spec == NULL)
785                 return -ENOMEM;
786
787         spec->gen.mixer_nid = 0x1a;
788
789         /* limit AA path volume to 0 dB */
790         snd_hda_override_amp_caps(codec, 0x1A, HDA_INPUT,
791                                   (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
792                                   (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
793                                   (0x5 << AC_AMPCAP_STEP_SIZE_SHIFT) |
794                                   (1 << AC_AMPCAP_MUTE_SHIFT));
795
796         err = snd_hda_add_verbs(codec, vt1702_init_verbs);
797         if (err < 0)
798                 goto error;
799
800         /* automatic parse from the BIOS config */
801         err = via_parse_auto_config(codec);
802         if (err < 0)
803                 goto error;
804
805         return 0;
806
807  error:
808         via_free(codec);
809         return err;
810 }
811
812 /* Patch for VT1718S */
813
814 static const struct hda_verb vt1718S_init_verbs[] = {
815         /* Enable MW0 adjust Gain 5 */
816         {0x1, 0xfb2, 0x10},
817         /* Enable Boost Volume backdoor */
818         {0x1, 0xf88, 0x8},
819
820         { }
821 };
822
823 /* Add a connection to the primary DAC from AA-mixer for some codecs
824  * This isn't listed from the raw info, but the chip has a secret connection.
825  */
826 static int add_secret_dac_path(struct hda_codec *codec)
827 {
828         struct via_spec *spec = codec->spec;
829         int i, nums;
830         hda_nid_t conn[8];
831         hda_nid_t nid;
832
833         if (!spec->gen.mixer_nid)
834                 return 0;
835         nums = snd_hda_get_connections(codec, spec->gen.mixer_nid, conn,
836                                        ARRAY_SIZE(conn) - 1);
837         if (nums < 0)
838                 return nums;
839
840         for (i = 0; i < nums; i++) {
841                 if (get_wcaps_type(get_wcaps(codec, conn[i])) == AC_WID_AUD_OUT)
842                         return 0;
843         }
844
845         /* find the primary DAC and add to the connection list */
846         for_each_hda_codec_node(nid, codec) {
847                 unsigned int caps = get_wcaps(codec, nid);
848                 if (get_wcaps_type(caps) == AC_WID_AUD_OUT &&
849                     !(caps & AC_WCAP_DIGITAL)) {
850                         conn[nums++] = nid;
851                         return snd_hda_override_conn_list(codec,
852                                                           spec->gen.mixer_nid,
853                                                           nums, conn);
854                 }
855         }
856         return 0;
857 }
858
859
860 static int patch_vt1718S(struct hda_codec *codec)
861 {
862         struct via_spec *spec;
863         int err;
864
865         /* create a codec specific record */
866         spec = via_new_spec(codec);
867         if (spec == NULL)
868                 return -ENOMEM;
869
870         spec->gen.mixer_nid = 0x21;
871         override_mic_boost(codec, 0x2b, 0, 3, 40);
872         override_mic_boost(codec, 0x29, 0, 3, 40);
873         add_secret_dac_path(codec);
874
875         err = snd_hda_add_verbs(codec, vt1718S_init_verbs);
876         if (err < 0)
877                 goto error;
878
879         /* automatic parse from the BIOS config */
880         err = via_parse_auto_config(codec);
881         if (err < 0)
882                 goto error;
883
884         return 0;
885
886  error:
887         via_free(codec);
888         return err;
889 }
890
891 /* Patch for VT1716S */
892
893 static int vt1716s_dmic_info(struct snd_kcontrol *kcontrol,
894                             struct snd_ctl_elem_info *uinfo)
895 {
896         uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
897         uinfo->count = 1;
898         uinfo->value.integer.min = 0;
899         uinfo->value.integer.max = 1;
900         return 0;
901 }
902
903 static int vt1716s_dmic_get(struct snd_kcontrol *kcontrol,
904                            struct snd_ctl_elem_value *ucontrol)
905 {
906         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
907         int index = 0;
908
909         index = snd_hda_codec_read(codec, 0x26, 0,
910                                                AC_VERB_GET_CONNECT_SEL, 0);
911         if (index != -1)
912                 *ucontrol->value.integer.value = index;
913
914         return 0;
915 }
916
917 static int vt1716s_dmic_put(struct snd_kcontrol *kcontrol,
918                            struct snd_ctl_elem_value *ucontrol)
919 {
920         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
921         struct via_spec *spec = codec->spec;
922         int index = *ucontrol->value.integer.value;
923
924         snd_hda_codec_write(codec, 0x26, 0,
925                                                AC_VERB_SET_CONNECT_SEL, index);
926         spec->dmic_enabled = index;
927         return 1;
928 }
929
930 static const struct snd_kcontrol_new vt1716s_dmic_mixer_vol =
931         HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x22, 0x0, HDA_INPUT);
932 static const struct snd_kcontrol_new vt1716s_dmic_mixer_sw = {
933          .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
934          .name = "Digital Mic Capture Switch",
935          .subdevice = HDA_SUBDEV_NID_FLAG | 0x26,
936          .count = 1,
937          .info = vt1716s_dmic_info,
938          .get = vt1716s_dmic_get,
939          .put = vt1716s_dmic_put,
940 };
941
942
943 /* mono-out mixer elements */
944 static const struct snd_kcontrol_new vt1716S_mono_out_mixer =
945         HDA_CODEC_MUTE("Mono Playback Switch", 0x2a, 0x0, HDA_OUTPUT);
946
947 static const struct hda_verb vt1716S_init_verbs[] = {
948         /* Enable Boost Volume backdoor */
949         {0x1, 0xf8a, 0x80},
950         /* don't bybass mixer */
951         {0x1, 0xf88, 0xc0},
952         /* Enable mono output */
953         {0x1, 0xf90, 0x08},
954         { }
955 };
956
957 static int patch_vt1716S(struct hda_codec *codec)
958 {
959         struct via_spec *spec;
960         int err;
961
962         /* create a codec specific record */
963         spec = via_new_spec(codec);
964         if (spec == NULL)
965                 return -ENOMEM;
966
967         spec->gen.mixer_nid = 0x16;
968         override_mic_boost(codec, 0x1a, 0, 3, 40);
969         override_mic_boost(codec, 0x1e, 0, 3, 40);
970
971         err = snd_hda_add_verbs(codec, vt1716S_init_verbs);
972         if (err < 0)
973                 goto error;
974
975         /* automatic parse from the BIOS config */
976         err = via_parse_auto_config(codec);
977         if (err < 0)
978                 goto error;
979
980         if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &vt1716s_dmic_mixer_vol) ||
981             !snd_hda_gen_add_kctl(&spec->gen, NULL, &vt1716s_dmic_mixer_sw) ||
982             !snd_hda_gen_add_kctl(&spec->gen, NULL, &vt1716S_mono_out_mixer)) {
983                 err = -ENOMEM;
984                 goto error;
985         }
986
987         return 0;
988
989  error:
990         via_free(codec);
991         return err;
992 }
993
994 /* for vt2002P */
995
996 static const struct hda_verb vt2002P_init_verbs[] = {
997         /* Class-D speaker related verbs */
998         {0x1, 0xfe0, 0x4},
999         {0x1, 0xfe9, 0x80},
1000         {0x1, 0xfe2, 0x22},
1001         /* Enable Boost Volume backdoor */
1002         {0x1, 0xfb9, 0x24},
1003         /* Enable AOW0 to MW9 */
1004         {0x1, 0xfb8, 0x88},
1005         { }
1006 };
1007
1008 static const struct hda_verb vt1802_init_verbs[] = {
1009         /* Enable Boost Volume backdoor */
1010         {0x1, 0xfb9, 0x24},
1011         /* Enable AOW0 to MW9 */
1012         {0x1, 0xfb8, 0x88},
1013         { }
1014 };
1015
1016 /*
1017  * pin fix-up
1018  */
1019 enum {
1020         VIA_FIXUP_INTMIC_BOOST,
1021         VIA_FIXUP_ASUS_G75,
1022         VIA_FIXUP_POWER_SAVE,
1023 };
1024
1025 static void via_fixup_intmic_boost(struct hda_codec *codec,
1026                                   const struct hda_fixup *fix, int action)
1027 {
1028         if (action == HDA_FIXUP_ACT_PRE_PROBE)
1029                 override_mic_boost(codec, 0x30, 0, 2, 40);
1030 }
1031
1032 static void via_fixup_power_save(struct hda_codec *codec,
1033                                  const struct hda_fixup *fix, int action)
1034 {
1035         if (action == HDA_FIXUP_ACT_PRE_PROBE)
1036                 codec->power_save_node = 0;
1037 }
1038
1039 static const struct hda_fixup via_fixups[] = {
1040         [VIA_FIXUP_INTMIC_BOOST] = {
1041                 .type = HDA_FIXUP_FUNC,
1042                 .v.func = via_fixup_intmic_boost,
1043         },
1044         [VIA_FIXUP_ASUS_G75] = {
1045                 .type = HDA_FIXUP_PINS,
1046                 .v.pins = (const struct hda_pintbl[]) {
1047                         /* set 0x24 and 0x33 as speakers */
1048                         { 0x24, 0x991301f0 },
1049                         { 0x33, 0x991301f1 }, /* subwoofer */
1050                         { }
1051                 }
1052         },
1053         [VIA_FIXUP_POWER_SAVE] = {
1054                 .type = HDA_FIXUP_FUNC,
1055                 .v.func = via_fixup_power_save,
1056         },
1057 };
1058
1059 static const struct snd_pci_quirk vt2002p_fixups[] = {
1060         SND_PCI_QUIRK(0x1043, 0x1487, "Asus G75", VIA_FIXUP_ASUS_G75),
1061         SND_PCI_QUIRK(0x1043, 0x8532, "Asus X202E", VIA_FIXUP_INTMIC_BOOST),
1062         SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", VIA_FIXUP_POWER_SAVE),
1063         {}
1064 };
1065
1066 /* NIDs 0x24 and 0x33 on VT1802 have connections to non-existing NID 0x3e
1067  * Replace this with mixer NID 0x1c
1068  */
1069 static void fix_vt1802_connections(struct hda_codec *codec)
1070 {
1071         static hda_nid_t conn_24[] = { 0x14, 0x1c };
1072         static hda_nid_t conn_33[] = { 0x1c };
1073
1074         snd_hda_override_conn_list(codec, 0x24, ARRAY_SIZE(conn_24), conn_24);
1075         snd_hda_override_conn_list(codec, 0x33, ARRAY_SIZE(conn_33), conn_33);
1076 }
1077
1078 /* patch for vt2002P */
1079 static int patch_vt2002P(struct hda_codec *codec)
1080 {
1081         struct via_spec *spec;
1082         int err;
1083
1084         /* create a codec specific record */
1085         spec = via_new_spec(codec);
1086         if (spec == NULL)
1087                 return -ENOMEM;
1088
1089         spec->gen.mixer_nid = 0x21;
1090         override_mic_boost(codec, 0x2b, 0, 3, 40);
1091         override_mic_boost(codec, 0x29, 0, 3, 40);
1092         if (spec->codec_type == VT1802)
1093                 fix_vt1802_connections(codec);
1094         add_secret_dac_path(codec);
1095
1096         snd_hda_pick_fixup(codec, NULL, vt2002p_fixups, via_fixups);
1097         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1098
1099         if (spec->codec_type == VT1802)
1100                 err = snd_hda_add_verbs(codec, vt1802_init_verbs);
1101         else
1102                 err = snd_hda_add_verbs(codec, vt2002P_init_verbs);
1103         if (err < 0)
1104                 goto error;
1105
1106         /* automatic parse from the BIOS config */
1107         err = via_parse_auto_config(codec);
1108         if (err < 0)
1109                 goto error;
1110
1111         return 0;
1112
1113  error:
1114         via_free(codec);
1115         return err;
1116 }
1117
1118 /* for vt1812 */
1119
1120 static const struct hda_verb vt1812_init_verbs[] = {
1121         /* Enable Boost Volume backdoor */
1122         {0x1, 0xfb9, 0x24},
1123         /* Enable AOW0 to MW9 */
1124         {0x1, 0xfb8, 0xa8},
1125         { }
1126 };
1127
1128 /* patch for vt1812 */
1129 static int patch_vt1812(struct hda_codec *codec)
1130 {
1131         struct via_spec *spec;
1132         int err;
1133
1134         /* create a codec specific record */
1135         spec = via_new_spec(codec);
1136         if (spec == NULL)
1137                 return -ENOMEM;
1138
1139         spec->gen.mixer_nid = 0x21;
1140         override_mic_boost(codec, 0x2b, 0, 3, 40);
1141         override_mic_boost(codec, 0x29, 0, 3, 40);
1142         add_secret_dac_path(codec);
1143
1144         err = snd_hda_add_verbs(codec, vt1812_init_verbs);
1145         if (err < 0)
1146                 goto error;
1147
1148         /* automatic parse from the BIOS config */
1149         err = via_parse_auto_config(codec);
1150         if (err < 0)
1151                 goto error;
1152
1153         return 0;
1154
1155  error:
1156         via_free(codec);
1157         return err;
1158 }
1159
1160 /* patch for vt3476 */
1161
1162 static const struct hda_verb vt3476_init_verbs[] = {
1163         /* Enable DMic 8/16/32K */
1164         {0x1, 0xF7B, 0x30},
1165         /* Enable Boost Volume backdoor */
1166         {0x1, 0xFB9, 0x20},
1167         /* Enable AOW-MW9 path */
1168         {0x1, 0xFB8, 0x10},
1169         { }
1170 };
1171
1172 static int patch_vt3476(struct hda_codec *codec)
1173 {
1174         struct via_spec *spec;
1175         int err;
1176
1177         /* create a codec specific record */
1178         spec = via_new_spec(codec);
1179         if (spec == NULL)
1180                 return -ENOMEM;
1181
1182         spec->gen.mixer_nid = 0x3f;
1183         add_secret_dac_path(codec);
1184
1185         err = snd_hda_add_verbs(codec, vt3476_init_verbs);
1186         if (err < 0)
1187                 goto error;
1188
1189         /* automatic parse from the BIOS config */
1190         err = via_parse_auto_config(codec);
1191         if (err < 0)
1192                 goto error;
1193
1194         return 0;
1195
1196  error:
1197         via_free(codec);
1198         return err;
1199 }
1200
1201 /*
1202  * patch entries
1203  */
1204 static const struct hda_device_id snd_hda_id_via[] = {
1205         HDA_CODEC_ENTRY(0x11061708, "VT1708", patch_vt1708),
1206         HDA_CODEC_ENTRY(0x11061709, "VT1708", patch_vt1708),
1207         HDA_CODEC_ENTRY(0x1106170a, "VT1708", patch_vt1708),
1208         HDA_CODEC_ENTRY(0x1106170b, "VT1708", patch_vt1708),
1209         HDA_CODEC_ENTRY(0x1106e710, "VT1709 10-Ch", patch_vt1709),
1210         HDA_CODEC_ENTRY(0x1106e711, "VT1709 10-Ch", patch_vt1709),
1211         HDA_CODEC_ENTRY(0x1106e712, "VT1709 10-Ch", patch_vt1709),
1212         HDA_CODEC_ENTRY(0x1106e713, "VT1709 10-Ch", patch_vt1709),
1213         HDA_CODEC_ENTRY(0x1106e714, "VT1709 6-Ch", patch_vt1709),
1214         HDA_CODEC_ENTRY(0x1106e715, "VT1709 6-Ch", patch_vt1709),
1215         HDA_CODEC_ENTRY(0x1106e716, "VT1709 6-Ch", patch_vt1709),
1216         HDA_CODEC_ENTRY(0x1106e717, "VT1709 6-Ch", patch_vt1709),
1217         HDA_CODEC_ENTRY(0x1106e720, "VT1708B 8-Ch", patch_vt1708B),
1218         HDA_CODEC_ENTRY(0x1106e721, "VT1708B 8-Ch", patch_vt1708B),
1219         HDA_CODEC_ENTRY(0x1106e722, "VT1708B 8-Ch", patch_vt1708B),
1220         HDA_CODEC_ENTRY(0x1106e723, "VT1708B 8-Ch", patch_vt1708B),
1221         HDA_CODEC_ENTRY(0x1106e724, "VT1708B 4-Ch", patch_vt1708B),
1222         HDA_CODEC_ENTRY(0x1106e725, "VT1708B 4-Ch", patch_vt1708B),
1223         HDA_CODEC_ENTRY(0x1106e726, "VT1708B 4-Ch", patch_vt1708B),
1224         HDA_CODEC_ENTRY(0x1106e727, "VT1708B 4-Ch", patch_vt1708B),
1225         HDA_CODEC_ENTRY(0x11060397, "VT1708S", patch_vt1708S),
1226         HDA_CODEC_ENTRY(0x11061397, "VT1708S", patch_vt1708S),
1227         HDA_CODEC_ENTRY(0x11062397, "VT1708S", patch_vt1708S),
1228         HDA_CODEC_ENTRY(0x11063397, "VT1708S", patch_vt1708S),
1229         HDA_CODEC_ENTRY(0x11064397, "VT1705", patch_vt1708S),
1230         HDA_CODEC_ENTRY(0x11065397, "VT1708S", patch_vt1708S),
1231         HDA_CODEC_ENTRY(0x11066397, "VT1708S", patch_vt1708S),
1232         HDA_CODEC_ENTRY(0x11067397, "VT1708S", patch_vt1708S),
1233         HDA_CODEC_ENTRY(0x11060398, "VT1702", patch_vt1702),
1234         HDA_CODEC_ENTRY(0x11061398, "VT1702", patch_vt1702),
1235         HDA_CODEC_ENTRY(0x11062398, "VT1702", patch_vt1702),
1236         HDA_CODEC_ENTRY(0x11063398, "VT1702", patch_vt1702),
1237         HDA_CODEC_ENTRY(0x11064398, "VT1702", patch_vt1702),
1238         HDA_CODEC_ENTRY(0x11065398, "VT1702", patch_vt1702),
1239         HDA_CODEC_ENTRY(0x11066398, "VT1702", patch_vt1702),
1240         HDA_CODEC_ENTRY(0x11067398, "VT1702", patch_vt1702),
1241         HDA_CODEC_ENTRY(0x11060428, "VT1718S", patch_vt1718S),
1242         HDA_CODEC_ENTRY(0x11064428, "VT1718S", patch_vt1718S),
1243         HDA_CODEC_ENTRY(0x11060441, "VT2020", patch_vt1718S),
1244         HDA_CODEC_ENTRY(0x11064441, "VT1828S", patch_vt1718S),
1245         HDA_CODEC_ENTRY(0x11060433, "VT1716S", patch_vt1716S),
1246         HDA_CODEC_ENTRY(0x1106a721, "VT1716S", patch_vt1716S),
1247         HDA_CODEC_ENTRY(0x11060438, "VT2002P", patch_vt2002P),
1248         HDA_CODEC_ENTRY(0x11064438, "VT2002P", patch_vt2002P),
1249         HDA_CODEC_ENTRY(0x11060448, "VT1812", patch_vt1812),
1250         HDA_CODEC_ENTRY(0x11060440, "VT1818S", patch_vt1708S),
1251         HDA_CODEC_ENTRY(0x11060446, "VT1802", patch_vt2002P),
1252         HDA_CODEC_ENTRY(0x11068446, "VT1802", patch_vt2002P),
1253         HDA_CODEC_ENTRY(0x11064760, "VT1705CF", patch_vt3476),
1254         HDA_CODEC_ENTRY(0x11064761, "VT1708SCE", patch_vt3476),
1255         HDA_CODEC_ENTRY(0x11064762, "VT1808", patch_vt3476),
1256         {} /* terminator */
1257 };
1258 MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_via);
1259
1260 static struct hda_codec_driver via_driver = {
1261         .id = snd_hda_id_via,
1262 };
1263
1264 MODULE_LICENSE("GPL");
1265 MODULE_DESCRIPTION("VIA HD-audio codec");
1266
1267 module_hda_codec_driver(via_driver);