aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-06-20 06:39:26 -0400
committerTakashi Iwai <tiwai@suse.de>2011-06-20 10:24:11 -0400
commit4a918ffeaadd6a2269b9c6575478c102382c7702 (patch)
tree7f906cee7013bb504808a1b7d886cb49e25e6351 /sound/pci
parent096a885494f6b89a9962c6faf18e1c6092e7919c (diff)
ALSA: hda - Initialize unsol events dynamically in patch_via.c
Issue the init verbs of unsolicited events dynamically from the parsed results for VIA codecs. Also, consolidate the unsol handlers for HP and line-out mutes. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/patch_via.c444
1 files changed, 98 insertions, 346 deletions
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 68f435dbbfd4..1edcd3221c98 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -138,6 +138,7 @@ struct via_spec {
138 struct nid_path out_path[4]; 138 struct nid_path out_path[4];
139 struct nid_path hp_path; 139 struct nid_path hp_path;
140 struct nid_path hp_dep_path; 140 struct nid_path hp_dep_path;
141 struct nid_path speaker_path;
141 142
142 /* capture */ 143 /* capture */
143 unsigned int num_adc_nids; 144 unsigned int num_adc_nids;
@@ -252,15 +253,12 @@ static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec)
252#define VIA_JACK_EVENT 0x20 253#define VIA_JACK_EVENT 0x20
253#define VIA_HP_EVENT 0x01 254#define VIA_HP_EVENT 0x01
254#define VIA_GPIO_EVENT 0x02 255#define VIA_GPIO_EVENT 0x02
255#define VIA_MONO_EVENT 0x03 256#define VIA_LINE_EVENT 0x03
256#define VIA_SPEAKER_EVENT 0x04
257#define VIA_BIND_HP_EVENT 0x05
258 257
259enum { 258enum {
260 VIA_CTL_WIDGET_VOL, 259 VIA_CTL_WIDGET_VOL,
261 VIA_CTL_WIDGET_MUTE, 260 VIA_CTL_WIDGET_MUTE,
262 VIA_CTL_WIDGET_ANALOG_MUTE, 261 VIA_CTL_WIDGET_ANALOG_MUTE,
263 VIA_CTL_WIDGET_BIND_PIN_MUTE,
264}; 262};
265 263
266static void analog_low_current_mode(struct hda_codec *codec, int stream_idle); 264static void analog_low_current_mode(struct hda_codec *codec, int stream_idle);
@@ -323,106 +321,10 @@ static int analog_input_switch_put(struct snd_kcontrol *kcontrol,
323 .put = analog_input_switch_put, \ 321 .put = analog_input_switch_put, \
324 .private_value = HDA_COMPOSE_AMP_VAL(0, 3, 0, 0) } 322 .private_value = HDA_COMPOSE_AMP_VAL(0, 3, 0, 0) }
325 323
326static void via_hp_bind_automute(struct hda_codec *codec);
327
328static int bind_pin_switch_put(struct snd_kcontrol *kcontrol,
329 struct snd_ctl_elem_value *ucontrol)
330{
331 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
332 struct via_spec *spec = codec->spec;
333 int i;
334 int change = 0;
335
336 long *valp = ucontrol->value.integer.value;
337 int lmute, rmute;
338 if (strstr(kcontrol->id.name, "Switch") == NULL) {
339 snd_printd("Invalid control!\n");
340 return change;
341 }
342 change = snd_hda_mixer_amp_switch_put(kcontrol,
343 ucontrol);
344 /* Get mute value */
345 lmute = *valp ? 0 : HDA_AMP_MUTE;
346 valp++;
347 rmute = *valp ? 0 : HDA_AMP_MUTE;
348
349 /* Set hp pins */
350 if (!spec->hp_independent_mode) {
351 for (i = 0; i < spec->autocfg.hp_outs; i++) {
352 snd_hda_codec_amp_update(
353 codec, spec->autocfg.hp_pins[i],
354 0, HDA_OUTPUT, 0, HDA_AMP_MUTE,
355 lmute);
356 snd_hda_codec_amp_update(
357 codec, spec->autocfg.hp_pins[i],
358 1, HDA_OUTPUT, 0, HDA_AMP_MUTE,
359 rmute);
360 }
361 }
362
363 if (!lmute && !rmute) {
364 /* Line Outs */
365 for (i = 0; i < spec->autocfg.line_outs; i++)
366 snd_hda_codec_amp_stereo(
367 codec, spec->autocfg.line_out_pins[i],
368 HDA_OUTPUT, 0, HDA_AMP_MUTE, 0);
369 /* Speakers */
370 for (i = 0; i < spec->autocfg.speaker_outs; i++)
371 snd_hda_codec_amp_stereo(
372 codec, spec->autocfg.speaker_pins[i],
373 HDA_OUTPUT, 0, HDA_AMP_MUTE, 0);
374 /* unmute */
375 via_hp_bind_automute(codec);
376
377 } else {
378 if (lmute) {
379 /* Mute all left channels */
380 for (i = 1; i < spec->autocfg.line_outs; i++)
381 snd_hda_codec_amp_update(
382 codec,
383 spec->autocfg.line_out_pins[i],
384 0, HDA_OUTPUT, 0, HDA_AMP_MUTE,
385 lmute);
386 for (i = 0; i < spec->autocfg.speaker_outs; i++)
387 snd_hda_codec_amp_update(
388 codec,
389 spec->autocfg.speaker_pins[i],
390 0, HDA_OUTPUT, 0, HDA_AMP_MUTE,
391 lmute);
392 }
393 if (rmute) {
394 /* mute all right channels */
395 for (i = 1; i < spec->autocfg.line_outs; i++)
396 snd_hda_codec_amp_update(
397 codec,
398 spec->autocfg.line_out_pins[i],
399 1, HDA_OUTPUT, 0, HDA_AMP_MUTE,
400 rmute);
401 for (i = 0; i < spec->autocfg.speaker_outs; i++)
402 snd_hda_codec_amp_update(
403 codec,
404 spec->autocfg.speaker_pins[i],
405 1, HDA_OUTPUT, 0, HDA_AMP_MUTE,
406 rmute);
407 }
408 }
409 return change;
410}
411
412#define BIND_PIN_MUTE \
413 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
414 .name = NULL, \
415 .index = 0, \
416 .info = snd_hda_mixer_amp_switch_info, \
417 .get = snd_hda_mixer_amp_switch_get, \
418 .put = bind_pin_switch_put, \
419 .private_value = HDA_COMPOSE_AMP_VAL(0, 3, 0, 0) }
420
421static const struct snd_kcontrol_new via_control_templates[] = { 324static const struct snd_kcontrol_new via_control_templates[] = {
422 HDA_CODEC_VOLUME(NULL, 0, 0, 0), 325 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
423 HDA_CODEC_MUTE(NULL, 0, 0, 0), 326 HDA_CODEC_MUTE(NULL, 0, 0, 0),
424 ANALOG_INPUT_MUTE, 327 ANALOG_INPUT_MUTE,
425 BIND_PIN_MUTE,
426}; 328};
427 329
428 330
@@ -623,6 +525,15 @@ static void via_auto_init_hp_out(struct hda_codec *codec)
623 &spec->hp_dep_path); 525 &spec->hp_dep_path);
624} 526}
625 527
528static void via_auto_init_speaker_out(struct hda_codec *codec)
529{
530 struct via_spec *spec = codec->spec;
531
532 if (spec->autocfg.speaker_outs)
533 via_auto_init_output(codec, spec->autocfg.speaker_pins[0],
534 PIN_OUT, &spec->speaker_path);
535}
536
626static bool is_smart51_pins(struct hda_codec *codec, hda_nid_t pin); 537static bool is_smart51_pins(struct hda_codec *codec, hda_nid_t pin);
627 538
628static void via_auto_init_analog_input(struct hda_codec *codec) 539static void via_auto_init_analog_input(struct hda_codec *codec)
@@ -1554,46 +1465,34 @@ static void toggle_output_mutes(struct hda_codec *codec, int num_pins,
1554 mute ? 0 : PIN_OUT); 1465 mute ? 0 : PIN_OUT);
1555} 1466}
1556 1467
1557/* mute internal speaker if HP is plugged */ 1468/* mute internal speaker if line-out is plugged */
1558static void via_hp_automute(struct hda_codec *codec) 1469static void via_line_automute(struct hda_codec *codec, int present)
1559{ 1470{
1560 unsigned int present = 0;
1561 struct via_spec *spec = codec->spec; 1471 struct via_spec *spec = codec->spec;
1562 1472
1563 present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); 1473 if (!spec->autocfg.speaker_outs)
1564 1474 return;
1565 if (!spec->hp_independent_mode) 1475 if (!present)
1566 toggle_output_mutes(codec, spec->autocfg.line_outs, 1476 present = snd_hda_jack_detect(codec,
1567 spec->autocfg.line_out_pins, 1477 spec->autocfg.line_out_pins[0]);
1568 present); 1478 toggle_output_mutes(codec, spec->autocfg.speaker_outs,
1479 spec->autocfg.speaker_pins,
1480 present);
1569} 1481}
1570 1482
1571/* mute mono out if HP or Line out is plugged */ 1483/* mute internal speaker if HP is plugged */
1572static void via_mono_automute(struct hda_codec *codec) 1484static void via_hp_automute(struct hda_codec *codec)
1573{ 1485{
1574 unsigned int hp_present, lineout_present; 1486 int present = 0;
1575 struct via_spec *spec = codec->spec; 1487 struct via_spec *spec = codec->spec;
1576 1488
1577 if (spec->codec_type != VT1716S) 1489 if (!spec->hp_independent_mode && spec->autocfg.hp_pins[0]) {
1578 return; 1490 present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]);
1579 1491 toggle_output_mutes(codec, spec->autocfg.line_outs,
1580 lineout_present = snd_hda_jack_detect(codec, 1492 spec->autocfg.line_out_pins,
1581 spec->autocfg.line_out_pins[0]); 1493 present);
1582
1583 /* Mute Mono Out if Line Out is plugged */
1584 if (lineout_present) {
1585 snd_hda_codec_write(codec, 0x2A, 0,
1586 AC_VERB_SET_PIN_WIDGET_CONTROL,
1587 lineout_present ? 0 : PIN_OUT);
1588 return;
1589 } 1494 }
1590 1495 via_line_automute(codec, present);
1591 hp_present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]);
1592
1593 if (!spec->hp_independent_mode)
1594 snd_hda_codec_write(codec, 0x2A, 0,
1595 AC_VERB_SET_PIN_WIDGET_CONTROL,
1596 hp_present ? 0 : PIN_OUT);
1597} 1496}
1598 1497
1599static void via_gpio_control(struct hda_codec *codec) 1498static void via_gpio_control(struct hda_codec *codec)
@@ -1643,49 +1542,6 @@ static void via_gpio_control(struct hda_codec *codec)
1643 } 1542 }
1644} 1543}
1645 1544
1646/* mute Internal-Speaker if HP is plugged */
1647static void via_speaker_automute(struct hda_codec *codec)
1648{
1649 unsigned int hp_present;
1650 struct via_spec *spec = codec->spec;
1651
1652 if (!VT2002P_COMPATIBLE(spec))
1653 return;
1654
1655 hp_present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]);
1656
1657 if (!spec->hp_independent_mode)
1658 toggle_output_mutes(codec, spec->autocfg.speaker_outs,
1659 spec->autocfg.speaker_pins,
1660 hp_present);
1661}
1662
1663/* mute line-out and internal speaker if HP is plugged */
1664static void via_hp_bind_automute(struct hda_codec *codec)
1665{
1666 int present;
1667 struct via_spec *spec = codec->spec;
1668
1669 if (!spec->autocfg.hp_pins[0] || !spec->autocfg.line_out_pins[0])
1670 return;
1671
1672 present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]);
1673 if (!spec->hp_independent_mode)
1674 toggle_output_mutes(codec, spec->autocfg.line_outs,
1675 spec->autocfg.line_out_pins,
1676 present);
1677
1678 if (!present)
1679 present = snd_hda_jack_detect(codec,
1680 spec->autocfg.line_out_pins[0]);
1681
1682 /* Speakers */
1683 toggle_output_mutes(codec, spec->autocfg.speaker_outs,
1684 spec->autocfg.speaker_pins,
1685 present);
1686}
1687
1688
1689/* unsolicited event for jack sensing */ 1545/* unsolicited event for jack sensing */
1690static void via_unsol_event(struct hda_codec *codec, 1546static void via_unsol_event(struct hda_codec *codec,
1691 unsigned int res) 1547 unsigned int res)
@@ -1701,12 +1557,8 @@ static void via_unsol_event(struct hda_codec *codec,
1701 via_hp_automute(codec); 1557 via_hp_automute(codec);
1702 else if (res == VIA_GPIO_EVENT) 1558 else if (res == VIA_GPIO_EVENT)
1703 via_gpio_control(codec); 1559 via_gpio_control(codec);
1704 else if (res == VIA_MONO_EVENT) 1560 else if (res == VIA_LINE_EVENT)
1705 via_mono_automute(codec); 1561 via_line_automute(codec, false);
1706 else if (res == VIA_SPEAKER_EVENT)
1707 via_speaker_automute(codec);
1708 else if (res == VIA_BIND_HP_EVENT)
1709 via_hp_bind_automute(codec);
1710} 1562}
1711 1563
1712#ifdef SND_HDA_NEEDS_RESUME 1564#ifdef SND_HDA_NEEDS_RESUME
@@ -1736,6 +1588,7 @@ static const struct hda_codec_ops via_patch_ops = {
1736 .build_pcms = via_build_pcms, 1588 .build_pcms = via_build_pcms,
1737 .init = via_init, 1589 .init = via_init,
1738 .free = via_free, 1590 .free = via_free,
1591 .unsol_event = via_unsol_event,
1739#ifdef SND_HDA_NEEDS_RESUME 1592#ifdef SND_HDA_NEEDS_RESUME
1740 .suspend = via_suspend, 1593 .suspend = via_suspend,
1741#endif 1594#endif
@@ -1968,6 +1821,27 @@ static int via_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
1968 return 0; 1821 return 0;
1969} 1822}
1970 1823
1824static int via_auto_create_speaker_ctls(struct hda_codec *codec)
1825{
1826 struct via_spec *spec = codec->spec;
1827 hda_nid_t pin, dac;
1828
1829 pin = spec->autocfg.speaker_pins[0];
1830 if (!spec->autocfg.speaker_outs || !pin)
1831 return 0;
1832
1833 if (parse_output_path(codec, pin, 0, &spec->speaker_path, 0, -1)) {
1834 dac = spec->speaker_path.path[spec->speaker_path.depth - 1];
1835 spec->multiout.extra_out_nid[0] = dac;
1836 return create_ch_ctls(codec, "Speaker", pin, dac, 3);
1837 }
1838 if (parse_output_path(codec, pin, spec->multiout.dac_nids[HDA_FRONT],
1839 &spec->speaker_path, 0, -1))
1840 return create_ch_ctls(codec, "Headphone", pin, 0, 3);
1841
1842 return 0;
1843}
1844
1971/* look for ADCs */ 1845/* look for ADCs */
1972static int via_fill_adcs(struct hda_codec *codec) 1846static int via_fill_adcs(struct hda_codec *codec)
1973{ 1847{
@@ -2203,6 +2077,9 @@ static int via_parse_auto_config(struct hda_codec *codec)
2203 err = via_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]); 2077 err = via_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
2204 if (err < 0) 2078 if (err < 0)
2205 return err; 2079 return err;
2080 err = via_auto_create_speaker_ctls(codec);
2081 if (err < 0)
2082 return err;
2206 err = via_auto_create_analog_input_ctls(codec, &spec->autocfg); 2083 err = via_auto_create_analog_input_ctls(codec, &spec->autocfg);
2207 if (err < 0) 2084 if (err < 0)
2208 return err; 2085 return err;
@@ -2254,6 +2131,39 @@ static void via_auto_init_dig_in(struct hda_codec *codec)
2254 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN); 2131 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN);
2255} 2132}
2256 2133
2134/* initialize the unsolicited events */
2135static void via_auto_init_unsol_event(struct hda_codec *codec)
2136{
2137 struct via_spec *spec = codec->spec;
2138 struct auto_pin_cfg *cfg = &spec->autocfg;
2139 unsigned int ev;
2140 int i;
2141
2142 if (cfg->hp_pins[0] && is_jack_detectable(codec, cfg->hp_pins[0]))
2143 snd_hda_codec_write(codec, cfg->hp_pins[0], 0,
2144 AC_VERB_SET_UNSOLICITED_ENABLE,
2145 AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT);
2146
2147 if (cfg->speaker_pins[0])
2148 ev = VIA_LINE_EVENT;
2149 else
2150 ev = 0;
2151 for (i = 0; i < cfg->line_outs; i++) {
2152 if (cfg->line_out_pins[i] &&
2153 is_jack_detectable(codec, cfg->line_out_pins[i]))
2154 snd_hda_codec_write(codec, cfg->line_out_pins[0], 0,
2155 AC_VERB_SET_UNSOLICITED_ENABLE,
2156 AC_USRSP_EN | ev | VIA_JACK_EVENT);
2157 }
2158
2159 for (i = 0; i < cfg->num_inputs; i++) {
2160 if (is_jack_detectable(codec, cfg->inputs[i].pin))
2161 snd_hda_codec_write(codec, cfg->inputs[i].pin, 0,
2162 AC_VERB_SET_UNSOLICITED_ENABLE,
2163 AC_USRSP_EN | VIA_JACK_EVENT);
2164 }
2165}
2166
2257static int via_init(struct hda_codec *codec) 2167static int via_init(struct hda_codec *codec)
2258{ 2168{
2259 struct via_spec *spec = codec->spec; 2169 struct via_spec *spec = codec->spec;
@@ -2264,16 +2174,15 @@ static int via_init(struct hda_codec *codec)
2264 2174
2265 via_auto_init_multi_out(codec); 2175 via_auto_init_multi_out(codec);
2266 via_auto_init_hp_out(codec); 2176 via_auto_init_hp_out(codec);
2177 via_auto_init_speaker_out(codec);
2267 via_auto_init_analog_input(codec); 2178 via_auto_init_analog_input(codec);
2268 via_auto_init_dig_outs(codec); 2179 via_auto_init_dig_outs(codec);
2269 via_auto_init_dig_in(codec); 2180 via_auto_init_dig_in(codec);
2270 2181
2271 if (VT2002P_COMPATIBLE(spec)) { 2182 via_auto_init_unsol_event(codec);
2272 via_hp_bind_automute(codec); 2183
2273 } else { 2184 via_hp_automute(codec);
2274 via_hp_automute(codec); 2185 via_line_automute(codec, false);
2275 via_speaker_automute(codec);
2276 }
2277 2186
2278 return 0; 2187 return 0;
2279} 2188}
@@ -2360,12 +2269,6 @@ static int patch_vt1708(struct hda_codec *codec)
2360 return 0; 2269 return 0;
2361} 2270}
2362 2271
2363static const struct hda_verb vt1709_uniwill_init_verbs[] = {
2364 {0x20, AC_VERB_SET_UNSOLICITED_ENABLE,
2365 AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT},
2366 { }
2367};
2368
2369/* 2272/*
2370 * generic initialization of ADC, input mixers and output mixers 2273 * generic initialization of ADC, input mixers and output mixers
2371 */ 2274 */
@@ -2397,11 +2300,8 @@ static int patch_vt1709_10ch(struct hda_codec *codec)
2397 return err; 2300 return err;
2398 } 2301 }
2399 2302
2400 spec->init_verbs[spec->num_iverbs++] = vt1709_uniwill_init_verbs;
2401
2402 codec->patch_ops = via_patch_ops; 2303 codec->patch_ops = via_patch_ops;
2403 2304
2404 codec->patch_ops.unsol_event = via_unsol_event;
2405#ifdef CONFIG_SND_HDA_POWER_SAVE 2305#ifdef CONFIG_SND_HDA_POWER_SAVE
2406 spec->loopback.amplist = vt1709_loopbacks; 2306 spec->loopback.amplist = vt1709_loopbacks;
2407#endif 2307#endif
@@ -2429,11 +2329,8 @@ static int patch_vt1709_6ch(struct hda_codec *codec)
2429 return err; 2329 return err;
2430 } 2330 }
2431 2331
2432 spec->init_verbs[spec->num_iverbs++] = vt1709_uniwill_init_verbs;
2433
2434 codec->patch_ops = via_patch_ops; 2332 codec->patch_ops = via_patch_ops;
2435 2333
2436 codec->patch_ops.unsol_event = via_unsol_event;
2437#ifdef CONFIG_SND_HDA_POWER_SAVE 2334#ifdef CONFIG_SND_HDA_POWER_SAVE
2438 spec->loopback.amplist = vt1709_loopbacks; 2335 spec->loopback.amplist = vt1709_loopbacks;
2439#endif 2336#endif
@@ -2443,19 +2340,6 @@ static int patch_vt1709_6ch(struct hda_codec *codec)
2443/* 2340/*
2444 * generic initialization of ADC, input mixers and output mixers 2341 * generic initialization of ADC, input mixers and output mixers
2445 */ 2342 */
2446static const struct hda_verb vt1708B_uniwill_init_verbs[] = {
2447 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE,
2448 AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT},
2449 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2450 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2451 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2452 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2453 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2454 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2455 {0x23, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2456 { }
2457};
2458
2459#ifdef CONFIG_SND_HDA_POWER_SAVE 2343#ifdef CONFIG_SND_HDA_POWER_SAVE
2460static const struct hda_amp_list vt1708B_loopbacks[] = { 2344static const struct hda_amp_list vt1708B_loopbacks[] = {
2461 { 0x16, HDA_INPUT, 1 }, 2345 { 0x16, HDA_INPUT, 1 },
@@ -2568,11 +2452,8 @@ static int patch_vt1708B_8ch(struct hda_codec *codec)
2568 return err; 2452 return err;
2569 } 2453 }
2570 2454
2571 spec->init_verbs[spec->num_iverbs++] = vt1708B_uniwill_init_verbs;
2572
2573 codec->patch_ops = via_patch_ops; 2455 codec->patch_ops = via_patch_ops;
2574 2456
2575 codec->patch_ops.unsol_event = via_unsol_event;
2576#ifdef CONFIG_SND_HDA_POWER_SAVE 2457#ifdef CONFIG_SND_HDA_POWER_SAVE
2577 spec->loopback.amplist = vt1708B_loopbacks; 2458 spec->loopback.amplist = vt1708B_loopbacks;
2578#endif 2459#endif
@@ -2599,11 +2480,8 @@ static int patch_vt1708B_4ch(struct hda_codec *codec)
2599 return err; 2480 return err;
2600 } 2481 }
2601 2482
2602 spec->init_verbs[spec->num_iverbs++] = vt1708B_uniwill_init_verbs;
2603
2604 codec->patch_ops = via_patch_ops; 2483 codec->patch_ops = via_patch_ops;
2605 2484
2606 codec->patch_ops.unsol_event = via_unsol_event;
2607#ifdef CONFIG_SND_HDA_POWER_SAVE 2485#ifdef CONFIG_SND_HDA_POWER_SAVE
2608 spec->loopback.amplist = vt1708B_loopbacks; 2486 spec->loopback.amplist = vt1708B_loopbacks;
2609#endif 2487#endif
@@ -2622,31 +2500,6 @@ static const struct hda_verb vt1708S_init_verbs[] = {
2622 { } 2500 { }
2623}; 2501};
2624 2502
2625static const struct hda_verb vt1708S_uniwill_init_verbs[] = {
2626 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE,
2627 AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT},
2628 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2629 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2630 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2631 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2632 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2633 {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2634 {0x23, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2635 { }
2636};
2637
2638static const struct hda_verb vt1705_uniwill_init_verbs[] = {
2639 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE,
2640 AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT},
2641 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2642 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2643 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2644 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2645 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2646 {0x23, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2647 { }
2648};
2649
2650/* fill out digital output widgets; one for master and one for slave outputs */ 2503/* fill out digital output widgets; one for master and one for slave outputs */
2651static void fill_dig_outs(struct hda_codec *codec) 2504static void fill_dig_outs(struct hda_codec *codec)
2652{ 2505{
@@ -2741,16 +2594,9 @@ static int patch_vt1708S(struct hda_codec *codec)
2741 } 2594 }
2742 2595
2743 spec->init_verbs[spec->num_iverbs++] = vt1708S_init_verbs; 2596 spec->init_verbs[spec->num_iverbs++] = vt1708S_init_verbs;
2744 if (codec->vendor_id == 0x11064397)
2745 spec->init_verbs[spec->num_iverbs++] =
2746 vt1705_uniwill_init_verbs;
2747 else
2748 spec->init_verbs[spec->num_iverbs++] =
2749 vt1708S_uniwill_init_verbs;
2750 2597
2751 codec->patch_ops = via_patch_ops; 2598 codec->patch_ops = via_patch_ops;
2752 2599
2753 codec->patch_ops.unsol_event = via_unsol_event;
2754#ifdef CONFIG_SND_HDA_POWER_SAVE 2600#ifdef CONFIG_SND_HDA_POWER_SAVE
2755 spec->loopback.amplist = vt1708S_loopbacks; 2601 spec->loopback.amplist = vt1708S_loopbacks;
2756#endif 2602#endif
@@ -2785,16 +2631,6 @@ static const struct hda_verb vt1702_init_verbs[] = {
2785 { } 2631 { }
2786}; 2632};
2787 2633
2788static const struct hda_verb vt1702_uniwill_init_verbs[] = {
2789 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE,
2790 AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT},
2791 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2792 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2793 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2794 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2795 { }
2796};
2797
2798#ifdef CONFIG_SND_HDA_POWER_SAVE 2634#ifdef CONFIG_SND_HDA_POWER_SAVE
2799static const struct hda_amp_list vt1702_loopbacks[] = { 2635static const struct hda_amp_list vt1702_loopbacks[] = {
2800 { 0x1A, HDA_INPUT, 1 }, 2636 { 0x1A, HDA_INPUT, 1 },
@@ -2863,11 +2699,9 @@ static int patch_vt1702(struct hda_codec *codec)
2863 } 2699 }
2864 2700
2865 spec->init_verbs[spec->num_iverbs++] = vt1702_init_verbs; 2701 spec->init_verbs[spec->num_iverbs++] = vt1702_init_verbs;
2866 spec->init_verbs[spec->num_iverbs++] = vt1702_uniwill_init_verbs;
2867 2702
2868 codec->patch_ops = via_patch_ops; 2703 codec->patch_ops = via_patch_ops;
2869 2704
2870 codec->patch_ops.unsol_event = via_unsol_event;
2871#ifdef CONFIG_SND_HDA_POWER_SAVE 2705#ifdef CONFIG_SND_HDA_POWER_SAVE
2872 spec->loopback.amplist = vt1702_loopbacks; 2706 spec->loopback.amplist = vt1702_loopbacks;
2873#endif 2707#endif
@@ -2887,20 +2721,6 @@ static const struct hda_verb vt1718S_init_verbs[] = {
2887 { } 2721 { }
2888}; 2722};
2889 2723
2890
2891static const struct hda_verb vt1718S_uniwill_init_verbs[] = {
2892 {0x28, AC_VERB_SET_UNSOLICITED_ENABLE,
2893 AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT},
2894 {0x24, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2895 {0x25, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2896 {0x26, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2897 {0x27, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2898 {0x29, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2899 {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2900 {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
2901 { }
2902};
2903
2904#ifdef CONFIG_SND_HDA_POWER_SAVE 2724#ifdef CONFIG_SND_HDA_POWER_SAVE
2905static const struct hda_amp_list vt1718S_loopbacks[] = { 2725static const struct hda_amp_list vt1718S_loopbacks[] = {
2906 { 0x21, HDA_INPUT, 1 }, 2726 { 0x21, HDA_INPUT, 1 },
@@ -2999,12 +2819,9 @@ static int patch_vt1718S(struct hda_codec *codec)
2999 } 2819 }
3000 2820
3001 spec->init_verbs[spec->num_iverbs++] = vt1718S_init_verbs; 2821 spec->init_verbs[spec->num_iverbs++] = vt1718S_init_verbs;
3002 spec->init_verbs[spec->num_iverbs++] = vt1718S_uniwill_init_verbs;
3003 2822
3004 codec->patch_ops = via_patch_ops; 2823 codec->patch_ops = via_patch_ops;
3005 2824
3006 codec->patch_ops.unsol_event = via_unsol_event;
3007
3008#ifdef CONFIG_SND_HDA_POWER_SAVE 2825#ifdef CONFIG_SND_HDA_POWER_SAVE
3009 spec->loopback.amplist = vt1718S_loopbacks; 2826 spec->loopback.amplist = vt1718S_loopbacks;
3010#endif 2827#endif
@@ -3085,20 +2902,6 @@ static const struct hda_verb vt1716S_init_verbs[] = {
3085 { } 2902 { }
3086}; 2903};
3087 2904
3088
3089static const struct hda_verb vt1716S_uniwill_init_verbs[] = {
3090 {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE,
3091 AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT},
3092 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
3093 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
3094 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
3095 {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE,
3096 AC_USRSP_EN | VIA_MONO_EVENT | VIA_JACK_EVENT},
3097 {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
3098 {0x23, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
3099 { }
3100};
3101
3102#ifdef CONFIG_SND_HDA_POWER_SAVE 2905#ifdef CONFIG_SND_HDA_POWER_SAVE
3103static const struct hda_amp_list vt1716S_loopbacks[] = { 2906static const struct hda_amp_list vt1716S_loopbacks[] = {
3104 { 0x16, HDA_INPUT, 1 }, 2907 { 0x16, HDA_INPUT, 1 },
@@ -3224,7 +3027,6 @@ static int patch_vt1716S(struct hda_codec *codec)
3224 } 3027 }
3225 3028
3226 spec->init_verbs[spec->num_iverbs++] = vt1716S_init_verbs; 3029 spec->init_verbs[spec->num_iverbs++] = vt1716S_init_verbs;
3227 spec->init_verbs[spec->num_iverbs++] = vt1716S_uniwill_init_verbs;
3228 3030
3229 spec->mixers[spec->num_mixers] = vt1716s_dmic_mixer; 3031 spec->mixers[spec->num_mixers] = vt1716s_dmic_mixer;
3230 spec->num_mixers++; 3032 spec->num_mixers++;
@@ -3233,8 +3035,6 @@ static int patch_vt1716S(struct hda_codec *codec)
3233 3035
3234 codec->patch_ops = via_patch_ops; 3036 codec->patch_ops = via_patch_ops;
3235 3037
3236 codec->patch_ops.unsol_event = via_unsol_event;
3237
3238#ifdef CONFIG_SND_HDA_POWER_SAVE 3038#ifdef CONFIG_SND_HDA_POWER_SAVE
3239 spec->loopback.amplist = vt1716S_loopbacks; 3039 spec->loopback.amplist = vt1716S_loopbacks;
3240#endif 3040#endif
@@ -3256,6 +3056,7 @@ static const struct hda_verb vt2002P_init_verbs[] = {
3256 {0x1, 0xfb8, 0x88}, 3056 {0x1, 0xfb8, 0x88},
3257 { } 3057 { }
3258}; 3058};
3059
3259static const struct hda_verb vt1802_init_verbs[] = { 3060static const struct hda_verb vt1802_init_verbs[] = {
3260 /* Enable Boost Volume backdoor */ 3061 /* Enable Boost Volume backdoor */
3261 {0x1, 0xfb9, 0x24}, 3062 {0x1, 0xfb9, 0x24},
@@ -3264,28 +3065,6 @@ static const struct hda_verb vt1802_init_verbs[] = {
3264 { } 3065 { }
3265}; 3066};
3266 3067
3267
3268static const struct hda_verb vt2002P_uniwill_init_verbs[] = {
3269 {0x25, AC_VERB_SET_UNSOLICITED_ENABLE,
3270 AC_USRSP_EN | VIA_JACK_EVENT | VIA_BIND_HP_EVENT},
3271 {0x26, AC_VERB_SET_UNSOLICITED_ENABLE,
3272 AC_USRSP_EN | VIA_JACK_EVENT | VIA_BIND_HP_EVENT},
3273 {0x29, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
3274 {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
3275 {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
3276 { }
3277};
3278static const struct hda_verb vt1802_uniwill_init_verbs[] = {
3279 {0x25, AC_VERB_SET_UNSOLICITED_ENABLE,
3280 AC_USRSP_EN | VIA_JACK_EVENT | VIA_BIND_HP_EVENT},
3281 {0x28, AC_VERB_SET_UNSOLICITED_ENABLE,
3282 AC_USRSP_EN | VIA_JACK_EVENT | VIA_BIND_HP_EVENT},
3283 {0x29, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
3284 {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
3285 {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
3286 { }
3287};
3288
3289#ifdef CONFIG_SND_HDA_POWER_SAVE 3068#ifdef CONFIG_SND_HDA_POWER_SAVE
3290static const struct hda_amp_list vt2002P_loopbacks[] = { 3069static const struct hda_amp_list vt2002P_loopbacks[] = {
3291 { 0x21, HDA_INPUT, 0 }, 3070 { 0x21, HDA_INPUT, 0 },
@@ -3429,23 +3208,12 @@ static int patch_vt2002P(struct hda_codec *codec)
3429 } 3208 }
3430 3209
3431 if (spec->codec_type == VT1802) 3210 if (spec->codec_type == VT1802)
3432 spec->init_verbs[spec->num_iverbs++] = 3211 spec->init_verbs[spec->num_iverbs++] = vt1802_init_verbs;
3433 vt1802_init_verbs;
3434 else 3212 else
3435 spec->init_verbs[spec->num_iverbs++] = 3213 spec->init_verbs[spec->num_iverbs++] = vt2002P_init_verbs;
3436 vt2002P_init_verbs;
3437
3438 if (spec->codec_type == VT1802)
3439 spec->init_verbs[spec->num_iverbs++] =
3440 vt1802_uniwill_init_verbs;
3441 else
3442 spec->init_verbs[spec->num_iverbs++] =
3443 vt2002P_uniwill_init_verbs;
3444 3214
3445 codec->patch_ops = via_patch_ops; 3215 codec->patch_ops = via_patch_ops;
3446 3216
3447 codec->patch_ops.unsol_event = via_unsol_event;
3448
3449#ifdef CONFIG_SND_HDA_POWER_SAVE 3217#ifdef CONFIG_SND_HDA_POWER_SAVE
3450 spec->loopback.amplist = vt2002P_loopbacks; 3218 spec->loopback.amplist = vt2002P_loopbacks;
3451#endif 3219#endif
@@ -3464,19 +3232,6 @@ static const struct hda_verb vt1812_init_verbs[] = {
3464 { } 3232 { }
3465}; 3233};
3466 3234
3467
3468static const struct hda_verb vt1812_uniwill_init_verbs[] = {
3469 {0x33, AC_VERB_SET_UNSOLICITED_ENABLE,
3470 AC_USRSP_EN | VIA_JACK_EVENT | VIA_BIND_HP_EVENT},
3471 {0x25, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT },
3472 {0x28, AC_VERB_SET_UNSOLICITED_ENABLE,
3473 AC_USRSP_EN | VIA_JACK_EVENT | VIA_BIND_HP_EVENT},
3474 {0x29, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
3475 {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
3476 {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT},
3477 { }
3478};
3479
3480#ifdef CONFIG_SND_HDA_POWER_SAVE 3235#ifdef CONFIG_SND_HDA_POWER_SAVE
3481static const struct hda_amp_list vt1812_loopbacks[] = { 3236static const struct hda_amp_list vt1812_loopbacks[] = {
3482 { 0x21, HDA_INPUT, 0 }, 3237 { 0x21, HDA_INPUT, 0 },
@@ -3601,12 +3356,9 @@ static int patch_vt1812(struct hda_codec *codec)
3601 } 3356 }
3602 3357
3603 spec->init_verbs[spec->num_iverbs++] = vt1812_init_verbs; 3358 spec->init_verbs[spec->num_iverbs++] = vt1812_init_verbs;
3604 spec->init_verbs[spec->num_iverbs++] = vt1812_uniwill_init_verbs;
3605 3359
3606 codec->patch_ops = via_patch_ops; 3360 codec->patch_ops = via_patch_ops;
3607 3361
3608 codec->patch_ops.unsol_event = via_unsol_event;
3609
3610#ifdef CONFIG_SND_HDA_POWER_SAVE 3362#ifdef CONFIG_SND_HDA_POWER_SAVE
3611 spec->loopback.amplist = vt1812_loopbacks; 3363 spec->loopback.amplist = vt1812_loopbacks;
3612#endif 3364#endif