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