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