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> |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 52 | #include <sound/core.h> |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 53 | #include <sound/asoundef.h> |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 54 | #include "hda_codec.h" |
| 55 | #include "hda_local.h" |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 56 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 57 | #define NID_MAPPING (-1) |
| 58 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 59 | /* amp values */ |
| 60 | #define AMP_VAL_IDX_SHIFT 19 |
| 61 | #define AMP_VAL_IDX_MASK (0x0f<<19) |
| 62 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 63 | /* Pin Widget NID */ |
| 64 | #define VT1708_HP_NID 0x13 |
| 65 | #define VT1708_DIGOUT_NID 0x14 |
| 66 | #define VT1708_DIGIN_NID 0x16 |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 67 | #define VT1708_DIGIN_PIN 0x26 |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 68 | #define VT1708_HP_PIN_NID 0x20 |
| 69 | #define VT1708_CD_PIN_NID 0x24 |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 70 | |
| 71 | #define VT1709_HP_DAC_NID 0x28 |
| 72 | #define VT1709_DIGOUT_NID 0x13 |
| 73 | #define VT1709_DIGIN_NID 0x17 |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 74 | #define VT1709_DIGIN_PIN 0x25 |
| 75 | |
| 76 | #define VT1708B_HP_NID 0x25 |
| 77 | #define VT1708B_DIGOUT_NID 0x12 |
| 78 | #define VT1708B_DIGIN_NID 0x15 |
| 79 | #define VT1708B_DIGIN_PIN 0x21 |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 80 | |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 81 | #define VT1708S_HP_NID 0x25 |
| 82 | #define VT1708S_DIGOUT_NID 0x12 |
| 83 | |
| 84 | #define VT1702_HP_NID 0x17 |
| 85 | #define VT1702_DIGOUT_NID 0x11 |
| 86 | |
Harald Welte | d742632 | 2008-09-15 22:43:23 +0800 | [diff] [blame] | 87 | enum VIA_HDA_CODEC { |
| 88 | UNKNOWN = -1, |
| 89 | VT1708, |
| 90 | VT1709_10CH, |
| 91 | VT1709_6CH, |
| 92 | VT1708B_8CH, |
| 93 | VT1708B_4CH, |
| 94 | VT1708S, |
Lydia Wang | 518bf3b | 2009-10-10 19:07:29 +0800 | [diff] [blame] | 95 | VT1708BCE, |
Harald Welte | d742632 | 2008-09-15 22:43:23 +0800 | [diff] [blame] | 96 | VT1702, |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 97 | VT1718S, |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 98 | VT1716S, |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 99 | VT2002P, |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 100 | VT1812, |
Lydia Wang | 11890956 | 2011-03-23 17:57:34 +0800 | [diff] [blame] | 101 | VT1802, |
Harald Welte | d742632 | 2008-09-15 22:43:23 +0800 | [diff] [blame] | 102 | CODEC_TYPES, |
| 103 | }; |
| 104 | |
Lydia Wang | 11890956 | 2011-03-23 17:57:34 +0800 | [diff] [blame] | 105 | #define VT2002P_COMPATIBLE(spec) \ |
| 106 | ((spec)->codec_type == VT2002P ||\ |
| 107 | (spec)->codec_type == VT1812 ||\ |
| 108 | (spec)->codec_type == VT1802) |
| 109 | |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 110 | struct nid_path { |
| 111 | int depth; |
| 112 | hda_nid_t path[5]; |
| 113 | short idx[5]; |
| 114 | }; |
| 115 | |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 116 | struct via_spec { |
| 117 | /* codec parameterization */ |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 118 | const struct snd_kcontrol_new *mixers[6]; |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 119 | unsigned int num_mixers; |
| 120 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 121 | const struct hda_verb *init_verbs[5]; |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 122 | unsigned int num_iverbs; |
| 123 | |
Takashi Iwai | 82673bc | 2011-06-17 16:24:21 +0200 | [diff] [blame] | 124 | char stream_name_analog[32]; |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 125 | char stream_name_hp[32]; |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 126 | const struct hda_pcm_stream *stream_analog_playback; |
| 127 | const struct hda_pcm_stream *stream_analog_capture; |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 128 | |
Takashi Iwai | 82673bc | 2011-06-17 16:24:21 +0200 | [diff] [blame] | 129 | char stream_name_digital[32]; |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 130 | const struct hda_pcm_stream *stream_digital_playback; |
| 131 | const struct hda_pcm_stream *stream_digital_capture; |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 132 | |
| 133 | /* playback */ |
| 134 | struct hda_multi_out multiout; |
| 135 | hda_nid_t slave_dig_outs[2]; |
| 136 | |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 137 | struct nid_path out_path[4]; |
| 138 | struct nid_path hp_path; |
| 139 | struct nid_path hp_dep_path; |
| 140 | |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 141 | /* capture */ |
| 142 | unsigned int num_adc_nids; |
Takashi Iwai | a766d0d | 2011-06-17 09:01:29 +0200 | [diff] [blame] | 143 | hda_nid_t adc_nids[3]; |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 144 | hda_nid_t mux_nids[3]; |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 145 | hda_nid_t aa_mix_nid; |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 146 | hda_nid_t dig_in_nid; |
| 147 | hda_nid_t dig_in_pin; |
| 148 | |
| 149 | /* capture source */ |
| 150 | const struct hda_input_mux *input_mux; |
| 151 | unsigned int cur_mux[3]; |
| 152 | |
| 153 | /* PCM information */ |
| 154 | struct hda_pcm pcm_rec[3]; |
| 155 | |
| 156 | /* dynamic controls, init_verbs and input_mux */ |
| 157 | struct auto_pin_cfg autocfg; |
| 158 | struct snd_array kctls; |
| 159 | struct hda_input_mux private_imux[2]; |
| 160 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
| 161 | |
| 162 | /* HP mode source */ |
| 163 | const struct hda_input_mux *hp_mux; |
| 164 | unsigned int hp_independent_mode; |
| 165 | unsigned int hp_independent_mode_index; |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 166 | unsigned int can_smart51; |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 167 | unsigned int smart51_enabled; |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 168 | unsigned int dmic_enabled; |
Takashi Iwai | 24088a5 | 2011-06-17 16:59:21 +0200 | [diff] [blame] | 169 | unsigned int no_pin_power_ctl; |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 170 | enum VIA_HDA_CODEC codec_type; |
| 171 | |
| 172 | /* work to check hp jack state */ |
| 173 | struct hda_codec *codec; |
| 174 | struct delayed_work vt1708_hp_work; |
Takashi Iwai | e06e5a2 | 2011-06-17 15:46:13 +0200 | [diff] [blame] | 175 | int vt1708_jack_detect; |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 176 | int vt1708_hp_present; |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 177 | |
| 178 | void (*set_widgets_power_state)(struct hda_codec *codec); |
| 179 | |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 180 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 181 | struct hda_loopback_check loopback; |
| 182 | #endif |
| 183 | }; |
| 184 | |
Lydia Wang | 0341ccd | 2011-03-22 16:25:03 +0800 | [diff] [blame] | 185 | static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec); |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 186 | static struct via_spec * via_new_spec(struct hda_codec *codec) |
| 187 | { |
| 188 | struct via_spec *spec; |
| 189 | |
| 190 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 191 | if (spec == NULL) |
| 192 | return NULL; |
| 193 | |
| 194 | codec->spec = spec; |
| 195 | spec->codec = codec; |
Lydia Wang | 0341ccd | 2011-03-22 16:25:03 +0800 | [diff] [blame] | 196 | spec->codec_type = get_codec_type(codec); |
| 197 | /* VT1708BCE & VT1708S are almost same */ |
| 198 | if (spec->codec_type == VT1708BCE) |
| 199 | spec->codec_type = VT1708S; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 200 | return spec; |
| 201 | } |
| 202 | |
Lydia Wang | 744ff5f | 2009-10-10 19:07:26 +0800 | [diff] [blame] | 203 | static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec) |
Harald Welte | d742632 | 2008-09-15 22:43:23 +0800 | [diff] [blame] | 204 | { |
Lydia Wang | 744ff5f | 2009-10-10 19:07:26 +0800 | [diff] [blame] | 205 | u32 vendor_id = codec->vendor_id; |
Harald Welte | d742632 | 2008-09-15 22:43:23 +0800 | [diff] [blame] | 206 | u16 ven_id = vendor_id >> 16; |
| 207 | u16 dev_id = vendor_id & 0xffff; |
| 208 | enum VIA_HDA_CODEC codec_type; |
| 209 | |
| 210 | /* get codec type */ |
| 211 | if (ven_id != 0x1106) |
| 212 | codec_type = UNKNOWN; |
| 213 | else if (dev_id >= 0x1708 && dev_id <= 0x170b) |
| 214 | codec_type = VT1708; |
| 215 | else if (dev_id >= 0xe710 && dev_id <= 0xe713) |
| 216 | codec_type = VT1709_10CH; |
| 217 | else if (dev_id >= 0xe714 && dev_id <= 0xe717) |
| 218 | codec_type = VT1709_6CH; |
Lydia Wang | 518bf3b | 2009-10-10 19:07:29 +0800 | [diff] [blame] | 219 | else if (dev_id >= 0xe720 && dev_id <= 0xe723) { |
Harald Welte | d742632 | 2008-09-15 22:43:23 +0800 | [diff] [blame] | 220 | codec_type = VT1708B_8CH; |
Lydia Wang | 518bf3b | 2009-10-10 19:07:29 +0800 | [diff] [blame] | 221 | if (snd_hda_param_read(codec, 0x16, AC_PAR_CONNLIST_LEN) == 0x7) |
| 222 | codec_type = VT1708BCE; |
| 223 | } else if (dev_id >= 0xe724 && dev_id <= 0xe727) |
Harald Welte | d742632 | 2008-09-15 22:43:23 +0800 | [diff] [blame] | 224 | codec_type = VT1708B_4CH; |
| 225 | else if ((dev_id & 0xfff) == 0x397 |
| 226 | && (dev_id >> 12) < 8) |
| 227 | codec_type = VT1708S; |
| 228 | else if ((dev_id & 0xfff) == 0x398 |
| 229 | && (dev_id >> 12) < 8) |
| 230 | codec_type = VT1702; |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 231 | else if ((dev_id & 0xfff) == 0x428 |
| 232 | && (dev_id >> 12) < 8) |
| 233 | codec_type = VT1718S; |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 234 | else if (dev_id == 0x0433 || dev_id == 0xa721) |
| 235 | codec_type = VT1716S; |
Lydia Wang | bb3c6bfc | 2009-10-10 19:08:39 +0800 | [diff] [blame] | 236 | else if (dev_id == 0x0441 || dev_id == 0x4441) |
| 237 | codec_type = VT1718S; |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 238 | else if (dev_id == 0x0438 || dev_id == 0x4438) |
| 239 | codec_type = VT2002P; |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 240 | else if (dev_id == 0x0448) |
| 241 | codec_type = VT1812; |
Lydia Wang | 36dd5c4 | 2009-10-20 13:18:04 +0800 | [diff] [blame] | 242 | else if (dev_id == 0x0440) |
| 243 | codec_type = VT1708S; |
Lydia Wang | 11890956 | 2011-03-23 17:57:34 +0800 | [diff] [blame] | 244 | else if ((dev_id & 0xfff) == 0x446) |
| 245 | codec_type = VT1802; |
Harald Welte | d742632 | 2008-09-15 22:43:23 +0800 | [diff] [blame] | 246 | else |
| 247 | codec_type = UNKNOWN; |
| 248 | return codec_type; |
| 249 | }; |
| 250 | |
Lydia Wang | ec7e7e4 | 2011-03-24 12:43:44 +0800 | [diff] [blame] | 251 | #define VIA_JACK_EVENT 0x20 |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 252 | #define VIA_HP_EVENT 0x01 |
| 253 | #define VIA_GPIO_EVENT 0x02 |
Lydia Wang | ec7e7e4 | 2011-03-24 12:43:44 +0800 | [diff] [blame] | 254 | #define VIA_MONO_EVENT 0x03 |
| 255 | #define VIA_SPEAKER_EVENT 0x04 |
| 256 | #define VIA_BIND_HP_EVENT 0x05 |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 257 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 258 | enum { |
| 259 | VIA_CTL_WIDGET_VOL, |
| 260 | VIA_CTL_WIDGET_MUTE, |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 261 | VIA_CTL_WIDGET_ANALOG_MUTE, |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 262 | VIA_CTL_WIDGET_BIND_PIN_MUTE, |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 263 | }; |
| 264 | |
| 265 | enum { |
Harald Welte | eb14a46 | 2008-09-09 15:40:38 +0800 | [diff] [blame] | 266 | AUTO_SEQ_FRONT = 0, |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 267 | AUTO_SEQ_SURROUND, |
| 268 | AUTO_SEQ_CENLFE, |
| 269 | AUTO_SEQ_SIDE |
| 270 | }; |
| 271 | |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 272 | static void analog_low_current_mode(struct hda_codec *codec, int stream_idle); |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 273 | static int is_aa_path_mute(struct hda_codec *codec); |
| 274 | |
| 275 | static void vt1708_start_hp_work(struct via_spec *spec) |
| 276 | { |
| 277 | if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0) |
| 278 | return; |
| 279 | snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, |
Takashi Iwai | e06e5a2 | 2011-06-17 15:46:13 +0200 | [diff] [blame] | 280 | !spec->vt1708_jack_detect); |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 281 | if (!delayed_work_pending(&spec->vt1708_hp_work)) |
| 282 | schedule_delayed_work(&spec->vt1708_hp_work, |
| 283 | msecs_to_jiffies(100)); |
| 284 | } |
| 285 | |
| 286 | static void vt1708_stop_hp_work(struct via_spec *spec) |
| 287 | { |
| 288 | if (spec->codec_type != VT1708 || spec->autocfg.hp_pins[0] == 0) |
| 289 | return; |
| 290 | if (snd_hda_get_bool_hint(spec->codec, "analog_loopback_hp_detect") == 1 |
| 291 | && !is_aa_path_mute(spec->codec)) |
| 292 | return; |
| 293 | snd_hda_codec_write(spec->codec, 0x1, 0, 0xf81, |
Takashi Iwai | e06e5a2 | 2011-06-17 15:46:13 +0200 | [diff] [blame] | 294 | !spec->vt1708_jack_detect); |
Tejun Heo | 5b84ba2 | 2010-12-11 17:51:26 +0100 | [diff] [blame] | 295 | cancel_delayed_work_sync(&spec->vt1708_hp_work); |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 296 | } |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 297 | |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 298 | static void set_widgets_power_state(struct hda_codec *codec) |
| 299 | { |
| 300 | struct via_spec *spec = codec->spec; |
| 301 | if (spec->set_widgets_power_state) |
| 302 | spec->set_widgets_power_state(codec); |
| 303 | } |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 304 | |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 305 | static int analog_input_switch_put(struct snd_kcontrol *kcontrol, |
| 306 | struct snd_ctl_elem_value *ucontrol) |
| 307 | { |
| 308 | int change = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); |
| 309 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 310 | |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 311 | set_widgets_power_state(codec); |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 312 | analog_low_current_mode(snd_kcontrol_chip(kcontrol), -1); |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 313 | if (snd_hda_get_bool_hint(codec, "analog_loopback_hp_detect") == 1) { |
| 314 | if (is_aa_path_mute(codec)) |
| 315 | vt1708_start_hp_work(codec->spec); |
| 316 | else |
| 317 | vt1708_stop_hp_work(codec->spec); |
| 318 | } |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 319 | return change; |
| 320 | } |
| 321 | |
| 322 | /* modify .put = snd_hda_mixer_amp_switch_put */ |
| 323 | #define ANALOG_INPUT_MUTE \ |
| 324 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 325 | .name = NULL, \ |
| 326 | .index = 0, \ |
| 327 | .info = snd_hda_mixer_amp_switch_info, \ |
| 328 | .get = snd_hda_mixer_amp_switch_get, \ |
| 329 | .put = analog_input_switch_put, \ |
| 330 | .private_value = HDA_COMPOSE_AMP_VAL(0, 3, 0, 0) } |
| 331 | |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 332 | static void via_hp_bind_automute(struct hda_codec *codec); |
| 333 | |
| 334 | static int bind_pin_switch_put(struct snd_kcontrol *kcontrol, |
| 335 | struct snd_ctl_elem_value *ucontrol) |
| 336 | { |
| 337 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 338 | struct via_spec *spec = codec->spec; |
| 339 | int i; |
| 340 | int change = 0; |
| 341 | |
| 342 | long *valp = ucontrol->value.integer.value; |
| 343 | int lmute, rmute; |
| 344 | if (strstr(kcontrol->id.name, "Switch") == NULL) { |
| 345 | snd_printd("Invalid control!\n"); |
| 346 | return change; |
| 347 | } |
| 348 | change = snd_hda_mixer_amp_switch_put(kcontrol, |
| 349 | ucontrol); |
| 350 | /* Get mute value */ |
| 351 | lmute = *valp ? 0 : HDA_AMP_MUTE; |
| 352 | valp++; |
| 353 | rmute = *valp ? 0 : HDA_AMP_MUTE; |
| 354 | |
| 355 | /* Set hp pins */ |
| 356 | if (!spec->hp_independent_mode) { |
| 357 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 358 | snd_hda_codec_amp_update( |
| 359 | codec, spec->autocfg.hp_pins[i], |
| 360 | 0, HDA_OUTPUT, 0, HDA_AMP_MUTE, |
| 361 | lmute); |
| 362 | snd_hda_codec_amp_update( |
| 363 | codec, spec->autocfg.hp_pins[i], |
| 364 | 1, HDA_OUTPUT, 0, HDA_AMP_MUTE, |
| 365 | rmute); |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | if (!lmute && !rmute) { |
| 370 | /* Line Outs */ |
| 371 | for (i = 0; i < spec->autocfg.line_outs; i++) |
| 372 | snd_hda_codec_amp_stereo( |
| 373 | codec, spec->autocfg.line_out_pins[i], |
| 374 | HDA_OUTPUT, 0, HDA_AMP_MUTE, 0); |
| 375 | /* Speakers */ |
| 376 | for (i = 0; i < spec->autocfg.speaker_outs; i++) |
| 377 | snd_hda_codec_amp_stereo( |
| 378 | codec, spec->autocfg.speaker_pins[i], |
| 379 | HDA_OUTPUT, 0, HDA_AMP_MUTE, 0); |
| 380 | /* unmute */ |
| 381 | via_hp_bind_automute(codec); |
| 382 | |
| 383 | } else { |
| 384 | if (lmute) { |
| 385 | /* Mute all left channels */ |
| 386 | for (i = 1; i < spec->autocfg.line_outs; i++) |
| 387 | snd_hda_codec_amp_update( |
| 388 | codec, |
| 389 | spec->autocfg.line_out_pins[i], |
| 390 | 0, HDA_OUTPUT, 0, HDA_AMP_MUTE, |
| 391 | lmute); |
| 392 | for (i = 0; i < spec->autocfg.speaker_outs; i++) |
| 393 | snd_hda_codec_amp_update( |
| 394 | codec, |
| 395 | spec->autocfg.speaker_pins[i], |
| 396 | 0, HDA_OUTPUT, 0, HDA_AMP_MUTE, |
| 397 | lmute); |
| 398 | } |
| 399 | if (rmute) { |
| 400 | /* mute all right channels */ |
| 401 | for (i = 1; i < spec->autocfg.line_outs; i++) |
| 402 | snd_hda_codec_amp_update( |
| 403 | codec, |
| 404 | spec->autocfg.line_out_pins[i], |
| 405 | 1, HDA_OUTPUT, 0, HDA_AMP_MUTE, |
| 406 | rmute); |
| 407 | for (i = 0; i < spec->autocfg.speaker_outs; i++) |
| 408 | snd_hda_codec_amp_update( |
| 409 | codec, |
| 410 | spec->autocfg.speaker_pins[i], |
| 411 | 1, HDA_OUTPUT, 0, HDA_AMP_MUTE, |
| 412 | rmute); |
| 413 | } |
| 414 | } |
| 415 | return change; |
| 416 | } |
| 417 | |
| 418 | #define BIND_PIN_MUTE \ |
| 419 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 420 | .name = NULL, \ |
| 421 | .index = 0, \ |
| 422 | .info = snd_hda_mixer_amp_switch_info, \ |
| 423 | .get = snd_hda_mixer_amp_switch_get, \ |
| 424 | .put = bind_pin_switch_put, \ |
| 425 | .private_value = HDA_COMPOSE_AMP_VAL(0, 3, 0, 0) } |
| 426 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 427 | static const struct snd_kcontrol_new via_control_templates[] = { |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 428 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 429 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 430 | ANALOG_INPUT_MUTE, |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 431 | BIND_PIN_MUTE, |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 432 | }; |
| 433 | |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 434 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 435 | /* add dynamic controls */ |
Takashi Iwai | 291c9e3 | 2011-06-17 16:15:26 +0200 | [diff] [blame] | 436 | static struct snd_kcontrol_new *__via_clone_ctl(struct via_spec *spec, |
| 437 | const struct snd_kcontrol_new *tmpl, |
| 438 | const char *name) |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 439 | { |
| 440 | struct snd_kcontrol_new *knew; |
| 441 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 442 | snd_array_init(&spec->kctls, sizeof(*knew), 32); |
| 443 | knew = snd_array_new(&spec->kctls); |
| 444 | if (!knew) |
Takashi Iwai | 291c9e3 | 2011-06-17 16:15:26 +0200 | [diff] [blame] | 445 | return NULL; |
| 446 | *knew = *tmpl; |
| 447 | if (!name) |
| 448 | name = tmpl->name; |
| 449 | if (name) { |
| 450 | knew->name = kstrdup(name, GFP_KERNEL); |
| 451 | if (!knew->name) |
| 452 | return NULL; |
| 453 | } |
| 454 | return knew; |
| 455 | } |
| 456 | |
| 457 | static int __via_add_control(struct via_spec *spec, int type, const char *name, |
| 458 | int idx, unsigned long val) |
| 459 | { |
| 460 | struct snd_kcontrol_new *knew; |
| 461 | |
| 462 | knew = __via_clone_ctl(spec, &via_control_templates[type], name); |
| 463 | if (!knew) |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 464 | return -ENOMEM; |
Takashi Iwai | d7a99cc | 2011-06-18 17:24:46 +0200 | [diff] [blame] | 465 | knew->index = idx; |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 466 | if (get_amp_nid_(val)) |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 467 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 468 | knew->private_value = val; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 469 | return 0; |
| 470 | } |
| 471 | |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 472 | #define via_add_control(spec, type, name, val) \ |
| 473 | __via_add_control(spec, type, name, 0, val) |
| 474 | |
Takashi Iwai | 291c9e3 | 2011-06-17 16:15:26 +0200 | [diff] [blame] | 475 | #define via_clone_control(spec, tmpl) __via_clone_ctl(spec, tmpl, NULL) |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 476 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 477 | static void via_free_kctls(struct hda_codec *codec) |
| 478 | { |
| 479 | struct via_spec *spec = codec->spec; |
| 480 | |
| 481 | if (spec->kctls.list) { |
| 482 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 483 | int i; |
| 484 | for (i = 0; i < spec->kctls.used; i++) |
| 485 | kfree(kctl[i].name); |
| 486 | } |
| 487 | snd_array_free(&spec->kctls); |
| 488 | } |
| 489 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 490 | /* create input playback/capture controls for the given pin */ |
Lydia Wang | 9510e8d | 2009-10-10 19:07:39 +0800 | [diff] [blame] | 491 | static int via_new_analog_input(struct via_spec *spec, const char *ctlname, |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 492 | int type_idx, int idx, int mix_nid) |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 493 | { |
| 494 | char name[32]; |
| 495 | int err; |
| 496 | |
| 497 | sprintf(name, "%s Playback Volume", ctlname); |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 498 | err = __via_add_control(spec, VIA_CTL_WIDGET_VOL, name, type_idx, |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 499 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
| 500 | if (err < 0) |
| 501 | return err; |
| 502 | sprintf(name, "%s Playback Switch", ctlname); |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 503 | err = __via_add_control(spec, VIA_CTL_WIDGET_ANALOG_MUTE, name, type_idx, |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 504 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
| 505 | if (err < 0) |
| 506 | return err; |
| 507 | return 0; |
| 508 | } |
| 509 | |
| 510 | static void via_auto_set_output_and_unmute(struct hda_codec *codec, |
| 511 | hda_nid_t nid, int pin_type, |
| 512 | int dac_idx) |
| 513 | { |
| 514 | /* set as output */ |
| 515 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 516 | pin_type); |
| 517 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 518 | AMP_OUT_UNMUTE); |
Takashi Iwai | d3a11e6 | 2009-07-07 13:43:35 +0200 | [diff] [blame] | 519 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) |
Lydia Wang | 377ff31 | 2009-10-10 19:08:55 +0800 | [diff] [blame] | 520 | snd_hda_codec_write(codec, nid, 0, |
Takashi Iwai | d3a11e6 | 2009-07-07 13:43:35 +0200 | [diff] [blame] | 521 | AC_VERB_SET_EAPD_BTLENABLE, 0x02); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | |
| 525 | static void via_auto_init_multi_out(struct hda_codec *codec) |
| 526 | { |
| 527 | struct via_spec *spec = codec->spec; |
| 528 | int i; |
| 529 | |
| 530 | for (i = 0; i <= AUTO_SEQ_SIDE; i++) { |
| 531 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 532 | if (nid) |
| 533 | via_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | static void via_auto_init_hp_out(struct hda_codec *codec) |
| 538 | { |
| 539 | struct via_spec *spec = codec->spec; |
| 540 | hda_nid_t pin; |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 541 | int i; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 542 | |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 543 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 544 | pin = spec->autocfg.hp_pins[i]; |
| 545 | if (pin) /* connect to front */ |
| 546 | via_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); |
| 547 | } |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 548 | } |
| 549 | |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 550 | static bool is_smart51_pins(struct hda_codec *codec, hda_nid_t pin); |
Clemens Ladisch | 32e0191 | 2010-07-12 16:28:50 +0200 | [diff] [blame] | 551 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 552 | static void via_auto_init_analog_input(struct hda_codec *codec) |
| 553 | { |
| 554 | struct via_spec *spec = codec->spec; |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 555 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
Clemens Ladisch | 32e0191 | 2010-07-12 16:28:50 +0200 | [diff] [blame] | 556 | unsigned int ctl; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 557 | int i; |
| 558 | |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 559 | for (i = 0; i < cfg->num_inputs; i++) { |
| 560 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 561 | if (spec->smart51_enabled && is_smart51_pins(codec, nid)) |
Clemens Ladisch | 32e0191 | 2010-07-12 16:28:50 +0200 | [diff] [blame] | 562 | ctl = PIN_OUT; |
David Henningsson | 3064967 | 2011-02-21 10:23:18 +0100 | [diff] [blame] | 563 | else if (cfg->inputs[i].type == AUTO_PIN_MIC) |
Clemens Ladisch | 32e0191 | 2010-07-12 16:28:50 +0200 | [diff] [blame] | 564 | ctl = PIN_VREF50; |
| 565 | else |
| 566 | ctl = PIN_IN; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 567 | snd_hda_codec_write(codec, nid, 0, |
Clemens Ladisch | 32e0191 | 2010-07-12 16:28:50 +0200 | [diff] [blame] | 568 | AC_VERB_SET_PIN_WIDGET_CONTROL, ctl); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 569 | } |
| 570 | } |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 571 | |
| 572 | static void set_pin_power_state(struct hda_codec *codec, hda_nid_t nid, |
| 573 | unsigned int *affected_parm) |
| 574 | { |
| 575 | unsigned parm; |
| 576 | unsigned def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 577 | unsigned no_presence = (def_conf & AC_DEFCFG_MISC) |
| 578 | >> AC_DEFCFG_MISC_SHIFT |
| 579 | & AC_DEFCFG_MISC_NO_PRESENCE; /* do not support pin sense */ |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 580 | struct via_spec *spec = codec->spec; |
Takashi Iwai | 24088a5 | 2011-06-17 16:59:21 +0200 | [diff] [blame] | 581 | unsigned present = 0; |
| 582 | |
| 583 | no_presence |= spec->no_pin_power_ctl; |
| 584 | if (!no_presence) |
| 585 | present = snd_hda_jack_detect(codec, nid); |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 586 | if ((spec->smart51_enabled && is_smart51_pins(codec, nid)) |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 587 | || ((no_presence || present) |
| 588 | && get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)) { |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 589 | *affected_parm = AC_PWRST_D0; /* if it's connected */ |
| 590 | parm = AC_PWRST_D0; |
| 591 | } else |
| 592 | parm = AC_PWRST_D3; |
| 593 | |
| 594 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, parm); |
| 595 | } |
| 596 | |
Takashi Iwai | 24088a5 | 2011-06-17 16:59:21 +0200 | [diff] [blame] | 597 | static int via_pin_power_ctl_info(struct snd_kcontrol *kcontrol, |
| 598 | struct snd_ctl_elem_info *uinfo) |
| 599 | { |
| 600 | static const char * const texts[] = { |
| 601 | "Disabled", "Enabled" |
| 602 | }; |
| 603 | |
| 604 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 605 | uinfo->count = 1; |
| 606 | uinfo->value.enumerated.items = 2; |
| 607 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) |
| 608 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; |
| 609 | strcpy(uinfo->value.enumerated.name, |
| 610 | texts[uinfo->value.enumerated.item]); |
| 611 | return 0; |
| 612 | } |
| 613 | |
| 614 | static int via_pin_power_ctl_get(struct snd_kcontrol *kcontrol, |
| 615 | struct snd_ctl_elem_value *ucontrol) |
| 616 | { |
| 617 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 618 | struct via_spec *spec = codec->spec; |
| 619 | ucontrol->value.enumerated.item[0] = !spec->no_pin_power_ctl; |
| 620 | return 0; |
| 621 | } |
| 622 | |
| 623 | static int via_pin_power_ctl_put(struct snd_kcontrol *kcontrol, |
| 624 | struct snd_ctl_elem_value *ucontrol) |
| 625 | { |
| 626 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 627 | struct via_spec *spec = codec->spec; |
| 628 | unsigned int val = !ucontrol->value.enumerated.item[0]; |
| 629 | |
| 630 | if (val == spec->no_pin_power_ctl) |
| 631 | return 0; |
| 632 | spec->no_pin_power_ctl = val; |
| 633 | set_widgets_power_state(codec); |
| 634 | return 1; |
| 635 | } |
| 636 | |
| 637 | static const struct snd_kcontrol_new via_pin_power_ctl_enum = { |
| 638 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 639 | .name = "Dynamic Power-Control", |
| 640 | .info = via_pin_power_ctl_info, |
| 641 | .get = via_pin_power_ctl_get, |
| 642 | .put = via_pin_power_ctl_put, |
| 643 | }; |
| 644 | |
| 645 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 646 | /* |
| 647 | * input MUX handling |
| 648 | */ |
| 649 | static int via_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 650 | struct snd_ctl_elem_info *uinfo) |
| 651 | { |
| 652 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 653 | struct via_spec *spec = codec->spec; |
| 654 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
| 655 | } |
| 656 | |
| 657 | static int via_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 658 | struct snd_ctl_elem_value *ucontrol) |
| 659 | { |
| 660 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 661 | struct via_spec *spec = codec->spec; |
| 662 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 663 | |
| 664 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 665 | return 0; |
| 666 | } |
| 667 | |
| 668 | static int via_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 669 | struct snd_ctl_elem_value *ucontrol) |
| 670 | { |
| 671 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 672 | struct via_spec *spec = codec->spec; |
| 673 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Lydia Wang | bff5fbf | 2011-03-22 16:21:38 +0800 | [diff] [blame] | 674 | int ret; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 675 | |
Takashi Iwai | 337b9d0 | 2009-07-07 18:18:59 +0200 | [diff] [blame] | 676 | if (!spec->mux_nids[adc_idx]) |
| 677 | return -EINVAL; |
Lydia Wang | a80e6e3 | 2009-10-10 19:07:55 +0800 | [diff] [blame] | 678 | /* switch to D0 beofre change index */ |
| 679 | if (snd_hda_codec_read(codec, spec->mux_nids[adc_idx], 0, |
| 680 | AC_VERB_GET_POWER_STATE, 0x00) != AC_PWRST_D0) |
| 681 | snd_hda_codec_write(codec, spec->mux_nids[adc_idx], 0, |
| 682 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
Lydia Wang | bff5fbf | 2011-03-22 16:21:38 +0800 | [diff] [blame] | 683 | |
| 684 | ret = snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
| 685 | spec->mux_nids[adc_idx], |
| 686 | &spec->cur_mux[adc_idx]); |
Lydia Wang | a80e6e3 | 2009-10-10 19:07:55 +0800 | [diff] [blame] | 687 | /* update jack power state */ |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 688 | set_widgets_power_state(codec); |
Lydia Wang | a80e6e3 | 2009-10-10 19:07:55 +0800 | [diff] [blame] | 689 | |
Lydia Wang | bff5fbf | 2011-03-22 16:21:38 +0800 | [diff] [blame] | 690 | return ret; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 691 | } |
| 692 | |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 693 | static int via_independent_hp_info(struct snd_kcontrol *kcontrol, |
| 694 | struct snd_ctl_elem_info *uinfo) |
| 695 | { |
| 696 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 697 | struct via_spec *spec = codec->spec; |
| 698 | return snd_hda_input_mux_info(spec->hp_mux, uinfo); |
| 699 | } |
| 700 | |
| 701 | static int via_independent_hp_get(struct snd_kcontrol *kcontrol, |
| 702 | struct snd_ctl_elem_value *ucontrol) |
| 703 | { |
| 704 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 705 | hda_nid_t nid = kcontrol->private_value; |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 706 | unsigned int pinsel; |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 707 | |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 708 | /* use !! to translate conn sel 2 for VT1718S */ |
| 709 | pinsel = !!snd_hda_codec_read(codec, nid, 0, |
| 710 | AC_VERB_GET_CONNECT_SEL, |
| 711 | 0x00); |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 712 | ucontrol->value.enumerated.item[0] = pinsel; |
| 713 | |
| 714 | return 0; |
| 715 | } |
| 716 | |
Lydia Wang | 0713efe | 2009-10-10 19:07:43 +0800 | [diff] [blame] | 717 | static void activate_ctl(struct hda_codec *codec, const char *name, int active) |
| 718 | { |
| 719 | struct snd_kcontrol *ctl = snd_hda_find_mixer_ctl(codec, name); |
| 720 | if (ctl) { |
| 721 | ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; |
| 722 | ctl->vd[0].access |= active |
| 723 | ? 0 : SNDRV_CTL_ELEM_ACCESS_INACTIVE; |
| 724 | snd_ctl_notify(codec->bus->card, |
| 725 | SNDRV_CTL_EVENT_MASK_VALUE, &ctl->id); |
| 726 | } |
| 727 | } |
| 728 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 729 | static hda_nid_t side_mute_channel(struct via_spec *spec) |
| 730 | { |
| 731 | switch (spec->codec_type) { |
| 732 | case VT1708: return 0x1b; |
| 733 | case VT1709_10CH: return 0x29; |
| 734 | case VT1708B_8CH: /* fall thru */ |
| 735 | case VT1708S: return 0x27; |
Lydia Wang | e87885f | 2011-03-24 12:39:05 +0800 | [diff] [blame] | 736 | case VT2002P: return 0x19; |
| 737 | case VT1802: return 0x15; |
| 738 | case VT1812: return 0x15; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 739 | default: return 0; |
| 740 | } |
| 741 | } |
| 742 | |
Lydia Wang | cdc1784 | 2009-10-10 19:07:47 +0800 | [diff] [blame] | 743 | static int update_side_mute_status(struct hda_codec *codec) |
| 744 | { |
| 745 | /* mute side channel */ |
| 746 | struct via_spec *spec = codec->spec; |
Lydia Wang | e87885f | 2011-03-24 12:39:05 +0800 | [diff] [blame] | 747 | unsigned int parm; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 748 | hda_nid_t sw3 = side_mute_channel(spec); |
Lydia Wang | cdc1784 | 2009-10-10 19:07:47 +0800 | [diff] [blame] | 749 | |
Lydia Wang | e87885f | 2011-03-24 12:39:05 +0800 | [diff] [blame] | 750 | if (sw3) { |
| 751 | if (VT2002P_COMPATIBLE(spec)) |
| 752 | parm = spec->hp_independent_mode ? |
| 753 | AMP_IN_MUTE(1) : AMP_IN_UNMUTE(1); |
| 754 | else |
| 755 | parm = spec->hp_independent_mode ? |
| 756 | AMP_OUT_MUTE : AMP_OUT_UNMUTE; |
| 757 | snd_hda_codec_write(codec, sw3, 0, |
| 758 | AC_VERB_SET_AMP_GAIN_MUTE, parm); |
| 759 | if (spec->codec_type == VT1812) |
| 760 | snd_hda_codec_write(codec, 0x1d, 0, |
| 761 | AC_VERB_SET_AMP_GAIN_MUTE, parm); |
| 762 | } |
Lydia Wang | cdc1784 | 2009-10-10 19:07:47 +0800 | [diff] [blame] | 763 | return 0; |
| 764 | } |
| 765 | |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 766 | static int via_independent_hp_put(struct snd_kcontrol *kcontrol, |
| 767 | struct snd_ctl_elem_value *ucontrol) |
| 768 | { |
| 769 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 770 | struct via_spec *spec = codec->spec; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 771 | hda_nid_t nid = kcontrol->private_value; |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 772 | unsigned int pinsel = ucontrol->value.enumerated.item[0]; |
Lydia Wang | cdc1784 | 2009-10-10 19:07:47 +0800 | [diff] [blame] | 773 | /* Get Independent Mode index of headphone pin widget */ |
| 774 | spec->hp_independent_mode = spec->hp_independent_mode_index == pinsel |
| 775 | ? 1 : 0; |
Lydia Wang | ce0e5a9 | 2011-03-22 16:22:37 +0800 | [diff] [blame] | 776 | if (spec->codec_type == VT1718S) |
| 777 | snd_hda_codec_write(codec, nid, 0, |
| 778 | AC_VERB_SET_CONNECT_SEL, pinsel ? 2 : 0); |
| 779 | else |
| 780 | snd_hda_codec_write(codec, nid, 0, |
| 781 | AC_VERB_SET_CONNECT_SEL, pinsel); |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 782 | |
Lydia Wang | ce0e5a9 | 2011-03-22 16:22:37 +0800 | [diff] [blame] | 783 | if (spec->codec_type == VT1812) |
| 784 | snd_hda_codec_write(codec, 0x35, 0, |
| 785 | AC_VERB_SET_CONNECT_SEL, pinsel); |
Lydia Wang | cdc1784 | 2009-10-10 19:07:47 +0800 | [diff] [blame] | 786 | if (spec->multiout.hp_nid && spec->multiout.hp_nid |
| 787 | != spec->multiout.dac_nids[HDA_FRONT]) |
| 788 | snd_hda_codec_setup_stream(codec, spec->multiout.hp_nid, |
| 789 | 0, 0, 0); |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 790 | |
Lydia Wang | cdc1784 | 2009-10-10 19:07:47 +0800 | [diff] [blame] | 791 | update_side_mute_status(codec); |
Lydia Wang | 0713efe | 2009-10-10 19:07:43 +0800 | [diff] [blame] | 792 | /* update HP volume/swtich active state */ |
| 793 | if (spec->codec_type == VT1708S |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 794 | || spec->codec_type == VT1702 |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 795 | || spec->codec_type == VT1718S |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 796 | || spec->codec_type == VT1716S |
Lydia Wang | 11890956 | 2011-03-23 17:57:34 +0800 | [diff] [blame] | 797 | || VT2002P_COMPATIBLE(spec)) { |
Lydia Wang | 0713efe | 2009-10-10 19:07:43 +0800 | [diff] [blame] | 798 | activate_ctl(codec, "Headphone Playback Volume", |
| 799 | spec->hp_independent_mode); |
| 800 | activate_ctl(codec, "Headphone Playback Switch", |
| 801 | spec->hp_independent_mode); |
| 802 | } |
Lydia Wang | ce0e5a9 | 2011-03-22 16:22:37 +0800 | [diff] [blame] | 803 | /* update jack power state */ |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 804 | set_widgets_power_state(codec); |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 805 | return 0; |
| 806 | } |
| 807 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 808 | static const struct snd_kcontrol_new via_hp_mixer[2] = { |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 809 | { |
| 810 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 811 | .name = "Independent HP", |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 812 | .info = via_independent_hp_info, |
| 813 | .get = via_independent_hp_get, |
| 814 | .put = via_independent_hp_put, |
| 815 | }, |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 816 | { |
| 817 | .iface = NID_MAPPING, |
| 818 | .name = "Independent HP", |
| 819 | }, |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 820 | }; |
| 821 | |
Takashi Iwai | 3d83e57 | 2010-04-14 14:36:23 +0200 | [diff] [blame] | 822 | static int via_hp_build(struct hda_codec *codec) |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 823 | { |
Takashi Iwai | 3d83e57 | 2010-04-14 14:36:23 +0200 | [diff] [blame] | 824 | struct via_spec *spec = codec->spec; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 825 | struct snd_kcontrol_new *knew; |
| 826 | hda_nid_t nid; |
Takashi Iwai | 3d83e57 | 2010-04-14 14:36:23 +0200 | [diff] [blame] | 827 | int nums; |
| 828 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 829 | |
| 830 | switch (spec->codec_type) { |
| 831 | case VT1718S: |
| 832 | nid = 0x34; |
| 833 | break; |
| 834 | case VT2002P: |
Lydia Wang | 11890956 | 2011-03-23 17:57:34 +0800 | [diff] [blame] | 835 | case VT1802: |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 836 | nid = 0x35; |
| 837 | break; |
| 838 | case VT1812: |
| 839 | nid = 0x3d; |
| 840 | break; |
| 841 | default: |
| 842 | nid = spec->autocfg.hp_pins[0]; |
| 843 | break; |
| 844 | } |
| 845 | |
Lydia Wang | ee3c35c | 2011-03-22 16:26:36 +0800 | [diff] [blame] | 846 | if (spec->codec_type != VT1708) { |
| 847 | nums = snd_hda_get_connections(codec, nid, |
| 848 | conn, HDA_MAX_CONNECTIONS); |
| 849 | if (nums <= 1) |
| 850 | return 0; |
| 851 | } |
Takashi Iwai | 3d83e57 | 2010-04-14 14:36:23 +0200 | [diff] [blame] | 852 | |
| 853 | knew = via_clone_control(spec, &via_hp_mixer[0]); |
| 854 | if (knew == NULL) |
| 855 | return -ENOMEM; |
| 856 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 857 | knew->subdevice = HDA_SUBDEV_NID_FLAG | nid; |
| 858 | knew->private_value = nid; |
| 859 | |
| 860 | knew = via_clone_control(spec, &via_hp_mixer[1]); |
| 861 | if (knew == NULL) |
| 862 | return -ENOMEM; |
| 863 | knew->subdevice = side_mute_channel(spec); |
| 864 | |
| 865 | return 0; |
| 866 | } |
| 867 | |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 868 | static void notify_aa_path_ctls(struct hda_codec *codec) |
| 869 | { |
| 870 | int i; |
| 871 | struct snd_ctl_elem_id id; |
Lydia Wang | 525566c | 2011-04-28 16:03:39 +0800 | [diff] [blame] | 872 | const char *labels[] = {"Mic", "Front Mic", "Line", "Rear Mic"}; |
| 873 | struct snd_kcontrol *ctl; |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 874 | |
| 875 | memset(&id, 0, sizeof(id)); |
| 876 | id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
| 877 | for (i = 0; i < ARRAY_SIZE(labels); i++) { |
| 878 | sprintf(id.name, "%s Playback Volume", labels[i]); |
Lydia Wang | 525566c | 2011-04-28 16:03:39 +0800 | [diff] [blame] | 879 | ctl = snd_hda_find_mixer_ctl(codec, id.name); |
| 880 | if (ctl) |
| 881 | snd_ctl_notify(codec->bus->card, |
| 882 | SNDRV_CTL_EVENT_MASK_VALUE, |
| 883 | &ctl->id); |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 884 | } |
| 885 | } |
| 886 | |
| 887 | static void mute_aa_path(struct hda_codec *codec, int mute) |
| 888 | { |
| 889 | struct via_spec *spec = codec->spec; |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 890 | int start_idx; |
| 891 | int end_idx; |
| 892 | int i; |
| 893 | /* get nid of MW0 and start & end index */ |
| 894 | switch (spec->codec_type) { |
| 895 | case VT1708: |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 896 | start_idx = 2; |
| 897 | end_idx = 4; |
| 898 | break; |
| 899 | case VT1709_10CH: |
| 900 | case VT1709_6CH: |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 901 | start_idx = 2; |
| 902 | end_idx = 4; |
| 903 | break; |
| 904 | case VT1708B_8CH: |
| 905 | case VT1708B_4CH: |
| 906 | case VT1708S: |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 907 | case VT1716S: |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 908 | start_idx = 2; |
| 909 | end_idx = 4; |
| 910 | break; |
Lydia Wang | ab657e0 | 2011-03-22 16:23:23 +0800 | [diff] [blame] | 911 | case VT1718S: |
Lydia Wang | ab657e0 | 2011-03-22 16:23:23 +0800 | [diff] [blame] | 912 | start_idx = 1; |
| 913 | end_idx = 3; |
| 914 | break; |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 915 | default: |
| 916 | return; |
| 917 | } |
| 918 | /* check AA path's mute status */ |
| 919 | for (i = start_idx; i <= end_idx; i++) { |
| 920 | int val = mute ? HDA_AMP_MUTE : HDA_AMP_UNMUTE; |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 921 | snd_hda_codec_amp_stereo(codec, spec->aa_mix_nid, HDA_INPUT, i, |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 922 | HDA_AMP_MUTE, val); |
| 923 | } |
| 924 | } |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 925 | |
| 926 | static bool is_smart51_pins(struct hda_codec *codec, hda_nid_t pin) |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 927 | { |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 928 | struct via_spec *spec = codec->spec; |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 929 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
| 930 | int i; |
| 931 | |
| 932 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 933 | unsigned int defcfg; |
| 934 | if (pin != cfg->inputs[i].pin) |
| 935 | continue; |
| 936 | if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) |
| 937 | return false; |
| 938 | defcfg = snd_hda_codec_get_pincfg(codec, pin); |
| 939 | if (snd_hda_get_input_pin_attr(defcfg) < INPUT_PIN_ATTR_NORMAL) |
| 940 | return false; |
| 941 | return true; |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 942 | } |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 943 | return false; |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 944 | } |
| 945 | |
| 946 | static int via_smart51_info(struct snd_kcontrol *kcontrol, |
| 947 | struct snd_ctl_elem_info *uinfo) |
| 948 | { |
| 949 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
| 950 | uinfo->count = 1; |
| 951 | uinfo->value.integer.min = 0; |
| 952 | uinfo->value.integer.max = 1; |
| 953 | return 0; |
| 954 | } |
| 955 | |
| 956 | static int via_smart51_get(struct snd_kcontrol *kcontrol, |
| 957 | struct snd_ctl_elem_value *ucontrol) |
| 958 | { |
| 959 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 960 | struct via_spec *spec = codec->spec; |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 961 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 962 | int on = 1; |
| 963 | int i; |
| 964 | |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 965 | for (i = 0; i < cfg->num_inputs; i++) { |
| 966 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 967 | unsigned int ctl; |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 968 | if (cfg->inputs[i].type == AUTO_PIN_MIC && |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 969 | spec->hp_independent_mode && spec->codec_type != VT1718S) |
| 970 | continue; /* ignore FMic for independent HP */ |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 971 | if (!is_smart51_pins(codec, nid)) |
| 972 | continue; |
| 973 | ctl = snd_hda_codec_read(codec, nid, 0, |
| 974 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 975 | if ((ctl & AC_PINCTL_IN_EN) && !(ctl & AC_PINCTL_OUT_EN)) |
| 976 | on = 0; |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 977 | } |
| 978 | *ucontrol->value.integer.value = on; |
| 979 | return 0; |
| 980 | } |
| 981 | |
| 982 | static int via_smart51_put(struct snd_kcontrol *kcontrol, |
| 983 | struct snd_ctl_elem_value *ucontrol) |
| 984 | { |
| 985 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 986 | struct via_spec *spec = codec->spec; |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 987 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 988 | int out_in = *ucontrol->value.integer.value |
| 989 | ? AC_PINCTL_OUT_EN : AC_PINCTL_IN_EN; |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 990 | int i; |
| 991 | |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 992 | for (i = 0; i < cfg->num_inputs; i++) { |
| 993 | hda_nid_t nid = cfg->inputs[i].pin; |
| 994 | unsigned int parm; |
| 995 | |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 996 | if (cfg->inputs[i].type == AUTO_PIN_MIC && |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 997 | spec->hp_independent_mode && spec->codec_type != VT1718S) |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 998 | continue; /* don't retask FMic for independent HP */ |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 999 | if (!is_smart51_pins(codec, nid)) |
| 1000 | continue; |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 1001 | |
| 1002 | parm = snd_hda_codec_read(codec, nid, 0, |
| 1003 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 1004 | parm &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 1005 | parm |= out_in; |
| 1006 | snd_hda_codec_write(codec, nid, 0, |
| 1007 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1008 | parm); |
| 1009 | if (out_in == AC_PINCTL_OUT_EN) { |
| 1010 | mute_aa_path(codec, 1); |
| 1011 | notify_aa_path_ctls(codec); |
| 1012 | } |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 1013 | } |
| 1014 | spec->smart51_enabled = *ucontrol->value.integer.value; |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 1015 | set_widgets_power_state(codec); |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 1016 | return 1; |
| 1017 | } |
| 1018 | |
Takashi Iwai | 5f4b36d | 2011-06-17 14:55:02 +0200 | [diff] [blame] | 1019 | static const struct snd_kcontrol_new via_smart51_mixer = { |
| 1020 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1021 | .name = "Smart 5.1", |
| 1022 | .count = 1, |
| 1023 | .info = via_smart51_info, |
| 1024 | .get = via_smart51_get, |
| 1025 | .put = via_smart51_put, |
Lydia Wang | 1564b28 | 2009-10-10 19:07:52 +0800 | [diff] [blame] | 1026 | }; |
| 1027 | |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 1028 | static int via_smart51_build(struct hda_codec *codec) |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1029 | { |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 1030 | struct via_spec *spec = codec->spec; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1031 | struct snd_kcontrol_new *knew; |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 1032 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1033 | hda_nid_t nid; |
| 1034 | int i; |
| 1035 | |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 1036 | if (!spec->can_smart51) |
Lydia Wang | cb34c20 | 2011-04-27 17:44:16 +0800 | [diff] [blame] | 1037 | return 0; |
| 1038 | |
Takashi Iwai | 5f4b36d | 2011-06-17 14:55:02 +0200 | [diff] [blame] | 1039 | knew = via_clone_control(spec, &via_smart51_mixer); |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1040 | if (knew == NULL) |
| 1041 | return -ENOMEM; |
| 1042 | |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 1043 | for (i = 0; i < cfg->num_inputs; i++) { |
| 1044 | nid = cfg->inputs[i].pin; |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 1045 | if (is_smart51_pins(codec, nid)) { |
Takashi Iwai | 5f4b36d | 2011-06-17 14:55:02 +0200 | [diff] [blame] | 1046 | knew->subdevice = HDA_SUBDEV_NID_FLAG | nid; |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 1047 | break; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1048 | } |
| 1049 | } |
| 1050 | |
| 1051 | return 0; |
| 1052 | } |
| 1053 | |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 1054 | /* check AA path's mute statue */ |
| 1055 | static int is_aa_path_mute(struct hda_codec *codec) |
| 1056 | { |
| 1057 | int mute = 1; |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 1058 | int start_idx; |
| 1059 | int end_idx; |
| 1060 | int i; |
| 1061 | struct via_spec *spec = codec->spec; |
| 1062 | /* get nid of MW0 and start & end index */ |
| 1063 | switch (spec->codec_type) { |
| 1064 | case VT1708B_8CH: |
| 1065 | case VT1708B_4CH: |
| 1066 | case VT1708S: |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 1067 | case VT1716S: |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 1068 | start_idx = 2; |
| 1069 | end_idx = 4; |
| 1070 | break; |
| 1071 | case VT1702: |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 1072 | start_idx = 1; |
| 1073 | end_idx = 3; |
| 1074 | break; |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 1075 | case VT1718S: |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 1076 | start_idx = 1; |
| 1077 | end_idx = 3; |
| 1078 | break; |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 1079 | case VT2002P: |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 1080 | case VT1812: |
Lydia Wang | 11890956 | 2011-03-23 17:57:34 +0800 | [diff] [blame] | 1081 | case VT1802: |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 1082 | start_idx = 0; |
| 1083 | end_idx = 2; |
| 1084 | break; |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 1085 | default: |
| 1086 | return 0; |
| 1087 | } |
| 1088 | /* check AA path's mute status */ |
| 1089 | for (i = start_idx; i <= end_idx; i++) { |
| 1090 | unsigned int con_list = snd_hda_codec_read( |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 1091 | codec, spec->aa_mix_nid, 0, AC_VERB_GET_CONNECT_LIST, i/4*4); |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 1092 | int shift = 8 * (i % 4); |
| 1093 | hda_nid_t nid_pin = (con_list & (0xff << shift)) >> shift; |
| 1094 | unsigned int defconf = snd_hda_codec_get_pincfg(codec, nid_pin); |
| 1095 | if (get_defcfg_connect(defconf) == AC_JACK_PORT_COMPLEX) { |
| 1096 | /* check mute status while the pin is connected */ |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 1097 | int mute_l = snd_hda_codec_amp_read(codec, spec->aa_mix_nid, 0, |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 1098 | HDA_INPUT, i) >> 7; |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 1099 | int mute_r = snd_hda_codec_amp_read(codec, spec->aa_mix_nid, 1, |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 1100 | HDA_INPUT, i) >> 7; |
| 1101 | if (!mute_l || !mute_r) { |
| 1102 | mute = 0; |
| 1103 | break; |
| 1104 | } |
| 1105 | } |
| 1106 | } |
| 1107 | return mute; |
| 1108 | } |
| 1109 | |
| 1110 | /* enter/exit analog low-current mode */ |
| 1111 | static void analog_low_current_mode(struct hda_codec *codec, int stream_idle) |
| 1112 | { |
| 1113 | struct via_spec *spec = codec->spec; |
| 1114 | static int saved_stream_idle = 1; /* saved stream idle status */ |
| 1115 | int enable = is_aa_path_mute(codec); |
| 1116 | unsigned int verb = 0; |
| 1117 | unsigned int parm = 0; |
| 1118 | |
| 1119 | if (stream_idle == -1) /* stream status did not change */ |
| 1120 | enable = enable && saved_stream_idle; |
| 1121 | else { |
| 1122 | enable = enable && stream_idle; |
| 1123 | saved_stream_idle = stream_idle; |
| 1124 | } |
| 1125 | |
| 1126 | /* decide low current mode's verb & parameter */ |
| 1127 | switch (spec->codec_type) { |
| 1128 | case VT1708B_8CH: |
| 1129 | case VT1708B_4CH: |
| 1130 | verb = 0xf70; |
| 1131 | parm = enable ? 0x02 : 0x00; /* 0x02: 2/3x, 0x00: 1x */ |
| 1132 | break; |
| 1133 | case VT1708S: |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 1134 | case VT1718S: |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 1135 | case VT1716S: |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 1136 | verb = 0xf73; |
| 1137 | parm = enable ? 0x51 : 0xe1; /* 0x51: 4/28x, 0xe1: 1x */ |
| 1138 | break; |
| 1139 | case VT1702: |
| 1140 | verb = 0xf73; |
| 1141 | parm = enable ? 0x01 : 0x1d; /* 0x01: 4/40x, 0x1d: 1x */ |
| 1142 | break; |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 1143 | case VT2002P: |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 1144 | case VT1812: |
Lydia Wang | 11890956 | 2011-03-23 17:57:34 +0800 | [diff] [blame] | 1145 | case VT1802: |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 1146 | verb = 0xf93; |
| 1147 | parm = enable ? 0x00 : 0xe0; /* 0x00: 4/40x, 0xe0: 1x */ |
| 1148 | break; |
Lydia Wang | f527110 | 2009-10-10 19:07:35 +0800 | [diff] [blame] | 1149 | default: |
| 1150 | return; /* other codecs are not supported */ |
| 1151 | } |
| 1152 | /* send verb */ |
| 1153 | snd_hda_codec_write(codec, codec->afg, 0, verb, parm); |
| 1154 | } |
| 1155 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1156 | /* |
| 1157 | * generic initialization of ADC, input mixers and output mixers |
| 1158 | */ |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 1159 | static const struct hda_verb vt1708_volume_init_verbs[] = { |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1160 | /* |
| 1161 | * Unmute ADC0-1 and set the default input to mic-in |
| 1162 | */ |
| 1163 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1164 | {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1165 | |
| 1166 | |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 1167 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1168 | * mixer widget |
| 1169 | */ |
| 1170 | /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 1171 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1172 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 1173 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 1174 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 1175 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1176 | |
| 1177 | /* |
| 1178 | * Set up output mixers (0x19 - 0x1b) |
| 1179 | */ |
| 1180 | /* set vol=0 to output mixers */ |
| 1181 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1182 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 1183 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
Lydia Wang | 377ff31 | 2009-10-10 19:08:55 +0800 | [diff] [blame] | 1184 | |
Lydia Wang | bfdc675 | 2009-10-10 19:08:50 +0800 | [diff] [blame] | 1185 | /* Setup default input MW0 to PW4 */ |
| 1186 | {0x20, AC_VERB_SET_CONNECT_SEL, 0}, |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1187 | /* PW9 Output enable */ |
| 1188 | {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
Lydia Wang | aa266fc | 2011-03-24 12:41:01 +0800 | [diff] [blame] | 1189 | /* power down jack detect function */ |
| 1190 | {0x1, 0xf81, 0x1}, |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 1191 | { } |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1192 | }; |
| 1193 | |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 1194 | static void substream_set_idle(struct hda_codec *codec, |
| 1195 | struct snd_pcm_substream *substream) |
| 1196 | { |
| 1197 | int idle = substream->pstr->substream_opened == 1 |
| 1198 | && substream->ref_count == 0; |
| 1199 | analog_low_current_mode(codec, idle); |
| 1200 | } |
| 1201 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1202 | static int via_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 1203 | struct hda_codec *codec, |
| 1204 | struct snd_pcm_substream *substream) |
| 1205 | { |
| 1206 | struct via_spec *spec = codec->spec; |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 1207 | substream_set_idle(codec, substream); |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1208 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 1209 | hinfo); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1210 | } |
| 1211 | |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1212 | static int via_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 1213 | struct hda_codec *codec, |
| 1214 | struct snd_pcm_substream *substream) |
| 1215 | { |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 1216 | substream_set_idle(codec, substream); |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1217 | return 0; |
| 1218 | } |
| 1219 | |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 1220 | static int via_playback_hp_pcm_open(struct hda_pcm_stream *hinfo, |
| 1221 | struct hda_codec *codec, |
| 1222 | struct snd_pcm_substream *substream) |
| 1223 | { |
| 1224 | struct via_spec *spec = codec->spec; |
| 1225 | struct hda_multi_out *mout = &spec->multiout; |
| 1226 | |
| 1227 | if (!mout->hp_nid || mout->hp_nid == mout->dac_nids[HDA_FRONT] || |
| 1228 | !spec->hp_independent_mode) |
| 1229 | return -EINVAL; |
| 1230 | substream_set_idle(codec, substream); |
| 1231 | return 0; |
| 1232 | } |
| 1233 | |
| 1234 | static int via_playback_multi_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 1235 | struct hda_codec *codec, |
| 1236 | unsigned int stream_tag, |
| 1237 | unsigned int format, |
| 1238 | struct snd_pcm_substream *substream) |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1239 | { |
| 1240 | struct via_spec *spec = codec->spec; |
| 1241 | struct hda_multi_out *mout = &spec->multiout; |
Takashi Iwai | dda1441 | 2011-05-02 11:29:30 +0200 | [diff] [blame] | 1242 | const hda_nid_t *nids = mout->dac_nids; |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1243 | int chs = substream->runtime->channels; |
| 1244 | int i; |
Stephen Warren | 7c93597 | 2011-06-01 11:14:17 -0600 | [diff] [blame] | 1245 | struct hda_spdif_out *spdif = |
| 1246 | snd_hda_spdif_out_of_nid(codec, spec->multiout.dig_out_nid); |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1247 | |
| 1248 | mutex_lock(&codec->spdif_mutex); |
| 1249 | if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) { |
| 1250 | if (chs == 2 && |
| 1251 | snd_hda_is_supported_format(codec, mout->dig_out_nid, |
| 1252 | format) && |
Stephen Warren | 7c93597 | 2011-06-01 11:14:17 -0600 | [diff] [blame] | 1253 | !(spdif->status & IEC958_AES0_NONAUDIO)) { |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1254 | mout->dig_out_used = HDA_DIG_ANALOG_DUP; |
| 1255 | /* turn off SPDIF once; otherwise the IEC958 bits won't |
| 1256 | * be updated */ |
Stephen Warren | 7c93597 | 2011-06-01 11:14:17 -0600 | [diff] [blame] | 1257 | if (spdif->ctls & AC_DIG1_ENABLE) |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1258 | snd_hda_codec_write(codec, mout->dig_out_nid, 0, |
| 1259 | AC_VERB_SET_DIGI_CONVERT_1, |
Stephen Warren | 7c93597 | 2011-06-01 11:14:17 -0600 | [diff] [blame] | 1260 | spdif->ctls & |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1261 | ~AC_DIG1_ENABLE & 0xff); |
| 1262 | snd_hda_codec_setup_stream(codec, mout->dig_out_nid, |
| 1263 | stream_tag, 0, format); |
| 1264 | /* turn on again (if needed) */ |
Stephen Warren | 7c93597 | 2011-06-01 11:14:17 -0600 | [diff] [blame] | 1265 | if (spdif->ctls & AC_DIG1_ENABLE) |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1266 | snd_hda_codec_write(codec, mout->dig_out_nid, 0, |
| 1267 | AC_VERB_SET_DIGI_CONVERT_1, |
Stephen Warren | 7c93597 | 2011-06-01 11:14:17 -0600 | [diff] [blame] | 1268 | spdif->ctls & 0xff); |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1269 | } else { |
| 1270 | mout->dig_out_used = 0; |
| 1271 | snd_hda_codec_setup_stream(codec, mout->dig_out_nid, |
| 1272 | 0, 0, 0); |
| 1273 | } |
| 1274 | } |
| 1275 | mutex_unlock(&codec->spdif_mutex); |
| 1276 | |
| 1277 | /* front */ |
| 1278 | snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag, |
| 1279 | 0, format); |
| 1280 | |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 1281 | if (mout->hp_nid && mout->hp_nid != nids[HDA_FRONT] |
| 1282 | && !spec->hp_independent_mode) |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1283 | /* headphone out will just decode front left/right (stereo) */ |
| 1284 | snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, |
| 1285 | 0, format); |
| 1286 | |
| 1287 | /* extra outputs copied from front */ |
| 1288 | for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) |
| 1289 | if (mout->extra_out_nid[i]) |
| 1290 | snd_hda_codec_setup_stream(codec, |
| 1291 | mout->extra_out_nid[i], |
| 1292 | stream_tag, 0, format); |
| 1293 | |
| 1294 | /* surrounds */ |
| 1295 | for (i = 1; i < mout->num_dacs; i++) { |
| 1296 | if (chs >= (i + 1) * 2) /* independent out */ |
| 1297 | snd_hda_codec_setup_stream(codec, nids[i], stream_tag, |
| 1298 | i * 2, format); |
| 1299 | else /* copy front */ |
| 1300 | snd_hda_codec_setup_stream(codec, nids[i], stream_tag, |
| 1301 | 0, format); |
| 1302 | } |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 1303 | vt1708_start_hp_work(spec); |
| 1304 | return 0; |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1305 | } |
| 1306 | |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 1307 | static int via_playback_hp_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 1308 | struct hda_codec *codec, |
| 1309 | unsigned int stream_tag, |
| 1310 | unsigned int format, |
| 1311 | struct snd_pcm_substream *substream) |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1312 | { |
| 1313 | struct via_spec *spec = codec->spec; |
| 1314 | struct hda_multi_out *mout = &spec->multiout; |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1315 | |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 1316 | snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format); |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 1317 | vt1708_start_hp_work(spec); |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1318 | return 0; |
| 1319 | } |
| 1320 | |
| 1321 | static int via_playback_multi_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 1322 | struct hda_codec *codec, |
| 1323 | struct snd_pcm_substream *substream) |
| 1324 | { |
| 1325 | struct via_spec *spec = codec->spec; |
| 1326 | struct hda_multi_out *mout = &spec->multiout; |
Takashi Iwai | dda1441 | 2011-05-02 11:29:30 +0200 | [diff] [blame] | 1327 | const hda_nid_t *nids = mout->dac_nids; |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1328 | int i; |
| 1329 | |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 1330 | for (i = 0; i < mout->num_dacs; i++) |
| 1331 | snd_hda_codec_setup_stream(codec, nids[i], 0, 0, 0); |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1332 | |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 1333 | if (mout->hp_nid && !spec->hp_independent_mode) |
| 1334 | snd_hda_codec_setup_stream(codec, mout->hp_nid, |
| 1335 | 0, 0, 0); |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1336 | |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 1337 | for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) |
| 1338 | if (mout->extra_out_nid[i]) |
| 1339 | snd_hda_codec_setup_stream(codec, |
| 1340 | mout->extra_out_nid[i], |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1341 | 0, 0, 0); |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 1342 | mutex_lock(&codec->spdif_mutex); |
| 1343 | if (mout->dig_out_nid && |
| 1344 | mout->dig_out_used == HDA_DIG_ANALOG_DUP) { |
| 1345 | snd_hda_codec_setup_stream(codec, mout->dig_out_nid, |
| 1346 | 0, 0, 0); |
| 1347 | mout->dig_out_used = 0; |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1348 | } |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 1349 | mutex_unlock(&codec->spdif_mutex); |
| 1350 | vt1708_stop_hp_work(spec); |
| 1351 | return 0; |
| 1352 | } |
| 1353 | |
| 1354 | static int via_playback_hp_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 1355 | struct hda_codec *codec, |
| 1356 | struct snd_pcm_substream *substream) |
| 1357 | { |
| 1358 | struct via_spec *spec = codec->spec; |
| 1359 | struct hda_multi_out *mout = &spec->multiout; |
| 1360 | |
| 1361 | snd_hda_codec_setup_stream(codec, mout->hp_nid, 0, 0, 0); |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 1362 | vt1708_stop_hp_work(spec); |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1363 | return 0; |
| 1364 | } |
| 1365 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1366 | /* |
| 1367 | * Digital out |
| 1368 | */ |
| 1369 | static int via_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 1370 | struct hda_codec *codec, |
| 1371 | struct snd_pcm_substream *substream) |
| 1372 | { |
| 1373 | struct via_spec *spec = codec->spec; |
| 1374 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 1375 | } |
| 1376 | |
| 1377 | static int via_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 1378 | struct hda_codec *codec, |
| 1379 | struct snd_pcm_substream *substream) |
| 1380 | { |
| 1381 | struct via_spec *spec = codec->spec; |
| 1382 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 1383 | } |
| 1384 | |
Harald Welte | 5691ec7 | 2008-09-15 22:42:26 +0800 | [diff] [blame] | 1385 | static int via_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Harald Welte | 98aa34c | 2008-09-09 16:02:09 +0800 | [diff] [blame] | 1386 | struct hda_codec *codec, |
| 1387 | unsigned int stream_tag, |
| 1388 | unsigned int format, |
| 1389 | struct snd_pcm_substream *substream) |
| 1390 | { |
| 1391 | struct via_spec *spec = codec->spec; |
Takashi Iwai | 9da2927 | 2009-05-07 16:31:14 +0200 | [diff] [blame] | 1392 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 1393 | stream_tag, format, substream); |
| 1394 | } |
Harald Welte | 5691ec7 | 2008-09-15 22:42:26 +0800 | [diff] [blame] | 1395 | |
Takashi Iwai | 9da2927 | 2009-05-07 16:31:14 +0200 | [diff] [blame] | 1396 | static int via_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 1397 | struct hda_codec *codec, |
| 1398 | struct snd_pcm_substream *substream) |
| 1399 | { |
| 1400 | struct via_spec *spec = codec->spec; |
| 1401 | snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
Harald Welte | 98aa34c | 2008-09-09 16:02:09 +0800 | [diff] [blame] | 1402 | return 0; |
| 1403 | } |
| 1404 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1405 | /* |
| 1406 | * Analog capture |
| 1407 | */ |
| 1408 | static int via_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 1409 | struct hda_codec *codec, |
| 1410 | unsigned int stream_tag, |
| 1411 | unsigned int format, |
| 1412 | struct snd_pcm_substream *substream) |
| 1413 | { |
| 1414 | struct via_spec *spec = codec->spec; |
| 1415 | |
| 1416 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 1417 | stream_tag, 0, format); |
| 1418 | return 0; |
| 1419 | } |
| 1420 | |
| 1421 | static int via_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 1422 | struct hda_codec *codec, |
| 1423 | struct snd_pcm_substream *substream) |
| 1424 | { |
| 1425 | struct via_spec *spec = codec->spec; |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 1426 | snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1427 | return 0; |
| 1428 | } |
| 1429 | |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1430 | static const struct hda_pcm_stream via_pcm_analog_playback = { |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 1431 | .substreams = 1, |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1432 | .channels_min = 2, |
| 1433 | .channels_max = 8, |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1434 | /* NID is set in via_build_pcms */ |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1435 | .ops = { |
| 1436 | .open = via_playback_pcm_open, |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1437 | .close = via_playback_pcm_close, |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 1438 | .prepare = via_playback_multi_pcm_prepare, |
| 1439 | .cleanup = via_playback_multi_pcm_cleanup |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1440 | }, |
| 1441 | }; |
| 1442 | |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 1443 | static const struct hda_pcm_stream via_pcm_hp_playback = { |
| 1444 | .substreams = 1, |
| 1445 | .channels_min = 2, |
| 1446 | .channels_max = 2, |
| 1447 | /* NID is set in via_build_pcms */ |
| 1448 | .ops = { |
| 1449 | .open = via_playback_hp_pcm_open, |
| 1450 | .close = via_playback_pcm_close, |
| 1451 | .prepare = via_playback_hp_pcm_prepare, |
| 1452 | .cleanup = via_playback_hp_pcm_cleanup |
| 1453 | }, |
| 1454 | }; |
| 1455 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 1456 | static const struct hda_pcm_stream vt1708_pcm_analog_s16_playback = { |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 1457 | .substreams = 1, |
Takashi Iwai | bc9b56238 | 2008-05-23 17:50:27 +0200 | [diff] [blame] | 1458 | .channels_min = 2, |
| 1459 | .channels_max = 8, |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1460 | /* NID is set in via_build_pcms */ |
Takashi Iwai | bc9b56238 | 2008-05-23 17:50:27 +0200 | [diff] [blame] | 1461 | /* We got noisy outputs on the right channel on VT1708 when |
| 1462 | * 24bit samples are used. Until any workaround is found, |
| 1463 | * disable the 24bit format, so far. |
| 1464 | */ |
| 1465 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
| 1466 | .ops = { |
| 1467 | .open = via_playback_pcm_open, |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1468 | .close = via_playback_pcm_close, |
Lydia Wang | c873cc2 | 2009-10-10 19:08:21 +0800 | [diff] [blame] | 1469 | .prepare = via_playback_multi_pcm_prepare, |
| 1470 | .cleanup = via_playback_multi_pcm_cleanup |
Takashi Iwai | bc9b56238 | 2008-05-23 17:50:27 +0200 | [diff] [blame] | 1471 | }, |
| 1472 | }; |
| 1473 | |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1474 | static const struct hda_pcm_stream via_pcm_analog_capture = { |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 1475 | .substreams = 1, /* will be changed in via_build_pcms() */ |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1476 | .channels_min = 2, |
| 1477 | .channels_max = 2, |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1478 | /* NID is set in via_build_pcms */ |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1479 | .ops = { |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1480 | .open = via_playback_pcm_open, |
| 1481 | .close = via_playback_pcm_close, |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1482 | .prepare = via_capture_pcm_prepare, |
| 1483 | .cleanup = via_capture_pcm_cleanup |
| 1484 | }, |
| 1485 | }; |
| 1486 | |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1487 | static const struct hda_pcm_stream via_pcm_digital_playback = { |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1488 | .substreams = 1, |
| 1489 | .channels_min = 2, |
| 1490 | .channels_max = 2, |
| 1491 | /* NID is set in via_build_pcms */ |
| 1492 | .ops = { |
| 1493 | .open = via_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 1494 | .close = via_dig_playback_pcm_close, |
Takashi Iwai | 9da2927 | 2009-05-07 16:31:14 +0200 | [diff] [blame] | 1495 | .prepare = via_dig_playback_pcm_prepare, |
| 1496 | .cleanup = via_dig_playback_pcm_cleanup |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1497 | }, |
| 1498 | }; |
| 1499 | |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1500 | static const struct hda_pcm_stream via_pcm_digital_capture = { |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1501 | .substreams = 1, |
| 1502 | .channels_min = 2, |
| 1503 | .channels_max = 2, |
| 1504 | }; |
| 1505 | |
| 1506 | static int via_build_controls(struct hda_codec *codec) |
| 1507 | { |
| 1508 | struct via_spec *spec = codec->spec; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1509 | struct snd_kcontrol *kctl; |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 1510 | const struct snd_kcontrol_new *knew; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1511 | int err, i; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1512 | |
Takashi Iwai | 24088a5 | 2011-06-17 16:59:21 +0200 | [diff] [blame] | 1513 | if (spec->set_widgets_power_state) |
| 1514 | if (!via_clone_control(spec, &via_pin_power_ctl_enum)) |
| 1515 | return -ENOMEM; |
| 1516 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1517 | for (i = 0; i < spec->num_mixers; i++) { |
| 1518 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1519 | if (err < 0) |
| 1520 | return err; |
| 1521 | } |
| 1522 | |
| 1523 | if (spec->multiout.dig_out_nid) { |
| 1524 | err = snd_hda_create_spdif_out_ctls(codec, |
Stephen Warren | 74b654c | 2011-06-01 11:14:18 -0600 | [diff] [blame] | 1525 | spec->multiout.dig_out_nid, |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1526 | spec->multiout.dig_out_nid); |
| 1527 | if (err < 0) |
| 1528 | return err; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1529 | err = snd_hda_create_spdif_share_sw(codec, |
| 1530 | &spec->multiout); |
| 1531 | if (err < 0) |
| 1532 | return err; |
| 1533 | spec->multiout.share_spdif = 1; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1534 | } |
| 1535 | if (spec->dig_in_nid) { |
| 1536 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1537 | if (err < 0) |
| 1538 | return err; |
| 1539 | } |
Lydia Wang | 1731437 | 2009-10-10 19:07:37 +0800 | [diff] [blame] | 1540 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1541 | /* assign Capture Source enums to NID */ |
| 1542 | kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); |
| 1543 | for (i = 0; kctl && i < kctl->count; i++) { |
Takashi Iwai | 21949f0 | 2009-12-23 08:31:59 +0100 | [diff] [blame] | 1544 | err = snd_hda_add_nid(codec, kctl, i, spec->mux_nids[i]); |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1545 | if (err < 0) |
| 1546 | return err; |
| 1547 | } |
| 1548 | |
| 1549 | /* other nid->control mapping */ |
| 1550 | for (i = 0; i < spec->num_mixers; i++) { |
| 1551 | for (knew = spec->mixers[i]; knew->name; knew++) { |
| 1552 | if (knew->iface != NID_MAPPING) |
| 1553 | continue; |
| 1554 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 1555 | if (kctl == NULL) |
| 1556 | continue; |
| 1557 | err = snd_hda_add_nid(codec, kctl, 0, |
| 1558 | knew->subdevice); |
| 1559 | } |
| 1560 | } |
| 1561 | |
Lydia Wang | 1731437 | 2009-10-10 19:07:37 +0800 | [diff] [blame] | 1562 | /* init power states */ |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 1563 | set_widgets_power_state(codec); |
Lydia Wang | 1731437 | 2009-10-10 19:07:37 +0800 | [diff] [blame] | 1564 | analog_low_current_mode(codec, 1); |
| 1565 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1566 | via_free_kctls(codec); /* no longer needed */ |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1567 | return 0; |
| 1568 | } |
| 1569 | |
| 1570 | static int via_build_pcms(struct hda_codec *codec) |
| 1571 | { |
| 1572 | struct via_spec *spec = codec->spec; |
| 1573 | struct hda_pcm *info = spec->pcm_rec; |
| 1574 | |
| 1575 | codec->num_pcms = 1; |
| 1576 | codec->pcm_info = info; |
| 1577 | |
Takashi Iwai | 82673bc | 2011-06-17 16:24:21 +0200 | [diff] [blame] | 1578 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), |
| 1579 | "%s Analog", codec->chip_name); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1580 | info->name = spec->stream_name_analog; |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1581 | |
| 1582 | if (!spec->stream_analog_playback) |
| 1583 | spec->stream_analog_playback = &via_pcm_analog_playback; |
Lydia Wang | 377ff31 | 2009-10-10 19:08:55 +0800 | [diff] [blame] | 1584 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1585 | *spec->stream_analog_playback; |
Lydia Wang | 377ff31 | 2009-10-10 19:08:55 +0800 | [diff] [blame] | 1586 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 1587 | spec->multiout.dac_nids[0]; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1588 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = |
| 1589 | spec->multiout.max_channels; |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1590 | |
| 1591 | if (!spec->stream_analog_capture) |
| 1592 | spec->stream_analog_capture = &via_pcm_analog_capture; |
| 1593 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 1594 | *spec->stream_analog_capture; |
| 1595 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 1596 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = |
| 1597 | spec->num_adc_nids; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1598 | |
| 1599 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 1600 | codec->num_pcms++; |
| 1601 | info++; |
Takashi Iwai | 82673bc | 2011-06-17 16:24:21 +0200 | [diff] [blame] | 1602 | snprintf(spec->stream_name_digital, |
| 1603 | sizeof(spec->stream_name_digital), |
| 1604 | "%s Digital", codec->chip_name); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1605 | info->name = spec->stream_name_digital; |
Takashi Iwai | 7ba72ba | 2008-02-06 14:03:20 +0100 | [diff] [blame] | 1606 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1607 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1608 | if (!spec->stream_digital_playback) |
| 1609 | spec->stream_digital_playback = |
| 1610 | &via_pcm_digital_playback; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1611 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1612 | *spec->stream_digital_playback; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1613 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 1614 | spec->multiout.dig_out_nid; |
| 1615 | } |
| 1616 | if (spec->dig_in_nid) { |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1617 | if (!spec->stream_digital_capture) |
| 1618 | spec->stream_digital_capture = |
| 1619 | &via_pcm_digital_capture; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1620 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
Takashi Iwai | 9af7421 | 2011-06-18 16:17:45 +0200 | [diff] [blame] | 1621 | *spec->stream_digital_capture; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1622 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = |
| 1623 | spec->dig_in_nid; |
| 1624 | } |
| 1625 | } |
| 1626 | |
Takashi Iwai | 7eb56e84 | 2011-06-18 16:40:14 +0200 | [diff] [blame] | 1627 | if (spec->multiout.hp_nid) { |
| 1628 | codec->num_pcms++; |
| 1629 | info++; |
| 1630 | snprintf(spec->stream_name_hp, sizeof(spec->stream_name_hp), |
| 1631 | "%s HP", codec->chip_name); |
| 1632 | info->name = spec->stream_name_hp; |
| 1633 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = via_pcm_hp_playback; |
| 1634 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 1635 | spec->multiout.hp_nid; |
| 1636 | } |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1637 | return 0; |
| 1638 | } |
| 1639 | |
| 1640 | static void via_free(struct hda_codec *codec) |
| 1641 | { |
| 1642 | struct via_spec *spec = codec->spec; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1643 | |
| 1644 | if (!spec) |
| 1645 | return; |
| 1646 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1647 | via_free_kctls(codec); |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 1648 | vt1708_stop_hp_work(spec); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1649 | kfree(codec->spec); |
| 1650 | } |
| 1651 | |
Takashi Iwai | 64be285 | 2011-06-17 16:51:39 +0200 | [diff] [blame] | 1652 | /* mute/unmute outputs */ |
| 1653 | static void toggle_output_mutes(struct hda_codec *codec, int num_pins, |
| 1654 | hda_nid_t *pins, bool mute) |
| 1655 | { |
| 1656 | int i; |
| 1657 | for (i = 0; i < num_pins; i++) |
| 1658 | snd_hda_codec_write(codec, pins[i], 0, |
| 1659 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1660 | mute ? 0 : PIN_OUT); |
| 1661 | } |
| 1662 | |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 1663 | /* mute internal speaker if HP is plugged */ |
| 1664 | static void via_hp_automute(struct hda_codec *codec) |
| 1665 | { |
Lydia Wang | dcf34c8 | 2009-10-10 19:08:15 +0800 | [diff] [blame] | 1666 | unsigned int present = 0; |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 1667 | struct via_spec *spec = codec->spec; |
| 1668 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1669 | present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); |
Lydia Wang | dcf34c8 | 2009-10-10 19:08:15 +0800 | [diff] [blame] | 1670 | |
Takashi Iwai | 64be285 | 2011-06-17 16:51:39 +0200 | [diff] [blame] | 1671 | if (!spec->hp_independent_mode) |
| 1672 | toggle_output_mutes(codec, spec->autocfg.line_outs, |
| 1673 | spec->autocfg.line_out_pins, |
| 1674 | present); |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 1675 | } |
| 1676 | |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 1677 | /* mute mono out if HP or Line out is plugged */ |
| 1678 | static void via_mono_automute(struct hda_codec *codec) |
| 1679 | { |
| 1680 | unsigned int hp_present, lineout_present; |
| 1681 | struct via_spec *spec = codec->spec; |
| 1682 | |
| 1683 | if (spec->codec_type != VT1716S) |
| 1684 | return; |
| 1685 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1686 | lineout_present = snd_hda_jack_detect(codec, |
| 1687 | spec->autocfg.line_out_pins[0]); |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 1688 | |
| 1689 | /* Mute Mono Out if Line Out is plugged */ |
| 1690 | if (lineout_present) { |
Takashi Iwai | 3e0693e | 2011-06-17 16:37:45 +0200 | [diff] [blame] | 1691 | snd_hda_codec_write(codec, 0x2A, 0, |
| 1692 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1693 | lineout_present ? 0 : PIN_OUT); |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 1694 | return; |
| 1695 | } |
| 1696 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1697 | hp_present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 1698 | |
| 1699 | if (!spec->hp_independent_mode) |
Takashi Iwai | 3e0693e | 2011-06-17 16:37:45 +0200 | [diff] [blame] | 1700 | snd_hda_codec_write(codec, 0x2A, 0, |
| 1701 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1702 | hp_present ? 0 : PIN_OUT); |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 1703 | } |
| 1704 | |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 1705 | static void via_gpio_control(struct hda_codec *codec) |
| 1706 | { |
| 1707 | unsigned int gpio_data; |
| 1708 | unsigned int vol_counter; |
| 1709 | unsigned int vol; |
| 1710 | unsigned int master_vol; |
| 1711 | |
| 1712 | struct via_spec *spec = codec->spec; |
| 1713 | |
| 1714 | gpio_data = snd_hda_codec_read(codec, codec->afg, 0, |
| 1715 | AC_VERB_GET_GPIO_DATA, 0) & 0x03; |
| 1716 | |
| 1717 | vol_counter = (snd_hda_codec_read(codec, codec->afg, 0, |
| 1718 | 0xF84, 0) & 0x3F0000) >> 16; |
| 1719 | |
| 1720 | vol = vol_counter & 0x1F; |
| 1721 | master_vol = snd_hda_codec_read(codec, 0x1A, 0, |
| 1722 | AC_VERB_GET_AMP_GAIN_MUTE, |
| 1723 | AC_AMP_GET_INPUT); |
| 1724 | |
| 1725 | if (gpio_data == 0x02) { |
| 1726 | /* unmute line out */ |
Takashi Iwai | 3e0693e | 2011-06-17 16:37:45 +0200 | [diff] [blame] | 1727 | snd_hda_codec_write(codec, spec->autocfg.line_out_pins[0], 0, |
| 1728 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1729 | PIN_OUT); |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 1730 | if (vol_counter & 0x20) { |
| 1731 | /* decrease volume */ |
| 1732 | if (vol > master_vol) |
| 1733 | vol = master_vol; |
| 1734 | snd_hda_codec_amp_stereo(codec, 0x1A, HDA_INPUT, |
| 1735 | 0, HDA_AMP_VOLMASK, |
| 1736 | master_vol-vol); |
| 1737 | } else { |
| 1738 | /* increase volume */ |
| 1739 | snd_hda_codec_amp_stereo(codec, 0x1A, HDA_INPUT, 0, |
| 1740 | HDA_AMP_VOLMASK, |
| 1741 | ((master_vol+vol) > 0x2A) ? 0x2A : |
| 1742 | (master_vol+vol)); |
| 1743 | } |
| 1744 | } else if (!(gpio_data & 0x02)) { |
| 1745 | /* mute line out */ |
Takashi Iwai | 3e0693e | 2011-06-17 16:37:45 +0200 | [diff] [blame] | 1746 | snd_hda_codec_write(codec, spec->autocfg.line_out_pins[0], 0, |
| 1747 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1748 | 0); |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 1749 | } |
| 1750 | } |
| 1751 | |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 1752 | /* mute Internal-Speaker if HP is plugged */ |
| 1753 | static void via_speaker_automute(struct hda_codec *codec) |
| 1754 | { |
| 1755 | unsigned int hp_present; |
| 1756 | struct via_spec *spec = codec->spec; |
| 1757 | |
Lydia Wang | 27439ce | 2011-03-24 12:40:10 +0800 | [diff] [blame] | 1758 | if (!VT2002P_COMPATIBLE(spec)) |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 1759 | return; |
| 1760 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 1761 | hp_present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 1762 | |
Takashi Iwai | 64be285 | 2011-06-17 16:51:39 +0200 | [diff] [blame] | 1763 | if (!spec->hp_independent_mode) |
| 1764 | toggle_output_mutes(codec, spec->autocfg.speaker_outs, |
| 1765 | spec->autocfg.speaker_pins, |
| 1766 | hp_present); |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 1767 | } |
| 1768 | |
| 1769 | /* mute line-out and internal speaker if HP is plugged */ |
| 1770 | static void via_hp_bind_automute(struct hda_codec *codec) |
| 1771 | { |
Takashi Iwai | 64be285 | 2011-06-17 16:51:39 +0200 | [diff] [blame] | 1772 | int present; |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 1773 | struct via_spec *spec = codec->spec; |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 1774 | |
| 1775 | if (!spec->autocfg.hp_pins[0] || !spec->autocfg.line_out_pins[0]) |
| 1776 | return; |
| 1777 | |
Takashi Iwai | 64be285 | 2011-06-17 16:51:39 +0200 | [diff] [blame] | 1778 | present = snd_hda_jack_detect(codec, spec->autocfg.hp_pins[0]); |
| 1779 | if (!spec->hp_independent_mode) |
| 1780 | toggle_output_mutes(codec, spec->autocfg.line_outs, |
| 1781 | spec->autocfg.line_out_pins, |
| 1782 | present); |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 1783 | |
Takashi Iwai | 64be285 | 2011-06-17 16:51:39 +0200 | [diff] [blame] | 1784 | if (!present) |
| 1785 | present = snd_hda_jack_detect(codec, |
| 1786 | spec->autocfg.line_out_pins[0]); |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 1787 | |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 1788 | /* Speakers */ |
Takashi Iwai | 64be285 | 2011-06-17 16:51:39 +0200 | [diff] [blame] | 1789 | toggle_output_mutes(codec, spec->autocfg.speaker_outs, |
| 1790 | spec->autocfg.speaker_pins, |
| 1791 | present); |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 1792 | } |
| 1793 | |
| 1794 | |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 1795 | /* unsolicited event for jack sensing */ |
| 1796 | static void via_unsol_event(struct hda_codec *codec, |
| 1797 | unsigned int res) |
| 1798 | { |
| 1799 | res >>= 26; |
Lydia Wang | ec7e7e4 | 2011-03-24 12:43:44 +0800 | [diff] [blame] | 1800 | |
Lydia Wang | a34df19 | 2009-10-10 19:08:01 +0800 | [diff] [blame] | 1801 | if (res & VIA_JACK_EVENT) |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 1802 | set_widgets_power_state(codec); |
Lydia Wang | ec7e7e4 | 2011-03-24 12:43:44 +0800 | [diff] [blame] | 1803 | |
| 1804 | res &= ~VIA_JACK_EVENT; |
| 1805 | |
| 1806 | if (res == VIA_HP_EVENT) |
| 1807 | via_hp_automute(codec); |
| 1808 | else if (res == VIA_GPIO_EVENT) |
| 1809 | via_gpio_control(codec); |
| 1810 | else if (res == VIA_MONO_EVENT) |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 1811 | via_mono_automute(codec); |
Lydia Wang | ec7e7e4 | 2011-03-24 12:43:44 +0800 | [diff] [blame] | 1812 | else if (res == VIA_SPEAKER_EVENT) |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 1813 | via_speaker_automute(codec); |
Lydia Wang | ec7e7e4 | 2011-03-24 12:43:44 +0800 | [diff] [blame] | 1814 | else if (res == VIA_BIND_HP_EVENT) |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 1815 | via_hp_bind_automute(codec); |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 1816 | } |
| 1817 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1818 | static int via_init(struct hda_codec *codec) |
| 1819 | { |
| 1820 | struct via_spec *spec = codec->spec; |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 1821 | int i; |
| 1822 | for (i = 0; i < spec->num_iverbs; i++) |
| 1823 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
| 1824 | |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 1825 | /* Lydia Add for EAPD enable */ |
| 1826 | if (!spec->dig_in_nid) { /* No Digital In connection */ |
Takashi Iwai | 55d1d6c | 2009-07-07 13:39:03 +0200 | [diff] [blame] | 1827 | if (spec->dig_in_pin) { |
| 1828 | snd_hda_codec_write(codec, spec->dig_in_pin, 0, |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 1829 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
Takashi Iwai | 12b74c8 | 2008-01-15 12:39:38 +0100 | [diff] [blame] | 1830 | PIN_OUT); |
Takashi Iwai | 55d1d6c | 2009-07-07 13:39:03 +0200 | [diff] [blame] | 1831 | snd_hda_codec_write(codec, spec->dig_in_pin, 0, |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 1832 | AC_VERB_SET_EAPD_BTLENABLE, 0x02); |
| 1833 | } |
Takashi Iwai | 12b74c8 | 2008-01-15 12:39:38 +0100 | [diff] [blame] | 1834 | } else /* enable SPDIF-input pin */ |
| 1835 | snd_hda_codec_write(codec, spec->autocfg.dig_in_pin, 0, |
| 1836 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN); |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 1837 | |
Takashi Iwai | 9da2927 | 2009-05-07 16:31:14 +0200 | [diff] [blame] | 1838 | /* assign slave outs */ |
| 1839 | if (spec->slave_dig_outs[0]) |
| 1840 | codec->slave_dig_outs = spec->slave_dig_outs; |
Harald Welte | 5691ec7 | 2008-09-15 22:42:26 +0800 | [diff] [blame] | 1841 | |
Lydia Wang | 377ff31 | 2009-10-10 19:08:55 +0800 | [diff] [blame] | 1842 | return 0; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1843 | } |
| 1844 | |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 1845 | #ifdef SND_HDA_NEEDS_RESUME |
| 1846 | static int via_suspend(struct hda_codec *codec, pm_message_t state) |
| 1847 | { |
| 1848 | struct via_spec *spec = codec->spec; |
| 1849 | vt1708_stop_hp_work(spec); |
| 1850 | return 0; |
| 1851 | } |
| 1852 | #endif |
| 1853 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1854 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 1855 | static int via_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
| 1856 | { |
| 1857 | struct via_spec *spec = codec->spec; |
| 1858 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); |
| 1859 | } |
| 1860 | #endif |
| 1861 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1862 | /* |
| 1863 | */ |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 1864 | static const struct hda_codec_ops via_patch_ops = { |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1865 | .build_controls = via_build_controls, |
| 1866 | .build_pcms = via_build_pcms, |
| 1867 | .init = via_init, |
| 1868 | .free = via_free, |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 1869 | #ifdef SND_HDA_NEEDS_RESUME |
| 1870 | .suspend = via_suspend, |
| 1871 | #endif |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1872 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 1873 | .check_power_status = via_check_power_status, |
| 1874 | #endif |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1875 | }; |
| 1876 | |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 1877 | static bool is_empty_dac(struct hda_codec *codec, hda_nid_t dac) |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1878 | { |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 1879 | struct via_spec *spec = codec->spec; |
| 1880 | int i; |
| 1881 | |
| 1882 | for (i = 0; i < spec->multiout.num_dacs; i++) { |
| 1883 | if (spec->multiout.dac_nids[i] == dac) |
| 1884 | return false; |
| 1885 | } |
| 1886 | if (spec->multiout.hp_nid == dac) |
| 1887 | return false; |
| 1888 | return true; |
| 1889 | } |
| 1890 | |
| 1891 | static bool parse_output_path(struct hda_codec *codec, hda_nid_t nid, |
| 1892 | hda_nid_t target_dac, struct nid_path *path, |
| 1893 | int depth, int wid_type) |
| 1894 | { |
| 1895 | hda_nid_t conn[8]; |
| 1896 | int i, nums; |
| 1897 | |
| 1898 | nums = snd_hda_get_connections(codec, nid, conn, ARRAY_SIZE(conn)); |
| 1899 | for (i = 0; i < nums; i++) { |
| 1900 | if (get_wcaps_type(get_wcaps(codec, conn[i])) != AC_WID_AUD_OUT) |
| 1901 | continue; |
| 1902 | if (conn[i] == target_dac || is_empty_dac(codec, conn[i])) { |
| 1903 | path->path[depth] = conn[i]; |
| 1904 | path->idx[depth] = i; |
| 1905 | path->depth = ++depth; |
| 1906 | return true; |
| 1907 | } |
| 1908 | } |
| 1909 | if (depth > 4) |
| 1910 | return false; |
| 1911 | for (i = 0; i < nums; i++) { |
| 1912 | unsigned int type; |
| 1913 | type = get_wcaps_type(get_wcaps(codec, conn[i])); |
| 1914 | if (type == AC_WID_AUD_OUT || |
| 1915 | (wid_type != -1 && type != wid_type)) |
| 1916 | continue; |
| 1917 | if (parse_output_path(codec, conn[i], target_dac, |
| 1918 | path, depth + 1, AC_WID_AUD_SEL)) { |
| 1919 | path->path[depth] = conn[i]; |
| 1920 | path->idx[depth] = i; |
| 1921 | return true; |
| 1922 | } |
| 1923 | } |
| 1924 | return false; |
| 1925 | } |
| 1926 | |
| 1927 | static int via_auto_fill_dac_nids(struct hda_codec *codec) |
| 1928 | { |
| 1929 | struct via_spec *spec = codec->spec; |
| 1930 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1931 | int i; |
| 1932 | hda_nid_t nid; |
| 1933 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1934 | spec->multiout.dac_nids = spec->private_dac_nids; |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 1935 | spec->multiout.num_dacs = cfg->line_outs; |
| 1936 | for (i = 0; i < cfg->line_outs; i++) { |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1937 | nid = cfg->line_out_pins[i]; |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 1938 | if (!nid) |
| 1939 | continue; |
| 1940 | if (parse_output_path(codec, nid, 0, &spec->out_path[i], 0, -1)) |
| 1941 | spec->private_dac_nids[i] = |
| 1942 | spec->out_path[i].path[spec->out_path[i].depth - 1]; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1943 | } |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1944 | return 0; |
| 1945 | } |
| 1946 | |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 1947 | static int create_ch_ctls(struct hda_codec *codec, const char *pfx, |
| 1948 | hda_nid_t pin, hda_nid_t dac, int chs) |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1949 | { |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 1950 | struct via_spec *spec = codec->spec; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 1951 | char name[32]; |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 1952 | hda_nid_t nid; |
| 1953 | int err; |
| 1954 | |
| 1955 | if (dac && query_amp_caps(codec, dac, HDA_OUTPUT) & AC_AMPCAP_NUM_STEPS) |
| 1956 | nid = dac; |
| 1957 | else if (query_amp_caps(codec, pin, HDA_OUTPUT) & AC_AMPCAP_NUM_STEPS) |
| 1958 | nid = pin; |
| 1959 | else |
| 1960 | nid = 0; |
| 1961 | if (nid) { |
| 1962 | sprintf(name, "%s Playback Volume", pfx); |
| 1963 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, |
| 1964 | HDA_COMPOSE_AMP_VAL(dac, chs, 0, HDA_OUTPUT)); |
| 1965 | if (err < 0) |
| 1966 | return err; |
| 1967 | } |
| 1968 | |
| 1969 | if (dac && query_amp_caps(codec, dac, HDA_OUTPUT) & AC_AMPCAP_MUTE) |
| 1970 | nid = dac; |
| 1971 | else if (query_amp_caps(codec, pin, HDA_OUTPUT) & AC_AMPCAP_MUTE) |
| 1972 | nid = pin; |
| 1973 | else |
| 1974 | nid = 0; |
| 1975 | if (nid) { |
| 1976 | sprintf(name, "%s Playback Switch", pfx); |
| 1977 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, |
| 1978 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 1979 | if (err < 0) |
| 1980 | return err; |
| 1981 | } |
| 1982 | return 0; |
| 1983 | } |
| 1984 | |
| 1985 | static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, |
| 1986 | hda_nid_t nid); |
| 1987 | |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 1988 | static void mangle_smart51(struct hda_codec *codec) |
| 1989 | { |
| 1990 | struct via_spec *spec = codec->spec; |
| 1991 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1992 | int i; |
| 1993 | |
| 1994 | for (i = 0; i < cfg->num_inputs; i++) { |
| 1995 | if (!is_smart51_pins(codec, cfg->inputs[i].pin)) |
| 1996 | continue; |
| 1997 | spec->can_smart51 = 1; |
| 1998 | cfg->line_out_pins[cfg->line_outs++] = cfg->inputs[i].pin; |
| 1999 | if (cfg->line_outs == 3) |
| 2000 | break; |
| 2001 | } |
| 2002 | } |
| 2003 | |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 2004 | /* add playback controls from the parsed DAC table */ |
| 2005 | static int via_auto_create_multi_out_ctls(struct hda_codec *codec) |
| 2006 | { |
| 2007 | struct via_spec *spec = codec->spec; |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 2008 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 2009 | static const char * const chname[4] = { |
| 2010 | "Front", "Surround", "C/LFE", "Side" |
| 2011 | }; |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 2012 | int i, idx, err; |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 2013 | int old_line_outs; |
| 2014 | |
| 2015 | /* check smart51 */ |
| 2016 | old_line_outs = cfg->line_outs; |
| 2017 | if (cfg->line_outs == 1) |
| 2018 | mangle_smart51(codec); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2019 | |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 2020 | for (i = 0; i < cfg->line_outs; i++) { |
| 2021 | hda_nid_t pin, dac; |
| 2022 | pin = cfg->line_out_pins[i]; |
| 2023 | dac = spec->multiout.dac_nids[i]; |
| 2024 | if (!pin || !dac) |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2025 | continue; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2026 | if (i == AUTO_SEQ_CENLFE) { |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 2027 | err = create_ch_ctls(codec, "Center", pin, dac, 1); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2028 | if (err < 0) |
| 2029 | return err; |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 2030 | err = create_ch_ctls(codec, "LFE", pin, dac, 2); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2031 | if (err < 0) |
| 2032 | return err; |
| 2033 | } else { |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 2034 | err = create_ch_ctls(codec, chname[i], pin, dac, 3); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2035 | if (err < 0) |
| 2036 | return err; |
| 2037 | } |
| 2038 | } |
| 2039 | |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 2040 | idx = get_connection_index(codec, spec->aa_mix_nid, |
| 2041 | spec->multiout.dac_nids[0]); |
| 2042 | if (idx >= 0) { |
| 2043 | /* add control to mixer */ |
| 2044 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, |
| 2045 | "PCM Playback Volume", |
| 2046 | HDA_COMPOSE_AMP_VAL(spec->aa_mix_nid, 3, |
| 2047 | idx, HDA_INPUT)); |
| 2048 | if (err < 0) |
| 2049 | return err; |
| 2050 | err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, |
| 2051 | "PCM Playback Switch", |
| 2052 | HDA_COMPOSE_AMP_VAL(spec->aa_mix_nid, 3, |
| 2053 | idx, HDA_INPUT)); |
| 2054 | if (err < 0) |
| 2055 | return err; |
| 2056 | } |
| 2057 | |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 2058 | cfg->line_outs = old_line_outs; |
| 2059 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2060 | return 0; |
| 2061 | } |
| 2062 | |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 2063 | static void create_hp_imux(struct via_spec *spec) |
| 2064 | { |
| 2065 | int i; |
| 2066 | struct hda_input_mux *imux = &spec->private_imux[1]; |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 2067 | static const char * const texts[] = { "OFF", "ON", NULL}; |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 2068 | |
| 2069 | /* for hp mode select */ |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2070 | for (i = 0; texts[i]; i++) |
| 2071 | snd_hda_add_imux_item(imux, texts[i], i, NULL); |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 2072 | |
| 2073 | spec->hp_mux = &spec->private_imux[1]; |
| 2074 | } |
| 2075 | |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 2076 | static int via_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin) |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2077 | { |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 2078 | struct via_spec *spec = codec->spec; |
| 2079 | hda_nid_t dac = 0; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2080 | int err; |
| 2081 | |
| 2082 | if (!pin) |
| 2083 | return 0; |
| 2084 | |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 2085 | if (!parse_output_path(codec, pin, spec->multiout.dac_nids[HDA_FRONT], |
| 2086 | &spec->hp_dep_path, 0, -1)) |
| 2087 | return 0; |
| 2088 | if (parse_output_path(codec, pin, 0, &spec->hp_path, 0, -1)) { |
| 2089 | dac = spec->hp_path.path[spec->hp_path.depth - 1]; |
| 2090 | spec->multiout.hp_nid = dac; |
| 2091 | spec->hp_independent_mode_index = |
| 2092 | spec->hp_path.idx[spec->hp_path.depth - 1]; |
| 2093 | create_hp_imux(spec); |
| 2094 | } |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2095 | |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 2096 | err = create_ch_ctls(codec, "Headphone", pin, dac, 3); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2097 | if (err < 0) |
| 2098 | return err; |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 2099 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2100 | return 0; |
| 2101 | } |
| 2102 | |
Takashi Iwai | a766d0d | 2011-06-17 09:01:29 +0200 | [diff] [blame] | 2103 | static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, |
| 2104 | hda_nid_t nid) |
| 2105 | { |
| 2106 | hda_nid_t conn[HDA_MAX_NUM_INPUTS]; |
| 2107 | int i, nums; |
| 2108 | |
| 2109 | nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn)); |
| 2110 | for (i = 0; i < nums; i++) |
| 2111 | if (conn[i] == nid) |
| 2112 | return i; |
| 2113 | return -1; |
| 2114 | } |
| 2115 | |
| 2116 | /* look for ADCs */ |
| 2117 | static int via_fill_adcs(struct hda_codec *codec) |
| 2118 | { |
| 2119 | struct via_spec *spec = codec->spec; |
| 2120 | hda_nid_t nid = codec->start_nid; |
| 2121 | int i; |
| 2122 | |
| 2123 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 2124 | unsigned int wcaps = get_wcaps(codec, nid); |
| 2125 | if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) |
| 2126 | continue; |
| 2127 | if (wcaps & AC_WCAP_DIGITAL) |
| 2128 | continue; |
| 2129 | if (!(wcaps & AC_WCAP_CONN_LIST)) |
| 2130 | continue; |
| 2131 | if (spec->num_adc_nids >= ARRAY_SIZE(spec->adc_nids)) |
| 2132 | return -ENOMEM; |
| 2133 | spec->adc_nids[spec->num_adc_nids++] = nid; |
| 2134 | } |
| 2135 | return 0; |
| 2136 | } |
| 2137 | |
| 2138 | static int get_mux_nids(struct hda_codec *codec); |
| 2139 | |
Takashi Iwai | d7a99cc | 2011-06-18 17:24:46 +0200 | [diff] [blame] | 2140 | static const struct snd_kcontrol_new via_input_src_ctl = { |
| 2141 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2142 | /* The multiple "Capture Source" controls confuse alsamixer |
| 2143 | * So call somewhat different.. |
| 2144 | */ |
| 2145 | /* .name = "Capture Source", */ |
| 2146 | .name = "Input Source", |
| 2147 | .info = via_mux_enum_info, |
| 2148 | .get = via_mux_enum_get, |
| 2149 | .put = via_mux_enum_put, |
| 2150 | }; |
| 2151 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2152 | /* create playback/capture controls for input pins */ |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 2153 | static int via_auto_create_analog_input_ctls(struct hda_codec *codec, |
| 2154 | const struct auto_pin_cfg *cfg) |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2155 | { |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2156 | struct via_spec *spec = codec->spec; |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 2157 | struct hda_input_mux *imux = &spec->private_imux[0]; |
Takashi Iwai | a766d0d | 2011-06-17 09:01:29 +0200 | [diff] [blame] | 2158 | int i, err, idx, idx2, type, type_idx = 0; |
| 2159 | hda_nid_t cap_nid; |
| 2160 | hda_nid_t pin_idxs[8]; |
| 2161 | int num_idxs; |
| 2162 | |
| 2163 | err = via_fill_adcs(codec); |
| 2164 | if (err < 0) |
| 2165 | return err; |
| 2166 | err = get_mux_nids(codec); |
| 2167 | if (err < 0) |
| 2168 | return err; |
| 2169 | cap_nid = spec->mux_nids[0]; |
| 2170 | |
| 2171 | num_idxs = snd_hda_get_connections(codec, cap_nid, pin_idxs, |
| 2172 | ARRAY_SIZE(pin_idxs)); |
| 2173 | if (num_idxs <= 0) |
| 2174 | return 0; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2175 | |
| 2176 | /* for internal loopback recording select */ |
Takashi Iwai | f326851 | 2010-08-30 11:00:19 +0200 | [diff] [blame] | 2177 | for (idx = 0; idx < num_idxs; idx++) { |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 2178 | if (pin_idxs[idx] == spec->aa_mix_nid) { |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2179 | snd_hda_add_imux_item(imux, "Stereo Mixer", idx, NULL); |
Takashi Iwai | f326851 | 2010-08-30 11:00:19 +0200 | [diff] [blame] | 2180 | break; |
| 2181 | } |
| 2182 | } |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2183 | |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 2184 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2185 | const char *label; |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 2186 | type = cfg->inputs[i].type; |
Takashi Iwai | f326851 | 2010-08-30 11:00:19 +0200 | [diff] [blame] | 2187 | for (idx = 0; idx < num_idxs; idx++) |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 2188 | if (pin_idxs[idx] == cfg->inputs[i].pin) |
Takashi Iwai | f326851 | 2010-08-30 11:00:19 +0200 | [diff] [blame] | 2189 | break; |
| 2190 | if (idx >= num_idxs) |
| 2191 | continue; |
Takashi Iwai | 7b315bb | 2010-08-30 13:06:30 +0200 | [diff] [blame] | 2192 | if (i > 0 && type == cfg->inputs[i - 1].type) |
| 2193 | type_idx++; |
| 2194 | else |
| 2195 | type_idx = 0; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2196 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 2197 | idx2 = get_connection_index(codec, spec->aa_mix_nid, |
| 2198 | pin_idxs[idx]); |
Takashi Iwai | a766d0d | 2011-06-17 09:01:29 +0200 | [diff] [blame] | 2199 | if (idx2 >= 0) |
Lydia Wang | 1692228 | 2011-03-22 16:24:10 +0800 | [diff] [blame] | 2200 | err = via_new_analog_input(spec, label, type_idx, |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 2201 | idx2, spec->aa_mix_nid); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2202 | if (err < 0) |
| 2203 | return err; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2204 | snd_hda_add_imux_item(imux, label, idx, NULL); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2205 | } |
Takashi Iwai | d7a99cc | 2011-06-18 17:24:46 +0200 | [diff] [blame] | 2206 | |
| 2207 | /* create capture mixer elements */ |
| 2208 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 2209 | hda_nid_t adc = spec->adc_nids[i]; |
| 2210 | err = __via_add_control(spec, VIA_CTL_WIDGET_VOL, |
| 2211 | "Capture Volume", i, |
| 2212 | HDA_COMPOSE_AMP_VAL(adc, 3, 0, |
| 2213 | HDA_INPUT)); |
| 2214 | if (err < 0) |
| 2215 | return err; |
| 2216 | err = __via_add_control(spec, VIA_CTL_WIDGET_MUTE, |
| 2217 | "Capture Switch", i, |
| 2218 | HDA_COMPOSE_AMP_VAL(adc, 3, 0, |
| 2219 | HDA_INPUT)); |
| 2220 | if (err < 0) |
| 2221 | return err; |
| 2222 | } |
| 2223 | |
| 2224 | /* input-source control */ |
| 2225 | for (i = 0; i < spec->num_adc_nids; i++) |
| 2226 | if (!spec->mux_nids[i]) |
| 2227 | break; |
| 2228 | if (i) { |
| 2229 | struct snd_kcontrol_new *knew; |
| 2230 | knew = via_clone_control(spec, &via_input_src_ctl); |
| 2231 | if (!knew) |
| 2232 | return -ENOMEM; |
| 2233 | knew->count = i; |
| 2234 | } |
| 2235 | |
| 2236 | /* mic-boosts */ |
| 2237 | for (i = 0; i < cfg->num_inputs; i++) { |
| 2238 | hda_nid_t pin = cfg->inputs[i].pin; |
| 2239 | unsigned int caps; |
| 2240 | const char *label; |
| 2241 | char name[32]; |
| 2242 | |
| 2243 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
| 2244 | continue; |
| 2245 | caps = query_amp_caps(codec, pin, HDA_INPUT); |
| 2246 | if (caps == -1 || !(caps & AC_AMPCAP_NUM_STEPS)) |
| 2247 | continue; |
| 2248 | label = hda_get_autocfg_input_label(codec, cfg, i); |
| 2249 | snprintf(name, sizeof(name), "%s Boost Capture Volume", label); |
| 2250 | err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, |
| 2251 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_INPUT)); |
| 2252 | if (err < 0) |
| 2253 | return err; |
| 2254 | } |
| 2255 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2256 | return 0; |
| 2257 | } |
| 2258 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2259 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 2260 | static const struct hda_amp_list vt1708_loopbacks[] = { |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2261 | { 0x17, HDA_INPUT, 1 }, |
| 2262 | { 0x17, HDA_INPUT, 2 }, |
| 2263 | { 0x17, HDA_INPUT, 3 }, |
| 2264 | { 0x17, HDA_INPUT, 4 }, |
| 2265 | { } /* end */ |
| 2266 | }; |
| 2267 | #endif |
| 2268 | |
Harald Welte | 76d9b0d | 2008-09-09 15:50:37 +0800 | [diff] [blame] | 2269 | static void vt1708_set_pinconfig_connect(struct hda_codec *codec, hda_nid_t nid) |
| 2270 | { |
| 2271 | unsigned int def_conf; |
| 2272 | unsigned char seqassoc; |
| 2273 | |
Takashi Iwai | 2f334f9 | 2009-02-20 14:37:42 +0100 | [diff] [blame] | 2274 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Harald Welte | 76d9b0d | 2008-09-09 15:50:37 +0800 | [diff] [blame] | 2275 | seqassoc = (unsigned char) get_defcfg_association(def_conf); |
| 2276 | seqassoc = (seqassoc << 4) | get_defcfg_sequence(def_conf); |
Lydia Wang | 82ef9e4 | 2009-10-10 19:08:19 +0800 | [diff] [blame] | 2277 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE |
| 2278 | && (seqassoc == 0xf0 || seqassoc == 0xff)) { |
| 2279 | def_conf = def_conf & (~(AC_JACK_PORT_BOTH << 30)); |
| 2280 | snd_hda_codec_set_pincfg(codec, nid, def_conf); |
Harald Welte | 76d9b0d | 2008-09-09 15:50:37 +0800 | [diff] [blame] | 2281 | } |
| 2282 | |
| 2283 | return; |
| 2284 | } |
| 2285 | |
Takashi Iwai | e06e5a2 | 2011-06-17 15:46:13 +0200 | [diff] [blame] | 2286 | static int vt1708_jack_detect_get(struct snd_kcontrol *kcontrol, |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 2287 | struct snd_ctl_elem_value *ucontrol) |
| 2288 | { |
| 2289 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2290 | struct via_spec *spec = codec->spec; |
| 2291 | |
| 2292 | if (spec->codec_type != VT1708) |
| 2293 | return 0; |
Takashi Iwai | e06e5a2 | 2011-06-17 15:46:13 +0200 | [diff] [blame] | 2294 | spec->vt1708_jack_detect = |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 2295 | !((snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8) & 0x1); |
Takashi Iwai | e06e5a2 | 2011-06-17 15:46:13 +0200 | [diff] [blame] | 2296 | ucontrol->value.integer.value[0] = spec->vt1708_jack_detect; |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 2297 | return 0; |
| 2298 | } |
| 2299 | |
Takashi Iwai | e06e5a2 | 2011-06-17 15:46:13 +0200 | [diff] [blame] | 2300 | static int vt1708_jack_detect_put(struct snd_kcontrol *kcontrol, |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 2301 | struct snd_ctl_elem_value *ucontrol) |
| 2302 | { |
| 2303 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2304 | struct via_spec *spec = codec->spec; |
| 2305 | int change; |
| 2306 | |
| 2307 | if (spec->codec_type != VT1708) |
| 2308 | return 0; |
Takashi Iwai | e06e5a2 | 2011-06-17 15:46:13 +0200 | [diff] [blame] | 2309 | spec->vt1708_jack_detect = ucontrol->value.integer.value[0]; |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 2310 | change = (0x1 & (snd_hda_codec_read(codec, 0x1, 0, 0xf84, 0) >> 8)) |
Takashi Iwai | e06e5a2 | 2011-06-17 15:46:13 +0200 | [diff] [blame] | 2311 | == !spec->vt1708_jack_detect; |
| 2312 | if (spec->vt1708_jack_detect) { |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 2313 | mute_aa_path(codec, 1); |
| 2314 | notify_aa_path_ctls(codec); |
| 2315 | } |
| 2316 | return change; |
| 2317 | } |
| 2318 | |
Takashi Iwai | e06e5a2 | 2011-06-17 15:46:13 +0200 | [diff] [blame] | 2319 | static const struct snd_kcontrol_new vt1708_jack_detect_ctl = { |
| 2320 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2321 | .name = "Jack Detect", |
| 2322 | .count = 1, |
| 2323 | .info = snd_ctl_boolean_mono_info, |
| 2324 | .get = vt1708_jack_detect_get, |
| 2325 | .put = vt1708_jack_detect_put, |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 2326 | }; |
| 2327 | |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 2328 | static void fill_dig_outs(struct hda_codec *codec); |
| 2329 | static void fill_dig_in(struct hda_codec *codec); |
| 2330 | |
| 2331 | static int via_parse_auto_config(struct hda_codec *codec) |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2332 | { |
| 2333 | struct via_spec *spec = codec->spec; |
| 2334 | int err; |
| 2335 | |
| 2336 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); |
| 2337 | if (err < 0) |
| 2338 | return err; |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 2339 | err = via_auto_fill_dac_nids(codec); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2340 | if (err < 0) |
| 2341 | return err; |
| 2342 | if (!spec->autocfg.line_outs && !spec->autocfg.hp_pins[0]) |
Takashi Iwai | 7f0df88 | 2011-06-18 17:33:34 +0200 | [diff] [blame] | 2343 | return -EINVAL; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2344 | |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 2345 | err = via_auto_create_multi_out_ctls(codec); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2346 | if (err < 0) |
| 2347 | return err; |
Takashi Iwai | 4a79616 | 2011-06-17 17:53:38 +0200 | [diff] [blame] | 2348 | err = via_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2349 | if (err < 0) |
| 2350 | return err; |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 2351 | err = via_auto_create_analog_input_ctls(codec, &spec->autocfg); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2352 | if (err < 0) |
| 2353 | return err; |
| 2354 | |
| 2355 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 2356 | |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 2357 | fill_dig_outs(codec); |
| 2358 | fill_dig_in(codec); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2359 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2360 | if (spec->kctls.list) |
| 2361 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2362 | |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 2363 | spec->init_verbs[spec->num_iverbs++] = vt1708_volume_init_verbs; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2364 | |
Harald Welte | 0aa62ae | 2008-09-09 15:58:27 +0800 | [diff] [blame] | 2365 | spec->input_mux = &spec->private_imux[0]; |
| 2366 | |
Harald Welte | f8fdd49 | 2008-09-15 22:41:31 +0800 | [diff] [blame] | 2367 | if (spec->hp_mux) |
Takashi Iwai | 3d83e57 | 2010-04-14 14:36:23 +0200 | [diff] [blame] | 2368 | via_hp_build(codec); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2369 | |
Takashi Iwai | f4a7828 | 2011-06-17 18:46:48 +0200 | [diff] [blame] | 2370 | err = via_smart51_build(codec); |
| 2371 | if (err < 0) |
| 2372 | return err; |
| 2373 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2374 | return 1; |
| 2375 | } |
| 2376 | |
| 2377 | /* init callback for auto-configuration model -- overriding the default init */ |
| 2378 | static int via_auto_init(struct hda_codec *codec) |
| 2379 | { |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 2380 | struct via_spec *spec = codec->spec; |
| 2381 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2382 | via_init(codec); |
| 2383 | via_auto_init_multi_out(codec); |
| 2384 | via_auto_init_hp_out(codec); |
| 2385 | via_auto_init_analog_input(codec); |
Lydia Wang | 11890956 | 2011-03-23 17:57:34 +0800 | [diff] [blame] | 2386 | |
| 2387 | if (VT2002P_COMPATIBLE(spec)) { |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 2388 | via_hp_bind_automute(codec); |
| 2389 | } else { |
| 2390 | via_hp_automute(codec); |
| 2391 | via_speaker_automute(codec); |
| 2392 | } |
| 2393 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2394 | return 0; |
| 2395 | } |
| 2396 | |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 2397 | static void vt1708_update_hp_jack_state(struct work_struct *work) |
| 2398 | { |
| 2399 | struct via_spec *spec = container_of(work, struct via_spec, |
| 2400 | vt1708_hp_work.work); |
| 2401 | if (spec->codec_type != VT1708) |
| 2402 | return; |
| 2403 | /* if jack state toggled */ |
| 2404 | if (spec->vt1708_hp_present |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 2405 | != snd_hda_jack_detect(spec->codec, spec->autocfg.hp_pins[0])) { |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 2406 | spec->vt1708_hp_present ^= 1; |
| 2407 | via_hp_automute(spec->codec); |
| 2408 | } |
| 2409 | vt1708_start_hp_work(spec); |
| 2410 | } |
| 2411 | |
Takashi Iwai | 337b9d0 | 2009-07-07 18:18:59 +0200 | [diff] [blame] | 2412 | static int get_mux_nids(struct hda_codec *codec) |
| 2413 | { |
| 2414 | struct via_spec *spec = codec->spec; |
| 2415 | hda_nid_t nid, conn[8]; |
| 2416 | unsigned int type; |
| 2417 | int i, n; |
| 2418 | |
| 2419 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 2420 | nid = spec->adc_nids[i]; |
| 2421 | while (nid) { |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 2422 | type = get_wcaps_type(get_wcaps(codec, nid)); |
Takashi Iwai | 1c55d52 | 2009-07-08 07:45:46 +0200 | [diff] [blame] | 2423 | if (type == AC_WID_PIN) |
| 2424 | break; |
Takashi Iwai | 337b9d0 | 2009-07-07 18:18:59 +0200 | [diff] [blame] | 2425 | n = snd_hda_get_connections(codec, nid, conn, |
| 2426 | ARRAY_SIZE(conn)); |
| 2427 | if (n <= 0) |
| 2428 | break; |
| 2429 | if (n > 1) { |
| 2430 | spec->mux_nids[i] = nid; |
| 2431 | break; |
| 2432 | } |
| 2433 | nid = conn[0]; |
| 2434 | } |
| 2435 | } |
Takashi Iwai | 1c55d52 | 2009-07-08 07:45:46 +0200 | [diff] [blame] | 2436 | return 0; |
Takashi Iwai | 337b9d0 | 2009-07-07 18:18:59 +0200 | [diff] [blame] | 2437 | } |
| 2438 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2439 | static int patch_vt1708(struct hda_codec *codec) |
| 2440 | { |
| 2441 | struct via_spec *spec; |
| 2442 | int err; |
| 2443 | |
| 2444 | /* create a codec specific record */ |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 2445 | spec = via_new_spec(codec); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2446 | if (spec == NULL) |
| 2447 | return -ENOMEM; |
| 2448 | |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 2449 | spec->aa_mix_nid = 0x17; |
| 2450 | |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 2451 | /* Add HP and CD pin config connect bit re-config action */ |
| 2452 | vt1708_set_pinconfig_connect(codec, VT1708_HP_PIN_NID); |
| 2453 | vt1708_set_pinconfig_connect(codec, VT1708_CD_PIN_NID); |
| 2454 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2455 | /* automatic parse from the BIOS config */ |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 2456 | err = via_parse_auto_config(codec); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2457 | if (err < 0) { |
| 2458 | via_free(codec); |
| 2459 | return err; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2460 | } |
| 2461 | |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 2462 | /* add jack detect on/off control */ |
| 2463 | if (!via_clone_control(spec, &vt1708_jack_detect_ctl)) |
| 2464 | return -ENOMEM; |
| 2465 | |
Takashi Iwai | bc9b56238 | 2008-05-23 17:50:27 +0200 | [diff] [blame] | 2466 | /* disable 32bit format on VT1708 */ |
| 2467 | if (codec->vendor_id == 0x11061708) |
| 2468 | spec->stream_analog_playback = &vt1708_pcm_analog_s16_playback; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2469 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2470 | codec->patch_ops = via_patch_ops; |
| 2471 | |
| 2472 | codec->patch_ops.init = via_auto_init; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2473 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 2474 | spec->loopback.amplist = vt1708_loopbacks; |
| 2475 | #endif |
Lydia Wang | 1f2e99f | 2009-10-10 19:08:17 +0800 | [diff] [blame] | 2476 | INIT_DELAYED_WORK(&spec->vt1708_hp_work, vt1708_update_hp_jack_state); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2477 | return 0; |
| 2478 | } |
| 2479 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 2480 | static const struct hda_verb vt1709_uniwill_init_verbs[] = { |
Lydia Wang | a34df19 | 2009-10-10 19:08:01 +0800 | [diff] [blame] | 2481 | {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, |
| 2482 | AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT}, |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 2483 | { } |
| 2484 | }; |
| 2485 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2486 | /* |
| 2487 | * generic initialization of ADC, input mixers and output mixers |
| 2488 | */ |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 2489 | static const struct hda_verb vt1709_10ch_volume_init_verbs[] = { |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2490 | /* |
| 2491 | * Unmute ADC0-2 and set the default input to mic-in |
| 2492 | */ |
| 2493 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2494 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2495 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2496 | |
| 2497 | |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2498 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2499 | * mixer widget |
| 2500 | */ |
| 2501 | /* Amp Indices: AOW0=0, CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2502 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2503 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 2504 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 2505 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 2506 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2507 | |
| 2508 | /* |
| 2509 | * Set up output selector (0x1a, 0x1b, 0x29) |
| 2510 | */ |
| 2511 | /* set vol=0 to output mixers */ |
| 2512 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2513 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2514 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2515 | |
| 2516 | /* |
| 2517 | * Unmute PW3 and PW4 |
| 2518 | */ |
| 2519 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2520 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2521 | |
Lydia Wang | bfdc675 | 2009-10-10 19:08:50 +0800 | [diff] [blame] | 2522 | /* Set input of PW4 as MW0 */ |
| 2523 | {0x20, AC_VERB_SET_CONNECT_SEL, 0}, |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2524 | /* PW9 Output enable */ |
| 2525 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 2526 | { } |
| 2527 | }; |
| 2528 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2529 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 2530 | static const struct hda_amp_list vt1709_loopbacks[] = { |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2531 | { 0x18, HDA_INPUT, 1 }, |
| 2532 | { 0x18, HDA_INPUT, 2 }, |
| 2533 | { 0x18, HDA_INPUT, 3 }, |
| 2534 | { 0x18, HDA_INPUT, 4 }, |
| 2535 | { } /* end */ |
| 2536 | }; |
| 2537 | #endif |
| 2538 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2539 | static int patch_vt1709_10ch(struct hda_codec *codec) |
| 2540 | { |
| 2541 | struct via_spec *spec; |
| 2542 | int err; |
| 2543 | |
| 2544 | /* create a codec specific record */ |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 2545 | spec = via_new_spec(codec); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2546 | if (spec == NULL) |
| 2547 | return -ENOMEM; |
| 2548 | |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 2549 | spec->aa_mix_nid = 0x18; |
| 2550 | |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 2551 | err = via_parse_auto_config(codec); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2552 | if (err < 0) { |
| 2553 | via_free(codec); |
| 2554 | return err; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2555 | } |
| 2556 | |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 2557 | spec->init_verbs[spec->num_iverbs++] = vt1709_10ch_volume_init_verbs; |
| 2558 | spec->init_verbs[spec->num_iverbs++] = vt1709_uniwill_init_verbs; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2559 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2560 | codec->patch_ops = via_patch_ops; |
| 2561 | |
| 2562 | codec->patch_ops.init = via_auto_init; |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 2563 | codec->patch_ops.unsol_event = via_unsol_event; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2564 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 2565 | spec->loopback.amplist = vt1709_loopbacks; |
| 2566 | #endif |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2567 | |
| 2568 | return 0; |
| 2569 | } |
| 2570 | /* |
| 2571 | * generic initialization of ADC, input mixers and output mixers |
| 2572 | */ |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 2573 | static const struct hda_verb vt1709_6ch_volume_init_verbs[] = { |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2574 | /* |
| 2575 | * Unmute ADC0-2 and set the default input to mic-in |
| 2576 | */ |
| 2577 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2578 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2579 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2580 | |
| 2581 | |
| 2582 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 2583 | * mixer widget |
| 2584 | */ |
| 2585 | /* Amp Indices: AOW0=0, CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ |
| 2586 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2587 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 2588 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 2589 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 2590 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 2591 | |
| 2592 | /* |
| 2593 | * Set up output selector (0x1a, 0x1b, 0x29) |
| 2594 | */ |
| 2595 | /* set vol=0 to output mixers */ |
| 2596 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2597 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2598 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2599 | |
| 2600 | /* |
| 2601 | * Unmute PW3 and PW4 |
| 2602 | */ |
| 2603 | {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2604 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2605 | |
| 2606 | /* Set input of PW4 as MW0 */ |
| 2607 | {0x20, AC_VERB_SET_CONNECT_SEL, 0}, |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2608 | /* PW9 Output enable */ |
| 2609 | {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 2610 | { } |
| 2611 | }; |
| 2612 | |
| 2613 | static int patch_vt1709_6ch(struct hda_codec *codec) |
| 2614 | { |
| 2615 | struct via_spec *spec; |
| 2616 | int err; |
| 2617 | |
| 2618 | /* create a codec specific record */ |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 2619 | spec = via_new_spec(codec); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2620 | if (spec == NULL) |
| 2621 | return -ENOMEM; |
| 2622 | |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 2623 | spec->aa_mix_nid = 0x18; |
| 2624 | |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 2625 | err = via_parse_auto_config(codec); |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2626 | if (err < 0) { |
| 2627 | via_free(codec); |
| 2628 | return err; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2629 | } |
| 2630 | |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 2631 | spec->init_verbs[spec->num_iverbs++] = vt1709_6ch_volume_init_verbs; |
| 2632 | spec->init_verbs[spec->num_iverbs++] = vt1709_uniwill_init_verbs; |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2633 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2634 | codec->patch_ops = via_patch_ops; |
| 2635 | |
| 2636 | codec->patch_ops.init = via_auto_init; |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 2637 | codec->patch_ops.unsol_event = via_unsol_event; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2638 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 2639 | spec->loopback.amplist = vt1709_loopbacks; |
| 2640 | #endif |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2641 | return 0; |
| 2642 | } |
| 2643 | |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2644 | /* |
| 2645 | * generic initialization of ADC, input mixers and output mixers |
| 2646 | */ |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 2647 | static const struct hda_verb vt1708B_8ch_volume_init_verbs[] = { |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2648 | /* |
| 2649 | * Unmute ADC0-1 and set the default input to mic-in |
| 2650 | */ |
| 2651 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2652 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2653 | |
| 2654 | |
| 2655 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 2656 | * mixer widget |
| 2657 | */ |
| 2658 | /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ |
| 2659 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2660 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 2661 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 2662 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 2663 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 2664 | |
| 2665 | /* |
| 2666 | * Set up output mixers |
| 2667 | */ |
| 2668 | /* set vol=0 to output mixers */ |
| 2669 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2670 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2671 | {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2672 | |
| 2673 | /* Setup default input to PW4 */ |
Lydia Wang | bfdc675 | 2009-10-10 19:08:50 +0800 | [diff] [blame] | 2674 | {0x1d, AC_VERB_SET_CONNECT_SEL, 0}, |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2675 | /* PW9 Output enable */ |
| 2676 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 2677 | /* PW10 Input enable */ |
| 2678 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 2679 | { } |
| 2680 | }; |
| 2681 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 2682 | static const struct hda_verb vt1708B_4ch_volume_init_verbs[] = { |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2683 | /* |
| 2684 | * Unmute ADC0-1 and set the default input to mic-in |
| 2685 | */ |
| 2686 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2687 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2688 | |
| 2689 | |
| 2690 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 2691 | * mixer widget |
| 2692 | */ |
| 2693 | /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ |
| 2694 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2695 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 2696 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 2697 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 2698 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 2699 | |
| 2700 | /* |
| 2701 | * Set up output mixers |
| 2702 | */ |
| 2703 | /* set vol=0 to output mixers */ |
| 2704 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2705 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2706 | {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
| 2707 | |
| 2708 | /* Setup default input of PW4 to MW0 */ |
| 2709 | {0x1d, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 2710 | /* PW9 Output enable */ |
| 2711 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 2712 | /* PW10 Input enable */ |
| 2713 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, |
| 2714 | { } |
| 2715 | }; |
| 2716 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 2717 | static const struct hda_verb vt1708B_uniwill_init_verbs[] = { |
Lydia Wang | a34df19 | 2009-10-10 19:08:01 +0800 | [diff] [blame] | 2718 | {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, |
| 2719 | AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT}, |
| 2720 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2721 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2722 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2723 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2724 | {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2725 | {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2726 | {0x23, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 2727 | { } |
| 2728 | }; |
| 2729 | |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2730 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 2731 | static const struct hda_amp_list vt1708B_loopbacks[] = { |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2732 | { 0x16, HDA_INPUT, 1 }, |
| 2733 | { 0x16, HDA_INPUT, 2 }, |
| 2734 | { 0x16, HDA_INPUT, 3 }, |
| 2735 | { 0x16, HDA_INPUT, 4 }, |
| 2736 | { } /* end */ |
| 2737 | }; |
| 2738 | #endif |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 2739 | |
| 2740 | static void set_widgets_power_state_vt1708B(struct hda_codec *codec) |
| 2741 | { |
| 2742 | struct via_spec *spec = codec->spec; |
| 2743 | int imux_is_smixer; |
| 2744 | unsigned int parm; |
| 2745 | int is_8ch = 0; |
Lydia Wang | bc92df7 | 2011-03-23 17:56:05 +0800 | [diff] [blame] | 2746 | if ((spec->codec_type != VT1708B_4CH) && |
| 2747 | (codec->vendor_id != 0x11064397)) |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 2748 | is_8ch = 1; |
| 2749 | |
| 2750 | /* SW0 (17h) = stereo mixer */ |
| 2751 | imux_is_smixer = |
| 2752 | (snd_hda_codec_read(codec, 0x17, 0, AC_VERB_GET_CONNECT_SEL, 0x00) |
| 2753 | == ((spec->codec_type == VT1708S) ? 5 : 0)); |
| 2754 | /* inputs */ |
| 2755 | /* PW 1/2/5 (1ah/1bh/1eh) */ |
| 2756 | parm = AC_PWRST_D3; |
| 2757 | set_pin_power_state(codec, 0x1a, &parm); |
| 2758 | set_pin_power_state(codec, 0x1b, &parm); |
| 2759 | set_pin_power_state(codec, 0x1e, &parm); |
| 2760 | if (imux_is_smixer) |
| 2761 | parm = AC_PWRST_D0; |
| 2762 | /* SW0 (17h), AIW 0/1 (13h/14h) */ |
| 2763 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_POWER_STATE, parm); |
| 2764 | snd_hda_codec_write(codec, 0x13, 0, AC_VERB_SET_POWER_STATE, parm); |
| 2765 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_POWER_STATE, parm); |
| 2766 | |
| 2767 | /* outputs */ |
| 2768 | /* PW0 (19h), SW1 (18h), AOW1 (11h) */ |
| 2769 | parm = AC_PWRST_D3; |
| 2770 | set_pin_power_state(codec, 0x19, &parm); |
| 2771 | if (spec->smart51_enabled) |
| 2772 | set_pin_power_state(codec, 0x1b, &parm); |
| 2773 | snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_POWER_STATE, parm); |
| 2774 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_POWER_STATE, parm); |
| 2775 | |
| 2776 | /* PW6 (22h), SW2 (26h), AOW2 (24h) */ |
| 2777 | if (is_8ch) { |
| 2778 | parm = AC_PWRST_D3; |
| 2779 | set_pin_power_state(codec, 0x22, &parm); |
| 2780 | if (spec->smart51_enabled) |
| 2781 | set_pin_power_state(codec, 0x1a, &parm); |
| 2782 | snd_hda_codec_write(codec, 0x26, 0, |
| 2783 | AC_VERB_SET_POWER_STATE, parm); |
| 2784 | snd_hda_codec_write(codec, 0x24, 0, |
| 2785 | AC_VERB_SET_POWER_STATE, parm); |
Lydia Wang | bc92df7 | 2011-03-23 17:56:05 +0800 | [diff] [blame] | 2786 | } else if (codec->vendor_id == 0x11064397) { |
| 2787 | /* PW7(23h), SW2(27h), AOW2(25h) */ |
| 2788 | parm = AC_PWRST_D3; |
| 2789 | set_pin_power_state(codec, 0x23, &parm); |
| 2790 | if (spec->smart51_enabled) |
| 2791 | set_pin_power_state(codec, 0x1a, &parm); |
| 2792 | snd_hda_codec_write(codec, 0x27, 0, |
| 2793 | AC_VERB_SET_POWER_STATE, parm); |
| 2794 | snd_hda_codec_write(codec, 0x25, 0, |
| 2795 | AC_VERB_SET_POWER_STATE, parm); |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 2796 | } |
| 2797 | |
| 2798 | /* PW 3/4/7 (1ch/1dh/23h) */ |
| 2799 | parm = AC_PWRST_D3; |
| 2800 | /* force to D0 for internal Speaker */ |
| 2801 | set_pin_power_state(codec, 0x1c, &parm); |
| 2802 | set_pin_power_state(codec, 0x1d, &parm); |
| 2803 | if (is_8ch) |
| 2804 | set_pin_power_state(codec, 0x23, &parm); |
| 2805 | |
| 2806 | /* MW0 (16h), Sw3 (27h), AOW 0/3 (10h/25h) */ |
| 2807 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_POWER_STATE, |
| 2808 | imux_is_smixer ? AC_PWRST_D0 : parm); |
| 2809 | snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_POWER_STATE, parm); |
| 2810 | if (is_8ch) { |
| 2811 | snd_hda_codec_write(codec, 0x25, 0, |
| 2812 | AC_VERB_SET_POWER_STATE, parm); |
| 2813 | snd_hda_codec_write(codec, 0x27, 0, |
| 2814 | AC_VERB_SET_POWER_STATE, parm); |
Lydia Wang | bc92df7 | 2011-03-23 17:56:05 +0800 | [diff] [blame] | 2815 | } else if (codec->vendor_id == 0x11064397 && spec->hp_independent_mode) |
| 2816 | snd_hda_codec_write(codec, 0x25, 0, |
| 2817 | AC_VERB_SET_POWER_STATE, parm); |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 2818 | } |
| 2819 | |
Lydia Wang | 518bf3b | 2009-10-10 19:07:29 +0800 | [diff] [blame] | 2820 | static int patch_vt1708S(struct hda_codec *codec); |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2821 | static int patch_vt1708B_8ch(struct hda_codec *codec) |
| 2822 | { |
| 2823 | struct via_spec *spec; |
| 2824 | int err; |
| 2825 | |
Lydia Wang | 518bf3b | 2009-10-10 19:07:29 +0800 | [diff] [blame] | 2826 | if (get_codec_type(codec) == VT1708BCE) |
| 2827 | return patch_vt1708S(codec); |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2828 | /* create a codec specific record */ |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 2829 | spec = via_new_spec(codec); |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2830 | if (spec == NULL) |
| 2831 | return -ENOMEM; |
| 2832 | |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 2833 | spec->aa_mix_nid = 0x16; |
| 2834 | |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2835 | /* automatic parse from the BIOS config */ |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 2836 | err = via_parse_auto_config(codec); |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2837 | if (err < 0) { |
| 2838 | via_free(codec); |
| 2839 | return err; |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2840 | } |
| 2841 | |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 2842 | spec->init_verbs[spec->num_iverbs++] = vt1708B_8ch_volume_init_verbs; |
| 2843 | spec->init_verbs[spec->num_iverbs++] = vt1708B_uniwill_init_verbs; |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2844 | |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2845 | codec->patch_ops = via_patch_ops; |
| 2846 | |
| 2847 | codec->patch_ops.init = via_auto_init; |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 2848 | codec->patch_ops.unsol_event = via_unsol_event; |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2849 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 2850 | spec->loopback.amplist = vt1708B_loopbacks; |
| 2851 | #endif |
| 2852 | |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 2853 | spec->set_widgets_power_state = set_widgets_power_state_vt1708B; |
| 2854 | |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2855 | return 0; |
| 2856 | } |
| 2857 | |
| 2858 | static int patch_vt1708B_4ch(struct hda_codec *codec) |
| 2859 | { |
| 2860 | struct via_spec *spec; |
| 2861 | int err; |
| 2862 | |
| 2863 | /* create a codec specific record */ |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 2864 | spec = via_new_spec(codec); |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2865 | if (spec == NULL) |
| 2866 | return -ENOMEM; |
| 2867 | |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2868 | /* automatic parse from the BIOS config */ |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 2869 | err = via_parse_auto_config(codec); |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2870 | if (err < 0) { |
| 2871 | via_free(codec); |
| 2872 | return err; |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2873 | } |
| 2874 | |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 2875 | spec->init_verbs[spec->num_iverbs++] = vt1708B_4ch_volume_init_verbs; |
| 2876 | spec->init_verbs[spec->num_iverbs++] = vt1708B_uniwill_init_verbs; |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2877 | |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2878 | codec->patch_ops = via_patch_ops; |
| 2879 | |
| 2880 | codec->patch_ops.init = via_auto_init; |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 2881 | codec->patch_ops.unsol_event = via_unsol_event; |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 2882 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 2883 | spec->loopback.amplist = vt1708B_loopbacks; |
| 2884 | #endif |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2885 | |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 2886 | spec->set_widgets_power_state = set_widgets_power_state_vt1708B; |
| 2887 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 2888 | return 0; |
| 2889 | } |
| 2890 | |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 2891 | /* Patch for VT1708S */ |
| 2892 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 2893 | static const struct hda_verb vt1708S_volume_init_verbs[] = { |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 2894 | /* Unmute ADC0-1 and set the default input to mic-in */ |
| 2895 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2896 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2897 | |
| 2898 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the |
| 2899 | * analog-loopback mixer widget */ |
| 2900 | /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ |
| 2901 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 2902 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 2903 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 2904 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 2905 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, |
| 2906 | |
| 2907 | /* Setup default input of PW4 to MW0 */ |
| 2908 | {0x1d, AC_VERB_SET_CONNECT_SEL, 0x0}, |
Harald Welte | 5691ec7 | 2008-09-15 22:42:26 +0800 | [diff] [blame] | 2909 | /* PW9, PW10 Output enable */ |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 2910 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
Harald Welte | 5691ec7 | 2008-09-15 22:42:26 +0800 | [diff] [blame] | 2911 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
Harald Welte | d742632 | 2008-09-15 22:43:23 +0800 | [diff] [blame] | 2912 | /* Enable Mic Boost Volume backdoor */ |
| 2913 | {0x1, 0xf98, 0x1}, |
Lydia Wang | bc7e7e5 | 2009-10-10 19:08:32 +0800 | [diff] [blame] | 2914 | /* don't bybass mixer */ |
| 2915 | {0x1, 0xf88, 0xc0}, |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 2916 | { } |
| 2917 | }; |
| 2918 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 2919 | static const struct hda_verb vt1708S_uniwill_init_verbs[] = { |
Lydia Wang | a34df19 | 2009-10-10 19:08:01 +0800 | [diff] [blame] | 2920 | {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, |
| 2921 | AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT}, |
| 2922 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2923 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2924 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2925 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2926 | {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2927 | {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2928 | {0x23, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 2929 | { } |
| 2930 | }; |
| 2931 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 2932 | static const struct hda_verb vt1705_uniwill_init_verbs[] = { |
Lydia Wang | bc92df7 | 2011-03-23 17:56:05 +0800 | [diff] [blame] | 2933 | {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, |
| 2934 | AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT}, |
| 2935 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2936 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2937 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2938 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2939 | {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2940 | {0x23, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 2941 | { } |
| 2942 | }; |
| 2943 | |
Takashi Iwai | 9da2927 | 2009-05-07 16:31:14 +0200 | [diff] [blame] | 2944 | /* fill out digital output widgets; one for master and one for slave outputs */ |
| 2945 | static void fill_dig_outs(struct hda_codec *codec) |
| 2946 | { |
| 2947 | struct via_spec *spec = codec->spec; |
| 2948 | int i; |
| 2949 | |
| 2950 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
| 2951 | hda_nid_t nid; |
| 2952 | int conn; |
| 2953 | |
| 2954 | nid = spec->autocfg.dig_out_pins[i]; |
| 2955 | if (!nid) |
| 2956 | continue; |
| 2957 | conn = snd_hda_get_connections(codec, nid, &nid, 1); |
| 2958 | if (conn < 1) |
| 2959 | continue; |
| 2960 | if (!spec->multiout.dig_out_nid) |
| 2961 | spec->multiout.dig_out_nid = nid; |
| 2962 | else { |
| 2963 | spec->slave_dig_outs[0] = nid; |
| 2964 | break; /* at most two dig outs */ |
| 2965 | } |
| 2966 | } |
| 2967 | } |
| 2968 | |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 2969 | static void fill_dig_in(struct hda_codec *codec) |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 2970 | { |
| 2971 | struct via_spec *spec = codec->spec; |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 2972 | hda_nid_t dig_nid; |
| 2973 | int i, err; |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 2974 | |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 2975 | if (!spec->autocfg.dig_in_pin) |
| 2976 | return; |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 2977 | |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 2978 | dig_nid = codec->start_nid; |
| 2979 | for (i = 0; i < codec->num_nodes; i++, dig_nid++) { |
| 2980 | unsigned int wcaps = get_wcaps(codec, dig_nid); |
| 2981 | if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) |
| 2982 | continue; |
| 2983 | if (!(wcaps & AC_WCAP_DIGITAL)) |
| 2984 | continue; |
| 2985 | if (!(wcaps & AC_WCAP_CONN_LIST)) |
| 2986 | continue; |
| 2987 | err = get_connection_index(codec, dig_nid, |
| 2988 | spec->autocfg.dig_in_pin); |
| 2989 | if (err >= 0) { |
| 2990 | spec->dig_in_nid = dig_nid; |
| 2991 | break; |
| 2992 | } |
| 2993 | } |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 2994 | } |
| 2995 | |
| 2996 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 2997 | static const struct hda_amp_list vt1708S_loopbacks[] = { |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 2998 | { 0x16, HDA_INPUT, 1 }, |
| 2999 | { 0x16, HDA_INPUT, 2 }, |
| 3000 | { 0x16, HDA_INPUT, 3 }, |
| 3001 | { 0x16, HDA_INPUT, 4 }, |
| 3002 | { } /* end */ |
| 3003 | }; |
| 3004 | #endif |
| 3005 | |
Lydia Wang | 6369bcf | 2009-10-10 19:08:31 +0800 | [diff] [blame] | 3006 | static void override_mic_boost(struct hda_codec *codec, hda_nid_t pin, |
| 3007 | int offset, int num_steps, int step_size) |
| 3008 | { |
| 3009 | snd_hda_override_amp_caps(codec, pin, HDA_INPUT, |
| 3010 | (offset << AC_AMPCAP_OFFSET_SHIFT) | |
| 3011 | (num_steps << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 3012 | (step_size << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 3013 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 3014 | } |
| 3015 | |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3016 | static int patch_vt1708S(struct hda_codec *codec) |
| 3017 | { |
| 3018 | struct via_spec *spec; |
| 3019 | int err; |
| 3020 | |
| 3021 | /* create a codec specific record */ |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 3022 | spec = via_new_spec(codec); |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3023 | if (spec == NULL) |
| 3024 | return -ENOMEM; |
| 3025 | |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 3026 | spec->aa_mix_nid = 0x16; |
Takashi Iwai | d7a99cc | 2011-06-18 17:24:46 +0200 | [diff] [blame] | 3027 | override_mic_boost(codec, 0x1a, 0, 3, 40); |
| 3028 | override_mic_boost(codec, 0x1e, 0, 3, 40); |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 3029 | |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3030 | /* automatic parse from the BIOS config */ |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 3031 | err = via_parse_auto_config(codec); |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3032 | if (err < 0) { |
| 3033 | via_free(codec); |
| 3034 | return err; |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3035 | } |
| 3036 | |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 3037 | spec->init_verbs[spec->num_iverbs++] = vt1708S_volume_init_verbs; |
Lydia Wang | bc92df7 | 2011-03-23 17:56:05 +0800 | [diff] [blame] | 3038 | if (codec->vendor_id == 0x11064397) |
| 3039 | spec->init_verbs[spec->num_iverbs++] = |
| 3040 | vt1705_uniwill_init_verbs; |
| 3041 | else |
| 3042 | spec->init_verbs[spec->num_iverbs++] = |
| 3043 | vt1708S_uniwill_init_verbs; |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3044 | |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3045 | codec->patch_ops = via_patch_ops; |
| 3046 | |
| 3047 | codec->patch_ops.init = via_auto_init; |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 3048 | codec->patch_ops.unsol_event = via_unsol_event; |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3049 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 3050 | spec->loopback.amplist = vt1708S_loopbacks; |
| 3051 | #endif |
| 3052 | |
Lydia Wang | 518bf3b | 2009-10-10 19:07:29 +0800 | [diff] [blame] | 3053 | /* correct names for VT1708BCE */ |
| 3054 | if (get_codec_type(codec) == VT1708BCE) { |
| 3055 | kfree(codec->chip_name); |
| 3056 | codec->chip_name = kstrdup("VT1708BCE", GFP_KERNEL); |
| 3057 | snprintf(codec->bus->card->mixername, |
| 3058 | sizeof(codec->bus->card->mixername), |
| 3059 | "%s %s", codec->vendor_name, codec->chip_name); |
Lydia Wang | 970f630f | 2011-03-22 16:25:56 +0800 | [diff] [blame] | 3060 | } |
Lydia Wang | bc92df7 | 2011-03-23 17:56:05 +0800 | [diff] [blame] | 3061 | /* correct names for VT1705 */ |
| 3062 | if (codec->vendor_id == 0x11064397) { |
| 3063 | kfree(codec->chip_name); |
| 3064 | codec->chip_name = kstrdup("VT1705", GFP_KERNEL); |
| 3065 | snprintf(codec->bus->card->mixername, |
| 3066 | sizeof(codec->bus->card->mixername), |
| 3067 | "%s %s", codec->vendor_name, codec->chip_name); |
| 3068 | } |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 3069 | spec->set_widgets_power_state = set_widgets_power_state_vt1708B; |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3070 | return 0; |
| 3071 | } |
| 3072 | |
| 3073 | /* Patch for VT1702 */ |
| 3074 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3075 | static const struct hda_verb vt1702_volume_init_verbs[] = { |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3076 | /* |
| 3077 | * Unmute ADC0-1 and set the default input to mic-in |
| 3078 | */ |
| 3079 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3080 | {0x1F, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3081 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3082 | |
| 3083 | |
| 3084 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 3085 | * mixer widget |
| 3086 | */ |
| 3087 | /* Amp Indices: Mic1 = 1, Line = 1, Mic2 = 3 */ |
| 3088 | {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3089 | {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3090 | {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
| 3091 | {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, |
| 3092 | {0x1A, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 3093 | |
| 3094 | /* Setup default input of PW4 to MW0 */ |
| 3095 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 3096 | /* PW6 PW7 Output enable */ |
| 3097 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 3098 | {0x1C, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
Lydia Wang | bc7e7e5 | 2009-10-10 19:08:32 +0800 | [diff] [blame] | 3099 | /* mixer enable */ |
| 3100 | {0x1, 0xF88, 0x3}, |
| 3101 | /* GPIO 0~2 */ |
| 3102 | {0x1, 0xF82, 0x3F}, |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3103 | { } |
| 3104 | }; |
| 3105 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3106 | static const struct hda_verb vt1702_uniwill_init_verbs[] = { |
Lydia Wang | a34df19 | 2009-10-10 19:08:01 +0800 | [diff] [blame] | 3107 | {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, |
| 3108 | AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT}, |
| 3109 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3110 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3111 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3112 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 3113 | { } |
| 3114 | }; |
| 3115 | |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3116 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3117 | static const struct hda_amp_list vt1702_loopbacks[] = { |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3118 | { 0x1A, HDA_INPUT, 1 }, |
| 3119 | { 0x1A, HDA_INPUT, 2 }, |
| 3120 | { 0x1A, HDA_INPUT, 3 }, |
| 3121 | { 0x1A, HDA_INPUT, 4 }, |
| 3122 | { } /* end */ |
| 3123 | }; |
| 3124 | #endif |
| 3125 | |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 3126 | static void set_widgets_power_state_vt1702(struct hda_codec *codec) |
| 3127 | { |
| 3128 | int imux_is_smixer = |
| 3129 | snd_hda_codec_read(codec, 0x13, 0, AC_VERB_GET_CONNECT_SEL, 0x00) == 3; |
| 3130 | unsigned int parm; |
| 3131 | /* inputs */ |
| 3132 | /* PW 1/2/5 (14h/15h/18h) */ |
| 3133 | parm = AC_PWRST_D3; |
| 3134 | set_pin_power_state(codec, 0x14, &parm); |
| 3135 | set_pin_power_state(codec, 0x15, &parm); |
| 3136 | set_pin_power_state(codec, 0x18, &parm); |
| 3137 | if (imux_is_smixer) |
| 3138 | parm = AC_PWRST_D0; /* SW0 (13h) = stereo mixer (idx 3) */ |
| 3139 | /* SW0 (13h), AIW 0/1/2 (12h/1fh/20h) */ |
| 3140 | snd_hda_codec_write(codec, 0x13, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3141 | snd_hda_codec_write(codec, 0x12, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3142 | snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3143 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3144 | |
| 3145 | /* outputs */ |
| 3146 | /* PW 3/4 (16h/17h) */ |
| 3147 | parm = AC_PWRST_D3; |
| 3148 | set_pin_power_state(codec, 0x17, &parm); |
| 3149 | set_pin_power_state(codec, 0x16, &parm); |
| 3150 | /* MW0 (1ah), AOW 0/1 (10h/1dh) */ |
| 3151 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_POWER_STATE, |
| 3152 | imux_is_smixer ? AC_PWRST_D0 : parm); |
| 3153 | snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3154 | snd_hda_codec_write(codec, 0x1d, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3155 | } |
| 3156 | |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3157 | static int patch_vt1702(struct hda_codec *codec) |
| 3158 | { |
| 3159 | struct via_spec *spec; |
| 3160 | int err; |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3161 | |
| 3162 | /* create a codec specific record */ |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 3163 | spec = via_new_spec(codec); |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3164 | if (spec == NULL) |
| 3165 | return -ENOMEM; |
| 3166 | |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 3167 | spec->aa_mix_nid = 0x1a; |
| 3168 | |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 3169 | /* limit AA path volume to 0 dB */ |
| 3170 | snd_hda_override_amp_caps(codec, 0x1A, HDA_INPUT, |
| 3171 | (0x17 << AC_AMPCAP_OFFSET_SHIFT) | |
| 3172 | (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 3173 | (0x5 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 3174 | (1 << AC_AMPCAP_MUTE_SHIFT)); |
| 3175 | |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3176 | /* automatic parse from the BIOS config */ |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 3177 | err = via_parse_auto_config(codec); |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3178 | if (err < 0) { |
| 3179 | via_free(codec); |
| 3180 | return err; |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3181 | } |
| 3182 | |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 3183 | spec->init_verbs[spec->num_iverbs++] = vt1702_volume_init_verbs; |
| 3184 | spec->init_verbs[spec->num_iverbs++] = vt1702_uniwill_init_verbs; |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3185 | |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3186 | codec->patch_ops = via_patch_ops; |
| 3187 | |
| 3188 | codec->patch_ops.init = via_auto_init; |
Harald Welte | 69e52a8 | 2008-09-09 15:57:32 +0800 | [diff] [blame] | 3189 | codec->patch_ops.unsol_event = via_unsol_event; |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3190 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 3191 | spec->loopback.amplist = vt1702_loopbacks; |
| 3192 | #endif |
| 3193 | |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 3194 | spec->set_widgets_power_state = set_widgets_power_state_vt1702; |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 3195 | return 0; |
| 3196 | } |
| 3197 | |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 3198 | /* Patch for VT1718S */ |
| 3199 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3200 | static const struct hda_verb vt1718S_volume_init_verbs[] = { |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 3201 | /* |
| 3202 | * Unmute ADC0-1 and set the default input to mic-in |
| 3203 | */ |
| 3204 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3205 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3206 | |
Lydia Wang | 4ab2d53 | 2011-03-24 12:42:03 +0800 | [diff] [blame] | 3207 | /* Enable MW0 adjust Gain 5 */ |
| 3208 | {0x1, 0xfb2, 0x10}, |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 3209 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 3210 | * mixer widget |
| 3211 | */ |
| 3212 | /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ |
| 3213 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3214 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3215 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 3216 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
Lydia Wang | 4ab2d53 | 2011-03-24 12:42:03 +0800 | [diff] [blame] | 3217 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 3218 | |
| 3219 | /* Setup default input of Front HP to MW9 */ |
| 3220 | {0x28, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 3221 | /* PW9 PW10 Output enable */ |
| 3222 | {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN}, |
| 3223 | {0x2e, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN}, |
| 3224 | /* PW11 Input enable */ |
| 3225 | {0x2f, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_IN_EN}, |
| 3226 | /* Enable Boost Volume backdoor */ |
| 3227 | {0x1, 0xf88, 0x8}, |
| 3228 | /* MW0/1/2/3/4: un-mute index 0 (AOWx), mute index 1 (MW9) */ |
| 3229 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3230 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3231 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3232 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3233 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3234 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3235 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3236 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3237 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3238 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3239 | /* set MUX1 = 2 (AOW4), MUX2 = 1 (AOW3) */ |
| 3240 | {0x34, AC_VERB_SET_CONNECT_SEL, 0x2}, |
| 3241 | {0x35, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 3242 | /* Unmute MW4's index 0 */ |
| 3243 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3244 | { } |
| 3245 | }; |
| 3246 | |
| 3247 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3248 | static const struct hda_verb vt1718S_uniwill_init_verbs[] = { |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 3249 | {0x28, AC_VERB_SET_UNSOLICITED_ENABLE, |
| 3250 | AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT}, |
| 3251 | {0x24, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3252 | {0x25, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3253 | {0x26, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3254 | {0x27, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3255 | {0x29, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3256 | {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3257 | {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3258 | { } |
| 3259 | }; |
| 3260 | |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 3261 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3262 | static const struct hda_amp_list vt1718S_loopbacks[] = { |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 3263 | { 0x21, HDA_INPUT, 1 }, |
| 3264 | { 0x21, HDA_INPUT, 2 }, |
| 3265 | { 0x21, HDA_INPUT, 3 }, |
| 3266 | { 0x21, HDA_INPUT, 4 }, |
| 3267 | { } /* end */ |
| 3268 | }; |
| 3269 | #endif |
| 3270 | |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 3271 | static void set_widgets_power_state_vt1718S(struct hda_codec *codec) |
| 3272 | { |
| 3273 | struct via_spec *spec = codec->spec; |
| 3274 | int imux_is_smixer; |
| 3275 | unsigned int parm; |
| 3276 | /* MUX6 (1eh) = stereo mixer */ |
| 3277 | imux_is_smixer = |
| 3278 | snd_hda_codec_read(codec, 0x1e, 0, AC_VERB_GET_CONNECT_SEL, 0x00) == 5; |
| 3279 | /* inputs */ |
| 3280 | /* PW 5/6/7 (29h/2ah/2bh) */ |
| 3281 | parm = AC_PWRST_D3; |
| 3282 | set_pin_power_state(codec, 0x29, &parm); |
| 3283 | set_pin_power_state(codec, 0x2a, &parm); |
| 3284 | set_pin_power_state(codec, 0x2b, &parm); |
| 3285 | if (imux_is_smixer) |
| 3286 | parm = AC_PWRST_D0; |
| 3287 | /* MUX6/7 (1eh/1fh), AIW 0/1 (10h/11h) */ |
| 3288 | snd_hda_codec_write(codec, 0x1e, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3289 | snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3290 | snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3291 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3292 | |
| 3293 | /* outputs */ |
| 3294 | /* PW3 (27h), MW2 (1ah), AOW3 (bh) */ |
| 3295 | parm = AC_PWRST_D3; |
| 3296 | set_pin_power_state(codec, 0x27, &parm); |
| 3297 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3298 | snd_hda_codec_write(codec, 0xb, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3299 | |
| 3300 | /* PW2 (26h), AOW2 (ah) */ |
| 3301 | parm = AC_PWRST_D3; |
| 3302 | set_pin_power_state(codec, 0x26, &parm); |
| 3303 | if (spec->smart51_enabled) |
| 3304 | set_pin_power_state(codec, 0x2b, &parm); |
| 3305 | snd_hda_codec_write(codec, 0xa, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3306 | |
| 3307 | /* PW0 (24h), AOW0 (8h) */ |
| 3308 | parm = AC_PWRST_D3; |
| 3309 | set_pin_power_state(codec, 0x24, &parm); |
| 3310 | if (!spec->hp_independent_mode) /* check for redirected HP */ |
| 3311 | set_pin_power_state(codec, 0x28, &parm); |
| 3312 | snd_hda_codec_write(codec, 0x8, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3313 | /* MW9 (21h), Mw2 (1ah), AOW0 (8h) */ |
| 3314 | snd_hda_codec_write(codec, 0x21, 0, AC_VERB_SET_POWER_STATE, |
| 3315 | imux_is_smixer ? AC_PWRST_D0 : parm); |
| 3316 | |
| 3317 | /* PW1 (25h), AOW1 (9h) */ |
| 3318 | parm = AC_PWRST_D3; |
| 3319 | set_pin_power_state(codec, 0x25, &parm); |
| 3320 | if (spec->smart51_enabled) |
| 3321 | set_pin_power_state(codec, 0x2a, &parm); |
| 3322 | snd_hda_codec_write(codec, 0x9, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3323 | |
| 3324 | if (spec->hp_independent_mode) { |
| 3325 | /* PW4 (28h), MW3 (1bh), MUX1(34h), AOW4 (ch) */ |
| 3326 | parm = AC_PWRST_D3; |
| 3327 | set_pin_power_state(codec, 0x28, &parm); |
| 3328 | snd_hda_codec_write(codec, 0x1b, 0, |
| 3329 | AC_VERB_SET_POWER_STATE, parm); |
| 3330 | snd_hda_codec_write(codec, 0x34, 0, |
| 3331 | AC_VERB_SET_POWER_STATE, parm); |
| 3332 | snd_hda_codec_write(codec, 0xc, 0, |
| 3333 | AC_VERB_SET_POWER_STATE, parm); |
| 3334 | } |
| 3335 | } |
| 3336 | |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 3337 | static int patch_vt1718S(struct hda_codec *codec) |
| 3338 | { |
| 3339 | struct via_spec *spec; |
| 3340 | int err; |
| 3341 | |
| 3342 | /* create a codec specific record */ |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 3343 | spec = via_new_spec(codec); |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 3344 | if (spec == NULL) |
| 3345 | return -ENOMEM; |
| 3346 | |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 3347 | spec->aa_mix_nid = 0x21; |
Takashi Iwai | d7a99cc | 2011-06-18 17:24:46 +0200 | [diff] [blame] | 3348 | override_mic_boost(codec, 0x2b, 0, 3, 40); |
| 3349 | override_mic_boost(codec, 0x29, 0, 3, 40); |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 3350 | |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 3351 | /* automatic parse from the BIOS config */ |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 3352 | err = via_parse_auto_config(codec); |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 3353 | if (err < 0) { |
| 3354 | via_free(codec); |
| 3355 | return err; |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 3356 | } |
| 3357 | |
| 3358 | spec->init_verbs[spec->num_iverbs++] = vt1718S_volume_init_verbs; |
| 3359 | spec->init_verbs[spec->num_iverbs++] = vt1718S_uniwill_init_verbs; |
| 3360 | |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 3361 | codec->patch_ops = via_patch_ops; |
| 3362 | |
| 3363 | codec->patch_ops.init = via_auto_init; |
Stephen Rothwell | 0f48327 | 2009-10-12 15:56:17 +1100 | [diff] [blame] | 3364 | codec->patch_ops.unsol_event = via_unsol_event; |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 3365 | |
| 3366 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 3367 | spec->loopback.amplist = vt1718S_loopbacks; |
| 3368 | #endif |
| 3369 | |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 3370 | spec->set_widgets_power_state = set_widgets_power_state_vt1718S; |
| 3371 | |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 3372 | return 0; |
| 3373 | } |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 3374 | |
| 3375 | /* Patch for VT1716S */ |
| 3376 | |
| 3377 | static int vt1716s_dmic_info(struct snd_kcontrol *kcontrol, |
| 3378 | struct snd_ctl_elem_info *uinfo) |
| 3379 | { |
| 3380 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
| 3381 | uinfo->count = 1; |
| 3382 | uinfo->value.integer.min = 0; |
| 3383 | uinfo->value.integer.max = 1; |
| 3384 | return 0; |
| 3385 | } |
| 3386 | |
| 3387 | static int vt1716s_dmic_get(struct snd_kcontrol *kcontrol, |
| 3388 | struct snd_ctl_elem_value *ucontrol) |
| 3389 | { |
| 3390 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3391 | int index = 0; |
| 3392 | |
| 3393 | index = snd_hda_codec_read(codec, 0x26, 0, |
| 3394 | AC_VERB_GET_CONNECT_SEL, 0); |
| 3395 | if (index != -1) |
| 3396 | *ucontrol->value.integer.value = index; |
| 3397 | |
| 3398 | return 0; |
| 3399 | } |
| 3400 | |
| 3401 | static int vt1716s_dmic_put(struct snd_kcontrol *kcontrol, |
| 3402 | struct snd_ctl_elem_value *ucontrol) |
| 3403 | { |
| 3404 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3405 | struct via_spec *spec = codec->spec; |
| 3406 | int index = *ucontrol->value.integer.value; |
| 3407 | |
| 3408 | snd_hda_codec_write(codec, 0x26, 0, |
| 3409 | AC_VERB_SET_CONNECT_SEL, index); |
| 3410 | spec->dmic_enabled = index; |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 3411 | set_widgets_power_state(codec); |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 3412 | return 1; |
| 3413 | } |
| 3414 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3415 | static const struct snd_kcontrol_new vt1716s_dmic_mixer[] = { |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 3416 | HDA_CODEC_VOLUME("Digital Mic Capture Volume", 0x22, 0x0, HDA_INPUT), |
| 3417 | { |
| 3418 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3419 | .name = "Digital Mic Capture Switch", |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 3420 | .subdevice = HDA_SUBDEV_NID_FLAG | 0x26, |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 3421 | .count = 1, |
| 3422 | .info = vt1716s_dmic_info, |
| 3423 | .get = vt1716s_dmic_get, |
| 3424 | .put = vt1716s_dmic_put, |
| 3425 | }, |
| 3426 | {} /* end */ |
| 3427 | }; |
| 3428 | |
| 3429 | |
| 3430 | /* mono-out mixer elements */ |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3431 | static const struct snd_kcontrol_new vt1716S_mono_out_mixer[] = { |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 3432 | HDA_CODEC_MUTE("Mono Playback Switch", 0x2a, 0x0, HDA_OUTPUT), |
| 3433 | { } /* end */ |
| 3434 | }; |
| 3435 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3436 | static const struct hda_verb vt1716S_volume_init_verbs[] = { |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 3437 | /* |
| 3438 | * Unmute ADC0-1 and set the default input to mic-in |
| 3439 | */ |
| 3440 | {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3441 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3442 | |
| 3443 | |
| 3444 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 3445 | * mixer widget |
| 3446 | */ |
| 3447 | /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ |
| 3448 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3449 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3450 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 3451 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 3452 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 3453 | |
| 3454 | /* MUX Indices: Stereo Mixer = 5 */ |
| 3455 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x5}, |
| 3456 | |
| 3457 | /* Setup default input of PW4 to MW0 */ |
| 3458 | {0x1d, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 3459 | |
| 3460 | /* Setup default input of SW1 as MW0 */ |
| 3461 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 3462 | |
| 3463 | /* Setup default input of SW4 as AOW0 */ |
| 3464 | {0x28, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 3465 | |
| 3466 | /* PW9 PW10 Output enable */ |
| 3467 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 3468 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 3469 | |
| 3470 | /* Unmute SW1, PW12 */ |
| 3471 | {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3472 | {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
| 3473 | /* PW12 Output enable */ |
| 3474 | {0x2a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, |
| 3475 | /* Enable Boost Volume backdoor */ |
| 3476 | {0x1, 0xf8a, 0x80}, |
| 3477 | /* don't bybass mixer */ |
| 3478 | {0x1, 0xf88, 0xc0}, |
| 3479 | /* Enable mono output */ |
| 3480 | {0x1, 0xf90, 0x08}, |
| 3481 | { } |
| 3482 | }; |
| 3483 | |
| 3484 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3485 | static const struct hda_verb vt1716S_uniwill_init_verbs[] = { |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 3486 | {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, |
| 3487 | AC_USRSP_EN | VIA_HP_EVENT | VIA_JACK_EVENT}, |
| 3488 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3489 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3490 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3491 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, |
| 3492 | AC_USRSP_EN | VIA_MONO_EVENT | VIA_JACK_EVENT}, |
| 3493 | {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3494 | {0x23, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3495 | { } |
| 3496 | }; |
| 3497 | |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 3498 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3499 | static const struct hda_amp_list vt1716S_loopbacks[] = { |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 3500 | { 0x16, HDA_INPUT, 1 }, |
| 3501 | { 0x16, HDA_INPUT, 2 }, |
| 3502 | { 0x16, HDA_INPUT, 3 }, |
| 3503 | { 0x16, HDA_INPUT, 4 }, |
| 3504 | { } /* end */ |
| 3505 | }; |
| 3506 | #endif |
| 3507 | |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 3508 | static void set_widgets_power_state_vt1716S(struct hda_codec *codec) |
| 3509 | { |
| 3510 | struct via_spec *spec = codec->spec; |
| 3511 | int imux_is_smixer; |
| 3512 | unsigned int parm; |
| 3513 | unsigned int mono_out, present; |
| 3514 | /* SW0 (17h) = stereo mixer */ |
| 3515 | imux_is_smixer = |
| 3516 | (snd_hda_codec_read(codec, 0x17, 0, |
| 3517 | AC_VERB_GET_CONNECT_SEL, 0x00) == 5); |
| 3518 | /* inputs */ |
| 3519 | /* PW 1/2/5 (1ah/1bh/1eh) */ |
| 3520 | parm = AC_PWRST_D3; |
| 3521 | set_pin_power_state(codec, 0x1a, &parm); |
| 3522 | set_pin_power_state(codec, 0x1b, &parm); |
| 3523 | set_pin_power_state(codec, 0x1e, &parm); |
| 3524 | if (imux_is_smixer) |
| 3525 | parm = AC_PWRST_D0; |
| 3526 | /* SW0 (17h), AIW0(13h) */ |
| 3527 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3528 | snd_hda_codec_write(codec, 0x13, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3529 | |
| 3530 | parm = AC_PWRST_D3; |
| 3531 | set_pin_power_state(codec, 0x1e, &parm); |
| 3532 | /* PW11 (22h) */ |
| 3533 | if (spec->dmic_enabled) |
| 3534 | set_pin_power_state(codec, 0x22, &parm); |
| 3535 | else |
| 3536 | snd_hda_codec_write(codec, 0x22, 0, |
| 3537 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 3538 | |
| 3539 | /* SW2(26h), AIW1(14h) */ |
| 3540 | snd_hda_codec_write(codec, 0x26, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3541 | snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3542 | |
| 3543 | /* outputs */ |
| 3544 | /* PW0 (19h), SW1 (18h), AOW1 (11h) */ |
| 3545 | parm = AC_PWRST_D3; |
| 3546 | set_pin_power_state(codec, 0x19, &parm); |
| 3547 | /* Smart 5.1 PW2(1bh) */ |
| 3548 | if (spec->smart51_enabled) |
| 3549 | set_pin_power_state(codec, 0x1b, &parm); |
| 3550 | snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3551 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3552 | |
| 3553 | /* PW7 (23h), SW3 (27h), AOW3 (25h) */ |
| 3554 | parm = AC_PWRST_D3; |
| 3555 | set_pin_power_state(codec, 0x23, &parm); |
| 3556 | /* Smart 5.1 PW1(1ah) */ |
| 3557 | if (spec->smart51_enabled) |
| 3558 | set_pin_power_state(codec, 0x1a, &parm); |
| 3559 | snd_hda_codec_write(codec, 0x27, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3560 | |
| 3561 | /* Smart 5.1 PW5(1eh) */ |
| 3562 | if (spec->smart51_enabled) |
| 3563 | set_pin_power_state(codec, 0x1e, &parm); |
| 3564 | snd_hda_codec_write(codec, 0x25, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3565 | |
| 3566 | /* Mono out */ |
| 3567 | /* SW4(28h)->MW1(29h)-> PW12 (2ah)*/ |
| 3568 | present = snd_hda_jack_detect(codec, 0x1c); |
| 3569 | |
| 3570 | if (present) |
| 3571 | mono_out = 0; |
| 3572 | else { |
| 3573 | present = snd_hda_jack_detect(codec, 0x1d); |
| 3574 | if (!spec->hp_independent_mode && present) |
| 3575 | mono_out = 0; |
| 3576 | else |
| 3577 | mono_out = 1; |
| 3578 | } |
| 3579 | parm = mono_out ? AC_PWRST_D0 : AC_PWRST_D3; |
| 3580 | snd_hda_codec_write(codec, 0x28, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3581 | snd_hda_codec_write(codec, 0x29, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3582 | snd_hda_codec_write(codec, 0x2a, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3583 | |
| 3584 | /* PW 3/4 (1ch/1dh) */ |
| 3585 | parm = AC_PWRST_D3; |
| 3586 | set_pin_power_state(codec, 0x1c, &parm); |
| 3587 | set_pin_power_state(codec, 0x1d, &parm); |
| 3588 | /* HP Independent Mode, power on AOW3 */ |
| 3589 | if (spec->hp_independent_mode) |
| 3590 | snd_hda_codec_write(codec, 0x25, 0, |
| 3591 | AC_VERB_SET_POWER_STATE, parm); |
| 3592 | |
| 3593 | /* force to D0 for internal Speaker */ |
| 3594 | /* MW0 (16h), AOW0 (10h) */ |
| 3595 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_POWER_STATE, |
| 3596 | imux_is_smixer ? AC_PWRST_D0 : parm); |
| 3597 | snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_POWER_STATE, |
| 3598 | mono_out ? AC_PWRST_D0 : parm); |
| 3599 | } |
| 3600 | |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 3601 | static int patch_vt1716S(struct hda_codec *codec) |
| 3602 | { |
| 3603 | struct via_spec *spec; |
| 3604 | int err; |
| 3605 | |
| 3606 | /* create a codec specific record */ |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 3607 | spec = via_new_spec(codec); |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 3608 | if (spec == NULL) |
| 3609 | return -ENOMEM; |
| 3610 | |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 3611 | spec->aa_mix_nid = 0x16; |
Takashi Iwai | d7a99cc | 2011-06-18 17:24:46 +0200 | [diff] [blame] | 3612 | override_mic_boost(codec, 0x1a, 0, 3, 40); |
| 3613 | override_mic_boost(codec, 0x1e, 0, 3, 40); |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 3614 | |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 3615 | /* automatic parse from the BIOS config */ |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 3616 | err = via_parse_auto_config(codec); |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 3617 | if (err < 0) { |
| 3618 | via_free(codec); |
| 3619 | return err; |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 3620 | } |
| 3621 | |
| 3622 | spec->init_verbs[spec->num_iverbs++] = vt1716S_volume_init_verbs; |
| 3623 | spec->init_verbs[spec->num_iverbs++] = vt1716S_uniwill_init_verbs; |
| 3624 | |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 3625 | spec->mixers[spec->num_mixers] = vt1716s_dmic_mixer; |
| 3626 | spec->num_mixers++; |
| 3627 | |
| 3628 | spec->mixers[spec->num_mixers++] = vt1716S_mono_out_mixer; |
| 3629 | |
| 3630 | codec->patch_ops = via_patch_ops; |
| 3631 | |
| 3632 | codec->patch_ops.init = via_auto_init; |
Stephen Rothwell | 0f48327 | 2009-10-12 15:56:17 +1100 | [diff] [blame] | 3633 | codec->patch_ops.unsol_event = via_unsol_event; |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 3634 | |
| 3635 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 3636 | spec->loopback.amplist = vt1716S_loopbacks; |
| 3637 | #endif |
| 3638 | |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 3639 | spec->set_widgets_power_state = set_widgets_power_state_vt1716S; |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 3640 | return 0; |
| 3641 | } |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 3642 | |
| 3643 | /* for vt2002P */ |
| 3644 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3645 | static const struct hda_verb vt2002P_volume_init_verbs[] = { |
Lydia Wang | eadb9a8 | 2011-03-24 12:43:02 +0800 | [diff] [blame] | 3646 | /* Class-D speaker related verbs */ |
| 3647 | {0x1, 0xfe0, 0x4}, |
| 3648 | {0x1, 0xfe9, 0x80}, |
| 3649 | {0x1, 0xfe2, 0x22}, |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 3650 | /* |
| 3651 | * Unmute ADC0-1 and set the default input to mic-in |
| 3652 | */ |
| 3653 | {0x8, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3654 | {0x9, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3655 | |
| 3656 | |
| 3657 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 3658 | * mixer widget |
| 3659 | */ |
| 3660 | /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ |
| 3661 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3662 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3663 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 3664 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 3665 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 3666 | |
| 3667 | /* MUX Indices: Mic = 0 */ |
| 3668 | {0x1e, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3669 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3670 | |
| 3671 | /* PW9 Output enable */ |
| 3672 | {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN}, |
| 3673 | |
| 3674 | /* Enable Boost Volume backdoor */ |
| 3675 | {0x1, 0xfb9, 0x24}, |
| 3676 | |
| 3677 | /* MW0/1/4/8: un-mute index 0 (MUXx), un-mute index 1 (MW9) */ |
| 3678 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3679 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3680 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3681 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3682 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3683 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3684 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3685 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3686 | |
| 3687 | /* set MUX0/1/4/8 = 0 (AOW0) */ |
| 3688 | {0x34, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3689 | {0x35, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3690 | {0x37, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3691 | {0x3b, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3692 | |
| 3693 | /* set PW0 index=0 (MW0) */ |
| 3694 | {0x24, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3695 | |
| 3696 | /* Enable AOW0 to MW9 */ |
| 3697 | {0x1, 0xfb8, 0x88}, |
| 3698 | { } |
| 3699 | }; |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3700 | static const struct hda_verb vt1802_volume_init_verbs[] = { |
Lydia Wang | 11890956 | 2011-03-23 17:57:34 +0800 | [diff] [blame] | 3701 | /* |
| 3702 | * Unmute ADC0-1 and set the default input to mic-in |
| 3703 | */ |
| 3704 | {0x8, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3705 | {0x9, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3706 | |
| 3707 | |
| 3708 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 3709 | * mixer widget |
| 3710 | */ |
| 3711 | /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ |
| 3712 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3713 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3714 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 3715 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 3716 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 3717 | |
| 3718 | /* MUX Indices: Mic = 0 */ |
| 3719 | {0x1e, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3720 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3721 | |
| 3722 | /* PW9 Output enable */ |
| 3723 | {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN}, |
| 3724 | |
| 3725 | /* Enable Boost Volume backdoor */ |
| 3726 | {0x1, 0xfb9, 0x24}, |
| 3727 | |
| 3728 | /* MW0/1/4/8: un-mute index 0 (MUXx), un-mute index 1 (MW9) */ |
| 3729 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3730 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3731 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3732 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3733 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3734 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3735 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3736 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3737 | |
| 3738 | /* set MUX0/1/4/8 = 0 (AOW0) */ |
| 3739 | {0x34, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3740 | {0x35, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3741 | {0x38, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3742 | {0x3c, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3743 | |
| 3744 | /* set PW0 index=0 (MW0) */ |
| 3745 | {0x24, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3746 | |
| 3747 | /* Enable AOW0 to MW9 */ |
| 3748 | {0x1, 0xfb8, 0x88}, |
| 3749 | { } |
| 3750 | }; |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 3751 | |
| 3752 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3753 | static const struct hda_verb vt2002P_uniwill_init_verbs[] = { |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 3754 | {0x25, AC_VERB_SET_UNSOLICITED_ENABLE, |
| 3755 | AC_USRSP_EN | VIA_JACK_EVENT | VIA_BIND_HP_EVENT}, |
| 3756 | {0x26, AC_VERB_SET_UNSOLICITED_ENABLE, |
| 3757 | AC_USRSP_EN | VIA_JACK_EVENT | VIA_BIND_HP_EVENT}, |
| 3758 | {0x29, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3759 | {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3760 | {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3761 | { } |
| 3762 | }; |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3763 | static const struct hda_verb vt1802_uniwill_init_verbs[] = { |
Lydia Wang | 11890956 | 2011-03-23 17:57:34 +0800 | [diff] [blame] | 3764 | {0x25, AC_VERB_SET_UNSOLICITED_ENABLE, |
| 3765 | AC_USRSP_EN | VIA_JACK_EVENT | VIA_BIND_HP_EVENT}, |
| 3766 | {0x28, AC_VERB_SET_UNSOLICITED_ENABLE, |
| 3767 | AC_USRSP_EN | VIA_JACK_EVENT | VIA_BIND_HP_EVENT}, |
| 3768 | {0x29, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3769 | {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3770 | {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 3771 | { } |
| 3772 | }; |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 3773 | |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 3774 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3775 | static const struct hda_amp_list vt2002P_loopbacks[] = { |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 3776 | { 0x21, HDA_INPUT, 0 }, |
| 3777 | { 0x21, HDA_INPUT, 1 }, |
| 3778 | { 0x21, HDA_INPUT, 2 }, |
| 3779 | { } /* end */ |
| 3780 | }; |
| 3781 | #endif |
| 3782 | |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 3783 | static void set_widgets_power_state_vt2002P(struct hda_codec *codec) |
| 3784 | { |
| 3785 | struct via_spec *spec = codec->spec; |
| 3786 | int imux_is_smixer; |
| 3787 | unsigned int parm; |
| 3788 | unsigned int present; |
| 3789 | /* MUX9 (1eh) = stereo mixer */ |
| 3790 | imux_is_smixer = |
| 3791 | snd_hda_codec_read(codec, 0x1e, 0, AC_VERB_GET_CONNECT_SEL, 0x00) == 3; |
| 3792 | /* inputs */ |
| 3793 | /* PW 5/6/7 (29h/2ah/2bh) */ |
| 3794 | parm = AC_PWRST_D3; |
| 3795 | set_pin_power_state(codec, 0x29, &parm); |
| 3796 | set_pin_power_state(codec, 0x2a, &parm); |
| 3797 | set_pin_power_state(codec, 0x2b, &parm); |
| 3798 | parm = AC_PWRST_D0; |
| 3799 | /* MUX9/10 (1eh/1fh), AIW 0/1 (10h/11h) */ |
| 3800 | snd_hda_codec_write(codec, 0x1e, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3801 | snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3802 | snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3803 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3804 | |
| 3805 | /* outputs */ |
| 3806 | /* AOW0 (8h)*/ |
| 3807 | snd_hda_codec_write(codec, 0x8, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3808 | |
Lydia Wang | 11890956 | 2011-03-23 17:57:34 +0800 | [diff] [blame] | 3809 | if (spec->codec_type == VT1802) { |
| 3810 | /* PW4 (28h), MW4 (18h), MUX4(38h) */ |
| 3811 | parm = AC_PWRST_D3; |
| 3812 | set_pin_power_state(codec, 0x28, &parm); |
| 3813 | snd_hda_codec_write(codec, 0x18, 0, |
| 3814 | AC_VERB_SET_POWER_STATE, parm); |
| 3815 | snd_hda_codec_write(codec, 0x38, 0, |
| 3816 | AC_VERB_SET_POWER_STATE, parm); |
| 3817 | } else { |
| 3818 | /* PW4 (26h), MW4 (1ch), MUX4(37h) */ |
| 3819 | parm = AC_PWRST_D3; |
| 3820 | set_pin_power_state(codec, 0x26, &parm); |
| 3821 | snd_hda_codec_write(codec, 0x1c, 0, |
| 3822 | AC_VERB_SET_POWER_STATE, parm); |
| 3823 | snd_hda_codec_write(codec, 0x37, 0, |
| 3824 | AC_VERB_SET_POWER_STATE, parm); |
| 3825 | } |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 3826 | |
Lydia Wang | 11890956 | 2011-03-23 17:57:34 +0800 | [diff] [blame] | 3827 | if (spec->codec_type == VT1802) { |
| 3828 | /* PW1 (25h), MW1 (15h), MUX1(35h), AOW1 (9h) */ |
| 3829 | parm = AC_PWRST_D3; |
| 3830 | set_pin_power_state(codec, 0x25, &parm); |
| 3831 | snd_hda_codec_write(codec, 0x15, 0, |
| 3832 | AC_VERB_SET_POWER_STATE, parm); |
| 3833 | snd_hda_codec_write(codec, 0x35, 0, |
| 3834 | AC_VERB_SET_POWER_STATE, parm); |
| 3835 | } else { |
| 3836 | /* PW1 (25h), MW1 (19h), MUX1(35h), AOW1 (9h) */ |
| 3837 | parm = AC_PWRST_D3; |
| 3838 | set_pin_power_state(codec, 0x25, &parm); |
| 3839 | snd_hda_codec_write(codec, 0x19, 0, |
| 3840 | AC_VERB_SET_POWER_STATE, parm); |
| 3841 | snd_hda_codec_write(codec, 0x35, 0, |
| 3842 | AC_VERB_SET_POWER_STATE, parm); |
| 3843 | } |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 3844 | |
| 3845 | if (spec->hp_independent_mode) |
| 3846 | snd_hda_codec_write(codec, 0x9, 0, |
| 3847 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 3848 | |
| 3849 | /* Class-D */ |
| 3850 | /* PW0 (24h), MW0(18h/14h), MUX0(34h) */ |
| 3851 | present = snd_hda_jack_detect(codec, 0x25); |
| 3852 | |
| 3853 | parm = AC_PWRST_D3; |
| 3854 | set_pin_power_state(codec, 0x24, &parm); |
| 3855 | parm = present ? AC_PWRST_D3 : AC_PWRST_D0; |
Lydia Wang | 11890956 | 2011-03-23 17:57:34 +0800 | [diff] [blame] | 3856 | if (spec->codec_type == VT1802) |
| 3857 | snd_hda_codec_write(codec, 0x14, 0, |
| 3858 | AC_VERB_SET_POWER_STATE, parm); |
| 3859 | else |
| 3860 | snd_hda_codec_write(codec, 0x18, 0, |
| 3861 | AC_VERB_SET_POWER_STATE, parm); |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 3862 | snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_POWER_STATE, parm); |
| 3863 | |
| 3864 | /* Mono Out */ |
| 3865 | present = snd_hda_jack_detect(codec, 0x26); |
| 3866 | |
| 3867 | parm = present ? AC_PWRST_D3 : AC_PWRST_D0; |
Lydia Wang | 11890956 | 2011-03-23 17:57:34 +0800 | [diff] [blame] | 3868 | if (spec->codec_type == VT1802) { |
| 3869 | /* PW15 (33h), MW8(1ch), MUX8(3ch) */ |
| 3870 | snd_hda_codec_write(codec, 0x33, 0, |
| 3871 | AC_VERB_SET_POWER_STATE, parm); |
| 3872 | snd_hda_codec_write(codec, 0x1c, 0, |
| 3873 | AC_VERB_SET_POWER_STATE, parm); |
| 3874 | snd_hda_codec_write(codec, 0x3c, 0, |
| 3875 | AC_VERB_SET_POWER_STATE, parm); |
| 3876 | } else { |
| 3877 | /* PW15 (31h), MW8(17h), MUX8(3bh) */ |
| 3878 | snd_hda_codec_write(codec, 0x31, 0, |
| 3879 | AC_VERB_SET_POWER_STATE, parm); |
| 3880 | snd_hda_codec_write(codec, 0x17, 0, |
| 3881 | AC_VERB_SET_POWER_STATE, parm); |
| 3882 | snd_hda_codec_write(codec, 0x3b, 0, |
| 3883 | AC_VERB_SET_POWER_STATE, parm); |
| 3884 | } |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 3885 | /* MW9 (21h) */ |
| 3886 | if (imux_is_smixer || !is_aa_path_mute(codec)) |
| 3887 | snd_hda_codec_write(codec, 0x21, 0, |
| 3888 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 3889 | else |
| 3890 | snd_hda_codec_write(codec, 0x21, 0, |
| 3891 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 3892 | } |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 3893 | |
| 3894 | /* patch for vt2002P */ |
| 3895 | static int patch_vt2002P(struct hda_codec *codec) |
| 3896 | { |
| 3897 | struct via_spec *spec; |
| 3898 | int err; |
| 3899 | |
| 3900 | /* create a codec specific record */ |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 3901 | spec = via_new_spec(codec); |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 3902 | if (spec == NULL) |
| 3903 | return -ENOMEM; |
| 3904 | |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 3905 | spec->aa_mix_nid = 0x21; |
Takashi Iwai | d7a99cc | 2011-06-18 17:24:46 +0200 | [diff] [blame] | 3906 | override_mic_boost(codec, 0x2b, 0, 3, 40); |
| 3907 | override_mic_boost(codec, 0x29, 0, 3, 40); |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 3908 | |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 3909 | /* automatic parse from the BIOS config */ |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 3910 | err = via_parse_auto_config(codec); |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 3911 | if (err < 0) { |
| 3912 | via_free(codec); |
| 3913 | return err; |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 3914 | } |
| 3915 | |
Lydia Wang | 11890956 | 2011-03-23 17:57:34 +0800 | [diff] [blame] | 3916 | if (spec->codec_type == VT1802) |
| 3917 | spec->init_verbs[spec->num_iverbs++] = |
| 3918 | vt1802_volume_init_verbs; |
| 3919 | else |
| 3920 | spec->init_verbs[spec->num_iverbs++] = |
| 3921 | vt2002P_volume_init_verbs; |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 3922 | |
Lydia Wang | 11890956 | 2011-03-23 17:57:34 +0800 | [diff] [blame] | 3923 | if (spec->codec_type == VT1802) |
| 3924 | spec->init_verbs[spec->num_iverbs++] = |
| 3925 | vt1802_uniwill_init_verbs; |
| 3926 | else |
| 3927 | spec->init_verbs[spec->num_iverbs++] = |
| 3928 | vt2002P_uniwill_init_verbs; |
| 3929 | |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 3930 | codec->patch_ops = via_patch_ops; |
| 3931 | |
| 3932 | codec->patch_ops.init = via_auto_init; |
Stephen Rothwell | 0f48327 | 2009-10-12 15:56:17 +1100 | [diff] [blame] | 3933 | codec->patch_ops.unsol_event = via_unsol_event; |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 3934 | |
| 3935 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 3936 | spec->loopback.amplist = vt2002P_loopbacks; |
| 3937 | #endif |
| 3938 | |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 3939 | spec->set_widgets_power_state = set_widgets_power_state_vt2002P; |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 3940 | return 0; |
| 3941 | } |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 3942 | |
| 3943 | /* for vt1812 */ |
| 3944 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3945 | static const struct hda_verb vt1812_volume_init_verbs[] = { |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 3946 | /* |
| 3947 | * Unmute ADC0-1 and set the default input to mic-in |
| 3948 | */ |
| 3949 | {0x8, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3950 | {0x9, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3951 | |
| 3952 | |
| 3953 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback |
| 3954 | * mixer widget |
| 3955 | */ |
| 3956 | /* Amp Indices: CD = 1, Mic1 = 2, Line = 3, Mic2 = 4 */ |
| 3957 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
| 3958 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 3959 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
| 3960 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
| 3961 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
| 3962 | |
| 3963 | /* MUX Indices: Mic = 0 */ |
| 3964 | {0x1e, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3965 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3966 | |
| 3967 | /* PW9 Output enable */ |
| 3968 | {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN}, |
| 3969 | |
| 3970 | /* Enable Boost Volume backdoor */ |
| 3971 | {0x1, 0xfb9, 0x24}, |
| 3972 | |
| 3973 | /* MW0/1/4/13/15: un-mute index 0 (MUXx), un-mute index 1 (MW9) */ |
| 3974 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3975 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3976 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3977 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3978 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 3979 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3980 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3981 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3982 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3983 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
| 3984 | |
| 3985 | /* set MUX0/1/4/13/15 = 0 (AOW0) */ |
| 3986 | {0x34, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3987 | {0x35, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3988 | {0x38, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3989 | {0x3c, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3990 | {0x3d, AC_VERB_SET_CONNECT_SEL, 0}, |
| 3991 | |
| 3992 | /* Enable AOW0 to MW9 */ |
| 3993 | {0x1, 0xfb8, 0xa8}, |
| 3994 | { } |
| 3995 | }; |
| 3996 | |
| 3997 | |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 3998 | static const struct hda_verb vt1812_uniwill_init_verbs[] = { |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 3999 | {0x33, AC_VERB_SET_UNSOLICITED_ENABLE, |
| 4000 | AC_USRSP_EN | VIA_JACK_EVENT | VIA_BIND_HP_EVENT}, |
| 4001 | {0x25, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT }, |
| 4002 | {0x28, AC_VERB_SET_UNSOLICITED_ENABLE, |
| 4003 | AC_USRSP_EN | VIA_JACK_EVENT | VIA_BIND_HP_EVENT}, |
| 4004 | {0x29, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 4005 | {0x2a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 4006 | {0x2b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | VIA_JACK_EVENT}, |
| 4007 | { } |
| 4008 | }; |
| 4009 | |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 4010 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 4011 | static const struct hda_amp_list vt1812_loopbacks[] = { |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 4012 | { 0x21, HDA_INPUT, 0 }, |
| 4013 | { 0x21, HDA_INPUT, 1 }, |
| 4014 | { 0x21, HDA_INPUT, 2 }, |
| 4015 | { } /* end */ |
| 4016 | }; |
| 4017 | #endif |
| 4018 | |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 4019 | static void set_widgets_power_state_vt1812(struct hda_codec *codec) |
| 4020 | { |
| 4021 | struct via_spec *spec = codec->spec; |
| 4022 | int imux_is_smixer = |
| 4023 | snd_hda_codec_read(codec, 0x13, 0, AC_VERB_GET_CONNECT_SEL, 0x00) == 3; |
| 4024 | unsigned int parm; |
| 4025 | unsigned int present; |
| 4026 | /* MUX10 (1eh) = stereo mixer */ |
| 4027 | imux_is_smixer = |
| 4028 | snd_hda_codec_read(codec, 0x1e, 0, AC_VERB_GET_CONNECT_SEL, 0x00) == 5; |
| 4029 | /* inputs */ |
| 4030 | /* PW 5/6/7 (29h/2ah/2bh) */ |
| 4031 | parm = AC_PWRST_D3; |
| 4032 | set_pin_power_state(codec, 0x29, &parm); |
| 4033 | set_pin_power_state(codec, 0x2a, &parm); |
| 4034 | set_pin_power_state(codec, 0x2b, &parm); |
| 4035 | parm = AC_PWRST_D0; |
| 4036 | /* MUX10/11 (1eh/1fh), AIW 0/1 (10h/11h) */ |
| 4037 | snd_hda_codec_write(codec, 0x1e, 0, AC_VERB_SET_POWER_STATE, parm); |
| 4038 | snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_POWER_STATE, parm); |
| 4039 | snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_POWER_STATE, parm); |
| 4040 | snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_POWER_STATE, parm); |
| 4041 | |
| 4042 | /* outputs */ |
| 4043 | /* AOW0 (8h)*/ |
| 4044 | snd_hda_codec_write(codec, 0x8, 0, |
| 4045 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 4046 | |
| 4047 | /* PW4 (28h), MW4 (18h), MUX4(38h) */ |
| 4048 | parm = AC_PWRST_D3; |
| 4049 | set_pin_power_state(codec, 0x28, &parm); |
| 4050 | snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_POWER_STATE, parm); |
| 4051 | snd_hda_codec_write(codec, 0x38, 0, AC_VERB_SET_POWER_STATE, parm); |
| 4052 | |
| 4053 | /* PW1 (25h), MW1 (15h), MUX1(35h), AOW1 (9h) */ |
| 4054 | parm = AC_PWRST_D3; |
| 4055 | set_pin_power_state(codec, 0x25, &parm); |
| 4056 | snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_POWER_STATE, parm); |
| 4057 | snd_hda_codec_write(codec, 0x35, 0, AC_VERB_SET_POWER_STATE, parm); |
| 4058 | if (spec->hp_independent_mode) |
| 4059 | snd_hda_codec_write(codec, 0x9, 0, |
| 4060 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 4061 | |
| 4062 | /* Internal Speaker */ |
| 4063 | /* PW0 (24h), MW0(14h), MUX0(34h) */ |
| 4064 | present = snd_hda_jack_detect(codec, 0x25); |
| 4065 | |
| 4066 | parm = AC_PWRST_D3; |
| 4067 | set_pin_power_state(codec, 0x24, &parm); |
| 4068 | if (present) { |
| 4069 | snd_hda_codec_write(codec, 0x14, 0, |
| 4070 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 4071 | snd_hda_codec_write(codec, 0x34, 0, |
| 4072 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 4073 | } else { |
| 4074 | snd_hda_codec_write(codec, 0x14, 0, |
| 4075 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 4076 | snd_hda_codec_write(codec, 0x34, 0, |
| 4077 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 4078 | } |
| 4079 | |
| 4080 | |
| 4081 | /* Mono Out */ |
| 4082 | /* PW13 (31h), MW13(1ch), MUX13(3ch), MW14(3eh) */ |
| 4083 | present = snd_hda_jack_detect(codec, 0x28); |
| 4084 | |
| 4085 | parm = AC_PWRST_D3; |
| 4086 | set_pin_power_state(codec, 0x31, &parm); |
| 4087 | if (present) { |
| 4088 | snd_hda_codec_write(codec, 0x1c, 0, |
| 4089 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 4090 | snd_hda_codec_write(codec, 0x3c, 0, |
| 4091 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 4092 | snd_hda_codec_write(codec, 0x3e, 0, |
| 4093 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 4094 | } else { |
| 4095 | snd_hda_codec_write(codec, 0x1c, 0, |
| 4096 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 4097 | snd_hda_codec_write(codec, 0x3c, 0, |
| 4098 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 4099 | snd_hda_codec_write(codec, 0x3e, 0, |
| 4100 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 4101 | } |
| 4102 | |
| 4103 | /* PW15 (33h), MW15 (1dh), MUX15(3dh) */ |
| 4104 | parm = AC_PWRST_D3; |
| 4105 | set_pin_power_state(codec, 0x33, &parm); |
| 4106 | snd_hda_codec_write(codec, 0x1d, 0, AC_VERB_SET_POWER_STATE, parm); |
| 4107 | snd_hda_codec_write(codec, 0x3d, 0, AC_VERB_SET_POWER_STATE, parm); |
| 4108 | |
| 4109 | } |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 4110 | |
| 4111 | /* patch for vt1812 */ |
| 4112 | static int patch_vt1812(struct hda_codec *codec) |
| 4113 | { |
| 4114 | struct via_spec *spec; |
| 4115 | int err; |
| 4116 | |
| 4117 | /* create a codec specific record */ |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 4118 | spec = via_new_spec(codec); |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 4119 | if (spec == NULL) |
| 4120 | return -ENOMEM; |
| 4121 | |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 4122 | spec->aa_mix_nid = 0x21; |
Takashi Iwai | d7a99cc | 2011-06-18 17:24:46 +0200 | [diff] [blame] | 4123 | override_mic_boost(codec, 0x2b, 0, 3, 40); |
| 4124 | override_mic_boost(codec, 0x29, 0, 3, 40); |
Takashi Iwai | 620e2b2 | 2011-06-17 17:19:19 +0200 | [diff] [blame] | 4125 | |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 4126 | /* automatic parse from the BIOS config */ |
Takashi Iwai | 12daef6 | 2011-06-18 17:45:49 +0200 | [diff] [blame^] | 4127 | err = via_parse_auto_config(codec); |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 4128 | if (err < 0) { |
| 4129 | via_free(codec); |
| 4130 | return err; |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 4131 | } |
| 4132 | |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 4133 | spec->init_verbs[spec->num_iverbs++] = vt1812_volume_init_verbs; |
| 4134 | spec->init_verbs[spec->num_iverbs++] = vt1812_uniwill_init_verbs; |
| 4135 | |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 4136 | codec->patch_ops = via_patch_ops; |
| 4137 | |
| 4138 | codec->patch_ops.init = via_auto_init; |
Stephen Rothwell | 0f48327 | 2009-10-12 15:56:17 +1100 | [diff] [blame] | 4139 | codec->patch_ops.unsol_event = via_unsol_event; |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 4140 | |
| 4141 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4142 | spec->loopback.amplist = vt1812_loopbacks; |
| 4143 | #endif |
| 4144 | |
Lydia Wang | 3e95b9a | 2011-03-23 15:13:28 +0800 | [diff] [blame] | 4145 | spec->set_widgets_power_state = set_widgets_power_state_vt1812; |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 4146 | return 0; |
| 4147 | } |
| 4148 | |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 4149 | /* |
| 4150 | * patch entries |
| 4151 | */ |
Takashi Iwai | 90dd48a | 2011-05-02 12:38:19 +0200 | [diff] [blame] | 4152 | static const struct hda_codec_preset snd_hda_preset_via[] = { |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4153 | { .id = 0x11061708, .name = "VT1708", .patch = patch_vt1708}, |
| 4154 | { .id = 0x11061709, .name = "VT1708", .patch = patch_vt1708}, |
| 4155 | { .id = 0x1106170a, .name = "VT1708", .patch = patch_vt1708}, |
| 4156 | { .id = 0x1106170b, .name = "VT1708", .patch = patch_vt1708}, |
| 4157 | { .id = 0x1106e710, .name = "VT1709 10-Ch", |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 4158 | .patch = patch_vt1709_10ch}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4159 | { .id = 0x1106e711, .name = "VT1709 10-Ch", |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 4160 | .patch = patch_vt1709_10ch}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4161 | { .id = 0x1106e712, .name = "VT1709 10-Ch", |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 4162 | .patch = patch_vt1709_10ch}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4163 | { .id = 0x1106e713, .name = "VT1709 10-Ch", |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 4164 | .patch = patch_vt1709_10ch}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4165 | { .id = 0x1106e714, .name = "VT1709 6-Ch", |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 4166 | .patch = patch_vt1709_6ch}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4167 | { .id = 0x1106e715, .name = "VT1709 6-Ch", |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 4168 | .patch = patch_vt1709_6ch}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4169 | { .id = 0x1106e716, .name = "VT1709 6-Ch", |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 4170 | .patch = patch_vt1709_6ch}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4171 | { .id = 0x1106e717, .name = "VT1709 6-Ch", |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 4172 | .patch = patch_vt1709_6ch}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4173 | { .id = 0x1106e720, .name = "VT1708B 8-Ch", |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 4174 | .patch = patch_vt1708B_8ch}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4175 | { .id = 0x1106e721, .name = "VT1708B 8-Ch", |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 4176 | .patch = patch_vt1708B_8ch}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4177 | { .id = 0x1106e722, .name = "VT1708B 8-Ch", |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 4178 | .patch = patch_vt1708B_8ch}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4179 | { .id = 0x1106e723, .name = "VT1708B 8-Ch", |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 4180 | .patch = patch_vt1708B_8ch}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4181 | { .id = 0x1106e724, .name = "VT1708B 4-Ch", |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 4182 | .patch = patch_vt1708B_4ch}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4183 | { .id = 0x1106e725, .name = "VT1708B 4-Ch", |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 4184 | .patch = patch_vt1708B_4ch}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4185 | { .id = 0x1106e726, .name = "VT1708B 4-Ch", |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 4186 | .patch = patch_vt1708B_4ch}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4187 | { .id = 0x1106e727, .name = "VT1708B 4-Ch", |
Josepch Chan | f7278fd | 2007-12-13 16:40:40 +0100 | [diff] [blame] | 4188 | .patch = patch_vt1708B_4ch}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4189 | { .id = 0x11060397, .name = "VT1708S", |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 4190 | .patch = patch_vt1708S}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4191 | { .id = 0x11061397, .name = "VT1708S", |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 4192 | .patch = patch_vt1708S}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4193 | { .id = 0x11062397, .name = "VT1708S", |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 4194 | .patch = patch_vt1708S}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4195 | { .id = 0x11063397, .name = "VT1708S", |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 4196 | .patch = patch_vt1708S}, |
Lydia Wang | bc92df7 | 2011-03-23 17:56:05 +0800 | [diff] [blame] | 4197 | { .id = 0x11064397, .name = "VT1705", |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 4198 | .patch = patch_vt1708S}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4199 | { .id = 0x11065397, .name = "VT1708S", |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 4200 | .patch = patch_vt1708S}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4201 | { .id = 0x11066397, .name = "VT1708S", |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 4202 | .patch = patch_vt1708S}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4203 | { .id = 0x11067397, .name = "VT1708S", |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 4204 | .patch = patch_vt1708S}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4205 | { .id = 0x11060398, .name = "VT1702", |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 4206 | .patch = patch_vt1702}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4207 | { .id = 0x11061398, .name = "VT1702", |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 4208 | .patch = patch_vt1702}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4209 | { .id = 0x11062398, .name = "VT1702", |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 4210 | .patch = patch_vt1702}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4211 | { .id = 0x11063398, .name = "VT1702", |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 4212 | .patch = patch_vt1702}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4213 | { .id = 0x11064398, .name = "VT1702", |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 4214 | .patch = patch_vt1702}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4215 | { .id = 0x11065398, .name = "VT1702", |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 4216 | .patch = patch_vt1702}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4217 | { .id = 0x11066398, .name = "VT1702", |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 4218 | .patch = patch_vt1702}, |
Takashi Iwai | 3218c17 | 2008-12-18 09:17:56 +0100 | [diff] [blame] | 4219 | { .id = 0x11067398, .name = "VT1702", |
Harald Welte | d949cac | 2008-09-09 15:56:01 +0800 | [diff] [blame] | 4220 | .patch = patch_vt1702}, |
Lydia Wang | eb7188c | 2009-10-10 19:08:34 +0800 | [diff] [blame] | 4221 | { .id = 0x11060428, .name = "VT1718S", |
| 4222 | .patch = patch_vt1718S}, |
| 4223 | { .id = 0x11064428, .name = "VT1718S", |
| 4224 | .patch = patch_vt1718S}, |
Lydia Wang | bb3c6bfc | 2009-10-10 19:08:39 +0800 | [diff] [blame] | 4225 | { .id = 0x11060441, .name = "VT2020", |
| 4226 | .patch = patch_vt1718S}, |
| 4227 | { .id = 0x11064441, .name = "VT1828S", |
| 4228 | .patch = patch_vt1718S}, |
Lydia Wang | f3db423 | 2009-10-10 19:08:41 +0800 | [diff] [blame] | 4229 | { .id = 0x11060433, .name = "VT1716S", |
| 4230 | .patch = patch_vt1716S}, |
| 4231 | { .id = 0x1106a721, .name = "VT1716S", |
| 4232 | .patch = patch_vt1716S}, |
Lydia Wang | 25eaba2 | 2009-10-10 19:08:43 +0800 | [diff] [blame] | 4233 | { .id = 0x11060438, .name = "VT2002P", .patch = patch_vt2002P}, |
| 4234 | { .id = 0x11064438, .name = "VT2002P", .patch = patch_vt2002P}, |
Lydia Wang | ab6734e | 2009-10-10 19:08:46 +0800 | [diff] [blame] | 4235 | { .id = 0x11060448, .name = "VT1812", .patch = patch_vt1812}, |
Lydia Wang | 36dd5c4 | 2009-10-20 13:18:04 +0800 | [diff] [blame] | 4236 | { .id = 0x11060440, .name = "VT1818S", |
| 4237 | .patch = patch_vt1708S}, |
Lydia Wang | 11890956 | 2011-03-23 17:57:34 +0800 | [diff] [blame] | 4238 | { .id = 0x11060446, .name = "VT1802", |
| 4239 | .patch = patch_vt2002P}, |
| 4240 | { .id = 0x11068446, .name = "VT1802", |
| 4241 | .patch = patch_vt2002P}, |
Joseph Chan | c577b8a | 2006-11-29 15:29:40 +0100 | [diff] [blame] | 4242 | {} /* terminator */ |
| 4243 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 4244 | |
| 4245 | MODULE_ALIAS("snd-hda-codec-id:1106*"); |
| 4246 | |
| 4247 | static struct hda_codec_preset_list via_list = { |
| 4248 | .preset = snd_hda_preset_via, |
| 4249 | .owner = THIS_MODULE, |
| 4250 | }; |
| 4251 | |
| 4252 | MODULE_LICENSE("GPL"); |
| 4253 | MODULE_DESCRIPTION("VIA HD-audio codec"); |
| 4254 | |
| 4255 | static int __init patch_via_init(void) |
| 4256 | { |
| 4257 | return snd_hda_add_codec_preset(&via_list); |
| 4258 | } |
| 4259 | |
| 4260 | static void __exit patch_via_exit(void) |
| 4261 | { |
| 4262 | snd_hda_delete_codec_preset(&via_list); |
| 4263 | } |
| 4264 | |
| 4265 | module_init(patch_via_init) |
| 4266 | module_exit(patch_via_exit) |