blob: a34d7671937f675d8dbdbc27bf809e5b0cb6dc44 [file] [log] [blame]
Joseph Chanc577b8a2006-11-29 15:29:40 +01001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
Lydia Wang8e865972009-10-10 19:08:52 +08004 * HD audio interface patch for VIA VT17xx/VT18xx/VT20xx codec
Joseph Chanc577b8a2006-11-29 15:29:40 +01005 *
Lydia Wang8e865972009-10-10 19:08:52 +08006 * (C) 2006-2009 VIA Technology, Inc.
7 * (C) 2006-2008 Takashi Iwai <tiwai@suse.de>
Joseph Chanc577b8a2006-11-29 15:29:40 +01008 *
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 * * * * * * * * * * * * * * * * */
Lydia Wang377ff312009-10-10 19:08:55 +080025/* */
Joseph Chanc577b8a2006-11-29 15:29:40 +010026/* 2006-03-03 Lydia Wang Create the basic patch to support VT1708 codec */
Lydia Wang377ff312009-10-10 19:08:55 +080027/* 2006-03-14 Lydia Wang Modify hard code for some pin widget nid */
28/* 2006-08-02 Lydia Wang Add support to VT1709 codec */
Joseph Chanc577b8a2006-11-29 15:29:40 +010029/* 2006-09-08 Lydia Wang Fix internal loopback recording source select bug */
Lydia Wang377ff312009-10-10 19:08:55 +080030/* 2007-09-12 Lydia Wang Add EAPD enable during driver initialization */
31/* 2007-09-17 Lydia Wang Add VT1708B codec support */
Harald Welte76d9b0d2008-09-09 15:50:37 +080032/* 2007-11-14 Lydia Wang Add VT1708A codec HP and CD pin connect config */
Harald Weltefb4cb772008-09-09 15:53:36 +080033/* 2008-02-03 Lydia Wang Fix Rear channels and Back channels inverse issue */
Lydia Wang377ff312009-10-10 19:08:55 +080034/* 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 */
Harald Welte98aa34c2008-09-09 16:02:09 +080037/* 2008-05-28 Lydia Wang Add second S/PDIF Out support for VT1702 */
Lydia Wang377ff312009-10-10 19:08:55 +080038/* 2008-09-15 Logan Li Add VT1708S Mic Boost workaround/backdoor */
Lydia Wang8e865972009-10-10 19:08:52 +080039/* 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 */
Lydia Wang36dd5c42009-10-20 13:18:04 +080044/* 2009-09-19 Lydia Wang Add support for VT1818S */
Lydia Wang377ff312009-10-10 19:08:55 +080045/* */
Joseph Chanc577b8a2006-11-29 15:29:40 +010046/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
47
48
Joseph Chanc577b8a2006-11-29 15:29:40 +010049#include <linux/init.h>
50#include <linux/delay.h>
51#include <linux/slab.h>
Paul Gortmakerda155d52011-07-15 12:38:28 -040052#include <linux/module.h>
Joseph Chanc577b8a2006-11-29 15:29:40 +010053#include <sound/core.h>
Harald Welte0aa62ae2008-09-09 15:58:27 +080054#include <sound/asoundef.h>
Joseph Chanc577b8a2006-11-29 15:29:40 +010055#include "hda_codec.h"
56#include "hda_local.h"
Takashi Iwai128bc4b2012-05-07 17:42:31 +020057#include "hda_auto_parser.h"
Takashi Iwai1835a0f2011-10-27 22:12:46 +020058#include "hda_jack.h"
Takashi Iwaib3f60082013-01-07 12:27:36 +010059#include "hda_generic.h"
Joseph Chanc577b8a2006-11-29 15:29:40 +010060
Joseph Chanc577b8a2006-11-29 15:29:40 +010061/* Pin Widget NID */
Harald Welted949cac2008-09-09 15:56:01 +080062#define VT1708_HP_PIN_NID 0x20
63#define VT1708_CD_PIN_NID 0x24
Joseph Chanc577b8a2006-11-29 15:29:40 +010064
Harald Welted7426322008-09-15 22:43:23 +080065enum VIA_HDA_CODEC {
66 UNKNOWN = -1,
67 VT1708,
68 VT1709_10CH,
69 VT1709_6CH,
70 VT1708B_8CH,
71 VT1708B_4CH,
72 VT1708S,
Lydia Wang518bf3b2009-10-10 19:07:29 +080073 VT1708BCE,
Harald Welted7426322008-09-15 22:43:23 +080074 VT1702,
Lydia Wangeb7188c2009-10-10 19:08:34 +080075 VT1718S,
Lydia Wangf3db4232009-10-10 19:08:41 +080076 VT1716S,
Lydia Wang25eaba22009-10-10 19:08:43 +080077 VT2002P,
Lydia Wangab6734e2009-10-10 19:08:46 +080078 VT1812,
Lydia Wang118909562011-03-23 17:57:34 +080079 VT1802,
Lydia Wang43737e02012-12-10 18:28:11 +080080 VT1705CF,
Lydia Wang6121b842012-12-10 19:03:26 +080081 VT1808,
Harald Welted7426322008-09-15 22:43:23 +080082 CODEC_TYPES,
83};
84
Lydia Wang118909562011-03-23 17:57:34 +080085#define VT2002P_COMPATIBLE(spec) \
86 ((spec)->codec_type == VT2002P ||\
87 (spec)->codec_type == VT1812 ||\
88 (spec)->codec_type == VT1802)
89
Lydia Wang1f2e99f2009-10-10 19:08:17 +080090struct via_spec {
Takashi Iwaib3f60082013-01-07 12:27:36 +010091 struct hda_gen_spec gen;
92
Lydia Wang1f2e99f2009-10-10 19:08:17 +080093 /* codec parameterization */
Takashi Iwai90dd48a2011-05-02 12:38:19 +020094 const struct snd_kcontrol_new *mixers[6];
Lydia Wang1f2e99f2009-10-10 19:08:17 +080095 unsigned int num_mixers;
96
Takashi Iwai90dd48a2011-05-02 12:38:19 +020097 const struct hda_verb *init_verbs[5];
Lydia Wang1f2e99f2009-10-10 19:08:17 +080098 unsigned int num_iverbs;
99
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800100 /* HP mode source */
Lydia Wangf3db4232009-10-10 19:08:41 +0800101 unsigned int dmic_enabled;
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800102 enum VIA_HDA_CODEC codec_type;
103
Takashi Iwaie9d010c2012-02-01 10:33:23 +0100104 /* analog low-power control */
105 bool alc_mode;
106
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800107 /* work to check hp jack state */
Takashi Iwai187d3332011-11-24 16:33:09 +0100108 int hp_work_active;
Takashi Iwaie06e5a22011-06-17 15:46:13 +0200109 int vt1708_jack_detect;
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800110};
111
Lydia Wang0341ccd2011-03-22 16:25:03 +0800112static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec);
Takashi Iwaib3f60082013-01-07 12:27:36 +0100113static void via_playback_pcm_hook(struct hda_pcm_stream *hinfo,
114 struct hda_codec *codec,
115 struct snd_pcm_substream *substream,
116 int action);
Takashi Iwaib3f60082013-01-07 12:27:36 +0100117
118static struct via_spec *via_new_spec(struct hda_codec *codec)
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100119{
120 struct via_spec *spec;
121
122 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
123 if (spec == NULL)
124 return NULL;
125
126 codec->spec = spec;
Takashi Iwaib3f60082013-01-07 12:27:36 +0100127 snd_hda_gen_spec_init(&spec->gen);
Lydia Wang0341ccd2011-03-22 16:25:03 +0800128 spec->codec_type = get_codec_type(codec);
129 /* VT1708BCE & VT1708S are almost same */
130 if (spec->codec_type == VT1708BCE)
131 spec->codec_type = VT1708S;
Takashi Iwai13961172013-01-21 15:15:55 +0100132 spec->gen.indep_hp = 1;
Takashi Iwai05909d5c2013-05-31 19:55:54 +0200133 spec->gen.keep_eapd_on = 1;
Takashi Iwaib3f60082013-01-07 12:27:36 +0100134 spec->gen.pcm_playback_hook = via_playback_pcm_hook;
Takashi Iwai74f14b32014-12-15 13:43:59 +0100135 spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO;
Takashi Iwai967b1302015-03-20 18:21:03 +0100136 codec->power_save_node = 1;
Takashi Iwai688b12c2015-03-17 15:56:05 +0100137 spec->gen.power_down_unused = 1;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100138 return spec;
139}
140
Lydia Wang744ff5f2009-10-10 19:07:26 +0800141static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec)
Harald Welted7426322008-09-15 22:43:23 +0800142{
Takashi Iwai7639a062015-03-03 10:07:24 +0100143 u32 vendor_id = codec->core.vendor_id;
Harald Welted7426322008-09-15 22:43:23 +0800144 u16 ven_id = vendor_id >> 16;
145 u16 dev_id = vendor_id & 0xffff;
146 enum VIA_HDA_CODEC codec_type;
147
148 /* get codec type */
149 if (ven_id != 0x1106)
150 codec_type = UNKNOWN;
151 else if (dev_id >= 0x1708 && dev_id <= 0x170b)
152 codec_type = VT1708;
153 else if (dev_id >= 0xe710 && dev_id <= 0xe713)
154 codec_type = VT1709_10CH;
155 else if (dev_id >= 0xe714 && dev_id <= 0xe717)
156 codec_type = VT1709_6CH;
Lydia Wang518bf3b2009-10-10 19:07:29 +0800157 else if (dev_id >= 0xe720 && dev_id <= 0xe723) {
Harald Welted7426322008-09-15 22:43:23 +0800158 codec_type = VT1708B_8CH;
Lydia Wang518bf3b2009-10-10 19:07:29 +0800159 if (snd_hda_param_read(codec, 0x16, AC_PAR_CONNLIST_LEN) == 0x7)
160 codec_type = VT1708BCE;
161 } else if (dev_id >= 0xe724 && dev_id <= 0xe727)
Harald Welted7426322008-09-15 22:43:23 +0800162 codec_type = VT1708B_4CH;
163 else if ((dev_id & 0xfff) == 0x397
164 && (dev_id >> 12) < 8)
165 codec_type = VT1708S;
166 else if ((dev_id & 0xfff) == 0x398
167 && (dev_id >> 12) < 8)
168 codec_type = VT1702;
Lydia Wangeb7188c2009-10-10 19:08:34 +0800169 else if ((dev_id & 0xfff) == 0x428
170 && (dev_id >> 12) < 8)
171 codec_type = VT1718S;
Lydia Wangf3db4232009-10-10 19:08:41 +0800172 else if (dev_id == 0x0433 || dev_id == 0xa721)
173 codec_type = VT1716S;
Lydia Wangbb3c6bfc2009-10-10 19:08:39 +0800174 else if (dev_id == 0x0441 || dev_id == 0x4441)
175 codec_type = VT1718S;
Lydia Wang25eaba22009-10-10 19:08:43 +0800176 else if (dev_id == 0x0438 || dev_id == 0x4438)
177 codec_type = VT2002P;
Lydia Wangab6734e2009-10-10 19:08:46 +0800178 else if (dev_id == 0x0448)
179 codec_type = VT1812;
Lydia Wang36dd5c42009-10-20 13:18:04 +0800180 else if (dev_id == 0x0440)
181 codec_type = VT1708S;
Lydia Wang118909562011-03-23 17:57:34 +0800182 else if ((dev_id & 0xfff) == 0x446)
183 codec_type = VT1802;
Lydia Wang43737e02012-12-10 18:28:11 +0800184 else if (dev_id == 0x4760)
185 codec_type = VT1705CF;
Lydia Wang6121b842012-12-10 19:03:26 +0800186 else if (dev_id == 0x4761 || dev_id == 0x4762)
187 codec_type = VT1808;
Harald Welted7426322008-09-15 22:43:23 +0800188 else
189 codec_type = UNKNOWN;
190 return codec_type;
191};
192
Takashi Iwaiada509e2011-06-20 15:40:19 +0200193static void analog_low_current_mode(struct hda_codec *codec);
194static bool is_aa_path_mute(struct hda_codec *codec);
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800195
Takashi Iwai187d3332011-11-24 16:33:09 +0100196#define hp_detect_with_aa(codec) \
197 (snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") == 1 && \
198 !is_aa_path_mute(codec))
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800199
Takashi Iwaib3f60082013-01-07 12:27:36 +0100200static void vt1708_stop_hp_work(struct hda_codec *codec)
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800201{
Takashi Iwaib3f60082013-01-07 12:27:36 +0100202 struct via_spec *spec = codec->spec;
203 if (spec->codec_type != VT1708 || !spec->gen.autocfg.hp_outs)
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800204 return;
Takashi Iwai187d3332011-11-24 16:33:09 +0100205 if (spec->hp_work_active) {
Takashi Iwaib3f60082013-01-07 12:27:36 +0100206 snd_hda_codec_write(codec, 0x1, 0, 0xf81, 1);
Wang Xingchao7eaa9162013-07-25 23:34:44 -0400207 codec->jackpoll_interval = 0;
Takashi Iwaib3f60082013-01-07 12:27:36 +0100208 cancel_delayed_work_sync(&codec->jackpoll_work);
209 spec->hp_work_active = false;
Takashi Iwai187d3332011-11-24 16:33:09 +0100210 }
211}
212
Takashi Iwaib3f60082013-01-07 12:27:36 +0100213static void vt1708_update_hp_work(struct hda_codec *codec)
Takashi Iwai187d3332011-11-24 16:33:09 +0100214{
Takashi Iwaib3f60082013-01-07 12:27:36 +0100215 struct via_spec *spec = codec->spec;
216 if (spec->codec_type != VT1708 || !spec->gen.autocfg.hp_outs)
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800217 return;
David Henningsson05dc0fc2013-02-05 12:06:03 +0100218 if (spec->vt1708_jack_detect) {
Takashi Iwai187d3332011-11-24 16:33:09 +0100219 if (!spec->hp_work_active) {
Takashi Iwaib3f60082013-01-07 12:27:36 +0100220 codec->jackpoll_interval = msecs_to_jiffies(100);
221 snd_hda_codec_write(codec, 0x1, 0, 0xf81, 0);
Takashi Iwai2f35c632015-02-27 22:43:26 +0100222 schedule_delayed_work(&codec->jackpoll_work, 0);
Takashi Iwaib3f60082013-01-07 12:27:36 +0100223 spec->hp_work_active = true;
Takashi Iwai187d3332011-11-24 16:33:09 +0100224 }
Takashi Iwaib3f60082013-01-07 12:27:36 +0100225 } else if (!hp_detect_with_aa(codec))
226 vt1708_stop_hp_work(codec);
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800227}
Lydia Wangf5271102009-10-10 19:07:35 +0800228
Takashi Iwai24088a52011-06-17 16:59:21 +0200229static int via_pin_power_ctl_info(struct snd_kcontrol *kcontrol,
230 struct snd_ctl_elem_info *uinfo)
231{
Takashi Iwaidda415d2012-11-30 18:34:38 +0100232 return snd_hda_enum_bool_helper_info(kcontrol, uinfo);
Takashi Iwai24088a52011-06-17 16:59:21 +0200233}
234
235static int via_pin_power_ctl_get(struct snd_kcontrol *kcontrol,
236 struct snd_ctl_elem_value *ucontrol)
237{
238 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai967b1302015-03-20 18:21:03 +0100239 ucontrol->value.enumerated.item[0] = codec->power_save_node;
Takashi Iwai24088a52011-06-17 16:59:21 +0200240 return 0;
241}
242
243static int via_pin_power_ctl_put(struct snd_kcontrol *kcontrol,
244 struct snd_ctl_elem_value *ucontrol)
245{
246 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
247 struct via_spec *spec = codec->spec;
Takashi Iwai688b12c2015-03-17 15:56:05 +0100248 bool val = !!ucontrol->value.enumerated.item[0];
Takashi Iwai24088a52011-06-17 16:59:21 +0200249
Takashi Iwai967b1302015-03-20 18:21:03 +0100250 if (val == codec->power_save_node)
Takashi Iwai24088a52011-06-17 16:59:21 +0200251 return 0;
Takashi Iwai967b1302015-03-20 18:21:03 +0100252 codec->power_save_node = val;
Takashi Iwai688b12c2015-03-17 15:56:05 +0100253 spec->gen.power_down_unused = val;
Takashi Iwaie9d010c2012-02-01 10:33:23 +0100254 analog_low_current_mode(codec);
Takashi Iwai24088a52011-06-17 16:59:21 +0200255 return 1;
256}
257
Takashi Iwaib3f60082013-01-07 12:27:36 +0100258static const struct snd_kcontrol_new via_pin_power_ctl_enum[] = {
259 {
Takashi Iwai24088a52011-06-17 16:59:21 +0200260 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
261 .name = "Dynamic Power-Control",
262 .info = via_pin_power_ctl_info,
263 .get = via_pin_power_ctl_get,
264 .put = via_pin_power_ctl_put,
Takashi Iwaib3f60082013-01-07 12:27:36 +0100265 },
266 {} /* terminator */
Takashi Iwai24088a52011-06-17 16:59:21 +0200267};
268
269
Takashi Iwaiada509e2011-06-20 15:40:19 +0200270/* check AA path's mute status */
271static bool is_aa_path_mute(struct hda_codec *codec)
Lydia Wangf5271102009-10-10 19:07:35 +0800272{
Lydia Wangf5271102009-10-10 19:07:35 +0800273 struct via_spec *spec = codec->spec;
Takashi Iwaiada509e2011-06-20 15:40:19 +0200274 const struct hda_amp_list *p;
Takashi Iwai0186f4f2013-02-07 10:45:11 +0100275 int ch, v;
Takashi Iwaiada509e2011-06-20 15:40:19 +0200276
Takashi Iwai0186f4f2013-02-07 10:45:11 +0100277 p = spec->gen.loopback.amplist;
278 if (!p)
279 return true;
280 for (; p->nid; p++) {
Takashi Iwaiada509e2011-06-20 15:40:19 +0200281 for (ch = 0; ch < 2; ch++) {
282 v = snd_hda_codec_amp_read(codec, p->nid, ch, p->dir,
283 p->idx);
284 if (!(v & HDA_AMP_MUTE) && v > 0)
285 return false;
Lydia Wangf5271102009-10-10 19:07:35 +0800286 }
287 }
Takashi Iwaiada509e2011-06-20 15:40:19 +0200288 return true;
Lydia Wangf5271102009-10-10 19:07:35 +0800289}
290
291/* enter/exit analog low-current mode */
Takashi Iwaie9d010c2012-02-01 10:33:23 +0100292static void __analog_low_current_mode(struct hda_codec *codec, bool force)
Lydia Wangf5271102009-10-10 19:07:35 +0800293{
294 struct via_spec *spec = codec->spec;
Takashi Iwaiada509e2011-06-20 15:40:19 +0200295 bool enable;
296 unsigned int verb, parm;
Lydia Wangf5271102009-10-10 19:07:35 +0800297
Takashi Iwai967b1302015-03-20 18:21:03 +0100298 if (!codec->power_save_node)
Takashi Iwaie9d010c2012-02-01 10:33:23 +0100299 enable = false;
300 else
Takashi Iwaib3f60082013-01-07 12:27:36 +0100301 enable = is_aa_path_mute(codec) && !spec->gen.active_streams;
Takashi Iwaie9d010c2012-02-01 10:33:23 +0100302 if (enable == spec->alc_mode && !force)
303 return;
304 spec->alc_mode = enable;
Lydia Wangf5271102009-10-10 19:07:35 +0800305
306 /* decide low current mode's verb & parameter */
307 switch (spec->codec_type) {
308 case VT1708B_8CH:
309 case VT1708B_4CH:
310 verb = 0xf70;
311 parm = enable ? 0x02 : 0x00; /* 0x02: 2/3x, 0x00: 1x */
312 break;
313 case VT1708S:
Lydia Wangeb7188c2009-10-10 19:08:34 +0800314 case VT1718S:
Lydia Wangf3db4232009-10-10 19:08:41 +0800315 case VT1716S:
Lydia Wangf5271102009-10-10 19:07:35 +0800316 verb = 0xf73;
317 parm = enable ? 0x51 : 0xe1; /* 0x51: 4/28x, 0xe1: 1x */
318 break;
319 case VT1702:
320 verb = 0xf73;
321 parm = enable ? 0x01 : 0x1d; /* 0x01: 4/40x, 0x1d: 1x */
322 break;
Lydia Wang25eaba22009-10-10 19:08:43 +0800323 case VT2002P:
Lydia Wangab6734e2009-10-10 19:08:46 +0800324 case VT1812:
Lydia Wang118909562011-03-23 17:57:34 +0800325 case VT1802:
Lydia Wang25eaba22009-10-10 19:08:43 +0800326 verb = 0xf93;
327 parm = enable ? 0x00 : 0xe0; /* 0x00: 4/40x, 0xe0: 1x */
328 break;
Lydia Wang43737e02012-12-10 18:28:11 +0800329 case VT1705CF:
Lydia Wang6121b842012-12-10 19:03:26 +0800330 case VT1808:
Lydia Wang43737e02012-12-10 18:28:11 +0800331 verb = 0xf82;
332 parm = enable ? 0x00 : 0xe0; /* 0x00: 4/40x, 0xe0: 1x */
333 break;
Lydia Wangf5271102009-10-10 19:07:35 +0800334 default:
335 return; /* other codecs are not supported */
336 }
337 /* send verb */
Takashi Iwai7639a062015-03-03 10:07:24 +0100338 snd_hda_codec_write(codec, codec->core.afg, 0, verb, parm);
Lydia Wangf5271102009-10-10 19:07:35 +0800339}
340
Takashi Iwaie9d010c2012-02-01 10:33:23 +0100341static void analog_low_current_mode(struct hda_codec *codec)
342{
343 return __analog_low_current_mode(codec, false);
344}
345
Joseph Chanc577b8a2006-11-29 15:29:40 +0100346static int via_build_controls(struct hda_codec *codec)
347{
348 struct via_spec *spec = codec->spec;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100349 int err, i;
Joseph Chanc577b8a2006-11-29 15:29:40 +0100350
Takashi Iwaib3f60082013-01-07 12:27:36 +0100351 err = snd_hda_gen_build_controls(codec);
352 if (err < 0)
353 return err;
354
Takashi Iwai688b12c2015-03-17 15:56:05 +0100355 spec->mixers[spec->num_mixers++] = via_pin_power_ctl_enum;
Takashi Iwai24088a52011-06-17 16:59:21 +0200356
Joseph Chanc577b8a2006-11-29 15:29:40 +0100357 for (i = 0; i < spec->num_mixers; i++) {
358 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
359 if (err < 0)
360 return err;
361 }
362
Joseph Chanc577b8a2006-11-29 15:29:40 +0100363 return 0;
364}
365
Takashi Iwaib3f60082013-01-07 12:27:36 +0100366static void via_playback_pcm_hook(struct hda_pcm_stream *hinfo,
367 struct hda_codec *codec,
368 struct snd_pcm_substream *substream,
369 int action)
Joseph Chanc577b8a2006-11-29 15:29:40 +0100370{
Takashi Iwaib3f60082013-01-07 12:27:36 +0100371 analog_low_current_mode(codec);
372 vt1708_update_hp_work(codec);
Joseph Chanc577b8a2006-11-29 15:29:40 +0100373}
374
375static void via_free(struct hda_codec *codec)
376{
Takashi Iwaib3f60082013-01-07 12:27:36 +0100377 vt1708_stop_hp_work(codec);
Takashi Iwaia8dca462014-02-10 18:23:57 +0100378 snd_hda_gen_free(codec);
Joseph Chanc577b8a2006-11-29 15:29:40 +0100379}
380
Takashi Iwai2a439522011-07-26 09:52:50 +0200381#ifdef CONFIG_PM
Takashi Iwai68cb2b52012-07-02 15:20:37 +0200382static int via_suspend(struct hda_codec *codec)
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800383{
384 struct via_spec *spec = codec->spec;
Takashi Iwaib3f60082013-01-07 12:27:36 +0100385 vt1708_stop_hp_work(codec);
David Henningsson94c142a2012-08-09 10:56:12 +0200386
Takashi Iwai2c38d992013-06-05 15:25:18 +0200387 /* Fix pop noise on headphones */
388 if (spec->codec_type == VT1802)
389 snd_hda_shutup_pins(codec);
David Henningsson94c142a2012-08-09 10:56:12 +0200390
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800391 return 0;
392}
393#endif
394
Takashi Iwai83012a72012-08-24 18:38:08 +0200395#ifdef CONFIG_PM
Takashi Iwaicb53c622007-08-10 17:21:45 +0200396static int via_check_power_status(struct hda_codec *codec, hda_nid_t nid)
397{
398 struct via_spec *spec = codec->spec;
Takashi Iwaib3f60082013-01-07 12:27:36 +0100399 analog_low_current_mode(codec);
400 vt1708_update_hp_work(codec);
401 return snd_hda_check_amp_list_power(codec, &spec->gen.loopback, nid);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200402}
403#endif
404
Joseph Chanc577b8a2006-11-29 15:29:40 +0100405/*
406 */
Takashi Iwai5d417622011-06-20 11:32:27 +0200407
408static int via_init(struct hda_codec *codec);
409
Takashi Iwai90dd48a2011-05-02 12:38:19 +0200410static const struct hda_codec_ops via_patch_ops = {
Joseph Chanc577b8a2006-11-29 15:29:40 +0100411 .build_controls = via_build_controls,
Takashi Iwaib3f60082013-01-07 12:27:36 +0100412 .build_pcms = snd_hda_gen_build_pcms,
Joseph Chanc577b8a2006-11-29 15:29:40 +0100413 .init = via_init,
414 .free = via_free,
David Henningsson4e2d16d2012-10-08 15:44:14 +0200415 .unsol_event = snd_hda_jack_unsol_event,
Takashi Iwai2a439522011-07-26 09:52:50 +0200416#ifdef CONFIG_PM
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800417 .suspend = via_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +0200418 .check_power_status = via_check_power_status,
419#endif
Joseph Chanc577b8a2006-11-29 15:29:40 +0100420};
421
Takashi Iwai4a796162011-06-17 17:53:38 +0200422
Takashi Iwaib3f60082013-01-07 12:27:36 +0100423static const struct hda_verb vt1708_init_verbs[] = {
424 /* power down jack detect function */
425 {0x1, 0xf81, 0x1},
426 { }
Takashi Iwai3214b962011-07-18 12:49:25 +0200427};
Harald Welte76d9b0d2008-09-09 15:50:37 +0800428static void vt1708_set_pinconfig_connect(struct hda_codec *codec, hda_nid_t nid)
429{
430 unsigned int def_conf;
431 unsigned char seqassoc;
432
Takashi Iwai2f334f92009-02-20 14:37:42 +0100433 def_conf = snd_hda_codec_get_pincfg(codec, nid);
Harald Welte76d9b0d2008-09-09 15:50:37 +0800434 seqassoc = (unsigned char) get_defcfg_association(def_conf);
435 seqassoc = (seqassoc << 4) | get_defcfg_sequence(def_conf);
Lydia Wang82ef9e42009-10-10 19:08:19 +0800436 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE
437 && (seqassoc == 0xf0 || seqassoc == 0xff)) {
438 def_conf = def_conf & (~(AC_JACK_PORT_BOTH << 30));
439 snd_hda_codec_set_pincfg(codec, nid, def_conf);
Harald Welte76d9b0d2008-09-09 15:50:37 +0800440 }
441
442 return;
443}
444
Takashi Iwaie06e5a22011-06-17 15:46:13 +0200445static int vt1708_jack_detect_get(struct snd_kcontrol *kcontrol,
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800446 struct snd_ctl_elem_value *ucontrol)
447{
448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
449 struct via_spec *spec = codec->spec;
450
451 if (spec->codec_type != VT1708)
452 return 0;
Takashi Iwaie06e5a22011-06-17 15:46:13 +0200453 ucontrol->value.integer.value[0] = spec->vt1708_jack_detect;
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800454 return 0;
455}
456
Takashi Iwaie06e5a22011-06-17 15:46:13 +0200457static int vt1708_jack_detect_put(struct snd_kcontrol *kcontrol,
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800458 struct snd_ctl_elem_value *ucontrol)
459{
460 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
461 struct via_spec *spec = codec->spec;
Takashi Iwai187d3332011-11-24 16:33:09 +0100462 int val;
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800463
464 if (spec->codec_type != VT1708)
465 return 0;
Takashi Iwai187d3332011-11-24 16:33:09 +0100466 val = !!ucontrol->value.integer.value[0];
467 if (spec->vt1708_jack_detect == val)
468 return 0;
469 spec->vt1708_jack_detect = val;
Takashi Iwaib3f60082013-01-07 12:27:36 +0100470 vt1708_update_hp_work(codec);
Takashi Iwai187d3332011-11-24 16:33:09 +0100471 return 1;
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800472}
473
Takashi Iwaib3f60082013-01-07 12:27:36 +0100474static const struct snd_kcontrol_new vt1708_jack_detect_ctl[] = {
475 {
Takashi Iwaie06e5a22011-06-17 15:46:13 +0200476 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
477 .name = "Jack Detect",
478 .count = 1,
479 .info = snd_ctl_boolean_mono_info,
480 .get = vt1708_jack_detect_get,
481 .put = vt1708_jack_detect_put,
Takashi Iwaib3f60082013-01-07 12:27:36 +0100482 },
483 {} /* terminator */
Lydia Wang1f2e99f2009-10-10 19:08:17 +0800484};
485
Takashi Iwai4abdbd12013-03-22 15:11:07 +0100486static const struct badness_table via_main_out_badness = {
487 .no_primary_dac = 0x10000,
488 .no_dac = 0x4000,
489 .shared_primary = 0x10000,
490 .shared_surr = 0x20,
491 .shared_clfe = 0x20,
492 .shared_surr_main = 0x20,
493};
494static const struct badness_table via_extra_out_badness = {
495 .no_primary_dac = 0x4000,
496 .no_dac = 0x4000,
497 .shared_primary = 0x12,
498 .shared_surr = 0x20,
499 .shared_clfe = 0x20,
500 .shared_surr_main = 0x10,
501};
502
Takashi Iwaib3f60082013-01-07 12:27:36 +0100503static int via_parse_auto_config(struct hda_codec *codec)
504{
505 struct via_spec *spec = codec->spec;
506 int err;
507
Takashi Iwai4abdbd12013-03-22 15:11:07 +0100508 spec->gen.main_out_badness = &via_main_out_badness;
509 spec->gen.extra_out_badness = &via_extra_out_badness;
510
Takashi Iwaib3f60082013-01-07 12:27:36 +0100511 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0);
512 if (err < 0)
513 return err;
514
515 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
516 if (err < 0)
517 return err;
518
Takashi Iwai688b12c2015-03-17 15:56:05 +0100519 /* disable widget PM at start for compatibility */
Takashi Iwai967b1302015-03-20 18:21:03 +0100520 codec->power_save_node = 0;
Takashi Iwai688b12c2015-03-17 15:56:05 +0100521 spec->gen.power_down_unused = 0;
Takashi Iwaib3f60082013-01-07 12:27:36 +0100522 return 0;
Takashi Iwai4a918ff2011-06-20 12:39:26 +0200523}
524
Takashi Iwai5d417622011-06-20 11:32:27 +0200525static int via_init(struct hda_codec *codec)
526{
527 struct via_spec *spec = codec->spec;
528 int i;
529
530 for (i = 0; i < spec->num_iverbs; i++)
531 snd_hda_sequence_write(codec, spec->init_verbs[i]);
532
Takashi Iwaie9d010c2012-02-01 10:33:23 +0100533 /* init power states */
Takashi Iwaie9d010c2012-02-01 10:33:23 +0100534 __analog_low_current_mode(codec, true);
535
Takashi Iwaib3f60082013-01-07 12:27:36 +0100536 snd_hda_gen_init(codec);
Lydia Wang118909562011-03-23 17:57:34 +0800537
Takashi Iwaib3f60082013-01-07 12:27:36 +0100538 vt1708_update_hp_work(codec);
Lydia Wang25eaba22009-10-10 19:08:43 +0800539
Joseph Chanc577b8a2006-11-29 15:29:40 +0100540 return 0;
541}
542
David Henningssonf672f652013-02-05 12:06:02 +0100543static int vt1708_build_controls(struct hda_codec *codec)
544{
545 /* In order not to create "Phantom Jack" controls,
546 temporary enable jackpoll */
547 int err;
548 int old_interval = codec->jackpoll_interval;
549 codec->jackpoll_interval = msecs_to_jiffies(100);
550 err = via_build_controls(codec);
551 codec->jackpoll_interval = old_interval;
552 return err;
553}
554
Takashi Iwaib3f60082013-01-07 12:27:36 +0100555static int vt1708_build_pcms(struct hda_codec *codec)
Takashi Iwai337b9d02009-07-07 18:18:59 +0200556{
557 struct via_spec *spec = codec->spec;
Takashi Iwaib3f60082013-01-07 12:27:36 +0100558 int i, err;
Takashi Iwai337b9d02009-07-07 18:18:59 +0200559
Takashi Iwaib3f60082013-01-07 12:27:36 +0100560 err = snd_hda_gen_build_pcms(codec);
Takashi Iwai7639a062015-03-03 10:07:24 +0100561 if (err < 0 || codec->core.vendor_id != 0x11061708)
Takashi Iwaib3f60082013-01-07 12:27:36 +0100562 return err;
563
564 /* We got noisy outputs on the right channel on VT1708 when
565 * 24bit samples are used. Until any workaround is found,
566 * disable the 24bit format, so far.
567 */
Takashi Iwaibbbc7e82015-02-27 17:43:19 +0100568 for (i = 0; i < ARRAY_SIZE(spec->gen.pcm_rec); i++) {
569 struct hda_pcm *info = spec->gen.pcm_rec[i];
570 if (!info)
571 continue;
Takashi Iwaib3f60082013-01-07 12:27:36 +0100572 if (!info->stream[SNDRV_PCM_STREAM_PLAYBACK].substreams ||
573 info->pcm_type != HDA_PCM_TYPE_AUDIO)
574 continue;
575 info->stream[SNDRV_PCM_STREAM_PLAYBACK].formats =
576 SNDRV_PCM_FMTBIT_S16_LE;
Takashi Iwai337b9d02009-07-07 18:18:59 +0200577 }
Takashi Iwaib3f60082013-01-07 12:27:36 +0100578
Takashi Iwai1c55d522009-07-08 07:45:46 +0200579 return 0;
Takashi Iwai337b9d02009-07-07 18:18:59 +0200580}
581
Joseph Chanc577b8a2006-11-29 15:29:40 +0100582static int patch_vt1708(struct hda_codec *codec)
583{
584 struct via_spec *spec;
585 int err;
586
587 /* create a codec specific record */
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100588 spec = via_new_spec(codec);
Joseph Chanc577b8a2006-11-29 15:29:40 +0100589 if (spec == NULL)
590 return -ENOMEM;
591
Takashi Iwaib3f60082013-01-07 12:27:36 +0100592 spec->gen.mixer_nid = 0x17;
593
594 /* set jackpoll_interval while parsing the codec */
595 codec->jackpoll_interval = msecs_to_jiffies(100);
596 spec->vt1708_jack_detect = 1;
597
598 /* don't support the input jack switching due to lack of unsol event */
599 /* (it may work with polling, though, but it needs testing) */
600 spec->gen.suppress_auto_mic = 1;
Takashi Iwaieb33ccf2013-06-24 16:18:10 +0200601 /* Some machines show the broken speaker mute */
602 spec->gen.auto_mute_via_amp = 1;
Takashi Iwai620e2b22011-06-17 17:19:19 +0200603
Takashi Iwai12daef62011-06-18 17:45:49 +0200604 /* Add HP and CD pin config connect bit re-config action */
605 vt1708_set_pinconfig_connect(codec, VT1708_HP_PIN_NID);
606 vt1708_set_pinconfig_connect(codec, VT1708_CD_PIN_NID);
607
Joseph Chanc577b8a2006-11-29 15:29:40 +0100608 /* automatic parse from the BIOS config */
Takashi Iwai12daef62011-06-18 17:45:49 +0200609 err = via_parse_auto_config(codec);
Joseph Chanc577b8a2006-11-29 15:29:40 +0100610 if (err < 0) {
611 via_free(codec);
612 return err;
Joseph Chanc577b8a2006-11-29 15:29:40 +0100613 }
614
Takashi Iwai12daef62011-06-18 17:45:49 +0200615 /* add jack detect on/off control */
Takashi Iwaib3f60082013-01-07 12:27:36 +0100616 spec->mixers[spec->num_mixers++] = vt1708_jack_detect_ctl;
Joseph Chanc577b8a2006-11-29 15:29:40 +0100617
Lydia Wange322a362011-06-29 13:52:02 +0800618 spec->init_verbs[spec->num_iverbs++] = vt1708_init_verbs;
619
Joseph Chanc577b8a2006-11-29 15:29:40 +0100620 codec->patch_ops = via_patch_ops;
David Henningssonf672f652013-02-05 12:06:02 +0100621 codec->patch_ops.build_controls = vt1708_build_controls;
Takashi Iwaib3f60082013-01-07 12:27:36 +0100622 codec->patch_ops.build_pcms = vt1708_build_pcms;
Joseph Chanc577b8a2006-11-29 15:29:40 +0100623
Takashi Iwaib3f60082013-01-07 12:27:36 +0100624 /* clear jackpoll_interval again; it's set dynamically */
625 codec->jackpoll_interval = 0;
626
Joseph Chanc577b8a2006-11-29 15:29:40 +0100627 return 0;
628}
629
Takashi Iwaiddd304d2011-06-21 16:33:55 +0200630static int patch_vt1709(struct hda_codec *codec)
Joseph Chanc577b8a2006-11-29 15:29:40 +0100631{
632 struct via_spec *spec;
633 int err;
634
635 /* create a codec specific record */
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100636 spec = via_new_spec(codec);
Joseph Chanc577b8a2006-11-29 15:29:40 +0100637 if (spec == NULL)
638 return -ENOMEM;
639
Takashi Iwaib3f60082013-01-07 12:27:36 +0100640 spec->gen.mixer_nid = 0x18;
Takashi Iwai620e2b22011-06-17 17:19:19 +0200641
Takashi Iwai12daef62011-06-18 17:45:49 +0200642 err = via_parse_auto_config(codec);
Joseph Chanc577b8a2006-11-29 15:29:40 +0100643 if (err < 0) {
644 via_free(codec);
645 return err;
Joseph Chanc577b8a2006-11-29 15:29:40 +0100646 }
647
Joseph Chanc577b8a2006-11-29 15:29:40 +0100648 codec->patch_ops = via_patch_ops;
649
Josepch Chanf7278fd2007-12-13 16:40:40 +0100650 return 0;
651}
652
Lydia Wang518bf3b2009-10-10 19:07:29 +0800653static int patch_vt1708S(struct hda_codec *codec);
Takashi Iwaiddd304d2011-06-21 16:33:55 +0200654static int patch_vt1708B(struct hda_codec *codec)
Josepch Chanf7278fd2007-12-13 16:40:40 +0100655{
656 struct via_spec *spec;
657 int err;
658
Lydia Wang518bf3b2009-10-10 19:07:29 +0800659 if (get_codec_type(codec) == VT1708BCE)
660 return patch_vt1708S(codec);
Takashi Iwaiddd304d2011-06-21 16:33:55 +0200661
Josepch Chanf7278fd2007-12-13 16:40:40 +0100662 /* create a codec specific record */
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100663 spec = via_new_spec(codec);
Josepch Chanf7278fd2007-12-13 16:40:40 +0100664 if (spec == NULL)
665 return -ENOMEM;
666
Takashi Iwaib3f60082013-01-07 12:27:36 +0100667 spec->gen.mixer_nid = 0x16;
Takashi Iwai620e2b22011-06-17 17:19:19 +0200668
Josepch Chanf7278fd2007-12-13 16:40:40 +0100669 /* automatic parse from the BIOS config */
Takashi Iwai12daef62011-06-18 17:45:49 +0200670 err = via_parse_auto_config(codec);
Josepch Chanf7278fd2007-12-13 16:40:40 +0100671 if (err < 0) {
672 via_free(codec);
673 return err;
Josepch Chanf7278fd2007-12-13 16:40:40 +0100674 }
675
Josepch Chanf7278fd2007-12-13 16:40:40 +0100676 codec->patch_ops = via_patch_ops;
Josepch Chanf7278fd2007-12-13 16:40:40 +0100677 return 0;
678}
679
Harald Welted949cac2008-09-09 15:56:01 +0800680/* Patch for VT1708S */
Takashi Iwai096a8852011-06-20 12:09:02 +0200681static const struct hda_verb vt1708S_init_verbs[] = {
Harald Welted7426322008-09-15 22:43:23 +0800682 /* Enable Mic Boost Volume backdoor */
683 {0x1, 0xf98, 0x1},
Lydia Wangbc7e7e52009-10-10 19:08:32 +0800684 /* don't bybass mixer */
685 {0x1, 0xf88, 0xc0},
Harald Welted949cac2008-09-09 15:56:01 +0800686 { }
687};
688
Lydia Wang6369bcf2009-10-10 19:08:31 +0800689static void override_mic_boost(struct hda_codec *codec, hda_nid_t pin,
690 int offset, int num_steps, int step_size)
691{
Takashi Iwaid045c5d2013-06-19 07:54:09 +0200692 snd_hda_override_wcaps(codec, pin,
693 get_wcaps(codec, pin) | AC_WCAP_IN_AMP);
Lydia Wang6369bcf2009-10-10 19:08:31 +0800694 snd_hda_override_amp_caps(codec, pin, HDA_INPUT,
695 (offset << AC_AMPCAP_OFFSET_SHIFT) |
696 (num_steps << AC_AMPCAP_NUM_STEPS_SHIFT) |
697 (step_size << AC_AMPCAP_STEP_SIZE_SHIFT) |
698 (0 << AC_AMPCAP_MUTE_SHIFT));
699}
700
Harald Welted949cac2008-09-09 15:56:01 +0800701static int patch_vt1708S(struct hda_codec *codec)
702{
703 struct via_spec *spec;
704 int err;
705
706 /* create a codec specific record */
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100707 spec = via_new_spec(codec);
Harald Welted949cac2008-09-09 15:56:01 +0800708 if (spec == NULL)
709 return -ENOMEM;
710
Takashi Iwaib3f60082013-01-07 12:27:36 +0100711 spec->gen.mixer_nid = 0x16;
Takashi Iwaid7a99cc2011-06-18 17:24:46 +0200712 override_mic_boost(codec, 0x1a, 0, 3, 40);
713 override_mic_boost(codec, 0x1e, 0, 3, 40);
Takashi Iwai620e2b22011-06-17 17:19:19 +0200714
Lydia Wang518bf3b2009-10-10 19:07:29 +0800715 /* correct names for VT1708BCE */
716 if (get_codec_type(codec) == VT1708BCE) {
Takashi Iwai7639a062015-03-03 10:07:24 +0100717 kfree(codec->core.chip_name);
718 codec->core.chip_name = kstrdup("VT1708BCE", GFP_KERNEL);
Takashi Iwai6efdd852015-02-27 16:09:22 +0100719 snprintf(codec->card->mixername,
720 sizeof(codec->card->mixername),
Takashi Iwai7639a062015-03-03 10:07:24 +0100721 "%s %s", codec->core.vendor_name, codec->core.chip_name);
Lydia Wang970f630f2011-03-22 16:25:56 +0800722 }
Lydia Wangbc92df72011-03-23 17:56:05 +0800723 /* correct names for VT1705 */
Takashi Iwai7639a062015-03-03 10:07:24 +0100724 if (codec->core.vendor_id == 0x11064397) {
725 kfree(codec->core.chip_name);
726 codec->core.chip_name = kstrdup("VT1705", GFP_KERNEL);
Takashi Iwai6efdd852015-02-27 16:09:22 +0100727 snprintf(codec->card->mixername,
728 sizeof(codec->card->mixername),
Takashi Iwai7639a062015-03-03 10:07:24 +0100729 "%s %s", codec->core.vendor_name, codec->core.chip_name);
Lydia Wangbc92df72011-03-23 17:56:05 +0800730 }
Takashi Iwaib3f60082013-01-07 12:27:36 +0100731
732 /* automatic parse from the BIOS config */
733 err = via_parse_auto_config(codec);
734 if (err < 0) {
735 via_free(codec);
736 return err;
737 }
738
739 spec->init_verbs[spec->num_iverbs++] = vt1708S_init_verbs;
740
741 codec->patch_ops = via_patch_ops;
Harald Welted949cac2008-09-09 15:56:01 +0800742 return 0;
743}
744
745/* Patch for VT1702 */
746
Takashi Iwai096a8852011-06-20 12:09:02 +0200747static const struct hda_verb vt1702_init_verbs[] = {
Lydia Wangbc7e7e52009-10-10 19:08:32 +0800748 /* mixer enable */
749 {0x1, 0xF88, 0x3},
750 /* GPIO 0~2 */
751 {0x1, 0xF82, 0x3F},
Harald Welted949cac2008-09-09 15:56:01 +0800752 { }
753};
754
Harald Welted949cac2008-09-09 15:56:01 +0800755static int patch_vt1702(struct hda_codec *codec)
756{
757 struct via_spec *spec;
758 int err;
Harald Welted949cac2008-09-09 15:56:01 +0800759
760 /* create a codec specific record */
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100761 spec = via_new_spec(codec);
Harald Welted949cac2008-09-09 15:56:01 +0800762 if (spec == NULL)
763 return -ENOMEM;
764
Takashi Iwaib3f60082013-01-07 12:27:36 +0100765 spec->gen.mixer_nid = 0x1a;
Takashi Iwai620e2b22011-06-17 17:19:19 +0200766
Takashi Iwai12daef62011-06-18 17:45:49 +0200767 /* limit AA path volume to 0 dB */
768 snd_hda_override_amp_caps(codec, 0x1A, HDA_INPUT,
769 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
770 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
771 (0x5 << AC_AMPCAP_STEP_SIZE_SHIFT) |
772 (1 << AC_AMPCAP_MUTE_SHIFT));
773
Harald Welted949cac2008-09-09 15:56:01 +0800774 /* automatic parse from the BIOS config */
Takashi Iwai12daef62011-06-18 17:45:49 +0200775 err = via_parse_auto_config(codec);
Harald Welted949cac2008-09-09 15:56:01 +0800776 if (err < 0) {
777 via_free(codec);
778 return err;
Harald Welted949cac2008-09-09 15:56:01 +0800779 }
780
Takashi Iwai096a8852011-06-20 12:09:02 +0200781 spec->init_verbs[spec->num_iverbs++] = vt1702_init_verbs;
Harald Welted949cac2008-09-09 15:56:01 +0800782
Harald Welted949cac2008-09-09 15:56:01 +0800783 codec->patch_ops = via_patch_ops;
Harald Welted949cac2008-09-09 15:56:01 +0800784 return 0;
785}
786
Lydia Wangeb7188c2009-10-10 19:08:34 +0800787/* Patch for VT1718S */
788
Takashi Iwai096a8852011-06-20 12:09:02 +0200789static const struct hda_verb vt1718S_init_verbs[] = {
Lydia Wang4ab2d532011-03-24 12:42:03 +0800790 /* Enable MW0 adjust Gain 5 */
791 {0x1, 0xfb2, 0x10},
Lydia Wangeb7188c2009-10-10 19:08:34 +0800792 /* Enable Boost Volume backdoor */
793 {0x1, 0xf88, 0x8},
Takashi Iwai5d417622011-06-20 11:32:27 +0200794
Lydia Wangeb7188c2009-10-10 19:08:34 +0800795 { }
796};
797
Takashi Iwai30b45032011-07-11 17:05:04 +0200798/* Add a connection to the primary DAC from AA-mixer for some codecs
799 * This isn't listed from the raw info, but the chip has a secret connection.
800 */
801static int add_secret_dac_path(struct hda_codec *codec)
802{
803 struct via_spec *spec = codec->spec;
804 int i, nums;
805 hda_nid_t conn[8];
806 hda_nid_t nid;
807
Takashi Iwaib3f60082013-01-07 12:27:36 +0100808 if (!spec->gen.mixer_nid)
Takashi Iwai30b45032011-07-11 17:05:04 +0200809 return 0;
Takashi Iwaib3f60082013-01-07 12:27:36 +0100810 nums = snd_hda_get_connections(codec, spec->gen.mixer_nid, conn,
Takashi Iwai30b45032011-07-11 17:05:04 +0200811 ARRAY_SIZE(conn) - 1);
812 for (i = 0; i < nums; i++) {
813 if (get_wcaps_type(get_wcaps(codec, conn[i])) == AC_WID_AUD_OUT)
814 return 0;
815 }
816
817 /* find the primary DAC and add to the connection list */
Takashi Iwai7639a062015-03-03 10:07:24 +0100818 for_each_hda_codec_node(nid, codec) {
Takashi Iwai30b45032011-07-11 17:05:04 +0200819 unsigned int caps = get_wcaps(codec, nid);
820 if (get_wcaps_type(caps) == AC_WID_AUD_OUT &&
821 !(caps & AC_WCAP_DIGITAL)) {
822 conn[nums++] = nid;
823 return snd_hda_override_conn_list(codec,
Takashi Iwaib3f60082013-01-07 12:27:36 +0100824 spec->gen.mixer_nid,
Takashi Iwai30b45032011-07-11 17:05:04 +0200825 nums, conn);
826 }
827 }
828 return 0;
829}
830
831
Lydia Wangeb7188c2009-10-10 19:08:34 +0800832static int patch_vt1718S(struct hda_codec *codec)
833{
834 struct via_spec *spec;
835 int err;
836
837 /* create a codec specific record */
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100838 spec = via_new_spec(codec);
Lydia Wangeb7188c2009-10-10 19:08:34 +0800839 if (spec == NULL)
840 return -ENOMEM;
841
Takashi Iwaib3f60082013-01-07 12:27:36 +0100842 spec->gen.mixer_nid = 0x21;
Takashi Iwaid7a99cc2011-06-18 17:24:46 +0200843 override_mic_boost(codec, 0x2b, 0, 3, 40);
844 override_mic_boost(codec, 0x29, 0, 3, 40);
Takashi Iwai30b45032011-07-11 17:05:04 +0200845 add_secret_dac_path(codec);
Takashi Iwai620e2b22011-06-17 17:19:19 +0200846
Lydia Wangeb7188c2009-10-10 19:08:34 +0800847 /* automatic parse from the BIOS config */
Takashi Iwai12daef62011-06-18 17:45:49 +0200848 err = via_parse_auto_config(codec);
Lydia Wangeb7188c2009-10-10 19:08:34 +0800849 if (err < 0) {
850 via_free(codec);
851 return err;
Lydia Wangeb7188c2009-10-10 19:08:34 +0800852 }
853
Takashi Iwai096a8852011-06-20 12:09:02 +0200854 spec->init_verbs[spec->num_iverbs++] = vt1718S_init_verbs;
Lydia Wangeb7188c2009-10-10 19:08:34 +0800855
Lydia Wangeb7188c2009-10-10 19:08:34 +0800856 codec->patch_ops = via_patch_ops;
Lydia Wangeb7188c2009-10-10 19:08:34 +0800857 return 0;
858}
Lydia Wangf3db4232009-10-10 19:08:41 +0800859
860/* Patch for VT1716S */
861
862static int vt1716s_dmic_info(struct snd_kcontrol *kcontrol,
863 struct snd_ctl_elem_info *uinfo)
864{
865 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
866 uinfo->count = 1;
867 uinfo->value.integer.min = 0;
868 uinfo->value.integer.max = 1;
869 return 0;
870}
871
872static int vt1716s_dmic_get(struct snd_kcontrol *kcontrol,
873 struct snd_ctl_elem_value *ucontrol)
874{
875 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
876 int index = 0;
877
878 index = snd_hda_codec_read(codec, 0x26, 0,
879 AC_VERB_GET_CONNECT_SEL, 0);
880 if (index != -1)
881 *ucontrol->value.integer.value = index;
882
883 return 0;
884}
885
886static int vt1716s_dmic_put(struct snd_kcontrol *kcontrol,
887 struct snd_ctl_elem_value *ucontrol)
888{
889 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
890 struct via_spec *spec = codec->spec;
891 int index = *ucontrol->value.integer.value;
892
893 snd_hda_codec_write(codec, 0x26, 0,
894 AC_VERB_SET_CONNECT_SEL, index);
895 spec->dmic_enabled = index;
Lydia Wangf3db4232009-10-10 19:08:41 +0800896 return 1;
897}
898
Takashi Iwai90dd48a2011-05-02 12:38:19 +0200899static const struct snd_kcontrol_new vt1716s_dmic_mixer[] = {
Lydia Wangf3db4232009-10-10 19:08:41 +0800900 HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x22, 0x0, HDA_INPUT),
901 {
902 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
903 .name = "Digital Mic Capture Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100904 .subdevice = HDA_SUBDEV_NID_FLAG | 0x26,
Lydia Wangf3db4232009-10-10 19:08:41 +0800905 .count = 1,
906 .info = vt1716s_dmic_info,
907 .get = vt1716s_dmic_get,
908 .put = vt1716s_dmic_put,
909 },
910 {} /* end */
911};
912
913
914/* mono-out mixer elements */
Takashi Iwai90dd48a2011-05-02 12:38:19 +0200915static const struct snd_kcontrol_new vt1716S_mono_out_mixer[] = {
Lydia Wangf3db4232009-10-10 19:08:41 +0800916 HDA_CODEC_MUTE("Mono Playback Switch", 0x2a, 0x0, HDA_OUTPUT),
917 { } /* end */
918};
919
Takashi Iwai096a8852011-06-20 12:09:02 +0200920static const struct hda_verb vt1716S_init_verbs[] = {
Lydia Wangf3db4232009-10-10 19:08:41 +0800921 /* Enable Boost Volume backdoor */
922 {0x1, 0xf8a, 0x80},
923 /* don't bybass mixer */
924 {0x1, 0xf88, 0xc0},
925 /* Enable mono output */
926 {0x1, 0xf90, 0x08},
927 { }
928};
929
Lydia Wangf3db4232009-10-10 19:08:41 +0800930static int patch_vt1716S(struct hda_codec *codec)
931{
932 struct via_spec *spec;
933 int err;
934
935 /* create a codec specific record */
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100936 spec = via_new_spec(codec);
Lydia Wangf3db4232009-10-10 19:08:41 +0800937 if (spec == NULL)
938 return -ENOMEM;
939
Takashi Iwaib3f60082013-01-07 12:27:36 +0100940 spec->gen.mixer_nid = 0x16;
Takashi Iwaid7a99cc2011-06-18 17:24:46 +0200941 override_mic_boost(codec, 0x1a, 0, 3, 40);
942 override_mic_boost(codec, 0x1e, 0, 3, 40);
Takashi Iwai620e2b22011-06-17 17:19:19 +0200943
Lydia Wangf3db4232009-10-10 19:08:41 +0800944 /* automatic parse from the BIOS config */
Takashi Iwai12daef62011-06-18 17:45:49 +0200945 err = via_parse_auto_config(codec);
Lydia Wangf3db4232009-10-10 19:08:41 +0800946 if (err < 0) {
947 via_free(codec);
948 return err;
Lydia Wangf3db4232009-10-10 19:08:41 +0800949 }
950
Takashi Iwai096a8852011-06-20 12:09:02 +0200951 spec->init_verbs[spec->num_iverbs++] = vt1716S_init_verbs;
Lydia Wangf3db4232009-10-10 19:08:41 +0800952
Takashi Iwaib3f60082013-01-07 12:27:36 +0100953 spec->mixers[spec->num_mixers++] = vt1716s_dmic_mixer;
Lydia Wangf3db4232009-10-10 19:08:41 +0800954 spec->mixers[spec->num_mixers++] = vt1716S_mono_out_mixer;
955
956 codec->patch_ops = via_patch_ops;
Lydia Wangf3db4232009-10-10 19:08:41 +0800957 return 0;
958}
Lydia Wang25eaba22009-10-10 19:08:43 +0800959
960/* for vt2002P */
961
Takashi Iwai096a8852011-06-20 12:09:02 +0200962static const struct hda_verb vt2002P_init_verbs[] = {
Lydia Wangeadb9a82011-03-24 12:43:02 +0800963 /* Class-D speaker related verbs */
964 {0x1, 0xfe0, 0x4},
965 {0x1, 0xfe9, 0x80},
966 {0x1, 0xfe2, 0x22},
Lydia Wang25eaba22009-10-10 19:08:43 +0800967 /* Enable Boost Volume backdoor */
968 {0x1, 0xfb9, 0x24},
Lydia Wang25eaba22009-10-10 19:08:43 +0800969 /* Enable AOW0 to MW9 */
970 {0x1, 0xfb8, 0x88},
971 { }
972};
Takashi Iwai4a918ff2011-06-20 12:39:26 +0200973
Takashi Iwai096a8852011-06-20 12:09:02 +0200974static const struct hda_verb vt1802_init_verbs[] = {
Lydia Wang118909562011-03-23 17:57:34 +0800975 /* Enable Boost Volume backdoor */
976 {0x1, 0xfb9, 0x24},
Lydia Wang118909562011-03-23 17:57:34 +0800977 /* Enable AOW0 to MW9 */
978 {0x1, 0xfb8, 0x88},
979 { }
980};
Lydia Wang25eaba22009-10-10 19:08:43 +0800981
David Henningsson4b527b62012-09-18 14:26:59 +0200982/*
983 * pin fix-up
984 */
985enum {
986 VIA_FIXUP_INTMIC_BOOST,
Takashi Iwaid5266122012-11-07 10:40:36 +0100987 VIA_FIXUP_ASUS_G75,
David Henningsson4b527b62012-09-18 14:26:59 +0200988};
989
990static void via_fixup_intmic_boost(struct hda_codec *codec,
991 const struct hda_fixup *fix, int action)
992{
993 if (action == HDA_FIXUP_ACT_PRE_PROBE)
994 override_mic_boost(codec, 0x30, 0, 2, 40);
995}
996
997static const struct hda_fixup via_fixups[] = {
998 [VIA_FIXUP_INTMIC_BOOST] = {
999 .type = HDA_FIXUP_FUNC,
1000 .v.func = via_fixup_intmic_boost,
1001 },
Takashi Iwaid5266122012-11-07 10:40:36 +01001002 [VIA_FIXUP_ASUS_G75] = {
1003 .type = HDA_FIXUP_PINS,
1004 .v.pins = (const struct hda_pintbl[]) {
1005 /* set 0x24 and 0x33 as speakers */
1006 { 0x24, 0x991301f0 },
1007 { 0x33, 0x991301f1 }, /* subwoofer */
1008 { }
1009 }
1010 },
David Henningsson4b527b62012-09-18 14:26:59 +02001011};
1012
1013static const struct snd_pci_quirk vt2002p_fixups[] = {
Takashi Iwaid5266122012-11-07 10:40:36 +01001014 SND_PCI_QUIRK(0x1043, 0x1487, "Asus G75", VIA_FIXUP_ASUS_G75),
David Henningsson4b527b62012-09-18 14:26:59 +02001015 SND_PCI_QUIRK(0x1043, 0x8532, "Asus X202E", VIA_FIXUP_INTMIC_BOOST),
1016 {}
1017};
1018
Takashi Iwaief4da452012-11-07 10:37:48 +01001019/* NIDs 0x24 and 0x33 on VT1802 have connections to non-existing NID 0x3e
1020 * Replace this with mixer NID 0x1c
1021 */
1022static void fix_vt1802_connections(struct hda_codec *codec)
1023{
1024 static hda_nid_t conn_24[] = { 0x14, 0x1c };
1025 static hda_nid_t conn_33[] = { 0x1c };
1026
1027 snd_hda_override_conn_list(codec, 0x24, ARRAY_SIZE(conn_24), conn_24);
1028 snd_hda_override_conn_list(codec, 0x33, ARRAY_SIZE(conn_33), conn_33);
1029}
1030
Lydia Wang25eaba22009-10-10 19:08:43 +08001031/* patch for vt2002P */
1032static int patch_vt2002P(struct hda_codec *codec)
1033{
1034 struct via_spec *spec;
1035 int err;
1036
1037 /* create a codec specific record */
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01001038 spec = via_new_spec(codec);
Lydia Wang25eaba22009-10-10 19:08:43 +08001039 if (spec == NULL)
1040 return -ENOMEM;
1041
Takashi Iwaib3f60082013-01-07 12:27:36 +01001042 spec->gen.mixer_nid = 0x21;
Takashi Iwaid7a99cc2011-06-18 17:24:46 +02001043 override_mic_boost(codec, 0x2b, 0, 3, 40);
1044 override_mic_boost(codec, 0x29, 0, 3, 40);
Takashi Iwaief4da452012-11-07 10:37:48 +01001045 if (spec->codec_type == VT1802)
1046 fix_vt1802_connections(codec);
Takashi Iwai30b45032011-07-11 17:05:04 +02001047 add_secret_dac_path(codec);
Takashi Iwai620e2b22011-06-17 17:19:19 +02001048
David Henningsson4b527b62012-09-18 14:26:59 +02001049 snd_hda_pick_fixup(codec, NULL, vt2002p_fixups, via_fixups);
1050 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1051
Lydia Wang25eaba22009-10-10 19:08:43 +08001052 /* automatic parse from the BIOS config */
Takashi Iwai12daef62011-06-18 17:45:49 +02001053 err = via_parse_auto_config(codec);
Lydia Wang25eaba22009-10-10 19:08:43 +08001054 if (err < 0) {
1055 via_free(codec);
1056 return err;
Lydia Wang25eaba22009-10-10 19:08:43 +08001057 }
1058
Lydia Wang118909562011-03-23 17:57:34 +08001059 if (spec->codec_type == VT1802)
Takashi Iwai4a918ff2011-06-20 12:39:26 +02001060 spec->init_verbs[spec->num_iverbs++] = vt1802_init_verbs;
Lydia Wang118909562011-03-23 17:57:34 +08001061 else
Takashi Iwai4a918ff2011-06-20 12:39:26 +02001062 spec->init_verbs[spec->num_iverbs++] = vt2002P_init_verbs;
Lydia Wang118909562011-03-23 17:57:34 +08001063
Lydia Wang25eaba22009-10-10 19:08:43 +08001064 codec->patch_ops = via_patch_ops;
Lydia Wang25eaba22009-10-10 19:08:43 +08001065 return 0;
1066}
Lydia Wangab6734e2009-10-10 19:08:46 +08001067
1068/* for vt1812 */
1069
Takashi Iwai096a8852011-06-20 12:09:02 +02001070static const struct hda_verb vt1812_init_verbs[] = {
Lydia Wangab6734e2009-10-10 19:08:46 +08001071 /* Enable Boost Volume backdoor */
1072 {0x1, 0xfb9, 0x24},
Lydia Wangab6734e2009-10-10 19:08:46 +08001073 /* Enable AOW0 to MW9 */
1074 {0x1, 0xfb8, 0xa8},
1075 { }
1076};
1077
Lydia Wangab6734e2009-10-10 19:08:46 +08001078/* patch for vt1812 */
1079static int patch_vt1812(struct hda_codec *codec)
1080{
1081 struct via_spec *spec;
1082 int err;
1083
1084 /* create a codec specific record */
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01001085 spec = via_new_spec(codec);
Lydia Wangab6734e2009-10-10 19:08:46 +08001086 if (spec == NULL)
1087 return -ENOMEM;
1088
Takashi Iwaib3f60082013-01-07 12:27:36 +01001089 spec->gen.mixer_nid = 0x21;
Takashi Iwaid7a99cc2011-06-18 17:24:46 +02001090 override_mic_boost(codec, 0x2b, 0, 3, 40);
1091 override_mic_boost(codec, 0x29, 0, 3, 40);
Takashi Iwai30b45032011-07-11 17:05:04 +02001092 add_secret_dac_path(codec);
Takashi Iwai620e2b22011-06-17 17:19:19 +02001093
Lydia Wangab6734e2009-10-10 19:08:46 +08001094 /* automatic parse from the BIOS config */
Takashi Iwai12daef62011-06-18 17:45:49 +02001095 err = via_parse_auto_config(codec);
Lydia Wangab6734e2009-10-10 19:08:46 +08001096 if (err < 0) {
1097 via_free(codec);
1098 return err;
Lydia Wangab6734e2009-10-10 19:08:46 +08001099 }
1100
Takashi Iwai096a8852011-06-20 12:09:02 +02001101 spec->init_verbs[spec->num_iverbs++] = vt1812_init_verbs;
Lydia Wangab6734e2009-10-10 19:08:46 +08001102
Lydia Wangab6734e2009-10-10 19:08:46 +08001103 codec->patch_ops = via_patch_ops;
Lydia Wangab6734e2009-10-10 19:08:46 +08001104 return 0;
1105}
1106
Lydia Wang43737e02012-12-10 18:28:11 +08001107/* patch for vt3476 */
1108
1109static const struct hda_verb vt3476_init_verbs[] = {
1110 /* Enable DMic 8/16/32K */
1111 {0x1, 0xF7B, 0x30},
1112 /* Enable Boost Volume backdoor */
1113 {0x1, 0xFB9, 0x20},
1114 /* Enable AOW-MW9 path */
1115 {0x1, 0xFB8, 0x10},
1116 { }
1117};
1118
Lydia Wang43737e02012-12-10 18:28:11 +08001119static int patch_vt3476(struct hda_codec *codec)
1120{
1121 struct via_spec *spec;
1122 int err;
1123
1124 /* create a codec specific record */
1125 spec = via_new_spec(codec);
1126 if (spec == NULL)
1127 return -ENOMEM;
1128
Takashi Iwaib3f60082013-01-07 12:27:36 +01001129 spec->gen.mixer_nid = 0x3f;
Lydia Wang43737e02012-12-10 18:28:11 +08001130 add_secret_dac_path(codec);
1131
1132 /* automatic parse from the BIOS config */
1133 err = via_parse_auto_config(codec);
1134 if (err < 0) {
1135 via_free(codec);
1136 return err;
1137 }
1138
1139 spec->init_verbs[spec->num_iverbs++] = vt3476_init_verbs;
1140
1141 codec->patch_ops = via_patch_ops;
Lydia Wang43737e02012-12-10 18:28:11 +08001142 return 0;
1143}
1144
Joseph Chanc577b8a2006-11-29 15:29:40 +01001145/*
1146 * patch entries
1147 */
Takashi Iwai90dd48a2011-05-02 12:38:19 +02001148static const struct hda_codec_preset snd_hda_preset_via[] = {
Takashi Iwai3218c172008-12-18 09:17:56 +01001149 { .id = 0x11061708, .name = "VT1708", .patch = patch_vt1708},
1150 { .id = 0x11061709, .name = "VT1708", .patch = patch_vt1708},
1151 { .id = 0x1106170a, .name = "VT1708", .patch = patch_vt1708},
1152 { .id = 0x1106170b, .name = "VT1708", .patch = patch_vt1708},
1153 { .id = 0x1106e710, .name = "VT1709 10-Ch",
Takashi Iwaiddd304d2011-06-21 16:33:55 +02001154 .patch = patch_vt1709},
Takashi Iwai3218c172008-12-18 09:17:56 +01001155 { .id = 0x1106e711, .name = "VT1709 10-Ch",
Takashi Iwaiddd304d2011-06-21 16:33:55 +02001156 .patch = patch_vt1709},
Takashi Iwai3218c172008-12-18 09:17:56 +01001157 { .id = 0x1106e712, .name = "VT1709 10-Ch",
Takashi Iwaiddd304d2011-06-21 16:33:55 +02001158 .patch = patch_vt1709},
Takashi Iwai3218c172008-12-18 09:17:56 +01001159 { .id = 0x1106e713, .name = "VT1709 10-Ch",
Takashi Iwaiddd304d2011-06-21 16:33:55 +02001160 .patch = patch_vt1709},
Takashi Iwai3218c172008-12-18 09:17:56 +01001161 { .id = 0x1106e714, .name = "VT1709 6-Ch",
Takashi Iwaiddd304d2011-06-21 16:33:55 +02001162 .patch = patch_vt1709},
Takashi Iwai3218c172008-12-18 09:17:56 +01001163 { .id = 0x1106e715, .name = "VT1709 6-Ch",
Takashi Iwaiddd304d2011-06-21 16:33:55 +02001164 .patch = patch_vt1709},
Takashi Iwai3218c172008-12-18 09:17:56 +01001165 { .id = 0x1106e716, .name = "VT1709 6-Ch",
Takashi Iwaiddd304d2011-06-21 16:33:55 +02001166 .patch = patch_vt1709},
Takashi Iwai3218c172008-12-18 09:17:56 +01001167 { .id = 0x1106e717, .name = "VT1709 6-Ch",
Takashi Iwaiddd304d2011-06-21 16:33:55 +02001168 .patch = patch_vt1709},
Takashi Iwai3218c172008-12-18 09:17:56 +01001169 { .id = 0x1106e720, .name = "VT1708B 8-Ch",
Takashi Iwaiddd304d2011-06-21 16:33:55 +02001170 .patch = patch_vt1708B},
Takashi Iwai3218c172008-12-18 09:17:56 +01001171 { .id = 0x1106e721, .name = "VT1708B 8-Ch",
Takashi Iwaiddd304d2011-06-21 16:33:55 +02001172 .patch = patch_vt1708B},
Takashi Iwai3218c172008-12-18 09:17:56 +01001173 { .id = 0x1106e722, .name = "VT1708B 8-Ch",
Takashi Iwaiddd304d2011-06-21 16:33:55 +02001174 .patch = patch_vt1708B},
Takashi Iwai3218c172008-12-18 09:17:56 +01001175 { .id = 0x1106e723, .name = "VT1708B 8-Ch",
Takashi Iwaiddd304d2011-06-21 16:33:55 +02001176 .patch = patch_vt1708B},
Takashi Iwai3218c172008-12-18 09:17:56 +01001177 { .id = 0x1106e724, .name = "VT1708B 4-Ch",
Takashi Iwaiddd304d2011-06-21 16:33:55 +02001178 .patch = patch_vt1708B},
Takashi Iwai3218c172008-12-18 09:17:56 +01001179 { .id = 0x1106e725, .name = "VT1708B 4-Ch",
Takashi Iwaiddd304d2011-06-21 16:33:55 +02001180 .patch = patch_vt1708B},
Takashi Iwai3218c172008-12-18 09:17:56 +01001181 { .id = 0x1106e726, .name = "VT1708B 4-Ch",
Takashi Iwaiddd304d2011-06-21 16:33:55 +02001182 .patch = patch_vt1708B},
Takashi Iwai3218c172008-12-18 09:17:56 +01001183 { .id = 0x1106e727, .name = "VT1708B 4-Ch",
Takashi Iwaiddd304d2011-06-21 16:33:55 +02001184 .patch = patch_vt1708B},
Takashi Iwai3218c172008-12-18 09:17:56 +01001185 { .id = 0x11060397, .name = "VT1708S",
Harald Welted949cac2008-09-09 15:56:01 +08001186 .patch = patch_vt1708S},
Takashi Iwai3218c172008-12-18 09:17:56 +01001187 { .id = 0x11061397, .name = "VT1708S",
Harald Welted949cac2008-09-09 15:56:01 +08001188 .patch = patch_vt1708S},
Takashi Iwai3218c172008-12-18 09:17:56 +01001189 { .id = 0x11062397, .name = "VT1708S",
Harald Welted949cac2008-09-09 15:56:01 +08001190 .patch = patch_vt1708S},
Takashi Iwai3218c172008-12-18 09:17:56 +01001191 { .id = 0x11063397, .name = "VT1708S",
Harald Welted949cac2008-09-09 15:56:01 +08001192 .patch = patch_vt1708S},
Lydia Wangbc92df72011-03-23 17:56:05 +08001193 { .id = 0x11064397, .name = "VT1705",
Harald Welted949cac2008-09-09 15:56:01 +08001194 .patch = patch_vt1708S},
Takashi Iwai3218c172008-12-18 09:17:56 +01001195 { .id = 0x11065397, .name = "VT1708S",
Harald Welted949cac2008-09-09 15:56:01 +08001196 .patch = patch_vt1708S},
Takashi Iwai3218c172008-12-18 09:17:56 +01001197 { .id = 0x11066397, .name = "VT1708S",
Harald Welted949cac2008-09-09 15:56:01 +08001198 .patch = patch_vt1708S},
Takashi Iwai3218c172008-12-18 09:17:56 +01001199 { .id = 0x11067397, .name = "VT1708S",
Harald Welted949cac2008-09-09 15:56:01 +08001200 .patch = patch_vt1708S},
Takashi Iwai3218c172008-12-18 09:17:56 +01001201 { .id = 0x11060398, .name = "VT1702",
Harald Welted949cac2008-09-09 15:56:01 +08001202 .patch = patch_vt1702},
Takashi Iwai3218c172008-12-18 09:17:56 +01001203 { .id = 0x11061398, .name = "VT1702",
Harald Welted949cac2008-09-09 15:56:01 +08001204 .patch = patch_vt1702},
Takashi Iwai3218c172008-12-18 09:17:56 +01001205 { .id = 0x11062398, .name = "VT1702",
Harald Welted949cac2008-09-09 15:56:01 +08001206 .patch = patch_vt1702},
Takashi Iwai3218c172008-12-18 09:17:56 +01001207 { .id = 0x11063398, .name = "VT1702",
Harald Welted949cac2008-09-09 15:56:01 +08001208 .patch = patch_vt1702},
Takashi Iwai3218c172008-12-18 09:17:56 +01001209 { .id = 0x11064398, .name = "VT1702",
Harald Welted949cac2008-09-09 15:56:01 +08001210 .patch = patch_vt1702},
Takashi Iwai3218c172008-12-18 09:17:56 +01001211 { .id = 0x11065398, .name = "VT1702",
Harald Welted949cac2008-09-09 15:56:01 +08001212 .patch = patch_vt1702},
Takashi Iwai3218c172008-12-18 09:17:56 +01001213 { .id = 0x11066398, .name = "VT1702",
Harald Welted949cac2008-09-09 15:56:01 +08001214 .patch = patch_vt1702},
Takashi Iwai3218c172008-12-18 09:17:56 +01001215 { .id = 0x11067398, .name = "VT1702",
Harald Welted949cac2008-09-09 15:56:01 +08001216 .patch = patch_vt1702},
Lydia Wangeb7188c2009-10-10 19:08:34 +08001217 { .id = 0x11060428, .name = "VT1718S",
1218 .patch = patch_vt1718S},
1219 { .id = 0x11064428, .name = "VT1718S",
1220 .patch = patch_vt1718S},
Lydia Wangbb3c6bfc2009-10-10 19:08:39 +08001221 { .id = 0x11060441, .name = "VT2020",
1222 .patch = patch_vt1718S},
1223 { .id = 0x11064441, .name = "VT1828S",
1224 .patch = patch_vt1718S},
Lydia Wangf3db4232009-10-10 19:08:41 +08001225 { .id = 0x11060433, .name = "VT1716S",
1226 .patch = patch_vt1716S},
1227 { .id = 0x1106a721, .name = "VT1716S",
1228 .patch = patch_vt1716S},
Lydia Wang25eaba22009-10-10 19:08:43 +08001229 { .id = 0x11060438, .name = "VT2002P", .patch = patch_vt2002P},
1230 { .id = 0x11064438, .name = "VT2002P", .patch = patch_vt2002P},
Lydia Wangab6734e2009-10-10 19:08:46 +08001231 { .id = 0x11060448, .name = "VT1812", .patch = patch_vt1812},
Lydia Wang36dd5c42009-10-20 13:18:04 +08001232 { .id = 0x11060440, .name = "VT1818S",
1233 .patch = patch_vt1708S},
Lydia Wang118909562011-03-23 17:57:34 +08001234 { .id = 0x11060446, .name = "VT1802",
1235 .patch = patch_vt2002P},
1236 { .id = 0x11068446, .name = "VT1802",
1237 .patch = patch_vt2002P},
Lydia Wang43737e02012-12-10 18:28:11 +08001238 { .id = 0x11064760, .name = "VT1705CF",
1239 .patch = patch_vt3476},
Lydia Wang6121b842012-12-10 19:03:26 +08001240 { .id = 0x11064761, .name = "VT1708SCE",
1241 .patch = patch_vt3476},
1242 { .id = 0x11064762, .name = "VT1808",
1243 .patch = patch_vt3476},
Joseph Chanc577b8a2006-11-29 15:29:40 +01001244 {} /* terminator */
1245};
Takashi Iwai1289e9e2008-11-27 15:47:11 +01001246
1247MODULE_ALIAS("snd-hda-codec-id:1106*");
1248
Takashi Iwaid8a766a2015-02-17 15:25:37 +01001249static struct hda_codec_driver via_driver = {
Takashi Iwai1289e9e2008-11-27 15:47:11 +01001250 .preset = snd_hda_preset_via,
Takashi Iwai1289e9e2008-11-27 15:47:11 +01001251};
1252
1253MODULE_LICENSE("GPL");
1254MODULE_DESCRIPTION("VIA HD-audio codec");
1255
Takashi Iwaid8a766a2015-02-17 15:25:37 +01001256module_hda_codec_driver(via_driver);