patch_via.c 31.8 KB
Newer Older
1 2 3
/*
 * Universal Interface for Intel High Definition Audio Codec
 *
4
 * HD audio interface patch for VIA VT17xx/VT18xx/VT20xx codec
5
 *
6 7
 *  (C) 2006-2009 VIA Technology, Inc.
 *  (C) 2006-2008 Takashi Iwai <tiwai@suse.de>
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 *
 *  This driver is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This driver is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 */

/* * * * * * * * * * * * * * Release History * * * * * * * * * * * * * * * * */
L
Lydia Wang 已提交
25
/*									     */
26
/* 2006-03-03  Lydia Wang  Create the basic patch to support VT1708 codec    */
L
Lydia Wang 已提交
27 28
/* 2006-03-14  Lydia Wang  Modify hard code for some pin widget nid	     */
/* 2006-08-02  Lydia Wang  Add support to VT1709 codec			     */
29
/* 2006-09-08  Lydia Wang  Fix internal loopback recording source select bug */
L
Lydia Wang 已提交
30 31
/* 2007-09-12  Lydia Wang  Add EAPD enable during driver initialization	     */
/* 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 */
L
Lydia Wang 已提交
34 35 36
/* 2008-03-06  Lydia Wang  Add VT1702 codec and VT1708S codec support	     */
/* 2008-04-09  Lydia Wang  Add mute front speaker when HP plugin	     */
/* 2008-04-09  Lydia Wang  Add Independent HP feature			     */
37
/* 2008-05-28  Lydia Wang  Add second S/PDIF Out support for VT1702	     */
L
Lydia Wang 已提交
38
/* 2008-09-15  Logan Li	   Add VT1708S Mic Boost workaround/backdoor	     */
39 40 41 42 43
/* 2009-02-16  Logan Li	   Add support for VT1718S			     */
/* 2009-03-13  Logan Li	   Add support for VT1716S			     */
/* 2009-04-14  Lydai Wang  Add support for VT1828S and VT2020		     */
/* 2009-07-08  Lydia Wang  Add support for VT2002P			     */
/* 2009-07-21  Lydia Wang  Add support for VT1812			     */
44
/* 2009-09-19  Lydia Wang  Add support for VT1818S			     */
L
Lydia Wang 已提交
45
/*									     */
46 47 48 49 50 51
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */


#include <linux/init.h>
#include <linux/delay.h>
#include <linux/slab.h>
52
#include <linux/module.h>
53
#include <sound/core.h>
54
#include <sound/asoundef.h>
55 56
#include "hda_codec.h"
#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 63
#define VT1708_HP_PIN_NID	0x20
#define VT1708_CD_PIN_NID	0x24
64

65 66 67 68 69 70 71 72
enum VIA_HDA_CODEC {
	UNKNOWN = -1,
	VT1708,
	VT1709_10CH,
	VT1709_6CH,
	VT1708B_8CH,
	VT1708B_4CH,
	VT1708S,
73
	VT1708BCE,
74
	VT1702,
L
Lydia Wang 已提交
75
	VT1718S,
L
Lydia Wang 已提交
76
	VT1716S,
L
Lydia Wang 已提交
77
	VT2002P,
L
Lydia Wang 已提交
78
	VT1812,
79
	VT1802,
80
	VT1705CF,
81
	VT1808,
82 83 84
	CODEC_TYPES,
};

85 86 87 88 89
#define VT2002P_COMPATIBLE(spec) \
	((spec)->codec_type == VT2002P ||\
	 (spec)->codec_type == VT1812 ||\
	 (spec)->codec_type == VT1802)

90
struct via_spec {
91 92
	struct hda_gen_spec gen;

93
	/* codec parameterization */
94
	const struct snd_kcontrol_new *mixers[6];
95 96
	unsigned int num_mixers;

97
	const struct hda_verb *init_verbs[5];
98 99 100
	unsigned int num_iverbs;

	/* HP mode source */
L
Lydia Wang 已提交
101
	unsigned int dmic_enabled;
102 103
	enum VIA_HDA_CODEC codec_type;

104 105 106
	/* analog low-power control */
	bool alc_mode;

107
	/* work to check hp jack state */
108
	int hp_work_active;
109
	int vt1708_jack_detect;
110 111
};

112
static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec);
113 114 115 116 117 118
static void via_playback_pcm_hook(struct hda_pcm_stream *hinfo,
				  struct hda_codec *codec,
				  struct snd_pcm_substream *substream,
				  int action);

static struct via_spec *via_new_spec(struct hda_codec *codec)
119 120 121 122 123 124 125 126
{
	struct via_spec *spec;

	spec = kzalloc(sizeof(*spec), GFP_KERNEL);
	if (spec == NULL)
		return NULL;

	codec->spec = spec;
127
	snd_hda_gen_spec_init(&spec->gen);
128 129 130 131
	spec->codec_type = get_codec_type(codec);
	/* VT1708BCE & VT1708S are almost same */
	if (spec->codec_type == VT1708BCE)
		spec->codec_type = VT1708S;
132
	spec->gen.indep_hp = 1;
133
	spec->gen.keep_eapd_on = 1;
134
	spec->gen.pcm_playback_hook = via_playback_pcm_hook;
135
	spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO;
136 137
	codec->power_mgmt = 1;
	spec->gen.power_down_unused = 1;
138 139 140
	return spec;
}

141
static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec)
142
{
143
	u32 vendor_id = codec->vendor_id;
144 145 146 147 148 149 150 151 152 153 154 155 156
	u16 ven_id = vendor_id >> 16;
	u16 dev_id = vendor_id & 0xffff;
	enum VIA_HDA_CODEC codec_type;

	/* get codec type */
	if (ven_id != 0x1106)
		codec_type = UNKNOWN;
	else if (dev_id >= 0x1708 && dev_id <= 0x170b)
		codec_type = VT1708;
	else if (dev_id >= 0xe710 && dev_id <= 0xe713)
		codec_type = VT1709_10CH;
	else if (dev_id >= 0xe714 && dev_id <= 0xe717)
		codec_type = VT1709_6CH;
157
	else if (dev_id >= 0xe720 && dev_id <= 0xe723) {
158
		codec_type = VT1708B_8CH;
159 160 161
		if (snd_hda_param_read(codec, 0x16, AC_PAR_CONNLIST_LEN) == 0x7)
			codec_type = VT1708BCE;
	} else if (dev_id >= 0xe724 && dev_id <= 0xe727)
162 163 164 165 166 167 168
		codec_type = VT1708B_4CH;
	else if ((dev_id & 0xfff) == 0x397
		 && (dev_id >> 12) < 8)
		codec_type = VT1708S;
	else if ((dev_id & 0xfff) == 0x398
		 && (dev_id >> 12) < 8)
		codec_type = VT1702;
L
Lydia Wang 已提交
169 170 171
	else if ((dev_id & 0xfff) == 0x428
		 && (dev_id >> 12) < 8)
		codec_type = VT1718S;
L
Lydia Wang 已提交
172 173
	else if (dev_id == 0x0433 || dev_id == 0xa721)
		codec_type = VT1716S;
174 175
	else if (dev_id == 0x0441 || dev_id == 0x4441)
		codec_type = VT1718S;
L
Lydia Wang 已提交
176 177
	else if (dev_id == 0x0438 || dev_id == 0x4438)
		codec_type = VT2002P;
L
Lydia Wang 已提交
178 179
	else if (dev_id == 0x0448)
		codec_type = VT1812;
180 181
	else if (dev_id == 0x0440)
		codec_type = VT1708S;
182 183
	else if ((dev_id & 0xfff) == 0x446)
		codec_type = VT1802;
184 185
	else if (dev_id == 0x4760)
		codec_type = VT1705CF;
186 187
	else if (dev_id == 0x4761 || dev_id == 0x4762)
		codec_type = VT1808;
188 189 190 191 192
	else
		codec_type = UNKNOWN;
	return codec_type;
};

193 194
static void analog_low_current_mode(struct hda_codec *codec);
static bool is_aa_path_mute(struct hda_codec *codec);
195

196 197 198 199
#define hp_detect_with_aa(codec) \
	(snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") == 1 && \
	 !is_aa_path_mute(codec))

200
static void vt1708_stop_hp_work(struct hda_codec *codec)
201
{
202 203
	struct via_spec *spec = codec->spec;
	if (spec->codec_type != VT1708 || !spec->gen.autocfg.hp_outs)
204
		return;
205
	if (spec->hp_work_active) {
206
		snd_hda_codec_write(codec, 0x1, 0, 0xf81, 1);
207
		codec->jackpoll_interval = 0;
208 209
		cancel_delayed_work_sync(&codec->jackpoll_work);
		spec->hp_work_active = false;
210
	}
211 212
}

213
static void vt1708_update_hp_work(struct hda_codec *codec)
214
{
215 216
	struct via_spec *spec = codec->spec;
	if (spec->codec_type != VT1708 || !spec->gen.autocfg.hp_outs)
217
		return;
218
	if (spec->vt1708_jack_detect) {
219
		if (!spec->hp_work_active) {
220 221
			codec->jackpoll_interval = msecs_to_jiffies(100);
			snd_hda_codec_write(codec, 0x1, 0, 0xf81, 0);
222
			schedule_delayed_work(&codec->jackpoll_work, 0);
223
			spec->hp_work_active = true;
224
		}
225 226
	} else if (!hp_detect_with_aa(codec))
		vt1708_stop_hp_work(codec);
227
}
228

229 230 231
static int via_pin_power_ctl_info(struct snd_kcontrol *kcontrol,
				  struct snd_ctl_elem_info *uinfo)
{
232
	return snd_hda_enum_bool_helper_info(kcontrol, uinfo);
233 234 235 236 237 238
}

static int via_pin_power_ctl_get(struct snd_kcontrol *kcontrol,
				 struct snd_ctl_elem_value *ucontrol)
{
	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
239
	ucontrol->value.enumerated.item[0] = codec->power_mgmt;
240 241 242 243 244 245 246 247
	return 0;
}

static int via_pin_power_ctl_put(struct snd_kcontrol *kcontrol,
				 struct snd_ctl_elem_value *ucontrol)
{
	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
	struct via_spec *spec = codec->spec;
248
	bool val = !!ucontrol->value.enumerated.item[0];
249

250
	if (val == codec->power_mgmt)
251
		return 0;
252 253
	codec->power_mgmt = val;
	spec->gen.power_down_unused = val;
254
	analog_low_current_mode(codec);
255 256 257
	return 1;
}

258 259
static const struct snd_kcontrol_new via_pin_power_ctl_enum[] = {
	{
260 261 262 263 264
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Dynamic Power-Control",
	.info = via_pin_power_ctl_info,
	.get = via_pin_power_ctl_get,
	.put = via_pin_power_ctl_put,
265 266
	},
	{} /* terminator */
267 268 269
};


270 271
/* check AA path's mute status */
static bool is_aa_path_mute(struct hda_codec *codec)
272
{
273
	struct via_spec *spec = codec->spec;
274
	const struct hda_amp_list *p;
275
	int ch, v;
276

277 278 279 280
	p = spec->gen.loopback.amplist;
	if (!p)
		return true;
	for (; p->nid; p++) {
281 282 283 284 285 286
		for (ch = 0; ch < 2; ch++) {
			v = snd_hda_codec_amp_read(codec, p->nid, ch, p->dir,
						   p->idx);
			if (!(v & HDA_AMP_MUTE) && v > 0)
				return false;
		}
287
	}
288
	return true;
289 290
}

291 292
/* enter/exit analog low-current mode */
static void __analog_low_current_mode(struct hda_codec *codec, bool force)
293 294
{
	struct via_spec *spec = codec->spec;
295 296
	bool enable;
	unsigned int verb, parm;
297

298
	if (!codec->power_mgmt)
299 300 301 302
		enable = false;
	else
		enable = is_aa_path_mute(codec) && !spec->gen.active_streams;
	if (enable == spec->alc_mode && !force)
303
		return;
304
	spec->alc_mode = enable;
305

306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
	/* decide low current mode's verb & parameter */
	switch (spec->codec_type) {
	case VT1708B_8CH:
	case VT1708B_4CH:
		verb = 0xf70;
		parm = enable ? 0x02 : 0x00; /* 0x02: 2/3x, 0x00: 1x */
		break;
	case VT1708S:
	case VT1718S:
	case VT1716S:
		verb = 0xf73;
		parm = enable ? 0x51 : 0xe1; /* 0x51: 4/28x, 0xe1: 1x */
		break;
	case VT1702:
		verb = 0xf73;
		parm = enable ? 0x01 : 0x1d; /* 0x01: 4/40x, 0x1d: 1x */
		break;
	case VT2002P:
	case VT1812:
	case VT1802:
		verb = 0xf93;
		parm = enable ? 0x00 : 0xe0; /* 0x00: 4/40x, 0xe0: 1x */
		break;
	case VT1705CF:
	case VT1808:
		verb = 0xf82;
		parm = enable ? 0x00 : 0xe0;  /* 0x00: 4/40x, 0xe0: 1x */
		break;
	default:
		return;		/* other codecs are not supported */
336 337
	}
	/* send verb */
338
	snd_hda_codec_write(codec, codec->afg, 0, verb, parm);
339 340
}

341 342 343 344
static void analog_low_current_mode(struct hda_codec *codec)
{
	return __analog_low_current_mode(codec, false);
}
345

346
static int via_build_controls(struct hda_codec *codec)
347 348
{
	struct via_spec *spec = codec->spec;
349
	int err, i;
350

351
	err = snd_hda_gen_build_controls(codec);
352 353
	if (err < 0)
		return err;
354

355
	spec->mixers[spec->num_mixers++] = via_pin_power_ctl_enum;
356

357 358 359 360 361
	for (i = 0; i < spec->num_mixers; i++) {
		err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
		if (err < 0)
			return err;
	}
362 363 364 365

	return 0;
}

366 367 368 369
static void via_playback_pcm_hook(struct hda_pcm_stream *hinfo,
				  struct hda_codec *codec,
				  struct snd_pcm_substream *substream,
				  int action)
370
{
371 372
	analog_low_current_mode(codec);
	vt1708_update_hp_work(codec);
373 374
}

375
static void via_free(struct hda_codec *codec)
376
{
377
	vt1708_stop_hp_work(codec);
378
	snd_hda_gen_free(codec);
379 380
}

381 382
#ifdef CONFIG_PM
static int via_suspend(struct hda_codec *codec)
383 384
{
	struct via_spec *spec = codec->spec;
385
	vt1708_stop_hp_work(codec);
386

387 388 389
	/* Fix pop noise on headphones */
	if (spec->codec_type == VT1802)
		snd_hda_shutup_pins(codec);
390

391 392
	return 0;
}
393
#endif
394

395 396
#ifdef CONFIG_PM
static int via_check_power_status(struct hda_codec *codec, hda_nid_t nid)
397 398
{
	struct via_spec *spec = codec->spec;
399 400 401 402 403
	analog_low_current_mode(codec);
	vt1708_update_hp_work(codec);
	return snd_hda_check_amp_list_power(codec, &spec->gen.loopback, nid);
}
#endif
404

405 406
/*
 */
407

408
static int via_init(struct hda_codec *codec);
409

410 411 412 413 414 415 416 417 418 419 420
static const struct hda_codec_ops via_patch_ops = {
	.build_controls = via_build_controls,
	.build_pcms = snd_hda_gen_build_pcms,
	.init = via_init,
	.free = via_free,
	.unsol_event = snd_hda_jack_unsol_event,
#ifdef CONFIG_PM
	.suspend = via_suspend,
	.check_power_status = via_check_power_status,
#endif
};
421

422

423 424 425 426 427
static const struct hda_verb vt1708_init_verbs[] = {
	/* power down jack detect function */
	{0x1, 0xf81, 0x1},
	{ }
};
428 429 430 431 432
static void vt1708_set_pinconfig_connect(struct hda_codec *codec, hda_nid_t nid)
{
	unsigned int def_conf;
	unsigned char seqassoc;

433
	def_conf = snd_hda_codec_get_pincfg(codec, nid);
434 435
	seqassoc = (unsigned char) get_defcfg_association(def_conf);
	seqassoc = (seqassoc << 4) | get_defcfg_sequence(def_conf);
436 437 438 439
	if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE
	    && (seqassoc == 0xf0 || seqassoc == 0xff)) {
		def_conf = def_conf & (~(AC_JACK_PORT_BOTH << 30));
		snd_hda_codec_set_pincfg(codec, nid, def_conf);
440 441 442 443 444
	}

	return;
}

445
static int vt1708_jack_detect_get(struct snd_kcontrol *kcontrol,
446 447 448 449 450 451 452
				     struct snd_ctl_elem_value *ucontrol)
{
	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
	struct via_spec *spec = codec->spec;

	if (spec->codec_type != VT1708)
		return 0;
453
	ucontrol->value.integer.value[0] = spec->vt1708_jack_detect;
454 455 456
	return 0;
}

457
static int vt1708_jack_detect_put(struct snd_kcontrol *kcontrol,
458 459 460 461
				     struct snd_ctl_elem_value *ucontrol)
{
	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
	struct via_spec *spec = codec->spec;
462
	int val;
463 464 465

	if (spec->codec_type != VT1708)
		return 0;
466 467 468 469
	val = !!ucontrol->value.integer.value[0];
	if (spec->vt1708_jack_detect == val)
		return 0;
	spec->vt1708_jack_detect = val;
470
	vt1708_update_hp_work(codec);
471
	return 1;
472 473
}

474 475
static const struct snd_kcontrol_new vt1708_jack_detect_ctl[] = {
	{
476 477 478 479 480 481
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Jack Detect",
	.count = 1,
	.info = snd_ctl_boolean_mono_info,
	.get = vt1708_jack_detect_get,
	.put = vt1708_jack_detect_put,
482 483
	},
	{} /* terminator */
484 485
};

486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502
static const struct badness_table via_main_out_badness = {
	.no_primary_dac = 0x10000,
	.no_dac = 0x4000,
	.shared_primary = 0x10000,
	.shared_surr = 0x20,
	.shared_clfe = 0x20,
	.shared_surr_main = 0x20,
};
static const struct badness_table via_extra_out_badness = {
	.no_primary_dac = 0x4000,
	.no_dac = 0x4000,
	.shared_primary = 0x12,
	.shared_surr = 0x20,
	.shared_clfe = 0x20,
	.shared_surr_main = 0x10,
};

503 504 505 506 507
static int via_parse_auto_config(struct hda_codec *codec)
{
	struct via_spec *spec = codec->spec;
	int err;

508 509 510
	spec->gen.main_out_badness = &via_main_out_badness;
	spec->gen.extra_out_badness = &via_extra_out_badness;

511 512 513 514 515 516 517 518
	err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0);
	if (err < 0)
		return err;

	err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
	if (err < 0)
		return err;

519 520 521
	/* disable widget PM at start for compatibility */
	codec->power_mgmt = 0;
	spec->gen.power_down_unused = 0;
522 523 524
	return 0;
}

525 526 527 528 529 530 531
static int via_init(struct hda_codec *codec)
{
	struct via_spec *spec = codec->spec;
	int i;

	for (i = 0; i < spec->num_iverbs; i++)
		snd_hda_sequence_write(codec, spec->init_verbs[i]);
L
Lydia Wang 已提交
532

533 534 535
	/* init power states */
	__analog_low_current_mode(codec, true);

536
	snd_hda_gen_init(codec);
537

538
	vt1708_update_hp_work(codec);
L
Lydia Wang 已提交
539

540 541 542
	return 0;
}

543 544 545 546 547 548 549 550 551 552 553 554
static int vt1708_build_controls(struct hda_codec *codec)
{
	/* In order not to create "Phantom Jack" controls,
	   temporary enable jackpoll */
	int err;
	int old_interval = codec->jackpoll_interval;
	codec->jackpoll_interval = msecs_to_jiffies(100);
	err = via_build_controls(codec);
	codec->jackpoll_interval = old_interval;
	return err;
}

555
static int vt1708_build_pcms(struct hda_codec *codec)
556 557
{
	struct via_spec *spec = codec->spec;
558 559 560 561 562 563 564 565 566 567
	int i, err;

	err = snd_hda_gen_build_pcms(codec);
	if (err < 0 || codec->vendor_id != 0x11061708)
		return err;

	/* We got noisy outputs on the right channel on VT1708 when
	 * 24bit samples are used.  Until any workaround is found,
	 * disable the 24bit format, so far.
	 */
568 569 570 571
	for (i = 0; i < ARRAY_SIZE(spec->gen.pcm_rec); i++) {
		struct hda_pcm *info = spec->gen.pcm_rec[i];
		if (!info)
			continue;
572 573 574 575 576
		if (!info->stream[SNDRV_PCM_STREAM_PLAYBACK].substreams ||
		    info->pcm_type != HDA_PCM_TYPE_AUDIO)
			continue;
		info->stream[SNDRV_PCM_STREAM_PLAYBACK].formats =
			SNDRV_PCM_FMTBIT_S16_LE;
577
	}
578

579
	return 0;
580 581
}

582 583 584 585 586 587
static int patch_vt1708(struct hda_codec *codec)
{
	struct via_spec *spec;
	int err;

	/* create a codec specific record */
588
	spec = via_new_spec(codec);
589 590 591
	if (spec == NULL)
		return -ENOMEM;

592 593 594 595 596 597 598 599 600
	spec->gen.mixer_nid = 0x17;

	/* set jackpoll_interval while parsing the codec */
	codec->jackpoll_interval = msecs_to_jiffies(100);
	spec->vt1708_jack_detect = 1;

	/* don't support the input jack switching due to lack of unsol event */
	/* (it may work with polling, though, but it needs testing) */
	spec->gen.suppress_auto_mic = 1;
601 602
	/* Some machines show the broken speaker mute */
	spec->gen.auto_mute_via_amp = 1;
603

604 605 606 607
	/* Add HP and CD pin config connect bit re-config action */
	vt1708_set_pinconfig_connect(codec, VT1708_HP_PIN_NID);
	vt1708_set_pinconfig_connect(codec, VT1708_CD_PIN_NID);

608
	/* automatic parse from the BIOS config */
609
	err = via_parse_auto_config(codec);
610 611 612 613 614
	if (err < 0) {
		via_free(codec);
		return err;
	}

615
	/* add jack detect on/off control */
616
	spec->mixers[spec->num_mixers++] = vt1708_jack_detect_ctl;
617

618 619
	spec->init_verbs[spec->num_iverbs++] = vt1708_init_verbs;

620
	codec->patch_ops = via_patch_ops;
621
	codec->patch_ops.build_controls = vt1708_build_controls;
622 623 624 625
	codec->patch_ops.build_pcms = vt1708_build_pcms;

	/* clear jackpoll_interval again; it's set dynamically */
	codec->jackpoll_interval = 0;
626 627 628 629

	return 0;
}

630
static int patch_vt1709(struct hda_codec *codec)
631 632 633 634 635
{
	struct via_spec *spec;
	int err;

	/* create a codec specific record */
636
	spec = via_new_spec(codec);
637 638 639
	if (spec == NULL)
		return -ENOMEM;

640
	spec->gen.mixer_nid = 0x18;
641

642
	err = via_parse_auto_config(codec);
643 644 645 646 647 648 649
	if (err < 0) {
		via_free(codec);
		return err;
	}

	codec->patch_ops = via_patch_ops;

650 651 652
	return 0;
}

653
static int patch_vt1708S(struct hda_codec *codec);
654
static int patch_vt1708B(struct hda_codec *codec)
655 656 657 658
{
	struct via_spec *spec;
	int err;

659 660
	if (get_codec_type(codec) == VT1708BCE)
		return patch_vt1708S(codec);
661

662
	/* create a codec specific record */
663
	spec = via_new_spec(codec);
664 665 666
	if (spec == NULL)
		return -ENOMEM;

667
	spec->gen.mixer_nid = 0x16;
668

669
	/* automatic parse from the BIOS config */
670
	err = via_parse_auto_config(codec);
671 672 673 674 675 676 677 678 679
	if (err < 0) {
		via_free(codec);
		return err;
	}

	codec->patch_ops = via_patch_ops;
	return 0;
}

680
/* Patch for VT1708S */
681
static const struct hda_verb vt1708S_init_verbs[] = {
682 683
	/* Enable Mic Boost Volume backdoor */
	{0x1, 0xf98, 0x1},
684 685
	/* don't bybass mixer */
	{0x1, 0xf88, 0xc0},
686 687 688
	{ }
};

689 690 691
static void override_mic_boost(struct hda_codec *codec, hda_nid_t pin,
			       int offset, int num_steps, int step_size)
{
692 693
	snd_hda_override_wcaps(codec, pin,
			       get_wcaps(codec, pin) | AC_WCAP_IN_AMP);
694 695 696 697 698 699 700
	snd_hda_override_amp_caps(codec, pin, HDA_INPUT,
				  (offset << AC_AMPCAP_OFFSET_SHIFT) |
				  (num_steps << AC_AMPCAP_NUM_STEPS_SHIFT) |
				  (step_size << AC_AMPCAP_STEP_SIZE_SHIFT) |
				  (0 << AC_AMPCAP_MUTE_SHIFT));
}

701 702 703 704 705 706
static int patch_vt1708S(struct hda_codec *codec)
{
	struct via_spec *spec;
	int err;

	/* create a codec specific record */
707
	spec = via_new_spec(codec);
708 709 710
	if (spec == NULL)
		return -ENOMEM;

711
	spec->gen.mixer_nid = 0x16;
712 713
	override_mic_boost(codec, 0x1a, 0, 3, 40);
	override_mic_boost(codec, 0x1e, 0, 3, 40);
714

715 716 717 718
	/* correct names for VT1708BCE */
	if (get_codec_type(codec) == VT1708BCE)	{
		kfree(codec->chip_name);
		codec->chip_name = kstrdup("VT1708BCE", GFP_KERNEL);
719 720
		snprintf(codec->card->mixername,
			 sizeof(codec->card->mixername),
721
			 "%s %s", codec->vendor_name, codec->chip_name);
722
	}
723 724 725 726
	/* correct names for VT1705 */
	if (codec->vendor_id == 0x11064397)	{
		kfree(codec->chip_name);
		codec->chip_name = kstrdup("VT1705", GFP_KERNEL);
727 728
		snprintf(codec->card->mixername,
			 sizeof(codec->card->mixername),
729 730
			 "%s %s", codec->vendor_name, codec->chip_name);
	}
731 732 733 734 735 736 737 738 739 740 741

	/* automatic parse from the BIOS config */
	err = via_parse_auto_config(codec);
	if (err < 0) {
		via_free(codec);
		return err;
	}

	spec->init_verbs[spec->num_iverbs++] = vt1708S_init_verbs;

	codec->patch_ops = via_patch_ops;
742 743 744 745 746
	return 0;
}

/* Patch for VT1702 */

747
static const struct hda_verb vt1702_init_verbs[] = {
748 749 750 751
	/* mixer enable */
	{0x1, 0xF88, 0x3},
	/* GPIO 0~2 */
	{0x1, 0xF82, 0x3F},
752 753 754 755 756 757 758 759 760
	{ }
};

static int patch_vt1702(struct hda_codec *codec)
{
	struct via_spec *spec;
	int err;

	/* create a codec specific record */
761
	spec = via_new_spec(codec);
762 763 764
	if (spec == NULL)
		return -ENOMEM;

765
	spec->gen.mixer_nid = 0x1a;
766

767 768 769 770 771 772 773
	/* limit AA path volume to 0 dB */
	snd_hda_override_amp_caps(codec, 0x1A, HDA_INPUT,
				  (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
				  (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
				  (0x5 << AC_AMPCAP_STEP_SIZE_SHIFT) |
				  (1 << AC_AMPCAP_MUTE_SHIFT));

774
	/* automatic parse from the BIOS config */
775
	err = via_parse_auto_config(codec);
776 777 778 779 780
	if (err < 0) {
		via_free(codec);
		return err;
	}

781
	spec->init_verbs[spec->num_iverbs++] = vt1702_init_verbs;
782 783 784 785 786

	codec->patch_ops = via_patch_ops;
	return 0;
}

L
Lydia Wang 已提交
787 788
/* Patch for VT1718S */

789
static const struct hda_verb vt1718S_init_verbs[] = {
790 791
	/* Enable MW0 adjust Gain 5 */
	{0x1, 0xfb2, 0x10},
L
Lydia Wang 已提交
792 793
	/* Enable Boost Volume backdoor */
	{0x1, 0xf88, 0x8},
794

L
Lydia Wang 已提交
795 796 797
	{ }
};

798 799 800 801 802 803 804 805 806 807
/* Add a connection to the primary DAC from AA-mixer for some codecs
 * This isn't listed from the raw info, but the chip has a secret connection.
 */
static int add_secret_dac_path(struct hda_codec *codec)
{
	struct via_spec *spec = codec->spec;
	int i, nums;
	hda_nid_t conn[8];
	hda_nid_t nid;

808
	if (!spec->gen.mixer_nid)
809
		return 0;
810
	nums = snd_hda_get_connections(codec, spec->gen.mixer_nid, conn,
811 812 813 814 815 816 817 818 819 820 821 822 823 824
				       ARRAY_SIZE(conn) - 1);
	for (i = 0; i < nums; i++) {
		if (get_wcaps_type(get_wcaps(codec, conn[i])) == AC_WID_AUD_OUT)
			return 0;
	}

	/* find the primary DAC and add to the connection list */
	nid = codec->start_nid;
	for (i = 0; i < codec->num_nodes; i++, nid++) {
		unsigned int caps = get_wcaps(codec, nid);
		if (get_wcaps_type(caps) == AC_WID_AUD_OUT &&
		    !(caps & AC_WCAP_DIGITAL)) {
			conn[nums++] = nid;
			return snd_hda_override_conn_list(codec,
825
							  spec->gen.mixer_nid,
826 827 828 829 830 831 832
							  nums, conn);
		}
	}
	return 0;
}


L
Lydia Wang 已提交
833 834 835 836 837 838
static int patch_vt1718S(struct hda_codec *codec)
{
	struct via_spec *spec;
	int err;

	/* create a codec specific record */
839
	spec = via_new_spec(codec);
L
Lydia Wang 已提交
840 841 842
	if (spec == NULL)
		return -ENOMEM;

843
	spec->gen.mixer_nid = 0x21;
844 845
	override_mic_boost(codec, 0x2b, 0, 3, 40);
	override_mic_boost(codec, 0x29, 0, 3, 40);
846
	add_secret_dac_path(codec);
847

L
Lydia Wang 已提交
848
	/* automatic parse from the BIOS config */
849
	err = via_parse_auto_config(codec);
L
Lydia Wang 已提交
850 851 852 853 854
	if (err < 0) {
		via_free(codec);
		return err;
	}

855
	spec->init_verbs[spec->num_iverbs++] = vt1718S_init_verbs;
L
Lydia Wang 已提交
856 857 858 859

	codec->patch_ops = via_patch_ops;
	return 0;
}
L
Lydia Wang 已提交
860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899

/* Patch for VT1716S */

static int vt1716s_dmic_info(struct snd_kcontrol *kcontrol,
			    struct snd_ctl_elem_info *uinfo)
{
	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
	uinfo->count = 1;
	uinfo->value.integer.min = 0;
	uinfo->value.integer.max = 1;
	return 0;
}

static int vt1716s_dmic_get(struct snd_kcontrol *kcontrol,
			   struct snd_ctl_elem_value *ucontrol)
{
	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
	int index = 0;

	index = snd_hda_codec_read(codec, 0x26, 0,
					       AC_VERB_GET_CONNECT_SEL, 0);
	if (index != -1)
		*ucontrol->value.integer.value = index;

	return 0;
}

static int vt1716s_dmic_put(struct snd_kcontrol *kcontrol,
			   struct snd_ctl_elem_value *ucontrol)
{
	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
	struct via_spec *spec = codec->spec;
	int index = *ucontrol->value.integer.value;

	snd_hda_codec_write(codec, 0x26, 0,
					       AC_VERB_SET_CONNECT_SEL, index);
	spec->dmic_enabled = index;
	return 1;
}

900
static const struct snd_kcontrol_new vt1716s_dmic_mixer[] = {
L
Lydia Wang 已提交
901 902 903 904
	HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x22, 0x0, HDA_INPUT),
	{
	 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	 .name = "Digital Mic Capture Switch",
905
	 .subdevice = HDA_SUBDEV_NID_FLAG | 0x26,
L
Lydia Wang 已提交
906 907 908 909 910 911 912 913 914 915
	 .count = 1,
	 .info = vt1716s_dmic_info,
	 .get = vt1716s_dmic_get,
	 .put = vt1716s_dmic_put,
	 },
	{}			/* end */
};


/* mono-out mixer elements */
916
static const struct snd_kcontrol_new vt1716S_mono_out_mixer[] = {
L
Lydia Wang 已提交
917 918 919 920
	HDA_CODEC_MUTE("Mono Playback Switch", 0x2a, 0x0, HDA_OUTPUT),
	{ } /* end */
};

921
static const struct hda_verb vt1716S_init_verbs[] = {
L
Lydia Wang 已提交
922 923 924 925 926 927 928 929 930 931 932 933 934 935 936
	/* Enable Boost Volume backdoor */
	{0x1, 0xf8a, 0x80},
	/* don't bybass mixer */
	{0x1, 0xf88, 0xc0},
	/* Enable mono output */
	{0x1, 0xf90, 0x08},
	{ }
};

static int patch_vt1716S(struct hda_codec *codec)
{
	struct via_spec *spec;
	int err;

	/* create a codec specific record */
937
	spec = via_new_spec(codec);
L
Lydia Wang 已提交
938 939 940
	if (spec == NULL)
		return -ENOMEM;

941
	spec->gen.mixer_nid = 0x16;
942 943
	override_mic_boost(codec, 0x1a, 0, 3, 40);
	override_mic_boost(codec, 0x1e, 0, 3, 40);
944

L
Lydia Wang 已提交
945
	/* automatic parse from the BIOS config */
946
	err = via_parse_auto_config(codec);
L
Lydia Wang 已提交
947 948 949 950 951
	if (err < 0) {
		via_free(codec);
		return err;
	}

952
	spec->init_verbs[spec->num_iverbs++]  = vt1716S_init_verbs;
L
Lydia Wang 已提交
953

954
	spec->mixers[spec->num_mixers++] = vt1716s_dmic_mixer;
L
Lydia Wang 已提交
955 956 957 958 959
	spec->mixers[spec->num_mixers++] = vt1716S_mono_out_mixer;

	codec->patch_ops = via_patch_ops;
	return 0;
}
L
Lydia Wang 已提交
960 961 962

/* for vt2002P */

963
static const struct hda_verb vt2002P_init_verbs[] = {
964 965 966 967
	/* Class-D speaker related verbs */
	{0x1, 0xfe0, 0x4},
	{0x1, 0xfe9, 0x80},
	{0x1, 0xfe2, 0x22},
L
Lydia Wang 已提交
968 969 970 971 972 973
	/* Enable Boost Volume backdoor */
	{0x1, 0xfb9, 0x24},
	/* Enable AOW0 to MW9 */
	{0x1, 0xfb8, 0x88},
	{ }
};
974

975
static const struct hda_verb vt1802_init_verbs[] = {
976 977 978 979 980 981
	/* Enable Boost Volume backdoor */
	{0x1, 0xfb9, 0x24},
	/* Enable AOW0 to MW9 */
	{0x1, 0xfb8, 0x88},
	{ }
};
L
Lydia Wang 已提交
982

983 984 985 986 987
/*
 * pin fix-up
 */
enum {
	VIA_FIXUP_INTMIC_BOOST,
988
	VIA_FIXUP_ASUS_G75,
989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002
};

static void via_fixup_intmic_boost(struct hda_codec *codec,
				  const struct hda_fixup *fix, int action)
{
	if (action == HDA_FIXUP_ACT_PRE_PROBE)
		override_mic_boost(codec, 0x30, 0, 2, 40);
}

static const struct hda_fixup via_fixups[] = {
	[VIA_FIXUP_INTMIC_BOOST] = {
		.type = HDA_FIXUP_FUNC,
		.v.func = via_fixup_intmic_boost,
	},
1003 1004 1005 1006 1007 1008 1009 1010 1011
	[VIA_FIXUP_ASUS_G75] = {
		.type = HDA_FIXUP_PINS,
		.v.pins = (const struct hda_pintbl[]) {
			/* set 0x24 and 0x33 as speakers */
			{ 0x24, 0x991301f0 },
			{ 0x33, 0x991301f1 }, /* subwoofer */
			{ }
		}
	},
1012 1013 1014
};

static const struct snd_pci_quirk vt2002p_fixups[] = {
1015
	SND_PCI_QUIRK(0x1043, 0x1487, "Asus G75", VIA_FIXUP_ASUS_G75),
1016 1017 1018 1019
	SND_PCI_QUIRK(0x1043, 0x8532, "Asus X202E", VIA_FIXUP_INTMIC_BOOST),
	{}
};

1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031
/* NIDs 0x24 and 0x33 on VT1802 have connections to non-existing NID 0x3e
 * Replace this with mixer NID 0x1c
 */
static void fix_vt1802_connections(struct hda_codec *codec)
{
	static hda_nid_t conn_24[] = { 0x14, 0x1c };
	static hda_nid_t conn_33[] = { 0x1c };

	snd_hda_override_conn_list(codec, 0x24, ARRAY_SIZE(conn_24), conn_24);
	snd_hda_override_conn_list(codec, 0x33, ARRAY_SIZE(conn_33), conn_33);
}

L
Lydia Wang 已提交
1032 1033 1034 1035 1036 1037 1038
/* patch for vt2002P */
static int patch_vt2002P(struct hda_codec *codec)
{
	struct via_spec *spec;
	int err;

	/* create a codec specific record */
1039
	spec = via_new_spec(codec);
L
Lydia Wang 已提交
1040 1041 1042
	if (spec == NULL)
		return -ENOMEM;

1043
	spec->gen.mixer_nid = 0x21;
1044 1045
	override_mic_boost(codec, 0x2b, 0, 3, 40);
	override_mic_boost(codec, 0x29, 0, 3, 40);
1046 1047
	if (spec->codec_type == VT1802)
		fix_vt1802_connections(codec);
1048
	add_secret_dac_path(codec);
1049

1050 1051 1052
	snd_hda_pick_fixup(codec, NULL, vt2002p_fixups, via_fixups);
	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);

L
Lydia Wang 已提交
1053
	/* automatic parse from the BIOS config */
1054
	err = via_parse_auto_config(codec);
L
Lydia Wang 已提交
1055 1056 1057 1058 1059
	if (err < 0) {
		via_free(codec);
		return err;
	}

1060
	if (spec->codec_type == VT1802)
1061
		spec->init_verbs[spec->num_iverbs++] = vt1802_init_verbs;
1062
	else
1063
		spec->init_verbs[spec->num_iverbs++] = vt2002P_init_verbs;
1064

L
Lydia Wang 已提交
1065 1066 1067
	codec->patch_ops = via_patch_ops;
	return 0;
}
L
Lydia Wang 已提交
1068 1069 1070

/* for vt1812 */

1071
static const struct hda_verb vt1812_init_verbs[] = {
L
Lydia Wang 已提交
1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085
	/* Enable Boost Volume backdoor */
	{0x1, 0xfb9, 0x24},
	/* Enable AOW0 to MW9 */
	{0x1, 0xfb8, 0xa8},
	{ }
};

/* patch for vt1812 */
static int patch_vt1812(struct hda_codec *codec)
{
	struct via_spec *spec;
	int err;

	/* create a codec specific record */
1086
	spec = via_new_spec(codec);
L
Lydia Wang 已提交
1087 1088 1089
	if (spec == NULL)
		return -ENOMEM;

1090
	spec->gen.mixer_nid = 0x21;
1091 1092
	override_mic_boost(codec, 0x2b, 0, 3, 40);
	override_mic_boost(codec, 0x29, 0, 3, 40);
1093
	add_secret_dac_path(codec);
1094

L
Lydia Wang 已提交
1095
	/* automatic parse from the BIOS config */
1096
	err = via_parse_auto_config(codec);
L
Lydia Wang 已提交
1097 1098 1099 1100 1101
	if (err < 0) {
		via_free(codec);
		return err;
	}

1102
	spec->init_verbs[spec->num_iverbs++]  = vt1812_init_verbs;
L
Lydia Wang 已提交
1103 1104 1105 1106 1107

	codec->patch_ops = via_patch_ops;
	return 0;
}

1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129
/* patch for vt3476 */

static const struct hda_verb vt3476_init_verbs[] = {
	/* Enable DMic 8/16/32K */
	{0x1, 0xF7B, 0x30},
	/* Enable Boost Volume backdoor */
	{0x1, 0xFB9, 0x20},
	/* Enable AOW-MW9 path */
	{0x1, 0xFB8, 0x10},
	{ }
};

static int patch_vt3476(struct hda_codec *codec)
{
	struct via_spec *spec;
	int err;

	/* create a codec specific record */
	spec = via_new_spec(codec);
	if (spec == NULL)
		return -ENOMEM;

1130
	spec->gen.mixer_nid = 0x3f;
1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145
	add_secret_dac_path(codec);

	/* automatic parse from the BIOS config */
	err = via_parse_auto_config(codec);
	if (err < 0) {
		via_free(codec);
		return err;
	}

	spec->init_verbs[spec->num_iverbs++] = vt3476_init_verbs;

	codec->patch_ops = via_patch_ops;
	return 0;
}

1146 1147 1148
/*
 * patch entries
 */
1149
static const struct hda_codec_preset snd_hda_preset_via[] = {
1150 1151 1152 1153 1154
	{ .id = 0x11061708, .name = "VT1708", .patch = patch_vt1708},
	{ .id = 0x11061709, .name = "VT1708", .patch = patch_vt1708},
	{ .id = 0x1106170a, .name = "VT1708", .patch = patch_vt1708},
	{ .id = 0x1106170b, .name = "VT1708", .patch = patch_vt1708},
	{ .id = 0x1106e710, .name = "VT1709 10-Ch",
1155
	  .patch = patch_vt1709},
1156
	{ .id = 0x1106e711, .name = "VT1709 10-Ch",
1157
	  .patch = patch_vt1709},
1158
	{ .id = 0x1106e712, .name = "VT1709 10-Ch",
1159
	  .patch = patch_vt1709},
1160
	{ .id = 0x1106e713, .name = "VT1709 10-Ch",
1161
	  .patch = patch_vt1709},
1162
	{ .id = 0x1106e714, .name = "VT1709 6-Ch",
1163
	  .patch = patch_vt1709},
1164
	{ .id = 0x1106e715, .name = "VT1709 6-Ch",
1165
	  .patch = patch_vt1709},
1166
	{ .id = 0x1106e716, .name = "VT1709 6-Ch",
1167
	  .patch = patch_vt1709},
1168
	{ .id = 0x1106e717, .name = "VT1709 6-Ch",
1169
	  .patch = patch_vt1709},
1170
	{ .id = 0x1106e720, .name = "VT1708B 8-Ch",
1171
	  .patch = patch_vt1708B},
1172
	{ .id = 0x1106e721, .name = "VT1708B 8-Ch",
1173
	  .patch = patch_vt1708B},
1174
	{ .id = 0x1106e722, .name = "VT1708B 8-Ch",
1175
	  .patch = patch_vt1708B},
1176
	{ .id = 0x1106e723, .name = "VT1708B 8-Ch",
1177
	  .patch = patch_vt1708B},
1178
	{ .id = 0x1106e724, .name = "VT1708B 4-Ch",
1179
	  .patch = patch_vt1708B},
1180
	{ .id = 0x1106e725, .name = "VT1708B 4-Ch",
1181
	  .patch = patch_vt1708B},
1182
	{ .id = 0x1106e726, .name = "VT1708B 4-Ch",
1183
	  .patch = patch_vt1708B},
1184
	{ .id = 0x1106e727, .name = "VT1708B 4-Ch",
1185
	  .patch = patch_vt1708B},
1186
	{ .id = 0x11060397, .name = "VT1708S",
1187
	  .patch = patch_vt1708S},
1188
	{ .id = 0x11061397, .name = "VT1708S",
1189
	  .patch = patch_vt1708S},
1190
	{ .id = 0x11062397, .name = "VT1708S",
1191
	  .patch = patch_vt1708S},
1192
	{ .id = 0x11063397, .name = "VT1708S",
1193
	  .patch = patch_vt1708S},
1194
	{ .id = 0x11064397, .name = "VT1705",
1195
	  .patch = patch_vt1708S},
1196
	{ .id = 0x11065397, .name = "VT1708S",
1197
	  .patch = patch_vt1708S},
1198
	{ .id = 0x11066397, .name = "VT1708S",
1199
	  .patch = patch_vt1708S},
1200
	{ .id = 0x11067397, .name = "VT1708S",
1201
	  .patch = patch_vt1708S},
1202
	{ .id = 0x11060398, .name = "VT1702",
1203
	  .patch = patch_vt1702},
1204
	{ .id = 0x11061398, .name = "VT1702",
1205
	  .patch = patch_vt1702},
1206
	{ .id = 0x11062398, .name = "VT1702",
1207
	  .patch = patch_vt1702},
1208
	{ .id = 0x11063398, .name = "VT1702",
1209
	  .patch = patch_vt1702},
1210
	{ .id = 0x11064398, .name = "VT1702",
1211
	  .patch = patch_vt1702},
1212
	{ .id = 0x11065398, .name = "VT1702",
1213
	  .patch = patch_vt1702},
1214
	{ .id = 0x11066398, .name = "VT1702",
1215
	  .patch = patch_vt1702},
1216
	{ .id = 0x11067398, .name = "VT1702",
1217
	  .patch = patch_vt1702},
L
Lydia Wang 已提交
1218 1219 1220 1221
	{ .id = 0x11060428, .name = "VT1718S",
	  .patch = patch_vt1718S},
	{ .id = 0x11064428, .name = "VT1718S",
	  .patch = patch_vt1718S},
1222 1223 1224 1225
	{ .id = 0x11060441, .name = "VT2020",
	  .patch = patch_vt1718S},
	{ .id = 0x11064441, .name = "VT1828S",
	  .patch = patch_vt1718S},
L
Lydia Wang 已提交
1226 1227 1228 1229
	{ .id = 0x11060433, .name = "VT1716S",
	  .patch = patch_vt1716S},
	{ .id = 0x1106a721, .name = "VT1716S",
	  .patch = patch_vt1716S},
L
Lydia Wang 已提交
1230 1231
	{ .id = 0x11060438, .name = "VT2002P", .patch = patch_vt2002P},
	{ .id = 0x11064438, .name = "VT2002P", .patch = patch_vt2002P},
L
Lydia Wang 已提交
1232
	{ .id = 0x11060448, .name = "VT1812", .patch = patch_vt1812},
1233 1234
	{ .id = 0x11060440, .name = "VT1818S",
	  .patch = patch_vt1708S},
1235 1236 1237 1238
	{ .id = 0x11060446, .name = "VT1802",
		.patch = patch_vt2002P},
	{ .id = 0x11068446, .name = "VT1802",
		.patch = patch_vt2002P},
1239 1240
	{ .id = 0x11064760, .name = "VT1705CF",
		.patch = patch_vt3476},
1241 1242 1243 1244
	{ .id = 0x11064761, .name = "VT1708SCE",
		.patch = patch_vt3476},
	{ .id = 0x11064762, .name = "VT1808",
		.patch = patch_vt3476},
1245 1246
	{} /* terminator */
};
1247 1248 1249

MODULE_ALIAS("snd-hda-codec-id:1106*");

1250
static struct hda_codec_driver via_driver = {
1251 1252 1253 1254 1255 1256
	.preset = snd_hda_preset_via,
};

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("VIA HD-audio codec");

1257
module_hda_codec_driver(via_driver);