aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-06-20 05:32:27 -0400
committerTakashi Iwai <tiwai@suse.de>2011-06-20 10:24:09 -0400
commit5d41762a210851943f59f0a08656ca582f76d9d3 (patch)
treeecef2db78e172c8cf9e520684b9d07bf12b29955
parent0fe0adf82f95ed5ce5a75512b281f6cbc89cefa1 (diff)
ALSA: hda - Initialize output path dynamically in patch_via.c
Instead of fixed array for each codec type, initialize the output path dynamically from the parsed results. Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/pci/hda/patch_via.c349
1 files changed, 135 insertions, 214 deletions
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index ae90b95eab3..4f6e7bebdb4 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -501,44 +501,126 @@ static int via_new_analog_input(struct via_spec *spec, const char *ctlname,
501 return 0; 501 return 0;
502} 502}
503 503
504static void via_auto_set_output_and_unmute(struct hda_codec *codec, 504/* return the index of the given widget nid as the source of mux;
505 hda_nid_t nid, int pin_type, 505 * return -1 if not found;
506 int dac_idx) 506 * if num_conns is non-NULL, set the total number of connections
507 */
508static int __get_connection_index(struct hda_codec *codec, hda_nid_t mux,
509 hda_nid_t nid, int *num_conns)
507{ 510{
508 /* set as output */ 511 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
509 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 512 int i, nums;
510 pin_type); 513
514 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
515 if (num_conns)
516 *num_conns = nums;
517 for (i = 0; i < nums; i++)
518 if (conn[i] == nid)
519 return i;
520 return -1;
521}
522
523#define get_connection_index(codec, mux, nid) \
524 __get_connection_index(codec, mux, nid, NULL)
525
526/* unmute input amp and select the specificed source */
527static void unmute_and_select(struct hda_codec *codec, hda_nid_t nid,
528 hda_nid_t src, hda_nid_t mix)
529{
530 int idx, num_conns;
531
532 idx = __get_connection_index(codec, nid, src, &num_conns);
533 if (idx < 0)
534 return;
535
536 /* select the route explicitly when multiple connections exist */
537 if (num_conns > 1)
538 snd_hda_codec_write(codec, nid, 0,
539 AC_VERB_SET_CONNECT_SEL, idx);
540 /* unmute if the input amp is present */
541 if (!(query_amp_caps(codec, nid, HDA_INPUT) &
542 (AC_AMPCAP_NUM_STEPS | AC_AMPCAP_MUTE)))
543 return;
511 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 544 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
512 AMP_OUT_UNMUTE); 545 AMP_IN_UNMUTE(idx));
513 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) 546
547 /* unmute AA-path if present */
548 if (!mix)
549 return;
550 idx = __get_connection_index(codec, nid, mix, NULL);
551 if (idx >= 0)
514 snd_hda_codec_write(codec, nid, 0, 552 snd_hda_codec_write(codec, nid, 0,
553 AC_VERB_SET_AMP_GAIN_MUTE,
554 AMP_IN_UNMUTE(idx));
555}
556
557/* set the given pin as output */
558static void init_output_pin(struct hda_codec *codec, hda_nid_t pin,
559 int pin_type)
560{
561 if (!pin)
562 return;
563 snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
564 pin_type);
565 if (snd_hda_query_pin_caps(codec, pin) & AC_PINCAP_EAPD)
566 snd_hda_codec_write(codec, pin, 0,
515 AC_VERB_SET_EAPD_BTLENABLE, 0x02); 567 AC_VERB_SET_EAPD_BTLENABLE, 0x02);
516} 568}
517 569
570static void via_auto_init_output(struct hda_codec *codec, hda_nid_t pin,
571 int pin_type, struct nid_path *path)
572{
573 struct via_spec *spec = codec->spec;
574 unsigned int caps;
575 hda_nid_t nid;
576 int i;
577
578 if (!pin)
579 return;
580
581 init_output_pin(codec, pin, pin_type);
582 caps = query_amp_caps(codec, pin, HDA_OUTPUT);
583 if (caps & AC_AMPCAP_MUTE) {
584 unsigned int val;
585 val = (caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT;
586 snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE,
587 AMP_OUT_MUTE | val);
588 }
589
590 /* initialize the output path */
591 nid = pin;
592 for (i = 0; i < path->depth; i++) {
593 unmute_and_select(codec, nid, path->idx[i], spec->aa_mix_nid);
594 nid = path->path[i];
595 if (query_amp_caps(codec, nid, HDA_OUTPUT) &
596 (AC_AMPCAP_NUM_STEPS | AC_AMPCAP_MUTE))
597 snd_hda_codec_write(codec, nid, 0,
598 AC_VERB_SET_AMP_GAIN_MUTE,
599 AMP_OUT_UNMUTE);
600 }
601}
602
518 603
519static void via_auto_init_multi_out(struct hda_codec *codec) 604static void via_auto_init_multi_out(struct hda_codec *codec)
520{ 605{
521 struct via_spec *spec = codec->spec; 606 struct via_spec *spec = codec->spec;
522 int i; 607 int i;
523 608
524 for (i = 0; i <= HDA_SIDE; i++) { 609 for (i = 0; i < spec->autocfg.line_outs; i++)
525 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 610 via_auto_init_output(codec, spec->autocfg.line_out_pins[i],
526 if (nid) 611 PIN_OUT, &spec->out_path[i]);
527 via_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
528 }
529} 612}
530 613
531static void via_auto_init_hp_out(struct hda_codec *codec) 614static void via_auto_init_hp_out(struct hda_codec *codec)
532{ 615{
533 struct via_spec *spec = codec->spec; 616 struct via_spec *spec = codec->spec;
534 hda_nid_t pin;
535 int i;
536 617
537 for (i = 0; i < spec->autocfg.hp_outs; i++) { 618 if (spec->hp_dac_nid)
538 pin = spec->autocfg.hp_pins[i]; 619 via_auto_init_output(codec, spec->autocfg.hp_pins[0], PIN_HP,
539 if (pin) /* connect to front */ 620 &spec->hp_path);
540 via_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 621 else
541 } 622 via_auto_init_output(codec, spec->autocfg.hp_pins[0], PIN_HP,
623 &spec->hp_dep_path);
542} 624}
543 625
544static bool is_smart51_pins(struct hda_codec *codec, hda_nid_t pin); 626static bool is_smart51_pins(struct hda_codec *codec, hda_nid_t pin);
@@ -1053,18 +1135,6 @@ static const struct hda_verb vt1708_volume_init_verbs[] = {
1053 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 1135 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1054 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 1136 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
1055 1137
1056 /*
1057 * Set up output mixers (0x19 - 0x1b)
1058 */
1059 /* set vol=0 to output mixers */
1060 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1061 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1062 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1063
1064 /* Setup default input MW0 to PW4 */
1065 {0x20, AC_VERB_SET_CONNECT_SEL, 0},
1066 /* PW9 Output enable */
1067 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
1068 /* power down jack detect function */ 1138 /* power down jack detect function */
1069 {0x1, 0xf81, 0x1}, 1139 {0x1, 0xf81, 0x1},
1070 { } 1140 { }
@@ -1624,33 +1694,6 @@ static void via_unsol_event(struct hda_codec *codec,
1624 via_hp_bind_automute(codec); 1694 via_hp_bind_automute(codec);
1625} 1695}
1626 1696
1627static int via_init(struct hda_codec *codec)
1628{
1629 struct via_spec *spec = codec->spec;
1630 int i;
1631 for (i = 0; i < spec->num_iverbs; i++)
1632 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1633
1634 /* Lydia Add for EAPD enable */
1635 if (!spec->dig_in_nid) { /* No Digital In connection */
1636 if (spec->dig_in_pin) {
1637 snd_hda_codec_write(codec, spec->dig_in_pin, 0,
1638 AC_VERB_SET_PIN_WIDGET_CONTROL,
1639 PIN_OUT);
1640 snd_hda_codec_write(codec, spec->dig_in_pin, 0,
1641 AC_VERB_SET_EAPD_BTLENABLE, 0x02);
1642 }
1643 } else /* enable SPDIF-input pin */
1644 snd_hda_codec_write(codec, spec->autocfg.dig_in_pin, 0,
1645 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN);
1646
1647 /* assign slave outs */
1648 if (spec->slave_dig_outs[0])
1649 codec->slave_dig_outs = spec->slave_dig_outs;
1650
1651 return 0;
1652}
1653
1654#ifdef SND_HDA_NEEDS_RESUME 1697#ifdef SND_HDA_NEEDS_RESUME
1655static int via_suspend(struct hda_codec *codec, pm_message_t state) 1698static int via_suspend(struct hda_codec *codec, pm_message_t state)
1656{ 1699{
@@ -1670,6 +1713,9 @@ static int via_check_power_status(struct hda_codec *codec, hda_nid_t nid)
1670 1713
1671/* 1714/*
1672 */ 1715 */
1716
1717static int via_init(struct hda_codec *codec);
1718
1673static const struct hda_codec_ops via_patch_ops = { 1719static const struct hda_codec_ops via_patch_ops = {
1674 .build_controls = via_build_controls, 1720 .build_controls = via_build_controls,
1675 .build_pcms = via_build_pcms, 1721 .build_pcms = via_build_pcms,
@@ -1791,9 +1837,6 @@ static int create_ch_ctls(struct hda_codec *codec, const char *pfx,
1791 return 0; 1837 return 0;
1792} 1838}
1793 1839
1794static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1795 hda_nid_t nid);
1796
1797static void mangle_smart51(struct hda_codec *codec) 1840static void mangle_smart51(struct hda_codec *codec)
1798{ 1841{
1799 struct via_spec *spec = codec->spec; 1842 struct via_spec *spec = codec->spec;
@@ -1910,19 +1953,6 @@ static int via_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
1910 return 0; 1953 return 0;
1911} 1954}
1912 1955
1913static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1914 hda_nid_t nid)
1915{
1916 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1917 int i, nums;
1918
1919 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1920 for (i = 0; i < nums; i++)
1921 if (conn[i] == nid)
1922 return i;
1923 return -1;
1924}
1925
1926/* look for ADCs */ 1956/* look for ADCs */
1927static int via_fill_adcs(struct hda_codec *codec) 1957static int via_fill_adcs(struct hda_codec *codec)
1928{ 1958{
@@ -2184,18 +2214,44 @@ static int via_parse_auto_config(struct hda_codec *codec)
2184 if (err < 0) 2214 if (err < 0)
2185 return err; 2215 return err;
2186 2216
2217 /* assign slave outs */
2218 if (spec->slave_dig_outs[0])
2219 codec->slave_dig_outs = spec->slave_dig_outs;
2220
2187 return 1; 2221 return 1;
2188} 2222}
2189 2223
2190/* init callback for auto-configuration model -- overriding the default init */ 2224static void via_auto_init_dig_outs(struct hda_codec *codec)
2191static int via_auto_init(struct hda_codec *codec) 2225{
2226 struct via_spec *spec = codec->spec;
2227 if (spec->multiout.dig_out_nid)
2228 init_output_pin(codec, spec->autocfg.dig_out_pins[0], PIN_OUT);
2229 if (spec->slave_dig_outs[0])
2230 init_output_pin(codec, spec->autocfg.dig_out_pins[1], PIN_OUT);
2231}
2232
2233static void via_auto_init_dig_in(struct hda_codec *codec)
2192{ 2234{
2193 struct via_spec *spec = codec->spec; 2235 struct via_spec *spec = codec->spec;
2236 if (!spec->dig_in_nid)
2237 return;
2238 snd_hda_codec_write(codec, spec->autocfg.dig_in_pin, 0,
2239 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN);
2240}
2241
2242static int via_init(struct hda_codec *codec)
2243{
2244 struct via_spec *spec = codec->spec;
2245 int i;
2246
2247 for (i = 0; i < spec->num_iverbs; i++)
2248 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2194 2249
2195 via_init(codec);
2196 via_auto_init_multi_out(codec); 2250 via_auto_init_multi_out(codec);
2197 via_auto_init_hp_out(codec); 2251 via_auto_init_hp_out(codec);
2198 via_auto_init_analog_input(codec); 2252 via_auto_init_analog_input(codec);
2253 via_auto_init_dig_outs(codec);
2254 via_auto_init_dig_in(codec);
2199 2255
2200 if (VT2002P_COMPATIBLE(spec)) { 2256 if (VT2002P_COMPATIBLE(spec)) {
2201 via_hp_bind_automute(codec); 2257 via_hp_bind_automute(codec);
@@ -2282,7 +2338,6 @@ static int patch_vt1708(struct hda_codec *codec)
2282 2338
2283 codec->patch_ops = via_patch_ops; 2339 codec->patch_ops = via_patch_ops;
2284 2340
2285 codec->patch_ops.init = via_auto_init;
2286#ifdef CONFIG_SND_HDA_POWER_SAVE 2341#ifdef CONFIG_SND_HDA_POWER_SAVE
2287 spec->loopback.amplist = vt1708_loopbacks; 2342 spec->loopback.amplist = vt1708_loopbacks;
2288#endif 2343#endif
@@ -2318,24 +2373,8 @@ static const struct hda_verb vt1709_10ch_volume_init_verbs[] = {
2318 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 2373 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
2319 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 2374 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
2320 2375
2321 /*
2322 * Set up output selector (0x1a, 0x1b, 0x29)
2323 */
2324 /* set vol=0 to output mixers */
2325 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2326 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2327 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2328
2329 /*
2330 * Unmute PW3 and PW4
2331 */
2332 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2333 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2334
2335 /* Set input of PW4 as MW0 */ 2376 /* Set input of PW4 as MW0 */
2336 {0x20, AC_VERB_SET_CONNECT_SEL, 0}, 2377 {0x20, AC_VERB_SET_CONNECT_SEL, 0},
2337 /* PW9 Output enable */
2338 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2339 { } 2378 { }
2340}; 2379};
2341 2380
@@ -2372,7 +2411,6 @@ static int patch_vt1709_10ch(struct hda_codec *codec)
2372 2411
2373 codec->patch_ops = via_patch_ops; 2412 codec->patch_ops = via_patch_ops;
2374 2413
2375 codec->patch_ops.init = via_auto_init;
2376 codec->patch_ops.unsol_event = via_unsol_event; 2414 codec->patch_ops.unsol_event = via_unsol_event;
2377#ifdef CONFIG_SND_HDA_POWER_SAVE 2415#ifdef CONFIG_SND_HDA_POWER_SAVE
2378 spec->loopback.amplist = vt1709_loopbacks; 2416 spec->loopback.amplist = vt1709_loopbacks;
@@ -2446,7 +2484,6 @@ static int patch_vt1709_6ch(struct hda_codec *codec)
2446 2484
2447 codec->patch_ops = via_patch_ops; 2485 codec->patch_ops = via_patch_ops;
2448 2486
2449 codec->patch_ops.init = via_auto_init;
2450 codec->patch_ops.unsol_event = via_unsol_event; 2487 codec->patch_ops.unsol_event = via_unsol_event;
2451#ifdef CONFIG_SND_HDA_POWER_SAVE 2488#ifdef CONFIG_SND_HDA_POWER_SAVE
2452 spec->loopback.amplist = vt1709_loopbacks; 2489 spec->loopback.amplist = vt1709_loopbacks;
@@ -2483,8 +2520,6 @@ static const struct hda_verb vt1708B_8ch_volume_init_verbs[] = {
2483 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 2520 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2484 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 2521 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2485 2522
2486 /* Setup default input to PW4 */
2487 {0x1d, AC_VERB_SET_CONNECT_SEL, 0},
2488 /* PW9 Output enable */ 2523 /* PW9 Output enable */
2489 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 2524 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2490 /* PW10 Input enable */ 2525 /* PW10 Input enable */
@@ -2510,18 +2545,6 @@ static const struct hda_verb vt1708B_4ch_volume_init_verbs[] = {
2510 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 2545 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
2511 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 2546 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
2512 2547
2513 /*
2514 * Set up output mixers
2515 */
2516 /* set vol=0 to output mixers */
2517 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2518 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2519 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2520
2521 /* Setup default input of PW4 to MW0 */
2522 {0x1d, AC_VERB_SET_CONNECT_SEL, 0x0},
2523 /* PW9 Output enable */
2524 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2525 /* PW10 Input enable */ 2548 /* PW10 Input enable */
2526 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 2549 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2527 { } 2550 { }
@@ -2657,7 +2680,6 @@ static int patch_vt1708B_8ch(struct hda_codec *codec)
2657 2680
2658 codec->patch_ops = via_patch_ops; 2681 codec->patch_ops = via_patch_ops;
2659 2682
2660 codec->patch_ops.init = via_auto_init;
2661 codec->patch_ops.unsol_event = via_unsol_event; 2683 codec->patch_ops.unsol_event = via_unsol_event;
2662#ifdef CONFIG_SND_HDA_POWER_SAVE 2684#ifdef CONFIG_SND_HDA_POWER_SAVE
2663 spec->loopback.amplist = vt1708B_loopbacks; 2685 spec->loopback.amplist = vt1708B_loopbacks;
@@ -2690,7 +2712,6 @@ static int patch_vt1708B_4ch(struct hda_codec *codec)
2690 2712
2691 codec->patch_ops = via_patch_ops; 2713 codec->patch_ops = via_patch_ops;
2692 2714
2693 codec->patch_ops.init = via_auto_init;
2694 codec->patch_ops.unsol_event = via_unsol_event; 2715 codec->patch_ops.unsol_event = via_unsol_event;
2695#ifdef CONFIG_SND_HDA_POWER_SAVE 2716#ifdef CONFIG_SND_HDA_POWER_SAVE
2696 spec->loopback.amplist = vt1708B_loopbacks; 2717 spec->loopback.amplist = vt1708B_loopbacks;
@@ -2717,11 +2738,6 @@ static const struct hda_verb vt1708S_volume_init_verbs[] = {
2717 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 2738 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
2718 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 2739 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
2719 2740
2720 /* Setup default input of PW4 to MW0 */
2721 {0x1d, AC_VERB_SET_CONNECT_SEL, 0x0},
2722 /* PW9, PW10 Output enable */
2723 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2724 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2725 /* Enable Mic Boost Volume backdoor */ 2741 /* Enable Mic Boost Volume backdoor */
2726 {0x1, 0xf98, 0x1}, 2742 {0x1, 0xf98, 0x1},
2727 /* don't bybass mixer */ 2743 /* don't bybass mixer */
@@ -2857,7 +2873,6 @@ static int patch_vt1708S(struct hda_codec *codec)
2857 2873
2858 codec->patch_ops = via_patch_ops; 2874 codec->patch_ops = via_patch_ops;
2859 2875
2860 codec->patch_ops.init = via_auto_init;
2861 codec->patch_ops.unsol_event = via_unsol_event; 2876 codec->patch_ops.unsol_event = via_unsol_event;
2862#ifdef CONFIG_SND_HDA_POWER_SAVE 2877#ifdef CONFIG_SND_HDA_POWER_SAVE
2863 spec->loopback.amplist = vt1708S_loopbacks; 2878 spec->loopback.amplist = vt1708S_loopbacks;
@@ -2904,11 +2919,6 @@ static const struct hda_verb vt1702_volume_init_verbs[] = {
2904 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 2919 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
2905 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 2920 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2906 2921
2907 /* Setup default input of PW4 to MW0 */
2908 {0x17, AC_VERB_SET_CONNECT_SEL, 0x1},
2909 /* PW6 PW7 Output enable */
2910 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2911 {0x1C, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2912 /* mixer enable */ 2922 /* mixer enable */
2913 {0x1, 0xF88, 0x3}, 2923 {0x1, 0xF88, 0x3},
2914 /* GPIO 0~2 */ 2924 /* GPIO 0~2 */
@@ -2998,7 +3008,6 @@ static int patch_vt1702(struct hda_codec *codec)
2998 3008
2999 codec->patch_ops = via_patch_ops; 3009 codec->patch_ops = via_patch_ops;
3000 3010
3001 codec->patch_ops.init = via_auto_init;
3002 codec->patch_ops.unsol_event = via_unsol_event; 3011 codec->patch_ops.unsol_event = via_unsol_event;
3003#ifdef CONFIG_SND_HDA_POWER_SAVE 3012#ifdef CONFIG_SND_HDA_POWER_SAVE
3004 spec->loopback.amplist = vt1702_loopbacks; 3013 spec->loopback.amplist = vt1702_loopbacks;
@@ -3029,31 +3038,9 @@ static const struct hda_verb vt1718S_volume_init_verbs[] = {
3029 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 3038 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3030 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, 3039 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
3031 3040
3032 /* Setup default input of Front HP to MW9 */
3033 {0x28, AC_VERB_SET_CONNECT_SEL, 0x1},
3034 /* PW9 PW10 Output enable */
3035 {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN},
3036 {0x2e, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN},
3037 /* PW11 Input enable */
3038 {0x2f, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_IN_EN},
3039 /* Enable Boost Volume backdoor */ 3041 /* Enable Boost Volume backdoor */
3040 {0x1, 0xf88, 0x8}, 3042 {0x1, 0xf88, 0x8},
3041 /* MW0/1/2/3/4: un-mute index 0 (AOWx), mute index 1 (MW9) */ 3043
3042 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3043 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3044 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3045 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3046 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3047 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3048 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3049 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3050 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3051 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3052 /* set MUX1 = 2 (AOW4), MUX2 = 1 (AOW3) */
3053 {0x34, AC_VERB_SET_CONNECT_SEL, 0x2},
3054 {0x35, AC_VERB_SET_CONNECT_SEL, 0x1},
3055 /* Unmute MW4's index 0 */
3056 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3057 { } 3044 { }
3058}; 3045};
3059 3046
@@ -3173,7 +3160,6 @@ static int patch_vt1718S(struct hda_codec *codec)
3173 3160
3174 codec->patch_ops = via_patch_ops; 3161 codec->patch_ops = via_patch_ops;
3175 3162
3176 codec->patch_ops.init = via_auto_init;
3177 codec->patch_ops.unsol_event = via_unsol_event; 3163 codec->patch_ops.unsol_event = via_unsol_event;
3178 3164
3179#ifdef CONFIG_SND_HDA_POWER_SAVE 3165#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -3267,24 +3253,6 @@ static const struct hda_verb vt1716S_volume_init_verbs[] = {
3267 /* MUX Indices: Stereo Mixer = 5 */ 3253 /* MUX Indices: Stereo Mixer = 5 */
3268 {0x17, AC_VERB_SET_CONNECT_SEL, 0x5}, 3254 {0x17, AC_VERB_SET_CONNECT_SEL, 0x5},
3269 3255
3270 /* Setup default input of PW4 to MW0 */
3271 {0x1d, AC_VERB_SET_CONNECT_SEL, 0x0},
3272
3273 /* Setup default input of SW1 as MW0 */
3274 {0x18, AC_VERB_SET_CONNECT_SEL, 0x1},
3275
3276 /* Setup default input of SW4 as AOW0 */
3277 {0x28, AC_VERB_SET_CONNECT_SEL, 0x1},
3278
3279 /* PW9 PW10 Output enable */
3280 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3281 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3282
3283 /* Unmute SW1, PW12 */
3284 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3285 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3286 /* PW12 Output enable */
3287 {0x2a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3288 /* Enable Boost Volume backdoor */ 3256 /* Enable Boost Volume backdoor */
3289 {0x1, 0xf8a, 0x80}, 3257 {0x1, 0xf8a, 0x80},
3290 /* don't bybass mixer */ 3258 /* don't bybass mixer */
@@ -3442,7 +3410,6 @@ static int patch_vt1716S(struct hda_codec *codec)
3442 3410
3443 codec->patch_ops = via_patch_ops; 3411 codec->patch_ops = via_patch_ops;
3444 3412
3445 codec->patch_ops.init = via_auto_init;
3446 codec->patch_ops.unsol_event = via_unsol_event; 3413 codec->patch_ops.unsol_event = via_unsol_event;
3447 3414
3448#ifdef CONFIG_SND_HDA_POWER_SAVE 3415#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -3481,31 +3448,9 @@ static const struct hda_verb vt2002P_volume_init_verbs[] = {
3481 {0x1e, AC_VERB_SET_CONNECT_SEL, 0}, 3448 {0x1e, AC_VERB_SET_CONNECT_SEL, 0},
3482 {0x1f, AC_VERB_SET_CONNECT_SEL, 0}, 3449 {0x1f, AC_VERB_SET_CONNECT_SEL, 0},
3483 3450
3484 /* PW9 Output enable */
3485 {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN},
3486
3487 /* Enable Boost Volume backdoor */ 3451 /* Enable Boost Volume backdoor */
3488 {0x1, 0xfb9, 0x24}, 3452 {0x1, 0xfb9, 0x24},
3489 3453
3490 /* MW0/1/4/8: un-mute index 0 (MUXx), un-mute index 1 (MW9) */
3491 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3492 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3493 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3494 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3495 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3496 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3497 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3498 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3499
3500 /* set MUX0/1/4/8 = 0 (AOW0) */
3501 {0x34, AC_VERB_SET_CONNECT_SEL, 0},
3502 {0x35, AC_VERB_SET_CONNECT_SEL, 0},
3503 {0x37, AC_VERB_SET_CONNECT_SEL, 0},
3504 {0x3b, AC_VERB_SET_CONNECT_SEL, 0},
3505
3506 /* set PW0 index=0 (MW0) */
3507 {0x24, AC_VERB_SET_CONNECT_SEL, 0},
3508
3509 /* Enable AOW0 to MW9 */ 3454 /* Enable AOW0 to MW9 */
3510 {0x1, 0xfb8, 0x88}, 3455 {0x1, 0xfb8, 0x88},
3511 { } 3456 { }
@@ -3742,7 +3687,6 @@ static int patch_vt2002P(struct hda_codec *codec)
3742 3687
3743 codec->patch_ops = via_patch_ops; 3688 codec->patch_ops = via_patch_ops;
3744 3689
3745 codec->patch_ops.init = via_auto_init;
3746 codec->patch_ops.unsol_event = via_unsol_event; 3690 codec->patch_ops.unsol_event = via_unsol_event;
3747 3691
3748#ifdef CONFIG_SND_HDA_POWER_SAVE 3692#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -3777,31 +3721,9 @@ static const struct hda_verb vt1812_volume_init_verbs[] = {
3777 {0x1e, AC_VERB_SET_CONNECT_SEL, 0}, 3721 {0x1e, AC_VERB_SET_CONNECT_SEL, 0},
3778 {0x1f, AC_VERB_SET_CONNECT_SEL, 0}, 3722 {0x1f, AC_VERB_SET_CONNECT_SEL, 0},
3779 3723
3780 /* PW9 Output enable */
3781 {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN},
3782
3783 /* Enable Boost Volume backdoor */ 3724 /* Enable Boost Volume backdoor */
3784 {0x1, 0xfb9, 0x24}, 3725 {0x1, 0xfb9, 0x24},
3785 3726
3786 /* MW0/1/4/13/15: un-mute index 0 (MUXx), un-mute index 1 (MW9) */
3787 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3788 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3789 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3790 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3791 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3792 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3794 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3795 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3796 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3797
3798 /* set MUX0/1/4/13/15 = 0 (AOW0) */
3799 {0x34, AC_VERB_SET_CONNECT_SEL, 0},
3800 {0x35, AC_VERB_SET_CONNECT_SEL, 0},
3801 {0x38, AC_VERB_SET_CONNECT_SEL, 0},
3802 {0x3c, AC_VERB_SET_CONNECT_SEL, 0},
3803 {0x3d, AC_VERB_SET_CONNECT_SEL, 0},
3804
3805 /* Enable AOW0 to MW9 */ 3727 /* Enable AOW0 to MW9 */
3806 {0x1, 0xfb8, 0xa8}, 3728 {0x1, 0xfb8, 0xa8},
3807 { } 3729 { }
@@ -3948,7 +3870,6 @@ static int patch_vt1812(struct hda_codec *codec)
3948 3870
3949 codec->patch_ops = via_patch_ops; 3871 codec->patch_ops = via_patch_ops;
3950 3872
3951 codec->patch_ops.init = via_auto_init;
3952 codec->patch_ops.unsol_event = via_unsol_event; 3873 codec->patch_ops.unsol_event = via_unsol_event;
3953 3874
3954#ifdef CONFIG_SND_HDA_POWER_SAVE 3875#ifdef CONFIG_SND_HDA_POWER_SAVE