Commit 912093bc7c08f59e97faed2c0269e1e5429dcd58

Authored by Takashi Iwai
1 parent fae3d88a5c

ALSA: hda/realtek - Add a few ALC882 model strings back

Since there are still many Acer models that might not be covered by
the current fixup table, let's add back a few typical model names so
that user can test the fixup without recompiling.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

Showing 2 changed files with 12 additions and 2 deletions Inline Diff

Documentation/sound/alsa/HD-Audio-Models.txt
1 Model name Description 1 Model name Description
2 ---------- ----------- 2 ---------- -----------
3 ALC880 3 ALC880
4 ====== 4 ======
5 3stack 3-jack in back and a headphone out 5 3stack 3-jack in back and a headphone out
6 3stack-digout 3-jack in back, a HP out and a SPDIF out 6 3stack-digout 3-jack in back, a HP out and a SPDIF out
7 5stack 5-jack in back, 2-jack in front 7 5stack 5-jack in back, 2-jack in front
8 5stack-digout 5-jack in back, 2-jack in front, a SPDIF out 8 5stack-digout 5-jack in back, 2-jack in front, a SPDIF out
9 6stack 6-jack in back, 2-jack in front 9 6stack 6-jack in back, 2-jack in front
10 6stack-digout 6-jack with a SPDIF out 10 6stack-digout 6-jack with a SPDIF out
11 11
12 ALC260 12 ALC260
13 ====== 13 ======
14 N/A 14 N/A
15 15
16 ALC262 16 ALC262
17 ====== 17 ======
18 N/A 18 N/A
19 19
20 ALC267/268 20 ALC267/268
21 ========== 21 ==========
22 N/A 22 N/A
23 23
24 ALC269 24 ALC269
25 ====== 25 ======
26 laptop-amic Laptops with analog-mic input 26 laptop-amic Laptops with analog-mic input
27 laptop-dmic Laptops with digital-mic input 27 laptop-dmic Laptops with digital-mic input
28 28
29 ALC662/663/272 29 ALC662/663/272
30 ============== 30 ==============
31 asus-mode1 ASUS 31 asus-mode1 ASUS
32 asus-mode2 ASUS 32 asus-mode2 ASUS
33 asus-mode3 ASUS 33 asus-mode3 ASUS
34 asus-mode4 ASUS 34 asus-mode4 ASUS
35 asus-mode5 ASUS 35 asus-mode5 ASUS
36 asus-mode6 ASUS 36 asus-mode6 ASUS
37 asus-mode7 ASUS 37 asus-mode7 ASUS
38 asus-mode8 ASUS 38 asus-mode8 ASUS
39 39
40 ALC680 40 ALC680
41 ====== 41 ======
42 N/A 42 N/A
43 43
44 ALC882/883/885/888/889 44 ALC882/883/885/888/889
45 ====================== 45 ======================
46 N/A 46 acer-aspire-4930g Acer Aspire 4930G/5930G/6530G/6930G/7730G
47 acer-aspire-8930g Acer Aspire 8330G/6935G
48 acer-aspire Acer Aspire others
47 49
48 ALC861/660 50 ALC861/660
49 ========== 51 ==========
50 N/A 52 N/A
51 53
52 ALC861VD/660VD 54 ALC861VD/660VD
53 ============== 55 ==============
54 N/A 56 N/A
55 57
56 CMI9880 58 CMI9880
57 ======= 59 =======
58 minimal 3-jack in back 60 minimal 3-jack in back
59 min_fp 3-jack in back, 2-jack in front 61 min_fp 3-jack in back, 2-jack in front
60 full 6-jack in back, 2-jack in front 62 full 6-jack in back, 2-jack in front
61 full_dig 6-jack in back, 2-jack in front, SPDIF I/O 63 full_dig 6-jack in back, 2-jack in front, SPDIF I/O
62 allout 5-jack in back, 2-jack in front, SPDIF out 64 allout 5-jack in back, 2-jack in front, SPDIF out
63 auto auto-config reading BIOS (default) 65 auto auto-config reading BIOS (default)
64 66
65 AD1882 / AD1882A 67 AD1882 / AD1882A
66 ================ 68 ================
67 3stack 3-stack mode (default) 69 3stack 3-stack mode (default)
68 6stack 6-stack mode 70 6stack 6-stack mode
69 71
70 AD1884A / AD1883 / AD1984A / AD1984B 72 AD1884A / AD1883 / AD1984A / AD1984B
71 ==================================== 73 ====================================
72 desktop 3-stack desktop (default) 74 desktop 3-stack desktop (default)
73 laptop laptop with HP jack sensing 75 laptop laptop with HP jack sensing
74 mobile mobile devices with HP jack sensing 76 mobile mobile devices with HP jack sensing
75 thinkpad Lenovo Thinkpad X300 77 thinkpad Lenovo Thinkpad X300
76 touchsmart HP Touchsmart 78 touchsmart HP Touchsmart
77 79
78 AD1884 80 AD1884
79 ====== 81 ======
80 N/A 82 N/A
81 83
82 AD1981 84 AD1981
83 ====== 85 ======
84 basic 3-jack (default) 86 basic 3-jack (default)
85 hp HP nx6320 87 hp HP nx6320
86 thinkpad Lenovo Thinkpad T60/X60/Z60 88 thinkpad Lenovo Thinkpad T60/X60/Z60
87 toshiba Toshiba U205 89 toshiba Toshiba U205
88 90
89 AD1983 91 AD1983
90 ====== 92 ======
91 N/A 93 N/A
92 94
93 AD1984 95 AD1984
94 ====== 96 ======
95 basic default configuration 97 basic default configuration
96 thinkpad Lenovo Thinkpad T61/X61 98 thinkpad Lenovo Thinkpad T61/X61
97 dell_desktop Dell T3400 99 dell_desktop Dell T3400
98 100
99 AD1986A 101 AD1986A
100 ======= 102 =======
101 6stack 6-jack, separate surrounds (default) 103 6stack 6-jack, separate surrounds (default)
102 3stack 3-stack, shared surrounds 104 3stack 3-stack, shared surrounds
103 laptop 2-channel only (FSC V2060, Samsung M50) 105 laptop 2-channel only (FSC V2060, Samsung M50)
104 laptop-eapd 2-channel with EAPD (ASUS A6J) 106 laptop-eapd 2-channel with EAPD (ASUS A6J)
105 laptop-automute 2-channel with EAPD and HP-automute (Lenovo N100) 107 laptop-automute 2-channel with EAPD and HP-automute (Lenovo N100)
106 ultra 2-channel with EAPD (Samsung Ultra tablet PC) 108 ultra 2-channel with EAPD (Samsung Ultra tablet PC)
107 samsung 2-channel with EAPD (Samsung R65) 109 samsung 2-channel with EAPD (Samsung R65)
108 samsung-p50 2-channel with HP-automute (Samsung P50) 110 samsung-p50 2-channel with HP-automute (Samsung P50)
109 111
110 AD1988/AD1988B/AD1989A/AD1989B 112 AD1988/AD1988B/AD1989A/AD1989B
111 ============================== 113 ==============================
112 6stack 6-jack 114 6stack 6-jack
113 6stack-dig ditto with SPDIF 115 6stack-dig ditto with SPDIF
114 3stack 3-jack 116 3stack 3-jack
115 3stack-dig ditto with SPDIF 117 3stack-dig ditto with SPDIF
116 laptop 3-jack with hp-jack automute 118 laptop 3-jack with hp-jack automute
117 laptop-dig ditto with SPDIF 119 laptop-dig ditto with SPDIF
118 auto auto-config reading BIOS (default) 120 auto auto-config reading BIOS (default)
119 121
120 Conexant 5045 122 Conexant 5045
121 ============= 123 =============
122 laptop-hpsense Laptop with HP sense (old model laptop) 124 laptop-hpsense Laptop with HP sense (old model laptop)
123 laptop-micsense Laptop with Mic sense (old model fujitsu) 125 laptop-micsense Laptop with Mic sense (old model fujitsu)
124 laptop-hpmicsense Laptop with HP and Mic senses 126 laptop-hpmicsense Laptop with HP and Mic senses
125 benq Benq R55E 127 benq Benq R55E
126 laptop-hp530 HP 530 laptop 128 laptop-hp530 HP 530 laptop
127 test for testing/debugging purpose, almost all controls 129 test for testing/debugging purpose, almost all controls
128 can be adjusted. Appearing only when compiled with 130 can be adjusted. Appearing only when compiled with
129 $CONFIG_SND_DEBUG=y 131 $CONFIG_SND_DEBUG=y
130 132
131 Conexant 5047 133 Conexant 5047
132 ============= 134 =============
133 laptop Basic Laptop config 135 laptop Basic Laptop config
134 laptop-hp Laptop config for some HP models (subdevice 30A5) 136 laptop-hp Laptop config for some HP models (subdevice 30A5)
135 laptop-eapd Laptop config with EAPD support 137 laptop-eapd Laptop config with EAPD support
136 test for testing/debugging purpose, almost all controls 138 test for testing/debugging purpose, almost all controls
137 can be adjusted. Appearing only when compiled with 139 can be adjusted. Appearing only when compiled with
138 $CONFIG_SND_DEBUG=y 140 $CONFIG_SND_DEBUG=y
139 141
140 Conexant 5051 142 Conexant 5051
141 ============= 143 =============
142 laptop Basic Laptop config (default) 144 laptop Basic Laptop config (default)
143 hp HP Spartan laptop 145 hp HP Spartan laptop
144 hp-dv6736 HP dv6736 146 hp-dv6736 HP dv6736
145 hp-f700 HP Compaq Presario F700 147 hp-f700 HP Compaq Presario F700
146 ideapad Lenovo IdeaPad laptop 148 ideapad Lenovo IdeaPad laptop
147 toshiba Toshiba Satellite M300 149 toshiba Toshiba Satellite M300
148 150
149 Conexant 5066 151 Conexant 5066
150 ============= 152 =============
151 laptop Basic Laptop config (default) 153 laptop Basic Laptop config (default)
152 hp-laptop HP laptops, e g G60 154 hp-laptop HP laptops, e g G60
153 asus Asus K52JU, Lenovo G560 155 asus Asus K52JU, Lenovo G560
154 dell-laptop Dell laptops 156 dell-laptop Dell laptops
155 dell-vostro Dell Vostro 157 dell-vostro Dell Vostro
156 olpc-xo-1_5 OLPC XO 1.5 158 olpc-xo-1_5 OLPC XO 1.5
157 ideapad Lenovo IdeaPad U150 159 ideapad Lenovo IdeaPad U150
158 thinkpad Lenovo Thinkpad 160 thinkpad Lenovo Thinkpad
159 161
160 STAC9200 162 STAC9200
161 ======== 163 ========
162 ref Reference board 164 ref Reference board
163 oqo OQO Model 2 165 oqo OQO Model 2
164 dell-d21 Dell (unknown) 166 dell-d21 Dell (unknown)
165 dell-d22 Dell (unknown) 167 dell-d22 Dell (unknown)
166 dell-d23 Dell (unknown) 168 dell-d23 Dell (unknown)
167 dell-m21 Dell Inspiron 630m, Dell Inspiron 640m 169 dell-m21 Dell Inspiron 630m, Dell Inspiron 640m
168 dell-m22 Dell Latitude D620, Dell Latitude D820 170 dell-m22 Dell Latitude D620, Dell Latitude D820
169 dell-m23 Dell XPS M1710, Dell Precision M90 171 dell-m23 Dell XPS M1710, Dell Precision M90
170 dell-m24 Dell Latitude 120L 172 dell-m24 Dell Latitude 120L
171 dell-m25 Dell Inspiron E1505n 173 dell-m25 Dell Inspiron E1505n
172 dell-m26 Dell Inspiron 1501 174 dell-m26 Dell Inspiron 1501
173 dell-m27 Dell Inspiron E1705/9400 175 dell-m27 Dell Inspiron E1705/9400
174 gateway-m4 Gateway laptops with EAPD control 176 gateway-m4 Gateway laptops with EAPD control
175 gateway-m4-2 Gateway laptops with EAPD control 177 gateway-m4-2 Gateway laptops with EAPD control
176 panasonic Panasonic CF-74 178 panasonic Panasonic CF-74
177 auto BIOS setup (default) 179 auto BIOS setup (default)
178 180
179 STAC9205/9254 181 STAC9205/9254
180 ============= 182 =============
181 ref Reference board 183 ref Reference board
182 dell-m42 Dell (unknown) 184 dell-m42 Dell (unknown)
183 dell-m43 Dell Precision 185 dell-m43 Dell Precision
184 dell-m44 Dell Inspiron 186 dell-m44 Dell Inspiron
185 eapd Keep EAPD on (e.g. Gateway T1616) 187 eapd Keep EAPD on (e.g. Gateway T1616)
186 auto BIOS setup (default) 188 auto BIOS setup (default)
187 189
188 STAC9220/9221 190 STAC9220/9221
189 ============= 191 =============
190 ref Reference board 192 ref Reference board
191 3stack D945 3stack 193 3stack D945 3stack
192 5stack D945 5stack + SPDIF 194 5stack D945 5stack + SPDIF
193 intel-mac-v1 Intel Mac Type 1 195 intel-mac-v1 Intel Mac Type 1
194 intel-mac-v2 Intel Mac Type 2 196 intel-mac-v2 Intel Mac Type 2
195 intel-mac-v3 Intel Mac Type 3 197 intel-mac-v3 Intel Mac Type 3
196 intel-mac-v4 Intel Mac Type 4 198 intel-mac-v4 Intel Mac Type 4
197 intel-mac-v5 Intel Mac Type 5 199 intel-mac-v5 Intel Mac Type 5
198 intel-mac-auto Intel Mac (detect type according to subsystem id) 200 intel-mac-auto Intel Mac (detect type according to subsystem id)
199 macmini Intel Mac Mini (equivalent with type 3) 201 macmini Intel Mac Mini (equivalent with type 3)
200 macbook Intel Mac Book (eq. type 5) 202 macbook Intel Mac Book (eq. type 5)
201 macbook-pro-v1 Intel Mac Book Pro 1st generation (eq. type 3) 203 macbook-pro-v1 Intel Mac Book Pro 1st generation (eq. type 3)
202 macbook-pro Intel Mac Book Pro 2nd generation (eq. type 3) 204 macbook-pro Intel Mac Book Pro 2nd generation (eq. type 3)
203 imac-intel Intel iMac (eq. type 2) 205 imac-intel Intel iMac (eq. type 2)
204 imac-intel-20 Intel iMac (newer version) (eq. type 3) 206 imac-intel-20 Intel iMac (newer version) (eq. type 3)
205 ecs202 ECS/PC chips 207 ecs202 ECS/PC chips
206 dell-d81 Dell (unknown) 208 dell-d81 Dell (unknown)
207 dell-d82 Dell (unknown) 209 dell-d82 Dell (unknown)
208 dell-m81 Dell (unknown) 210 dell-m81 Dell (unknown)
209 dell-m82 Dell XPS M1210 211 dell-m82 Dell XPS M1210
210 auto BIOS setup (default) 212 auto BIOS setup (default)
211 213
212 STAC9202/9250/9251 214 STAC9202/9250/9251
213 ================== 215 ==================
214 ref Reference board, base config 216 ref Reference board, base config
215 m1 Some Gateway MX series laptops (NX560XL) 217 m1 Some Gateway MX series laptops (NX560XL)
216 m1-2 Some Gateway MX series laptops (MX6453) 218 m1-2 Some Gateway MX series laptops (MX6453)
217 m2 Some Gateway MX series laptops (M255) 219 m2 Some Gateway MX series laptops (M255)
218 m2-2 Some Gateway MX series laptops 220 m2-2 Some Gateway MX series laptops
219 m3 Some Gateway MX series laptops 221 m3 Some Gateway MX series laptops
220 m5 Some Gateway MX series laptops (MP6954) 222 m5 Some Gateway MX series laptops (MP6954)
221 m6 Some Gateway NX series laptops 223 m6 Some Gateway NX series laptops
222 auto BIOS setup (default) 224 auto BIOS setup (default)
223 225
224 STAC9227/9228/9229/927x 226 STAC9227/9228/9229/927x
225 ======================= 227 =======================
226 ref Reference board 228 ref Reference board
227 ref-no-jd Reference board without HP/Mic jack detection 229 ref-no-jd Reference board without HP/Mic jack detection
228 3stack D965 3stack 230 3stack D965 3stack
229 5stack D965 5stack + SPDIF 231 5stack D965 5stack + SPDIF
230 5stack-no-fp D965 5stack without front panel 232 5stack-no-fp D965 5stack without front panel
231 dell-3stack Dell Dimension E520 233 dell-3stack Dell Dimension E520
232 dell-bios Fixes with Dell BIOS setup 234 dell-bios Fixes with Dell BIOS setup
233 volknob Fixes with volume-knob widget 0x24 235 volknob Fixes with volume-knob widget 0x24
234 auto BIOS setup (default) 236 auto BIOS setup (default)
235 237
236 STAC92HD71B* 238 STAC92HD71B*
237 ============ 239 ============
238 ref Reference board 240 ref Reference board
239 dell-m4-1 Dell desktops 241 dell-m4-1 Dell desktops
240 dell-m4-2 Dell desktops 242 dell-m4-2 Dell desktops
241 dell-m4-3 Dell desktops 243 dell-m4-3 Dell desktops
242 hp-m4 HP mini 1000 244 hp-m4 HP mini 1000
243 hp-dv5 HP dv series 245 hp-dv5 HP dv series
244 hp-hdx HP HDX series 246 hp-hdx HP HDX series
245 hp-dv4-1222nr HP dv4-1222nr (with LED support) 247 hp-dv4-1222nr HP dv4-1222nr (with LED support)
246 auto BIOS setup (default) 248 auto BIOS setup (default)
247 249
248 STAC92HD73* 250 STAC92HD73*
249 =========== 251 ===========
250 ref Reference board 252 ref Reference board
251 no-jd BIOS setup but without jack-detection 253 no-jd BIOS setup but without jack-detection
252 intel Intel DG45* mobos 254 intel Intel DG45* mobos
253 dell-m6-amic Dell desktops/laptops with analog mics 255 dell-m6-amic Dell desktops/laptops with analog mics
254 dell-m6-dmic Dell desktops/laptops with digital mics 256 dell-m6-dmic Dell desktops/laptops with digital mics
255 dell-m6 Dell desktops/laptops with both type of mics 257 dell-m6 Dell desktops/laptops with both type of mics
256 dell-eq Dell desktops/laptops 258 dell-eq Dell desktops/laptops
257 alienware Alienware M17x 259 alienware Alienware M17x
258 auto BIOS setup (default) 260 auto BIOS setup (default)
259 261
260 STAC92HD83* 262 STAC92HD83*
261 =========== 263 ===========
262 ref Reference board 264 ref Reference board
263 mic-ref Reference board with power management for ports 265 mic-ref Reference board with power management for ports
264 dell-s14 Dell laptop 266 dell-s14 Dell laptop
265 dell-vostro-3500 Dell Vostro 3500 laptop 267 dell-vostro-3500 Dell Vostro 3500 laptop
266 hp-dv7-4000 HP dv-7 4000 268 hp-dv7-4000 HP dv-7 4000
267 auto BIOS setup (default) 269 auto BIOS setup (default)
268 270
269 STAC9872 271 STAC9872
270 ======== 272 ========
271 vaio VAIO laptop without SPDIF 273 vaio VAIO laptop without SPDIF
272 auto BIOS setup (default) 274 auto BIOS setup (default)
273 275
274 Cirrus Logic CS4206/4207 276 Cirrus Logic CS4206/4207
275 ======================== 277 ========================
276 mbp55 MacBook Pro 5,5 278 mbp55 MacBook Pro 5,5
277 imac27 IMac 27 Inch 279 imac27 IMac 27 Inch
278 auto BIOS setup (default) 280 auto BIOS setup (default)
279 281
280 VIA VT17xx/VT18xx/VT20xx 282 VIA VT17xx/VT18xx/VT20xx
281 ======================== 283 ========================
282 auto BIOS setup (default) 284 auto BIOS setup (default)
283 285
sound/pci/hda/patch_realtek.c
1 /* 1 /*
2 * Universal Interface for Intel High Definition Audio Codec 2 * Universal Interface for Intel High Definition Audio Codec
3 * 3 *
4 * HD audio interface patch for Realtek ALC codecs 4 * HD audio interface patch for Realtek ALC codecs
5 * 5 *
6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> 6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw> 7 * PeiSen Hou <pshou@realtek.com.tw>
8 * Takashi Iwai <tiwai@suse.de> 8 * Takashi Iwai <tiwai@suse.de>
9 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au> 9 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
10 * 10 *
11 * This driver is free software; you can redistribute it and/or modify 11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by 12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or 13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version. 14 * (at your option) any later version.
15 * 15 *
16 * This driver is distributed in the hope that it will be useful, 16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */ 24 */
25 25
26 #include <linux/init.h> 26 #include <linux/init.h>
27 #include <linux/delay.h> 27 #include <linux/delay.h>
28 #include <linux/slab.h> 28 #include <linux/slab.h>
29 #include <linux/pci.h> 29 #include <linux/pci.h>
30 #include <linux/module.h> 30 #include <linux/module.h>
31 #include <sound/core.h> 31 #include <sound/core.h>
32 #include <sound/jack.h> 32 #include <sound/jack.h>
33 #include "hda_codec.h" 33 #include "hda_codec.h"
34 #include "hda_local.h" 34 #include "hda_local.h"
35 #include "hda_beep.h" 35 #include "hda_beep.h"
36 #include "hda_jack.h" 36 #include "hda_jack.h"
37 37
38 /* unsol event tags */ 38 /* unsol event tags */
39 #define ALC_FRONT_EVENT 0x01 39 #define ALC_FRONT_EVENT 0x01
40 #define ALC_DCVOL_EVENT 0x02 40 #define ALC_DCVOL_EVENT 0x02
41 #define ALC_HP_EVENT 0x04 41 #define ALC_HP_EVENT 0x04
42 #define ALC_MIC_EVENT 0x08 42 #define ALC_MIC_EVENT 0x08
43 43
44 /* for GPIO Poll */ 44 /* for GPIO Poll */
45 #define GPIO_MASK 0x03 45 #define GPIO_MASK 0x03
46 46
47 /* extra amp-initialization sequence types */ 47 /* extra amp-initialization sequence types */
48 enum { 48 enum {
49 ALC_INIT_NONE, 49 ALC_INIT_NONE,
50 ALC_INIT_DEFAULT, 50 ALC_INIT_DEFAULT,
51 ALC_INIT_GPIO1, 51 ALC_INIT_GPIO1,
52 ALC_INIT_GPIO2, 52 ALC_INIT_GPIO2,
53 ALC_INIT_GPIO3, 53 ALC_INIT_GPIO3,
54 }; 54 };
55 55
56 struct alc_customize_define { 56 struct alc_customize_define {
57 unsigned int sku_cfg; 57 unsigned int sku_cfg;
58 unsigned char port_connectivity; 58 unsigned char port_connectivity;
59 unsigned char check_sum; 59 unsigned char check_sum;
60 unsigned char customization; 60 unsigned char customization;
61 unsigned char external_amp; 61 unsigned char external_amp;
62 unsigned int enable_pcbeep:1; 62 unsigned int enable_pcbeep:1;
63 unsigned int platform_type:1; 63 unsigned int platform_type:1;
64 unsigned int swap:1; 64 unsigned int swap:1;
65 unsigned int override:1; 65 unsigned int override:1;
66 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */ 66 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
67 }; 67 };
68 68
69 struct alc_fixup; 69 struct alc_fixup;
70 70
71 struct alc_multi_io { 71 struct alc_multi_io {
72 hda_nid_t pin; /* multi-io widget pin NID */ 72 hda_nid_t pin; /* multi-io widget pin NID */
73 hda_nid_t dac; /* DAC to be connected */ 73 hda_nid_t dac; /* DAC to be connected */
74 unsigned int ctl_in; /* cached input-pin control value */ 74 unsigned int ctl_in; /* cached input-pin control value */
75 }; 75 };
76 76
77 enum { 77 enum {
78 ALC_AUTOMUTE_PIN, /* change the pin control */ 78 ALC_AUTOMUTE_PIN, /* change the pin control */
79 ALC_AUTOMUTE_AMP, /* mute/unmute the pin AMP */ 79 ALC_AUTOMUTE_AMP, /* mute/unmute the pin AMP */
80 ALC_AUTOMUTE_MIXER, /* mute/unmute mixer widget AMP */ 80 ALC_AUTOMUTE_MIXER, /* mute/unmute mixer widget AMP */
81 }; 81 };
82 82
83 #define MAX_VOL_NIDS 0x40 83 #define MAX_VOL_NIDS 0x40
84 84
85 struct alc_spec { 85 struct alc_spec {
86 /* codec parameterization */ 86 /* codec parameterization */
87 const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ 87 const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
88 unsigned int num_mixers; 88 unsigned int num_mixers;
89 const struct snd_kcontrol_new *cap_mixer; /* capture mixer */ 89 const struct snd_kcontrol_new *cap_mixer; /* capture mixer */
90 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ 90 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
91 91
92 const struct hda_verb *init_verbs[10]; /* initialization verbs 92 const struct hda_verb *init_verbs[10]; /* initialization verbs
93 * don't forget NULL 93 * don't forget NULL
94 * termination! 94 * termination!
95 */ 95 */
96 unsigned int num_init_verbs; 96 unsigned int num_init_verbs;
97 97
98 char stream_name_analog[32]; /* analog PCM stream */ 98 char stream_name_analog[32]; /* analog PCM stream */
99 const struct hda_pcm_stream *stream_analog_playback; 99 const struct hda_pcm_stream *stream_analog_playback;
100 const struct hda_pcm_stream *stream_analog_capture; 100 const struct hda_pcm_stream *stream_analog_capture;
101 const struct hda_pcm_stream *stream_analog_alt_playback; 101 const struct hda_pcm_stream *stream_analog_alt_playback;
102 const struct hda_pcm_stream *stream_analog_alt_capture; 102 const struct hda_pcm_stream *stream_analog_alt_capture;
103 103
104 char stream_name_digital[32]; /* digital PCM stream */ 104 char stream_name_digital[32]; /* digital PCM stream */
105 const struct hda_pcm_stream *stream_digital_playback; 105 const struct hda_pcm_stream *stream_digital_playback;
106 const struct hda_pcm_stream *stream_digital_capture; 106 const struct hda_pcm_stream *stream_digital_capture;
107 107
108 /* playback */ 108 /* playback */
109 struct hda_multi_out multiout; /* playback set-up 109 struct hda_multi_out multiout; /* playback set-up
110 * max_channels, dacs must be set 110 * max_channels, dacs must be set
111 * dig_out_nid and hp_nid are optional 111 * dig_out_nid and hp_nid are optional
112 */ 112 */
113 hda_nid_t alt_dac_nid; 113 hda_nid_t alt_dac_nid;
114 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */ 114 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
115 int dig_out_type; 115 int dig_out_type;
116 116
117 /* capture */ 117 /* capture */
118 unsigned int num_adc_nids; 118 unsigned int num_adc_nids;
119 const hda_nid_t *adc_nids; 119 const hda_nid_t *adc_nids;
120 const hda_nid_t *capsrc_nids; 120 const hda_nid_t *capsrc_nids;
121 hda_nid_t dig_in_nid; /* digital-in NID; optional */ 121 hda_nid_t dig_in_nid; /* digital-in NID; optional */
122 hda_nid_t mixer_nid; /* analog-mixer NID */ 122 hda_nid_t mixer_nid; /* analog-mixer NID */
123 DECLARE_BITMAP(vol_ctls, MAX_VOL_NIDS << 1); 123 DECLARE_BITMAP(vol_ctls, MAX_VOL_NIDS << 1);
124 DECLARE_BITMAP(sw_ctls, MAX_VOL_NIDS << 1); 124 DECLARE_BITMAP(sw_ctls, MAX_VOL_NIDS << 1);
125 125
126 /* capture setup for dynamic dual-adc switch */ 126 /* capture setup for dynamic dual-adc switch */
127 hda_nid_t cur_adc; 127 hda_nid_t cur_adc;
128 unsigned int cur_adc_stream_tag; 128 unsigned int cur_adc_stream_tag;
129 unsigned int cur_adc_format; 129 unsigned int cur_adc_format;
130 130
131 /* capture source */ 131 /* capture source */
132 unsigned int num_mux_defs; 132 unsigned int num_mux_defs;
133 const struct hda_input_mux *input_mux; 133 const struct hda_input_mux *input_mux;
134 unsigned int cur_mux[3]; 134 unsigned int cur_mux[3];
135 hda_nid_t ext_mic_pin; 135 hda_nid_t ext_mic_pin;
136 hda_nid_t dock_mic_pin; 136 hda_nid_t dock_mic_pin;
137 hda_nid_t int_mic_pin; 137 hda_nid_t int_mic_pin;
138 138
139 /* channel model */ 139 /* channel model */
140 const struct hda_channel_mode *channel_mode; 140 const struct hda_channel_mode *channel_mode;
141 int num_channel_mode; 141 int num_channel_mode;
142 int need_dac_fix; 142 int need_dac_fix;
143 int const_channel_count; 143 int const_channel_count;
144 int ext_channel_count; 144 int ext_channel_count;
145 145
146 /* PCM information */ 146 /* PCM information */
147 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ 147 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
148 148
149 /* dynamic controls, init_verbs and input_mux */ 149 /* dynamic controls, init_verbs and input_mux */
150 struct auto_pin_cfg autocfg; 150 struct auto_pin_cfg autocfg;
151 struct alc_customize_define cdefine; 151 struct alc_customize_define cdefine;
152 struct snd_array kctls; 152 struct snd_array kctls;
153 struct hda_input_mux private_imux[3]; 153 struct hda_input_mux private_imux[3];
154 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; 154 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
155 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS]; 155 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
156 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS]; 156 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
157 hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS]; 157 hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS];
158 unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS]; 158 unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS];
159 int int_mic_idx, ext_mic_idx, dock_mic_idx; /* for auto-mic */ 159 int int_mic_idx, ext_mic_idx, dock_mic_idx; /* for auto-mic */
160 160
161 /* hooks */ 161 /* hooks */
162 void (*init_hook)(struct hda_codec *codec); 162 void (*init_hook)(struct hda_codec *codec);
163 void (*unsol_event)(struct hda_codec *codec, unsigned int res); 163 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
164 #ifdef CONFIG_SND_HDA_POWER_SAVE 164 #ifdef CONFIG_SND_HDA_POWER_SAVE
165 void (*power_hook)(struct hda_codec *codec); 165 void (*power_hook)(struct hda_codec *codec);
166 #endif 166 #endif
167 void (*shutup)(struct hda_codec *codec); 167 void (*shutup)(struct hda_codec *codec);
168 void (*automute_hook)(struct hda_codec *codec); 168 void (*automute_hook)(struct hda_codec *codec);
169 169
170 /* for pin sensing */ 170 /* for pin sensing */
171 unsigned int hp_jack_present:1; 171 unsigned int hp_jack_present:1;
172 unsigned int line_jack_present:1; 172 unsigned int line_jack_present:1;
173 unsigned int master_mute:1; 173 unsigned int master_mute:1;
174 unsigned int auto_mic:1; 174 unsigned int auto_mic:1;
175 unsigned int auto_mic_valid_imux:1; /* valid imux for auto-mic */ 175 unsigned int auto_mic_valid_imux:1; /* valid imux for auto-mic */
176 unsigned int automute_speaker:1; /* automute speaker outputs */ 176 unsigned int automute_speaker:1; /* automute speaker outputs */
177 unsigned int automute_lo:1; /* automute LO outputs */ 177 unsigned int automute_lo:1; /* automute LO outputs */
178 unsigned int detect_hp:1; /* Headphone detection enabled */ 178 unsigned int detect_hp:1; /* Headphone detection enabled */
179 unsigned int detect_lo:1; /* Line-out detection enabled */ 179 unsigned int detect_lo:1; /* Line-out detection enabled */
180 unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */ 180 unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */
181 unsigned int automute_lo_possible:1; /* there are line outs and HP */ 181 unsigned int automute_lo_possible:1; /* there are line outs and HP */
182 unsigned int keep_vref_in_automute:1; /* Don't clear VREF in automute */ 182 unsigned int keep_vref_in_automute:1; /* Don't clear VREF in automute */
183 183
184 /* other flags */ 184 /* other flags */
185 unsigned int no_analog :1; /* digital I/O only */ 185 unsigned int no_analog :1; /* digital I/O only */
186 unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */ 186 unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */
187 unsigned int single_input_src:1; 187 unsigned int single_input_src:1;
188 unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */ 188 unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */
189 unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */ 189 unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */
190 unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */ 190 unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */
191 191
192 /* auto-mute control */ 192 /* auto-mute control */
193 int automute_mode; 193 int automute_mode;
194 hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS]; 194 hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS];
195 195
196 int init_amp; 196 int init_amp;
197 int codec_variant; /* flag for other variants */ 197 int codec_variant; /* flag for other variants */
198 198
199 /* for virtual master */ 199 /* for virtual master */
200 hda_nid_t vmaster_nid; 200 hda_nid_t vmaster_nid;
201 struct hda_vmaster_mute_hook vmaster_mute; 201 struct hda_vmaster_mute_hook vmaster_mute;
202 #ifdef CONFIG_SND_HDA_POWER_SAVE 202 #ifdef CONFIG_SND_HDA_POWER_SAVE
203 struct hda_loopback_check loopback; 203 struct hda_loopback_check loopback;
204 int num_loopbacks; 204 int num_loopbacks;
205 struct hda_amp_list loopback_list[8]; 205 struct hda_amp_list loopback_list[8];
206 #endif 206 #endif
207 207
208 /* for PLL fix */ 208 /* for PLL fix */
209 hda_nid_t pll_nid; 209 hda_nid_t pll_nid;
210 unsigned int pll_coef_idx, pll_coef_bit; 210 unsigned int pll_coef_idx, pll_coef_bit;
211 unsigned int coef0; 211 unsigned int coef0;
212 212
213 /* fix-up list */ 213 /* fix-up list */
214 int fixup_id; 214 int fixup_id;
215 const struct alc_fixup *fixup_list; 215 const struct alc_fixup *fixup_list;
216 const char *fixup_name; 216 const char *fixup_name;
217 217
218 /* multi-io */ 218 /* multi-io */
219 int multi_ios; 219 int multi_ios;
220 struct alc_multi_io multi_io[4]; 220 struct alc_multi_io multi_io[4];
221 221
222 /* bind volumes */ 222 /* bind volumes */
223 struct snd_array bind_ctls; 223 struct snd_array bind_ctls;
224 }; 224 };
225 225
226 static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid, 226 static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid,
227 int dir, unsigned int bits) 227 int dir, unsigned int bits)
228 { 228 {
229 if (!nid) 229 if (!nid)
230 return false; 230 return false;
231 if (get_wcaps(codec, nid) & (1 << (dir + 1))) 231 if (get_wcaps(codec, nid) & (1 << (dir + 1)))
232 if (query_amp_caps(codec, nid, dir) & bits) 232 if (query_amp_caps(codec, nid, dir) & bits)
233 return true; 233 return true;
234 return false; 234 return false;
235 } 235 }
236 236
237 #define nid_has_mute(codec, nid, dir) \ 237 #define nid_has_mute(codec, nid, dir) \
238 check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE) 238 check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE)
239 #define nid_has_volume(codec, nid, dir) \ 239 #define nid_has_volume(codec, nid, dir) \
240 check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS) 240 check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS)
241 241
242 /* 242 /*
243 * input MUX handling 243 * input MUX handling
244 */ 244 */
245 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, 245 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
246 struct snd_ctl_elem_info *uinfo) 246 struct snd_ctl_elem_info *uinfo)
247 { 247 {
248 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 248 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
249 struct alc_spec *spec = codec->spec; 249 struct alc_spec *spec = codec->spec;
250 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); 250 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
251 if (mux_idx >= spec->num_mux_defs) 251 if (mux_idx >= spec->num_mux_defs)
252 mux_idx = 0; 252 mux_idx = 0;
253 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0) 253 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
254 mux_idx = 0; 254 mux_idx = 0;
255 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); 255 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
256 } 256 }
257 257
258 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, 258 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
259 struct snd_ctl_elem_value *ucontrol) 259 struct snd_ctl_elem_value *ucontrol)
260 { 260 {
261 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 261 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
262 struct alc_spec *spec = codec->spec; 262 struct alc_spec *spec = codec->spec;
263 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 263 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
264 264
265 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; 265 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
266 return 0; 266 return 0;
267 } 267 }
268 268
269 static bool alc_dyn_adc_pcm_resetup(struct hda_codec *codec, int cur) 269 static bool alc_dyn_adc_pcm_resetup(struct hda_codec *codec, int cur)
270 { 270 {
271 struct alc_spec *spec = codec->spec; 271 struct alc_spec *spec = codec->spec;
272 hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]]; 272 hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]];
273 273
274 if (spec->cur_adc && spec->cur_adc != new_adc) { 274 if (spec->cur_adc && spec->cur_adc != new_adc) {
275 /* stream is running, let's swap the current ADC */ 275 /* stream is running, let's swap the current ADC */
276 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); 276 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
277 spec->cur_adc = new_adc; 277 spec->cur_adc = new_adc;
278 snd_hda_codec_setup_stream(codec, new_adc, 278 snd_hda_codec_setup_stream(codec, new_adc,
279 spec->cur_adc_stream_tag, 0, 279 spec->cur_adc_stream_tag, 0,
280 spec->cur_adc_format); 280 spec->cur_adc_format);
281 return true; 281 return true;
282 } 282 }
283 return false; 283 return false;
284 } 284 }
285 285
286 static inline hda_nid_t get_capsrc(struct alc_spec *spec, int idx) 286 static inline hda_nid_t get_capsrc(struct alc_spec *spec, int idx)
287 { 287 {
288 return spec->capsrc_nids ? 288 return spec->capsrc_nids ?
289 spec->capsrc_nids[idx] : spec->adc_nids[idx]; 289 spec->capsrc_nids[idx] : spec->adc_nids[idx];
290 } 290 }
291 291
292 static void call_update_outputs(struct hda_codec *codec); 292 static void call_update_outputs(struct hda_codec *codec);
293 293
294 /* select the given imux item; either unmute exclusively or select the route */ 294 /* select the given imux item; either unmute exclusively or select the route */
295 static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, 295 static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
296 unsigned int idx, bool force) 296 unsigned int idx, bool force)
297 { 297 {
298 struct alc_spec *spec = codec->spec; 298 struct alc_spec *spec = codec->spec;
299 const struct hda_input_mux *imux; 299 const struct hda_input_mux *imux;
300 unsigned int mux_idx; 300 unsigned int mux_idx;
301 int i, type, num_conns; 301 int i, type, num_conns;
302 hda_nid_t nid; 302 hda_nid_t nid;
303 303
304 if (!spec->input_mux) 304 if (!spec->input_mux)
305 return 0; 305 return 0;
306 306
307 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; 307 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
308 imux = &spec->input_mux[mux_idx]; 308 imux = &spec->input_mux[mux_idx];
309 if (!imux->num_items && mux_idx > 0) 309 if (!imux->num_items && mux_idx > 0)
310 imux = &spec->input_mux[0]; 310 imux = &spec->input_mux[0];
311 if (!imux->num_items) 311 if (!imux->num_items)
312 return 0; 312 return 0;
313 313
314 if (idx >= imux->num_items) 314 if (idx >= imux->num_items)
315 idx = imux->num_items - 1; 315 idx = imux->num_items - 1;
316 if (spec->cur_mux[adc_idx] == idx && !force) 316 if (spec->cur_mux[adc_idx] == idx && !force)
317 return 0; 317 return 0;
318 spec->cur_mux[adc_idx] = idx; 318 spec->cur_mux[adc_idx] = idx;
319 319
320 /* for shared I/O, change the pin-control accordingly */ 320 /* for shared I/O, change the pin-control accordingly */
321 if (spec->shared_mic_hp) { 321 if (spec->shared_mic_hp) {
322 /* NOTE: this assumes that there are only two inputs, the 322 /* NOTE: this assumes that there are only two inputs, the
323 * first is the real internal mic and the second is HP jack. 323 * first is the real internal mic and the second is HP jack.
324 */ 324 */
325 snd_hda_codec_write(codec, spec->autocfg.inputs[1].pin, 0, 325 snd_hda_codec_write(codec, spec->autocfg.inputs[1].pin, 0,
326 AC_VERB_SET_PIN_WIDGET_CONTROL, 326 AC_VERB_SET_PIN_WIDGET_CONTROL,
327 spec->cur_mux[adc_idx] ? 327 spec->cur_mux[adc_idx] ?
328 PIN_VREF80 : PIN_HP); 328 PIN_VREF80 : PIN_HP);
329 spec->automute_speaker = !spec->cur_mux[adc_idx]; 329 spec->automute_speaker = !spec->cur_mux[adc_idx];
330 call_update_outputs(codec); 330 call_update_outputs(codec);
331 } 331 }
332 332
333 if (spec->dyn_adc_switch) { 333 if (spec->dyn_adc_switch) {
334 alc_dyn_adc_pcm_resetup(codec, idx); 334 alc_dyn_adc_pcm_resetup(codec, idx);
335 adc_idx = spec->dyn_adc_idx[idx]; 335 adc_idx = spec->dyn_adc_idx[idx];
336 } 336 }
337 337
338 nid = get_capsrc(spec, adc_idx); 338 nid = get_capsrc(spec, adc_idx);
339 339
340 /* no selection? */ 340 /* no selection? */
341 num_conns = snd_hda_get_conn_list(codec, nid, NULL); 341 num_conns = snd_hda_get_conn_list(codec, nid, NULL);
342 if (num_conns <= 1) 342 if (num_conns <= 1)
343 return 1; 343 return 1;
344 344
345 type = get_wcaps_type(get_wcaps(codec, nid)); 345 type = get_wcaps_type(get_wcaps(codec, nid));
346 if (type == AC_WID_AUD_MIX) { 346 if (type == AC_WID_AUD_MIX) {
347 /* Matrix-mixer style (e.g. ALC882) */ 347 /* Matrix-mixer style (e.g. ALC882) */
348 int active = imux->items[idx].index; 348 int active = imux->items[idx].index;
349 for (i = 0; i < num_conns; i++) { 349 for (i = 0; i < num_conns; i++) {
350 unsigned int v = (i == active) ? 0 : HDA_AMP_MUTE; 350 unsigned int v = (i == active) ? 0 : HDA_AMP_MUTE;
351 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, i, 351 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, i,
352 HDA_AMP_MUTE, v); 352 HDA_AMP_MUTE, v);
353 } 353 }
354 } else { 354 } else {
355 /* MUX style (e.g. ALC880) */ 355 /* MUX style (e.g. ALC880) */
356 snd_hda_codec_write_cache(codec, nid, 0, 356 snd_hda_codec_write_cache(codec, nid, 0,
357 AC_VERB_SET_CONNECT_SEL, 357 AC_VERB_SET_CONNECT_SEL,
358 imux->items[idx].index); 358 imux->items[idx].index);
359 } 359 }
360 return 1; 360 return 1;
361 } 361 }
362 362
363 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, 363 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
364 struct snd_ctl_elem_value *ucontrol) 364 struct snd_ctl_elem_value *ucontrol)
365 { 365 {
366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
367 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 367 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
368 return alc_mux_select(codec, adc_idx, 368 return alc_mux_select(codec, adc_idx,
369 ucontrol->value.enumerated.item[0], false); 369 ucontrol->value.enumerated.item[0], false);
370 } 370 }
371 371
372 /* 372 /*
373 * set up the input pin config (depending on the given auto-pin type) 373 * set up the input pin config (depending on the given auto-pin type)
374 */ 374 */
375 static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, 375 static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
376 int auto_pin_type) 376 int auto_pin_type)
377 { 377 {
378 unsigned int val = PIN_IN; 378 unsigned int val = PIN_IN;
379 379
380 if (auto_pin_type == AUTO_PIN_MIC) { 380 if (auto_pin_type == AUTO_PIN_MIC) {
381 unsigned int pincap; 381 unsigned int pincap;
382 unsigned int oldval; 382 unsigned int oldval;
383 oldval = snd_hda_codec_read(codec, nid, 0, 383 oldval = snd_hda_codec_read(codec, nid, 0,
384 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 384 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
385 pincap = snd_hda_query_pin_caps(codec, nid); 385 pincap = snd_hda_query_pin_caps(codec, nid);
386 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; 386 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
387 /* if the default pin setup is vref50, we give it priority */ 387 /* if the default pin setup is vref50, we give it priority */
388 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50) 388 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
389 val = PIN_VREF80; 389 val = PIN_VREF80;
390 else if (pincap & AC_PINCAP_VREF_50) 390 else if (pincap & AC_PINCAP_VREF_50)
391 val = PIN_VREF50; 391 val = PIN_VREF50;
392 else if (pincap & AC_PINCAP_VREF_100) 392 else if (pincap & AC_PINCAP_VREF_100)
393 val = PIN_VREF100; 393 val = PIN_VREF100;
394 else if (pincap & AC_PINCAP_VREF_GRD) 394 else if (pincap & AC_PINCAP_VREF_GRD)
395 val = PIN_VREFGRD; 395 val = PIN_VREFGRD;
396 } 396 }
397 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val); 397 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
398 } 398 }
399 399
400 /* 400 /*
401 * Append the given mixer and verb elements for the later use 401 * Append the given mixer and verb elements for the later use
402 * The mixer array is referred in build_controls(), and init_verbs are 402 * The mixer array is referred in build_controls(), and init_verbs are
403 * called in init(). 403 * called in init().
404 */ 404 */
405 static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix) 405 static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix)
406 { 406 {
407 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) 407 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
408 return; 408 return;
409 spec->mixers[spec->num_mixers++] = mix; 409 spec->mixers[spec->num_mixers++] = mix;
410 } 410 }
411 411
412 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb) 412 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
413 { 413 {
414 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs))) 414 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
415 return; 415 return;
416 spec->init_verbs[spec->num_init_verbs++] = verb; 416 spec->init_verbs[spec->num_init_verbs++] = verb;
417 } 417 }
418 418
419 /* 419 /*
420 * GPIO setup tables, used in initialization 420 * GPIO setup tables, used in initialization
421 */ 421 */
422 /* Enable GPIO mask and set output */ 422 /* Enable GPIO mask and set output */
423 static const struct hda_verb alc_gpio1_init_verbs[] = { 423 static const struct hda_verb alc_gpio1_init_verbs[] = {
424 {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, 424 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
425 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, 425 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
426 {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, 426 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
427 { } 427 { }
428 }; 428 };
429 429
430 static const struct hda_verb alc_gpio2_init_verbs[] = { 430 static const struct hda_verb alc_gpio2_init_verbs[] = {
431 {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, 431 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
432 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, 432 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
433 {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, 433 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
434 { } 434 { }
435 }; 435 };
436 436
437 static const struct hda_verb alc_gpio3_init_verbs[] = { 437 static const struct hda_verb alc_gpio3_init_verbs[] = {
438 {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 438 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
439 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, 439 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
440 {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, 440 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
441 { } 441 { }
442 }; 442 };
443 443
444 /* 444 /*
445 * Fix hardware PLL issue 445 * Fix hardware PLL issue
446 * On some codecs, the analog PLL gating control must be off while 446 * On some codecs, the analog PLL gating control must be off while
447 * the default value is 1. 447 * the default value is 1.
448 */ 448 */
449 static void alc_fix_pll(struct hda_codec *codec) 449 static void alc_fix_pll(struct hda_codec *codec)
450 { 450 {
451 struct alc_spec *spec = codec->spec; 451 struct alc_spec *spec = codec->spec;
452 unsigned int val; 452 unsigned int val;
453 453
454 if (!spec->pll_nid) 454 if (!spec->pll_nid)
455 return; 455 return;
456 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, 456 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
457 spec->pll_coef_idx); 457 spec->pll_coef_idx);
458 val = snd_hda_codec_read(codec, spec->pll_nid, 0, 458 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
459 AC_VERB_GET_PROC_COEF, 0); 459 AC_VERB_GET_PROC_COEF, 0);
460 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, 460 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
461 spec->pll_coef_idx); 461 spec->pll_coef_idx);
462 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, 462 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
463 val & ~(1 << spec->pll_coef_bit)); 463 val & ~(1 << spec->pll_coef_bit));
464 } 464 }
465 465
466 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, 466 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
467 unsigned int coef_idx, unsigned int coef_bit) 467 unsigned int coef_idx, unsigned int coef_bit)
468 { 468 {
469 struct alc_spec *spec = codec->spec; 469 struct alc_spec *spec = codec->spec;
470 spec->pll_nid = nid; 470 spec->pll_nid = nid;
471 spec->pll_coef_idx = coef_idx; 471 spec->pll_coef_idx = coef_idx;
472 spec->pll_coef_bit = coef_bit; 472 spec->pll_coef_bit = coef_bit;
473 alc_fix_pll(codec); 473 alc_fix_pll(codec);
474 } 474 }
475 475
476 /* 476 /*
477 * Jack detections for HP auto-mute and mic-switch 477 * Jack detections for HP auto-mute and mic-switch
478 */ 478 */
479 479
480 /* check each pin in the given array; returns true if any of them is plugged */ 480 /* check each pin in the given array; returns true if any of them is plugged */
481 static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins) 481 static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins)
482 { 482 {
483 int i, present = 0; 483 int i, present = 0;
484 484
485 for (i = 0; i < num_pins; i++) { 485 for (i = 0; i < num_pins; i++) {
486 hda_nid_t nid = pins[i]; 486 hda_nid_t nid = pins[i];
487 if (!nid) 487 if (!nid)
488 break; 488 break;
489 present |= snd_hda_jack_detect(codec, nid); 489 present |= snd_hda_jack_detect(codec, nid);
490 } 490 }
491 return present; 491 return present;
492 } 492 }
493 493
494 /* standard HP/line-out auto-mute helper */ 494 /* standard HP/line-out auto-mute helper */
495 static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins, 495 static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins,
496 bool mute, bool hp_out) 496 bool mute, bool hp_out)
497 { 497 {
498 struct alc_spec *spec = codec->spec; 498 struct alc_spec *spec = codec->spec;
499 unsigned int mute_bits = mute ? HDA_AMP_MUTE : 0; 499 unsigned int mute_bits = mute ? HDA_AMP_MUTE : 0;
500 unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT); 500 unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT);
501 int i; 501 int i;
502 502
503 for (i = 0; i < num_pins; i++) { 503 for (i = 0; i < num_pins; i++) {
504 hda_nid_t nid = pins[i]; 504 hda_nid_t nid = pins[i];
505 unsigned int val; 505 unsigned int val;
506 if (!nid) 506 if (!nid)
507 break; 507 break;
508 switch (spec->automute_mode) { 508 switch (spec->automute_mode) {
509 case ALC_AUTOMUTE_PIN: 509 case ALC_AUTOMUTE_PIN:
510 /* don't reset VREF value in case it's controlling 510 /* don't reset VREF value in case it's controlling
511 * the amp (see alc861_fixup_asus_amp_vref_0f()) 511 * the amp (see alc861_fixup_asus_amp_vref_0f())
512 */ 512 */
513 if (spec->keep_vref_in_automute) { 513 if (spec->keep_vref_in_automute) {
514 val = snd_hda_codec_read(codec, nid, 0, 514 val = snd_hda_codec_read(codec, nid, 0,
515 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 515 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
516 val &= ~PIN_HP; 516 val &= ~PIN_HP;
517 } else 517 } else
518 val = 0; 518 val = 0;
519 val |= pin_bits; 519 val |= pin_bits;
520 snd_hda_codec_write(codec, nid, 0, 520 snd_hda_codec_write(codec, nid, 0,
521 AC_VERB_SET_PIN_WIDGET_CONTROL, 521 AC_VERB_SET_PIN_WIDGET_CONTROL,
522 val); 522 val);
523 break; 523 break;
524 case ALC_AUTOMUTE_AMP: 524 case ALC_AUTOMUTE_AMP:
525 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, 525 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
526 HDA_AMP_MUTE, mute_bits); 526 HDA_AMP_MUTE, mute_bits);
527 break; 527 break;
528 case ALC_AUTOMUTE_MIXER: 528 case ALC_AUTOMUTE_MIXER:
529 nid = spec->automute_mixer_nid[i]; 529 nid = spec->automute_mixer_nid[i];
530 if (!nid) 530 if (!nid)
531 break; 531 break;
532 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, 532 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
533 HDA_AMP_MUTE, mute_bits); 533 HDA_AMP_MUTE, mute_bits);
534 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 1, 534 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 1,
535 HDA_AMP_MUTE, mute_bits); 535 HDA_AMP_MUTE, mute_bits);
536 break; 536 break;
537 } 537 }
538 } 538 }
539 } 539 }
540 540
541 /* Toggle outputs muting */ 541 /* Toggle outputs muting */
542 static void update_outputs(struct hda_codec *codec) 542 static void update_outputs(struct hda_codec *codec)
543 { 543 {
544 struct alc_spec *spec = codec->spec; 544 struct alc_spec *spec = codec->spec;
545 int on; 545 int on;
546 546
547 /* Control HP pins/amps depending on master_mute state; 547 /* Control HP pins/amps depending on master_mute state;
548 * in general, HP pins/amps control should be enabled in all cases, 548 * in general, HP pins/amps control should be enabled in all cases,
549 * but currently set only for master_mute, just to be safe 549 * but currently set only for master_mute, just to be safe
550 */ 550 */
551 if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */ 551 if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */
552 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), 552 do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
553 spec->autocfg.hp_pins, spec->master_mute, true); 553 spec->autocfg.hp_pins, spec->master_mute, true);
554 554
555 if (!spec->automute_speaker) 555 if (!spec->automute_speaker)
556 on = 0; 556 on = 0;
557 else 557 else
558 on = spec->hp_jack_present | spec->line_jack_present; 558 on = spec->hp_jack_present | spec->line_jack_present;
559 on |= spec->master_mute; 559 on |= spec->master_mute;
560 do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), 560 do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins),
561 spec->autocfg.speaker_pins, on, false); 561 spec->autocfg.speaker_pins, on, false);
562 562
563 /* toggle line-out mutes if needed, too */ 563 /* toggle line-out mutes if needed, too */
564 /* if LO is a copy of either HP or Speaker, don't need to handle it */ 564 /* if LO is a copy of either HP or Speaker, don't need to handle it */
565 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] || 565 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] ||
566 spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0]) 566 spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0])
567 return; 567 return;
568 if (!spec->automute_lo) 568 if (!spec->automute_lo)
569 on = 0; 569 on = 0;
570 else 570 else
571 on = spec->hp_jack_present; 571 on = spec->hp_jack_present;
572 on |= spec->master_mute; 572 on |= spec->master_mute;
573 do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), 573 do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
574 spec->autocfg.line_out_pins, on, false); 574 spec->autocfg.line_out_pins, on, false);
575 } 575 }
576 576
577 static void call_update_outputs(struct hda_codec *codec) 577 static void call_update_outputs(struct hda_codec *codec)
578 { 578 {
579 struct alc_spec *spec = codec->spec; 579 struct alc_spec *spec = codec->spec;
580 if (spec->automute_hook) 580 if (spec->automute_hook)
581 spec->automute_hook(codec); 581 spec->automute_hook(codec);
582 else 582 else
583 update_outputs(codec); 583 update_outputs(codec);
584 } 584 }
585 585
586 /* standard HP-automute helper */ 586 /* standard HP-automute helper */
587 static void alc_hp_automute(struct hda_codec *codec) 587 static void alc_hp_automute(struct hda_codec *codec)
588 { 588 {
589 struct alc_spec *spec = codec->spec; 589 struct alc_spec *spec = codec->spec;
590 590
591 spec->hp_jack_present = 591 spec->hp_jack_present =
592 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins), 592 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins),
593 spec->autocfg.hp_pins); 593 spec->autocfg.hp_pins);
594 if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo)) 594 if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo))
595 return; 595 return;
596 call_update_outputs(codec); 596 call_update_outputs(codec);
597 } 597 }
598 598
599 /* standard line-out-automute helper */ 599 /* standard line-out-automute helper */
600 static void alc_line_automute(struct hda_codec *codec) 600 static void alc_line_automute(struct hda_codec *codec)
601 { 601 {
602 struct alc_spec *spec = codec->spec; 602 struct alc_spec *spec = codec->spec;
603 603
604 /* check LO jack only when it's different from HP */ 604 /* check LO jack only when it's different from HP */
605 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0]) 605 if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0])
606 return; 606 return;
607 607
608 spec->line_jack_present = 608 spec->line_jack_present =
609 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), 609 detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins),
610 spec->autocfg.line_out_pins); 610 spec->autocfg.line_out_pins);
611 if (!spec->automute_speaker || !spec->detect_lo) 611 if (!spec->automute_speaker || !spec->detect_lo)
612 return; 612 return;
613 call_update_outputs(codec); 613 call_update_outputs(codec);
614 } 614 }
615 615
616 #define get_connection_index(codec, mux, nid) \ 616 #define get_connection_index(codec, mux, nid) \
617 snd_hda_get_conn_index(codec, mux, nid, 0) 617 snd_hda_get_conn_index(codec, mux, nid, 0)
618 618
619 /* standard mic auto-switch helper */ 619 /* standard mic auto-switch helper */
620 static void alc_mic_automute(struct hda_codec *codec) 620 static void alc_mic_automute(struct hda_codec *codec)
621 { 621 {
622 struct alc_spec *spec = codec->spec; 622 struct alc_spec *spec = codec->spec;
623 hda_nid_t *pins = spec->imux_pins; 623 hda_nid_t *pins = spec->imux_pins;
624 624
625 if (!spec->auto_mic || !spec->auto_mic_valid_imux) 625 if (!spec->auto_mic || !spec->auto_mic_valid_imux)
626 return; 626 return;
627 if (snd_BUG_ON(!spec->adc_nids)) 627 if (snd_BUG_ON(!spec->adc_nids))
628 return; 628 return;
629 if (snd_BUG_ON(spec->int_mic_idx < 0 || spec->ext_mic_idx < 0)) 629 if (snd_BUG_ON(spec->int_mic_idx < 0 || spec->ext_mic_idx < 0))
630 return; 630 return;
631 631
632 if (snd_hda_jack_detect(codec, pins[spec->ext_mic_idx])) 632 if (snd_hda_jack_detect(codec, pins[spec->ext_mic_idx]))
633 alc_mux_select(codec, 0, spec->ext_mic_idx, false); 633 alc_mux_select(codec, 0, spec->ext_mic_idx, false);
634 else if (spec->dock_mic_idx >= 0 && 634 else if (spec->dock_mic_idx >= 0 &&
635 snd_hda_jack_detect(codec, pins[spec->dock_mic_idx])) 635 snd_hda_jack_detect(codec, pins[spec->dock_mic_idx]))
636 alc_mux_select(codec, 0, spec->dock_mic_idx, false); 636 alc_mux_select(codec, 0, spec->dock_mic_idx, false);
637 else 637 else
638 alc_mux_select(codec, 0, spec->int_mic_idx, false); 638 alc_mux_select(codec, 0, spec->int_mic_idx, false);
639 } 639 }
640 640
641 /* handle the specified unsol action (ALC_XXX_EVENT) */ 641 /* handle the specified unsol action (ALC_XXX_EVENT) */
642 static void alc_exec_unsol_event(struct hda_codec *codec, int action) 642 static void alc_exec_unsol_event(struct hda_codec *codec, int action)
643 { 643 {
644 switch (action) { 644 switch (action) {
645 case ALC_HP_EVENT: 645 case ALC_HP_EVENT:
646 alc_hp_automute(codec); 646 alc_hp_automute(codec);
647 break; 647 break;
648 case ALC_FRONT_EVENT: 648 case ALC_FRONT_EVENT:
649 alc_line_automute(codec); 649 alc_line_automute(codec);
650 break; 650 break;
651 case ALC_MIC_EVENT: 651 case ALC_MIC_EVENT:
652 alc_mic_automute(codec); 652 alc_mic_automute(codec);
653 break; 653 break;
654 } 654 }
655 snd_hda_jack_report_sync(codec); 655 snd_hda_jack_report_sync(codec);
656 } 656 }
657 657
658 /* update the master volume per volume-knob's unsol event */ 658 /* update the master volume per volume-knob's unsol event */
659 static void alc_update_knob_master(struct hda_codec *codec, hda_nid_t nid) 659 static void alc_update_knob_master(struct hda_codec *codec, hda_nid_t nid)
660 { 660 {
661 unsigned int val; 661 unsigned int val;
662 struct snd_kcontrol *kctl; 662 struct snd_kcontrol *kctl;
663 struct snd_ctl_elem_value *uctl; 663 struct snd_ctl_elem_value *uctl;
664 664
665 kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume"); 665 kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
666 if (!kctl) 666 if (!kctl)
667 return; 667 return;
668 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); 668 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
669 if (!uctl) 669 if (!uctl)
670 return; 670 return;
671 val = snd_hda_codec_read(codec, nid, 0, 671 val = snd_hda_codec_read(codec, nid, 0,
672 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); 672 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
673 val &= HDA_AMP_VOLMASK; 673 val &= HDA_AMP_VOLMASK;
674 uctl->value.integer.value[0] = val; 674 uctl->value.integer.value[0] = val;
675 uctl->value.integer.value[1] = val; 675 uctl->value.integer.value[1] = val;
676 kctl->put(kctl, uctl); 676 kctl->put(kctl, uctl);
677 kfree(uctl); 677 kfree(uctl);
678 } 678 }
679 679
680 /* unsolicited event for HP jack sensing */ 680 /* unsolicited event for HP jack sensing */
681 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) 681 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
682 { 682 {
683 int action; 683 int action;
684 684
685 if (codec->vendor_id == 0x10ec0880) 685 if (codec->vendor_id == 0x10ec0880)
686 res >>= 28; 686 res >>= 28;
687 else 687 else
688 res >>= 26; 688 res >>= 26;
689 action = snd_hda_jack_get_action(codec, res); 689 action = snd_hda_jack_get_action(codec, res);
690 if (action == ALC_DCVOL_EVENT) { 690 if (action == ALC_DCVOL_EVENT) {
691 /* Execute the dc-vol event here as it requires the NID 691 /* Execute the dc-vol event here as it requires the NID
692 * but we don't pass NID to alc_exec_unsol_event(). 692 * but we don't pass NID to alc_exec_unsol_event().
693 * Once when we convert all static quirks to the auto-parser, 693 * Once when we convert all static quirks to the auto-parser,
694 * this can be integerated into there. 694 * this can be integerated into there.
695 */ 695 */
696 struct hda_jack_tbl *jack; 696 struct hda_jack_tbl *jack;
697 jack = snd_hda_jack_tbl_get_from_tag(codec, res); 697 jack = snd_hda_jack_tbl_get_from_tag(codec, res);
698 if (jack) 698 if (jack)
699 alc_update_knob_master(codec, jack->nid); 699 alc_update_knob_master(codec, jack->nid);
700 return; 700 return;
701 } 701 }
702 alc_exec_unsol_event(codec, action); 702 alc_exec_unsol_event(codec, action);
703 } 703 }
704 704
705 /* call init functions of standard auto-mute helpers */ 705 /* call init functions of standard auto-mute helpers */
706 static void alc_inithook(struct hda_codec *codec) 706 static void alc_inithook(struct hda_codec *codec)
707 { 707 {
708 alc_hp_automute(codec); 708 alc_hp_automute(codec);
709 alc_line_automute(codec); 709 alc_line_automute(codec);
710 alc_mic_automute(codec); 710 alc_mic_automute(codec);
711 } 711 }
712 712
713 /* additional initialization for ALC888 variants */ 713 /* additional initialization for ALC888 variants */
714 static void alc888_coef_init(struct hda_codec *codec) 714 static void alc888_coef_init(struct hda_codec *codec)
715 { 715 {
716 unsigned int tmp; 716 unsigned int tmp;
717 717
718 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); 718 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
719 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); 719 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
720 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); 720 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
721 if ((tmp & 0xf0) == 0x20) 721 if ((tmp & 0xf0) == 0x20)
722 /* alc888S-VC */ 722 /* alc888S-VC */
723 snd_hda_codec_read(codec, 0x20, 0, 723 snd_hda_codec_read(codec, 0x20, 0,
724 AC_VERB_SET_PROC_COEF, 0x830); 724 AC_VERB_SET_PROC_COEF, 0x830);
725 else 725 else
726 /* alc888-VB */ 726 /* alc888-VB */
727 snd_hda_codec_read(codec, 0x20, 0, 727 snd_hda_codec_read(codec, 0x20, 0,
728 AC_VERB_SET_PROC_COEF, 0x3030); 728 AC_VERB_SET_PROC_COEF, 0x3030);
729 } 729 }
730 730
731 /* additional initialization for ALC889 variants */ 731 /* additional initialization for ALC889 variants */
732 static void alc889_coef_init(struct hda_codec *codec) 732 static void alc889_coef_init(struct hda_codec *codec)
733 { 733 {
734 unsigned int tmp; 734 unsigned int tmp;
735 735
736 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); 736 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
737 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); 737 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
738 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); 738 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
739 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); 739 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
740 } 740 }
741 741
742 /* turn on/off EAPD control (only if available) */ 742 /* turn on/off EAPD control (only if available) */
743 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) 743 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
744 { 744 {
745 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) 745 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
746 return; 746 return;
747 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) 747 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
748 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, 748 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
749 on ? 2 : 0); 749 on ? 2 : 0);
750 } 750 }
751 751
752 /* turn on/off EAPD controls of the codec */ 752 /* turn on/off EAPD controls of the codec */
753 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on) 753 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
754 { 754 {
755 /* We currently only handle front, HP */ 755 /* We currently only handle front, HP */
756 static hda_nid_t pins[] = { 756 static hda_nid_t pins[] = {
757 0x0f, 0x10, 0x14, 0x15, 0 757 0x0f, 0x10, 0x14, 0x15, 0
758 }; 758 };
759 hda_nid_t *p; 759 hda_nid_t *p;
760 for (p = pins; *p; p++) 760 for (p = pins; *p; p++)
761 set_eapd(codec, *p, on); 761 set_eapd(codec, *p, on);
762 } 762 }
763 763
764 /* generic shutup callback; 764 /* generic shutup callback;
765 * just turning off EPAD and a little pause for avoiding pop-noise 765 * just turning off EPAD and a little pause for avoiding pop-noise
766 */ 766 */
767 static void alc_eapd_shutup(struct hda_codec *codec) 767 static void alc_eapd_shutup(struct hda_codec *codec)
768 { 768 {
769 alc_auto_setup_eapd(codec, false); 769 alc_auto_setup_eapd(codec, false);
770 msleep(200); 770 msleep(200);
771 } 771 }
772 772
773 /* generic EAPD initialization */ 773 /* generic EAPD initialization */
774 static void alc_auto_init_amp(struct hda_codec *codec, int type) 774 static void alc_auto_init_amp(struct hda_codec *codec, int type)
775 { 775 {
776 unsigned int tmp; 776 unsigned int tmp;
777 777
778 alc_auto_setup_eapd(codec, true); 778 alc_auto_setup_eapd(codec, true);
779 switch (type) { 779 switch (type) {
780 case ALC_INIT_GPIO1: 780 case ALC_INIT_GPIO1:
781 snd_hda_sequence_write(codec, alc_gpio1_init_verbs); 781 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
782 break; 782 break;
783 case ALC_INIT_GPIO2: 783 case ALC_INIT_GPIO2:
784 snd_hda_sequence_write(codec, alc_gpio2_init_verbs); 784 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
785 break; 785 break;
786 case ALC_INIT_GPIO3: 786 case ALC_INIT_GPIO3:
787 snd_hda_sequence_write(codec, alc_gpio3_init_verbs); 787 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
788 break; 788 break;
789 case ALC_INIT_DEFAULT: 789 case ALC_INIT_DEFAULT:
790 switch (codec->vendor_id) { 790 switch (codec->vendor_id) {
791 case 0x10ec0260: 791 case 0x10ec0260:
792 snd_hda_codec_write(codec, 0x1a, 0, 792 snd_hda_codec_write(codec, 0x1a, 0,
793 AC_VERB_SET_COEF_INDEX, 7); 793 AC_VERB_SET_COEF_INDEX, 7);
794 tmp = snd_hda_codec_read(codec, 0x1a, 0, 794 tmp = snd_hda_codec_read(codec, 0x1a, 0,
795 AC_VERB_GET_PROC_COEF, 0); 795 AC_VERB_GET_PROC_COEF, 0);
796 snd_hda_codec_write(codec, 0x1a, 0, 796 snd_hda_codec_write(codec, 0x1a, 0,
797 AC_VERB_SET_COEF_INDEX, 7); 797 AC_VERB_SET_COEF_INDEX, 7);
798 snd_hda_codec_write(codec, 0x1a, 0, 798 snd_hda_codec_write(codec, 0x1a, 0,
799 AC_VERB_SET_PROC_COEF, 799 AC_VERB_SET_PROC_COEF,
800 tmp | 0x2010); 800 tmp | 0x2010);
801 break; 801 break;
802 case 0x10ec0262: 802 case 0x10ec0262:
803 case 0x10ec0880: 803 case 0x10ec0880:
804 case 0x10ec0882: 804 case 0x10ec0882:
805 case 0x10ec0883: 805 case 0x10ec0883:
806 case 0x10ec0885: 806 case 0x10ec0885:
807 case 0x10ec0887: 807 case 0x10ec0887:
808 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */ 808 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
809 alc889_coef_init(codec); 809 alc889_coef_init(codec);
810 break; 810 break;
811 case 0x10ec0888: 811 case 0x10ec0888:
812 alc888_coef_init(codec); 812 alc888_coef_init(codec);
813 break; 813 break;
814 #if 0 /* XXX: This may cause the silent output on speaker on some machines */ 814 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
815 case 0x10ec0267: 815 case 0x10ec0267:
816 case 0x10ec0268: 816 case 0x10ec0268:
817 snd_hda_codec_write(codec, 0x20, 0, 817 snd_hda_codec_write(codec, 0x20, 0,
818 AC_VERB_SET_COEF_INDEX, 7); 818 AC_VERB_SET_COEF_INDEX, 7);
819 tmp = snd_hda_codec_read(codec, 0x20, 0, 819 tmp = snd_hda_codec_read(codec, 0x20, 0,
820 AC_VERB_GET_PROC_COEF, 0); 820 AC_VERB_GET_PROC_COEF, 0);
821 snd_hda_codec_write(codec, 0x20, 0, 821 snd_hda_codec_write(codec, 0x20, 0,
822 AC_VERB_SET_COEF_INDEX, 7); 822 AC_VERB_SET_COEF_INDEX, 7);
823 snd_hda_codec_write(codec, 0x20, 0, 823 snd_hda_codec_write(codec, 0x20, 0,
824 AC_VERB_SET_PROC_COEF, 824 AC_VERB_SET_PROC_COEF,
825 tmp | 0x3000); 825 tmp | 0x3000);
826 break; 826 break;
827 #endif /* XXX */ 827 #endif /* XXX */
828 } 828 }
829 break; 829 break;
830 } 830 }
831 } 831 }
832 832
833 /* 833 /*
834 * Auto-Mute mode mixer enum support 834 * Auto-Mute mode mixer enum support
835 */ 835 */
836 static int alc_automute_mode_info(struct snd_kcontrol *kcontrol, 836 static int alc_automute_mode_info(struct snd_kcontrol *kcontrol,
837 struct snd_ctl_elem_info *uinfo) 837 struct snd_ctl_elem_info *uinfo)
838 { 838 {
839 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 839 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
840 struct alc_spec *spec = codec->spec; 840 struct alc_spec *spec = codec->spec;
841 static const char * const texts2[] = { 841 static const char * const texts2[] = {
842 "Disabled", "Enabled" 842 "Disabled", "Enabled"
843 }; 843 };
844 static const char * const texts3[] = { 844 static const char * const texts3[] = {
845 "Disabled", "Speaker Only", "Line Out+Speaker" 845 "Disabled", "Speaker Only", "Line Out+Speaker"
846 }; 846 };
847 const char * const *texts; 847 const char * const *texts;
848 848
849 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 849 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
850 uinfo->count = 1; 850 uinfo->count = 1;
851 if (spec->automute_speaker_possible && spec->automute_lo_possible) { 851 if (spec->automute_speaker_possible && spec->automute_lo_possible) {
852 uinfo->value.enumerated.items = 3; 852 uinfo->value.enumerated.items = 3;
853 texts = texts3; 853 texts = texts3;
854 } else { 854 } else {
855 uinfo->value.enumerated.items = 2; 855 uinfo->value.enumerated.items = 2;
856 texts = texts2; 856 texts = texts2;
857 } 857 }
858 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 858 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
859 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 859 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
860 strcpy(uinfo->value.enumerated.name, 860 strcpy(uinfo->value.enumerated.name,
861 texts[uinfo->value.enumerated.item]); 861 texts[uinfo->value.enumerated.item]);
862 return 0; 862 return 0;
863 } 863 }
864 864
865 static int alc_automute_mode_get(struct snd_kcontrol *kcontrol, 865 static int alc_automute_mode_get(struct snd_kcontrol *kcontrol,
866 struct snd_ctl_elem_value *ucontrol) 866 struct snd_ctl_elem_value *ucontrol)
867 { 867 {
868 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 868 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
869 struct alc_spec *spec = codec->spec; 869 struct alc_spec *spec = codec->spec;
870 unsigned int val = 0; 870 unsigned int val = 0;
871 if (spec->automute_speaker) 871 if (spec->automute_speaker)
872 val++; 872 val++;
873 if (spec->automute_lo) 873 if (spec->automute_lo)
874 val++; 874 val++;
875 875
876 ucontrol->value.enumerated.item[0] = val; 876 ucontrol->value.enumerated.item[0] = val;
877 return 0; 877 return 0;
878 } 878 }
879 879
880 static int alc_automute_mode_put(struct snd_kcontrol *kcontrol, 880 static int alc_automute_mode_put(struct snd_kcontrol *kcontrol,
881 struct snd_ctl_elem_value *ucontrol) 881 struct snd_ctl_elem_value *ucontrol)
882 { 882 {
883 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 883 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
884 struct alc_spec *spec = codec->spec; 884 struct alc_spec *spec = codec->spec;
885 885
886 switch (ucontrol->value.enumerated.item[0]) { 886 switch (ucontrol->value.enumerated.item[0]) {
887 case 0: 887 case 0:
888 if (!spec->automute_speaker && !spec->automute_lo) 888 if (!spec->automute_speaker && !spec->automute_lo)
889 return 0; 889 return 0;
890 spec->automute_speaker = 0; 890 spec->automute_speaker = 0;
891 spec->automute_lo = 0; 891 spec->automute_lo = 0;
892 break; 892 break;
893 case 1: 893 case 1:
894 if (spec->automute_speaker_possible) { 894 if (spec->automute_speaker_possible) {
895 if (!spec->automute_lo && spec->automute_speaker) 895 if (!spec->automute_lo && spec->automute_speaker)
896 return 0; 896 return 0;
897 spec->automute_speaker = 1; 897 spec->automute_speaker = 1;
898 spec->automute_lo = 0; 898 spec->automute_lo = 0;
899 } else if (spec->automute_lo_possible) { 899 } else if (spec->automute_lo_possible) {
900 if (spec->automute_lo) 900 if (spec->automute_lo)
901 return 0; 901 return 0;
902 spec->automute_lo = 1; 902 spec->automute_lo = 1;
903 } else 903 } else
904 return -EINVAL; 904 return -EINVAL;
905 break; 905 break;
906 case 2: 906 case 2:
907 if (!spec->automute_lo_possible || !spec->automute_speaker_possible) 907 if (!spec->automute_lo_possible || !spec->automute_speaker_possible)
908 return -EINVAL; 908 return -EINVAL;
909 if (spec->automute_speaker && spec->automute_lo) 909 if (spec->automute_speaker && spec->automute_lo)
910 return 0; 910 return 0;
911 spec->automute_speaker = 1; 911 spec->automute_speaker = 1;
912 spec->automute_lo = 1; 912 spec->automute_lo = 1;
913 break; 913 break;
914 default: 914 default:
915 return -EINVAL; 915 return -EINVAL;
916 } 916 }
917 call_update_outputs(codec); 917 call_update_outputs(codec);
918 return 1; 918 return 1;
919 } 919 }
920 920
921 static const struct snd_kcontrol_new alc_automute_mode_enum = { 921 static const struct snd_kcontrol_new alc_automute_mode_enum = {
922 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 922 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
923 .name = "Auto-Mute Mode", 923 .name = "Auto-Mute Mode",
924 .info = alc_automute_mode_info, 924 .info = alc_automute_mode_info,
925 .get = alc_automute_mode_get, 925 .get = alc_automute_mode_get,
926 .put = alc_automute_mode_put, 926 .put = alc_automute_mode_put,
927 }; 927 };
928 928
929 static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec) 929 static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec)
930 { 930 {
931 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); 931 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
932 return snd_array_new(&spec->kctls); 932 return snd_array_new(&spec->kctls);
933 } 933 }
934 934
935 static int alc_add_automute_mode_enum(struct hda_codec *codec) 935 static int alc_add_automute_mode_enum(struct hda_codec *codec)
936 { 936 {
937 struct alc_spec *spec = codec->spec; 937 struct alc_spec *spec = codec->spec;
938 struct snd_kcontrol_new *knew; 938 struct snd_kcontrol_new *knew;
939 939
940 knew = alc_kcontrol_new(spec); 940 knew = alc_kcontrol_new(spec);
941 if (!knew) 941 if (!knew)
942 return -ENOMEM; 942 return -ENOMEM;
943 *knew = alc_automute_mode_enum; 943 *knew = alc_automute_mode_enum;
944 knew->name = kstrdup("Auto-Mute Mode", GFP_KERNEL); 944 knew->name = kstrdup("Auto-Mute Mode", GFP_KERNEL);
945 if (!knew->name) 945 if (!knew->name)
946 return -ENOMEM; 946 return -ENOMEM;
947 return 0; 947 return 0;
948 } 948 }
949 949
950 /* 950 /*
951 * Check the availability of HP/line-out auto-mute; 951 * Check the availability of HP/line-out auto-mute;
952 * Set up appropriately if really supported 952 * Set up appropriately if really supported
953 */ 953 */
954 static void alc_init_automute(struct hda_codec *codec) 954 static void alc_init_automute(struct hda_codec *codec)
955 { 955 {
956 struct alc_spec *spec = codec->spec; 956 struct alc_spec *spec = codec->spec;
957 struct auto_pin_cfg *cfg = &spec->autocfg; 957 struct auto_pin_cfg *cfg = &spec->autocfg;
958 int present = 0; 958 int present = 0;
959 int i; 959 int i;
960 960
961 if (cfg->hp_pins[0]) 961 if (cfg->hp_pins[0])
962 present++; 962 present++;
963 if (cfg->line_out_pins[0]) 963 if (cfg->line_out_pins[0])
964 present++; 964 present++;
965 if (cfg->speaker_pins[0]) 965 if (cfg->speaker_pins[0])
966 present++; 966 present++;
967 if (present < 2) /* need two different output types */ 967 if (present < 2) /* need two different output types */
968 return; 968 return;
969 969
970 if (!cfg->speaker_pins[0] && 970 if (!cfg->speaker_pins[0] &&
971 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { 971 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
972 memcpy(cfg->speaker_pins, cfg->line_out_pins, 972 memcpy(cfg->speaker_pins, cfg->line_out_pins,
973 sizeof(cfg->speaker_pins)); 973 sizeof(cfg->speaker_pins));
974 cfg->speaker_outs = cfg->line_outs; 974 cfg->speaker_outs = cfg->line_outs;
975 } 975 }
976 976
977 if (!cfg->hp_pins[0] && 977 if (!cfg->hp_pins[0] &&
978 cfg->line_out_type == AUTO_PIN_HP_OUT) { 978 cfg->line_out_type == AUTO_PIN_HP_OUT) {
979 memcpy(cfg->hp_pins, cfg->line_out_pins, 979 memcpy(cfg->hp_pins, cfg->line_out_pins,
980 sizeof(cfg->hp_pins)); 980 sizeof(cfg->hp_pins));
981 cfg->hp_outs = cfg->line_outs; 981 cfg->hp_outs = cfg->line_outs;
982 } 982 }
983 983
984 spec->automute_mode = ALC_AUTOMUTE_PIN; 984 spec->automute_mode = ALC_AUTOMUTE_PIN;
985 985
986 for (i = 0; i < cfg->hp_outs; i++) { 986 for (i = 0; i < cfg->hp_outs; i++) {
987 hda_nid_t nid = cfg->hp_pins[i]; 987 hda_nid_t nid = cfg->hp_pins[i];
988 if (!is_jack_detectable(codec, nid)) 988 if (!is_jack_detectable(codec, nid))
989 continue; 989 continue;
990 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", 990 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
991 nid); 991 nid);
992 snd_hda_jack_detect_enable(codec, nid, ALC_HP_EVENT); 992 snd_hda_jack_detect_enable(codec, nid, ALC_HP_EVENT);
993 spec->detect_hp = 1; 993 spec->detect_hp = 1;
994 } 994 }
995 995
996 if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) { 996 if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) {
997 if (cfg->speaker_outs) 997 if (cfg->speaker_outs)
998 for (i = 0; i < cfg->line_outs; i++) { 998 for (i = 0; i < cfg->line_outs; i++) {
999 hda_nid_t nid = cfg->line_out_pins[i]; 999 hda_nid_t nid = cfg->line_out_pins[i];
1000 if (!is_jack_detectable(codec, nid)) 1000 if (!is_jack_detectable(codec, nid))
1001 continue; 1001 continue;
1002 snd_printdd("realtek: Enable Line-Out " 1002 snd_printdd("realtek: Enable Line-Out "
1003 "auto-muting on NID 0x%x\n", nid); 1003 "auto-muting on NID 0x%x\n", nid);
1004 snd_hda_jack_detect_enable(codec, nid, 1004 snd_hda_jack_detect_enable(codec, nid,
1005 ALC_FRONT_EVENT); 1005 ALC_FRONT_EVENT);
1006 spec->detect_lo = 1; 1006 spec->detect_lo = 1;
1007 } 1007 }
1008 spec->automute_lo_possible = spec->detect_hp; 1008 spec->automute_lo_possible = spec->detect_hp;
1009 } 1009 }
1010 1010
1011 spec->automute_speaker_possible = cfg->speaker_outs && 1011 spec->automute_speaker_possible = cfg->speaker_outs &&
1012 (spec->detect_hp || spec->detect_lo); 1012 (spec->detect_hp || spec->detect_lo);
1013 1013
1014 spec->automute_lo = spec->automute_lo_possible; 1014 spec->automute_lo = spec->automute_lo_possible;
1015 spec->automute_speaker = spec->automute_speaker_possible; 1015 spec->automute_speaker = spec->automute_speaker_possible;
1016 1016
1017 if (spec->automute_speaker_possible || spec->automute_lo_possible) { 1017 if (spec->automute_speaker_possible || spec->automute_lo_possible) {
1018 /* create a control for automute mode */ 1018 /* create a control for automute mode */
1019 alc_add_automute_mode_enum(codec); 1019 alc_add_automute_mode_enum(codec);
1020 spec->unsol_event = alc_sku_unsol_event; 1020 spec->unsol_event = alc_sku_unsol_event;
1021 } 1021 }
1022 } 1022 }
1023 1023
1024 /* return the position of NID in the list, or -1 if not found */ 1024 /* return the position of NID in the list, or -1 if not found */
1025 static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) 1025 static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
1026 { 1026 {
1027 int i; 1027 int i;
1028 for (i = 0; i < nums; i++) 1028 for (i = 0; i < nums; i++)
1029 if (list[i] == nid) 1029 if (list[i] == nid)
1030 return i; 1030 return i;
1031 return -1; 1031 return -1;
1032 } 1032 }
1033 1033
1034 /* check whether dynamic ADC-switching is available */ 1034 /* check whether dynamic ADC-switching is available */
1035 static bool alc_check_dyn_adc_switch(struct hda_codec *codec) 1035 static bool alc_check_dyn_adc_switch(struct hda_codec *codec)
1036 { 1036 {
1037 struct alc_spec *spec = codec->spec; 1037 struct alc_spec *spec = codec->spec;
1038 struct hda_input_mux *imux = &spec->private_imux[0]; 1038 struct hda_input_mux *imux = &spec->private_imux[0];
1039 int i, n, idx; 1039 int i, n, idx;
1040 hda_nid_t cap, pin; 1040 hda_nid_t cap, pin;
1041 1041
1042 if (imux != spec->input_mux) /* no dynamic imux? */ 1042 if (imux != spec->input_mux) /* no dynamic imux? */
1043 return false; 1043 return false;
1044 1044
1045 for (n = 0; n < spec->num_adc_nids; n++) { 1045 for (n = 0; n < spec->num_adc_nids; n++) {
1046 cap = spec->private_capsrc_nids[n]; 1046 cap = spec->private_capsrc_nids[n];
1047 for (i = 0; i < imux->num_items; i++) { 1047 for (i = 0; i < imux->num_items; i++) {
1048 pin = spec->imux_pins[i]; 1048 pin = spec->imux_pins[i];
1049 if (!pin) 1049 if (!pin)
1050 return false; 1050 return false;
1051 if (get_connection_index(codec, cap, pin) < 0) 1051 if (get_connection_index(codec, cap, pin) < 0)
1052 break; 1052 break;
1053 } 1053 }
1054 if (i >= imux->num_items) 1054 if (i >= imux->num_items)
1055 return true; /* no ADC-switch is needed */ 1055 return true; /* no ADC-switch is needed */
1056 } 1056 }
1057 1057
1058 for (i = 0; i < imux->num_items; i++) { 1058 for (i = 0; i < imux->num_items; i++) {
1059 pin = spec->imux_pins[i]; 1059 pin = spec->imux_pins[i];
1060 for (n = 0; n < spec->num_adc_nids; n++) { 1060 for (n = 0; n < spec->num_adc_nids; n++) {
1061 cap = spec->private_capsrc_nids[n]; 1061 cap = spec->private_capsrc_nids[n];
1062 idx = get_connection_index(codec, cap, pin); 1062 idx = get_connection_index(codec, cap, pin);
1063 if (idx >= 0) { 1063 if (idx >= 0) {
1064 imux->items[i].index = idx; 1064 imux->items[i].index = idx;
1065 spec->dyn_adc_idx[i] = n; 1065 spec->dyn_adc_idx[i] = n;
1066 break; 1066 break;
1067 } 1067 }
1068 } 1068 }
1069 } 1069 }
1070 1070
1071 snd_printdd("realtek: enabling ADC switching\n"); 1071 snd_printdd("realtek: enabling ADC switching\n");
1072 spec->dyn_adc_switch = 1; 1072 spec->dyn_adc_switch = 1;
1073 return true; 1073 return true;
1074 } 1074 }
1075 1075
1076 /* check whether all auto-mic pins are valid; setup indices if OK */ 1076 /* check whether all auto-mic pins are valid; setup indices if OK */
1077 static bool alc_auto_mic_check_imux(struct hda_codec *codec) 1077 static bool alc_auto_mic_check_imux(struct hda_codec *codec)
1078 { 1078 {
1079 struct alc_spec *spec = codec->spec; 1079 struct alc_spec *spec = codec->spec;
1080 const struct hda_input_mux *imux; 1080 const struct hda_input_mux *imux;
1081 1081
1082 if (!spec->auto_mic) 1082 if (!spec->auto_mic)
1083 return false; 1083 return false;
1084 if (spec->auto_mic_valid_imux) 1084 if (spec->auto_mic_valid_imux)
1085 return true; /* already checked */ 1085 return true; /* already checked */
1086 1086
1087 /* fill up imux indices */ 1087 /* fill up imux indices */
1088 if (!alc_check_dyn_adc_switch(codec)) { 1088 if (!alc_check_dyn_adc_switch(codec)) {
1089 spec->auto_mic = 0; 1089 spec->auto_mic = 0;
1090 return false; 1090 return false;
1091 } 1091 }
1092 1092
1093 imux = spec->input_mux; 1093 imux = spec->input_mux;
1094 spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin, 1094 spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin,
1095 spec->imux_pins, imux->num_items); 1095 spec->imux_pins, imux->num_items);
1096 spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin, 1096 spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin,
1097 spec->imux_pins, imux->num_items); 1097 spec->imux_pins, imux->num_items);
1098 spec->dock_mic_idx = find_idx_in_nid_list(spec->dock_mic_pin, 1098 spec->dock_mic_idx = find_idx_in_nid_list(spec->dock_mic_pin,
1099 spec->imux_pins, imux->num_items); 1099 spec->imux_pins, imux->num_items);
1100 if (spec->ext_mic_idx < 0 || spec->int_mic_idx < 0) { 1100 if (spec->ext_mic_idx < 0 || spec->int_mic_idx < 0) {
1101 spec->auto_mic = 0; 1101 spec->auto_mic = 0;
1102 return false; /* no corresponding imux */ 1102 return false; /* no corresponding imux */
1103 } 1103 }
1104 1104
1105 snd_hda_jack_detect_enable(codec, spec->ext_mic_pin, ALC_MIC_EVENT); 1105 snd_hda_jack_detect_enable(codec, spec->ext_mic_pin, ALC_MIC_EVENT);
1106 if (spec->dock_mic_pin) 1106 if (spec->dock_mic_pin)
1107 snd_hda_jack_detect_enable(codec, spec->dock_mic_pin, 1107 snd_hda_jack_detect_enable(codec, spec->dock_mic_pin,
1108 ALC_MIC_EVENT); 1108 ALC_MIC_EVENT);
1109 1109
1110 spec->auto_mic_valid_imux = 1; 1110 spec->auto_mic_valid_imux = 1;
1111 spec->auto_mic = 1; 1111 spec->auto_mic = 1;
1112 return true; 1112 return true;
1113 } 1113 }
1114 1114
1115 /* 1115 /*
1116 * Check the availability of auto-mic switch; 1116 * Check the availability of auto-mic switch;
1117 * Set up if really supported 1117 * Set up if really supported
1118 */ 1118 */
1119 static void alc_init_auto_mic(struct hda_codec *codec) 1119 static void alc_init_auto_mic(struct hda_codec *codec)
1120 { 1120 {
1121 struct alc_spec *spec = codec->spec; 1121 struct alc_spec *spec = codec->spec;
1122 struct auto_pin_cfg *cfg = &spec->autocfg; 1122 struct auto_pin_cfg *cfg = &spec->autocfg;
1123 hda_nid_t fixed, ext, dock; 1123 hda_nid_t fixed, ext, dock;
1124 int i; 1124 int i;
1125 1125
1126 if (spec->shared_mic_hp) 1126 if (spec->shared_mic_hp)
1127 return; /* no auto-mic for the shared I/O */ 1127 return; /* no auto-mic for the shared I/O */
1128 1128
1129 spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; 1129 spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1;
1130 1130
1131 fixed = ext = dock = 0; 1131 fixed = ext = dock = 0;
1132 for (i = 0; i < cfg->num_inputs; i++) { 1132 for (i = 0; i < cfg->num_inputs; i++) {
1133 hda_nid_t nid = cfg->inputs[i].pin; 1133 hda_nid_t nid = cfg->inputs[i].pin;
1134 unsigned int defcfg; 1134 unsigned int defcfg;
1135 defcfg = snd_hda_codec_get_pincfg(codec, nid); 1135 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1136 switch (snd_hda_get_input_pin_attr(defcfg)) { 1136 switch (snd_hda_get_input_pin_attr(defcfg)) {
1137 case INPUT_PIN_ATTR_INT: 1137 case INPUT_PIN_ATTR_INT:
1138 if (fixed) 1138 if (fixed)
1139 return; /* already occupied */ 1139 return; /* already occupied */
1140 if (cfg->inputs[i].type != AUTO_PIN_MIC) 1140 if (cfg->inputs[i].type != AUTO_PIN_MIC)
1141 return; /* invalid type */ 1141 return; /* invalid type */
1142 fixed = nid; 1142 fixed = nid;
1143 break; 1143 break;
1144 case INPUT_PIN_ATTR_UNUSED: 1144 case INPUT_PIN_ATTR_UNUSED:
1145 return; /* invalid entry */ 1145 return; /* invalid entry */
1146 case INPUT_PIN_ATTR_DOCK: 1146 case INPUT_PIN_ATTR_DOCK:
1147 if (dock) 1147 if (dock)
1148 return; /* already occupied */ 1148 return; /* already occupied */
1149 if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) 1149 if (cfg->inputs[i].type > AUTO_PIN_LINE_IN)
1150 return; /* invalid type */ 1150 return; /* invalid type */
1151 dock = nid; 1151 dock = nid;
1152 break; 1152 break;
1153 default: 1153 default:
1154 if (ext) 1154 if (ext)
1155 return; /* already occupied */ 1155 return; /* already occupied */
1156 if (cfg->inputs[i].type != AUTO_PIN_MIC) 1156 if (cfg->inputs[i].type != AUTO_PIN_MIC)
1157 return; /* invalid type */ 1157 return; /* invalid type */
1158 ext = nid; 1158 ext = nid;
1159 break; 1159 break;
1160 } 1160 }
1161 } 1161 }
1162 if (!ext && dock) { 1162 if (!ext && dock) {
1163 ext = dock; 1163 ext = dock;
1164 dock = 0; 1164 dock = 0;
1165 } 1165 }
1166 if (!ext || !fixed) 1166 if (!ext || !fixed)
1167 return; 1167 return;
1168 if (!is_jack_detectable(codec, ext)) 1168 if (!is_jack_detectable(codec, ext))
1169 return; /* no unsol support */ 1169 return; /* no unsol support */
1170 if (dock && !is_jack_detectable(codec, dock)) 1170 if (dock && !is_jack_detectable(codec, dock))
1171 return; /* no unsol support */ 1171 return; /* no unsol support */
1172 1172
1173 /* check imux indices */ 1173 /* check imux indices */
1174 spec->ext_mic_pin = ext; 1174 spec->ext_mic_pin = ext;
1175 spec->int_mic_pin = fixed; 1175 spec->int_mic_pin = fixed;
1176 spec->dock_mic_pin = dock; 1176 spec->dock_mic_pin = dock;
1177 1177
1178 spec->auto_mic = 1; 1178 spec->auto_mic = 1;
1179 if (!alc_auto_mic_check_imux(codec)) 1179 if (!alc_auto_mic_check_imux(codec))
1180 return; 1180 return;
1181 1181
1182 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", 1182 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
1183 ext, fixed, dock); 1183 ext, fixed, dock);
1184 spec->unsol_event = alc_sku_unsol_event; 1184 spec->unsol_event = alc_sku_unsol_event;
1185 } 1185 }
1186 1186
1187 /* check the availabilities of auto-mute and auto-mic switches */ 1187 /* check the availabilities of auto-mute and auto-mic switches */
1188 static void alc_auto_check_switches(struct hda_codec *codec) 1188 static void alc_auto_check_switches(struct hda_codec *codec)
1189 { 1189 {
1190 alc_init_automute(codec); 1190 alc_init_automute(codec);
1191 alc_init_auto_mic(codec); 1191 alc_init_auto_mic(codec);
1192 } 1192 }
1193 1193
1194 /* 1194 /*
1195 * Realtek SSID verification 1195 * Realtek SSID verification
1196 */ 1196 */
1197 1197
1198 /* Could be any non-zero and even value. When used as fixup, tells 1198 /* Could be any non-zero and even value. When used as fixup, tells
1199 * the driver to ignore any present sku defines. 1199 * the driver to ignore any present sku defines.
1200 */ 1200 */
1201 #define ALC_FIXUP_SKU_IGNORE (2) 1201 #define ALC_FIXUP_SKU_IGNORE (2)
1202 1202
1203 static int alc_auto_parse_customize_define(struct hda_codec *codec) 1203 static int alc_auto_parse_customize_define(struct hda_codec *codec)
1204 { 1204 {
1205 unsigned int ass, tmp, i; 1205 unsigned int ass, tmp, i;
1206 unsigned nid = 0; 1206 unsigned nid = 0;
1207 struct alc_spec *spec = codec->spec; 1207 struct alc_spec *spec = codec->spec;
1208 1208
1209 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ 1209 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1210 1210
1211 if (spec->cdefine.fixup) { 1211 if (spec->cdefine.fixup) {
1212 ass = spec->cdefine.sku_cfg; 1212 ass = spec->cdefine.sku_cfg;
1213 if (ass == ALC_FIXUP_SKU_IGNORE) 1213 if (ass == ALC_FIXUP_SKU_IGNORE)
1214 return -1; 1214 return -1;
1215 goto do_sku; 1215 goto do_sku;
1216 } 1216 }
1217 1217
1218 ass = codec->subsystem_id & 0xffff; 1218 ass = codec->subsystem_id & 0xffff;
1219 if (ass != codec->bus->pci->subsystem_device && (ass & 1)) 1219 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
1220 goto do_sku; 1220 goto do_sku;
1221 1221
1222 nid = 0x1d; 1222 nid = 0x1d;
1223 if (codec->vendor_id == 0x10ec0260) 1223 if (codec->vendor_id == 0x10ec0260)
1224 nid = 0x17; 1224 nid = 0x17;
1225 ass = snd_hda_codec_get_pincfg(codec, nid); 1225 ass = snd_hda_codec_get_pincfg(codec, nid);
1226 1226
1227 if (!(ass & 1)) { 1227 if (!(ass & 1)) {
1228 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n", 1228 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1229 codec->chip_name, ass); 1229 codec->chip_name, ass);
1230 return -1; 1230 return -1;
1231 } 1231 }
1232 1232
1233 /* check sum */ 1233 /* check sum */
1234 tmp = 0; 1234 tmp = 0;
1235 for (i = 1; i < 16; i++) { 1235 for (i = 1; i < 16; i++) {
1236 if ((ass >> i) & 1) 1236 if ((ass >> i) & 1)
1237 tmp++; 1237 tmp++;
1238 } 1238 }
1239 if (((ass >> 16) & 0xf) != tmp) 1239 if (((ass >> 16) & 0xf) != tmp)
1240 return -1; 1240 return -1;
1241 1241
1242 spec->cdefine.port_connectivity = ass >> 30; 1242 spec->cdefine.port_connectivity = ass >> 30;
1243 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20; 1243 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1244 spec->cdefine.check_sum = (ass >> 16) & 0xf; 1244 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1245 spec->cdefine.customization = ass >> 8; 1245 spec->cdefine.customization = ass >> 8;
1246 do_sku: 1246 do_sku:
1247 spec->cdefine.sku_cfg = ass; 1247 spec->cdefine.sku_cfg = ass;
1248 spec->cdefine.external_amp = (ass & 0x38) >> 3; 1248 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1249 spec->cdefine.platform_type = (ass & 0x4) >> 2; 1249 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1250 spec->cdefine.swap = (ass & 0x2) >> 1; 1250 spec->cdefine.swap = (ass & 0x2) >> 1;
1251 spec->cdefine.override = ass & 0x1; 1251 spec->cdefine.override = ass & 0x1;
1252 1252
1253 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n", 1253 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1254 nid, spec->cdefine.sku_cfg); 1254 nid, spec->cdefine.sku_cfg);
1255 snd_printd("SKU: port_connectivity=0x%x\n", 1255 snd_printd("SKU: port_connectivity=0x%x\n",
1256 spec->cdefine.port_connectivity); 1256 spec->cdefine.port_connectivity);
1257 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep); 1257 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1258 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum); 1258 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1259 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization); 1259 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1260 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp); 1260 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1261 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type); 1261 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1262 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap); 1262 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1263 snd_printd("SKU: override=0x%x\n", spec->cdefine.override); 1263 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1264 1264
1265 return 0; 1265 return 0;
1266 } 1266 }
1267 1267
1268 /* return true if the given NID is found in the list */ 1268 /* return true if the given NID is found in the list */
1269 static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) 1269 static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
1270 { 1270 {
1271 return find_idx_in_nid_list(nid, list, nums) >= 0; 1271 return find_idx_in_nid_list(nid, list, nums) >= 0;
1272 } 1272 }
1273 1273
1274 /* check subsystem ID and set up device-specific initialization; 1274 /* check subsystem ID and set up device-specific initialization;
1275 * return 1 if initialized, 0 if invalid SSID 1275 * return 1 if initialized, 0 if invalid SSID
1276 */ 1276 */
1277 /* 32-bit subsystem ID for BIOS loading in HD Audio codec. 1277 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1278 * 31 ~ 16 : Manufacture ID 1278 * 31 ~ 16 : Manufacture ID
1279 * 15 ~ 8 : SKU ID 1279 * 15 ~ 8 : SKU ID
1280 * 7 ~ 0 : Assembly ID 1280 * 7 ~ 0 : Assembly ID
1281 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 1281 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1282 */ 1282 */
1283 static int alc_subsystem_id(struct hda_codec *codec, 1283 static int alc_subsystem_id(struct hda_codec *codec,
1284 hda_nid_t porta, hda_nid_t porte, 1284 hda_nid_t porta, hda_nid_t porte,
1285 hda_nid_t portd, hda_nid_t porti) 1285 hda_nid_t portd, hda_nid_t porti)
1286 { 1286 {
1287 unsigned int ass, tmp, i; 1287 unsigned int ass, tmp, i;
1288 unsigned nid; 1288 unsigned nid;
1289 struct alc_spec *spec = codec->spec; 1289 struct alc_spec *spec = codec->spec;
1290 1290
1291 if (spec->cdefine.fixup) { 1291 if (spec->cdefine.fixup) {
1292 ass = spec->cdefine.sku_cfg; 1292 ass = spec->cdefine.sku_cfg;
1293 if (ass == ALC_FIXUP_SKU_IGNORE) 1293 if (ass == ALC_FIXUP_SKU_IGNORE)
1294 return 0; 1294 return 0;
1295 goto do_sku; 1295 goto do_sku;
1296 } 1296 }
1297 1297
1298 ass = codec->subsystem_id & 0xffff; 1298 ass = codec->subsystem_id & 0xffff;
1299 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) 1299 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1300 goto do_sku; 1300 goto do_sku;
1301 1301
1302 /* invalid SSID, check the special NID pin defcfg instead */ 1302 /* invalid SSID, check the special NID pin defcfg instead */
1303 /* 1303 /*
1304 * 31~30 : port connectivity 1304 * 31~30 : port connectivity
1305 * 29~21 : reserve 1305 * 29~21 : reserve
1306 * 20 : PCBEEP input 1306 * 20 : PCBEEP input
1307 * 19~16 : Check sum (15:1) 1307 * 19~16 : Check sum (15:1)
1308 * 15~1 : Custom 1308 * 15~1 : Custom
1309 * 0 : override 1309 * 0 : override
1310 */ 1310 */
1311 nid = 0x1d; 1311 nid = 0x1d;
1312 if (codec->vendor_id == 0x10ec0260) 1312 if (codec->vendor_id == 0x10ec0260)
1313 nid = 0x17; 1313 nid = 0x17;
1314 ass = snd_hda_codec_get_pincfg(codec, nid); 1314 ass = snd_hda_codec_get_pincfg(codec, nid);
1315 snd_printd("realtek: No valid SSID, " 1315 snd_printd("realtek: No valid SSID, "
1316 "checking pincfg 0x%08x for NID 0x%x\n", 1316 "checking pincfg 0x%08x for NID 0x%x\n",
1317 ass, nid); 1317 ass, nid);
1318 if (!(ass & 1)) 1318 if (!(ass & 1))
1319 return 0; 1319 return 0;
1320 if ((ass >> 30) != 1) /* no physical connection */ 1320 if ((ass >> 30) != 1) /* no physical connection */
1321 return 0; 1321 return 0;
1322 1322
1323 /* check sum */ 1323 /* check sum */
1324 tmp = 0; 1324 tmp = 0;
1325 for (i = 1; i < 16; i++) { 1325 for (i = 1; i < 16; i++) {
1326 if ((ass >> i) & 1) 1326 if ((ass >> i) & 1)
1327 tmp++; 1327 tmp++;
1328 } 1328 }
1329 if (((ass >> 16) & 0xf) != tmp) 1329 if (((ass >> 16) & 0xf) != tmp)
1330 return 0; 1330 return 0;
1331 do_sku: 1331 do_sku:
1332 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", 1332 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1333 ass & 0xffff, codec->vendor_id); 1333 ass & 0xffff, codec->vendor_id);
1334 /* 1334 /*
1335 * 0 : override 1335 * 0 : override
1336 * 1 : Swap Jack 1336 * 1 : Swap Jack
1337 * 2 : 0 --> Desktop, 1 --> Laptop 1337 * 2 : 0 --> Desktop, 1 --> Laptop
1338 * 3~5 : External Amplifier control 1338 * 3~5 : External Amplifier control
1339 * 7~6 : Reserved 1339 * 7~6 : Reserved
1340 */ 1340 */
1341 tmp = (ass & 0x38) >> 3; /* external Amp control */ 1341 tmp = (ass & 0x38) >> 3; /* external Amp control */
1342 switch (tmp) { 1342 switch (tmp) {
1343 case 1: 1343 case 1:
1344 spec->init_amp = ALC_INIT_GPIO1; 1344 spec->init_amp = ALC_INIT_GPIO1;
1345 break; 1345 break;
1346 case 3: 1346 case 3:
1347 spec->init_amp = ALC_INIT_GPIO2; 1347 spec->init_amp = ALC_INIT_GPIO2;
1348 break; 1348 break;
1349 case 7: 1349 case 7:
1350 spec->init_amp = ALC_INIT_GPIO3; 1350 spec->init_amp = ALC_INIT_GPIO3;
1351 break; 1351 break;
1352 case 5: 1352 case 5:
1353 default: 1353 default:
1354 spec->init_amp = ALC_INIT_DEFAULT; 1354 spec->init_amp = ALC_INIT_DEFAULT;
1355 break; 1355 break;
1356 } 1356 }
1357 1357
1358 /* is laptop or Desktop and enable the function "Mute internal speaker 1358 /* is laptop or Desktop and enable the function "Mute internal speaker
1359 * when the external headphone out jack is plugged" 1359 * when the external headphone out jack is plugged"
1360 */ 1360 */
1361 if (!(ass & 0x8000)) 1361 if (!(ass & 0x8000))
1362 return 1; 1362 return 1;
1363 /* 1363 /*
1364 * 10~8 : Jack location 1364 * 10~8 : Jack location
1365 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered 1365 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1366 * 14~13: Resvered 1366 * 14~13: Resvered
1367 * 15 : 1 --> enable the function "Mute internal speaker 1367 * 15 : 1 --> enable the function "Mute internal speaker
1368 * when the external headphone out jack is plugged" 1368 * when the external headphone out jack is plugged"
1369 */ 1369 */
1370 if (!spec->autocfg.hp_pins[0] && 1370 if (!spec->autocfg.hp_pins[0] &&
1371 !(spec->autocfg.line_out_pins[0] && 1371 !(spec->autocfg.line_out_pins[0] &&
1372 spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) { 1372 spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
1373 hda_nid_t nid; 1373 hda_nid_t nid;
1374 tmp = (ass >> 11) & 0x3; /* HP to chassis */ 1374 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1375 if (tmp == 0) 1375 if (tmp == 0)
1376 nid = porta; 1376 nid = porta;
1377 else if (tmp == 1) 1377 else if (tmp == 1)
1378 nid = porte; 1378 nid = porte;
1379 else if (tmp == 2) 1379 else if (tmp == 2)
1380 nid = portd; 1380 nid = portd;
1381 else if (tmp == 3) 1381 else if (tmp == 3)
1382 nid = porti; 1382 nid = porti;
1383 else 1383 else
1384 return 1; 1384 return 1;
1385 if (found_in_nid_list(nid, spec->autocfg.line_out_pins, 1385 if (found_in_nid_list(nid, spec->autocfg.line_out_pins,
1386 spec->autocfg.line_outs)) 1386 spec->autocfg.line_outs))
1387 return 1; 1387 return 1;
1388 spec->autocfg.hp_pins[0] = nid; 1388 spec->autocfg.hp_pins[0] = nid;
1389 } 1389 }
1390 return 1; 1390 return 1;
1391 } 1391 }
1392 1392
1393 /* Check the validity of ALC subsystem-id 1393 /* Check the validity of ALC subsystem-id
1394 * ports contains an array of 4 pin NIDs for port-A, E, D and I */ 1394 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
1395 static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports) 1395 static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
1396 { 1396 {
1397 if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) { 1397 if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) {
1398 struct alc_spec *spec = codec->spec; 1398 struct alc_spec *spec = codec->spec;
1399 snd_printd("realtek: " 1399 snd_printd("realtek: "
1400 "Enable default setup for auto mode as fallback\n"); 1400 "Enable default setup for auto mode as fallback\n");
1401 spec->init_amp = ALC_INIT_DEFAULT; 1401 spec->init_amp = ALC_INIT_DEFAULT;
1402 } 1402 }
1403 } 1403 }
1404 1404
1405 /* 1405 /*
1406 * Fix-up pin default configurations and add default verbs 1406 * Fix-up pin default configurations and add default verbs
1407 */ 1407 */
1408 1408
1409 struct alc_pincfg { 1409 struct alc_pincfg {
1410 hda_nid_t nid; 1410 hda_nid_t nid;
1411 u32 val; 1411 u32 val;
1412 }; 1412 };
1413 1413
1414 struct alc_model_fixup { 1414 struct alc_model_fixup {
1415 const int id; 1415 const int id;
1416 const char *name; 1416 const char *name;
1417 }; 1417 };
1418 1418
1419 struct alc_fixup { 1419 struct alc_fixup {
1420 int type; 1420 int type;
1421 bool chained; 1421 bool chained;
1422 int chain_id; 1422 int chain_id;
1423 union { 1423 union {
1424 unsigned int sku; 1424 unsigned int sku;
1425 const struct alc_pincfg *pins; 1425 const struct alc_pincfg *pins;
1426 const struct hda_verb *verbs; 1426 const struct hda_verb *verbs;
1427 void (*func)(struct hda_codec *codec, 1427 void (*func)(struct hda_codec *codec,
1428 const struct alc_fixup *fix, 1428 const struct alc_fixup *fix,
1429 int action); 1429 int action);
1430 } v; 1430 } v;
1431 }; 1431 };
1432 1432
1433 enum { 1433 enum {
1434 ALC_FIXUP_INVALID, 1434 ALC_FIXUP_INVALID,
1435 ALC_FIXUP_SKU, 1435 ALC_FIXUP_SKU,
1436 ALC_FIXUP_PINS, 1436 ALC_FIXUP_PINS,
1437 ALC_FIXUP_VERBS, 1437 ALC_FIXUP_VERBS,
1438 ALC_FIXUP_FUNC, 1438 ALC_FIXUP_FUNC,
1439 }; 1439 };
1440 1440
1441 enum { 1441 enum {
1442 ALC_FIXUP_ACT_PRE_PROBE, 1442 ALC_FIXUP_ACT_PRE_PROBE,
1443 ALC_FIXUP_ACT_PROBE, 1443 ALC_FIXUP_ACT_PROBE,
1444 ALC_FIXUP_ACT_INIT, 1444 ALC_FIXUP_ACT_INIT,
1445 ALC_FIXUP_ACT_BUILD, 1445 ALC_FIXUP_ACT_BUILD,
1446 }; 1446 };
1447 1447
1448 static void alc_apply_fixup(struct hda_codec *codec, int action) 1448 static void alc_apply_fixup(struct hda_codec *codec, int action)
1449 { 1449 {
1450 struct alc_spec *spec = codec->spec; 1450 struct alc_spec *spec = codec->spec;
1451 int id = spec->fixup_id; 1451 int id = spec->fixup_id;
1452 #ifdef CONFIG_SND_DEBUG_VERBOSE 1452 #ifdef CONFIG_SND_DEBUG_VERBOSE
1453 const char *modelname = spec->fixup_name; 1453 const char *modelname = spec->fixup_name;
1454 #endif 1454 #endif
1455 int depth = 0; 1455 int depth = 0;
1456 1456
1457 if (!spec->fixup_list) 1457 if (!spec->fixup_list)
1458 return; 1458 return;
1459 1459
1460 while (id >= 0) { 1460 while (id >= 0) {
1461 const struct alc_fixup *fix = spec->fixup_list + id; 1461 const struct alc_fixup *fix = spec->fixup_list + id;
1462 const struct alc_pincfg *cfg; 1462 const struct alc_pincfg *cfg;
1463 1463
1464 switch (fix->type) { 1464 switch (fix->type) {
1465 case ALC_FIXUP_SKU: 1465 case ALC_FIXUP_SKU:
1466 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku) 1466 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1467 break; 1467 break;
1468 snd_printdd(KERN_INFO "hda_codec: %s: " 1468 snd_printdd(KERN_INFO "hda_codec: %s: "
1469 "Apply sku override for %s\n", 1469 "Apply sku override for %s\n",
1470 codec->chip_name, modelname); 1470 codec->chip_name, modelname);
1471 spec->cdefine.sku_cfg = fix->v.sku; 1471 spec->cdefine.sku_cfg = fix->v.sku;
1472 spec->cdefine.fixup = 1; 1472 spec->cdefine.fixup = 1;
1473 break; 1473 break;
1474 case ALC_FIXUP_PINS: 1474 case ALC_FIXUP_PINS:
1475 cfg = fix->v.pins; 1475 cfg = fix->v.pins;
1476 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg) 1476 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg)
1477 break; 1477 break;
1478 snd_printdd(KERN_INFO "hda_codec: %s: " 1478 snd_printdd(KERN_INFO "hda_codec: %s: "
1479 "Apply pincfg for %s\n", 1479 "Apply pincfg for %s\n",
1480 codec->chip_name, modelname); 1480 codec->chip_name, modelname);
1481 for (; cfg->nid; cfg++) 1481 for (; cfg->nid; cfg++)
1482 snd_hda_codec_set_pincfg(codec, cfg->nid, 1482 snd_hda_codec_set_pincfg(codec, cfg->nid,
1483 cfg->val); 1483 cfg->val);
1484 break; 1484 break;
1485 case ALC_FIXUP_VERBS: 1485 case ALC_FIXUP_VERBS:
1486 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs) 1486 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs)
1487 break; 1487 break;
1488 snd_printdd(KERN_INFO "hda_codec: %s: " 1488 snd_printdd(KERN_INFO "hda_codec: %s: "
1489 "Apply fix-verbs for %s\n", 1489 "Apply fix-verbs for %s\n",
1490 codec->chip_name, modelname); 1490 codec->chip_name, modelname);
1491 add_verb(codec->spec, fix->v.verbs); 1491 add_verb(codec->spec, fix->v.verbs);
1492 break; 1492 break;
1493 case ALC_FIXUP_FUNC: 1493 case ALC_FIXUP_FUNC:
1494 if (!fix->v.func) 1494 if (!fix->v.func)
1495 break; 1495 break;
1496 snd_printdd(KERN_INFO "hda_codec: %s: " 1496 snd_printdd(KERN_INFO "hda_codec: %s: "
1497 "Apply fix-func for %s\n", 1497 "Apply fix-func for %s\n",
1498 codec->chip_name, modelname); 1498 codec->chip_name, modelname);
1499 fix->v.func(codec, fix, action); 1499 fix->v.func(codec, fix, action);
1500 break; 1500 break;
1501 default: 1501 default:
1502 snd_printk(KERN_ERR "hda_codec: %s: " 1502 snd_printk(KERN_ERR "hda_codec: %s: "
1503 "Invalid fixup type %d\n", 1503 "Invalid fixup type %d\n",
1504 codec->chip_name, fix->type); 1504 codec->chip_name, fix->type);
1505 break; 1505 break;
1506 } 1506 }
1507 if (!fix->chained) 1507 if (!fix->chained)
1508 break; 1508 break;
1509 if (++depth > 10) 1509 if (++depth > 10)
1510 break; 1510 break;
1511 id = fix->chain_id; 1511 id = fix->chain_id;
1512 } 1512 }
1513 } 1513 }
1514 1514
1515 static void alc_pick_fixup(struct hda_codec *codec, 1515 static void alc_pick_fixup(struct hda_codec *codec,
1516 const struct alc_model_fixup *models, 1516 const struct alc_model_fixup *models,
1517 const struct snd_pci_quirk *quirk, 1517 const struct snd_pci_quirk *quirk,
1518 const struct alc_fixup *fixlist) 1518 const struct alc_fixup *fixlist)
1519 { 1519 {
1520 struct alc_spec *spec = codec->spec; 1520 struct alc_spec *spec = codec->spec;
1521 const struct snd_pci_quirk *q; 1521 const struct snd_pci_quirk *q;
1522 int id = -1; 1522 int id = -1;
1523 const char *name = NULL; 1523 const char *name = NULL;
1524 1524
1525 /* when model=nofixup is given, don't pick up any fixups */ 1525 /* when model=nofixup is given, don't pick up any fixups */
1526 if (codec->modelname && !strcmp(codec->modelname, "nofixup")) { 1526 if (codec->modelname && !strcmp(codec->modelname, "nofixup")) {
1527 spec->fixup_list = NULL; 1527 spec->fixup_list = NULL;
1528 spec->fixup_id = -1; 1528 spec->fixup_id = -1;
1529 return; 1529 return;
1530 } 1530 }
1531 1531
1532 if (codec->modelname && models) { 1532 if (codec->modelname && models) {
1533 while (models->name) { 1533 while (models->name) {
1534 if (!strcmp(codec->modelname, models->name)) { 1534 if (!strcmp(codec->modelname, models->name)) {
1535 id = models->id; 1535 id = models->id;
1536 name = models->name; 1536 name = models->name;
1537 break; 1537 break;
1538 } 1538 }
1539 models++; 1539 models++;
1540 } 1540 }
1541 } 1541 }
1542 if (id < 0) { 1542 if (id < 0) {
1543 q = snd_pci_quirk_lookup(codec->bus->pci, quirk); 1543 q = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1544 if (q) { 1544 if (q) {
1545 id = q->value; 1545 id = q->value;
1546 #ifdef CONFIG_SND_DEBUG_VERBOSE 1546 #ifdef CONFIG_SND_DEBUG_VERBOSE
1547 name = q->name; 1547 name = q->name;
1548 #endif 1548 #endif
1549 } 1549 }
1550 } 1550 }
1551 if (id < 0) { 1551 if (id < 0) {
1552 for (q = quirk; q->subvendor; q++) { 1552 for (q = quirk; q->subvendor; q++) {
1553 unsigned int vendorid = 1553 unsigned int vendorid =
1554 q->subdevice | (q->subvendor << 16); 1554 q->subdevice | (q->subvendor << 16);
1555 if (vendorid == codec->subsystem_id) { 1555 if (vendorid == codec->subsystem_id) {
1556 id = q->value; 1556 id = q->value;
1557 #ifdef CONFIG_SND_DEBUG_VERBOSE 1557 #ifdef CONFIG_SND_DEBUG_VERBOSE
1558 name = q->name; 1558 name = q->name;
1559 #endif 1559 #endif
1560 break; 1560 break;
1561 } 1561 }
1562 } 1562 }
1563 } 1563 }
1564 1564
1565 spec->fixup_id = id; 1565 spec->fixup_id = id;
1566 if (id >= 0) { 1566 if (id >= 0) {
1567 spec->fixup_list = fixlist; 1567 spec->fixup_list = fixlist;
1568 spec->fixup_name = name; 1568 spec->fixup_name = name;
1569 } 1569 }
1570 } 1570 }
1571 1571
1572 /* 1572 /*
1573 * COEF access helper functions 1573 * COEF access helper functions
1574 */ 1574 */
1575 static int alc_read_coef_idx(struct hda_codec *codec, 1575 static int alc_read_coef_idx(struct hda_codec *codec,
1576 unsigned int coef_idx) 1576 unsigned int coef_idx)
1577 { 1577 {
1578 unsigned int val; 1578 unsigned int val;
1579 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 1579 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1580 coef_idx); 1580 coef_idx);
1581 val = snd_hda_codec_read(codec, 0x20, 0, 1581 val = snd_hda_codec_read(codec, 0x20, 0,
1582 AC_VERB_GET_PROC_COEF, 0); 1582 AC_VERB_GET_PROC_COEF, 0);
1583 return val; 1583 return val;
1584 } 1584 }
1585 1585
1586 static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, 1586 static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1587 unsigned int coef_val) 1587 unsigned int coef_val)
1588 { 1588 {
1589 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 1589 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1590 coef_idx); 1590 coef_idx);
1591 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, 1591 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1592 coef_val); 1592 coef_val);
1593 } 1593 }
1594 1594
1595 /* a special bypass for COEF 0; read the cached value at the second time */ 1595 /* a special bypass for COEF 0; read the cached value at the second time */
1596 static unsigned int alc_get_coef0(struct hda_codec *codec) 1596 static unsigned int alc_get_coef0(struct hda_codec *codec)
1597 { 1597 {
1598 struct alc_spec *spec = codec->spec; 1598 struct alc_spec *spec = codec->spec;
1599 if (!spec->coef0) 1599 if (!spec->coef0)
1600 spec->coef0 = alc_read_coef_idx(codec, 0); 1600 spec->coef0 = alc_read_coef_idx(codec, 0);
1601 return spec->coef0; 1601 return spec->coef0;
1602 } 1602 }
1603 1603
1604 /* 1604 /*
1605 * Digital I/O handling 1605 * Digital I/O handling
1606 */ 1606 */
1607 1607
1608 /* set right pin controls for digital I/O */ 1608 /* set right pin controls for digital I/O */
1609 static void alc_auto_init_digital(struct hda_codec *codec) 1609 static void alc_auto_init_digital(struct hda_codec *codec)
1610 { 1610 {
1611 struct alc_spec *spec = codec->spec; 1611 struct alc_spec *spec = codec->spec;
1612 int i; 1612 int i;
1613 hda_nid_t pin, dac; 1613 hda_nid_t pin, dac;
1614 1614
1615 for (i = 0; i < spec->autocfg.dig_outs; i++) { 1615 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1616 pin = spec->autocfg.dig_out_pins[i]; 1616 pin = spec->autocfg.dig_out_pins[i];
1617 if (!pin) 1617 if (!pin)
1618 continue; 1618 continue;
1619 snd_hda_codec_write(codec, pin, 0, 1619 snd_hda_codec_write(codec, pin, 0,
1620 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); 1620 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
1621 if (!i) 1621 if (!i)
1622 dac = spec->multiout.dig_out_nid; 1622 dac = spec->multiout.dig_out_nid;
1623 else 1623 else
1624 dac = spec->slave_dig_outs[i - 1]; 1624 dac = spec->slave_dig_outs[i - 1];
1625 if (!dac || !(get_wcaps(codec, dac) & AC_WCAP_OUT_AMP)) 1625 if (!dac || !(get_wcaps(codec, dac) & AC_WCAP_OUT_AMP))
1626 continue; 1626 continue;
1627 snd_hda_codec_write(codec, dac, 0, 1627 snd_hda_codec_write(codec, dac, 0,
1628 AC_VERB_SET_AMP_GAIN_MUTE, 1628 AC_VERB_SET_AMP_GAIN_MUTE,
1629 AMP_OUT_UNMUTE); 1629 AMP_OUT_UNMUTE);
1630 } 1630 }
1631 pin = spec->autocfg.dig_in_pin; 1631 pin = spec->autocfg.dig_in_pin;
1632 if (pin) 1632 if (pin)
1633 snd_hda_codec_write(codec, pin, 0, 1633 snd_hda_codec_write(codec, pin, 0,
1634 AC_VERB_SET_PIN_WIDGET_CONTROL, 1634 AC_VERB_SET_PIN_WIDGET_CONTROL,
1635 PIN_IN); 1635 PIN_IN);
1636 } 1636 }
1637 1637
1638 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ 1638 /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1639 static void alc_auto_parse_digital(struct hda_codec *codec) 1639 static void alc_auto_parse_digital(struct hda_codec *codec)
1640 { 1640 {
1641 struct alc_spec *spec = codec->spec; 1641 struct alc_spec *spec = codec->spec;
1642 int i, err, nums; 1642 int i, err, nums;
1643 hda_nid_t dig_nid; 1643 hda_nid_t dig_nid;
1644 1644
1645 /* support multiple SPDIFs; the secondary is set up as a slave */ 1645 /* support multiple SPDIFs; the secondary is set up as a slave */
1646 nums = 0; 1646 nums = 0;
1647 for (i = 0; i < spec->autocfg.dig_outs; i++) { 1647 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1648 hda_nid_t conn[4]; 1648 hda_nid_t conn[4];
1649 err = snd_hda_get_connections(codec, 1649 err = snd_hda_get_connections(codec,
1650 spec->autocfg.dig_out_pins[i], 1650 spec->autocfg.dig_out_pins[i],
1651 conn, ARRAY_SIZE(conn)); 1651 conn, ARRAY_SIZE(conn));
1652 if (err <= 0) 1652 if (err <= 0)
1653 continue; 1653 continue;
1654 dig_nid = conn[0]; /* assume the first element is audio-out */ 1654 dig_nid = conn[0]; /* assume the first element is audio-out */
1655 if (!nums) { 1655 if (!nums) {
1656 spec->multiout.dig_out_nid = dig_nid; 1656 spec->multiout.dig_out_nid = dig_nid;
1657 spec->dig_out_type = spec->autocfg.dig_out_type[0]; 1657 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1658 } else { 1658 } else {
1659 spec->multiout.slave_dig_outs = spec->slave_dig_outs; 1659 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1660 if (nums >= ARRAY_SIZE(spec->slave_dig_outs) - 1) 1660 if (nums >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1661 break; 1661 break;
1662 spec->slave_dig_outs[nums - 1] = dig_nid; 1662 spec->slave_dig_outs[nums - 1] = dig_nid;
1663 } 1663 }
1664 nums++; 1664 nums++;
1665 } 1665 }
1666 1666
1667 if (spec->autocfg.dig_in_pin) { 1667 if (spec->autocfg.dig_in_pin) {
1668 dig_nid = codec->start_nid; 1668 dig_nid = codec->start_nid;
1669 for (i = 0; i < codec->num_nodes; i++, dig_nid++) { 1669 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1670 unsigned int wcaps = get_wcaps(codec, dig_nid); 1670 unsigned int wcaps = get_wcaps(codec, dig_nid);
1671 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) 1671 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1672 continue; 1672 continue;
1673 if (!(wcaps & AC_WCAP_DIGITAL)) 1673 if (!(wcaps & AC_WCAP_DIGITAL))
1674 continue; 1674 continue;
1675 if (!(wcaps & AC_WCAP_CONN_LIST)) 1675 if (!(wcaps & AC_WCAP_CONN_LIST))
1676 continue; 1676 continue;
1677 err = get_connection_index(codec, dig_nid, 1677 err = get_connection_index(codec, dig_nid,
1678 spec->autocfg.dig_in_pin); 1678 spec->autocfg.dig_in_pin);
1679 if (err >= 0) { 1679 if (err >= 0) {
1680 spec->dig_in_nid = dig_nid; 1680 spec->dig_in_nid = dig_nid;
1681 break; 1681 break;
1682 } 1682 }
1683 } 1683 }
1684 } 1684 }
1685 } 1685 }
1686 1686
1687 /* 1687 /*
1688 * capture mixer elements 1688 * capture mixer elements
1689 */ 1689 */
1690 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol, 1690 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1691 struct snd_ctl_elem_info *uinfo) 1691 struct snd_ctl_elem_info *uinfo)
1692 { 1692 {
1693 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1693 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1694 struct alc_spec *spec = codec->spec; 1694 struct alc_spec *spec = codec->spec;
1695 unsigned long val; 1695 unsigned long val;
1696 int err; 1696 int err;
1697 1697
1698 mutex_lock(&codec->control_mutex); 1698 mutex_lock(&codec->control_mutex);
1699 if (spec->vol_in_capsrc) 1699 if (spec->vol_in_capsrc)
1700 val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); 1700 val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT);
1701 else 1701 else
1702 val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); 1702 val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT);
1703 kcontrol->private_value = val; 1703 kcontrol->private_value = val;
1704 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); 1704 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1705 mutex_unlock(&codec->control_mutex); 1705 mutex_unlock(&codec->control_mutex);
1706 return err; 1706 return err;
1707 } 1707 }
1708 1708
1709 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, 1709 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1710 unsigned int size, unsigned int __user *tlv) 1710 unsigned int size, unsigned int __user *tlv)
1711 { 1711 {
1712 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1712 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1713 struct alc_spec *spec = codec->spec; 1713 struct alc_spec *spec = codec->spec;
1714 unsigned long val; 1714 unsigned long val;
1715 int err; 1715 int err;
1716 1716
1717 mutex_lock(&codec->control_mutex); 1717 mutex_lock(&codec->control_mutex);
1718 if (spec->vol_in_capsrc) 1718 if (spec->vol_in_capsrc)
1719 val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); 1719 val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT);
1720 else 1720 else
1721 val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); 1721 val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT);
1722 kcontrol->private_value = val; 1722 kcontrol->private_value = val;
1723 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); 1723 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1724 mutex_unlock(&codec->control_mutex); 1724 mutex_unlock(&codec->control_mutex);
1725 return err; 1725 return err;
1726 } 1726 }
1727 1727
1728 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol, 1728 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1729 struct snd_ctl_elem_value *ucontrol); 1729 struct snd_ctl_elem_value *ucontrol);
1730 1730
1731 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol, 1731 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1732 struct snd_ctl_elem_value *ucontrol, 1732 struct snd_ctl_elem_value *ucontrol,
1733 getput_call_t func, bool check_adc_switch) 1733 getput_call_t func, bool check_adc_switch)
1734 { 1734 {
1735 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1735 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1736 struct alc_spec *spec = codec->spec; 1736 struct alc_spec *spec = codec->spec;
1737 int i, err = 0; 1737 int i, err = 0;
1738 1738
1739 mutex_lock(&codec->control_mutex); 1739 mutex_lock(&codec->control_mutex);
1740 if (check_adc_switch && spec->dyn_adc_switch) { 1740 if (check_adc_switch && spec->dyn_adc_switch) {
1741 for (i = 0; i < spec->num_adc_nids; i++) { 1741 for (i = 0; i < spec->num_adc_nids; i++) {
1742 kcontrol->private_value = 1742 kcontrol->private_value =
1743 HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], 1743 HDA_COMPOSE_AMP_VAL(spec->adc_nids[i],
1744 3, 0, HDA_INPUT); 1744 3, 0, HDA_INPUT);
1745 err = func(kcontrol, ucontrol); 1745 err = func(kcontrol, ucontrol);
1746 if (err < 0) 1746 if (err < 0)
1747 goto error; 1747 goto error;
1748 } 1748 }
1749 } else { 1749 } else {
1750 i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1750 i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1751 if (spec->vol_in_capsrc) 1751 if (spec->vol_in_capsrc)
1752 kcontrol->private_value = 1752 kcontrol->private_value =
1753 HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[i], 1753 HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[i],
1754 3, 0, HDA_OUTPUT); 1754 3, 0, HDA_OUTPUT);
1755 else 1755 else
1756 kcontrol->private_value = 1756 kcontrol->private_value =
1757 HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], 1757 HDA_COMPOSE_AMP_VAL(spec->adc_nids[i],
1758 3, 0, HDA_INPUT); 1758 3, 0, HDA_INPUT);
1759 err = func(kcontrol, ucontrol); 1759 err = func(kcontrol, ucontrol);
1760 } 1760 }
1761 error: 1761 error:
1762 mutex_unlock(&codec->control_mutex); 1762 mutex_unlock(&codec->control_mutex);
1763 return err; 1763 return err;
1764 } 1764 }
1765 1765
1766 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol, 1766 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1767 struct snd_ctl_elem_value *ucontrol) 1767 struct snd_ctl_elem_value *ucontrol)
1768 { 1768 {
1769 return alc_cap_getput_caller(kcontrol, ucontrol, 1769 return alc_cap_getput_caller(kcontrol, ucontrol,
1770 snd_hda_mixer_amp_volume_get, false); 1770 snd_hda_mixer_amp_volume_get, false);
1771 } 1771 }
1772 1772
1773 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, 1773 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1774 struct snd_ctl_elem_value *ucontrol) 1774 struct snd_ctl_elem_value *ucontrol)
1775 { 1775 {
1776 return alc_cap_getput_caller(kcontrol, ucontrol, 1776 return alc_cap_getput_caller(kcontrol, ucontrol,
1777 snd_hda_mixer_amp_volume_put, true); 1777 snd_hda_mixer_amp_volume_put, true);
1778 } 1778 }
1779 1779
1780 /* capture mixer elements */ 1780 /* capture mixer elements */
1781 #define alc_cap_sw_info snd_ctl_boolean_stereo_info 1781 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1782 1782
1783 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol, 1783 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1784 struct snd_ctl_elem_value *ucontrol) 1784 struct snd_ctl_elem_value *ucontrol)
1785 { 1785 {
1786 return alc_cap_getput_caller(kcontrol, ucontrol, 1786 return alc_cap_getput_caller(kcontrol, ucontrol,
1787 snd_hda_mixer_amp_switch_get, false); 1787 snd_hda_mixer_amp_switch_get, false);
1788 } 1788 }
1789 1789
1790 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, 1790 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1791 struct snd_ctl_elem_value *ucontrol) 1791 struct snd_ctl_elem_value *ucontrol)
1792 { 1792 {
1793 return alc_cap_getput_caller(kcontrol, ucontrol, 1793 return alc_cap_getput_caller(kcontrol, ucontrol,
1794 snd_hda_mixer_amp_switch_put, true); 1794 snd_hda_mixer_amp_switch_put, true);
1795 } 1795 }
1796 1796
1797 #define _DEFINE_CAPMIX(num) \ 1797 #define _DEFINE_CAPMIX(num) \
1798 { \ 1798 { \
1799 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 1799 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1800 .name = "Capture Switch", \ 1800 .name = "Capture Switch", \
1801 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ 1801 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1802 .count = num, \ 1802 .count = num, \
1803 .info = alc_cap_sw_info, \ 1803 .info = alc_cap_sw_info, \
1804 .get = alc_cap_sw_get, \ 1804 .get = alc_cap_sw_get, \
1805 .put = alc_cap_sw_put, \ 1805 .put = alc_cap_sw_put, \
1806 }, \ 1806 }, \
1807 { \ 1807 { \
1808 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 1808 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1809 .name = "Capture Volume", \ 1809 .name = "Capture Volume", \
1810 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \ 1810 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1811 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ 1811 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1812 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \ 1812 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1813 .count = num, \ 1813 .count = num, \
1814 .info = alc_cap_vol_info, \ 1814 .info = alc_cap_vol_info, \
1815 .get = alc_cap_vol_get, \ 1815 .get = alc_cap_vol_get, \
1816 .put = alc_cap_vol_put, \ 1816 .put = alc_cap_vol_put, \
1817 .tlv = { .c = alc_cap_vol_tlv }, \ 1817 .tlv = { .c = alc_cap_vol_tlv }, \
1818 } 1818 }
1819 1819
1820 #define _DEFINE_CAPSRC(num) \ 1820 #define _DEFINE_CAPSRC(num) \
1821 { \ 1821 { \
1822 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 1822 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1823 /* .name = "Capture Source", */ \ 1823 /* .name = "Capture Source", */ \
1824 .name = "Input Source", \ 1824 .name = "Input Source", \
1825 .count = num, \ 1825 .count = num, \
1826 .info = alc_mux_enum_info, \ 1826 .info = alc_mux_enum_info, \
1827 .get = alc_mux_enum_get, \ 1827 .get = alc_mux_enum_get, \
1828 .put = alc_mux_enum_put, \ 1828 .put = alc_mux_enum_put, \
1829 } 1829 }
1830 1830
1831 #define DEFINE_CAPMIX(num) \ 1831 #define DEFINE_CAPMIX(num) \
1832 static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \ 1832 static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1833 _DEFINE_CAPMIX(num), \ 1833 _DEFINE_CAPMIX(num), \
1834 _DEFINE_CAPSRC(num), \ 1834 _DEFINE_CAPSRC(num), \
1835 { } /* end */ \ 1835 { } /* end */ \
1836 } 1836 }
1837 1837
1838 #define DEFINE_CAPMIX_NOSRC(num) \ 1838 #define DEFINE_CAPMIX_NOSRC(num) \
1839 static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \ 1839 static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1840 _DEFINE_CAPMIX(num), \ 1840 _DEFINE_CAPMIX(num), \
1841 { } /* end */ \ 1841 { } /* end */ \
1842 } 1842 }
1843 1843
1844 /* up to three ADCs */ 1844 /* up to three ADCs */
1845 DEFINE_CAPMIX(1); 1845 DEFINE_CAPMIX(1);
1846 DEFINE_CAPMIX(2); 1846 DEFINE_CAPMIX(2);
1847 DEFINE_CAPMIX(3); 1847 DEFINE_CAPMIX(3);
1848 DEFINE_CAPMIX_NOSRC(1); 1848 DEFINE_CAPMIX_NOSRC(1);
1849 DEFINE_CAPMIX_NOSRC(2); 1849 DEFINE_CAPMIX_NOSRC(2);
1850 DEFINE_CAPMIX_NOSRC(3); 1850 DEFINE_CAPMIX_NOSRC(3);
1851 1851
1852 /* 1852 /*
1853 * virtual master controls 1853 * virtual master controls
1854 */ 1854 */
1855 1855
1856 /* 1856 /*
1857 * slave controls for virtual master 1857 * slave controls for virtual master
1858 */ 1858 */
1859 static const char * const alc_slave_pfxs[] = { 1859 static const char * const alc_slave_pfxs[] = {
1860 "Front", "Surround", "Center", "LFE", "Side", 1860 "Front", "Surround", "Center", "LFE", "Side",
1861 "Headphone", "Speaker", "Mono", "Line Out", 1861 "Headphone", "Speaker", "Mono", "Line Out",
1862 "CLFE", "Bass Speaker", "PCM", 1862 "CLFE", "Bass Speaker", "PCM",
1863 NULL, 1863 NULL,
1864 }; 1864 };
1865 1865
1866 /* 1866 /*
1867 * build control elements 1867 * build control elements
1868 */ 1868 */
1869 1869
1870 #define NID_MAPPING (-1) 1870 #define NID_MAPPING (-1)
1871 1871
1872 #define SUBDEV_SPEAKER_ (0 << 6) 1872 #define SUBDEV_SPEAKER_ (0 << 6)
1873 #define SUBDEV_HP_ (1 << 6) 1873 #define SUBDEV_HP_ (1 << 6)
1874 #define SUBDEV_LINE_ (2 << 6) 1874 #define SUBDEV_LINE_ (2 << 6)
1875 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f)) 1875 #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
1876 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f)) 1876 #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
1877 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f)) 1877 #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
1878 1878
1879 static void alc_free_kctls(struct hda_codec *codec); 1879 static void alc_free_kctls(struct hda_codec *codec);
1880 1880
1881 #ifdef CONFIG_SND_HDA_INPUT_BEEP 1881 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1882 /* additional beep mixers; the actual parameters are overwritten at build */ 1882 /* additional beep mixers; the actual parameters are overwritten at build */
1883 static const struct snd_kcontrol_new alc_beep_mixer[] = { 1883 static const struct snd_kcontrol_new alc_beep_mixer[] = {
1884 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), 1884 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
1885 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), 1885 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
1886 { } /* end */ 1886 { } /* end */
1887 }; 1887 };
1888 #endif 1888 #endif
1889 1889
1890 static int __alc_build_controls(struct hda_codec *codec) 1890 static int __alc_build_controls(struct hda_codec *codec)
1891 { 1891 {
1892 struct alc_spec *spec = codec->spec; 1892 struct alc_spec *spec = codec->spec;
1893 struct snd_kcontrol *kctl = NULL; 1893 struct snd_kcontrol *kctl = NULL;
1894 const struct snd_kcontrol_new *knew; 1894 const struct snd_kcontrol_new *knew;
1895 int i, j, err; 1895 int i, j, err;
1896 unsigned int u; 1896 unsigned int u;
1897 hda_nid_t nid; 1897 hda_nid_t nid;
1898 1898
1899 for (i = 0; i < spec->num_mixers; i++) { 1899 for (i = 0; i < spec->num_mixers; i++) {
1900 err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 1900 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1901 if (err < 0) 1901 if (err < 0)
1902 return err; 1902 return err;
1903 } 1903 }
1904 if (spec->cap_mixer) { 1904 if (spec->cap_mixer) {
1905 err = snd_hda_add_new_ctls(codec, spec->cap_mixer); 1905 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
1906 if (err < 0) 1906 if (err < 0)
1907 return err; 1907 return err;
1908 } 1908 }
1909 if (spec->multiout.dig_out_nid) { 1909 if (spec->multiout.dig_out_nid) {
1910 err = snd_hda_create_spdif_out_ctls(codec, 1910 err = snd_hda_create_spdif_out_ctls(codec,
1911 spec->multiout.dig_out_nid, 1911 spec->multiout.dig_out_nid,
1912 spec->multiout.dig_out_nid); 1912 spec->multiout.dig_out_nid);
1913 if (err < 0) 1913 if (err < 0)
1914 return err; 1914 return err;
1915 if (!spec->no_analog) { 1915 if (!spec->no_analog) {
1916 err = snd_hda_create_spdif_share_sw(codec, 1916 err = snd_hda_create_spdif_share_sw(codec,
1917 &spec->multiout); 1917 &spec->multiout);
1918 if (err < 0) 1918 if (err < 0)
1919 return err; 1919 return err;
1920 spec->multiout.share_spdif = 1; 1920 spec->multiout.share_spdif = 1;
1921 } 1921 }
1922 } 1922 }
1923 if (spec->dig_in_nid) { 1923 if (spec->dig_in_nid) {
1924 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 1924 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1925 if (err < 0) 1925 if (err < 0)
1926 return err; 1926 return err;
1927 } 1927 }
1928 1928
1929 #ifdef CONFIG_SND_HDA_INPUT_BEEP 1929 #ifdef CONFIG_SND_HDA_INPUT_BEEP
1930 /* create beep controls if needed */ 1930 /* create beep controls if needed */
1931 if (spec->beep_amp) { 1931 if (spec->beep_amp) {
1932 const struct snd_kcontrol_new *knew; 1932 const struct snd_kcontrol_new *knew;
1933 for (knew = alc_beep_mixer; knew->name; knew++) { 1933 for (knew = alc_beep_mixer; knew->name; knew++) {
1934 struct snd_kcontrol *kctl; 1934 struct snd_kcontrol *kctl;
1935 kctl = snd_ctl_new1(knew, codec); 1935 kctl = snd_ctl_new1(knew, codec);
1936 if (!kctl) 1936 if (!kctl)
1937 return -ENOMEM; 1937 return -ENOMEM;
1938 kctl->private_value = spec->beep_amp; 1938 kctl->private_value = spec->beep_amp;
1939 err = snd_hda_ctl_add(codec, 0, kctl); 1939 err = snd_hda_ctl_add(codec, 0, kctl);
1940 if (err < 0) 1940 if (err < 0)
1941 return err; 1941 return err;
1942 } 1942 }
1943 } 1943 }
1944 #endif 1944 #endif
1945 1945
1946 /* if we have no master control, let's create it */ 1946 /* if we have no master control, let's create it */
1947 if (!spec->no_analog && 1947 if (!spec->no_analog &&
1948 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 1948 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1949 unsigned int vmaster_tlv[4]; 1949 unsigned int vmaster_tlv[4];
1950 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, 1950 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1951 HDA_OUTPUT, vmaster_tlv); 1951 HDA_OUTPUT, vmaster_tlv);
1952 err = snd_hda_add_vmaster(codec, "Master Playback Volume", 1952 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1953 vmaster_tlv, alc_slave_pfxs, 1953 vmaster_tlv, alc_slave_pfxs,
1954 "Playback Volume"); 1954 "Playback Volume");
1955 if (err < 0) 1955 if (err < 0)
1956 return err; 1956 return err;
1957 } 1957 }
1958 if (!spec->no_analog && 1958 if (!spec->no_analog &&
1959 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { 1959 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1960 err = __snd_hda_add_vmaster(codec, "Master Playback Switch", 1960 err = __snd_hda_add_vmaster(codec, "Master Playback Switch",
1961 NULL, alc_slave_pfxs, 1961 NULL, alc_slave_pfxs,
1962 "Playback Switch", 1962 "Playback Switch",
1963 true, &spec->vmaster_mute.sw_kctl); 1963 true, &spec->vmaster_mute.sw_kctl);
1964 if (err < 0) 1964 if (err < 0)
1965 return err; 1965 return err;
1966 } 1966 }
1967 1967
1968 /* assign Capture Source enums to NID */ 1968 /* assign Capture Source enums to NID */
1969 if (spec->capsrc_nids || spec->adc_nids) { 1969 if (spec->capsrc_nids || spec->adc_nids) {
1970 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); 1970 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
1971 if (!kctl) 1971 if (!kctl)
1972 kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); 1972 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
1973 for (i = 0; kctl && i < kctl->count; i++) { 1973 for (i = 0; kctl && i < kctl->count; i++) {
1974 err = snd_hda_add_nid(codec, kctl, i, 1974 err = snd_hda_add_nid(codec, kctl, i,
1975 get_capsrc(spec, i)); 1975 get_capsrc(spec, i));
1976 if (err < 0) 1976 if (err < 0)
1977 return err; 1977 return err;
1978 } 1978 }
1979 } 1979 }
1980 if (spec->cap_mixer && spec->adc_nids) { 1980 if (spec->cap_mixer && spec->adc_nids) {
1981 const char *kname = kctl ? kctl->id.name : NULL; 1981 const char *kname = kctl ? kctl->id.name : NULL;
1982 for (knew = spec->cap_mixer; knew->name; knew++) { 1982 for (knew = spec->cap_mixer; knew->name; knew++) {
1983 if (kname && strcmp(knew->name, kname) == 0) 1983 if (kname && strcmp(knew->name, kname) == 0)
1984 continue; 1984 continue;
1985 kctl = snd_hda_find_mixer_ctl(codec, knew->name); 1985 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
1986 for (i = 0; kctl && i < kctl->count; i++) { 1986 for (i = 0; kctl && i < kctl->count; i++) {
1987 err = snd_hda_add_nid(codec, kctl, i, 1987 err = snd_hda_add_nid(codec, kctl, i,
1988 spec->adc_nids[i]); 1988 spec->adc_nids[i]);
1989 if (err < 0) 1989 if (err < 0)
1990 return err; 1990 return err;
1991 } 1991 }
1992 } 1992 }
1993 } 1993 }
1994 1994
1995 /* other nid->control mapping */ 1995 /* other nid->control mapping */
1996 for (i = 0; i < spec->num_mixers; i++) { 1996 for (i = 0; i < spec->num_mixers; i++) {
1997 for (knew = spec->mixers[i]; knew->name; knew++) { 1997 for (knew = spec->mixers[i]; knew->name; knew++) {
1998 if (knew->iface != NID_MAPPING) 1998 if (knew->iface != NID_MAPPING)
1999 continue; 1999 continue;
2000 kctl = snd_hda_find_mixer_ctl(codec, knew->name); 2000 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2001 if (kctl == NULL) 2001 if (kctl == NULL)
2002 continue; 2002 continue;
2003 u = knew->subdevice; 2003 u = knew->subdevice;
2004 for (j = 0; j < 4; j++, u >>= 8) { 2004 for (j = 0; j < 4; j++, u >>= 8) {
2005 nid = u & 0x3f; 2005 nid = u & 0x3f;
2006 if (nid == 0) 2006 if (nid == 0)
2007 continue; 2007 continue;
2008 switch (u & 0xc0) { 2008 switch (u & 0xc0) {
2009 case SUBDEV_SPEAKER_: 2009 case SUBDEV_SPEAKER_:
2010 nid = spec->autocfg.speaker_pins[nid]; 2010 nid = spec->autocfg.speaker_pins[nid];
2011 break; 2011 break;
2012 case SUBDEV_LINE_: 2012 case SUBDEV_LINE_:
2013 nid = spec->autocfg.line_out_pins[nid]; 2013 nid = spec->autocfg.line_out_pins[nid];
2014 break; 2014 break;
2015 case SUBDEV_HP_: 2015 case SUBDEV_HP_:
2016 nid = spec->autocfg.hp_pins[nid]; 2016 nid = spec->autocfg.hp_pins[nid];
2017 break; 2017 break;
2018 default: 2018 default:
2019 continue; 2019 continue;
2020 } 2020 }
2021 err = snd_hda_add_nid(codec, kctl, 0, nid); 2021 err = snd_hda_add_nid(codec, kctl, 0, nid);
2022 if (err < 0) 2022 if (err < 0)
2023 return err; 2023 return err;
2024 } 2024 }
2025 u = knew->private_value; 2025 u = knew->private_value;
2026 for (j = 0; j < 4; j++, u >>= 8) { 2026 for (j = 0; j < 4; j++, u >>= 8) {
2027 nid = u & 0xff; 2027 nid = u & 0xff;
2028 if (nid == 0) 2028 if (nid == 0)
2029 continue; 2029 continue;
2030 err = snd_hda_add_nid(codec, kctl, 0, nid); 2030 err = snd_hda_add_nid(codec, kctl, 0, nid);
2031 if (err < 0) 2031 if (err < 0)
2032 return err; 2032 return err;
2033 } 2033 }
2034 } 2034 }
2035 } 2035 }
2036 2036
2037 alc_free_kctls(codec); /* no longer needed */ 2037 alc_free_kctls(codec); /* no longer needed */
2038 2038
2039 return 0; 2039 return 0;
2040 } 2040 }
2041 2041
2042 static int alc_build_controls(struct hda_codec *codec) 2042 static int alc_build_controls(struct hda_codec *codec)
2043 { 2043 {
2044 struct alc_spec *spec = codec->spec; 2044 struct alc_spec *spec = codec->spec;
2045 int err = __alc_build_controls(codec); 2045 int err = __alc_build_controls(codec);
2046 if (err < 0) 2046 if (err < 0)
2047 return err; 2047 return err;
2048 err = snd_hda_jack_add_kctls(codec, &spec->autocfg); 2048 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
2049 if (err < 0) 2049 if (err < 0)
2050 return err; 2050 return err;
2051 alc_apply_fixup(codec, ALC_FIXUP_ACT_BUILD); 2051 alc_apply_fixup(codec, ALC_FIXUP_ACT_BUILD);
2052 return 0; 2052 return 0;
2053 } 2053 }
2054 2054
2055 2055
2056 /* 2056 /*
2057 * Common callbacks 2057 * Common callbacks
2058 */ 2058 */
2059 2059
2060 static void alc_init_special_input_src(struct hda_codec *codec); 2060 static void alc_init_special_input_src(struct hda_codec *codec);
2061 static void alc_auto_init_std(struct hda_codec *codec); 2061 static void alc_auto_init_std(struct hda_codec *codec);
2062 2062
2063 static int alc_init(struct hda_codec *codec) 2063 static int alc_init(struct hda_codec *codec)
2064 { 2064 {
2065 struct alc_spec *spec = codec->spec; 2065 struct alc_spec *spec = codec->spec;
2066 unsigned int i; 2066 unsigned int i;
2067 2067
2068 if (spec->init_hook) 2068 if (spec->init_hook)
2069 spec->init_hook(codec); 2069 spec->init_hook(codec);
2070 2070
2071 alc_fix_pll(codec); 2071 alc_fix_pll(codec);
2072 alc_auto_init_amp(codec, spec->init_amp); 2072 alc_auto_init_amp(codec, spec->init_amp);
2073 2073
2074 for (i = 0; i < spec->num_init_verbs; i++) 2074 for (i = 0; i < spec->num_init_verbs; i++)
2075 snd_hda_sequence_write(codec, spec->init_verbs[i]); 2075 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2076 alc_init_special_input_src(codec); 2076 alc_init_special_input_src(codec);
2077 alc_auto_init_std(codec); 2077 alc_auto_init_std(codec);
2078 2078
2079 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); 2079 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
2080 2080
2081 snd_hda_jack_report_sync(codec); 2081 snd_hda_jack_report_sync(codec);
2082 2082
2083 hda_call_check_power_status(codec, 0x01); 2083 hda_call_check_power_status(codec, 0x01);
2084 return 0; 2084 return 0;
2085 } 2085 }
2086 2086
2087 static void alc_unsol_event(struct hda_codec *codec, unsigned int res) 2087 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2088 { 2088 {
2089 struct alc_spec *spec = codec->spec; 2089 struct alc_spec *spec = codec->spec;
2090 2090
2091 if (spec->unsol_event) 2091 if (spec->unsol_event)
2092 spec->unsol_event(codec, res); 2092 spec->unsol_event(codec, res);
2093 } 2093 }
2094 2094
2095 #ifdef CONFIG_SND_HDA_POWER_SAVE 2095 #ifdef CONFIG_SND_HDA_POWER_SAVE
2096 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) 2096 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2097 { 2097 {
2098 struct alc_spec *spec = codec->spec; 2098 struct alc_spec *spec = codec->spec;
2099 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); 2099 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2100 } 2100 }
2101 #endif 2101 #endif
2102 2102
2103 /* 2103 /*
2104 * Analog playback callbacks 2104 * Analog playback callbacks
2105 */ 2105 */
2106 static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo, 2106 static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo,
2107 struct hda_codec *codec, 2107 struct hda_codec *codec,
2108 struct snd_pcm_substream *substream) 2108 struct snd_pcm_substream *substream)
2109 { 2109 {
2110 struct alc_spec *spec = codec->spec; 2110 struct alc_spec *spec = codec->spec;
2111 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, 2111 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2112 hinfo); 2112 hinfo);
2113 } 2113 }
2114 2114
2115 static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 2115 static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2116 struct hda_codec *codec, 2116 struct hda_codec *codec,
2117 unsigned int stream_tag, 2117 unsigned int stream_tag,
2118 unsigned int format, 2118 unsigned int format,
2119 struct snd_pcm_substream *substream) 2119 struct snd_pcm_substream *substream)
2120 { 2120 {
2121 struct alc_spec *spec = codec->spec; 2121 struct alc_spec *spec = codec->spec;
2122 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, 2122 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2123 stream_tag, format, substream); 2123 stream_tag, format, substream);
2124 } 2124 }
2125 2125
2126 static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 2126 static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2127 struct hda_codec *codec, 2127 struct hda_codec *codec,
2128 struct snd_pcm_substream *substream) 2128 struct snd_pcm_substream *substream)
2129 { 2129 {
2130 struct alc_spec *spec = codec->spec; 2130 struct alc_spec *spec = codec->spec;
2131 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 2131 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2132 } 2132 }
2133 2133
2134 /* 2134 /*
2135 * Digital out 2135 * Digital out
2136 */ 2136 */
2137 static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, 2137 static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2138 struct hda_codec *codec, 2138 struct hda_codec *codec,
2139 struct snd_pcm_substream *substream) 2139 struct snd_pcm_substream *substream)
2140 { 2140 {
2141 struct alc_spec *spec = codec->spec; 2141 struct alc_spec *spec = codec->spec;
2142 return snd_hda_multi_out_dig_open(codec, &spec->multiout); 2142 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2143 } 2143 }
2144 2144
2145 static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 2145 static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2146 struct hda_codec *codec, 2146 struct hda_codec *codec,
2147 unsigned int stream_tag, 2147 unsigned int stream_tag,
2148 unsigned int format, 2148 unsigned int format,
2149 struct snd_pcm_substream *substream) 2149 struct snd_pcm_substream *substream)
2150 { 2150 {
2151 struct alc_spec *spec = codec->spec; 2151 struct alc_spec *spec = codec->spec;
2152 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, 2152 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2153 stream_tag, format, substream); 2153 stream_tag, format, substream);
2154 } 2154 }
2155 2155
2156 static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 2156 static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2157 struct hda_codec *codec, 2157 struct hda_codec *codec,
2158 struct snd_pcm_substream *substream) 2158 struct snd_pcm_substream *substream)
2159 { 2159 {
2160 struct alc_spec *spec = codec->spec; 2160 struct alc_spec *spec = codec->spec;
2161 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); 2161 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2162 } 2162 }
2163 2163
2164 static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 2164 static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2165 struct hda_codec *codec, 2165 struct hda_codec *codec,
2166 struct snd_pcm_substream *substream) 2166 struct snd_pcm_substream *substream)
2167 { 2167 {
2168 struct alc_spec *spec = codec->spec; 2168 struct alc_spec *spec = codec->spec;
2169 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 2169 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2170 } 2170 }
2171 2171
2172 /* 2172 /*
2173 * Analog capture 2173 * Analog capture
2174 */ 2174 */
2175 static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 2175 static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2176 struct hda_codec *codec, 2176 struct hda_codec *codec,
2177 unsigned int stream_tag, 2177 unsigned int stream_tag,
2178 unsigned int format, 2178 unsigned int format,
2179 struct snd_pcm_substream *substream) 2179 struct snd_pcm_substream *substream)
2180 { 2180 {
2181 struct alc_spec *spec = codec->spec; 2181 struct alc_spec *spec = codec->spec;
2182 2182
2183 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], 2183 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
2184 stream_tag, 0, format); 2184 stream_tag, 0, format);
2185 return 0; 2185 return 0;
2186 } 2186 }
2187 2187
2188 static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 2188 static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2189 struct hda_codec *codec, 2189 struct hda_codec *codec,
2190 struct snd_pcm_substream *substream) 2190 struct snd_pcm_substream *substream)
2191 { 2191 {
2192 struct alc_spec *spec = codec->spec; 2192 struct alc_spec *spec = codec->spec;
2193 2193
2194 snd_hda_codec_cleanup_stream(codec, 2194 snd_hda_codec_cleanup_stream(codec,
2195 spec->adc_nids[substream->number + 1]); 2195 spec->adc_nids[substream->number + 1]);
2196 return 0; 2196 return 0;
2197 } 2197 }
2198 2198
2199 /* analog capture with dynamic dual-adc changes */ 2199 /* analog capture with dynamic dual-adc changes */
2200 static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 2200 static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2201 struct hda_codec *codec, 2201 struct hda_codec *codec,
2202 unsigned int stream_tag, 2202 unsigned int stream_tag,
2203 unsigned int format, 2203 unsigned int format,
2204 struct snd_pcm_substream *substream) 2204 struct snd_pcm_substream *substream)
2205 { 2205 {
2206 struct alc_spec *spec = codec->spec; 2206 struct alc_spec *spec = codec->spec;
2207 spec->cur_adc = spec->adc_nids[spec->dyn_adc_idx[spec->cur_mux[0]]]; 2207 spec->cur_adc = spec->adc_nids[spec->dyn_adc_idx[spec->cur_mux[0]]];
2208 spec->cur_adc_stream_tag = stream_tag; 2208 spec->cur_adc_stream_tag = stream_tag;
2209 spec->cur_adc_format = format; 2209 spec->cur_adc_format = format;
2210 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); 2210 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
2211 return 0; 2211 return 0;
2212 } 2212 }
2213 2213
2214 static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 2214 static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2215 struct hda_codec *codec, 2215 struct hda_codec *codec,
2216 struct snd_pcm_substream *substream) 2216 struct snd_pcm_substream *substream)
2217 { 2217 {
2218 struct alc_spec *spec = codec->spec; 2218 struct alc_spec *spec = codec->spec;
2219 snd_hda_codec_cleanup_stream(codec, spec->cur_adc); 2219 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
2220 spec->cur_adc = 0; 2220 spec->cur_adc = 0;
2221 return 0; 2221 return 0;
2222 } 2222 }
2223 2223
2224 static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = { 2224 static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = {
2225 .substreams = 1, 2225 .substreams = 1,
2226 .channels_min = 2, 2226 .channels_min = 2,
2227 .channels_max = 2, 2227 .channels_max = 2,
2228 .nid = 0, /* fill later */ 2228 .nid = 0, /* fill later */
2229 .ops = { 2229 .ops = {
2230 .prepare = dyn_adc_capture_pcm_prepare, 2230 .prepare = dyn_adc_capture_pcm_prepare,
2231 .cleanup = dyn_adc_capture_pcm_cleanup 2231 .cleanup = dyn_adc_capture_pcm_cleanup
2232 }, 2232 },
2233 }; 2233 };
2234 2234
2235 /* 2235 /*
2236 */ 2236 */
2237 static const struct hda_pcm_stream alc_pcm_analog_playback = { 2237 static const struct hda_pcm_stream alc_pcm_analog_playback = {
2238 .substreams = 1, 2238 .substreams = 1,
2239 .channels_min = 2, 2239 .channels_min = 2,
2240 .channels_max = 8, 2240 .channels_max = 8,
2241 /* NID is set in alc_build_pcms */ 2241 /* NID is set in alc_build_pcms */
2242 .ops = { 2242 .ops = {
2243 .open = alc_playback_pcm_open, 2243 .open = alc_playback_pcm_open,
2244 .prepare = alc_playback_pcm_prepare, 2244 .prepare = alc_playback_pcm_prepare,
2245 .cleanup = alc_playback_pcm_cleanup 2245 .cleanup = alc_playback_pcm_cleanup
2246 }, 2246 },
2247 }; 2247 };
2248 2248
2249 static const struct hda_pcm_stream alc_pcm_analog_capture = { 2249 static const struct hda_pcm_stream alc_pcm_analog_capture = {
2250 .substreams = 1, 2250 .substreams = 1,
2251 .channels_min = 2, 2251 .channels_min = 2,
2252 .channels_max = 2, 2252 .channels_max = 2,
2253 /* NID is set in alc_build_pcms */ 2253 /* NID is set in alc_build_pcms */
2254 }; 2254 };
2255 2255
2256 static const struct hda_pcm_stream alc_pcm_analog_alt_playback = { 2256 static const struct hda_pcm_stream alc_pcm_analog_alt_playback = {
2257 .substreams = 1, 2257 .substreams = 1,
2258 .channels_min = 2, 2258 .channels_min = 2,
2259 .channels_max = 2, 2259 .channels_max = 2,
2260 /* NID is set in alc_build_pcms */ 2260 /* NID is set in alc_build_pcms */
2261 }; 2261 };
2262 2262
2263 static const struct hda_pcm_stream alc_pcm_analog_alt_capture = { 2263 static const struct hda_pcm_stream alc_pcm_analog_alt_capture = {
2264 .substreams = 2, /* can be overridden */ 2264 .substreams = 2, /* can be overridden */
2265 .channels_min = 2, 2265 .channels_min = 2,
2266 .channels_max = 2, 2266 .channels_max = 2,
2267 /* NID is set in alc_build_pcms */ 2267 /* NID is set in alc_build_pcms */
2268 .ops = { 2268 .ops = {
2269 .prepare = alc_alt_capture_pcm_prepare, 2269 .prepare = alc_alt_capture_pcm_prepare,
2270 .cleanup = alc_alt_capture_pcm_cleanup 2270 .cleanup = alc_alt_capture_pcm_cleanup
2271 }, 2271 },
2272 }; 2272 };
2273 2273
2274 static const struct hda_pcm_stream alc_pcm_digital_playback = { 2274 static const struct hda_pcm_stream alc_pcm_digital_playback = {
2275 .substreams = 1, 2275 .substreams = 1,
2276 .channels_min = 2, 2276 .channels_min = 2,
2277 .channels_max = 2, 2277 .channels_max = 2,
2278 /* NID is set in alc_build_pcms */ 2278 /* NID is set in alc_build_pcms */
2279 .ops = { 2279 .ops = {
2280 .open = alc_dig_playback_pcm_open, 2280 .open = alc_dig_playback_pcm_open,
2281 .close = alc_dig_playback_pcm_close, 2281 .close = alc_dig_playback_pcm_close,
2282 .prepare = alc_dig_playback_pcm_prepare, 2282 .prepare = alc_dig_playback_pcm_prepare,
2283 .cleanup = alc_dig_playback_pcm_cleanup 2283 .cleanup = alc_dig_playback_pcm_cleanup
2284 }, 2284 },
2285 }; 2285 };
2286 2286
2287 static const struct hda_pcm_stream alc_pcm_digital_capture = { 2287 static const struct hda_pcm_stream alc_pcm_digital_capture = {
2288 .substreams = 1, 2288 .substreams = 1,
2289 .channels_min = 2, 2289 .channels_min = 2,
2290 .channels_max = 2, 2290 .channels_max = 2,
2291 /* NID is set in alc_build_pcms */ 2291 /* NID is set in alc_build_pcms */
2292 }; 2292 };
2293 2293
2294 /* Used by alc_build_pcms to flag that a PCM has no playback stream */ 2294 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2295 static const struct hda_pcm_stream alc_pcm_null_stream = { 2295 static const struct hda_pcm_stream alc_pcm_null_stream = {
2296 .substreams = 0, 2296 .substreams = 0,
2297 .channels_min = 0, 2297 .channels_min = 0,
2298 .channels_max = 0, 2298 .channels_max = 0,
2299 }; 2299 };
2300 2300
2301 static int alc_build_pcms(struct hda_codec *codec) 2301 static int alc_build_pcms(struct hda_codec *codec)
2302 { 2302 {
2303 struct alc_spec *spec = codec->spec; 2303 struct alc_spec *spec = codec->spec;
2304 struct hda_pcm *info = spec->pcm_rec; 2304 struct hda_pcm *info = spec->pcm_rec;
2305 const struct hda_pcm_stream *p; 2305 const struct hda_pcm_stream *p;
2306 bool have_multi_adcs; 2306 bool have_multi_adcs;
2307 int i; 2307 int i;
2308 2308
2309 codec->num_pcms = 1; 2309 codec->num_pcms = 1;
2310 codec->pcm_info = info; 2310 codec->pcm_info = info;
2311 2311
2312 if (spec->no_analog) 2312 if (spec->no_analog)
2313 goto skip_analog; 2313 goto skip_analog;
2314 2314
2315 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), 2315 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
2316 "%s Analog", codec->chip_name); 2316 "%s Analog", codec->chip_name);
2317 info->name = spec->stream_name_analog; 2317 info->name = spec->stream_name_analog;
2318 2318
2319 if (spec->multiout.num_dacs > 0) { 2319 if (spec->multiout.num_dacs > 0) {
2320 p = spec->stream_analog_playback; 2320 p = spec->stream_analog_playback;
2321 if (!p) 2321 if (!p)
2322 p = &alc_pcm_analog_playback; 2322 p = &alc_pcm_analog_playback;
2323 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; 2323 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p;
2324 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; 2324 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2325 } 2325 }
2326 if (spec->adc_nids) { 2326 if (spec->adc_nids) {
2327 p = spec->stream_analog_capture; 2327 p = spec->stream_analog_capture;
2328 if (!p) { 2328 if (!p) {
2329 if (spec->dyn_adc_switch) 2329 if (spec->dyn_adc_switch)
2330 p = &dyn_adc_pcm_analog_capture; 2330 p = &dyn_adc_pcm_analog_capture;
2331 else 2331 else
2332 p = &alc_pcm_analog_capture; 2332 p = &alc_pcm_analog_capture;
2333 } 2333 }
2334 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; 2334 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p;
2335 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 2335 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2336 } 2336 }
2337 2337
2338 if (spec->channel_mode) { 2338 if (spec->channel_mode) {
2339 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; 2339 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2340 for (i = 0; i < spec->num_channel_mode; i++) { 2340 for (i = 0; i < spec->num_channel_mode; i++) {
2341 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { 2341 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2342 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; 2342 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2343 } 2343 }
2344 } 2344 }
2345 } 2345 }
2346 2346
2347 skip_analog: 2347 skip_analog:
2348 /* SPDIF for stream index #1 */ 2348 /* SPDIF for stream index #1 */
2349 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { 2349 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2350 snprintf(spec->stream_name_digital, 2350 snprintf(spec->stream_name_digital,
2351 sizeof(spec->stream_name_digital), 2351 sizeof(spec->stream_name_digital),
2352 "%s Digital", codec->chip_name); 2352 "%s Digital", codec->chip_name);
2353 codec->num_pcms = 2; 2353 codec->num_pcms = 2;
2354 codec->slave_dig_outs = spec->multiout.slave_dig_outs; 2354 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
2355 info = spec->pcm_rec + 1; 2355 info = spec->pcm_rec + 1;
2356 info->name = spec->stream_name_digital; 2356 info->name = spec->stream_name_digital;
2357 if (spec->dig_out_type) 2357 if (spec->dig_out_type)
2358 info->pcm_type = spec->dig_out_type; 2358 info->pcm_type = spec->dig_out_type;
2359 else 2359 else
2360 info->pcm_type = HDA_PCM_TYPE_SPDIF; 2360 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2361 if (spec->multiout.dig_out_nid) { 2361 if (spec->multiout.dig_out_nid) {
2362 p = spec->stream_digital_playback; 2362 p = spec->stream_digital_playback;
2363 if (!p) 2363 if (!p)
2364 p = &alc_pcm_digital_playback; 2364 p = &alc_pcm_digital_playback;
2365 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; 2365 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p;
2366 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; 2366 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2367 } 2367 }
2368 if (spec->dig_in_nid) { 2368 if (spec->dig_in_nid) {
2369 p = spec->stream_digital_capture; 2369 p = spec->stream_digital_capture;
2370 if (!p) 2370 if (!p)
2371 p = &alc_pcm_digital_capture; 2371 p = &alc_pcm_digital_capture;
2372 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; 2372 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p;
2373 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; 2373 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2374 } 2374 }
2375 /* FIXME: do we need this for all Realtek codec models? */ 2375 /* FIXME: do we need this for all Realtek codec models? */
2376 codec->spdif_status_reset = 1; 2376 codec->spdif_status_reset = 1;
2377 } 2377 }
2378 2378
2379 if (spec->no_analog) 2379 if (spec->no_analog)
2380 return 0; 2380 return 0;
2381 2381
2382 /* If the use of more than one ADC is requested for the current 2382 /* If the use of more than one ADC is requested for the current
2383 * model, configure a second analog capture-only PCM. 2383 * model, configure a second analog capture-only PCM.
2384 */ 2384 */
2385 have_multi_adcs = (spec->num_adc_nids > 1) && 2385 have_multi_adcs = (spec->num_adc_nids > 1) &&
2386 !spec->dyn_adc_switch && !spec->auto_mic && 2386 !spec->dyn_adc_switch && !spec->auto_mic &&
2387 (!spec->input_mux || spec->input_mux->num_items > 1); 2387 (!spec->input_mux || spec->input_mux->num_items > 1);
2388 /* Additional Analaog capture for index #2 */ 2388 /* Additional Analaog capture for index #2 */
2389 if (spec->alt_dac_nid || have_multi_adcs) { 2389 if (spec->alt_dac_nid || have_multi_adcs) {
2390 codec->num_pcms = 3; 2390 codec->num_pcms = 3;
2391 info = spec->pcm_rec + 2; 2391 info = spec->pcm_rec + 2;
2392 info->name = spec->stream_name_analog; 2392 info->name = spec->stream_name_analog;
2393 if (spec->alt_dac_nid) { 2393 if (spec->alt_dac_nid) {
2394 p = spec->stream_analog_alt_playback; 2394 p = spec->stream_analog_alt_playback;
2395 if (!p) 2395 if (!p)
2396 p = &alc_pcm_analog_alt_playback; 2396 p = &alc_pcm_analog_alt_playback;
2397 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; 2397 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p;
2398 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 2398 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2399 spec->alt_dac_nid; 2399 spec->alt_dac_nid;
2400 } else { 2400 } else {
2401 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = 2401 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2402 alc_pcm_null_stream; 2402 alc_pcm_null_stream;
2403 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; 2403 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2404 } 2404 }
2405 if (have_multi_adcs) { 2405 if (have_multi_adcs) {
2406 p = spec->stream_analog_alt_capture; 2406 p = spec->stream_analog_alt_capture;
2407 if (!p) 2407 if (!p)
2408 p = &alc_pcm_analog_alt_capture; 2408 p = &alc_pcm_analog_alt_capture;
2409 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; 2409 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p;
2410 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 2410 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2411 spec->adc_nids[1]; 2411 spec->adc_nids[1];
2412 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = 2412 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2413 spec->num_adc_nids - 1; 2413 spec->num_adc_nids - 1;
2414 } else { 2414 } else {
2415 info->stream[SNDRV_PCM_STREAM_CAPTURE] = 2415 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2416 alc_pcm_null_stream; 2416 alc_pcm_null_stream;
2417 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; 2417 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
2418 } 2418 }
2419 } 2419 }
2420 2420
2421 return 0; 2421 return 0;
2422 } 2422 }
2423 2423
2424 static inline void alc_shutup(struct hda_codec *codec) 2424 static inline void alc_shutup(struct hda_codec *codec)
2425 { 2425 {
2426 struct alc_spec *spec = codec->spec; 2426 struct alc_spec *spec = codec->spec;
2427 2427
2428 if (spec && spec->shutup) 2428 if (spec && spec->shutup)
2429 spec->shutup(codec); 2429 spec->shutup(codec);
2430 snd_hda_shutup_pins(codec); 2430 snd_hda_shutup_pins(codec);
2431 } 2431 }
2432 2432
2433 static void alc_free_kctls(struct hda_codec *codec) 2433 static void alc_free_kctls(struct hda_codec *codec)
2434 { 2434 {
2435 struct alc_spec *spec = codec->spec; 2435 struct alc_spec *spec = codec->spec;
2436 2436
2437 if (spec->kctls.list) { 2437 if (spec->kctls.list) {
2438 struct snd_kcontrol_new *kctl = spec->kctls.list; 2438 struct snd_kcontrol_new *kctl = spec->kctls.list;
2439 int i; 2439 int i;
2440 for (i = 0; i < spec->kctls.used; i++) 2440 for (i = 0; i < spec->kctls.used; i++)
2441 kfree(kctl[i].name); 2441 kfree(kctl[i].name);
2442 } 2442 }
2443 snd_array_free(&spec->kctls); 2443 snd_array_free(&spec->kctls);
2444 } 2444 }
2445 2445
2446 static void alc_free_bind_ctls(struct hda_codec *codec) 2446 static void alc_free_bind_ctls(struct hda_codec *codec)
2447 { 2447 {
2448 struct alc_spec *spec = codec->spec; 2448 struct alc_spec *spec = codec->spec;
2449 if (spec->bind_ctls.list) { 2449 if (spec->bind_ctls.list) {
2450 struct hda_bind_ctls **ctl = spec->bind_ctls.list; 2450 struct hda_bind_ctls **ctl = spec->bind_ctls.list;
2451 int i; 2451 int i;
2452 for (i = 0; i < spec->bind_ctls.used; i++) 2452 for (i = 0; i < spec->bind_ctls.used; i++)
2453 kfree(ctl[i]); 2453 kfree(ctl[i]);
2454 } 2454 }
2455 snd_array_free(&spec->bind_ctls); 2455 snd_array_free(&spec->bind_ctls);
2456 } 2456 }
2457 2457
2458 static void alc_free(struct hda_codec *codec) 2458 static void alc_free(struct hda_codec *codec)
2459 { 2459 {
2460 struct alc_spec *spec = codec->spec; 2460 struct alc_spec *spec = codec->spec;
2461 2461
2462 if (!spec) 2462 if (!spec)
2463 return; 2463 return;
2464 2464
2465 alc_shutup(codec); 2465 alc_shutup(codec);
2466 alc_free_kctls(codec); 2466 alc_free_kctls(codec);
2467 alc_free_bind_ctls(codec); 2467 alc_free_bind_ctls(codec);
2468 kfree(spec); 2468 kfree(spec);
2469 snd_hda_detach_beep_device(codec); 2469 snd_hda_detach_beep_device(codec);
2470 } 2470 }
2471 2471
2472 #ifdef CONFIG_SND_HDA_POWER_SAVE 2472 #ifdef CONFIG_SND_HDA_POWER_SAVE
2473 static void alc_power_eapd(struct hda_codec *codec) 2473 static void alc_power_eapd(struct hda_codec *codec)
2474 { 2474 {
2475 alc_auto_setup_eapd(codec, false); 2475 alc_auto_setup_eapd(codec, false);
2476 } 2476 }
2477 2477
2478 static int alc_suspend(struct hda_codec *codec, pm_message_t state) 2478 static int alc_suspend(struct hda_codec *codec, pm_message_t state)
2479 { 2479 {
2480 struct alc_spec *spec = codec->spec; 2480 struct alc_spec *spec = codec->spec;
2481 alc_shutup(codec); 2481 alc_shutup(codec);
2482 if (spec && spec->power_hook) 2482 if (spec && spec->power_hook)
2483 spec->power_hook(codec); 2483 spec->power_hook(codec);
2484 return 0; 2484 return 0;
2485 } 2485 }
2486 #endif 2486 #endif
2487 2487
2488 #ifdef CONFIG_PM 2488 #ifdef CONFIG_PM
2489 static int alc_resume(struct hda_codec *codec) 2489 static int alc_resume(struct hda_codec *codec)
2490 { 2490 {
2491 msleep(150); /* to avoid pop noise */ 2491 msleep(150); /* to avoid pop noise */
2492 codec->patch_ops.init(codec); 2492 codec->patch_ops.init(codec);
2493 snd_hda_codec_resume_amp(codec); 2493 snd_hda_codec_resume_amp(codec);
2494 snd_hda_codec_resume_cache(codec); 2494 snd_hda_codec_resume_cache(codec);
2495 hda_call_check_power_status(codec, 0x01); 2495 hda_call_check_power_status(codec, 0x01);
2496 return 0; 2496 return 0;
2497 } 2497 }
2498 #endif 2498 #endif
2499 2499
2500 /* 2500 /*
2501 */ 2501 */
2502 static const struct hda_codec_ops alc_patch_ops = { 2502 static const struct hda_codec_ops alc_patch_ops = {
2503 .build_controls = alc_build_controls, 2503 .build_controls = alc_build_controls,
2504 .build_pcms = alc_build_pcms, 2504 .build_pcms = alc_build_pcms,
2505 .init = alc_init, 2505 .init = alc_init,
2506 .free = alc_free, 2506 .free = alc_free,
2507 .unsol_event = alc_unsol_event, 2507 .unsol_event = alc_unsol_event,
2508 #ifdef CONFIG_PM 2508 #ifdef CONFIG_PM
2509 .resume = alc_resume, 2509 .resume = alc_resume,
2510 #endif 2510 #endif
2511 #ifdef CONFIG_SND_HDA_POWER_SAVE 2511 #ifdef CONFIG_SND_HDA_POWER_SAVE
2512 .suspend = alc_suspend, 2512 .suspend = alc_suspend,
2513 .check_power_status = alc_check_power_status, 2513 .check_power_status = alc_check_power_status,
2514 #endif 2514 #endif
2515 .reboot_notify = alc_shutup, 2515 .reboot_notify = alc_shutup,
2516 }; 2516 };
2517 2517
2518 /* replace the codec chip_name with the given string */ 2518 /* replace the codec chip_name with the given string */
2519 static int alc_codec_rename(struct hda_codec *codec, const char *name) 2519 static int alc_codec_rename(struct hda_codec *codec, const char *name)
2520 { 2520 {
2521 kfree(codec->chip_name); 2521 kfree(codec->chip_name);
2522 codec->chip_name = kstrdup(name, GFP_KERNEL); 2522 codec->chip_name = kstrdup(name, GFP_KERNEL);
2523 if (!codec->chip_name) { 2523 if (!codec->chip_name) {
2524 alc_free(codec); 2524 alc_free(codec);
2525 return -ENOMEM; 2525 return -ENOMEM;
2526 } 2526 }
2527 return 0; 2527 return 0;
2528 } 2528 }
2529 2529
2530 /* 2530 /*
2531 * Rename codecs appropriately from COEF value 2531 * Rename codecs appropriately from COEF value
2532 */ 2532 */
2533 struct alc_codec_rename_table { 2533 struct alc_codec_rename_table {
2534 unsigned int vendor_id; 2534 unsigned int vendor_id;
2535 unsigned short coef_mask; 2535 unsigned short coef_mask;
2536 unsigned short coef_bits; 2536 unsigned short coef_bits;
2537 const char *name; 2537 const char *name;
2538 }; 2538 };
2539 2539
2540 static struct alc_codec_rename_table rename_tbl[] = { 2540 static struct alc_codec_rename_table rename_tbl[] = {
2541 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, 2541 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
2542 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, 2542 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
2543 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" }, 2543 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
2544 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" }, 2544 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
2545 { 0x10ec0269, 0xffff, 0xa023, "ALC259" }, 2545 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
2546 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" }, 2546 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
2547 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" }, 2547 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
2548 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" }, 2548 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
2549 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" }, 2549 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
2550 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" }, 2550 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
2551 { 0x10ec0899, 0x2000, 0x2000, "ALC899" }, 2551 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
2552 { 0x10ec0892, 0xffff, 0x8020, "ALC661" }, 2552 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
2553 { 0x10ec0892, 0xffff, 0x8011, "ALC661" }, 2553 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
2554 { 0x10ec0892, 0xffff, 0x4011, "ALC656" }, 2554 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
2555 { } /* terminator */ 2555 { } /* terminator */
2556 }; 2556 };
2557 2557
2558 static int alc_codec_rename_from_preset(struct hda_codec *codec) 2558 static int alc_codec_rename_from_preset(struct hda_codec *codec)
2559 { 2559 {
2560 const struct alc_codec_rename_table *p; 2560 const struct alc_codec_rename_table *p;
2561 2561
2562 for (p = rename_tbl; p->vendor_id; p++) { 2562 for (p = rename_tbl; p->vendor_id; p++) {
2563 if (p->vendor_id != codec->vendor_id) 2563 if (p->vendor_id != codec->vendor_id)
2564 continue; 2564 continue;
2565 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) 2565 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
2566 return alc_codec_rename(codec, p->name); 2566 return alc_codec_rename(codec, p->name);
2567 } 2567 }
2568 return 0; 2568 return 0;
2569 } 2569 }
2570 2570
2571 /* 2571 /*
2572 * Automatic parse of I/O pins from the BIOS configuration 2572 * Automatic parse of I/O pins from the BIOS configuration
2573 */ 2573 */
2574 2574
2575 enum { 2575 enum {
2576 ALC_CTL_WIDGET_VOL, 2576 ALC_CTL_WIDGET_VOL,
2577 ALC_CTL_WIDGET_MUTE, 2577 ALC_CTL_WIDGET_MUTE,
2578 ALC_CTL_BIND_MUTE, 2578 ALC_CTL_BIND_MUTE,
2579 ALC_CTL_BIND_VOL, 2579 ALC_CTL_BIND_VOL,
2580 ALC_CTL_BIND_SW, 2580 ALC_CTL_BIND_SW,
2581 }; 2581 };
2582 static const struct snd_kcontrol_new alc_control_templates[] = { 2582 static const struct snd_kcontrol_new alc_control_templates[] = {
2583 HDA_CODEC_VOLUME(NULL, 0, 0, 0), 2583 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2584 HDA_CODEC_MUTE(NULL, 0, 0, 0), 2584 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2585 HDA_BIND_MUTE(NULL, 0, 0, 0), 2585 HDA_BIND_MUTE(NULL, 0, 0, 0),
2586 HDA_BIND_VOL(NULL, 0), 2586 HDA_BIND_VOL(NULL, 0),
2587 HDA_BIND_SW(NULL, 0), 2587 HDA_BIND_SW(NULL, 0),
2588 }; 2588 };
2589 2589
2590 /* add dynamic controls */ 2590 /* add dynamic controls */
2591 static int add_control(struct alc_spec *spec, int type, const char *name, 2591 static int add_control(struct alc_spec *spec, int type, const char *name,
2592 int cidx, unsigned long val) 2592 int cidx, unsigned long val)
2593 { 2593 {
2594 struct snd_kcontrol_new *knew; 2594 struct snd_kcontrol_new *knew;
2595 2595
2596 knew = alc_kcontrol_new(spec); 2596 knew = alc_kcontrol_new(spec);
2597 if (!knew) 2597 if (!knew)
2598 return -ENOMEM; 2598 return -ENOMEM;
2599 *knew = alc_control_templates[type]; 2599 *knew = alc_control_templates[type];
2600 knew->name = kstrdup(name, GFP_KERNEL); 2600 knew->name = kstrdup(name, GFP_KERNEL);
2601 if (!knew->name) 2601 if (!knew->name)
2602 return -ENOMEM; 2602 return -ENOMEM;
2603 knew->index = cidx; 2603 knew->index = cidx;
2604 if (get_amp_nid_(val)) 2604 if (get_amp_nid_(val))
2605 knew->subdevice = HDA_SUBDEV_AMP_FLAG; 2605 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
2606 knew->private_value = val; 2606 knew->private_value = val;
2607 return 0; 2607 return 0;
2608 } 2608 }
2609 2609
2610 static int add_control_with_pfx(struct alc_spec *spec, int type, 2610 static int add_control_with_pfx(struct alc_spec *spec, int type,
2611 const char *pfx, const char *dir, 2611 const char *pfx, const char *dir,
2612 const char *sfx, int cidx, unsigned long val) 2612 const char *sfx, int cidx, unsigned long val)
2613 { 2613 {
2614 char name[32]; 2614 char name[32];
2615 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); 2615 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
2616 return add_control(spec, type, name, cidx, val); 2616 return add_control(spec, type, name, cidx, val);
2617 } 2617 }
2618 2618
2619 #define add_pb_vol_ctrl(spec, type, pfx, val) \ 2619 #define add_pb_vol_ctrl(spec, type, pfx, val) \
2620 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val) 2620 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
2621 #define add_pb_sw_ctrl(spec, type, pfx, val) \ 2621 #define add_pb_sw_ctrl(spec, type, pfx, val) \
2622 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val) 2622 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
2623 #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \ 2623 #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
2624 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val) 2624 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
2625 #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ 2625 #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
2626 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val) 2626 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
2627 2627
2628 static const char * const channel_name[4] = { 2628 static const char * const channel_name[4] = {
2629 "Front", "Surround", "CLFE", "Side" 2629 "Front", "Surround", "CLFE", "Side"
2630 }; 2630 };
2631 2631
2632 static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch, 2632 static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch,
2633 bool can_be_master, int *index) 2633 bool can_be_master, int *index)
2634 { 2634 {
2635 struct auto_pin_cfg *cfg = &spec->autocfg; 2635 struct auto_pin_cfg *cfg = &spec->autocfg;
2636 2636
2637 *index = 0; 2637 *index = 0;
2638 if (cfg->line_outs == 1 && !spec->multi_ios && 2638 if (cfg->line_outs == 1 && !spec->multi_ios &&
2639 !cfg->hp_outs && !cfg->speaker_outs && can_be_master) 2639 !cfg->hp_outs && !cfg->speaker_outs && can_be_master)
2640 return "Master"; 2640 return "Master";
2641 2641
2642 switch (cfg->line_out_type) { 2642 switch (cfg->line_out_type) {
2643 case AUTO_PIN_SPEAKER_OUT: 2643 case AUTO_PIN_SPEAKER_OUT:
2644 if (cfg->line_outs == 1) 2644 if (cfg->line_outs == 1)
2645 return "Speaker"; 2645 return "Speaker";
2646 if (cfg->line_outs == 2) 2646 if (cfg->line_outs == 2)
2647 return ch ? "Bass Speaker" : "Speaker"; 2647 return ch ? "Bass Speaker" : "Speaker";
2648 break; 2648 break;
2649 case AUTO_PIN_HP_OUT: 2649 case AUTO_PIN_HP_OUT:
2650 /* for multi-io case, only the primary out */ 2650 /* for multi-io case, only the primary out */
2651 if (ch && spec->multi_ios) 2651 if (ch && spec->multi_ios)
2652 break; 2652 break;
2653 *index = ch; 2653 *index = ch;
2654 return "Headphone"; 2654 return "Headphone";
2655 default: 2655 default:
2656 if (cfg->line_outs == 1 && !spec->multi_ios) 2656 if (cfg->line_outs == 1 && !spec->multi_ios)
2657 return "PCM"; 2657 return "PCM";
2658 break; 2658 break;
2659 } 2659 }
2660 if (snd_BUG_ON(ch >= ARRAY_SIZE(channel_name))) 2660 if (snd_BUG_ON(ch >= ARRAY_SIZE(channel_name)))
2661 return "PCM"; 2661 return "PCM";
2662 2662
2663 return channel_name[ch]; 2663 return channel_name[ch];
2664 } 2664 }
2665 2665
2666 #ifdef CONFIG_SND_HDA_POWER_SAVE 2666 #ifdef CONFIG_SND_HDA_POWER_SAVE
2667 /* add the powersave loopback-list entry */ 2667 /* add the powersave loopback-list entry */
2668 static void add_loopback_list(struct alc_spec *spec, hda_nid_t mix, int idx) 2668 static void add_loopback_list(struct alc_spec *spec, hda_nid_t mix, int idx)
2669 { 2669 {
2670 struct hda_amp_list *list; 2670 struct hda_amp_list *list;
2671 2671
2672 if (spec->num_loopbacks >= ARRAY_SIZE(spec->loopback_list) - 1) 2672 if (spec->num_loopbacks >= ARRAY_SIZE(spec->loopback_list) - 1)
2673 return; 2673 return;
2674 list = spec->loopback_list + spec->num_loopbacks; 2674 list = spec->loopback_list + spec->num_loopbacks;
2675 list->nid = mix; 2675 list->nid = mix;
2676 list->dir = HDA_INPUT; 2676 list->dir = HDA_INPUT;
2677 list->idx = idx; 2677 list->idx = idx;
2678 spec->num_loopbacks++; 2678 spec->num_loopbacks++;
2679 spec->loopback.amplist = spec->loopback_list; 2679 spec->loopback.amplist = spec->loopback_list;
2680 } 2680 }
2681 #else 2681 #else
2682 #define add_loopback_list(spec, mix, idx) /* NOP */ 2682 #define add_loopback_list(spec, mix, idx) /* NOP */
2683 #endif 2683 #endif
2684 2684
2685 /* create input playback/capture controls for the given pin */ 2685 /* create input playback/capture controls for the given pin */
2686 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, 2686 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
2687 const char *ctlname, int ctlidx, 2687 const char *ctlname, int ctlidx,
2688 int idx, hda_nid_t mix_nid) 2688 int idx, hda_nid_t mix_nid)
2689 { 2689 {
2690 int err; 2690 int err;
2691 2691
2692 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx, 2692 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
2693 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); 2693 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
2694 if (err < 0) 2694 if (err < 0)
2695 return err; 2695 return err;
2696 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx, 2696 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
2697 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); 2697 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
2698 if (err < 0) 2698 if (err < 0)
2699 return err; 2699 return err;
2700 add_loopback_list(spec, mix_nid, idx); 2700 add_loopback_list(spec, mix_nid, idx);
2701 return 0; 2701 return 0;
2702 } 2702 }
2703 2703
2704 static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid) 2704 static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
2705 { 2705 {
2706 unsigned int pincap = snd_hda_query_pin_caps(codec, nid); 2706 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2707 return (pincap & AC_PINCAP_IN) != 0; 2707 return (pincap & AC_PINCAP_IN) != 0;
2708 } 2708 }
2709 2709
2710 /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */ 2710 /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */
2711 static int alc_auto_fill_adc_caps(struct hda_codec *codec) 2711 static int alc_auto_fill_adc_caps(struct hda_codec *codec)
2712 { 2712 {
2713 struct alc_spec *spec = codec->spec; 2713 struct alc_spec *spec = codec->spec;
2714 hda_nid_t nid; 2714 hda_nid_t nid;
2715 hda_nid_t *adc_nids = spec->private_adc_nids; 2715 hda_nid_t *adc_nids = spec->private_adc_nids;
2716 hda_nid_t *cap_nids = spec->private_capsrc_nids; 2716 hda_nid_t *cap_nids = spec->private_capsrc_nids;
2717 int max_nums = ARRAY_SIZE(spec->private_adc_nids); 2717 int max_nums = ARRAY_SIZE(spec->private_adc_nids);
2718 int i, nums = 0; 2718 int i, nums = 0;
2719 2719
2720 nid = codec->start_nid; 2720 nid = codec->start_nid;
2721 for (i = 0; i < codec->num_nodes; i++, nid++) { 2721 for (i = 0; i < codec->num_nodes; i++, nid++) {
2722 hda_nid_t src; 2722 hda_nid_t src;
2723 const hda_nid_t *list; 2723 const hda_nid_t *list;
2724 unsigned int caps = get_wcaps(codec, nid); 2724 unsigned int caps = get_wcaps(codec, nid);
2725 int type = get_wcaps_type(caps); 2725 int type = get_wcaps_type(caps);
2726 2726
2727 if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL)) 2727 if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL))
2728 continue; 2728 continue;
2729 adc_nids[nums] = nid; 2729 adc_nids[nums] = nid;
2730 cap_nids[nums] = nid; 2730 cap_nids[nums] = nid;
2731 src = nid; 2731 src = nid;
2732 for (;;) { 2732 for (;;) {
2733 int n; 2733 int n;
2734 type = get_wcaps_type(get_wcaps(codec, src)); 2734 type = get_wcaps_type(get_wcaps(codec, src));
2735 if (type == AC_WID_PIN) 2735 if (type == AC_WID_PIN)
2736 break; 2736 break;
2737 if (type == AC_WID_AUD_SEL) { 2737 if (type == AC_WID_AUD_SEL) {
2738 cap_nids[nums] = src; 2738 cap_nids[nums] = src;
2739 break; 2739 break;
2740 } 2740 }
2741 n = snd_hda_get_conn_list(codec, src, &list); 2741 n = snd_hda_get_conn_list(codec, src, &list);
2742 if (n > 1) { 2742 if (n > 1) {
2743 cap_nids[nums] = src; 2743 cap_nids[nums] = src;
2744 break; 2744 break;
2745 } else if (n != 1) 2745 } else if (n != 1)
2746 break; 2746 break;
2747 src = *list; 2747 src = *list;
2748 } 2748 }
2749 if (++nums >= max_nums) 2749 if (++nums >= max_nums)
2750 break; 2750 break;
2751 } 2751 }
2752 spec->adc_nids = spec->private_adc_nids; 2752 spec->adc_nids = spec->private_adc_nids;
2753 spec->capsrc_nids = spec->private_capsrc_nids; 2753 spec->capsrc_nids = spec->private_capsrc_nids;
2754 spec->num_adc_nids = nums; 2754 spec->num_adc_nids = nums;
2755 return nums; 2755 return nums;
2756 } 2756 }
2757 2757
2758 /* create playback/capture controls for input pins */ 2758 /* create playback/capture controls for input pins */
2759 static int alc_auto_create_input_ctls(struct hda_codec *codec) 2759 static int alc_auto_create_input_ctls(struct hda_codec *codec)
2760 { 2760 {
2761 struct alc_spec *spec = codec->spec; 2761 struct alc_spec *spec = codec->spec;
2762 const struct auto_pin_cfg *cfg = &spec->autocfg; 2762 const struct auto_pin_cfg *cfg = &spec->autocfg;
2763 hda_nid_t mixer = spec->mixer_nid; 2763 hda_nid_t mixer = spec->mixer_nid;
2764 struct hda_input_mux *imux = &spec->private_imux[0]; 2764 struct hda_input_mux *imux = &spec->private_imux[0];
2765 int num_adcs; 2765 int num_adcs;
2766 int i, c, err, idx, type_idx = 0; 2766 int i, c, err, idx, type_idx = 0;
2767 const char *prev_label = NULL; 2767 const char *prev_label = NULL;
2768 2768
2769 num_adcs = alc_auto_fill_adc_caps(codec); 2769 num_adcs = alc_auto_fill_adc_caps(codec);
2770 if (num_adcs < 0) 2770 if (num_adcs < 0)
2771 return 0; 2771 return 0;
2772 2772
2773 for (i = 0; i < cfg->num_inputs; i++) { 2773 for (i = 0; i < cfg->num_inputs; i++) {
2774 hda_nid_t pin; 2774 hda_nid_t pin;
2775 const char *label; 2775 const char *label;
2776 2776
2777 pin = cfg->inputs[i].pin; 2777 pin = cfg->inputs[i].pin;
2778 if (!alc_is_input_pin(codec, pin)) 2778 if (!alc_is_input_pin(codec, pin))
2779 continue; 2779 continue;
2780 2780
2781 label = hda_get_autocfg_input_label(codec, cfg, i); 2781 label = hda_get_autocfg_input_label(codec, cfg, i);
2782 if (spec->shared_mic_hp && !strcmp(label, "Misc")) 2782 if (spec->shared_mic_hp && !strcmp(label, "Misc"))
2783 label = "Headphone Mic"; 2783 label = "Headphone Mic";
2784 if (prev_label && !strcmp(label, prev_label)) 2784 if (prev_label && !strcmp(label, prev_label))
2785 type_idx++; 2785 type_idx++;
2786 else 2786 else
2787 type_idx = 0; 2787 type_idx = 0;
2788 prev_label = label; 2788 prev_label = label;
2789 2789
2790 if (mixer) { 2790 if (mixer) {
2791 idx = get_connection_index(codec, mixer, pin); 2791 idx = get_connection_index(codec, mixer, pin);
2792 if (idx >= 0) { 2792 if (idx >= 0) {
2793 err = new_analog_input(spec, pin, 2793 err = new_analog_input(spec, pin,
2794 label, type_idx, 2794 label, type_idx,
2795 idx, mixer); 2795 idx, mixer);
2796 if (err < 0) 2796 if (err < 0)
2797 return err; 2797 return err;
2798 } 2798 }
2799 } 2799 }
2800 2800
2801 for (c = 0; c < num_adcs; c++) { 2801 for (c = 0; c < num_adcs; c++) {
2802 hda_nid_t cap = get_capsrc(spec, c); 2802 hda_nid_t cap = get_capsrc(spec, c);
2803 idx = get_connection_index(codec, cap, pin); 2803 idx = get_connection_index(codec, cap, pin);
2804 if (idx >= 0) { 2804 if (idx >= 0) {
2805 spec->imux_pins[imux->num_items] = pin; 2805 spec->imux_pins[imux->num_items] = pin;
2806 snd_hda_add_imux_item(imux, label, idx, NULL); 2806 snd_hda_add_imux_item(imux, label, idx, NULL);
2807 break; 2807 break;
2808 } 2808 }
2809 } 2809 }
2810 } 2810 }
2811 2811
2812 spec->num_mux_defs = 1; 2812 spec->num_mux_defs = 1;
2813 spec->input_mux = imux; 2813 spec->input_mux = imux;
2814 2814
2815 return 0; 2815 return 0;
2816 } 2816 }
2817 2817
2818 /* create a shared input with the headphone out */ 2818 /* create a shared input with the headphone out */
2819 static int alc_auto_create_shared_input(struct hda_codec *codec) 2819 static int alc_auto_create_shared_input(struct hda_codec *codec)
2820 { 2820 {
2821 struct alc_spec *spec = codec->spec; 2821 struct alc_spec *spec = codec->spec;
2822 struct auto_pin_cfg *cfg = &spec->autocfg; 2822 struct auto_pin_cfg *cfg = &spec->autocfg;
2823 unsigned int defcfg; 2823 unsigned int defcfg;
2824 hda_nid_t nid; 2824 hda_nid_t nid;
2825 2825
2826 /* only one internal input pin? */ 2826 /* only one internal input pin? */
2827 if (cfg->num_inputs != 1) 2827 if (cfg->num_inputs != 1)
2828 return 0; 2828 return 0;
2829 defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); 2829 defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin);
2830 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) 2830 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
2831 return 0; 2831 return 0;
2832 2832
2833 if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) 2833 if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
2834 nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */ 2834 nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */
2835 else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT) 2835 else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT)
2836 nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */ 2836 nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */
2837 else 2837 else
2838 return 0; /* both not available */ 2838 return 0; /* both not available */
2839 2839
2840 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN)) 2840 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN))
2841 return 0; /* no input */ 2841 return 0; /* no input */
2842 2842
2843 cfg->inputs[1].pin = nid; 2843 cfg->inputs[1].pin = nid;
2844 cfg->inputs[1].type = AUTO_PIN_MIC; 2844 cfg->inputs[1].type = AUTO_PIN_MIC;
2845 cfg->num_inputs = 2; 2845 cfg->num_inputs = 2;
2846 spec->shared_mic_hp = 1; 2846 spec->shared_mic_hp = 1;
2847 snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid); 2847 snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid);
2848 return 0; 2848 return 0;
2849 } 2849 }
2850 2850
2851 static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, 2851 static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
2852 unsigned int pin_type) 2852 unsigned int pin_type)
2853 { 2853 {
2854 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 2854 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2855 pin_type); 2855 pin_type);
2856 /* unmute pin */ 2856 /* unmute pin */
2857 if (nid_has_mute(codec, nid, HDA_OUTPUT)) 2857 if (nid_has_mute(codec, nid, HDA_OUTPUT))
2858 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 2858 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2859 AMP_OUT_UNMUTE); 2859 AMP_OUT_UNMUTE);
2860 } 2860 }
2861 2861
2862 static int get_pin_type(int line_out_type) 2862 static int get_pin_type(int line_out_type)
2863 { 2863 {
2864 if (line_out_type == AUTO_PIN_HP_OUT) 2864 if (line_out_type == AUTO_PIN_HP_OUT)
2865 return PIN_HP; 2865 return PIN_HP;
2866 else 2866 else
2867 return PIN_OUT; 2867 return PIN_OUT;
2868 } 2868 }
2869 2869
2870 static void alc_auto_init_analog_input(struct hda_codec *codec) 2870 static void alc_auto_init_analog_input(struct hda_codec *codec)
2871 { 2871 {
2872 struct alc_spec *spec = codec->spec; 2872 struct alc_spec *spec = codec->spec;
2873 struct auto_pin_cfg *cfg = &spec->autocfg; 2873 struct auto_pin_cfg *cfg = &spec->autocfg;
2874 int i; 2874 int i;
2875 2875
2876 for (i = 0; i < cfg->num_inputs; i++) { 2876 for (i = 0; i < cfg->num_inputs; i++) {
2877 hda_nid_t nid = cfg->inputs[i].pin; 2877 hda_nid_t nid = cfg->inputs[i].pin;
2878 if (alc_is_input_pin(codec, nid)) { 2878 if (alc_is_input_pin(codec, nid)) {
2879 alc_set_input_pin(codec, nid, cfg->inputs[i].type); 2879 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
2880 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) 2880 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
2881 snd_hda_codec_write(codec, nid, 0, 2881 snd_hda_codec_write(codec, nid, 0,
2882 AC_VERB_SET_AMP_GAIN_MUTE, 2882 AC_VERB_SET_AMP_GAIN_MUTE,
2883 AMP_OUT_MUTE); 2883 AMP_OUT_MUTE);
2884 } 2884 }
2885 } 2885 }
2886 2886
2887 /* mute all loopback inputs */ 2887 /* mute all loopback inputs */
2888 if (spec->mixer_nid) { 2888 if (spec->mixer_nid) {
2889 int nums = snd_hda_get_conn_list(codec, spec->mixer_nid, NULL); 2889 int nums = snd_hda_get_conn_list(codec, spec->mixer_nid, NULL);
2890 for (i = 0; i < nums; i++) 2890 for (i = 0; i < nums; i++)
2891 snd_hda_codec_write(codec, spec->mixer_nid, 0, 2891 snd_hda_codec_write(codec, spec->mixer_nid, 0,
2892 AC_VERB_SET_AMP_GAIN_MUTE, 2892 AC_VERB_SET_AMP_GAIN_MUTE,
2893 AMP_IN_MUTE(i)); 2893 AMP_IN_MUTE(i));
2894 } 2894 }
2895 } 2895 }
2896 2896
2897 /* convert from MIX nid to DAC */ 2897 /* convert from MIX nid to DAC */
2898 static hda_nid_t alc_auto_mix_to_dac(struct hda_codec *codec, hda_nid_t nid) 2898 static hda_nid_t alc_auto_mix_to_dac(struct hda_codec *codec, hda_nid_t nid)
2899 { 2899 {
2900 hda_nid_t list[5]; 2900 hda_nid_t list[5];
2901 int i, num; 2901 int i, num;
2902 2902
2903 if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_AUD_OUT) 2903 if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_AUD_OUT)
2904 return nid; 2904 return nid;
2905 num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list)); 2905 num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list));
2906 for (i = 0; i < num; i++) { 2906 for (i = 0; i < num; i++) {
2907 if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT) 2907 if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT)
2908 return list[i]; 2908 return list[i];
2909 } 2909 }
2910 return 0; 2910 return 0;
2911 } 2911 }
2912 2912
2913 /* go down to the selector widget before the mixer */ 2913 /* go down to the selector widget before the mixer */
2914 static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin) 2914 static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin)
2915 { 2915 {
2916 hda_nid_t srcs[5]; 2916 hda_nid_t srcs[5];
2917 int num = snd_hda_get_connections(codec, pin, srcs, 2917 int num = snd_hda_get_connections(codec, pin, srcs,
2918 ARRAY_SIZE(srcs)); 2918 ARRAY_SIZE(srcs));
2919 if (num != 1 || 2919 if (num != 1 ||
2920 get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL) 2920 get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL)
2921 return pin; 2921 return pin;
2922 return srcs[0]; 2922 return srcs[0];
2923 } 2923 }
2924 2924
2925 /* get MIX nid connected to the given pin targeted to DAC */ 2925 /* get MIX nid connected to the given pin targeted to DAC */
2926 static hda_nid_t alc_auto_dac_to_mix(struct hda_codec *codec, hda_nid_t pin, 2926 static hda_nid_t alc_auto_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
2927 hda_nid_t dac) 2927 hda_nid_t dac)
2928 { 2928 {
2929 hda_nid_t mix[5]; 2929 hda_nid_t mix[5];
2930 int i, num; 2930 int i, num;
2931 2931
2932 pin = alc_go_down_to_selector(codec, pin); 2932 pin = alc_go_down_to_selector(codec, pin);
2933 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); 2933 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
2934 for (i = 0; i < num; i++) { 2934 for (i = 0; i < num; i++) {
2935 if (alc_auto_mix_to_dac(codec, mix[i]) == dac) 2935 if (alc_auto_mix_to_dac(codec, mix[i]) == dac)
2936 return mix[i]; 2936 return mix[i];
2937 } 2937 }
2938 return 0; 2938 return 0;
2939 } 2939 }
2940 2940
2941 /* select the connection from pin to DAC if needed */ 2941 /* select the connection from pin to DAC if needed */
2942 static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin, 2942 static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin,
2943 hda_nid_t dac) 2943 hda_nid_t dac)
2944 { 2944 {
2945 hda_nid_t mix[5]; 2945 hda_nid_t mix[5];
2946 int i, num; 2946 int i, num;
2947 2947
2948 pin = alc_go_down_to_selector(codec, pin); 2948 pin = alc_go_down_to_selector(codec, pin);
2949 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); 2949 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
2950 if (num < 2) 2950 if (num < 2)
2951 return 0; 2951 return 0;
2952 for (i = 0; i < num; i++) { 2952 for (i = 0; i < num; i++) {
2953 if (alc_auto_mix_to_dac(codec, mix[i]) == dac) { 2953 if (alc_auto_mix_to_dac(codec, mix[i]) == dac) {
2954 snd_hda_codec_update_cache(codec, pin, 0, 2954 snd_hda_codec_update_cache(codec, pin, 0,
2955 AC_VERB_SET_CONNECT_SEL, i); 2955 AC_VERB_SET_CONNECT_SEL, i);
2956 return 0; 2956 return 0;
2957 } 2957 }
2958 } 2958 }
2959 return 0; 2959 return 0;
2960 } 2960 }
2961 2961
2962 static bool alc_is_dac_already_used(struct hda_codec *codec, hda_nid_t nid) 2962 static bool alc_is_dac_already_used(struct hda_codec *codec, hda_nid_t nid)
2963 { 2963 {
2964 struct alc_spec *spec = codec->spec; 2964 struct alc_spec *spec = codec->spec;
2965 int i; 2965 int i;
2966 if (found_in_nid_list(nid, spec->multiout.dac_nids, 2966 if (found_in_nid_list(nid, spec->multiout.dac_nids,
2967 ARRAY_SIZE(spec->private_dac_nids)) || 2967 ARRAY_SIZE(spec->private_dac_nids)) ||
2968 found_in_nid_list(nid, spec->multiout.hp_out_nid, 2968 found_in_nid_list(nid, spec->multiout.hp_out_nid,
2969 ARRAY_SIZE(spec->multiout.hp_out_nid)) || 2969 ARRAY_SIZE(spec->multiout.hp_out_nid)) ||
2970 found_in_nid_list(nid, spec->multiout.extra_out_nid, 2970 found_in_nid_list(nid, spec->multiout.extra_out_nid,
2971 ARRAY_SIZE(spec->multiout.extra_out_nid))) 2971 ARRAY_SIZE(spec->multiout.extra_out_nid)))
2972 return true; 2972 return true;
2973 for (i = 0; i < spec->multi_ios; i++) { 2973 for (i = 0; i < spec->multi_ios; i++) {
2974 if (spec->multi_io[i].dac == nid) 2974 if (spec->multi_io[i].dac == nid)
2975 return true; 2975 return true;
2976 } 2976 }
2977 return false; 2977 return false;
2978 } 2978 }
2979 2979
2980 /* look for an empty DAC slot */ 2980 /* look for an empty DAC slot */
2981 static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin) 2981 static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
2982 { 2982 {
2983 hda_nid_t srcs[5]; 2983 hda_nid_t srcs[5];
2984 int i, num; 2984 int i, num;
2985 2985
2986 pin = alc_go_down_to_selector(codec, pin); 2986 pin = alc_go_down_to_selector(codec, pin);
2987 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs)); 2987 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
2988 for (i = 0; i < num; i++) { 2988 for (i = 0; i < num; i++) {
2989 hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]); 2989 hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]);
2990 if (!nid) 2990 if (!nid)
2991 continue; 2991 continue;
2992 if (!alc_is_dac_already_used(codec, nid)) 2992 if (!alc_is_dac_already_used(codec, nid))
2993 return nid; 2993 return nid;
2994 } 2994 }
2995 return 0; 2995 return 0;
2996 } 2996 }
2997 2997
2998 /* check whether the DAC is reachable from the pin */ 2998 /* check whether the DAC is reachable from the pin */
2999 static bool alc_auto_is_dac_reachable(struct hda_codec *codec, 2999 static bool alc_auto_is_dac_reachable(struct hda_codec *codec,
3000 hda_nid_t pin, hda_nid_t dac) 3000 hda_nid_t pin, hda_nid_t dac)
3001 { 3001 {
3002 hda_nid_t srcs[5]; 3002 hda_nid_t srcs[5];
3003 int i, num; 3003 int i, num;
3004 3004
3005 if (!pin || !dac) 3005 if (!pin || !dac)
3006 return false; 3006 return false;
3007 pin = alc_go_down_to_selector(codec, pin); 3007 pin = alc_go_down_to_selector(codec, pin);
3008 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs)); 3008 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
3009 for (i = 0; i < num; i++) { 3009 for (i = 0; i < num; i++) {
3010 hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]); 3010 hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]);
3011 if (nid == dac) 3011 if (nid == dac)
3012 return true; 3012 return true;
3013 } 3013 }
3014 return false; 3014 return false;
3015 } 3015 }
3016 3016
3017 static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) 3017 static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin)
3018 { 3018 {
3019 struct alc_spec *spec = codec->spec; 3019 struct alc_spec *spec = codec->spec;
3020 hda_nid_t sel = alc_go_down_to_selector(codec, pin); 3020 hda_nid_t sel = alc_go_down_to_selector(codec, pin);
3021 hda_nid_t nid, nid_found, srcs[5]; 3021 hda_nid_t nid, nid_found, srcs[5];
3022 int i, num = snd_hda_get_connections(codec, sel, srcs, 3022 int i, num = snd_hda_get_connections(codec, sel, srcs,
3023 ARRAY_SIZE(srcs)); 3023 ARRAY_SIZE(srcs));
3024 if (num == 1) 3024 if (num == 1)
3025 return alc_auto_look_for_dac(codec, pin); 3025 return alc_auto_look_for_dac(codec, pin);
3026 nid_found = 0; 3026 nid_found = 0;
3027 for (i = 0; i < num; i++) { 3027 for (i = 0; i < num; i++) {
3028 if (srcs[i] == spec->mixer_nid) 3028 if (srcs[i] == spec->mixer_nid)
3029 continue; 3029 continue;
3030 nid = alc_auto_mix_to_dac(codec, srcs[i]); 3030 nid = alc_auto_mix_to_dac(codec, srcs[i]);
3031 if (nid && !alc_is_dac_already_used(codec, nid)) { 3031 if (nid && !alc_is_dac_already_used(codec, nid)) {
3032 if (nid_found) 3032 if (nid_found)
3033 return 0; 3033 return 0;
3034 nid_found = nid; 3034 nid_found = nid;
3035 } 3035 }
3036 } 3036 }
3037 return nid_found; 3037 return nid_found;
3038 } 3038 }
3039 3039
3040 /* mark up volume and mute control NIDs: used during badness parsing and 3040 /* mark up volume and mute control NIDs: used during badness parsing and
3041 * at creating actual controls 3041 * at creating actual controls
3042 */ 3042 */
3043 static inline unsigned int get_ctl_pos(unsigned int data) 3043 static inline unsigned int get_ctl_pos(unsigned int data)
3044 { 3044 {
3045 hda_nid_t nid = get_amp_nid_(data); 3045 hda_nid_t nid = get_amp_nid_(data);
3046 unsigned int dir; 3046 unsigned int dir;
3047 if (snd_BUG_ON(nid >= MAX_VOL_NIDS)) 3047 if (snd_BUG_ON(nid >= MAX_VOL_NIDS))
3048 return 0; 3048 return 0;
3049 dir = get_amp_direction_(data); 3049 dir = get_amp_direction_(data);
3050 return (nid << 1) | dir; 3050 return (nid << 1) | dir;
3051 } 3051 }
3052 3052
3053 #define is_ctl_used(bits, data) \ 3053 #define is_ctl_used(bits, data) \
3054 test_bit(get_ctl_pos(data), bits) 3054 test_bit(get_ctl_pos(data), bits)
3055 #define mark_ctl_usage(bits, data) \ 3055 #define mark_ctl_usage(bits, data) \
3056 set_bit(get_ctl_pos(data), bits) 3056 set_bit(get_ctl_pos(data), bits)
3057 3057
3058 static void clear_vol_marks(struct hda_codec *codec) 3058 static void clear_vol_marks(struct hda_codec *codec)
3059 { 3059 {
3060 struct alc_spec *spec = codec->spec; 3060 struct alc_spec *spec = codec->spec;
3061 memset(spec->vol_ctls, 0, sizeof(spec->vol_ctls)); 3061 memset(spec->vol_ctls, 0, sizeof(spec->vol_ctls));
3062 memset(spec->sw_ctls, 0, sizeof(spec->sw_ctls)); 3062 memset(spec->sw_ctls, 0, sizeof(spec->sw_ctls));
3063 } 3063 }
3064 3064
3065 /* badness definition */ 3065 /* badness definition */
3066 enum { 3066 enum {
3067 /* No primary DAC is found for the main output */ 3067 /* No primary DAC is found for the main output */
3068 BAD_NO_PRIMARY_DAC = 0x10000, 3068 BAD_NO_PRIMARY_DAC = 0x10000,
3069 /* No DAC is found for the extra output */ 3069 /* No DAC is found for the extra output */
3070 BAD_NO_DAC = 0x4000, 3070 BAD_NO_DAC = 0x4000,
3071 /* No possible multi-ios */ 3071 /* No possible multi-ios */
3072 BAD_MULTI_IO = 0x103, 3072 BAD_MULTI_IO = 0x103,
3073 /* No individual DAC for extra output */ 3073 /* No individual DAC for extra output */
3074 BAD_NO_EXTRA_DAC = 0x102, 3074 BAD_NO_EXTRA_DAC = 0x102,
3075 /* No individual DAC for extra surrounds */ 3075 /* No individual DAC for extra surrounds */
3076 BAD_NO_EXTRA_SURR_DAC = 0x101, 3076 BAD_NO_EXTRA_SURR_DAC = 0x101,
3077 /* Primary DAC shared with main surrounds */ 3077 /* Primary DAC shared with main surrounds */
3078 BAD_SHARED_SURROUND = 0x100, 3078 BAD_SHARED_SURROUND = 0x100,
3079 /* Primary DAC shared with main CLFE */ 3079 /* Primary DAC shared with main CLFE */
3080 BAD_SHARED_CLFE = 0x10, 3080 BAD_SHARED_CLFE = 0x10,
3081 /* Primary DAC shared with extra surrounds */ 3081 /* Primary DAC shared with extra surrounds */
3082 BAD_SHARED_EXTRA_SURROUND = 0x10, 3082 BAD_SHARED_EXTRA_SURROUND = 0x10,
3083 /* Volume widget is shared */ 3083 /* Volume widget is shared */
3084 BAD_SHARED_VOL = 0x10, 3084 BAD_SHARED_VOL = 0x10,
3085 }; 3085 };
3086 3086
3087 static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, 3087 static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec,
3088 hda_nid_t pin, hda_nid_t dac); 3088 hda_nid_t pin, hda_nid_t dac);
3089 static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, 3089 static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec,
3090 hda_nid_t pin, hda_nid_t dac); 3090 hda_nid_t pin, hda_nid_t dac);
3091 3091
3092 static int eval_shared_vol_badness(struct hda_codec *codec, hda_nid_t pin, 3092 static int eval_shared_vol_badness(struct hda_codec *codec, hda_nid_t pin,
3093 hda_nid_t dac) 3093 hda_nid_t dac)
3094 { 3094 {
3095 struct alc_spec *spec = codec->spec; 3095 struct alc_spec *spec = codec->spec;
3096 hda_nid_t nid; 3096 hda_nid_t nid;
3097 unsigned int val; 3097 unsigned int val;
3098 int badness = 0; 3098 int badness = 0;
3099 3099
3100 nid = alc_look_for_out_vol_nid(codec, pin, dac); 3100 nid = alc_look_for_out_vol_nid(codec, pin, dac);
3101 if (nid) { 3101 if (nid) {
3102 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); 3102 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3103 if (is_ctl_used(spec->vol_ctls, nid)) 3103 if (is_ctl_used(spec->vol_ctls, nid))
3104 badness += BAD_SHARED_VOL; 3104 badness += BAD_SHARED_VOL;
3105 else 3105 else
3106 mark_ctl_usage(spec->vol_ctls, val); 3106 mark_ctl_usage(spec->vol_ctls, val);
3107 } else 3107 } else
3108 badness += BAD_SHARED_VOL; 3108 badness += BAD_SHARED_VOL;
3109 nid = alc_look_for_out_mute_nid(codec, pin, dac); 3109 nid = alc_look_for_out_mute_nid(codec, pin, dac);
3110 if (nid) { 3110 if (nid) {
3111 unsigned int wid_type = get_wcaps_type(get_wcaps(codec, nid)); 3111 unsigned int wid_type = get_wcaps_type(get_wcaps(codec, nid));
3112 if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) 3112 if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT)
3113 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); 3113 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3114 else 3114 else
3115 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); 3115 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT);
3116 if (is_ctl_used(spec->sw_ctls, val)) 3116 if (is_ctl_used(spec->sw_ctls, val))
3117 badness += BAD_SHARED_VOL; 3117 badness += BAD_SHARED_VOL;
3118 else 3118 else
3119 mark_ctl_usage(spec->sw_ctls, val); 3119 mark_ctl_usage(spec->sw_ctls, val);
3120 } else 3120 } else
3121 badness += BAD_SHARED_VOL; 3121 badness += BAD_SHARED_VOL;
3122 return badness; 3122 return badness;
3123 } 3123 }
3124 3124
3125 struct badness_table { 3125 struct badness_table {
3126 int no_primary_dac; /* no primary DAC */ 3126 int no_primary_dac; /* no primary DAC */
3127 int no_dac; /* no secondary DACs */ 3127 int no_dac; /* no secondary DACs */
3128 int shared_primary; /* primary DAC is shared with main output */ 3128 int shared_primary; /* primary DAC is shared with main output */
3129 int shared_surr; /* secondary DAC shared with main or primary */ 3129 int shared_surr; /* secondary DAC shared with main or primary */
3130 int shared_clfe; /* third DAC shared with main or primary */ 3130 int shared_clfe; /* third DAC shared with main or primary */
3131 int shared_surr_main; /* secondary DAC sahred with main/DAC0 */ 3131 int shared_surr_main; /* secondary DAC sahred with main/DAC0 */
3132 }; 3132 };
3133 3133
3134 static struct badness_table main_out_badness = { 3134 static struct badness_table main_out_badness = {
3135 .no_primary_dac = BAD_NO_PRIMARY_DAC, 3135 .no_primary_dac = BAD_NO_PRIMARY_DAC,
3136 .no_dac = BAD_NO_DAC, 3136 .no_dac = BAD_NO_DAC,
3137 .shared_primary = BAD_NO_PRIMARY_DAC, 3137 .shared_primary = BAD_NO_PRIMARY_DAC,
3138 .shared_surr = BAD_SHARED_SURROUND, 3138 .shared_surr = BAD_SHARED_SURROUND,
3139 .shared_clfe = BAD_SHARED_CLFE, 3139 .shared_clfe = BAD_SHARED_CLFE,
3140 .shared_surr_main = BAD_SHARED_SURROUND, 3140 .shared_surr_main = BAD_SHARED_SURROUND,
3141 }; 3141 };
3142 3142
3143 static struct badness_table extra_out_badness = { 3143 static struct badness_table extra_out_badness = {
3144 .no_primary_dac = BAD_NO_DAC, 3144 .no_primary_dac = BAD_NO_DAC,
3145 .no_dac = BAD_NO_DAC, 3145 .no_dac = BAD_NO_DAC,
3146 .shared_primary = BAD_NO_EXTRA_DAC, 3146 .shared_primary = BAD_NO_EXTRA_DAC,
3147 .shared_surr = BAD_SHARED_EXTRA_SURROUND, 3147 .shared_surr = BAD_SHARED_EXTRA_SURROUND,
3148 .shared_clfe = BAD_SHARED_EXTRA_SURROUND, 3148 .shared_clfe = BAD_SHARED_EXTRA_SURROUND,
3149 .shared_surr_main = BAD_NO_EXTRA_SURR_DAC, 3149 .shared_surr_main = BAD_NO_EXTRA_SURR_DAC,
3150 }; 3150 };
3151 3151
3152 /* try to assign DACs to pins and return the resultant badness */ 3152 /* try to assign DACs to pins and return the resultant badness */
3153 static int alc_auto_fill_dacs(struct hda_codec *codec, int num_outs, 3153 static int alc_auto_fill_dacs(struct hda_codec *codec, int num_outs,
3154 const hda_nid_t *pins, hda_nid_t *dacs, 3154 const hda_nid_t *pins, hda_nid_t *dacs,
3155 const struct badness_table *bad) 3155 const struct badness_table *bad)
3156 { 3156 {
3157 struct alc_spec *spec = codec->spec; 3157 struct alc_spec *spec = codec->spec;
3158 struct auto_pin_cfg *cfg = &spec->autocfg; 3158 struct auto_pin_cfg *cfg = &spec->autocfg;
3159 int i, j; 3159 int i, j;
3160 int badness = 0; 3160 int badness = 0;
3161 hda_nid_t dac; 3161 hda_nid_t dac;
3162 3162
3163 if (!num_outs) 3163 if (!num_outs)
3164 return 0; 3164 return 0;
3165 3165
3166 for (i = 0; i < num_outs; i++) { 3166 for (i = 0; i < num_outs; i++) {
3167 hda_nid_t pin = pins[i]; 3167 hda_nid_t pin = pins[i];
3168 if (!dacs[i]) 3168 if (!dacs[i])
3169 dacs[i] = alc_auto_look_for_dac(codec, pin); 3169 dacs[i] = alc_auto_look_for_dac(codec, pin);
3170 if (!dacs[i] && !i) { 3170 if (!dacs[i] && !i) {
3171 for (j = 1; j < num_outs; j++) { 3171 for (j = 1; j < num_outs; j++) {
3172 if (alc_auto_is_dac_reachable(codec, pin, dacs[j])) { 3172 if (alc_auto_is_dac_reachable(codec, pin, dacs[j])) {
3173 dacs[0] = dacs[j]; 3173 dacs[0] = dacs[j];
3174 dacs[j] = 0; 3174 dacs[j] = 0;
3175 break; 3175 break;
3176 } 3176 }
3177 } 3177 }
3178 } 3178 }
3179 dac = dacs[i]; 3179 dac = dacs[i];
3180 if (!dac) { 3180 if (!dac) {
3181 if (alc_auto_is_dac_reachable(codec, pin, dacs[0])) 3181 if (alc_auto_is_dac_reachable(codec, pin, dacs[0]))
3182 dac = dacs[0]; 3182 dac = dacs[0];
3183 else if (cfg->line_outs > i && 3183 else if (cfg->line_outs > i &&
3184 alc_auto_is_dac_reachable(codec, pin, 3184 alc_auto_is_dac_reachable(codec, pin,
3185 spec->private_dac_nids[i])) 3185 spec->private_dac_nids[i]))
3186 dac = spec->private_dac_nids[i]; 3186 dac = spec->private_dac_nids[i];
3187 if (dac) { 3187 if (dac) {
3188 if (!i) 3188 if (!i)
3189 badness += bad->shared_primary; 3189 badness += bad->shared_primary;
3190 else if (i == 1) 3190 else if (i == 1)
3191 badness += bad->shared_surr; 3191 badness += bad->shared_surr;
3192 else 3192 else
3193 badness += bad->shared_clfe; 3193 badness += bad->shared_clfe;
3194 } else if (alc_auto_is_dac_reachable(codec, pin, 3194 } else if (alc_auto_is_dac_reachable(codec, pin,
3195 spec->private_dac_nids[0])) { 3195 spec->private_dac_nids[0])) {
3196 dac = spec->private_dac_nids[0]; 3196 dac = spec->private_dac_nids[0];
3197 badness += bad->shared_surr_main; 3197 badness += bad->shared_surr_main;
3198 } else if (!i) 3198 } else if (!i)
3199 badness += bad->no_primary_dac; 3199 badness += bad->no_primary_dac;
3200 else 3200 else
3201 badness += bad->no_dac; 3201 badness += bad->no_dac;
3202 } 3202 }
3203 if (dac) 3203 if (dac)
3204 badness += eval_shared_vol_badness(codec, pin, dac); 3204 badness += eval_shared_vol_badness(codec, pin, dac);
3205 } 3205 }
3206 3206
3207 return badness; 3207 return badness;
3208 } 3208 }
3209 3209
3210 static int alc_auto_fill_multi_ios(struct hda_codec *codec, 3210 static int alc_auto_fill_multi_ios(struct hda_codec *codec,
3211 hda_nid_t reference_pin, 3211 hda_nid_t reference_pin,
3212 bool hardwired, int offset); 3212 bool hardwired, int offset);
3213 3213
3214 static bool alc_map_singles(struct hda_codec *codec, int outs, 3214 static bool alc_map_singles(struct hda_codec *codec, int outs,
3215 const hda_nid_t *pins, hda_nid_t *dacs) 3215 const hda_nid_t *pins, hda_nid_t *dacs)
3216 { 3216 {
3217 int i; 3217 int i;
3218 bool found = false; 3218 bool found = false;
3219 for (i = 0; i < outs; i++) { 3219 for (i = 0; i < outs; i++) {
3220 if (dacs[i]) 3220 if (dacs[i])
3221 continue; 3221 continue;
3222 dacs[i] = get_dac_if_single(codec, pins[i]); 3222 dacs[i] = get_dac_if_single(codec, pins[i]);
3223 if (dacs[i]) 3223 if (dacs[i])
3224 found = true; 3224 found = true;
3225 } 3225 }
3226 return found; 3226 return found;
3227 } 3227 }
3228 3228
3229 /* fill in the dac_nids table from the parsed pin configuration */ 3229 /* fill in the dac_nids table from the parsed pin configuration */
3230 static int fill_and_eval_dacs(struct hda_codec *codec, 3230 static int fill_and_eval_dacs(struct hda_codec *codec,
3231 bool fill_hardwired, 3231 bool fill_hardwired,
3232 bool fill_mio_first) 3232 bool fill_mio_first)
3233 { 3233 {
3234 struct alc_spec *spec = codec->spec; 3234 struct alc_spec *spec = codec->spec;
3235 struct auto_pin_cfg *cfg = &spec->autocfg; 3235 struct auto_pin_cfg *cfg = &spec->autocfg;
3236 int i, err, badness; 3236 int i, err, badness;
3237 3237
3238 /* set num_dacs once to full for alc_auto_look_for_dac() */ 3238 /* set num_dacs once to full for alc_auto_look_for_dac() */
3239 spec->multiout.num_dacs = cfg->line_outs; 3239 spec->multiout.num_dacs = cfg->line_outs;
3240 spec->multiout.dac_nids = spec->private_dac_nids; 3240 spec->multiout.dac_nids = spec->private_dac_nids;
3241 memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); 3241 memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids));
3242 memset(spec->multiout.hp_out_nid, 0, sizeof(spec->multiout.hp_out_nid)); 3242 memset(spec->multiout.hp_out_nid, 0, sizeof(spec->multiout.hp_out_nid));
3243 memset(spec->multiout.extra_out_nid, 0, sizeof(spec->multiout.extra_out_nid)); 3243 memset(spec->multiout.extra_out_nid, 0, sizeof(spec->multiout.extra_out_nid));
3244 spec->multi_ios = 0; 3244 spec->multi_ios = 0;
3245 clear_vol_marks(codec); 3245 clear_vol_marks(codec);
3246 badness = 0; 3246 badness = 0;
3247 3247
3248 /* fill hard-wired DACs first */ 3248 /* fill hard-wired DACs first */
3249 if (fill_hardwired) { 3249 if (fill_hardwired) {
3250 bool mapped; 3250 bool mapped;
3251 do { 3251 do {
3252 mapped = alc_map_singles(codec, cfg->line_outs, 3252 mapped = alc_map_singles(codec, cfg->line_outs,
3253 cfg->line_out_pins, 3253 cfg->line_out_pins,
3254 spec->private_dac_nids); 3254 spec->private_dac_nids);
3255 mapped |= alc_map_singles(codec, cfg->hp_outs, 3255 mapped |= alc_map_singles(codec, cfg->hp_outs,
3256 cfg->hp_pins, 3256 cfg->hp_pins,
3257 spec->multiout.hp_out_nid); 3257 spec->multiout.hp_out_nid);
3258 mapped |= alc_map_singles(codec, cfg->speaker_outs, 3258 mapped |= alc_map_singles(codec, cfg->speaker_outs,
3259 cfg->speaker_pins, 3259 cfg->speaker_pins,
3260 spec->multiout.extra_out_nid); 3260 spec->multiout.extra_out_nid);
3261 if (fill_mio_first && cfg->line_outs == 1 && 3261 if (fill_mio_first && cfg->line_outs == 1 &&
3262 cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { 3262 cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
3263 err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], true, 0); 3263 err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], true, 0);
3264 if (!err) 3264 if (!err)
3265 mapped = true; 3265 mapped = true;
3266 } 3266 }
3267 } while (mapped); 3267 } while (mapped);
3268 } 3268 }
3269 3269
3270 badness += alc_auto_fill_dacs(codec, cfg->line_outs, cfg->line_out_pins, 3270 badness += alc_auto_fill_dacs(codec, cfg->line_outs, cfg->line_out_pins,
3271 spec->private_dac_nids, 3271 spec->private_dac_nids,
3272 &main_out_badness); 3272 &main_out_badness);
3273 3273
3274 /* re-count num_dacs and squash invalid entries */ 3274 /* re-count num_dacs and squash invalid entries */
3275 spec->multiout.num_dacs = 0; 3275 spec->multiout.num_dacs = 0;
3276 for (i = 0; i < cfg->line_outs; i++) { 3276 for (i = 0; i < cfg->line_outs; i++) {
3277 if (spec->private_dac_nids[i]) 3277 if (spec->private_dac_nids[i])
3278 spec->multiout.num_dacs++; 3278 spec->multiout.num_dacs++;
3279 else { 3279 else {
3280 memmove(spec->private_dac_nids + i, 3280 memmove(spec->private_dac_nids + i,
3281 spec->private_dac_nids + i + 1, 3281 spec->private_dac_nids + i + 1,
3282 sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); 3282 sizeof(hda_nid_t) * (cfg->line_outs - i - 1));
3283 spec->private_dac_nids[cfg->line_outs - 1] = 0; 3283 spec->private_dac_nids[cfg->line_outs - 1] = 0;
3284 } 3284 }
3285 } 3285 }
3286 3286
3287 if (fill_mio_first && 3287 if (fill_mio_first &&
3288 cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { 3288 cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
3289 /* try to fill multi-io first */ 3289 /* try to fill multi-io first */
3290 err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], false, 0); 3290 err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], false, 0);
3291 if (err < 0) 3291 if (err < 0)
3292 return err; 3292 return err;
3293 /* we don't count badness at this stage yet */ 3293 /* we don't count badness at this stage yet */
3294 } 3294 }
3295 3295
3296 if (cfg->line_out_type != AUTO_PIN_HP_OUT) { 3296 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
3297 err = alc_auto_fill_dacs(codec, cfg->hp_outs, cfg->hp_pins, 3297 err = alc_auto_fill_dacs(codec, cfg->hp_outs, cfg->hp_pins,
3298 spec->multiout.hp_out_nid, 3298 spec->multiout.hp_out_nid,
3299 &extra_out_badness); 3299 &extra_out_badness);
3300 if (err < 0) 3300 if (err < 0)
3301 return err; 3301 return err;
3302 badness += err; 3302 badness += err;
3303 } 3303 }
3304 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { 3304 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
3305 err = alc_auto_fill_dacs(codec, cfg->speaker_outs, 3305 err = alc_auto_fill_dacs(codec, cfg->speaker_outs,
3306 cfg->speaker_pins, 3306 cfg->speaker_pins,
3307 spec->multiout.extra_out_nid, 3307 spec->multiout.extra_out_nid,
3308 &extra_out_badness); 3308 &extra_out_badness);
3309 if (err < 0) 3309 if (err < 0)
3310 return err; 3310 return err;
3311 badness += err; 3311 badness += err;
3312 } 3312 }
3313 if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { 3313 if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
3314 err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], false, 0); 3314 err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], false, 0);
3315 if (err < 0) 3315 if (err < 0)
3316 return err; 3316 return err;
3317 badness += err; 3317 badness += err;
3318 } 3318 }
3319 if (cfg->hp_outs && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { 3319 if (cfg->hp_outs && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
3320 /* try multi-ios with HP + inputs */ 3320 /* try multi-ios with HP + inputs */
3321 int offset = 0; 3321 int offset = 0;
3322 if (cfg->line_outs >= 3) 3322 if (cfg->line_outs >= 3)
3323 offset = 1; 3323 offset = 1;
3324 err = alc_auto_fill_multi_ios(codec, cfg->hp_pins[0], false, 3324 err = alc_auto_fill_multi_ios(codec, cfg->hp_pins[0], false,
3325 offset); 3325 offset);
3326 if (err < 0) 3326 if (err < 0)
3327 return err; 3327 return err;
3328 badness += err; 3328 badness += err;
3329 } 3329 }
3330 3330
3331 if (spec->multi_ios == 2) { 3331 if (spec->multi_ios == 2) {
3332 for (i = 0; i < 2; i++) 3332 for (i = 0; i < 2; i++)
3333 spec->private_dac_nids[spec->multiout.num_dacs++] = 3333 spec->private_dac_nids[spec->multiout.num_dacs++] =
3334 spec->multi_io[i].dac; 3334 spec->multi_io[i].dac;
3335 spec->ext_channel_count = 2; 3335 spec->ext_channel_count = 2;
3336 } else if (spec->multi_ios) { 3336 } else if (spec->multi_ios) {
3337 spec->multi_ios = 0; 3337 spec->multi_ios = 0;
3338 badness += BAD_MULTI_IO; 3338 badness += BAD_MULTI_IO;
3339 } 3339 }
3340 3340
3341 return badness; 3341 return badness;
3342 } 3342 }
3343 3343
3344 #define DEBUG_BADNESS 3344 #define DEBUG_BADNESS
3345 3345
3346 #ifdef DEBUG_BADNESS 3346 #ifdef DEBUG_BADNESS
3347 #define debug_badness snd_printdd 3347 #define debug_badness snd_printdd
3348 #else 3348 #else
3349 #define debug_badness(...) 3349 #define debug_badness(...)
3350 #endif 3350 #endif
3351 3351
3352 static void debug_show_configs(struct alc_spec *spec, struct auto_pin_cfg *cfg) 3352 static void debug_show_configs(struct alc_spec *spec, struct auto_pin_cfg *cfg)
3353 { 3353 {
3354 debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", 3354 debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3355 cfg->line_out_pins[0], cfg->line_out_pins[1], 3355 cfg->line_out_pins[0], cfg->line_out_pins[1],
3356 cfg->line_out_pins[2], cfg->line_out_pins[2], 3356 cfg->line_out_pins[2], cfg->line_out_pins[2],
3357 spec->multiout.dac_nids[0], 3357 spec->multiout.dac_nids[0],
3358 spec->multiout.dac_nids[1], 3358 spec->multiout.dac_nids[1],
3359 spec->multiout.dac_nids[2], 3359 spec->multiout.dac_nids[2],
3360 spec->multiout.dac_nids[3]); 3360 spec->multiout.dac_nids[3]);
3361 if (spec->multi_ios > 0) 3361 if (spec->multi_ios > 0)
3362 debug_badness("multi_ios(%d) = %x/%x : %x/%x\n", 3362 debug_badness("multi_ios(%d) = %x/%x : %x/%x\n",
3363 spec->multi_ios, 3363 spec->multi_ios,
3364 spec->multi_io[0].pin, spec->multi_io[1].pin, 3364 spec->multi_io[0].pin, spec->multi_io[1].pin,
3365 spec->multi_io[0].dac, spec->multi_io[1].dac); 3365 spec->multi_io[0].dac, spec->multi_io[1].dac);
3366 debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", 3366 debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3367 cfg->hp_pins[0], cfg->hp_pins[1], 3367 cfg->hp_pins[0], cfg->hp_pins[1],
3368 cfg->hp_pins[2], cfg->hp_pins[2], 3368 cfg->hp_pins[2], cfg->hp_pins[2],
3369 spec->multiout.hp_out_nid[0], 3369 spec->multiout.hp_out_nid[0],
3370 spec->multiout.hp_out_nid[1], 3370 spec->multiout.hp_out_nid[1],
3371 spec->multiout.hp_out_nid[2], 3371 spec->multiout.hp_out_nid[2],
3372 spec->multiout.hp_out_nid[3]); 3372 spec->multiout.hp_out_nid[3]);
3373 debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", 3373 debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n",
3374 cfg->speaker_pins[0], cfg->speaker_pins[1], 3374 cfg->speaker_pins[0], cfg->speaker_pins[1],
3375 cfg->speaker_pins[2], cfg->speaker_pins[3], 3375 cfg->speaker_pins[2], cfg->speaker_pins[3],
3376 spec->multiout.extra_out_nid[0], 3376 spec->multiout.extra_out_nid[0],
3377 spec->multiout.extra_out_nid[1], 3377 spec->multiout.extra_out_nid[1],
3378 spec->multiout.extra_out_nid[2], 3378 spec->multiout.extra_out_nid[2],
3379 spec->multiout.extra_out_nid[3]); 3379 spec->multiout.extra_out_nid[3]);
3380 } 3380 }
3381 3381
3382 static int alc_auto_fill_dac_nids(struct hda_codec *codec) 3382 static int alc_auto_fill_dac_nids(struct hda_codec *codec)
3383 { 3383 {
3384 struct alc_spec *spec = codec->spec; 3384 struct alc_spec *spec = codec->spec;
3385 struct auto_pin_cfg *cfg = &spec->autocfg; 3385 struct auto_pin_cfg *cfg = &spec->autocfg;
3386 struct auto_pin_cfg *best_cfg; 3386 struct auto_pin_cfg *best_cfg;
3387 int best_badness = INT_MAX; 3387 int best_badness = INT_MAX;
3388 int badness; 3388 int badness;
3389 bool fill_hardwired = true, fill_mio_first = true; 3389 bool fill_hardwired = true, fill_mio_first = true;
3390 bool best_wired = true, best_mio = true; 3390 bool best_wired = true, best_mio = true;
3391 bool hp_spk_swapped = false; 3391 bool hp_spk_swapped = false;
3392 3392
3393 best_cfg = kmalloc(sizeof(*best_cfg), GFP_KERNEL); 3393 best_cfg = kmalloc(sizeof(*best_cfg), GFP_KERNEL);
3394 if (!best_cfg) 3394 if (!best_cfg)
3395 return -ENOMEM; 3395 return -ENOMEM;
3396 *best_cfg = *cfg; 3396 *best_cfg = *cfg;
3397 3397
3398 for (;;) { 3398 for (;;) {
3399 badness = fill_and_eval_dacs(codec, fill_hardwired, 3399 badness = fill_and_eval_dacs(codec, fill_hardwired,
3400 fill_mio_first); 3400 fill_mio_first);
3401 if (badness < 0) 3401 if (badness < 0)
3402 return badness; 3402 return badness;
3403 debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n", 3403 debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n",
3404 cfg->line_out_type, fill_hardwired, fill_mio_first, 3404 cfg->line_out_type, fill_hardwired, fill_mio_first,
3405 badness); 3405 badness);
3406 debug_show_configs(spec, cfg); 3406 debug_show_configs(spec, cfg);
3407 if (badness < best_badness) { 3407 if (badness < best_badness) {
3408 best_badness = badness; 3408 best_badness = badness;
3409 *best_cfg = *cfg; 3409 *best_cfg = *cfg;
3410 best_wired = fill_hardwired; 3410 best_wired = fill_hardwired;
3411 best_mio = fill_mio_first; 3411 best_mio = fill_mio_first;
3412 } 3412 }
3413 if (!badness) 3413 if (!badness)
3414 break; 3414 break;
3415 fill_mio_first = !fill_mio_first; 3415 fill_mio_first = !fill_mio_first;
3416 if (!fill_mio_first) 3416 if (!fill_mio_first)
3417 continue; 3417 continue;
3418 fill_hardwired = !fill_hardwired; 3418 fill_hardwired = !fill_hardwired;
3419 if (!fill_hardwired) 3419 if (!fill_hardwired)
3420 continue; 3420 continue;
3421 if (hp_spk_swapped) 3421 if (hp_spk_swapped)
3422 break; 3422 break;
3423 hp_spk_swapped = true; 3423 hp_spk_swapped = true;
3424 if (cfg->speaker_outs > 0 && 3424 if (cfg->speaker_outs > 0 &&
3425 cfg->line_out_type == AUTO_PIN_HP_OUT) { 3425 cfg->line_out_type == AUTO_PIN_HP_OUT) {
3426 cfg->hp_outs = cfg->line_outs; 3426 cfg->hp_outs = cfg->line_outs;
3427 memcpy(cfg->hp_pins, cfg->line_out_pins, 3427 memcpy(cfg->hp_pins, cfg->line_out_pins,
3428 sizeof(cfg->hp_pins)); 3428 sizeof(cfg->hp_pins));
3429 cfg->line_outs = cfg->speaker_outs; 3429 cfg->line_outs = cfg->speaker_outs;
3430 memcpy(cfg->line_out_pins, cfg->speaker_pins, 3430 memcpy(cfg->line_out_pins, cfg->speaker_pins,
3431 sizeof(cfg->speaker_pins)); 3431 sizeof(cfg->speaker_pins));
3432 cfg->speaker_outs = 0; 3432 cfg->speaker_outs = 0;
3433 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); 3433 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins));
3434 cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; 3434 cfg->line_out_type = AUTO_PIN_SPEAKER_OUT;
3435 fill_hardwired = true; 3435 fill_hardwired = true;
3436 continue; 3436 continue;
3437 } 3437 }
3438 if (cfg->hp_outs > 0 && 3438 if (cfg->hp_outs > 0 &&
3439 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { 3439 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
3440 cfg->speaker_outs = cfg->line_outs; 3440 cfg->speaker_outs = cfg->line_outs;
3441 memcpy(cfg->speaker_pins, cfg->line_out_pins, 3441 memcpy(cfg->speaker_pins, cfg->line_out_pins,
3442 sizeof(cfg->speaker_pins)); 3442 sizeof(cfg->speaker_pins));
3443 cfg->line_outs = cfg->hp_outs; 3443 cfg->line_outs = cfg->hp_outs;
3444 memcpy(cfg->line_out_pins, cfg->hp_pins, 3444 memcpy(cfg->line_out_pins, cfg->hp_pins,
3445 sizeof(cfg->hp_pins)); 3445 sizeof(cfg->hp_pins));
3446 cfg->hp_outs = 0; 3446 cfg->hp_outs = 0;
3447 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); 3447 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins));
3448 cfg->line_out_type = AUTO_PIN_HP_OUT; 3448 cfg->line_out_type = AUTO_PIN_HP_OUT;
3449 fill_hardwired = true; 3449 fill_hardwired = true;
3450 continue; 3450 continue;
3451 } 3451 }
3452 break; 3452 break;
3453 } 3453 }
3454 3454
3455 if (badness) { 3455 if (badness) {
3456 *cfg = *best_cfg; 3456 *cfg = *best_cfg;
3457 fill_and_eval_dacs(codec, best_wired, best_mio); 3457 fill_and_eval_dacs(codec, best_wired, best_mio);
3458 } 3458 }
3459 debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n", 3459 debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n",
3460 cfg->line_out_type, best_wired, best_mio); 3460 cfg->line_out_type, best_wired, best_mio);
3461 debug_show_configs(spec, cfg); 3461 debug_show_configs(spec, cfg);
3462 3462
3463 if (cfg->line_out_pins[0]) 3463 if (cfg->line_out_pins[0])
3464 spec->vmaster_nid = 3464 spec->vmaster_nid =
3465 alc_look_for_out_vol_nid(codec, cfg->line_out_pins[0], 3465 alc_look_for_out_vol_nid(codec, cfg->line_out_pins[0],
3466 spec->multiout.dac_nids[0]); 3466 spec->multiout.dac_nids[0]);
3467 3467
3468 /* clear the bitmap flags for creating controls */ 3468 /* clear the bitmap flags for creating controls */
3469 clear_vol_marks(codec); 3469 clear_vol_marks(codec);
3470 kfree(best_cfg); 3470 kfree(best_cfg);
3471 return 0; 3471 return 0;
3472 } 3472 }
3473 3473
3474 static int alc_auto_add_vol_ctl(struct hda_codec *codec, 3474 static int alc_auto_add_vol_ctl(struct hda_codec *codec,
3475 const char *pfx, int cidx, 3475 const char *pfx, int cidx,
3476 hda_nid_t nid, unsigned int chs) 3476 hda_nid_t nid, unsigned int chs)
3477 { 3477 {
3478 struct alc_spec *spec = codec->spec; 3478 struct alc_spec *spec = codec->spec;
3479 unsigned int val; 3479 unsigned int val;
3480 if (!nid) 3480 if (!nid)
3481 return 0; 3481 return 0;
3482 val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT); 3482 val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT);
3483 if (is_ctl_used(spec->vol_ctls, val) && chs != 2) /* exclude LFE */ 3483 if (is_ctl_used(spec->vol_ctls, val) && chs != 2) /* exclude LFE */
3484 return 0; 3484 return 0;
3485 mark_ctl_usage(spec->vol_ctls, val); 3485 mark_ctl_usage(spec->vol_ctls, val);
3486 return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx, 3486 return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx,
3487 val); 3487 val);
3488 } 3488 }
3489 3489
3490 static int alc_auto_add_stereo_vol(struct hda_codec *codec, 3490 static int alc_auto_add_stereo_vol(struct hda_codec *codec,
3491 const char *pfx, int cidx, 3491 const char *pfx, int cidx,
3492 hda_nid_t nid) 3492 hda_nid_t nid)
3493 { 3493 {
3494 int chs = 1; 3494 int chs = 1;
3495 if (get_wcaps(codec, nid) & AC_WCAP_STEREO) 3495 if (get_wcaps(codec, nid) & AC_WCAP_STEREO)
3496 chs = 3; 3496 chs = 3;
3497 return alc_auto_add_vol_ctl(codec, pfx, cidx, nid, chs); 3497 return alc_auto_add_vol_ctl(codec, pfx, cidx, nid, chs);
3498 } 3498 }
3499 3499
3500 /* create a mute-switch for the given mixer widget; 3500 /* create a mute-switch for the given mixer widget;
3501 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute 3501 * if it has multiple sources (e.g. DAC and loopback), create a bind-mute
3502 */ 3502 */
3503 static int alc_auto_add_sw_ctl(struct hda_codec *codec, 3503 static int alc_auto_add_sw_ctl(struct hda_codec *codec,
3504 const char *pfx, int cidx, 3504 const char *pfx, int cidx,
3505 hda_nid_t nid, unsigned int chs) 3505 hda_nid_t nid, unsigned int chs)
3506 { 3506 {
3507 struct alc_spec *spec = codec->spec; 3507 struct alc_spec *spec = codec->spec;
3508 int wid_type; 3508 int wid_type;
3509 int type; 3509 int type;
3510 unsigned long val; 3510 unsigned long val;
3511 if (!nid) 3511 if (!nid)
3512 return 0; 3512 return 0;
3513 wid_type = get_wcaps_type(get_wcaps(codec, nid)); 3513 wid_type = get_wcaps_type(get_wcaps(codec, nid));
3514 if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) { 3514 if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) {
3515 type = ALC_CTL_WIDGET_MUTE; 3515 type = ALC_CTL_WIDGET_MUTE;
3516 val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT); 3516 val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT);
3517 } else if (snd_hda_get_conn_list(codec, nid, NULL) == 1) { 3517 } else if (snd_hda_get_conn_list(codec, nid, NULL) == 1) {
3518 type = ALC_CTL_WIDGET_MUTE; 3518 type = ALC_CTL_WIDGET_MUTE;
3519 val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT); 3519 val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT);
3520 } else { 3520 } else {
3521 type = ALC_CTL_BIND_MUTE; 3521 type = ALC_CTL_BIND_MUTE;
3522 val = HDA_COMPOSE_AMP_VAL(nid, chs, 2, HDA_INPUT); 3522 val = HDA_COMPOSE_AMP_VAL(nid, chs, 2, HDA_INPUT);
3523 } 3523 }
3524 if (is_ctl_used(spec->sw_ctls, val) && chs != 2) /* exclude LFE */ 3524 if (is_ctl_used(spec->sw_ctls, val) && chs != 2) /* exclude LFE */
3525 return 0; 3525 return 0;
3526 mark_ctl_usage(spec->sw_ctls, val); 3526 mark_ctl_usage(spec->sw_ctls, val);
3527 return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); 3527 return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val);
3528 } 3528 }
3529 3529
3530 static int alc_auto_add_stereo_sw(struct hda_codec *codec, const char *pfx, 3530 static int alc_auto_add_stereo_sw(struct hda_codec *codec, const char *pfx,
3531 int cidx, hda_nid_t nid) 3531 int cidx, hda_nid_t nid)
3532 { 3532 {
3533 int chs = 1; 3533 int chs = 1;
3534 if (get_wcaps(codec, nid) & AC_WCAP_STEREO) 3534 if (get_wcaps(codec, nid) & AC_WCAP_STEREO)
3535 chs = 3; 3535 chs = 3;
3536 return alc_auto_add_sw_ctl(codec, pfx, cidx, nid, chs); 3536 return alc_auto_add_sw_ctl(codec, pfx, cidx, nid, chs);
3537 } 3537 }
3538 3538
3539 static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, 3539 static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec,
3540 hda_nid_t pin, hda_nid_t dac) 3540 hda_nid_t pin, hda_nid_t dac)
3541 { 3541 {
3542 hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac); 3542 hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac);
3543 if (nid_has_mute(codec, pin, HDA_OUTPUT)) 3543 if (nid_has_mute(codec, pin, HDA_OUTPUT))
3544 return pin; 3544 return pin;
3545 else if (mix && nid_has_mute(codec, mix, HDA_INPUT)) 3545 else if (mix && nid_has_mute(codec, mix, HDA_INPUT))
3546 return mix; 3546 return mix;
3547 else if (nid_has_mute(codec, dac, HDA_OUTPUT)) 3547 else if (nid_has_mute(codec, dac, HDA_OUTPUT))
3548 return dac; 3548 return dac;
3549 return 0; 3549 return 0;
3550 } 3550 }
3551 3551
3552 static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, 3552 static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec,
3553 hda_nid_t pin, hda_nid_t dac) 3553 hda_nid_t pin, hda_nid_t dac)
3554 { 3554 {
3555 hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac); 3555 hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac);
3556 if (nid_has_volume(codec, dac, HDA_OUTPUT)) 3556 if (nid_has_volume(codec, dac, HDA_OUTPUT))
3557 return dac; 3557 return dac;
3558 else if (nid_has_volume(codec, mix, HDA_OUTPUT)) 3558 else if (nid_has_volume(codec, mix, HDA_OUTPUT))
3559 return mix; 3559 return mix;
3560 else if (nid_has_volume(codec, pin, HDA_OUTPUT)) 3560 else if (nid_has_volume(codec, pin, HDA_OUTPUT))
3561 return pin; 3561 return pin;
3562 return 0; 3562 return 0;
3563 } 3563 }
3564 3564
3565 /* add playback controls from the parsed DAC table */ 3565 /* add playback controls from the parsed DAC table */
3566 static int alc_auto_create_multi_out_ctls(struct hda_codec *codec, 3566 static int alc_auto_create_multi_out_ctls(struct hda_codec *codec,
3567 const struct auto_pin_cfg *cfg) 3567 const struct auto_pin_cfg *cfg)
3568 { 3568 {
3569 struct alc_spec *spec = codec->spec; 3569 struct alc_spec *spec = codec->spec;
3570 int i, err, noutputs; 3570 int i, err, noutputs;
3571 3571
3572 noutputs = cfg->line_outs; 3572 noutputs = cfg->line_outs;
3573 if (spec->multi_ios > 0 && cfg->line_outs < 3) 3573 if (spec->multi_ios > 0 && cfg->line_outs < 3)
3574 noutputs += spec->multi_ios; 3574 noutputs += spec->multi_ios;
3575 3575
3576 for (i = 0; i < noutputs; i++) { 3576 for (i = 0; i < noutputs; i++) {
3577 const char *name; 3577 const char *name;
3578 int index; 3578 int index;
3579 hda_nid_t dac, pin; 3579 hda_nid_t dac, pin;
3580 hda_nid_t sw, vol; 3580 hda_nid_t sw, vol;
3581 3581
3582 dac = spec->multiout.dac_nids[i]; 3582 dac = spec->multiout.dac_nids[i];
3583 if (!dac) 3583 if (!dac)
3584 continue; 3584 continue;
3585 if (i >= cfg->line_outs) { 3585 if (i >= cfg->line_outs) {
3586 pin = spec->multi_io[i - 1].pin; 3586 pin = spec->multi_io[i - 1].pin;
3587 index = 0; 3587 index = 0;
3588 name = channel_name[i]; 3588 name = channel_name[i];
3589 } else { 3589 } else {
3590 pin = cfg->line_out_pins[i]; 3590 pin = cfg->line_out_pins[i];
3591 name = alc_get_line_out_pfx(spec, i, true, &index); 3591 name = alc_get_line_out_pfx(spec, i, true, &index);
3592 } 3592 }
3593 3593
3594 sw = alc_look_for_out_mute_nid(codec, pin, dac); 3594 sw = alc_look_for_out_mute_nid(codec, pin, dac);
3595 vol = alc_look_for_out_vol_nid(codec, pin, dac); 3595 vol = alc_look_for_out_vol_nid(codec, pin, dac);
3596 if (!name || !strcmp(name, "CLFE")) { 3596 if (!name || !strcmp(name, "CLFE")) {
3597 /* Center/LFE */ 3597 /* Center/LFE */
3598 err = alc_auto_add_vol_ctl(codec, "Center", 0, vol, 1); 3598 err = alc_auto_add_vol_ctl(codec, "Center", 0, vol, 1);
3599 if (err < 0) 3599 if (err < 0)
3600 return err; 3600 return err;
3601 err = alc_auto_add_vol_ctl(codec, "LFE", 0, vol, 2); 3601 err = alc_auto_add_vol_ctl(codec, "LFE", 0, vol, 2);
3602 if (err < 0) 3602 if (err < 0)
3603 return err; 3603 return err;
3604 err = alc_auto_add_sw_ctl(codec, "Center", 0, sw, 1); 3604 err = alc_auto_add_sw_ctl(codec, "Center", 0, sw, 1);
3605 if (err < 0) 3605 if (err < 0)
3606 return err; 3606 return err;
3607 err = alc_auto_add_sw_ctl(codec, "LFE", 0, sw, 2); 3607 err = alc_auto_add_sw_ctl(codec, "LFE", 0, sw, 2);
3608 if (err < 0) 3608 if (err < 0)
3609 return err; 3609 return err;
3610 } else { 3610 } else {
3611 err = alc_auto_add_stereo_vol(codec, name, index, vol); 3611 err = alc_auto_add_stereo_vol(codec, name, index, vol);
3612 if (err < 0) 3612 if (err < 0)
3613 return err; 3613 return err;
3614 err = alc_auto_add_stereo_sw(codec, name, index, sw); 3614 err = alc_auto_add_stereo_sw(codec, name, index, sw);
3615 if (err < 0) 3615 if (err < 0)
3616 return err; 3616 return err;
3617 } 3617 }
3618 } 3618 }
3619 return 0; 3619 return 0;
3620 } 3620 }
3621 3621
3622 static int alc_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, 3622 static int alc_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
3623 hda_nid_t dac, const char *pfx, 3623 hda_nid_t dac, const char *pfx,
3624 int cidx) 3624 int cidx)
3625 { 3625 {
3626 struct alc_spec *spec = codec->spec; 3626 struct alc_spec *spec = codec->spec;
3627 hda_nid_t sw, vol; 3627 hda_nid_t sw, vol;
3628 int err; 3628 int err;
3629 3629
3630 if (!dac) { 3630 if (!dac) {
3631 unsigned int val; 3631 unsigned int val;
3632 /* the corresponding DAC is already occupied */ 3632 /* the corresponding DAC is already occupied */
3633 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)) 3633 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
3634 return 0; /* no way */ 3634 return 0; /* no way */
3635 /* create a switch only */ 3635 /* create a switch only */
3636 val = HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT); 3636 val = HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT);
3637 if (is_ctl_used(spec->sw_ctls, val)) 3637 if (is_ctl_used(spec->sw_ctls, val))
3638 return 0; /* already created */ 3638 return 0; /* already created */
3639 mark_ctl_usage(spec->sw_ctls, val); 3639 mark_ctl_usage(spec->sw_ctls, val);
3640 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, cidx, val); 3640 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, cidx, val);
3641 } 3641 }
3642 3642
3643 sw = alc_look_for_out_mute_nid(codec, pin, dac); 3643 sw = alc_look_for_out_mute_nid(codec, pin, dac);
3644 vol = alc_look_for_out_vol_nid(codec, pin, dac); 3644 vol = alc_look_for_out_vol_nid(codec, pin, dac);
3645 err = alc_auto_add_stereo_vol(codec, pfx, cidx, vol); 3645 err = alc_auto_add_stereo_vol(codec, pfx, cidx, vol);
3646 if (err < 0) 3646 if (err < 0)
3647 return err; 3647 return err;
3648 err = alc_auto_add_stereo_sw(codec, pfx, cidx, sw); 3648 err = alc_auto_add_stereo_sw(codec, pfx, cidx, sw);
3649 if (err < 0) 3649 if (err < 0)
3650 return err; 3650 return err;
3651 return 0; 3651 return 0;
3652 } 3652 }
3653 3653
3654 static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec, 3654 static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec,
3655 unsigned int nums, 3655 unsigned int nums,
3656 struct hda_ctl_ops *ops) 3656 struct hda_ctl_ops *ops)
3657 { 3657 {
3658 struct alc_spec *spec = codec->spec; 3658 struct alc_spec *spec = codec->spec;
3659 struct hda_bind_ctls **ctlp, *ctl; 3659 struct hda_bind_ctls **ctlp, *ctl;
3660 snd_array_init(&spec->bind_ctls, sizeof(ctl), 8); 3660 snd_array_init(&spec->bind_ctls, sizeof(ctl), 8);
3661 ctlp = snd_array_new(&spec->bind_ctls); 3661 ctlp = snd_array_new(&spec->bind_ctls);
3662 if (!ctlp) 3662 if (!ctlp)
3663 return NULL; 3663 return NULL;
3664 ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL); 3664 ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL);
3665 *ctlp = ctl; 3665 *ctlp = ctl;
3666 if (ctl) 3666 if (ctl)
3667 ctl->ops = ops; 3667 ctl->ops = ops;
3668 return ctl; 3668 return ctl;
3669 } 3669 }
3670 3670
3671 /* add playback controls for speaker and HP outputs */ 3671 /* add playback controls for speaker and HP outputs */
3672 static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins, 3672 static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins,
3673 const hda_nid_t *pins, 3673 const hda_nid_t *pins,
3674 const hda_nid_t *dacs, 3674 const hda_nid_t *dacs,
3675 const char *pfx) 3675 const char *pfx)
3676 { 3676 {
3677 struct alc_spec *spec = codec->spec; 3677 struct alc_spec *spec = codec->spec;
3678 struct hda_bind_ctls *ctl; 3678 struct hda_bind_ctls *ctl;
3679 char name[32]; 3679 char name[32];
3680 int i, n, err; 3680 int i, n, err;
3681 3681
3682 if (!num_pins || !pins[0]) 3682 if (!num_pins || !pins[0])
3683 return 0; 3683 return 0;
3684 3684
3685 if (num_pins == 1) { 3685 if (num_pins == 1) {
3686 hda_nid_t dac = *dacs; 3686 hda_nid_t dac = *dacs;
3687 if (!dac) 3687 if (!dac)
3688 dac = spec->multiout.dac_nids[0]; 3688 dac = spec->multiout.dac_nids[0];
3689 return alc_auto_create_extra_out(codec, *pins, dac, pfx, 0); 3689 return alc_auto_create_extra_out(codec, *pins, dac, pfx, 0);
3690 } 3690 }
3691 3691
3692 for (i = 0; i < num_pins; i++) { 3692 for (i = 0; i < num_pins; i++) {
3693 hda_nid_t dac; 3693 hda_nid_t dac;
3694 if (dacs[num_pins - 1]) 3694 if (dacs[num_pins - 1])
3695 dac = dacs[i]; /* with individual volumes */ 3695 dac = dacs[i]; /* with individual volumes */
3696 else 3696 else
3697 dac = 0; 3697 dac = 0;
3698 if (num_pins == 2 && i == 1 && !strcmp(pfx, "Speaker")) { 3698 if (num_pins == 2 && i == 1 && !strcmp(pfx, "Speaker")) {
3699 err = alc_auto_create_extra_out(codec, pins[i], dac, 3699 err = alc_auto_create_extra_out(codec, pins[i], dac,
3700 "Bass Speaker", 0); 3700 "Bass Speaker", 0);
3701 } else if (num_pins >= 3) { 3701 } else if (num_pins >= 3) {
3702 snprintf(name, sizeof(name), "%s %s", 3702 snprintf(name, sizeof(name), "%s %s",
3703 pfx, channel_name[i]); 3703 pfx, channel_name[i]);
3704 err = alc_auto_create_extra_out(codec, pins[i], dac, 3704 err = alc_auto_create_extra_out(codec, pins[i], dac,
3705 name, 0); 3705 name, 0);
3706 } else { 3706 } else {
3707 err = alc_auto_create_extra_out(codec, pins[i], dac, 3707 err = alc_auto_create_extra_out(codec, pins[i], dac,
3708 pfx, i); 3708 pfx, i);
3709 } 3709 }
3710 if (err < 0) 3710 if (err < 0)
3711 return err; 3711 return err;
3712 } 3712 }
3713 if (dacs[num_pins - 1]) 3713 if (dacs[num_pins - 1])
3714 return 0; 3714 return 0;
3715 3715
3716 /* Let's create a bind-controls for volumes */ 3716 /* Let's create a bind-controls for volumes */
3717 ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol); 3717 ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol);
3718 if (!ctl) 3718 if (!ctl)
3719 return -ENOMEM; 3719 return -ENOMEM;
3720 n = 0; 3720 n = 0;
3721 for (i = 0; i < num_pins; i++) { 3721 for (i = 0; i < num_pins; i++) {
3722 hda_nid_t vol; 3722 hda_nid_t vol;
3723 if (!pins[i] || !dacs[i]) 3723 if (!pins[i] || !dacs[i])
3724 continue; 3724 continue;
3725 vol = alc_look_for_out_vol_nid(codec, pins[i], dacs[i]); 3725 vol = alc_look_for_out_vol_nid(codec, pins[i], dacs[i]);
3726 if (vol) 3726 if (vol)
3727 ctl->values[n++] = 3727 ctl->values[n++] =
3728 HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT); 3728 HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT);
3729 } 3729 }
3730 if (n) { 3730 if (n) {
3731 snprintf(name, sizeof(name), "%s Playback Volume", pfx); 3731 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3732 err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl); 3732 err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl);
3733 if (err < 0) 3733 if (err < 0)
3734 return err; 3734 return err;
3735 } 3735 }
3736 return 0; 3736 return 0;
3737 } 3737 }
3738 3738
3739 static int alc_auto_create_hp_out(struct hda_codec *codec) 3739 static int alc_auto_create_hp_out(struct hda_codec *codec)
3740 { 3740 {
3741 struct alc_spec *spec = codec->spec; 3741 struct alc_spec *spec = codec->spec;
3742 return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs, 3742 return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs,
3743 spec->autocfg.hp_pins, 3743 spec->autocfg.hp_pins,
3744 spec->multiout.hp_out_nid, 3744 spec->multiout.hp_out_nid,
3745 "Headphone"); 3745 "Headphone");
3746 } 3746 }
3747 3747
3748 static int alc_auto_create_speaker_out(struct hda_codec *codec) 3748 static int alc_auto_create_speaker_out(struct hda_codec *codec)
3749 { 3749 {
3750 struct alc_spec *spec = codec->spec; 3750 struct alc_spec *spec = codec->spec;
3751 return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs, 3751 return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs,
3752 spec->autocfg.speaker_pins, 3752 spec->autocfg.speaker_pins,
3753 spec->multiout.extra_out_nid, 3753 spec->multiout.extra_out_nid,
3754 "Speaker"); 3754 "Speaker");
3755 } 3755 }
3756 3756
3757 static void alc_auto_set_output_and_unmute(struct hda_codec *codec, 3757 static void alc_auto_set_output_and_unmute(struct hda_codec *codec,
3758 hda_nid_t pin, int pin_type, 3758 hda_nid_t pin, int pin_type,
3759 hda_nid_t dac) 3759 hda_nid_t dac)
3760 { 3760 {
3761 int i, num; 3761 int i, num;
3762 hda_nid_t nid, mix = 0; 3762 hda_nid_t nid, mix = 0;
3763 hda_nid_t srcs[HDA_MAX_CONNECTIONS]; 3763 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
3764 3764
3765 alc_set_pin_output(codec, pin, pin_type); 3765 alc_set_pin_output(codec, pin, pin_type);
3766 nid = alc_go_down_to_selector(codec, pin); 3766 nid = alc_go_down_to_selector(codec, pin);
3767 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs)); 3767 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
3768 for (i = 0; i < num; i++) { 3768 for (i = 0; i < num; i++) {
3769 if (alc_auto_mix_to_dac(codec, srcs[i]) != dac) 3769 if (alc_auto_mix_to_dac(codec, srcs[i]) != dac)
3770 continue; 3770 continue;
3771 mix = srcs[i]; 3771 mix = srcs[i];
3772 break; 3772 break;
3773 } 3773 }
3774 if (!mix) 3774 if (!mix)
3775 return; 3775 return;
3776 3776
3777 /* need the manual connection? */ 3777 /* need the manual connection? */
3778 if (num > 1) 3778 if (num > 1)
3779 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i); 3779 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
3780 /* unmute mixer widget inputs */ 3780 /* unmute mixer widget inputs */
3781 if (nid_has_mute(codec, mix, HDA_INPUT)) { 3781 if (nid_has_mute(codec, mix, HDA_INPUT)) {
3782 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE, 3782 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3783 AMP_IN_UNMUTE(0)); 3783 AMP_IN_UNMUTE(0));
3784 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE, 3784 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3785 AMP_IN_UNMUTE(1)); 3785 AMP_IN_UNMUTE(1));
3786 } 3786 }
3787 /* initialize volume */ 3787 /* initialize volume */
3788 nid = alc_look_for_out_vol_nid(codec, pin, dac); 3788 nid = alc_look_for_out_vol_nid(codec, pin, dac);
3789 if (nid) 3789 if (nid)
3790 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 3790 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3791 AMP_OUT_ZERO); 3791 AMP_OUT_ZERO);
3792 3792
3793 /* unmute DAC if it's not assigned to a mixer */ 3793 /* unmute DAC if it's not assigned to a mixer */
3794 nid = alc_look_for_out_mute_nid(codec, pin, dac); 3794 nid = alc_look_for_out_mute_nid(codec, pin, dac);
3795 if (nid == mix && nid_has_mute(codec, dac, HDA_OUTPUT)) 3795 if (nid == mix && nid_has_mute(codec, dac, HDA_OUTPUT))
3796 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE, 3796 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3797 AMP_OUT_ZERO); 3797 AMP_OUT_ZERO);
3798 } 3798 }
3799 3799
3800 static void alc_auto_init_multi_out(struct hda_codec *codec) 3800 static void alc_auto_init_multi_out(struct hda_codec *codec)
3801 { 3801 {
3802 struct alc_spec *spec = codec->spec; 3802 struct alc_spec *spec = codec->spec;
3803 int pin_type = get_pin_type(spec->autocfg.line_out_type); 3803 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3804 int i; 3804 int i;
3805 3805
3806 for (i = 0; i <= HDA_SIDE; i++) { 3806 for (i = 0; i <= HDA_SIDE; i++) {
3807 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 3807 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3808 if (nid) 3808 if (nid)
3809 alc_auto_set_output_and_unmute(codec, nid, pin_type, 3809 alc_auto_set_output_and_unmute(codec, nid, pin_type,
3810 spec->multiout.dac_nids[i]); 3810 spec->multiout.dac_nids[i]);
3811 } 3811 }
3812 } 3812 }
3813 3813
3814 static void alc_auto_init_extra_out(struct hda_codec *codec) 3814 static void alc_auto_init_extra_out(struct hda_codec *codec)
3815 { 3815 {
3816 struct alc_spec *spec = codec->spec; 3816 struct alc_spec *spec = codec->spec;
3817 int i; 3817 int i;
3818 hda_nid_t pin, dac; 3818 hda_nid_t pin, dac;
3819 3819
3820 for (i = 0; i < spec->autocfg.hp_outs; i++) { 3820 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3821 if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) 3821 if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)
3822 break; 3822 break;
3823 pin = spec->autocfg.hp_pins[i]; 3823 pin = spec->autocfg.hp_pins[i];
3824 if (!pin) 3824 if (!pin)
3825 break; 3825 break;
3826 dac = spec->multiout.hp_out_nid[i]; 3826 dac = spec->multiout.hp_out_nid[i];
3827 if (!dac) { 3827 if (!dac) {
3828 if (i > 0 && spec->multiout.hp_out_nid[0]) 3828 if (i > 0 && spec->multiout.hp_out_nid[0])
3829 dac = spec->multiout.hp_out_nid[0]; 3829 dac = spec->multiout.hp_out_nid[0];
3830 else 3830 else
3831 dac = spec->multiout.dac_nids[0]; 3831 dac = spec->multiout.dac_nids[0];
3832 } 3832 }
3833 alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac); 3833 alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
3834 } 3834 }
3835 for (i = 0; i < spec->autocfg.speaker_outs; i++) { 3835 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3836 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) 3836 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
3837 break; 3837 break;
3838 pin = spec->autocfg.speaker_pins[i]; 3838 pin = spec->autocfg.speaker_pins[i];
3839 if (!pin) 3839 if (!pin)
3840 break; 3840 break;
3841 dac = spec->multiout.extra_out_nid[i]; 3841 dac = spec->multiout.extra_out_nid[i];
3842 if (!dac) { 3842 if (!dac) {
3843 if (i > 0 && spec->multiout.extra_out_nid[0]) 3843 if (i > 0 && spec->multiout.extra_out_nid[0])
3844 dac = spec->multiout.extra_out_nid[0]; 3844 dac = spec->multiout.extra_out_nid[0];
3845 else 3845 else
3846 dac = spec->multiout.dac_nids[0]; 3846 dac = spec->multiout.dac_nids[0];
3847 } 3847 }
3848 alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac); 3848 alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
3849 } 3849 }
3850 } 3850 }
3851 3851
3852 /* check whether the given pin can be a multi-io pin */ 3852 /* check whether the given pin can be a multi-io pin */
3853 static bool can_be_multiio_pin(struct hda_codec *codec, 3853 static bool can_be_multiio_pin(struct hda_codec *codec,
3854 unsigned int location, hda_nid_t nid) 3854 unsigned int location, hda_nid_t nid)
3855 { 3855 {
3856 unsigned int defcfg, caps; 3856 unsigned int defcfg, caps;
3857 3857
3858 defcfg = snd_hda_codec_get_pincfg(codec, nid); 3858 defcfg = snd_hda_codec_get_pincfg(codec, nid);
3859 if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX) 3859 if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX)
3860 return false; 3860 return false;
3861 if (location && get_defcfg_location(defcfg) != location) 3861 if (location && get_defcfg_location(defcfg) != location)
3862 return false; 3862 return false;
3863 caps = snd_hda_query_pin_caps(codec, nid); 3863 caps = snd_hda_query_pin_caps(codec, nid);
3864 if (!(caps & AC_PINCAP_OUT)) 3864 if (!(caps & AC_PINCAP_OUT))
3865 return false; 3865 return false;
3866 return true; 3866 return true;
3867 } 3867 }
3868 3868
3869 /* 3869 /*
3870 * multi-io helper 3870 * multi-io helper
3871 * 3871 *
3872 * When hardwired is set, try to fill ony hardwired pins, and returns 3872 * When hardwired is set, try to fill ony hardwired pins, and returns
3873 * zero if any pins are filled, non-zero if nothing found. 3873 * zero if any pins are filled, non-zero if nothing found.
3874 * When hardwired is off, try to fill possible input pins, and returns 3874 * When hardwired is off, try to fill possible input pins, and returns
3875 * the badness value. 3875 * the badness value.
3876 */ 3876 */
3877 static int alc_auto_fill_multi_ios(struct hda_codec *codec, 3877 static int alc_auto_fill_multi_ios(struct hda_codec *codec,
3878 hda_nid_t reference_pin, 3878 hda_nid_t reference_pin,
3879 bool hardwired, int offset) 3879 bool hardwired, int offset)
3880 { 3880 {
3881 struct alc_spec *spec = codec->spec; 3881 struct alc_spec *spec = codec->spec;
3882 struct auto_pin_cfg *cfg = &spec->autocfg; 3882 struct auto_pin_cfg *cfg = &spec->autocfg;
3883 int type, i, j, dacs, num_pins, old_pins; 3883 int type, i, j, dacs, num_pins, old_pins;
3884 unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin); 3884 unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin);
3885 unsigned int location = get_defcfg_location(defcfg); 3885 unsigned int location = get_defcfg_location(defcfg);
3886 int badness = 0; 3886 int badness = 0;
3887 3887
3888 old_pins = spec->multi_ios; 3888 old_pins = spec->multi_ios;
3889 if (old_pins >= 2) 3889 if (old_pins >= 2)
3890 goto end_fill; 3890 goto end_fill;
3891 3891
3892 num_pins = 0; 3892 num_pins = 0;
3893 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { 3893 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) {
3894 for (i = 0; i < cfg->num_inputs; i++) { 3894 for (i = 0; i < cfg->num_inputs; i++) {
3895 if (cfg->inputs[i].type != type) 3895 if (cfg->inputs[i].type != type)
3896 continue; 3896 continue;
3897 if (can_be_multiio_pin(codec, location, 3897 if (can_be_multiio_pin(codec, location,
3898 cfg->inputs[i].pin)) 3898 cfg->inputs[i].pin))
3899 num_pins++; 3899 num_pins++;
3900 } 3900 }
3901 } 3901 }
3902 if (num_pins < 2) 3902 if (num_pins < 2)
3903 goto end_fill; 3903 goto end_fill;
3904 3904
3905 dacs = spec->multiout.num_dacs; 3905 dacs = spec->multiout.num_dacs;
3906 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { 3906 for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) {
3907 for (i = 0; i < cfg->num_inputs; i++) { 3907 for (i = 0; i < cfg->num_inputs; i++) {
3908 hda_nid_t nid = cfg->inputs[i].pin; 3908 hda_nid_t nid = cfg->inputs[i].pin;
3909 hda_nid_t dac = 0; 3909 hda_nid_t dac = 0;
3910 3910
3911 if (cfg->inputs[i].type != type) 3911 if (cfg->inputs[i].type != type)
3912 continue; 3912 continue;
3913 if (!can_be_multiio_pin(codec, location, nid)) 3913 if (!can_be_multiio_pin(codec, location, nid))
3914 continue; 3914 continue;
3915 for (j = 0; j < spec->multi_ios; j++) { 3915 for (j = 0; j < spec->multi_ios; j++) {
3916 if (nid == spec->multi_io[j].pin) 3916 if (nid == spec->multi_io[j].pin)
3917 break; 3917 break;
3918 } 3918 }
3919 if (j < spec->multi_ios) 3919 if (j < spec->multi_ios)
3920 continue; 3920 continue;
3921 3921
3922 if (offset && offset + spec->multi_ios < dacs) { 3922 if (offset && offset + spec->multi_ios < dacs) {
3923 dac = spec->private_dac_nids[offset + spec->multi_ios]; 3923 dac = spec->private_dac_nids[offset + spec->multi_ios];
3924 if (!alc_auto_is_dac_reachable(codec, nid, dac)) 3924 if (!alc_auto_is_dac_reachable(codec, nid, dac))
3925 dac = 0; 3925 dac = 0;
3926 } 3926 }
3927 if (hardwired) 3927 if (hardwired)
3928 dac = get_dac_if_single(codec, nid); 3928 dac = get_dac_if_single(codec, nid);
3929 else if (!dac) 3929 else if (!dac)
3930 dac = alc_auto_look_for_dac(codec, nid); 3930 dac = alc_auto_look_for_dac(codec, nid);
3931 if (!dac) { 3931 if (!dac) {
3932 badness++; 3932 badness++;
3933 continue; 3933 continue;
3934 } 3934 }
3935 spec->multi_io[spec->multi_ios].pin = nid; 3935 spec->multi_io[spec->multi_ios].pin = nid;
3936 spec->multi_io[spec->multi_ios].dac = dac; 3936 spec->multi_io[spec->multi_ios].dac = dac;
3937 spec->multi_ios++; 3937 spec->multi_ios++;
3938 if (spec->multi_ios >= 2) 3938 if (spec->multi_ios >= 2)
3939 break; 3939 break;
3940 } 3940 }
3941 } 3941 }
3942 end_fill: 3942 end_fill:
3943 if (badness) 3943 if (badness)
3944 badness = BAD_MULTI_IO; 3944 badness = BAD_MULTI_IO;
3945 if (old_pins == spec->multi_ios) { 3945 if (old_pins == spec->multi_ios) {
3946 if (hardwired) 3946 if (hardwired)
3947 return 1; /* nothing found */ 3947 return 1; /* nothing found */
3948 else 3948 else
3949 return badness; /* no badness if nothing found */ 3949 return badness; /* no badness if nothing found */
3950 } 3950 }
3951 if (!hardwired && spec->multi_ios < 2) { 3951 if (!hardwired && spec->multi_ios < 2) {
3952 spec->multi_ios = old_pins; 3952 spec->multi_ios = old_pins;
3953 return badness; 3953 return badness;
3954 } 3954 }
3955 3955
3956 return 0; 3956 return 0;
3957 } 3957 }
3958 3958
3959 static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol, 3959 static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol,
3960 struct snd_ctl_elem_info *uinfo) 3960 struct snd_ctl_elem_info *uinfo)
3961 { 3961 {
3962 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 3962 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3963 struct alc_spec *spec = codec->spec; 3963 struct alc_spec *spec = codec->spec;
3964 3964
3965 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 3965 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3966 uinfo->count = 1; 3966 uinfo->count = 1;
3967 uinfo->value.enumerated.items = spec->multi_ios + 1; 3967 uinfo->value.enumerated.items = spec->multi_ios + 1;
3968 if (uinfo->value.enumerated.item > spec->multi_ios) 3968 if (uinfo->value.enumerated.item > spec->multi_ios)
3969 uinfo->value.enumerated.item = spec->multi_ios; 3969 uinfo->value.enumerated.item = spec->multi_ios;
3970 sprintf(uinfo->value.enumerated.name, "%dch", 3970 sprintf(uinfo->value.enumerated.name, "%dch",
3971 (uinfo->value.enumerated.item + 1) * 2); 3971 (uinfo->value.enumerated.item + 1) * 2);
3972 return 0; 3972 return 0;
3973 } 3973 }
3974 3974
3975 static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol, 3975 static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol,
3976 struct snd_ctl_elem_value *ucontrol) 3976 struct snd_ctl_elem_value *ucontrol)
3977 { 3977 {
3978 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 3978 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3979 struct alc_spec *spec = codec->spec; 3979 struct alc_spec *spec = codec->spec;
3980 ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2; 3980 ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2;
3981 return 0; 3981 return 0;
3982 } 3982 }
3983 3983
3984 static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) 3984 static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output)
3985 { 3985 {
3986 struct alc_spec *spec = codec->spec; 3986 struct alc_spec *spec = codec->spec;
3987 hda_nid_t nid = spec->multi_io[idx].pin; 3987 hda_nid_t nid = spec->multi_io[idx].pin;
3988 3988
3989 if (!spec->multi_io[idx].ctl_in) 3989 if (!spec->multi_io[idx].ctl_in)
3990 spec->multi_io[idx].ctl_in = 3990 spec->multi_io[idx].ctl_in =
3991 snd_hda_codec_read(codec, nid, 0, 3991 snd_hda_codec_read(codec, nid, 0,
3992 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 3992 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3993 if (output) { 3993 if (output) {
3994 snd_hda_codec_update_cache(codec, nid, 0, 3994 snd_hda_codec_update_cache(codec, nid, 0,
3995 AC_VERB_SET_PIN_WIDGET_CONTROL, 3995 AC_VERB_SET_PIN_WIDGET_CONTROL,
3996 PIN_OUT); 3996 PIN_OUT);
3997 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) 3997 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
3998 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, 3998 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3999 HDA_AMP_MUTE, 0); 3999 HDA_AMP_MUTE, 0);
4000 alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac); 4000 alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac);
4001 } else { 4001 } else {
4002 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) 4002 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
4003 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, 4003 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4004 HDA_AMP_MUTE, HDA_AMP_MUTE); 4004 HDA_AMP_MUTE, HDA_AMP_MUTE);
4005 snd_hda_codec_update_cache(codec, nid, 0, 4005 snd_hda_codec_update_cache(codec, nid, 0,
4006 AC_VERB_SET_PIN_WIDGET_CONTROL, 4006 AC_VERB_SET_PIN_WIDGET_CONTROL,
4007 spec->multi_io[idx].ctl_in); 4007 spec->multi_io[idx].ctl_in);
4008 } 4008 }
4009 return 0; 4009 return 0;
4010 } 4010 }
4011 4011
4012 static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol, 4012 static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol,
4013 struct snd_ctl_elem_value *ucontrol) 4013 struct snd_ctl_elem_value *ucontrol)
4014 { 4014 {
4015 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 4015 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4016 struct alc_spec *spec = codec->spec; 4016 struct alc_spec *spec = codec->spec;
4017 int i, ch; 4017 int i, ch;
4018 4018
4019 ch = ucontrol->value.enumerated.item[0]; 4019 ch = ucontrol->value.enumerated.item[0];
4020 if (ch < 0 || ch > spec->multi_ios) 4020 if (ch < 0 || ch > spec->multi_ios)
4021 return -EINVAL; 4021 return -EINVAL;
4022 if (ch == (spec->ext_channel_count - 1) / 2) 4022 if (ch == (spec->ext_channel_count - 1) / 2)
4023 return 0; 4023 return 0;
4024 spec->ext_channel_count = (ch + 1) * 2; 4024 spec->ext_channel_count = (ch + 1) * 2;
4025 for (i = 0; i < spec->multi_ios; i++) 4025 for (i = 0; i < spec->multi_ios; i++)
4026 alc_set_multi_io(codec, i, i < ch); 4026 alc_set_multi_io(codec, i, i < ch);
4027 spec->multiout.max_channels = spec->ext_channel_count; 4027 spec->multiout.max_channels = spec->ext_channel_count;
4028 if (spec->need_dac_fix && !spec->const_channel_count) 4028 if (spec->need_dac_fix && !spec->const_channel_count)
4029 spec->multiout.num_dacs = spec->multiout.max_channels / 2; 4029 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
4030 return 1; 4030 return 1;
4031 } 4031 }
4032 4032
4033 static const struct snd_kcontrol_new alc_auto_channel_mode_enum = { 4033 static const struct snd_kcontrol_new alc_auto_channel_mode_enum = {
4034 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4034 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4035 .name = "Channel Mode", 4035 .name = "Channel Mode",
4036 .info = alc_auto_ch_mode_info, 4036 .info = alc_auto_ch_mode_info,
4037 .get = alc_auto_ch_mode_get, 4037 .get = alc_auto_ch_mode_get,
4038 .put = alc_auto_ch_mode_put, 4038 .put = alc_auto_ch_mode_put,
4039 }; 4039 };
4040 4040
4041 static int alc_auto_add_multi_channel_mode(struct hda_codec *codec) 4041 static int alc_auto_add_multi_channel_mode(struct hda_codec *codec)
4042 { 4042 {
4043 struct alc_spec *spec = codec->spec; 4043 struct alc_spec *spec = codec->spec;
4044 4044
4045 if (spec->multi_ios > 0) { 4045 if (spec->multi_ios > 0) {
4046 struct snd_kcontrol_new *knew; 4046 struct snd_kcontrol_new *knew;
4047 4047
4048 knew = alc_kcontrol_new(spec); 4048 knew = alc_kcontrol_new(spec);
4049 if (!knew) 4049 if (!knew)
4050 return -ENOMEM; 4050 return -ENOMEM;
4051 *knew = alc_auto_channel_mode_enum; 4051 *knew = alc_auto_channel_mode_enum;
4052 knew->name = kstrdup("Channel Mode", GFP_KERNEL); 4052 knew->name = kstrdup("Channel Mode", GFP_KERNEL);
4053 if (!knew->name) 4053 if (!knew->name)
4054 return -ENOMEM; 4054 return -ENOMEM;
4055 } 4055 }
4056 return 0; 4056 return 0;
4057 } 4057 }
4058 4058
4059 /* filter out invalid adc_nids (and capsrc_nids) that don't give all 4059 /* filter out invalid adc_nids (and capsrc_nids) that don't give all
4060 * active input pins 4060 * active input pins
4061 */ 4061 */
4062 static void alc_remove_invalid_adc_nids(struct hda_codec *codec) 4062 static void alc_remove_invalid_adc_nids(struct hda_codec *codec)
4063 { 4063 {
4064 struct alc_spec *spec = codec->spec; 4064 struct alc_spec *spec = codec->spec;
4065 const struct hda_input_mux *imux; 4065 const struct hda_input_mux *imux;
4066 hda_nid_t adc_nids[ARRAY_SIZE(spec->private_adc_nids)]; 4066 hda_nid_t adc_nids[ARRAY_SIZE(spec->private_adc_nids)];
4067 hda_nid_t capsrc_nids[ARRAY_SIZE(spec->private_adc_nids)]; 4067 hda_nid_t capsrc_nids[ARRAY_SIZE(spec->private_adc_nids)];
4068 int i, n, nums; 4068 int i, n, nums;
4069 4069
4070 imux = spec->input_mux; 4070 imux = spec->input_mux;
4071 if (!imux) 4071 if (!imux)
4072 return; 4072 return;
4073 if (spec->dyn_adc_switch) 4073 if (spec->dyn_adc_switch)
4074 return; 4074 return;
4075 4075
4076 again: 4076 again:
4077 nums = 0; 4077 nums = 0;
4078 for (n = 0; n < spec->num_adc_nids; n++) { 4078 for (n = 0; n < spec->num_adc_nids; n++) {
4079 hda_nid_t cap = spec->private_capsrc_nids[n]; 4079 hda_nid_t cap = spec->private_capsrc_nids[n];
4080 int num_conns = snd_hda_get_conn_list(codec, cap, NULL); 4080 int num_conns = snd_hda_get_conn_list(codec, cap, NULL);
4081 for (i = 0; i < imux->num_items; i++) { 4081 for (i = 0; i < imux->num_items; i++) {
4082 hda_nid_t pin = spec->imux_pins[i]; 4082 hda_nid_t pin = spec->imux_pins[i];
4083 if (pin) { 4083 if (pin) {
4084 if (get_connection_index(codec, cap, pin) < 0) 4084 if (get_connection_index(codec, cap, pin) < 0)
4085 break; 4085 break;
4086 } else if (num_conns <= imux->items[i].index) 4086 } else if (num_conns <= imux->items[i].index)
4087 break; 4087 break;
4088 } 4088 }
4089 if (i >= imux->num_items) { 4089 if (i >= imux->num_items) {
4090 adc_nids[nums] = spec->private_adc_nids[n]; 4090 adc_nids[nums] = spec->private_adc_nids[n];
4091 capsrc_nids[nums++] = cap; 4091 capsrc_nids[nums++] = cap;
4092 } 4092 }
4093 } 4093 }
4094 if (!nums) { 4094 if (!nums) {
4095 /* check whether ADC-switch is possible */ 4095 /* check whether ADC-switch is possible */
4096 if (!alc_check_dyn_adc_switch(codec)) { 4096 if (!alc_check_dyn_adc_switch(codec)) {
4097 if (spec->shared_mic_hp) { 4097 if (spec->shared_mic_hp) {
4098 spec->shared_mic_hp = 0; 4098 spec->shared_mic_hp = 0;
4099 spec->private_imux[0].num_items = 1; 4099 spec->private_imux[0].num_items = 1;
4100 goto again; 4100 goto again;
4101 } 4101 }
4102 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;" 4102 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
4103 " using fallback 0x%x\n", 4103 " using fallback 0x%x\n",
4104 codec->chip_name, spec->private_adc_nids[0]); 4104 codec->chip_name, spec->private_adc_nids[0]);
4105 spec->num_adc_nids = 1; 4105 spec->num_adc_nids = 1;
4106 spec->auto_mic = 0; 4106 spec->auto_mic = 0;
4107 return; 4107 return;
4108 } 4108 }
4109 } else if (nums != spec->num_adc_nids) { 4109 } else if (nums != spec->num_adc_nids) {
4110 memcpy(spec->private_adc_nids, adc_nids, 4110 memcpy(spec->private_adc_nids, adc_nids,
4111 nums * sizeof(hda_nid_t)); 4111 nums * sizeof(hda_nid_t));
4112 memcpy(spec->private_capsrc_nids, capsrc_nids, 4112 memcpy(spec->private_capsrc_nids, capsrc_nids,
4113 nums * sizeof(hda_nid_t)); 4113 nums * sizeof(hda_nid_t));
4114 spec->num_adc_nids = nums; 4114 spec->num_adc_nids = nums;
4115 } 4115 }
4116 4116
4117 if (spec->auto_mic) 4117 if (spec->auto_mic)
4118 alc_auto_mic_check_imux(codec); /* check auto-mic setups */ 4118 alc_auto_mic_check_imux(codec); /* check auto-mic setups */
4119 else if (spec->input_mux->num_items == 1 || spec->shared_mic_hp) 4119 else if (spec->input_mux->num_items == 1 || spec->shared_mic_hp)
4120 spec->num_adc_nids = 1; /* reduce to a single ADC */ 4120 spec->num_adc_nids = 1; /* reduce to a single ADC */
4121 } 4121 }
4122 4122
4123 /* 4123 /*
4124 * initialize ADC paths 4124 * initialize ADC paths
4125 */ 4125 */
4126 static void alc_auto_init_adc(struct hda_codec *codec, int adc_idx) 4126 static void alc_auto_init_adc(struct hda_codec *codec, int adc_idx)
4127 { 4127 {
4128 struct alc_spec *spec = codec->spec; 4128 struct alc_spec *spec = codec->spec;
4129 hda_nid_t nid; 4129 hda_nid_t nid;
4130 4130
4131 nid = spec->adc_nids[adc_idx]; 4131 nid = spec->adc_nids[adc_idx];
4132 /* mute ADC */ 4132 /* mute ADC */
4133 if (nid_has_mute(codec, nid, HDA_INPUT)) { 4133 if (nid_has_mute(codec, nid, HDA_INPUT)) {
4134 snd_hda_codec_write(codec, nid, 0, 4134 snd_hda_codec_write(codec, nid, 0,
4135 AC_VERB_SET_AMP_GAIN_MUTE, 4135 AC_VERB_SET_AMP_GAIN_MUTE,
4136 AMP_IN_MUTE(0)); 4136 AMP_IN_MUTE(0));
4137 return; 4137 return;
4138 } 4138 }
4139 if (!spec->capsrc_nids) 4139 if (!spec->capsrc_nids)
4140 return; 4140 return;
4141 nid = spec->capsrc_nids[adc_idx]; 4141 nid = spec->capsrc_nids[adc_idx];
4142 if (nid_has_mute(codec, nid, HDA_OUTPUT)) 4142 if (nid_has_mute(codec, nid, HDA_OUTPUT))
4143 snd_hda_codec_write(codec, nid, 0, 4143 snd_hda_codec_write(codec, nid, 0,
4144 AC_VERB_SET_AMP_GAIN_MUTE, 4144 AC_VERB_SET_AMP_GAIN_MUTE,
4145 AMP_OUT_MUTE); 4145 AMP_OUT_MUTE);
4146 } 4146 }
4147 4147
4148 static void alc_auto_init_input_src(struct hda_codec *codec) 4148 static void alc_auto_init_input_src(struct hda_codec *codec)
4149 { 4149 {
4150 struct alc_spec *spec = codec->spec; 4150 struct alc_spec *spec = codec->spec;
4151 int c, nums; 4151 int c, nums;
4152 4152
4153 for (c = 0; c < spec->num_adc_nids; c++) 4153 for (c = 0; c < spec->num_adc_nids; c++)
4154 alc_auto_init_adc(codec, c); 4154 alc_auto_init_adc(codec, c);
4155 if (spec->dyn_adc_switch) 4155 if (spec->dyn_adc_switch)
4156 nums = 1; 4156 nums = 1;
4157 else 4157 else
4158 nums = spec->num_adc_nids; 4158 nums = spec->num_adc_nids;
4159 for (c = 0; c < nums; c++) 4159 for (c = 0; c < nums; c++)
4160 alc_mux_select(codec, c, spec->cur_mux[c], true); 4160 alc_mux_select(codec, c, spec->cur_mux[c], true);
4161 } 4161 }
4162 4162
4163 /* add mic boosts if needed */ 4163 /* add mic boosts if needed */
4164 static int alc_auto_add_mic_boost(struct hda_codec *codec) 4164 static int alc_auto_add_mic_boost(struct hda_codec *codec)
4165 { 4165 {
4166 struct alc_spec *spec = codec->spec; 4166 struct alc_spec *spec = codec->spec;
4167 struct auto_pin_cfg *cfg = &spec->autocfg; 4167 struct auto_pin_cfg *cfg = &spec->autocfg;
4168 int i, err; 4168 int i, err;
4169 int type_idx = 0; 4169 int type_idx = 0;
4170 hda_nid_t nid; 4170 hda_nid_t nid;
4171 const char *prev_label = NULL; 4171 const char *prev_label = NULL;
4172 4172
4173 for (i = 0; i < cfg->num_inputs; i++) { 4173 for (i = 0; i < cfg->num_inputs; i++) {
4174 if (cfg->inputs[i].type > AUTO_PIN_MIC) 4174 if (cfg->inputs[i].type > AUTO_PIN_MIC)
4175 break; 4175 break;
4176 nid = cfg->inputs[i].pin; 4176 nid = cfg->inputs[i].pin;
4177 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { 4177 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
4178 const char *label; 4178 const char *label;
4179 char boost_label[32]; 4179 char boost_label[32];
4180 4180
4181 label = hda_get_autocfg_input_label(codec, cfg, i); 4181 label = hda_get_autocfg_input_label(codec, cfg, i);
4182 if (spec->shared_mic_hp && !strcmp(label, "Misc")) 4182 if (spec->shared_mic_hp && !strcmp(label, "Misc"))
4183 label = "Headphone Mic"; 4183 label = "Headphone Mic";
4184 if (prev_label && !strcmp(label, prev_label)) 4184 if (prev_label && !strcmp(label, prev_label))
4185 type_idx++; 4185 type_idx++;
4186 else 4186 else
4187 type_idx = 0; 4187 type_idx = 0;
4188 prev_label = label; 4188 prev_label = label;
4189 4189
4190 snprintf(boost_label, sizeof(boost_label), 4190 snprintf(boost_label, sizeof(boost_label),
4191 "%s Boost Volume", label); 4191 "%s Boost Volume", label);
4192 err = add_control(spec, ALC_CTL_WIDGET_VOL, 4192 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4193 boost_label, type_idx, 4193 boost_label, type_idx,
4194 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); 4194 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
4195 if (err < 0) 4195 if (err < 0)
4196 return err; 4196 return err;
4197 } 4197 }
4198 } 4198 }
4199 return 0; 4199 return 0;
4200 } 4200 }
4201 4201
4202 /* select or unmute the given capsrc route */ 4202 /* select or unmute the given capsrc route */
4203 static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap, 4203 static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
4204 int idx) 4204 int idx)
4205 { 4205 {
4206 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) { 4206 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
4207 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx, 4207 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
4208 HDA_AMP_MUTE, 0); 4208 HDA_AMP_MUTE, 0);
4209 } else if (snd_hda_get_conn_list(codec, cap, NULL) > 1) { 4209 } else if (snd_hda_get_conn_list(codec, cap, NULL) > 1) {
4210 snd_hda_codec_write_cache(codec, cap, 0, 4210 snd_hda_codec_write_cache(codec, cap, 0,
4211 AC_VERB_SET_CONNECT_SEL, idx); 4211 AC_VERB_SET_CONNECT_SEL, idx);
4212 } 4212 }
4213 } 4213 }
4214 4214
4215 /* set the default connection to that pin */ 4215 /* set the default connection to that pin */
4216 static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin) 4216 static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
4217 { 4217 {
4218 struct alc_spec *spec = codec->spec; 4218 struct alc_spec *spec = codec->spec;
4219 int i; 4219 int i;
4220 4220
4221 if (!pin) 4221 if (!pin)
4222 return 0; 4222 return 0;
4223 for (i = 0; i < spec->num_adc_nids; i++) { 4223 for (i = 0; i < spec->num_adc_nids; i++) {
4224 hda_nid_t cap = get_capsrc(spec, i); 4224 hda_nid_t cap = get_capsrc(spec, i);
4225 int idx; 4225 int idx;
4226 4226
4227 idx = get_connection_index(codec, cap, pin); 4227 idx = get_connection_index(codec, cap, pin);
4228 if (idx < 0) 4228 if (idx < 0)
4229 continue; 4229 continue;
4230 select_or_unmute_capsrc(codec, cap, idx); 4230 select_or_unmute_capsrc(codec, cap, idx);
4231 return i; /* return the found index */ 4231 return i; /* return the found index */
4232 } 4232 }
4233 return -1; /* not found */ 4233 return -1; /* not found */
4234 } 4234 }
4235 4235
4236 /* initialize some special cases for input sources */ 4236 /* initialize some special cases for input sources */
4237 static void alc_init_special_input_src(struct hda_codec *codec) 4237 static void alc_init_special_input_src(struct hda_codec *codec)
4238 { 4238 {
4239 struct alc_spec *spec = codec->spec; 4239 struct alc_spec *spec = codec->spec;
4240 int i; 4240 int i;
4241 4241
4242 for (i = 0; i < spec->autocfg.num_inputs; i++) 4242 for (i = 0; i < spec->autocfg.num_inputs; i++)
4243 init_capsrc_for_pin(codec, spec->autocfg.inputs[i].pin); 4243 init_capsrc_for_pin(codec, spec->autocfg.inputs[i].pin);
4244 } 4244 }
4245 4245
4246 /* assign appropriate capture mixers */ 4246 /* assign appropriate capture mixers */
4247 static void set_capture_mixer(struct hda_codec *codec) 4247 static void set_capture_mixer(struct hda_codec *codec)
4248 { 4248 {
4249 struct alc_spec *spec = codec->spec; 4249 struct alc_spec *spec = codec->spec;
4250 static const struct snd_kcontrol_new *caps[2][3] = { 4250 static const struct snd_kcontrol_new *caps[2][3] = {
4251 { alc_capture_mixer_nosrc1, 4251 { alc_capture_mixer_nosrc1,
4252 alc_capture_mixer_nosrc2, 4252 alc_capture_mixer_nosrc2,
4253 alc_capture_mixer_nosrc3 }, 4253 alc_capture_mixer_nosrc3 },
4254 { alc_capture_mixer1, 4254 { alc_capture_mixer1,
4255 alc_capture_mixer2, 4255 alc_capture_mixer2,
4256 alc_capture_mixer3 }, 4256 alc_capture_mixer3 },
4257 }; 4257 };
4258 4258
4259 /* check whether either of ADC or MUX has a volume control */ 4259 /* check whether either of ADC or MUX has a volume control */
4260 if (!nid_has_volume(codec, spec->adc_nids[0], HDA_INPUT)) { 4260 if (!nid_has_volume(codec, spec->adc_nids[0], HDA_INPUT)) {
4261 if (!spec->capsrc_nids) 4261 if (!spec->capsrc_nids)
4262 return; /* no volume */ 4262 return; /* no volume */
4263 if (!nid_has_volume(codec, spec->capsrc_nids[0], HDA_OUTPUT)) 4263 if (!nid_has_volume(codec, spec->capsrc_nids[0], HDA_OUTPUT))
4264 return; /* no volume in capsrc, too */ 4264 return; /* no volume in capsrc, too */
4265 spec->vol_in_capsrc = 1; 4265 spec->vol_in_capsrc = 1;
4266 } 4266 }
4267 4267
4268 if (spec->num_adc_nids > 0) { 4268 if (spec->num_adc_nids > 0) {
4269 int mux = 0; 4269 int mux = 0;
4270 int num_adcs = 0; 4270 int num_adcs = 0;
4271 4271
4272 if (spec->input_mux && spec->input_mux->num_items > 1) 4272 if (spec->input_mux && spec->input_mux->num_items > 1)
4273 mux = 1; 4273 mux = 1;
4274 if (spec->auto_mic) { 4274 if (spec->auto_mic) {
4275 num_adcs = 1; 4275 num_adcs = 1;
4276 mux = 0; 4276 mux = 0;
4277 } else if (spec->dyn_adc_switch) 4277 } else if (spec->dyn_adc_switch)
4278 num_adcs = 1; 4278 num_adcs = 1;
4279 if (!num_adcs) { 4279 if (!num_adcs) {
4280 if (spec->num_adc_nids > 3) 4280 if (spec->num_adc_nids > 3)
4281 spec->num_adc_nids = 3; 4281 spec->num_adc_nids = 3;
4282 else if (!spec->num_adc_nids) 4282 else if (!spec->num_adc_nids)
4283 return; 4283 return;
4284 num_adcs = spec->num_adc_nids; 4284 num_adcs = spec->num_adc_nids;
4285 } 4285 }
4286 spec->cap_mixer = caps[mux][num_adcs - 1]; 4286 spec->cap_mixer = caps[mux][num_adcs - 1];
4287 } 4287 }
4288 } 4288 }
4289 4289
4290 /* 4290 /*
4291 * standard auto-parser initializations 4291 * standard auto-parser initializations
4292 */ 4292 */
4293 static void alc_auto_init_std(struct hda_codec *codec) 4293 static void alc_auto_init_std(struct hda_codec *codec)
4294 { 4294 {
4295 struct alc_spec *spec = codec->spec; 4295 struct alc_spec *spec = codec->spec;
4296 alc_auto_init_multi_out(codec); 4296 alc_auto_init_multi_out(codec);
4297 alc_auto_init_extra_out(codec); 4297 alc_auto_init_extra_out(codec);
4298 alc_auto_init_analog_input(codec); 4298 alc_auto_init_analog_input(codec);
4299 alc_auto_init_input_src(codec); 4299 alc_auto_init_input_src(codec);
4300 alc_auto_init_digital(codec); 4300 alc_auto_init_digital(codec);
4301 if (spec->unsol_event) 4301 if (spec->unsol_event)
4302 alc_inithook(codec); 4302 alc_inithook(codec);
4303 } 4303 }
4304 4304
4305 /* 4305 /*
4306 * Digital-beep handlers 4306 * Digital-beep handlers
4307 */ 4307 */
4308 #ifdef CONFIG_SND_HDA_INPUT_BEEP 4308 #ifdef CONFIG_SND_HDA_INPUT_BEEP
4309 #define set_beep_amp(spec, nid, idx, dir) \ 4309 #define set_beep_amp(spec, nid, idx, dir) \
4310 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) 4310 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4311 4311
4312 static const struct snd_pci_quirk beep_white_list[] = { 4312 static const struct snd_pci_quirk beep_white_list[] = {
4313 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), 4313 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
4314 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), 4314 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
4315 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), 4315 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
4316 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1), 4316 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
4317 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1), 4317 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
4318 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), 4318 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
4319 {} 4319 {}
4320 }; 4320 };
4321 4321
4322 static inline int has_cdefine_beep(struct hda_codec *codec) 4322 static inline int has_cdefine_beep(struct hda_codec *codec)
4323 { 4323 {
4324 struct alc_spec *spec = codec->spec; 4324 struct alc_spec *spec = codec->spec;
4325 const struct snd_pci_quirk *q; 4325 const struct snd_pci_quirk *q;
4326 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); 4326 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
4327 if (q) 4327 if (q)
4328 return q->value; 4328 return q->value;
4329 return spec->cdefine.enable_pcbeep; 4329 return spec->cdefine.enable_pcbeep;
4330 } 4330 }
4331 #else 4331 #else
4332 #define set_beep_amp(spec, nid, idx, dir) /* NOP */ 4332 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
4333 #define has_cdefine_beep(codec) 0 4333 #define has_cdefine_beep(codec) 0
4334 #endif 4334 #endif
4335 4335
4336 /* parse the BIOS configuration and set up the alc_spec */ 4336 /* parse the BIOS configuration and set up the alc_spec */
4337 /* return 1 if successful, 0 if the proper config is not found, 4337 /* return 1 if successful, 0 if the proper config is not found,
4338 * or a negative error code 4338 * or a negative error code
4339 */ 4339 */
4340 static int alc_parse_auto_config(struct hda_codec *codec, 4340 static int alc_parse_auto_config(struct hda_codec *codec,
4341 const hda_nid_t *ignore_nids, 4341 const hda_nid_t *ignore_nids,
4342 const hda_nid_t *ssid_nids) 4342 const hda_nid_t *ssid_nids)
4343 { 4343 {
4344 struct alc_spec *spec = codec->spec; 4344 struct alc_spec *spec = codec->spec;
4345 struct auto_pin_cfg *cfg = &spec->autocfg; 4345 struct auto_pin_cfg *cfg = &spec->autocfg;
4346 int err; 4346 int err;
4347 4347
4348 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids, 4348 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
4349 spec->parse_flags); 4349 spec->parse_flags);
4350 if (err < 0) 4350 if (err < 0)
4351 return err; 4351 return err;
4352 if (!cfg->line_outs) { 4352 if (!cfg->line_outs) {
4353 if (cfg->dig_outs || cfg->dig_in_pin) { 4353 if (cfg->dig_outs || cfg->dig_in_pin) {
4354 spec->multiout.max_channels = 2; 4354 spec->multiout.max_channels = 2;
4355 spec->no_analog = 1; 4355 spec->no_analog = 1;
4356 goto dig_only; 4356 goto dig_only;
4357 } 4357 }
4358 return 0; /* can't find valid BIOS pin config */ 4358 return 0; /* can't find valid BIOS pin config */
4359 } 4359 }
4360 4360
4361 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && 4361 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT &&
4362 cfg->line_outs <= cfg->hp_outs) { 4362 cfg->line_outs <= cfg->hp_outs) {
4363 /* use HP as primary out */ 4363 /* use HP as primary out */
4364 cfg->speaker_outs = cfg->line_outs; 4364 cfg->speaker_outs = cfg->line_outs;
4365 memcpy(cfg->speaker_pins, cfg->line_out_pins, 4365 memcpy(cfg->speaker_pins, cfg->line_out_pins,
4366 sizeof(cfg->speaker_pins)); 4366 sizeof(cfg->speaker_pins));
4367 cfg->line_outs = cfg->hp_outs; 4367 cfg->line_outs = cfg->hp_outs;
4368 memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins)); 4368 memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins));
4369 cfg->hp_outs = 0; 4369 cfg->hp_outs = 0;
4370 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); 4370 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins));
4371 cfg->line_out_type = AUTO_PIN_HP_OUT; 4371 cfg->line_out_type = AUTO_PIN_HP_OUT;
4372 } 4372 }
4373 4373
4374 err = alc_auto_fill_dac_nids(codec); 4374 err = alc_auto_fill_dac_nids(codec);
4375 if (err < 0) 4375 if (err < 0)
4376 return err; 4376 return err;
4377 err = alc_auto_add_multi_channel_mode(codec); 4377 err = alc_auto_add_multi_channel_mode(codec);
4378 if (err < 0) 4378 if (err < 0)
4379 return err; 4379 return err;
4380 err = alc_auto_create_multi_out_ctls(codec, cfg); 4380 err = alc_auto_create_multi_out_ctls(codec, cfg);
4381 if (err < 0) 4381 if (err < 0)
4382 return err; 4382 return err;
4383 err = alc_auto_create_hp_out(codec); 4383 err = alc_auto_create_hp_out(codec);
4384 if (err < 0) 4384 if (err < 0)
4385 return err; 4385 return err;
4386 err = alc_auto_create_speaker_out(codec); 4386 err = alc_auto_create_speaker_out(codec);
4387 if (err < 0) 4387 if (err < 0)
4388 return err; 4388 return err;
4389 err = alc_auto_create_shared_input(codec); 4389 err = alc_auto_create_shared_input(codec);
4390 if (err < 0) 4390 if (err < 0)
4391 return err; 4391 return err;
4392 err = alc_auto_create_input_ctls(codec); 4392 err = alc_auto_create_input_ctls(codec);
4393 if (err < 0) 4393 if (err < 0)
4394 return err; 4394 return err;
4395 4395
4396 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 4396 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4397 4397
4398 dig_only: 4398 dig_only:
4399 alc_auto_parse_digital(codec); 4399 alc_auto_parse_digital(codec);
4400 4400
4401 if (!spec->no_analog) 4401 if (!spec->no_analog)
4402 alc_remove_invalid_adc_nids(codec); 4402 alc_remove_invalid_adc_nids(codec);
4403 4403
4404 if (ssid_nids) 4404 if (ssid_nids)
4405 alc_ssid_check(codec, ssid_nids); 4405 alc_ssid_check(codec, ssid_nids);
4406 4406
4407 if (!spec->no_analog) { 4407 if (!spec->no_analog) {
4408 alc_auto_check_switches(codec); 4408 alc_auto_check_switches(codec);
4409 err = alc_auto_add_mic_boost(codec); 4409 err = alc_auto_add_mic_boost(codec);
4410 if (err < 0) 4410 if (err < 0)
4411 return err; 4411 return err;
4412 } 4412 }
4413 4413
4414 if (spec->kctls.list) 4414 if (spec->kctls.list)
4415 add_mixer(spec, spec->kctls.list); 4415 add_mixer(spec, spec->kctls.list);
4416 4416
4417 if (!spec->no_analog && !spec->cap_mixer) 4417 if (!spec->no_analog && !spec->cap_mixer)
4418 set_capture_mixer(codec); 4418 set_capture_mixer(codec);
4419 4419
4420 return 1; 4420 return 1;
4421 } 4421 }
4422 4422
4423 static int alc880_parse_auto_config(struct hda_codec *codec) 4423 static int alc880_parse_auto_config(struct hda_codec *codec)
4424 { 4424 {
4425 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; 4425 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
4426 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 }; 4426 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4427 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids); 4427 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
4428 } 4428 }
4429 4429
4430 /* 4430 /*
4431 * ALC880 fix-ups 4431 * ALC880 fix-ups
4432 */ 4432 */
4433 enum { 4433 enum {
4434 ALC880_FIXUP_GPIO1, 4434 ALC880_FIXUP_GPIO1,
4435 ALC880_FIXUP_GPIO2, 4435 ALC880_FIXUP_GPIO2,
4436 ALC880_FIXUP_MEDION_RIM, 4436 ALC880_FIXUP_MEDION_RIM,
4437 ALC880_FIXUP_LG, 4437 ALC880_FIXUP_LG,
4438 ALC880_FIXUP_W810, 4438 ALC880_FIXUP_W810,
4439 ALC880_FIXUP_EAPD_COEF, 4439 ALC880_FIXUP_EAPD_COEF,
4440 ALC880_FIXUP_TCL_S700, 4440 ALC880_FIXUP_TCL_S700,
4441 ALC880_FIXUP_VOL_KNOB, 4441 ALC880_FIXUP_VOL_KNOB,
4442 ALC880_FIXUP_FUJITSU, 4442 ALC880_FIXUP_FUJITSU,
4443 ALC880_FIXUP_F1734, 4443 ALC880_FIXUP_F1734,
4444 ALC880_FIXUP_UNIWILL, 4444 ALC880_FIXUP_UNIWILL,
4445 ALC880_FIXUP_UNIWILL_DIG, 4445 ALC880_FIXUP_UNIWILL_DIG,
4446 ALC880_FIXUP_Z71V, 4446 ALC880_FIXUP_Z71V,
4447 ALC880_FIXUP_3ST_BASE, 4447 ALC880_FIXUP_3ST_BASE,
4448 ALC880_FIXUP_3ST, 4448 ALC880_FIXUP_3ST,
4449 ALC880_FIXUP_3ST_DIG, 4449 ALC880_FIXUP_3ST_DIG,
4450 ALC880_FIXUP_5ST_BASE, 4450 ALC880_FIXUP_5ST_BASE,
4451 ALC880_FIXUP_5ST, 4451 ALC880_FIXUP_5ST,
4452 ALC880_FIXUP_5ST_DIG, 4452 ALC880_FIXUP_5ST_DIG,
4453 ALC880_FIXUP_6ST_BASE, 4453 ALC880_FIXUP_6ST_BASE,
4454 ALC880_FIXUP_6ST, 4454 ALC880_FIXUP_6ST,
4455 ALC880_FIXUP_6ST_DIG, 4455 ALC880_FIXUP_6ST_DIG,
4456 }; 4456 };
4457 4457
4458 /* enable the volume-knob widget support on NID 0x21 */ 4458 /* enable the volume-knob widget support on NID 0x21 */
4459 static void alc880_fixup_vol_knob(struct hda_codec *codec, 4459 static void alc880_fixup_vol_knob(struct hda_codec *codec,
4460 const struct alc_fixup *fix, int action) 4460 const struct alc_fixup *fix, int action)
4461 { 4461 {
4462 if (action == ALC_FIXUP_ACT_PROBE) 4462 if (action == ALC_FIXUP_ACT_PROBE)
4463 snd_hda_jack_detect_enable(codec, 0x21, ALC_DCVOL_EVENT); 4463 snd_hda_jack_detect_enable(codec, 0x21, ALC_DCVOL_EVENT);
4464 } 4464 }
4465 4465
4466 static const struct alc_fixup alc880_fixups[] = { 4466 static const struct alc_fixup alc880_fixups[] = {
4467 [ALC880_FIXUP_GPIO1] = { 4467 [ALC880_FIXUP_GPIO1] = {
4468 .type = ALC_FIXUP_VERBS, 4468 .type = ALC_FIXUP_VERBS,
4469 .v.verbs = alc_gpio1_init_verbs, 4469 .v.verbs = alc_gpio1_init_verbs,
4470 }, 4470 },
4471 [ALC880_FIXUP_GPIO2] = { 4471 [ALC880_FIXUP_GPIO2] = {
4472 .type = ALC_FIXUP_VERBS, 4472 .type = ALC_FIXUP_VERBS,
4473 .v.verbs = alc_gpio2_init_verbs, 4473 .v.verbs = alc_gpio2_init_verbs,
4474 }, 4474 },
4475 [ALC880_FIXUP_MEDION_RIM] = { 4475 [ALC880_FIXUP_MEDION_RIM] = {
4476 .type = ALC_FIXUP_VERBS, 4476 .type = ALC_FIXUP_VERBS,
4477 .v.verbs = (const struct hda_verb[]) { 4477 .v.verbs = (const struct hda_verb[]) {
4478 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 4478 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4479 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, 4479 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
4480 { } 4480 { }
4481 }, 4481 },
4482 .chained = true, 4482 .chained = true,
4483 .chain_id = ALC880_FIXUP_GPIO2, 4483 .chain_id = ALC880_FIXUP_GPIO2,
4484 }, 4484 },
4485 [ALC880_FIXUP_LG] = { 4485 [ALC880_FIXUP_LG] = {
4486 .type = ALC_FIXUP_PINS, 4486 .type = ALC_FIXUP_PINS,
4487 .v.pins = (const struct alc_pincfg[]) { 4487 .v.pins = (const struct alc_pincfg[]) {
4488 /* disable bogus unused pins */ 4488 /* disable bogus unused pins */
4489 { 0x16, 0x411111f0 }, 4489 { 0x16, 0x411111f0 },
4490 { 0x18, 0x411111f0 }, 4490 { 0x18, 0x411111f0 },
4491 { 0x1a, 0x411111f0 }, 4491 { 0x1a, 0x411111f0 },
4492 { } 4492 { }
4493 } 4493 }
4494 }, 4494 },
4495 [ALC880_FIXUP_W810] = { 4495 [ALC880_FIXUP_W810] = {
4496 .type = ALC_FIXUP_PINS, 4496 .type = ALC_FIXUP_PINS,
4497 .v.pins = (const struct alc_pincfg[]) { 4497 .v.pins = (const struct alc_pincfg[]) {
4498 /* disable bogus unused pins */ 4498 /* disable bogus unused pins */
4499 { 0x17, 0x411111f0 }, 4499 { 0x17, 0x411111f0 },
4500 { } 4500 { }
4501 }, 4501 },
4502 .chained = true, 4502 .chained = true,
4503 .chain_id = ALC880_FIXUP_GPIO2, 4503 .chain_id = ALC880_FIXUP_GPIO2,
4504 }, 4504 },
4505 [ALC880_FIXUP_EAPD_COEF] = { 4505 [ALC880_FIXUP_EAPD_COEF] = {
4506 .type = ALC_FIXUP_VERBS, 4506 .type = ALC_FIXUP_VERBS,
4507 .v.verbs = (const struct hda_verb[]) { 4507 .v.verbs = (const struct hda_verb[]) {
4508 /* change to EAPD mode */ 4508 /* change to EAPD mode */
4509 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 4509 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4510 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, 4510 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
4511 {} 4511 {}
4512 }, 4512 },
4513 }, 4513 },
4514 [ALC880_FIXUP_TCL_S700] = { 4514 [ALC880_FIXUP_TCL_S700] = {
4515 .type = ALC_FIXUP_VERBS, 4515 .type = ALC_FIXUP_VERBS,
4516 .v.verbs = (const struct hda_verb[]) { 4516 .v.verbs = (const struct hda_verb[]) {
4517 /* change to EAPD mode */ 4517 /* change to EAPD mode */
4518 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 4518 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4519 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, 4519 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
4520 {} 4520 {}
4521 }, 4521 },
4522 .chained = true, 4522 .chained = true,
4523 .chain_id = ALC880_FIXUP_GPIO2, 4523 .chain_id = ALC880_FIXUP_GPIO2,
4524 }, 4524 },
4525 [ALC880_FIXUP_VOL_KNOB] = { 4525 [ALC880_FIXUP_VOL_KNOB] = {
4526 .type = ALC_FIXUP_FUNC, 4526 .type = ALC_FIXUP_FUNC,
4527 .v.func = alc880_fixup_vol_knob, 4527 .v.func = alc880_fixup_vol_knob,
4528 }, 4528 },
4529 [ALC880_FIXUP_FUJITSU] = { 4529 [ALC880_FIXUP_FUJITSU] = {
4530 /* override all pins as BIOS on old Amilo is broken */ 4530 /* override all pins as BIOS on old Amilo is broken */
4531 .type = ALC_FIXUP_PINS, 4531 .type = ALC_FIXUP_PINS,
4532 .v.pins = (const struct alc_pincfg[]) { 4532 .v.pins = (const struct alc_pincfg[]) {
4533 { 0x14, 0x0121411f }, /* HP */ 4533 { 0x14, 0x0121411f }, /* HP */
4534 { 0x15, 0x99030120 }, /* speaker */ 4534 { 0x15, 0x99030120 }, /* speaker */
4535 { 0x16, 0x99030130 }, /* bass speaker */ 4535 { 0x16, 0x99030130 }, /* bass speaker */
4536 { 0x17, 0x411111f0 }, /* N/A */ 4536 { 0x17, 0x411111f0 }, /* N/A */
4537 { 0x18, 0x411111f0 }, /* N/A */ 4537 { 0x18, 0x411111f0 }, /* N/A */
4538 { 0x19, 0x01a19950 }, /* mic-in */ 4538 { 0x19, 0x01a19950 }, /* mic-in */
4539 { 0x1a, 0x411111f0 }, /* N/A */ 4539 { 0x1a, 0x411111f0 }, /* N/A */
4540 { 0x1b, 0x411111f0 }, /* N/A */ 4540 { 0x1b, 0x411111f0 }, /* N/A */
4541 { 0x1c, 0x411111f0 }, /* N/A */ 4541 { 0x1c, 0x411111f0 }, /* N/A */
4542 { 0x1d, 0x411111f0 }, /* N/A */ 4542 { 0x1d, 0x411111f0 }, /* N/A */
4543 { 0x1e, 0x01454140 }, /* SPDIF out */ 4543 { 0x1e, 0x01454140 }, /* SPDIF out */
4544 { } 4544 { }
4545 }, 4545 },
4546 .chained = true, 4546 .chained = true,
4547 .chain_id = ALC880_FIXUP_VOL_KNOB, 4547 .chain_id = ALC880_FIXUP_VOL_KNOB,
4548 }, 4548 },
4549 [ALC880_FIXUP_F1734] = { 4549 [ALC880_FIXUP_F1734] = {
4550 /* almost compatible with FUJITSU, but no bass and SPDIF */ 4550 /* almost compatible with FUJITSU, but no bass and SPDIF */
4551 .type = ALC_FIXUP_PINS, 4551 .type = ALC_FIXUP_PINS,
4552 .v.pins = (const struct alc_pincfg[]) { 4552 .v.pins = (const struct alc_pincfg[]) {
4553 { 0x14, 0x0121411f }, /* HP */ 4553 { 0x14, 0x0121411f }, /* HP */
4554 { 0x15, 0x99030120 }, /* speaker */ 4554 { 0x15, 0x99030120 }, /* speaker */
4555 { 0x16, 0x411111f0 }, /* N/A */ 4555 { 0x16, 0x411111f0 }, /* N/A */
4556 { 0x17, 0x411111f0 }, /* N/A */ 4556 { 0x17, 0x411111f0 }, /* N/A */
4557 { 0x18, 0x411111f0 }, /* N/A */ 4557 { 0x18, 0x411111f0 }, /* N/A */
4558 { 0x19, 0x01a19950 }, /* mic-in */ 4558 { 0x19, 0x01a19950 }, /* mic-in */
4559 { 0x1a, 0x411111f0 }, /* N/A */ 4559 { 0x1a, 0x411111f0 }, /* N/A */
4560 { 0x1b, 0x411111f0 }, /* N/A */ 4560 { 0x1b, 0x411111f0 }, /* N/A */
4561 { 0x1c, 0x411111f0 }, /* N/A */ 4561 { 0x1c, 0x411111f0 }, /* N/A */
4562 { 0x1d, 0x411111f0 }, /* N/A */ 4562 { 0x1d, 0x411111f0 }, /* N/A */
4563 { 0x1e, 0x411111f0 }, /* N/A */ 4563 { 0x1e, 0x411111f0 }, /* N/A */
4564 { } 4564 { }
4565 }, 4565 },
4566 .chained = true, 4566 .chained = true,
4567 .chain_id = ALC880_FIXUP_VOL_KNOB, 4567 .chain_id = ALC880_FIXUP_VOL_KNOB,
4568 }, 4568 },
4569 [ALC880_FIXUP_UNIWILL] = { 4569 [ALC880_FIXUP_UNIWILL] = {
4570 /* need to fix HP and speaker pins to be parsed correctly */ 4570 /* need to fix HP and speaker pins to be parsed correctly */
4571 .type = ALC_FIXUP_PINS, 4571 .type = ALC_FIXUP_PINS,
4572 .v.pins = (const struct alc_pincfg[]) { 4572 .v.pins = (const struct alc_pincfg[]) {
4573 { 0x14, 0x0121411f }, /* HP */ 4573 { 0x14, 0x0121411f }, /* HP */
4574 { 0x15, 0x99030120 }, /* speaker */ 4574 { 0x15, 0x99030120 }, /* speaker */
4575 { 0x16, 0x99030130 }, /* bass speaker */ 4575 { 0x16, 0x99030130 }, /* bass speaker */
4576 { } 4576 { }
4577 }, 4577 },
4578 }, 4578 },
4579 [ALC880_FIXUP_UNIWILL_DIG] = { 4579 [ALC880_FIXUP_UNIWILL_DIG] = {
4580 .type = ALC_FIXUP_PINS, 4580 .type = ALC_FIXUP_PINS,
4581 .v.pins = (const struct alc_pincfg[]) { 4581 .v.pins = (const struct alc_pincfg[]) {
4582 /* disable bogus unused pins */ 4582 /* disable bogus unused pins */
4583 { 0x17, 0x411111f0 }, 4583 { 0x17, 0x411111f0 },
4584 { 0x19, 0x411111f0 }, 4584 { 0x19, 0x411111f0 },
4585 { 0x1b, 0x411111f0 }, 4585 { 0x1b, 0x411111f0 },
4586 { 0x1f, 0x411111f0 }, 4586 { 0x1f, 0x411111f0 },
4587 { } 4587 { }
4588 } 4588 }
4589 }, 4589 },
4590 [ALC880_FIXUP_Z71V] = { 4590 [ALC880_FIXUP_Z71V] = {
4591 .type = ALC_FIXUP_PINS, 4591 .type = ALC_FIXUP_PINS,
4592 .v.pins = (const struct alc_pincfg[]) { 4592 .v.pins = (const struct alc_pincfg[]) {
4593 /* set up the whole pins as BIOS is utterly broken */ 4593 /* set up the whole pins as BIOS is utterly broken */
4594 { 0x14, 0x99030120 }, /* speaker */ 4594 { 0x14, 0x99030120 }, /* speaker */
4595 { 0x15, 0x0121411f }, /* HP */ 4595 { 0x15, 0x0121411f }, /* HP */
4596 { 0x16, 0x411111f0 }, /* N/A */ 4596 { 0x16, 0x411111f0 }, /* N/A */
4597 { 0x17, 0x411111f0 }, /* N/A */ 4597 { 0x17, 0x411111f0 }, /* N/A */
4598 { 0x18, 0x01a19950 }, /* mic-in */ 4598 { 0x18, 0x01a19950 }, /* mic-in */
4599 { 0x19, 0x411111f0 }, /* N/A */ 4599 { 0x19, 0x411111f0 }, /* N/A */
4600 { 0x1a, 0x01813031 }, /* line-in */ 4600 { 0x1a, 0x01813031 }, /* line-in */
4601 { 0x1b, 0x411111f0 }, /* N/A */ 4601 { 0x1b, 0x411111f0 }, /* N/A */
4602 { 0x1c, 0x411111f0 }, /* N/A */ 4602 { 0x1c, 0x411111f0 }, /* N/A */
4603 { 0x1d, 0x411111f0 }, /* N/A */ 4603 { 0x1d, 0x411111f0 }, /* N/A */
4604 { 0x1e, 0x0144111e }, /* SPDIF */ 4604 { 0x1e, 0x0144111e }, /* SPDIF */
4605 { } 4605 { }
4606 } 4606 }
4607 }, 4607 },
4608 [ALC880_FIXUP_3ST_BASE] = { 4608 [ALC880_FIXUP_3ST_BASE] = {
4609 .type = ALC_FIXUP_PINS, 4609 .type = ALC_FIXUP_PINS,
4610 .v.pins = (const struct alc_pincfg[]) { 4610 .v.pins = (const struct alc_pincfg[]) {
4611 { 0x14, 0x01014010 }, /* line-out */ 4611 { 0x14, 0x01014010 }, /* line-out */
4612 { 0x15, 0x411111f0 }, /* N/A */ 4612 { 0x15, 0x411111f0 }, /* N/A */
4613 { 0x16, 0x411111f0 }, /* N/A */ 4613 { 0x16, 0x411111f0 }, /* N/A */
4614 { 0x17, 0x411111f0 }, /* N/A */ 4614 { 0x17, 0x411111f0 }, /* N/A */
4615 { 0x18, 0x01a19c30 }, /* mic-in */ 4615 { 0x18, 0x01a19c30 }, /* mic-in */
4616 { 0x19, 0x0121411f }, /* HP */ 4616 { 0x19, 0x0121411f }, /* HP */
4617 { 0x1a, 0x01813031 }, /* line-in */ 4617 { 0x1a, 0x01813031 }, /* line-in */
4618 { 0x1b, 0x02a19c40 }, /* front-mic */ 4618 { 0x1b, 0x02a19c40 }, /* front-mic */
4619 { 0x1c, 0x411111f0 }, /* N/A */ 4619 { 0x1c, 0x411111f0 }, /* N/A */
4620 { 0x1d, 0x411111f0 }, /* N/A */ 4620 { 0x1d, 0x411111f0 }, /* N/A */
4621 /* 0x1e is filled in below */ 4621 /* 0x1e is filled in below */
4622 { 0x1f, 0x411111f0 }, /* N/A */ 4622 { 0x1f, 0x411111f0 }, /* N/A */
4623 { } 4623 { }
4624 } 4624 }
4625 }, 4625 },
4626 [ALC880_FIXUP_3ST] = { 4626 [ALC880_FIXUP_3ST] = {
4627 .type = ALC_FIXUP_PINS, 4627 .type = ALC_FIXUP_PINS,
4628 .v.pins = (const struct alc_pincfg[]) { 4628 .v.pins = (const struct alc_pincfg[]) {
4629 { 0x1e, 0x411111f0 }, /* N/A */ 4629 { 0x1e, 0x411111f0 }, /* N/A */
4630 { } 4630 { }
4631 }, 4631 },
4632 .chained = true, 4632 .chained = true,
4633 .chain_id = ALC880_FIXUP_3ST_BASE, 4633 .chain_id = ALC880_FIXUP_3ST_BASE,
4634 }, 4634 },
4635 [ALC880_FIXUP_3ST_DIG] = { 4635 [ALC880_FIXUP_3ST_DIG] = {
4636 .type = ALC_FIXUP_PINS, 4636 .type = ALC_FIXUP_PINS,
4637 .v.pins = (const struct alc_pincfg[]) { 4637 .v.pins = (const struct alc_pincfg[]) {
4638 { 0x1e, 0x0144111e }, /* SPDIF */ 4638 { 0x1e, 0x0144111e }, /* SPDIF */
4639 { } 4639 { }
4640 }, 4640 },
4641 .chained = true, 4641 .chained = true,
4642 .chain_id = ALC880_FIXUP_3ST_BASE, 4642 .chain_id = ALC880_FIXUP_3ST_BASE,
4643 }, 4643 },
4644 [ALC880_FIXUP_5ST_BASE] = { 4644 [ALC880_FIXUP_5ST_BASE] = {
4645 .type = ALC_FIXUP_PINS, 4645 .type = ALC_FIXUP_PINS,
4646 .v.pins = (const struct alc_pincfg[]) { 4646 .v.pins = (const struct alc_pincfg[]) {
4647 { 0x14, 0x01014010 }, /* front */ 4647 { 0x14, 0x01014010 }, /* front */
4648 { 0x15, 0x411111f0 }, /* N/A */ 4648 { 0x15, 0x411111f0 }, /* N/A */
4649 { 0x16, 0x01011411 }, /* CLFE */ 4649 { 0x16, 0x01011411 }, /* CLFE */
4650 { 0x17, 0x01016412 }, /* surr */ 4650 { 0x17, 0x01016412 }, /* surr */
4651 { 0x18, 0x01a19c30 }, /* mic-in */ 4651 { 0x18, 0x01a19c30 }, /* mic-in */
4652 { 0x19, 0x0121411f }, /* HP */ 4652 { 0x19, 0x0121411f }, /* HP */
4653 { 0x1a, 0x01813031 }, /* line-in */ 4653 { 0x1a, 0x01813031 }, /* line-in */
4654 { 0x1b, 0x02a19c40 }, /* front-mic */ 4654 { 0x1b, 0x02a19c40 }, /* front-mic */
4655 { 0x1c, 0x411111f0 }, /* N/A */ 4655 { 0x1c, 0x411111f0 }, /* N/A */
4656 { 0x1d, 0x411111f0 }, /* N/A */ 4656 { 0x1d, 0x411111f0 }, /* N/A */
4657 /* 0x1e is filled in below */ 4657 /* 0x1e is filled in below */
4658 { 0x1f, 0x411111f0 }, /* N/A */ 4658 { 0x1f, 0x411111f0 }, /* N/A */
4659 { } 4659 { }
4660 } 4660 }
4661 }, 4661 },
4662 [ALC880_FIXUP_5ST] = { 4662 [ALC880_FIXUP_5ST] = {
4663 .type = ALC_FIXUP_PINS, 4663 .type = ALC_FIXUP_PINS,
4664 .v.pins = (const struct alc_pincfg[]) { 4664 .v.pins = (const struct alc_pincfg[]) {
4665 { 0x1e, 0x411111f0 }, /* N/A */ 4665 { 0x1e, 0x411111f0 }, /* N/A */
4666 { } 4666 { }
4667 }, 4667 },
4668 .chained = true, 4668 .chained = true,
4669 .chain_id = ALC880_FIXUP_5ST_BASE, 4669 .chain_id = ALC880_FIXUP_5ST_BASE,
4670 }, 4670 },
4671 [ALC880_FIXUP_5ST_DIG] = { 4671 [ALC880_FIXUP_5ST_DIG] = {
4672 .type = ALC_FIXUP_PINS, 4672 .type = ALC_FIXUP_PINS,
4673 .v.pins = (const struct alc_pincfg[]) { 4673 .v.pins = (const struct alc_pincfg[]) {
4674 { 0x1e, 0x0144111e }, /* SPDIF */ 4674 { 0x1e, 0x0144111e }, /* SPDIF */
4675 { } 4675 { }
4676 }, 4676 },
4677 .chained = true, 4677 .chained = true,
4678 .chain_id = ALC880_FIXUP_5ST_BASE, 4678 .chain_id = ALC880_FIXUP_5ST_BASE,
4679 }, 4679 },
4680 [ALC880_FIXUP_6ST_BASE] = { 4680 [ALC880_FIXUP_6ST_BASE] = {
4681 .type = ALC_FIXUP_PINS, 4681 .type = ALC_FIXUP_PINS,
4682 .v.pins = (const struct alc_pincfg[]) { 4682 .v.pins = (const struct alc_pincfg[]) {
4683 { 0x14, 0x01014010 }, /* front */ 4683 { 0x14, 0x01014010 }, /* front */
4684 { 0x15, 0x01016412 }, /* surr */ 4684 { 0x15, 0x01016412 }, /* surr */
4685 { 0x16, 0x01011411 }, /* CLFE */ 4685 { 0x16, 0x01011411 }, /* CLFE */
4686 { 0x17, 0x01012414 }, /* side */ 4686 { 0x17, 0x01012414 }, /* side */
4687 { 0x18, 0x01a19c30 }, /* mic-in */ 4687 { 0x18, 0x01a19c30 }, /* mic-in */
4688 { 0x19, 0x02a19c40 }, /* front-mic */ 4688 { 0x19, 0x02a19c40 }, /* front-mic */
4689 { 0x1a, 0x01813031 }, /* line-in */ 4689 { 0x1a, 0x01813031 }, /* line-in */
4690 { 0x1b, 0x0121411f }, /* HP */ 4690 { 0x1b, 0x0121411f }, /* HP */
4691 { 0x1c, 0x411111f0 }, /* N/A */ 4691 { 0x1c, 0x411111f0 }, /* N/A */
4692 { 0x1d, 0x411111f0 }, /* N/A */ 4692 { 0x1d, 0x411111f0 }, /* N/A */
4693 /* 0x1e is filled in below */ 4693 /* 0x1e is filled in below */
4694 { 0x1f, 0x411111f0 }, /* N/A */ 4694 { 0x1f, 0x411111f0 }, /* N/A */
4695 { } 4695 { }
4696 } 4696 }
4697 }, 4697 },
4698 [ALC880_FIXUP_6ST] = { 4698 [ALC880_FIXUP_6ST] = {
4699 .type = ALC_FIXUP_PINS, 4699 .type = ALC_FIXUP_PINS,
4700 .v.pins = (const struct alc_pincfg[]) { 4700 .v.pins = (const struct alc_pincfg[]) {
4701 { 0x1e, 0x411111f0 }, /* N/A */ 4701 { 0x1e, 0x411111f0 }, /* N/A */
4702 { } 4702 { }
4703 }, 4703 },
4704 .chained = true, 4704 .chained = true,
4705 .chain_id = ALC880_FIXUP_6ST_BASE, 4705 .chain_id = ALC880_FIXUP_6ST_BASE,
4706 }, 4706 },
4707 [ALC880_FIXUP_6ST_DIG] = { 4707 [ALC880_FIXUP_6ST_DIG] = {
4708 .type = ALC_FIXUP_PINS, 4708 .type = ALC_FIXUP_PINS,
4709 .v.pins = (const struct alc_pincfg[]) { 4709 .v.pins = (const struct alc_pincfg[]) {
4710 { 0x1e, 0x0144111e }, /* SPDIF */ 4710 { 0x1e, 0x0144111e }, /* SPDIF */
4711 { } 4711 { }
4712 }, 4712 },
4713 .chained = true, 4713 .chained = true,
4714 .chain_id = ALC880_FIXUP_6ST_BASE, 4714 .chain_id = ALC880_FIXUP_6ST_BASE,
4715 }, 4715 },
4716 }; 4716 };
4717 4717
4718 static const struct snd_pci_quirk alc880_fixup_tbl[] = { 4718 static const struct snd_pci_quirk alc880_fixup_tbl[] = {
4719 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810), 4719 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
4720 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V), 4720 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
4721 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1), 4721 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
4722 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2), 4722 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
4723 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF), 4723 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
4724 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG), 4724 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
4725 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734), 4725 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
4726 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL), 4726 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
4727 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB), 4727 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
4728 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810), 4728 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
4729 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM), 4729 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
4730 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734), 4730 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734),
4731 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU), 4731 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
4732 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734), 4732 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
4733 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU), 4733 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
4734 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG), 4734 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
4735 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG), 4735 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
4736 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG), 4736 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
4737 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700), 4737 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
4738 4738
4739 /* Below is the copied entries from alc880_quirks.c. 4739 /* Below is the copied entries from alc880_quirks.c.
4740 * It's not quite sure whether BIOS sets the correct pin-config table 4740 * It's not quite sure whether BIOS sets the correct pin-config table
4741 * on these machines, thus they are kept to be compatible with 4741 * on these machines, thus they are kept to be compatible with
4742 * the old static quirks. Once when it's confirmed to work without 4742 * the old static quirks. Once when it's confirmed to work without
4743 * these overrides, it'd be better to remove. 4743 * these overrides, it'd be better to remove.
4744 */ 4744 */
4745 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG), 4745 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
4746 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST), 4746 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
4747 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG), 4747 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
4748 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG), 4748 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
4749 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG), 4749 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
4750 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG), 4750 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
4751 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG), 4751 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
4752 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST), 4752 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
4753 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG), 4753 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
4754 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST), 4754 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
4755 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST), 4755 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
4756 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST), 4756 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
4757 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST), 4757 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
4758 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST), 4758 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
4759 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG), 4759 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
4760 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG), 4760 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
4761 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG), 4761 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
4762 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG), 4762 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
4763 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG), 4763 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
4764 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG), 4764 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
4765 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG), 4765 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
4766 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */ 4766 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
4767 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG), 4767 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
4768 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG), 4768 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
4769 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG), 4769 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
4770 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG), 4770 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
4771 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG), 4771 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
4772 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG), 4772 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
4773 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG), 4773 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
4774 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG), 4774 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
4775 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG), 4775 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
4776 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG), 4776 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
4777 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG), 4777 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
4778 /* default Intel */ 4778 /* default Intel */
4779 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST), 4779 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
4780 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG), 4780 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
4781 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG), 4781 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
4782 {} 4782 {}
4783 }; 4783 };
4784 4784
4785 static const struct alc_model_fixup alc880_fixup_models[] = { 4785 static const struct alc_model_fixup alc880_fixup_models[] = {
4786 {.id = ALC880_FIXUP_3ST, .name = "3stack"}, 4786 {.id = ALC880_FIXUP_3ST, .name = "3stack"},
4787 {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"}, 4787 {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
4788 {.id = ALC880_FIXUP_5ST, .name = "5stack"}, 4788 {.id = ALC880_FIXUP_5ST, .name = "5stack"},
4789 {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"}, 4789 {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
4790 {.id = ALC880_FIXUP_6ST, .name = "6stack"}, 4790 {.id = ALC880_FIXUP_6ST, .name = "6stack"},
4791 {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"}, 4791 {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
4792 {} 4792 {}
4793 }; 4793 };
4794 4794
4795 4795
4796 /* 4796 /*
4797 * OK, here we have finally the patch for ALC880 4797 * OK, here we have finally the patch for ALC880
4798 */ 4798 */
4799 static int patch_alc880(struct hda_codec *codec) 4799 static int patch_alc880(struct hda_codec *codec)
4800 { 4800 {
4801 struct alc_spec *spec; 4801 struct alc_spec *spec;
4802 int err; 4802 int err;
4803 4803
4804 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4804 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4805 if (spec == NULL) 4805 if (spec == NULL)
4806 return -ENOMEM; 4806 return -ENOMEM;
4807 4807
4808 codec->spec = spec; 4808 codec->spec = spec;
4809 4809
4810 spec->mixer_nid = 0x0b; 4810 spec->mixer_nid = 0x0b;
4811 spec->need_dac_fix = 1; 4811 spec->need_dac_fix = 1;
4812 4812
4813 alc_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, 4813 alc_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
4814 alc880_fixups); 4814 alc880_fixups);
4815 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); 4815 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4816 4816
4817 /* automatic parse from the BIOS config */ 4817 /* automatic parse from the BIOS config */
4818 err = alc880_parse_auto_config(codec); 4818 err = alc880_parse_auto_config(codec);
4819 if (err < 0) 4819 if (err < 0)
4820 goto error; 4820 goto error;
4821 4821
4822 if (!spec->no_analog) { 4822 if (!spec->no_analog) {
4823 err = snd_hda_attach_beep_device(codec, 0x1); 4823 err = snd_hda_attach_beep_device(codec, 0x1);
4824 if (err < 0) 4824 if (err < 0)
4825 goto error; 4825 goto error;
4826 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 4826 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4827 } 4827 }
4828 4828
4829 codec->patch_ops = alc_patch_ops; 4829 codec->patch_ops = alc_patch_ops;
4830 4830
4831 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 4831 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4832 4832
4833 return 0; 4833 return 0;
4834 4834
4835 error: 4835 error:
4836 alc_free(codec); 4836 alc_free(codec);
4837 return err; 4837 return err;
4838 } 4838 }
4839 4839
4840 4840
4841 /* 4841 /*
4842 * ALC260 support 4842 * ALC260 support
4843 */ 4843 */
4844 static int alc260_parse_auto_config(struct hda_codec *codec) 4844 static int alc260_parse_auto_config(struct hda_codec *codec)
4845 { 4845 {
4846 static const hda_nid_t alc260_ignore[] = { 0x17, 0 }; 4846 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
4847 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 }; 4847 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
4848 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids); 4848 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
4849 } 4849 }
4850 4850
4851 /* 4851 /*
4852 * Pin config fixes 4852 * Pin config fixes
4853 */ 4853 */
4854 enum { 4854 enum {
4855 ALC260_FIXUP_HP_DC5750, 4855 ALC260_FIXUP_HP_DC5750,
4856 ALC260_FIXUP_HP_PIN_0F, 4856 ALC260_FIXUP_HP_PIN_0F,
4857 ALC260_FIXUP_COEF, 4857 ALC260_FIXUP_COEF,
4858 ALC260_FIXUP_GPIO1, 4858 ALC260_FIXUP_GPIO1,
4859 ALC260_FIXUP_GPIO1_TOGGLE, 4859 ALC260_FIXUP_GPIO1_TOGGLE,
4860 ALC260_FIXUP_REPLACER, 4860 ALC260_FIXUP_REPLACER,
4861 ALC260_FIXUP_HP_B1900, 4861 ALC260_FIXUP_HP_B1900,
4862 }; 4862 };
4863 4863
4864 static void alc260_gpio1_automute(struct hda_codec *codec) 4864 static void alc260_gpio1_automute(struct hda_codec *codec)
4865 { 4865 {
4866 struct alc_spec *spec = codec->spec; 4866 struct alc_spec *spec = codec->spec;
4867 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 4867 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
4868 spec->hp_jack_present); 4868 spec->hp_jack_present);
4869 } 4869 }
4870 4870
4871 static void alc260_fixup_gpio1_toggle(struct hda_codec *codec, 4871 static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
4872 const struct alc_fixup *fix, int action) 4872 const struct alc_fixup *fix, int action)
4873 { 4873 {
4874 struct alc_spec *spec = codec->spec; 4874 struct alc_spec *spec = codec->spec;
4875 if (action == ALC_FIXUP_ACT_PROBE) { 4875 if (action == ALC_FIXUP_ACT_PROBE) {
4876 /* although the machine has only one output pin, we need to 4876 /* although the machine has only one output pin, we need to
4877 * toggle GPIO1 according to the jack state 4877 * toggle GPIO1 according to the jack state
4878 */ 4878 */
4879 spec->automute_hook = alc260_gpio1_automute; 4879 spec->automute_hook = alc260_gpio1_automute;
4880 spec->detect_hp = 1; 4880 spec->detect_hp = 1;
4881 spec->automute_speaker = 1; 4881 spec->automute_speaker = 1;
4882 spec->autocfg.hp_pins[0] = 0x0f; /* copy it for automute */ 4882 spec->autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
4883 snd_hda_jack_detect_enable(codec, 0x0f, ALC_HP_EVENT); 4883 snd_hda_jack_detect_enable(codec, 0x0f, ALC_HP_EVENT);
4884 spec->unsol_event = alc_sku_unsol_event; 4884 spec->unsol_event = alc_sku_unsol_event;
4885 add_verb(codec->spec, alc_gpio1_init_verbs); 4885 add_verb(codec->spec, alc_gpio1_init_verbs);
4886 } 4886 }
4887 } 4887 }
4888 4888
4889 static const struct alc_fixup alc260_fixups[] = { 4889 static const struct alc_fixup alc260_fixups[] = {
4890 [ALC260_FIXUP_HP_DC5750] = { 4890 [ALC260_FIXUP_HP_DC5750] = {
4891 .type = ALC_FIXUP_PINS, 4891 .type = ALC_FIXUP_PINS,
4892 .v.pins = (const struct alc_pincfg[]) { 4892 .v.pins = (const struct alc_pincfg[]) {
4893 { 0x11, 0x90130110 }, /* speaker */ 4893 { 0x11, 0x90130110 }, /* speaker */
4894 { } 4894 { }
4895 } 4895 }
4896 }, 4896 },
4897 [ALC260_FIXUP_HP_PIN_0F] = { 4897 [ALC260_FIXUP_HP_PIN_0F] = {
4898 .type = ALC_FIXUP_PINS, 4898 .type = ALC_FIXUP_PINS,
4899 .v.pins = (const struct alc_pincfg[]) { 4899 .v.pins = (const struct alc_pincfg[]) {
4900 { 0x0f, 0x01214000 }, /* HP */ 4900 { 0x0f, 0x01214000 }, /* HP */
4901 { } 4901 { }
4902 } 4902 }
4903 }, 4903 },
4904 [ALC260_FIXUP_COEF] = { 4904 [ALC260_FIXUP_COEF] = {
4905 .type = ALC_FIXUP_VERBS, 4905 .type = ALC_FIXUP_VERBS,
4906 .v.verbs = (const struct hda_verb[]) { 4906 .v.verbs = (const struct hda_verb[]) {
4907 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 4907 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4908 { 0x20, AC_VERB_SET_PROC_COEF, 0x3040 }, 4908 { 0x20, AC_VERB_SET_PROC_COEF, 0x3040 },
4909 { } 4909 { }
4910 }, 4910 },
4911 .chained = true, 4911 .chained = true,
4912 .chain_id = ALC260_FIXUP_HP_PIN_0F, 4912 .chain_id = ALC260_FIXUP_HP_PIN_0F,
4913 }, 4913 },
4914 [ALC260_FIXUP_GPIO1] = { 4914 [ALC260_FIXUP_GPIO1] = {
4915 .type = ALC_FIXUP_VERBS, 4915 .type = ALC_FIXUP_VERBS,
4916 .v.verbs = alc_gpio1_init_verbs, 4916 .v.verbs = alc_gpio1_init_verbs,
4917 }, 4917 },
4918 [ALC260_FIXUP_GPIO1_TOGGLE] = { 4918 [ALC260_FIXUP_GPIO1_TOGGLE] = {
4919 .type = ALC_FIXUP_FUNC, 4919 .type = ALC_FIXUP_FUNC,
4920 .v.func = alc260_fixup_gpio1_toggle, 4920 .v.func = alc260_fixup_gpio1_toggle,
4921 .chained = true, 4921 .chained = true,
4922 .chain_id = ALC260_FIXUP_HP_PIN_0F, 4922 .chain_id = ALC260_FIXUP_HP_PIN_0F,
4923 }, 4923 },
4924 [ALC260_FIXUP_REPLACER] = { 4924 [ALC260_FIXUP_REPLACER] = {
4925 .type = ALC_FIXUP_VERBS, 4925 .type = ALC_FIXUP_VERBS,
4926 .v.verbs = (const struct hda_verb[]) { 4926 .v.verbs = (const struct hda_verb[]) {
4927 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 4927 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
4928 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, 4928 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
4929 { } 4929 { }
4930 }, 4930 },
4931 .chained = true, 4931 .chained = true,
4932 .chain_id = ALC260_FIXUP_GPIO1_TOGGLE, 4932 .chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
4933 }, 4933 },
4934 [ALC260_FIXUP_HP_B1900] = { 4934 [ALC260_FIXUP_HP_B1900] = {
4935 .type = ALC_FIXUP_FUNC, 4935 .type = ALC_FIXUP_FUNC,
4936 .v.func = alc260_fixup_gpio1_toggle, 4936 .v.func = alc260_fixup_gpio1_toggle,
4937 .chained = true, 4937 .chained = true,
4938 .chain_id = ALC260_FIXUP_COEF, 4938 .chain_id = ALC260_FIXUP_COEF,
4939 } 4939 }
4940 }; 4940 };
4941 4941
4942 static const struct snd_pci_quirk alc260_fixup_tbl[] = { 4942 static const struct snd_pci_quirk alc260_fixup_tbl[] = {
4943 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1), 4943 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
4944 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF), 4944 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
4945 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1), 4945 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
4946 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750), 4946 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
4947 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900), 4947 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
4948 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1), 4948 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
4949 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER), 4949 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
4950 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF), 4950 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
4951 {} 4951 {}
4952 }; 4952 };
4953 4953
4954 /* 4954 /*
4955 */ 4955 */
4956 static int patch_alc260(struct hda_codec *codec) 4956 static int patch_alc260(struct hda_codec *codec)
4957 { 4957 {
4958 struct alc_spec *spec; 4958 struct alc_spec *spec;
4959 int err; 4959 int err;
4960 4960
4961 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4961 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4962 if (spec == NULL) 4962 if (spec == NULL)
4963 return -ENOMEM; 4963 return -ENOMEM;
4964 4964
4965 codec->spec = spec; 4965 codec->spec = spec;
4966 4966
4967 spec->mixer_nid = 0x07; 4967 spec->mixer_nid = 0x07;
4968 4968
4969 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); 4969 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
4970 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); 4970 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
4971 4971
4972 /* automatic parse from the BIOS config */ 4972 /* automatic parse from the BIOS config */
4973 err = alc260_parse_auto_config(codec); 4973 err = alc260_parse_auto_config(codec);
4974 if (err < 0) 4974 if (err < 0)
4975 goto error; 4975 goto error;
4976 4976
4977 if (!spec->no_analog) { 4977 if (!spec->no_analog) {
4978 err = snd_hda_attach_beep_device(codec, 0x1); 4978 err = snd_hda_attach_beep_device(codec, 0x1);
4979 if (err < 0) 4979 if (err < 0)
4980 goto error; 4980 goto error;
4981 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); 4981 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
4982 } 4982 }
4983 4983
4984 codec->patch_ops = alc_patch_ops; 4984 codec->patch_ops = alc_patch_ops;
4985 spec->shutup = alc_eapd_shutup; 4985 spec->shutup = alc_eapd_shutup;
4986 4986
4987 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 4987 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
4988 4988
4989 return 0; 4989 return 0;
4990 4990
4991 error: 4991 error:
4992 alc_free(codec); 4992 alc_free(codec);
4993 return err; 4993 return err;
4994 } 4994 }
4995 4995
4996 4996
4997 /* 4997 /*
4998 * ALC882/883/885/888/889 support 4998 * ALC882/883/885/888/889 support
4999 * 4999 *
5000 * ALC882 is almost identical with ALC880 but has cleaner and more flexible 5000 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5001 * configuration. Each pin widget can choose any input DACs and a mixer. 5001 * configuration. Each pin widget can choose any input DACs and a mixer.
5002 * Each ADC is connected from a mixer of all inputs. This makes possible 5002 * Each ADC is connected from a mixer of all inputs. This makes possible
5003 * 6-channel independent captures. 5003 * 6-channel independent captures.
5004 * 5004 *
5005 * In addition, an independent DAC for the multi-playback (not used in this 5005 * In addition, an independent DAC for the multi-playback (not used in this
5006 * driver yet). 5006 * driver yet).
5007 */ 5007 */
5008 5008
5009 /* 5009 /*
5010 * Pin config fixes 5010 * Pin config fixes
5011 */ 5011 */
5012 enum { 5012 enum {
5013 ALC882_FIXUP_ABIT_AW9D_MAX, 5013 ALC882_FIXUP_ABIT_AW9D_MAX,
5014 ALC882_FIXUP_LENOVO_Y530, 5014 ALC882_FIXUP_LENOVO_Y530,
5015 ALC882_FIXUP_PB_M5210, 5015 ALC882_FIXUP_PB_M5210,
5016 ALC882_FIXUP_ACER_ASPIRE_7736, 5016 ALC882_FIXUP_ACER_ASPIRE_7736,
5017 ALC882_FIXUP_ASUS_W90V, 5017 ALC882_FIXUP_ASUS_W90V,
5018 ALC889_FIXUP_CD, 5018 ALC889_FIXUP_CD,
5019 ALC889_FIXUP_VAIO_TT, 5019 ALC889_FIXUP_VAIO_TT,
5020 ALC888_FIXUP_EEE1601, 5020 ALC888_FIXUP_EEE1601,
5021 ALC882_FIXUP_EAPD, 5021 ALC882_FIXUP_EAPD,
5022 ALC883_FIXUP_EAPD, 5022 ALC883_FIXUP_EAPD,
5023 ALC883_FIXUP_ACER_EAPD, 5023 ALC883_FIXUP_ACER_EAPD,
5024 ALC882_FIXUP_GPIO1, 5024 ALC882_FIXUP_GPIO1,
5025 ALC882_FIXUP_GPIO2, 5025 ALC882_FIXUP_GPIO2,
5026 ALC882_FIXUP_GPIO3, 5026 ALC882_FIXUP_GPIO3,
5027 ALC889_FIXUP_COEF, 5027 ALC889_FIXUP_COEF,
5028 ALC882_FIXUP_ASUS_W2JC, 5028 ALC882_FIXUP_ASUS_W2JC,
5029 ALC882_FIXUP_ACER_ASPIRE_4930G, 5029 ALC882_FIXUP_ACER_ASPIRE_4930G,
5030 ALC882_FIXUP_ACER_ASPIRE_8930G, 5030 ALC882_FIXUP_ACER_ASPIRE_8930G,
5031 ALC882_FIXUP_ASPIRE_8930G_VERBS, 5031 ALC882_FIXUP_ASPIRE_8930G_VERBS,
5032 ALC885_FIXUP_MACPRO_GPIO, 5032 ALC885_FIXUP_MACPRO_GPIO,
5033 ALC889_FIXUP_DAC_ROUTE, 5033 ALC889_FIXUP_DAC_ROUTE,
5034 ALC889_FIXUP_MBP_VREF, 5034 ALC889_FIXUP_MBP_VREF,
5035 ALC889_FIXUP_IMAC91_VREF, 5035 ALC889_FIXUP_IMAC91_VREF,
5036 }; 5036 };
5037 5037
5038 static void alc889_fixup_coef(struct hda_codec *codec, 5038 static void alc889_fixup_coef(struct hda_codec *codec,
5039 const struct alc_fixup *fix, int action) 5039 const struct alc_fixup *fix, int action)
5040 { 5040 {
5041 if (action != ALC_FIXUP_ACT_INIT) 5041 if (action != ALC_FIXUP_ACT_INIT)
5042 return; 5042 return;
5043 alc889_coef_init(codec); 5043 alc889_coef_init(codec);
5044 } 5044 }
5045 5045
5046 /* toggle speaker-output according to the hp-jack state */ 5046 /* toggle speaker-output according to the hp-jack state */
5047 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) 5047 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5048 { 5048 {
5049 unsigned int gpiostate, gpiomask, gpiodir; 5049 unsigned int gpiostate, gpiomask, gpiodir;
5050 5050
5051 gpiostate = snd_hda_codec_read(codec, codec->afg, 0, 5051 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5052 AC_VERB_GET_GPIO_DATA, 0); 5052 AC_VERB_GET_GPIO_DATA, 0);
5053 5053
5054 if (!muted) 5054 if (!muted)
5055 gpiostate |= (1 << pin); 5055 gpiostate |= (1 << pin);
5056 else 5056 else
5057 gpiostate &= ~(1 << pin); 5057 gpiostate &= ~(1 << pin);
5058 5058
5059 gpiomask = snd_hda_codec_read(codec, codec->afg, 0, 5059 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5060 AC_VERB_GET_GPIO_MASK, 0); 5060 AC_VERB_GET_GPIO_MASK, 0);
5061 gpiomask |= (1 << pin); 5061 gpiomask |= (1 << pin);
5062 5062
5063 gpiodir = snd_hda_codec_read(codec, codec->afg, 0, 5063 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5064 AC_VERB_GET_GPIO_DIRECTION, 0); 5064 AC_VERB_GET_GPIO_DIRECTION, 0);
5065 gpiodir |= (1 << pin); 5065 gpiodir |= (1 << pin);
5066 5066
5067 5067
5068 snd_hda_codec_write(codec, codec->afg, 0, 5068 snd_hda_codec_write(codec, codec->afg, 0,
5069 AC_VERB_SET_GPIO_MASK, gpiomask); 5069 AC_VERB_SET_GPIO_MASK, gpiomask);
5070 snd_hda_codec_write(codec, codec->afg, 0, 5070 snd_hda_codec_write(codec, codec->afg, 0,
5071 AC_VERB_SET_GPIO_DIRECTION, gpiodir); 5071 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5072 5072
5073 msleep(1); 5073 msleep(1);
5074 5074
5075 snd_hda_codec_write(codec, codec->afg, 0, 5075 snd_hda_codec_write(codec, codec->afg, 0,
5076 AC_VERB_SET_GPIO_DATA, gpiostate); 5076 AC_VERB_SET_GPIO_DATA, gpiostate);
5077 } 5077 }
5078 5078
5079 /* set up GPIO at initialization */ 5079 /* set up GPIO at initialization */
5080 static void alc885_fixup_macpro_gpio(struct hda_codec *codec, 5080 static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
5081 const struct alc_fixup *fix, int action) 5081 const struct alc_fixup *fix, int action)
5082 { 5082 {
5083 if (action != ALC_FIXUP_ACT_INIT) 5083 if (action != ALC_FIXUP_ACT_INIT)
5084 return; 5084 return;
5085 alc882_gpio_mute(codec, 0, 0); 5085 alc882_gpio_mute(codec, 0, 0);
5086 alc882_gpio_mute(codec, 1, 0); 5086 alc882_gpio_mute(codec, 1, 0);
5087 } 5087 }
5088 5088
5089 /* Fix the connection of some pins for ALC889: 5089 /* Fix the connection of some pins for ALC889:
5090 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't 5090 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
5091 * work correctly (bko#42740) 5091 * work correctly (bko#42740)
5092 */ 5092 */
5093 static void alc889_fixup_dac_route(struct hda_codec *codec, 5093 static void alc889_fixup_dac_route(struct hda_codec *codec,
5094 const struct alc_fixup *fix, int action) 5094 const struct alc_fixup *fix, int action)
5095 { 5095 {
5096 if (action == ALC_FIXUP_ACT_PRE_PROBE) { 5096 if (action == ALC_FIXUP_ACT_PRE_PROBE) {
5097 /* fake the connections during parsing the tree */ 5097 /* fake the connections during parsing the tree */
5098 hda_nid_t conn1[2] = { 0x0c, 0x0d }; 5098 hda_nid_t conn1[2] = { 0x0c, 0x0d };
5099 hda_nid_t conn2[2] = { 0x0e, 0x0f }; 5099 hda_nid_t conn2[2] = { 0x0e, 0x0f };
5100 snd_hda_override_conn_list(codec, 0x14, 2, conn1); 5100 snd_hda_override_conn_list(codec, 0x14, 2, conn1);
5101 snd_hda_override_conn_list(codec, 0x15, 2, conn1); 5101 snd_hda_override_conn_list(codec, 0x15, 2, conn1);
5102 snd_hda_override_conn_list(codec, 0x18, 2, conn2); 5102 snd_hda_override_conn_list(codec, 0x18, 2, conn2);
5103 snd_hda_override_conn_list(codec, 0x1a, 2, conn2); 5103 snd_hda_override_conn_list(codec, 0x1a, 2, conn2);
5104 } else if (action == ALC_FIXUP_ACT_PROBE) { 5104 } else if (action == ALC_FIXUP_ACT_PROBE) {
5105 /* restore the connections */ 5105 /* restore the connections */
5106 hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; 5106 hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
5107 snd_hda_override_conn_list(codec, 0x14, 5, conn); 5107 snd_hda_override_conn_list(codec, 0x14, 5, conn);
5108 snd_hda_override_conn_list(codec, 0x15, 5, conn); 5108 snd_hda_override_conn_list(codec, 0x15, 5, conn);
5109 snd_hda_override_conn_list(codec, 0x18, 5, conn); 5109 snd_hda_override_conn_list(codec, 0x18, 5, conn);
5110 snd_hda_override_conn_list(codec, 0x1a, 5, conn); 5110 snd_hda_override_conn_list(codec, 0x1a, 5, conn);
5111 } 5111 }
5112 } 5112 }
5113 5113
5114 /* Set VREF on HP pin */ 5114 /* Set VREF on HP pin */
5115 static void alc889_fixup_mbp_vref(struct hda_codec *codec, 5115 static void alc889_fixup_mbp_vref(struct hda_codec *codec,
5116 const struct alc_fixup *fix, int action) 5116 const struct alc_fixup *fix, int action)
5117 { 5117 {
5118 struct alc_spec *spec = codec->spec; 5118 struct alc_spec *spec = codec->spec;
5119 static hda_nid_t nids[2] = { 0x14, 0x15 }; 5119 static hda_nid_t nids[2] = { 0x14, 0x15 };
5120 int i; 5120 int i;
5121 5121
5122 if (action != ALC_FIXUP_ACT_INIT) 5122 if (action != ALC_FIXUP_ACT_INIT)
5123 return; 5123 return;
5124 for (i = 0; i < ARRAY_SIZE(nids); i++) { 5124 for (i = 0; i < ARRAY_SIZE(nids); i++) {
5125 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]); 5125 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
5126 if (get_defcfg_device(val) != AC_JACK_HP_OUT) 5126 if (get_defcfg_device(val) != AC_JACK_HP_OUT)
5127 continue; 5127 continue;
5128 val = snd_hda_codec_read(codec, nids[i], 0, 5128 val = snd_hda_codec_read(codec, nids[i], 0,
5129 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 5129 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5130 val |= AC_PINCTL_VREF_80; 5130 val |= AC_PINCTL_VREF_80;
5131 snd_hda_codec_write(codec, nids[i], 0, 5131 snd_hda_codec_write(codec, nids[i], 0,
5132 AC_VERB_SET_PIN_WIDGET_CONTROL, val); 5132 AC_VERB_SET_PIN_WIDGET_CONTROL, val);
5133 spec->keep_vref_in_automute = 1; 5133 spec->keep_vref_in_automute = 1;
5134 break; 5134 break;
5135 } 5135 }
5136 } 5136 }
5137 5137
5138 /* Set VREF on speaker pins on imac91 */ 5138 /* Set VREF on speaker pins on imac91 */
5139 static void alc889_fixup_imac91_vref(struct hda_codec *codec, 5139 static void alc889_fixup_imac91_vref(struct hda_codec *codec,
5140 const struct alc_fixup *fix, int action) 5140 const struct alc_fixup *fix, int action)
5141 { 5141 {
5142 struct alc_spec *spec = codec->spec; 5142 struct alc_spec *spec = codec->spec;
5143 static hda_nid_t nids[2] = { 0x18, 0x1a }; 5143 static hda_nid_t nids[2] = { 0x18, 0x1a };
5144 int i; 5144 int i;
5145 5145
5146 if (action != ALC_FIXUP_ACT_INIT) 5146 if (action != ALC_FIXUP_ACT_INIT)
5147 return; 5147 return;
5148 for (i = 0; i < ARRAY_SIZE(nids); i++) { 5148 for (i = 0; i < ARRAY_SIZE(nids); i++) {
5149 unsigned int val; 5149 unsigned int val;
5150 val = snd_hda_codec_read(codec, nids[i], 0, 5150 val = snd_hda_codec_read(codec, nids[i], 0,
5151 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 5151 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5152 val |= AC_PINCTL_VREF_50; 5152 val |= AC_PINCTL_VREF_50;
5153 snd_hda_codec_write(codec, nids[i], 0, 5153 snd_hda_codec_write(codec, nids[i], 0,
5154 AC_VERB_SET_PIN_WIDGET_CONTROL, val); 5154 AC_VERB_SET_PIN_WIDGET_CONTROL, val);
5155 } 5155 }
5156 spec->keep_vref_in_automute = 1; 5156 spec->keep_vref_in_automute = 1;
5157 } 5157 }
5158 5158
5159 static const struct alc_fixup alc882_fixups[] = { 5159 static const struct alc_fixup alc882_fixups[] = {
5160 [ALC882_FIXUP_ABIT_AW9D_MAX] = { 5160 [ALC882_FIXUP_ABIT_AW9D_MAX] = {
5161 .type = ALC_FIXUP_PINS, 5161 .type = ALC_FIXUP_PINS,
5162 .v.pins = (const struct alc_pincfg[]) { 5162 .v.pins = (const struct alc_pincfg[]) {
5163 { 0x15, 0x01080104 }, /* side */ 5163 { 0x15, 0x01080104 }, /* side */
5164 { 0x16, 0x01011012 }, /* rear */ 5164 { 0x16, 0x01011012 }, /* rear */
5165 { 0x17, 0x01016011 }, /* clfe */ 5165 { 0x17, 0x01016011 }, /* clfe */
5166 { } 5166 { }
5167 } 5167 }
5168 }, 5168 },
5169 [ALC882_FIXUP_LENOVO_Y530] = { 5169 [ALC882_FIXUP_LENOVO_Y530] = {
5170 .type = ALC_FIXUP_PINS, 5170 .type = ALC_FIXUP_PINS,
5171 .v.pins = (const struct alc_pincfg[]) { 5171 .v.pins = (const struct alc_pincfg[]) {
5172 { 0x15, 0x99130112 }, /* rear int speakers */ 5172 { 0x15, 0x99130112 }, /* rear int speakers */
5173 { 0x16, 0x99130111 }, /* subwoofer */ 5173 { 0x16, 0x99130111 }, /* subwoofer */
5174 { } 5174 { }
5175 } 5175 }
5176 }, 5176 },
5177 [ALC882_FIXUP_PB_M5210] = { 5177 [ALC882_FIXUP_PB_M5210] = {
5178 .type = ALC_FIXUP_VERBS, 5178 .type = ALC_FIXUP_VERBS,
5179 .v.verbs = (const struct hda_verb[]) { 5179 .v.verbs = (const struct hda_verb[]) {
5180 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, 5180 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
5181 {} 5181 {}
5182 } 5182 }
5183 }, 5183 },
5184 [ALC882_FIXUP_ACER_ASPIRE_7736] = { 5184 [ALC882_FIXUP_ACER_ASPIRE_7736] = {
5185 .type = ALC_FIXUP_SKU, 5185 .type = ALC_FIXUP_SKU,
5186 .v.sku = ALC_FIXUP_SKU_IGNORE, 5186 .v.sku = ALC_FIXUP_SKU_IGNORE,
5187 }, 5187 },
5188 [ALC882_FIXUP_ASUS_W90V] = { 5188 [ALC882_FIXUP_ASUS_W90V] = {
5189 .type = ALC_FIXUP_PINS, 5189 .type = ALC_FIXUP_PINS,
5190 .v.pins = (const struct alc_pincfg[]) { 5190 .v.pins = (const struct alc_pincfg[]) {
5191 { 0x16, 0x99130110 }, /* fix sequence for CLFE */ 5191 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
5192 { } 5192 { }
5193 } 5193 }
5194 }, 5194 },
5195 [ALC889_FIXUP_CD] = { 5195 [ALC889_FIXUP_CD] = {
5196 .type = ALC_FIXUP_PINS, 5196 .type = ALC_FIXUP_PINS,
5197 .v.pins = (const struct alc_pincfg[]) { 5197 .v.pins = (const struct alc_pincfg[]) {
5198 { 0x1c, 0x993301f0 }, /* CD */ 5198 { 0x1c, 0x993301f0 }, /* CD */
5199 { } 5199 { }
5200 } 5200 }
5201 }, 5201 },
5202 [ALC889_FIXUP_VAIO_TT] = { 5202 [ALC889_FIXUP_VAIO_TT] = {
5203 .type = ALC_FIXUP_PINS, 5203 .type = ALC_FIXUP_PINS,
5204 .v.pins = (const struct alc_pincfg[]) { 5204 .v.pins = (const struct alc_pincfg[]) {
5205 { 0x17, 0x90170111 }, /* hidden surround speaker */ 5205 { 0x17, 0x90170111 }, /* hidden surround speaker */
5206 { } 5206 { }
5207 } 5207 }
5208 }, 5208 },
5209 [ALC888_FIXUP_EEE1601] = { 5209 [ALC888_FIXUP_EEE1601] = {
5210 .type = ALC_FIXUP_VERBS, 5210 .type = ALC_FIXUP_VERBS,
5211 .v.verbs = (const struct hda_verb[]) { 5211 .v.verbs = (const struct hda_verb[]) {
5212 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, 5212 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
5213 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 }, 5213 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
5214 { } 5214 { }
5215 } 5215 }
5216 }, 5216 },
5217 [ALC882_FIXUP_EAPD] = { 5217 [ALC882_FIXUP_EAPD] = {
5218 .type = ALC_FIXUP_VERBS, 5218 .type = ALC_FIXUP_VERBS,
5219 .v.verbs = (const struct hda_verb[]) { 5219 .v.verbs = (const struct hda_verb[]) {
5220 /* change to EAPD mode */ 5220 /* change to EAPD mode */
5221 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 5221 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
5222 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, 5222 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
5223 { } 5223 { }
5224 } 5224 }
5225 }, 5225 },
5226 [ALC883_FIXUP_EAPD] = { 5226 [ALC883_FIXUP_EAPD] = {
5227 .type = ALC_FIXUP_VERBS, 5227 .type = ALC_FIXUP_VERBS,
5228 .v.verbs = (const struct hda_verb[]) { 5228 .v.verbs = (const struct hda_verb[]) {
5229 /* change to EAPD mode */ 5229 /* change to EAPD mode */
5230 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 5230 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
5231 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, 5231 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
5232 { } 5232 { }
5233 } 5233 }
5234 }, 5234 },
5235 [ALC883_FIXUP_ACER_EAPD] = { 5235 [ALC883_FIXUP_ACER_EAPD] = {
5236 .type = ALC_FIXUP_VERBS, 5236 .type = ALC_FIXUP_VERBS,
5237 .v.verbs = (const struct hda_verb[]) { 5237 .v.verbs = (const struct hda_verb[]) {
5238 /* eanable EAPD on Acer laptops */ 5238 /* eanable EAPD on Acer laptops */
5239 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 5239 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
5240 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, 5240 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
5241 { } 5241 { }
5242 } 5242 }
5243 }, 5243 },
5244 [ALC882_FIXUP_GPIO1] = { 5244 [ALC882_FIXUP_GPIO1] = {
5245 .type = ALC_FIXUP_VERBS, 5245 .type = ALC_FIXUP_VERBS,
5246 .v.verbs = alc_gpio1_init_verbs, 5246 .v.verbs = alc_gpio1_init_verbs,
5247 }, 5247 },
5248 [ALC882_FIXUP_GPIO2] = { 5248 [ALC882_FIXUP_GPIO2] = {
5249 .type = ALC_FIXUP_VERBS, 5249 .type = ALC_FIXUP_VERBS,
5250 .v.verbs = alc_gpio2_init_verbs, 5250 .v.verbs = alc_gpio2_init_verbs,
5251 }, 5251 },
5252 [ALC882_FIXUP_GPIO3] = { 5252 [ALC882_FIXUP_GPIO3] = {
5253 .type = ALC_FIXUP_VERBS, 5253 .type = ALC_FIXUP_VERBS,
5254 .v.verbs = alc_gpio3_init_verbs, 5254 .v.verbs = alc_gpio3_init_verbs,
5255 }, 5255 },
5256 [ALC882_FIXUP_ASUS_W2JC] = { 5256 [ALC882_FIXUP_ASUS_W2JC] = {
5257 .type = ALC_FIXUP_VERBS, 5257 .type = ALC_FIXUP_VERBS,
5258 .v.verbs = alc_gpio1_init_verbs, 5258 .v.verbs = alc_gpio1_init_verbs,
5259 .chained = true, 5259 .chained = true,
5260 .chain_id = ALC882_FIXUP_EAPD, 5260 .chain_id = ALC882_FIXUP_EAPD,
5261 }, 5261 },
5262 [ALC889_FIXUP_COEF] = { 5262 [ALC889_FIXUP_COEF] = {
5263 .type = ALC_FIXUP_FUNC, 5263 .type = ALC_FIXUP_FUNC,
5264 .v.func = alc889_fixup_coef, 5264 .v.func = alc889_fixup_coef,
5265 }, 5265 },
5266 [ALC882_FIXUP_ACER_ASPIRE_4930G] = { 5266 [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
5267 .type = ALC_FIXUP_PINS, 5267 .type = ALC_FIXUP_PINS,
5268 .v.pins = (const struct alc_pincfg[]) { 5268 .v.pins = (const struct alc_pincfg[]) {
5269 { 0x16, 0x99130111 }, /* CLFE speaker */ 5269 { 0x16, 0x99130111 }, /* CLFE speaker */
5270 { 0x17, 0x99130112 }, /* surround speaker */ 5270 { 0x17, 0x99130112 }, /* surround speaker */
5271 { } 5271 { }
5272 } 5272 }
5273 }, 5273 },
5274 [ALC882_FIXUP_ACER_ASPIRE_8930G] = { 5274 [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
5275 .type = ALC_FIXUP_PINS, 5275 .type = ALC_FIXUP_PINS,
5276 .v.pins = (const struct alc_pincfg[]) { 5276 .v.pins = (const struct alc_pincfg[]) {
5277 { 0x16, 0x99130111 }, /* CLFE speaker */ 5277 { 0x16, 0x99130111 }, /* CLFE speaker */
5278 { 0x1b, 0x99130112 }, /* surround speaker */ 5278 { 0x1b, 0x99130112 }, /* surround speaker */
5279 { } 5279 { }
5280 }, 5280 },
5281 .chained = true, 5281 .chained = true,
5282 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS, 5282 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
5283 }, 5283 },
5284 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = { 5284 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
5285 /* additional init verbs for Acer Aspire 8930G */ 5285 /* additional init verbs for Acer Aspire 8930G */
5286 .type = ALC_FIXUP_VERBS, 5286 .type = ALC_FIXUP_VERBS,
5287 .v.verbs = (const struct hda_verb[]) { 5287 .v.verbs = (const struct hda_verb[]) {
5288 /* Enable all DACs */ 5288 /* Enable all DACs */
5289 /* DAC DISABLE/MUTE 1? */ 5289 /* DAC DISABLE/MUTE 1? */
5290 /* setting bits 1-5 disables DAC nids 0x02-0x06 5290 /* setting bits 1-5 disables DAC nids 0x02-0x06
5291 * apparently. Init=0x38 */ 5291 * apparently. Init=0x38 */
5292 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 }, 5292 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
5293 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, 5293 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
5294 /* DAC DISABLE/MUTE 2? */ 5294 /* DAC DISABLE/MUTE 2? */
5295 /* some bit here disables the other DACs. 5295 /* some bit here disables the other DACs.
5296 * Init=0x4900 */ 5296 * Init=0x4900 */
5297 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 }, 5297 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
5298 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, 5298 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
5299 /* DMIC fix 5299 /* DMIC fix
5300 * This laptop has a stereo digital microphone. 5300 * This laptop has a stereo digital microphone.
5301 * The mics are only 1cm apart which makes the stereo 5301 * The mics are only 1cm apart which makes the stereo
5302 * useless. However, either the mic or the ALC889 5302 * useless. However, either the mic or the ALC889
5303 * makes the signal become a difference/sum signal 5303 * makes the signal become a difference/sum signal
5304 * instead of standard stereo, which is annoying. 5304 * instead of standard stereo, which is annoying.
5305 * So instead we flip this bit which makes the 5305 * So instead we flip this bit which makes the
5306 * codec replicate the sum signal to both channels, 5306 * codec replicate the sum signal to both channels,
5307 * turning it into a normal mono mic. 5307 * turning it into a normal mono mic.
5308 */ 5308 */
5309 /* DMIC_CONTROL? Init value = 0x0001 */ 5309 /* DMIC_CONTROL? Init value = 0x0001 */
5310 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, 5310 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
5311 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 }, 5311 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
5312 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 5312 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
5313 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, 5313 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
5314 { } 5314 { }
5315 } 5315 }
5316 }, 5316 },
5317 [ALC885_FIXUP_MACPRO_GPIO] = { 5317 [ALC885_FIXUP_MACPRO_GPIO] = {
5318 .type = ALC_FIXUP_FUNC, 5318 .type = ALC_FIXUP_FUNC,
5319 .v.func = alc885_fixup_macpro_gpio, 5319 .v.func = alc885_fixup_macpro_gpio,
5320 }, 5320 },
5321 [ALC889_FIXUP_DAC_ROUTE] = { 5321 [ALC889_FIXUP_DAC_ROUTE] = {
5322 .type = ALC_FIXUP_FUNC, 5322 .type = ALC_FIXUP_FUNC,
5323 .v.func = alc889_fixup_dac_route, 5323 .v.func = alc889_fixup_dac_route,
5324 }, 5324 },
5325 [ALC889_FIXUP_MBP_VREF] = { 5325 [ALC889_FIXUP_MBP_VREF] = {
5326 .type = ALC_FIXUP_FUNC, 5326 .type = ALC_FIXUP_FUNC,
5327 .v.func = alc889_fixup_mbp_vref, 5327 .v.func = alc889_fixup_mbp_vref,
5328 .chained = true, 5328 .chained = true,
5329 .chain_id = ALC882_FIXUP_GPIO1, 5329 .chain_id = ALC882_FIXUP_GPIO1,
5330 }, 5330 },
5331 [ALC889_FIXUP_IMAC91_VREF] = { 5331 [ALC889_FIXUP_IMAC91_VREF] = {
5332 .type = ALC_FIXUP_FUNC, 5332 .type = ALC_FIXUP_FUNC,
5333 .v.func = alc889_fixup_imac91_vref, 5333 .v.func = alc889_fixup_imac91_vref,
5334 .chained = true, 5334 .chained = true,
5335 .chain_id = ALC882_FIXUP_GPIO1, 5335 .chain_id = ALC882_FIXUP_GPIO1,
5336 }, 5336 },
5337 }; 5337 };
5338 5338
5339 static const struct snd_pci_quirk alc882_fixup_tbl[] = { 5339 static const struct snd_pci_quirk alc882_fixup_tbl[] = {
5340 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD), 5340 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
5341 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), 5341 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
5342 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD), 5342 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
5343 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), 5343 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
5344 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD), 5344 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
5345 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD), 5345 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
5346 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", 5346 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
5347 ALC882_FIXUP_ACER_ASPIRE_4930G), 5347 ALC882_FIXUP_ACER_ASPIRE_4930G),
5348 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", 5348 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
5349 ALC882_FIXUP_ACER_ASPIRE_4930G), 5349 ALC882_FIXUP_ACER_ASPIRE_4930G),
5350 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G", 5350 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
5351 ALC882_FIXUP_ACER_ASPIRE_8930G), 5351 ALC882_FIXUP_ACER_ASPIRE_8930G),
5352 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", 5352 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
5353 ALC882_FIXUP_ACER_ASPIRE_8930G), 5353 ALC882_FIXUP_ACER_ASPIRE_8930G),
5354 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", 5354 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
5355 ALC882_FIXUP_ACER_ASPIRE_4930G), 5355 ALC882_FIXUP_ACER_ASPIRE_4930G),
5356 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", 5356 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
5357 ALC882_FIXUP_ACER_ASPIRE_4930G), 5357 ALC882_FIXUP_ACER_ASPIRE_4930G),
5358 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", 5358 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
5359 ALC882_FIXUP_ACER_ASPIRE_4930G), 5359 ALC882_FIXUP_ACER_ASPIRE_4930G),
5360 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210), 5360 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
5361 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE), 5361 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
5362 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736), 5362 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
5363 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD), 5363 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
5364 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V), 5364 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
5365 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), 5365 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
5366 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), 5366 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
5367 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), 5367 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
5368 5368
5369 /* All Apple entries are in codec SSIDs */ 5369 /* All Apple entries are in codec SSIDs */
5370 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF), 5370 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
5371 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF), 5371 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
5372 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), 5372 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
5373 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO), 5373 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO),
5374 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO), 5374 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
5375 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO), 5375 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
5376 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF), 5376 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
5377 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF), 5377 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
5378 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD), 5378 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
5379 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF), 5379 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF),
5380 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF), 5380 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF),
5381 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF), 5381 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
5382 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), 5382 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
5383 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO), 5383 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
5384 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF), 5384 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
5385 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF), 5385 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
5386 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF), 5386 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
5387 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF), 5387 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
5388 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF), 5388 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
5389 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF), 5389 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF),
5390 5390
5391 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), 5391 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
5392 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), 5392 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
5393 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD), 5393 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD),
5394 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX), 5394 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
5395 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD), 5395 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
5396 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD), 5396 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
5397 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530), 5397 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
5398 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF), 5398 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
5399 {} 5399 {}
5400 }; 5400 };
5401 5401
5402 static const struct alc_model_fixup alc882_fixup_models[] = {
5403 {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
5404 {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
5405 {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
5406 {}
5407 };
5408
5402 /* 5409 /*
5403 * BIOS auto configuration 5410 * BIOS auto configuration
5404 */ 5411 */
5405 /* almost identical with ALC880 parser... */ 5412 /* almost identical with ALC880 parser... */
5406 static int alc882_parse_auto_config(struct hda_codec *codec) 5413 static int alc882_parse_auto_config(struct hda_codec *codec)
5407 { 5414 {
5408 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 }; 5415 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
5409 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 }; 5416 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5410 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids); 5417 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
5411 } 5418 }
5412 5419
5413 /* 5420 /*
5414 */ 5421 */
5415 static int patch_alc882(struct hda_codec *codec) 5422 static int patch_alc882(struct hda_codec *codec)
5416 { 5423 {
5417 struct alc_spec *spec; 5424 struct alc_spec *spec;
5418 int err; 5425 int err;
5419 5426
5420 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5427 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5421 if (spec == NULL) 5428 if (spec == NULL)
5422 return -ENOMEM; 5429 return -ENOMEM;
5423 5430
5424 codec->spec = spec; 5431 codec->spec = spec;
5425 5432
5426 spec->mixer_nid = 0x0b; 5433 spec->mixer_nid = 0x0b;
5427 5434
5428 switch (codec->vendor_id) { 5435 switch (codec->vendor_id) {
5429 case 0x10ec0882: 5436 case 0x10ec0882:
5430 case 0x10ec0885: 5437 case 0x10ec0885:
5431 break; 5438 break;
5432 default: 5439 default:
5433 /* ALC883 and variants */ 5440 /* ALC883 and variants */
5434 alc_fix_pll_init(codec, 0x20, 0x0a, 10); 5441 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
5435 break; 5442 break;
5436 } 5443 }
5437 5444
5438 err = alc_codec_rename_from_preset(codec); 5445 err = alc_codec_rename_from_preset(codec);
5439 if (err < 0) 5446 if (err < 0)
5440 goto error; 5447 goto error;
5441 5448
5442 alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups); 5449 alc_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
5450 alc882_fixups);
5443 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); 5451 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
5444 5452
5445 alc_auto_parse_customize_define(codec); 5453 alc_auto_parse_customize_define(codec);
5446 5454
5447 /* automatic parse from the BIOS config */ 5455 /* automatic parse from the BIOS config */
5448 err = alc882_parse_auto_config(codec); 5456 err = alc882_parse_auto_config(codec);
5449 if (err < 0) 5457 if (err < 0)
5450 goto error; 5458 goto error;
5451 5459
5452 if (!spec->no_analog && has_cdefine_beep(codec)) { 5460 if (!spec->no_analog && has_cdefine_beep(codec)) {
5453 err = snd_hda_attach_beep_device(codec, 0x1); 5461 err = snd_hda_attach_beep_device(codec, 0x1);
5454 if (err < 0) 5462 if (err < 0)
5455 goto error; 5463 goto error;
5456 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 5464 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
5457 } 5465 }
5458 5466
5459 codec->patch_ops = alc_patch_ops; 5467 codec->patch_ops = alc_patch_ops;
5460 5468
5461 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 5469 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5462 5470
5463 return 0; 5471 return 0;
5464 5472
5465 error: 5473 error:
5466 alc_free(codec); 5474 alc_free(codec);
5467 return err; 5475 return err;
5468 } 5476 }
5469 5477
5470 5478
5471 /* 5479 /*
5472 * ALC262 support 5480 * ALC262 support
5473 */ 5481 */
5474 static int alc262_parse_auto_config(struct hda_codec *codec) 5482 static int alc262_parse_auto_config(struct hda_codec *codec)
5475 { 5483 {
5476 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 }; 5484 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
5477 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 }; 5485 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5478 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids); 5486 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
5479 } 5487 }
5480 5488
5481 /* 5489 /*
5482 * Pin config fixes 5490 * Pin config fixes
5483 */ 5491 */
5484 enum { 5492 enum {
5485 ALC262_FIXUP_FSC_H270, 5493 ALC262_FIXUP_FSC_H270,
5486 ALC262_FIXUP_HP_Z200, 5494 ALC262_FIXUP_HP_Z200,
5487 ALC262_FIXUP_TYAN, 5495 ALC262_FIXUP_TYAN,
5488 ALC262_FIXUP_LENOVO_3000, 5496 ALC262_FIXUP_LENOVO_3000,
5489 ALC262_FIXUP_BENQ, 5497 ALC262_FIXUP_BENQ,
5490 ALC262_FIXUP_BENQ_T31, 5498 ALC262_FIXUP_BENQ_T31,
5491 }; 5499 };
5492 5500
5493 static const struct alc_fixup alc262_fixups[] = { 5501 static const struct alc_fixup alc262_fixups[] = {
5494 [ALC262_FIXUP_FSC_H270] = { 5502 [ALC262_FIXUP_FSC_H270] = {
5495 .type = ALC_FIXUP_PINS, 5503 .type = ALC_FIXUP_PINS,
5496 .v.pins = (const struct alc_pincfg[]) { 5504 .v.pins = (const struct alc_pincfg[]) {
5497 { 0x14, 0x99130110 }, /* speaker */ 5505 { 0x14, 0x99130110 }, /* speaker */
5498 { 0x15, 0x0221142f }, /* front HP */ 5506 { 0x15, 0x0221142f }, /* front HP */
5499 { 0x1b, 0x0121141f }, /* rear HP */ 5507 { 0x1b, 0x0121141f }, /* rear HP */
5500 { } 5508 { }
5501 } 5509 }
5502 }, 5510 },
5503 [ALC262_FIXUP_HP_Z200] = { 5511 [ALC262_FIXUP_HP_Z200] = {
5504 .type = ALC_FIXUP_PINS, 5512 .type = ALC_FIXUP_PINS,
5505 .v.pins = (const struct alc_pincfg[]) { 5513 .v.pins = (const struct alc_pincfg[]) {
5506 { 0x16, 0x99130120 }, /* internal speaker */ 5514 { 0x16, 0x99130120 }, /* internal speaker */
5507 { } 5515 { }
5508 } 5516 }
5509 }, 5517 },
5510 [ALC262_FIXUP_TYAN] = { 5518 [ALC262_FIXUP_TYAN] = {
5511 .type = ALC_FIXUP_PINS, 5519 .type = ALC_FIXUP_PINS,
5512 .v.pins = (const struct alc_pincfg[]) { 5520 .v.pins = (const struct alc_pincfg[]) {
5513 { 0x14, 0x1993e1f0 }, /* int AUX */ 5521 { 0x14, 0x1993e1f0 }, /* int AUX */
5514 { } 5522 { }
5515 } 5523 }
5516 }, 5524 },
5517 [ALC262_FIXUP_LENOVO_3000] = { 5525 [ALC262_FIXUP_LENOVO_3000] = {
5518 .type = ALC_FIXUP_VERBS, 5526 .type = ALC_FIXUP_VERBS,
5519 .v.verbs = (const struct hda_verb[]) { 5527 .v.verbs = (const struct hda_verb[]) {
5520 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, 5528 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
5521 {} 5529 {}
5522 }, 5530 },
5523 .chained = true, 5531 .chained = true,
5524 .chain_id = ALC262_FIXUP_BENQ, 5532 .chain_id = ALC262_FIXUP_BENQ,
5525 }, 5533 },
5526 [ALC262_FIXUP_BENQ] = { 5534 [ALC262_FIXUP_BENQ] = {
5527 .type = ALC_FIXUP_VERBS, 5535 .type = ALC_FIXUP_VERBS,
5528 .v.verbs = (const struct hda_verb[]) { 5536 .v.verbs = (const struct hda_verb[]) {
5529 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 5537 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
5530 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, 5538 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
5531 {} 5539 {}
5532 } 5540 }
5533 }, 5541 },
5534 [ALC262_FIXUP_BENQ_T31] = { 5542 [ALC262_FIXUP_BENQ_T31] = {
5535 .type = ALC_FIXUP_VERBS, 5543 .type = ALC_FIXUP_VERBS,
5536 .v.verbs = (const struct hda_verb[]) { 5544 .v.verbs = (const struct hda_verb[]) {
5537 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 5545 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
5538 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, 5546 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
5539 {} 5547 {}
5540 } 5548 }
5541 }, 5549 },
5542 }; 5550 };
5543 5551
5544 static const struct snd_pci_quirk alc262_fixup_tbl[] = { 5552 static const struct snd_pci_quirk alc262_fixup_tbl[] = {
5545 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200), 5553 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
5546 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ), 5554 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ),
5547 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ), 5555 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
5548 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN), 5556 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
5549 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270), 5557 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
5550 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000), 5558 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
5551 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ), 5559 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
5552 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31), 5560 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
5553 {} 5561 {}
5554 }; 5562 };
5555 5563
5556 5564
5557 /* 5565 /*
5558 */ 5566 */
5559 static int patch_alc262(struct hda_codec *codec) 5567 static int patch_alc262(struct hda_codec *codec)
5560 { 5568 {
5561 struct alc_spec *spec; 5569 struct alc_spec *spec;
5562 int err; 5570 int err;
5563 5571
5564 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5572 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5565 if (spec == NULL) 5573 if (spec == NULL)
5566 return -ENOMEM; 5574 return -ENOMEM;
5567 5575
5568 codec->spec = spec; 5576 codec->spec = spec;
5569 5577
5570 spec->mixer_nid = 0x0b; 5578 spec->mixer_nid = 0x0b;
5571 5579
5572 #if 0 5580 #if 0
5573 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is 5581 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
5574 * under-run 5582 * under-run
5575 */ 5583 */
5576 { 5584 {
5577 int tmp; 5585 int tmp;
5578 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); 5586 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5579 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); 5587 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
5580 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); 5588 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5581 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); 5589 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
5582 } 5590 }
5583 #endif 5591 #endif
5584 alc_auto_parse_customize_define(codec); 5592 alc_auto_parse_customize_define(codec);
5585 5593
5586 alc_fix_pll_init(codec, 0x20, 0x0a, 10); 5594 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
5587 5595
5588 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups); 5596 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
5589 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); 5597 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
5590 5598
5591 /* automatic parse from the BIOS config */ 5599 /* automatic parse from the BIOS config */
5592 err = alc262_parse_auto_config(codec); 5600 err = alc262_parse_auto_config(codec);
5593 if (err < 0) 5601 if (err < 0)
5594 goto error; 5602 goto error;
5595 5603
5596 if (!spec->no_analog && has_cdefine_beep(codec)) { 5604 if (!spec->no_analog && has_cdefine_beep(codec)) {
5597 err = snd_hda_attach_beep_device(codec, 0x1); 5605 err = snd_hda_attach_beep_device(codec, 0x1);
5598 if (err < 0) 5606 if (err < 0)
5599 goto error; 5607 goto error;
5600 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 5608 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
5601 } 5609 }
5602 5610
5603 codec->patch_ops = alc_patch_ops; 5611 codec->patch_ops = alc_patch_ops;
5604 spec->shutup = alc_eapd_shutup; 5612 spec->shutup = alc_eapd_shutup;
5605 5613
5606 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 5614 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
5607 5615
5608 return 0; 5616 return 0;
5609 5617
5610 error: 5618 error:
5611 alc_free(codec); 5619 alc_free(codec);
5612 return err; 5620 return err;
5613 } 5621 }
5614 5622
5615 /* 5623 /*
5616 * ALC268 5624 * ALC268
5617 */ 5625 */
5618 /* bind Beep switches of both NID 0x0f and 0x10 */ 5626 /* bind Beep switches of both NID 0x0f and 0x10 */
5619 static const struct hda_bind_ctls alc268_bind_beep_sw = { 5627 static const struct hda_bind_ctls alc268_bind_beep_sw = {
5620 .ops = &snd_hda_bind_sw, 5628 .ops = &snd_hda_bind_sw,
5621 .values = { 5629 .values = {
5622 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), 5630 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
5623 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), 5631 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
5624 0 5632 0
5625 }, 5633 },
5626 }; 5634 };
5627 5635
5628 static const struct snd_kcontrol_new alc268_beep_mixer[] = { 5636 static const struct snd_kcontrol_new alc268_beep_mixer[] = {
5629 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), 5637 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
5630 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), 5638 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
5631 { } 5639 { }
5632 }; 5640 };
5633 5641
5634 /* set PCBEEP vol = 0, mute connections */ 5642 /* set PCBEEP vol = 0, mute connections */
5635 static const struct hda_verb alc268_beep_init_verbs[] = { 5643 static const struct hda_verb alc268_beep_init_verbs[] = {
5636 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5644 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5637 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5645 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5638 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 5646 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5639 { } 5647 { }
5640 }; 5648 };
5641 5649
5642 /* 5650 /*
5643 * BIOS auto configuration 5651 * BIOS auto configuration
5644 */ 5652 */
5645 static int alc268_parse_auto_config(struct hda_codec *codec) 5653 static int alc268_parse_auto_config(struct hda_codec *codec)
5646 { 5654 {
5647 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; 5655 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5648 struct alc_spec *spec = codec->spec; 5656 struct alc_spec *spec = codec->spec;
5649 int err = alc_parse_auto_config(codec, NULL, alc268_ssids); 5657 int err = alc_parse_auto_config(codec, NULL, alc268_ssids);
5650 if (err > 0) { 5658 if (err > 0) {
5651 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) { 5659 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) {
5652 add_mixer(spec, alc268_beep_mixer); 5660 add_mixer(spec, alc268_beep_mixer);
5653 add_verb(spec, alc268_beep_init_verbs); 5661 add_verb(spec, alc268_beep_init_verbs);
5654 } 5662 }
5655 } 5663 }
5656 return err; 5664 return err;
5657 } 5665 }
5658 5666
5659 /* 5667 /*
5660 */ 5668 */
5661 static int patch_alc268(struct hda_codec *codec) 5669 static int patch_alc268(struct hda_codec *codec)
5662 { 5670 {
5663 struct alc_spec *spec; 5671 struct alc_spec *spec;
5664 int i, has_beep, err; 5672 int i, has_beep, err;
5665 5673
5666 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5674 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5667 if (spec == NULL) 5675 if (spec == NULL)
5668 return -ENOMEM; 5676 return -ENOMEM;
5669 5677
5670 codec->spec = spec; 5678 codec->spec = spec;
5671 5679
5672 /* ALC268 has no aa-loopback mixer */ 5680 /* ALC268 has no aa-loopback mixer */
5673 5681
5674 /* automatic parse from the BIOS config */ 5682 /* automatic parse from the BIOS config */
5675 err = alc268_parse_auto_config(codec); 5683 err = alc268_parse_auto_config(codec);
5676 if (err < 0) 5684 if (err < 0)
5677 goto error; 5685 goto error;
5678 5686
5679 has_beep = 0; 5687 has_beep = 0;
5680 for (i = 0; i < spec->num_mixers; i++) { 5688 for (i = 0; i < spec->num_mixers; i++) {
5681 if (spec->mixers[i] == alc268_beep_mixer) { 5689 if (spec->mixers[i] == alc268_beep_mixer) {
5682 has_beep = 1; 5690 has_beep = 1;
5683 break; 5691 break;
5684 } 5692 }
5685 } 5693 }
5686 5694
5687 if (has_beep) { 5695 if (has_beep) {
5688 err = snd_hda_attach_beep_device(codec, 0x1); 5696 err = snd_hda_attach_beep_device(codec, 0x1);
5689 if (err < 0) 5697 if (err < 0)
5690 goto error; 5698 goto error;
5691 if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) 5699 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
5692 /* override the amp caps for beep generator */ 5700 /* override the amp caps for beep generator */
5693 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, 5701 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
5694 (0x0c << AC_AMPCAP_OFFSET_SHIFT) | 5702 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
5695 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | 5703 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
5696 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | 5704 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5697 (0 << AC_AMPCAP_MUTE_SHIFT)); 5705 (0 << AC_AMPCAP_MUTE_SHIFT));
5698 } 5706 }
5699 5707
5700 codec->patch_ops = alc_patch_ops; 5708 codec->patch_ops = alc_patch_ops;
5701 spec->shutup = alc_eapd_shutup; 5709 spec->shutup = alc_eapd_shutup;
5702 5710
5703 return 0; 5711 return 0;
5704 5712
5705 error: 5713 error:
5706 alc_free(codec); 5714 alc_free(codec);
5707 return err; 5715 return err;
5708 } 5716 }
5709 5717
5710 /* 5718 /*
5711 * ALC269 5719 * ALC269
5712 */ 5720 */
5713 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = { 5721 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
5714 .substreams = 1, 5722 .substreams = 1,
5715 .channels_min = 2, 5723 .channels_min = 2,
5716 .channels_max = 8, 5724 .channels_max = 8,
5717 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ 5725 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
5718 /* NID is set in alc_build_pcms */ 5726 /* NID is set in alc_build_pcms */
5719 .ops = { 5727 .ops = {
5720 .open = alc_playback_pcm_open, 5728 .open = alc_playback_pcm_open,
5721 .prepare = alc_playback_pcm_prepare, 5729 .prepare = alc_playback_pcm_prepare,
5722 .cleanup = alc_playback_pcm_cleanup 5730 .cleanup = alc_playback_pcm_cleanup
5723 }, 5731 },
5724 }; 5732 };
5725 5733
5726 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = { 5734 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
5727 .substreams = 1, 5735 .substreams = 1,
5728 .channels_min = 2, 5736 .channels_min = 2,
5729 .channels_max = 2, 5737 .channels_max = 2,
5730 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ 5738 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
5731 /* NID is set in alc_build_pcms */ 5739 /* NID is set in alc_build_pcms */
5732 }; 5740 };
5733 5741
5734 /* different alc269-variants */ 5742 /* different alc269-variants */
5735 enum { 5743 enum {
5736 ALC269_TYPE_ALC269VA, 5744 ALC269_TYPE_ALC269VA,
5737 ALC269_TYPE_ALC269VB, 5745 ALC269_TYPE_ALC269VB,
5738 ALC269_TYPE_ALC269VC, 5746 ALC269_TYPE_ALC269VC,
5739 }; 5747 };
5740 5748
5741 /* 5749 /*
5742 * BIOS auto configuration 5750 * BIOS auto configuration
5743 */ 5751 */
5744 static int alc269_parse_auto_config(struct hda_codec *codec) 5752 static int alc269_parse_auto_config(struct hda_codec *codec)
5745 { 5753 {
5746 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 }; 5754 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
5747 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 }; 5755 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
5748 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 }; 5756 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
5749 struct alc_spec *spec = codec->spec; 5757 struct alc_spec *spec = codec->spec;
5750 const hda_nid_t *ssids = spec->codec_variant == ALC269_TYPE_ALC269VA ? 5758 const hda_nid_t *ssids = spec->codec_variant == ALC269_TYPE_ALC269VA ?
5751 alc269va_ssids : alc269_ssids; 5759 alc269va_ssids : alc269_ssids;
5752 5760
5753 return alc_parse_auto_config(codec, alc269_ignore, ssids); 5761 return alc_parse_auto_config(codec, alc269_ignore, ssids);
5754 } 5762 }
5755 5763
5756 static void alc269_toggle_power_output(struct hda_codec *codec, int power_up) 5764 static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
5757 { 5765 {
5758 int val = alc_read_coef_idx(codec, 0x04); 5766 int val = alc_read_coef_idx(codec, 0x04);
5759 if (power_up) 5767 if (power_up)
5760 val |= 1 << 11; 5768 val |= 1 << 11;
5761 else 5769 else
5762 val &= ~(1 << 11); 5770 val &= ~(1 << 11);
5763 alc_write_coef_idx(codec, 0x04, val); 5771 alc_write_coef_idx(codec, 0x04, val);
5764 } 5772 }
5765 5773
5766 static void alc269_shutup(struct hda_codec *codec) 5774 static void alc269_shutup(struct hda_codec *codec)
5767 { 5775 {
5768 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) 5776 if ((alc_get_coef0(codec) & 0x00ff) == 0x017)
5769 alc269_toggle_power_output(codec, 0); 5777 alc269_toggle_power_output(codec, 0);
5770 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { 5778 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
5771 alc269_toggle_power_output(codec, 0); 5779 alc269_toggle_power_output(codec, 0);
5772 msleep(150); 5780 msleep(150);
5773 } 5781 }
5774 } 5782 }
5775 5783
5776 #ifdef CONFIG_PM 5784 #ifdef CONFIG_PM
5777 static int alc269_resume(struct hda_codec *codec) 5785 static int alc269_resume(struct hda_codec *codec)
5778 { 5786 {
5779 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { 5787 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
5780 alc269_toggle_power_output(codec, 0); 5788 alc269_toggle_power_output(codec, 0);
5781 msleep(150); 5789 msleep(150);
5782 } 5790 }
5783 5791
5784 codec->patch_ops.init(codec); 5792 codec->patch_ops.init(codec);
5785 5793
5786 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { 5794 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
5787 alc269_toggle_power_output(codec, 1); 5795 alc269_toggle_power_output(codec, 1);
5788 msleep(200); 5796 msleep(200);
5789 } 5797 }
5790 5798
5791 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) 5799 if ((alc_get_coef0(codec) & 0x00ff) == 0x018)
5792 alc269_toggle_power_output(codec, 1); 5800 alc269_toggle_power_output(codec, 1);
5793 5801
5794 snd_hda_codec_resume_amp(codec); 5802 snd_hda_codec_resume_amp(codec);
5795 snd_hda_codec_resume_cache(codec); 5803 snd_hda_codec_resume_cache(codec);
5796 hda_call_check_power_status(codec, 0x01); 5804 hda_call_check_power_status(codec, 0x01);
5797 return 0; 5805 return 0;
5798 } 5806 }
5799 #endif /* CONFIG_PM */ 5807 #endif /* CONFIG_PM */
5800 5808
5801 static void alc269_fixup_hweq(struct hda_codec *codec, 5809 static void alc269_fixup_hweq(struct hda_codec *codec,
5802 const struct alc_fixup *fix, int action) 5810 const struct alc_fixup *fix, int action)
5803 { 5811 {
5804 int coef; 5812 int coef;
5805 5813
5806 if (action != ALC_FIXUP_ACT_INIT) 5814 if (action != ALC_FIXUP_ACT_INIT)
5807 return; 5815 return;
5808 coef = alc_read_coef_idx(codec, 0x1e); 5816 coef = alc_read_coef_idx(codec, 0x1e);
5809 alc_write_coef_idx(codec, 0x1e, coef | 0x80); 5817 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
5810 } 5818 }
5811 5819
5812 static void alc271_fixup_dmic(struct hda_codec *codec, 5820 static void alc271_fixup_dmic(struct hda_codec *codec,
5813 const struct alc_fixup *fix, int action) 5821 const struct alc_fixup *fix, int action)
5814 { 5822 {
5815 static const struct hda_verb verbs[] = { 5823 static const struct hda_verb verbs[] = {
5816 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, 5824 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
5817 {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, 5825 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
5818 {} 5826 {}
5819 }; 5827 };
5820 unsigned int cfg; 5828 unsigned int cfg;
5821 5829
5822 if (strcmp(codec->chip_name, "ALC271X")) 5830 if (strcmp(codec->chip_name, "ALC271X"))
5823 return; 5831 return;
5824 cfg = snd_hda_codec_get_pincfg(codec, 0x12); 5832 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
5825 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) 5833 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
5826 snd_hda_sequence_write(codec, verbs); 5834 snd_hda_sequence_write(codec, verbs);
5827 } 5835 }
5828 5836
5829 static void alc269_fixup_pcm_44k(struct hda_codec *codec, 5837 static void alc269_fixup_pcm_44k(struct hda_codec *codec,
5830 const struct alc_fixup *fix, int action) 5838 const struct alc_fixup *fix, int action)
5831 { 5839 {
5832 struct alc_spec *spec = codec->spec; 5840 struct alc_spec *spec = codec->spec;
5833 5841
5834 if (action != ALC_FIXUP_ACT_PROBE) 5842 if (action != ALC_FIXUP_ACT_PROBE)
5835 return; 5843 return;
5836 5844
5837 /* Due to a hardware problem on Lenovo Ideadpad, we need to 5845 /* Due to a hardware problem on Lenovo Ideadpad, we need to
5838 * fix the sample rate of analog I/O to 44.1kHz 5846 * fix the sample rate of analog I/O to 44.1kHz
5839 */ 5847 */
5840 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback; 5848 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
5841 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture; 5849 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
5842 } 5850 }
5843 5851
5844 static void alc269_fixup_stereo_dmic(struct hda_codec *codec, 5852 static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
5845 const struct alc_fixup *fix, int action) 5853 const struct alc_fixup *fix, int action)
5846 { 5854 {
5847 int coef; 5855 int coef;
5848 5856
5849 if (action != ALC_FIXUP_ACT_INIT) 5857 if (action != ALC_FIXUP_ACT_INIT)
5850 return; 5858 return;
5851 /* The digital-mic unit sends PDM (differential signal) instead of 5859 /* The digital-mic unit sends PDM (differential signal) instead of
5852 * the standard PCM, thus you can't record a valid mono stream as is. 5860 * the standard PCM, thus you can't record a valid mono stream as is.
5853 * Below is a workaround specific to ALC269 to control the dmic 5861 * Below is a workaround specific to ALC269 to control the dmic
5854 * signal source as mono. 5862 * signal source as mono.
5855 */ 5863 */
5856 coef = alc_read_coef_idx(codec, 0x07); 5864 coef = alc_read_coef_idx(codec, 0x07);
5857 alc_write_coef_idx(codec, 0x07, coef | 0x80); 5865 alc_write_coef_idx(codec, 0x07, coef | 0x80);
5858 } 5866 }
5859 5867
5860 static void alc269_quanta_automute(struct hda_codec *codec) 5868 static void alc269_quanta_automute(struct hda_codec *codec)
5861 { 5869 {
5862 update_outputs(codec); 5870 update_outputs(codec);
5863 5871
5864 snd_hda_codec_write(codec, 0x20, 0, 5872 snd_hda_codec_write(codec, 0x20, 0,
5865 AC_VERB_SET_COEF_INDEX, 0x0c); 5873 AC_VERB_SET_COEF_INDEX, 0x0c);
5866 snd_hda_codec_write(codec, 0x20, 0, 5874 snd_hda_codec_write(codec, 0x20, 0,
5867 AC_VERB_SET_PROC_COEF, 0x680); 5875 AC_VERB_SET_PROC_COEF, 0x680);
5868 5876
5869 snd_hda_codec_write(codec, 0x20, 0, 5877 snd_hda_codec_write(codec, 0x20, 0,
5870 AC_VERB_SET_COEF_INDEX, 0x0c); 5878 AC_VERB_SET_COEF_INDEX, 0x0c);
5871 snd_hda_codec_write(codec, 0x20, 0, 5879 snd_hda_codec_write(codec, 0x20, 0,
5872 AC_VERB_SET_PROC_COEF, 0x480); 5880 AC_VERB_SET_PROC_COEF, 0x480);
5873 } 5881 }
5874 5882
5875 static void alc269_fixup_quanta_mute(struct hda_codec *codec, 5883 static void alc269_fixup_quanta_mute(struct hda_codec *codec,
5876 const struct alc_fixup *fix, int action) 5884 const struct alc_fixup *fix, int action)
5877 { 5885 {
5878 struct alc_spec *spec = codec->spec; 5886 struct alc_spec *spec = codec->spec;
5879 if (action != ALC_FIXUP_ACT_PROBE) 5887 if (action != ALC_FIXUP_ACT_PROBE)
5880 return; 5888 return;
5881 spec->automute_hook = alc269_quanta_automute; 5889 spec->automute_hook = alc269_quanta_automute;
5882 } 5890 }
5883 5891
5884 /* update mute-LED according to the speaker mute state via mic2 VREF pin */ 5892 /* update mute-LED according to the speaker mute state via mic2 VREF pin */
5885 static void alc269_fixup_mic2_mute_hook(void *private_data, int enabled) 5893 static void alc269_fixup_mic2_mute_hook(void *private_data, int enabled)
5886 { 5894 {
5887 struct hda_codec *codec = private_data; 5895 struct hda_codec *codec = private_data;
5888 unsigned int pinval = enabled ? 0x20 : 0x24; 5896 unsigned int pinval = enabled ? 0x20 : 0x24;
5889 snd_hda_codec_update_cache(codec, 0x19, 0, 5897 snd_hda_codec_update_cache(codec, 0x19, 0,
5890 AC_VERB_SET_PIN_WIDGET_CONTROL, 5898 AC_VERB_SET_PIN_WIDGET_CONTROL,
5891 pinval); 5899 pinval);
5892 } 5900 }
5893 5901
5894 static void alc269_fixup_mic2_mute(struct hda_codec *codec, 5902 static void alc269_fixup_mic2_mute(struct hda_codec *codec,
5895 const struct alc_fixup *fix, int action) 5903 const struct alc_fixup *fix, int action)
5896 { 5904 {
5897 struct alc_spec *spec = codec->spec; 5905 struct alc_spec *spec = codec->spec;
5898 switch (action) { 5906 switch (action) {
5899 case ALC_FIXUP_ACT_BUILD: 5907 case ALC_FIXUP_ACT_BUILD:
5900 spec->vmaster_mute.hook = alc269_fixup_mic2_mute_hook; 5908 spec->vmaster_mute.hook = alc269_fixup_mic2_mute_hook;
5901 snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true); 5909 snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true);
5902 /* fallthru */ 5910 /* fallthru */
5903 case ALC_FIXUP_ACT_INIT: 5911 case ALC_FIXUP_ACT_INIT:
5904 snd_hda_sync_vmaster_hook(&spec->vmaster_mute); 5912 snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
5905 break; 5913 break;
5906 } 5914 }
5907 } 5915 }
5908 5916
5909 enum { 5917 enum {
5910 ALC269_FIXUP_SONY_VAIO, 5918 ALC269_FIXUP_SONY_VAIO,
5911 ALC275_FIXUP_SONY_VAIO_GPIO2, 5919 ALC275_FIXUP_SONY_VAIO_GPIO2,
5912 ALC269_FIXUP_DELL_M101Z, 5920 ALC269_FIXUP_DELL_M101Z,
5913 ALC269_FIXUP_SKU_IGNORE, 5921 ALC269_FIXUP_SKU_IGNORE,
5914 ALC269_FIXUP_ASUS_G73JW, 5922 ALC269_FIXUP_ASUS_G73JW,
5915 ALC269_FIXUP_LENOVO_EAPD, 5923 ALC269_FIXUP_LENOVO_EAPD,
5916 ALC275_FIXUP_SONY_HWEQ, 5924 ALC275_FIXUP_SONY_HWEQ,
5917 ALC271_FIXUP_DMIC, 5925 ALC271_FIXUP_DMIC,
5918 ALC269_FIXUP_PCM_44K, 5926 ALC269_FIXUP_PCM_44K,
5919 ALC269_FIXUP_STEREO_DMIC, 5927 ALC269_FIXUP_STEREO_DMIC,
5920 ALC269_FIXUP_QUANTA_MUTE, 5928 ALC269_FIXUP_QUANTA_MUTE,
5921 ALC269_FIXUP_LIFEBOOK, 5929 ALC269_FIXUP_LIFEBOOK,
5922 ALC269_FIXUP_AMIC, 5930 ALC269_FIXUP_AMIC,
5923 ALC269_FIXUP_DMIC, 5931 ALC269_FIXUP_DMIC,
5924 ALC269VB_FIXUP_AMIC, 5932 ALC269VB_FIXUP_AMIC,
5925 ALC269VB_FIXUP_DMIC, 5933 ALC269VB_FIXUP_DMIC,
5926 ALC269_FIXUP_MIC2_MUTE_LED, 5934 ALC269_FIXUP_MIC2_MUTE_LED,
5927 }; 5935 };
5928 5936
5929 static const struct alc_fixup alc269_fixups[] = { 5937 static const struct alc_fixup alc269_fixups[] = {
5930 [ALC269_FIXUP_SONY_VAIO] = { 5938 [ALC269_FIXUP_SONY_VAIO] = {
5931 .type = ALC_FIXUP_VERBS, 5939 .type = ALC_FIXUP_VERBS,
5932 .v.verbs = (const struct hda_verb[]) { 5940 .v.verbs = (const struct hda_verb[]) {
5933 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, 5941 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
5934 {} 5942 {}
5935 } 5943 }
5936 }, 5944 },
5937 [ALC275_FIXUP_SONY_VAIO_GPIO2] = { 5945 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
5938 .type = ALC_FIXUP_VERBS, 5946 .type = ALC_FIXUP_VERBS,
5939 .v.verbs = (const struct hda_verb[]) { 5947 .v.verbs = (const struct hda_verb[]) {
5940 {0x01, AC_VERB_SET_GPIO_MASK, 0x04}, 5948 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
5941 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04}, 5949 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
5942 {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, 5950 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5943 { } 5951 { }
5944 }, 5952 },
5945 .chained = true, 5953 .chained = true,
5946 .chain_id = ALC269_FIXUP_SONY_VAIO 5954 .chain_id = ALC269_FIXUP_SONY_VAIO
5947 }, 5955 },
5948 [ALC269_FIXUP_DELL_M101Z] = { 5956 [ALC269_FIXUP_DELL_M101Z] = {
5949 .type = ALC_FIXUP_VERBS, 5957 .type = ALC_FIXUP_VERBS,
5950 .v.verbs = (const struct hda_verb[]) { 5958 .v.verbs = (const struct hda_verb[]) {
5951 /* Enables internal speaker */ 5959 /* Enables internal speaker */
5952 {0x20, AC_VERB_SET_COEF_INDEX, 13}, 5960 {0x20, AC_VERB_SET_COEF_INDEX, 13},
5953 {0x20, AC_VERB_SET_PROC_COEF, 0x4040}, 5961 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
5954 {} 5962 {}
5955 } 5963 }
5956 }, 5964 },
5957 [ALC269_FIXUP_SKU_IGNORE] = { 5965 [ALC269_FIXUP_SKU_IGNORE] = {
5958 .type = ALC_FIXUP_SKU, 5966 .type = ALC_FIXUP_SKU,
5959 .v.sku = ALC_FIXUP_SKU_IGNORE, 5967 .v.sku = ALC_FIXUP_SKU_IGNORE,
5960 }, 5968 },
5961 [ALC269_FIXUP_ASUS_G73JW] = { 5969 [ALC269_FIXUP_ASUS_G73JW] = {
5962 .type = ALC_FIXUP_PINS, 5970 .type = ALC_FIXUP_PINS,
5963 .v.pins = (const struct alc_pincfg[]) { 5971 .v.pins = (const struct alc_pincfg[]) {
5964 { 0x17, 0x99130111 }, /* subwoofer */ 5972 { 0x17, 0x99130111 }, /* subwoofer */
5965 { } 5973 { }
5966 } 5974 }
5967 }, 5975 },
5968 [ALC269_FIXUP_LENOVO_EAPD] = { 5976 [ALC269_FIXUP_LENOVO_EAPD] = {
5969 .type = ALC_FIXUP_VERBS, 5977 .type = ALC_FIXUP_VERBS,
5970 .v.verbs = (const struct hda_verb[]) { 5978 .v.verbs = (const struct hda_verb[]) {
5971 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, 5979 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
5972 {} 5980 {}
5973 } 5981 }
5974 }, 5982 },
5975 [ALC275_FIXUP_SONY_HWEQ] = { 5983 [ALC275_FIXUP_SONY_HWEQ] = {
5976 .type = ALC_FIXUP_FUNC, 5984 .type = ALC_FIXUP_FUNC,
5977 .v.func = alc269_fixup_hweq, 5985 .v.func = alc269_fixup_hweq,
5978 .chained = true, 5986 .chained = true,
5979 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2 5987 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
5980 }, 5988 },
5981 [ALC271_FIXUP_DMIC] = { 5989 [ALC271_FIXUP_DMIC] = {
5982 .type = ALC_FIXUP_FUNC, 5990 .type = ALC_FIXUP_FUNC,
5983 .v.func = alc271_fixup_dmic, 5991 .v.func = alc271_fixup_dmic,
5984 }, 5992 },
5985 [ALC269_FIXUP_PCM_44K] = { 5993 [ALC269_FIXUP_PCM_44K] = {
5986 .type = ALC_FIXUP_FUNC, 5994 .type = ALC_FIXUP_FUNC,
5987 .v.func = alc269_fixup_pcm_44k, 5995 .v.func = alc269_fixup_pcm_44k,
5988 }, 5996 },
5989 [ALC269_FIXUP_STEREO_DMIC] = { 5997 [ALC269_FIXUP_STEREO_DMIC] = {
5990 .type = ALC_FIXUP_FUNC, 5998 .type = ALC_FIXUP_FUNC,
5991 .v.func = alc269_fixup_stereo_dmic, 5999 .v.func = alc269_fixup_stereo_dmic,
5992 }, 6000 },
5993 [ALC269_FIXUP_QUANTA_MUTE] = { 6001 [ALC269_FIXUP_QUANTA_MUTE] = {
5994 .type = ALC_FIXUP_FUNC, 6002 .type = ALC_FIXUP_FUNC,
5995 .v.func = alc269_fixup_quanta_mute, 6003 .v.func = alc269_fixup_quanta_mute,
5996 }, 6004 },
5997 [ALC269_FIXUP_LIFEBOOK] = { 6005 [ALC269_FIXUP_LIFEBOOK] = {
5998 .type = ALC_FIXUP_PINS, 6006 .type = ALC_FIXUP_PINS,
5999 .v.pins = (const struct alc_pincfg[]) { 6007 .v.pins = (const struct alc_pincfg[]) {
6000 { 0x1a, 0x2101103f }, /* dock line-out */ 6008 { 0x1a, 0x2101103f }, /* dock line-out */
6001 { 0x1b, 0x23a11040 }, /* dock mic-in */ 6009 { 0x1b, 0x23a11040 }, /* dock mic-in */
6002 { } 6010 { }
6003 }, 6011 },
6004 .chained = true, 6012 .chained = true,
6005 .chain_id = ALC269_FIXUP_QUANTA_MUTE 6013 .chain_id = ALC269_FIXUP_QUANTA_MUTE
6006 }, 6014 },
6007 [ALC269_FIXUP_AMIC] = { 6015 [ALC269_FIXUP_AMIC] = {
6008 .type = ALC_FIXUP_PINS, 6016 .type = ALC_FIXUP_PINS,
6009 .v.pins = (const struct alc_pincfg[]) { 6017 .v.pins = (const struct alc_pincfg[]) {
6010 { 0x14, 0x99130110 }, /* speaker */ 6018 { 0x14, 0x99130110 }, /* speaker */
6011 { 0x15, 0x0121401f }, /* HP out */ 6019 { 0x15, 0x0121401f }, /* HP out */
6012 { 0x18, 0x01a19c20 }, /* mic */ 6020 { 0x18, 0x01a19c20 }, /* mic */
6013 { 0x19, 0x99a3092f }, /* int-mic */ 6021 { 0x19, 0x99a3092f }, /* int-mic */
6014 { } 6022 { }
6015 }, 6023 },
6016 }, 6024 },
6017 [ALC269_FIXUP_DMIC] = { 6025 [ALC269_FIXUP_DMIC] = {
6018 .type = ALC_FIXUP_PINS, 6026 .type = ALC_FIXUP_PINS,
6019 .v.pins = (const struct alc_pincfg[]) { 6027 .v.pins = (const struct alc_pincfg[]) {
6020 { 0x12, 0x99a3092f }, /* int-mic */ 6028 { 0x12, 0x99a3092f }, /* int-mic */
6021 { 0x14, 0x99130110 }, /* speaker */ 6029 { 0x14, 0x99130110 }, /* speaker */
6022 { 0x15, 0x0121401f }, /* HP out */ 6030 { 0x15, 0x0121401f }, /* HP out */
6023 { 0x18, 0x01a19c20 }, /* mic */ 6031 { 0x18, 0x01a19c20 }, /* mic */
6024 { } 6032 { }
6025 }, 6033 },
6026 }, 6034 },
6027 [ALC269VB_FIXUP_AMIC] = { 6035 [ALC269VB_FIXUP_AMIC] = {
6028 .type = ALC_FIXUP_PINS, 6036 .type = ALC_FIXUP_PINS,
6029 .v.pins = (const struct alc_pincfg[]) { 6037 .v.pins = (const struct alc_pincfg[]) {
6030 { 0x14, 0x99130110 }, /* speaker */ 6038 { 0x14, 0x99130110 }, /* speaker */
6031 { 0x18, 0x01a19c20 }, /* mic */ 6039 { 0x18, 0x01a19c20 }, /* mic */
6032 { 0x19, 0x99a3092f }, /* int-mic */ 6040 { 0x19, 0x99a3092f }, /* int-mic */
6033 { 0x21, 0x0121401f }, /* HP out */ 6041 { 0x21, 0x0121401f }, /* HP out */
6034 { } 6042 { }
6035 }, 6043 },
6036 }, 6044 },
6037 [ALC269VB_FIXUP_DMIC] = { 6045 [ALC269VB_FIXUP_DMIC] = {
6038 .type = ALC_FIXUP_PINS, 6046 .type = ALC_FIXUP_PINS,
6039 .v.pins = (const struct alc_pincfg[]) { 6047 .v.pins = (const struct alc_pincfg[]) {
6040 { 0x12, 0x99a3092f }, /* int-mic */ 6048 { 0x12, 0x99a3092f }, /* int-mic */
6041 { 0x14, 0x99130110 }, /* speaker */ 6049 { 0x14, 0x99130110 }, /* speaker */
6042 { 0x18, 0x01a19c20 }, /* mic */ 6050 { 0x18, 0x01a19c20 }, /* mic */
6043 { 0x21, 0x0121401f }, /* HP out */ 6051 { 0x21, 0x0121401f }, /* HP out */
6044 { } 6052 { }
6045 }, 6053 },
6046 }, 6054 },
6047 [ALC269_FIXUP_MIC2_MUTE_LED] = { 6055 [ALC269_FIXUP_MIC2_MUTE_LED] = {
6048 .type = ALC_FIXUP_FUNC, 6056 .type = ALC_FIXUP_FUNC,
6049 .v.func = alc269_fixup_mic2_mute, 6057 .v.func = alc269_fixup_mic2_mute,
6050 }, 6058 },
6051 }; 6059 };
6052 6060
6053 static const struct snd_pci_quirk alc269_fixup_tbl[] = { 6061 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
6054 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED), 6062 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED),
6055 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), 6063 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
6056 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), 6064 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
6057 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), 6065 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
6058 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), 6066 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
6059 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), 6067 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
6060 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), 6068 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
6061 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), 6069 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
6062 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), 6070 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
6063 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), 6071 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
6064 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), 6072 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
6065 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), 6073 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
6066 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), 6074 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
6067 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), 6075 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
6068 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), 6076 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
6069 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), 6077 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
6070 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), 6078 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
6071 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE), 6079 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
6072 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), 6080 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
6073 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE), 6081 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE),
6074 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K), 6082 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K),
6075 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), 6083 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
6076 6084
6077 #if 0 6085 #if 0
6078 /* Below is a quirk table taken from the old code. 6086 /* Below is a quirk table taken from the old code.
6079 * Basically the device should work as is without the fixup table. 6087 * Basically the device should work as is without the fixup table.
6080 * If BIOS doesn't give a proper info, enable the corresponding 6088 * If BIOS doesn't give a proper info, enable the corresponding
6081 * fixup entry. 6089 * fixup entry.
6082 */ 6090 */
6083 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", 6091 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
6084 ALC269_FIXUP_AMIC), 6092 ALC269_FIXUP_AMIC),
6085 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), 6093 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
6086 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC), 6094 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
6087 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC), 6095 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
6088 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC), 6096 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
6089 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC), 6097 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
6090 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC), 6098 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
6091 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC), 6099 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
6092 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC), 6100 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
6093 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC), 6101 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
6094 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC), 6102 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
6095 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC), 6103 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
6096 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC), 6104 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
6097 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC), 6105 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
6098 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC), 6106 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
6099 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC), 6107 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
6100 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC), 6108 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
6101 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC), 6109 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
6102 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC), 6110 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
6103 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC), 6111 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
6104 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC), 6112 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
6105 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC), 6113 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
6106 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC), 6114 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
6107 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC), 6115 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
6108 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC), 6116 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
6109 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC), 6117 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
6110 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC), 6118 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
6111 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC), 6119 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
6112 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC), 6120 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
6113 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC), 6121 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
6114 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC), 6122 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
6115 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC), 6123 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
6116 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC), 6124 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
6117 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC), 6125 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
6118 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC), 6126 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
6119 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC), 6127 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
6120 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC), 6128 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
6121 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC), 6129 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
6122 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC), 6130 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
6123 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC), 6131 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
6124 #endif 6132 #endif
6125 {} 6133 {}
6126 }; 6134 };
6127 6135
6128 static const struct alc_model_fixup alc269_fixup_models[] = { 6136 static const struct alc_model_fixup alc269_fixup_models[] = {
6129 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"}, 6137 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
6130 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"}, 6138 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
6131 {} 6139 {}
6132 }; 6140 };
6133 6141
6134 6142
6135 static void alc269_fill_coef(struct hda_codec *codec) 6143 static void alc269_fill_coef(struct hda_codec *codec)
6136 { 6144 {
6137 struct alc_spec *spec = codec->spec; 6145 struct alc_spec *spec = codec->spec;
6138 int val; 6146 int val;
6139 6147
6140 if (spec->codec_variant != ALC269_TYPE_ALC269VB) 6148 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
6141 return; 6149 return;
6142 6150
6143 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) { 6151 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
6144 alc_write_coef_idx(codec, 0xf, 0x960b); 6152 alc_write_coef_idx(codec, 0xf, 0x960b);
6145 alc_write_coef_idx(codec, 0xe, 0x8817); 6153 alc_write_coef_idx(codec, 0xe, 0x8817);
6146 } 6154 }
6147 6155
6148 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) { 6156 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
6149 alc_write_coef_idx(codec, 0xf, 0x960b); 6157 alc_write_coef_idx(codec, 0xf, 0x960b);
6150 alc_write_coef_idx(codec, 0xe, 0x8814); 6158 alc_write_coef_idx(codec, 0xe, 0x8814);
6151 } 6159 }
6152 6160
6153 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { 6161 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
6154 val = alc_read_coef_idx(codec, 0x04); 6162 val = alc_read_coef_idx(codec, 0x04);
6155 /* Power up output pin */ 6163 /* Power up output pin */
6156 alc_write_coef_idx(codec, 0x04, val | (1<<11)); 6164 alc_write_coef_idx(codec, 0x04, val | (1<<11));
6157 } 6165 }
6158 6166
6159 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { 6167 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
6160 val = alc_read_coef_idx(codec, 0xd); 6168 val = alc_read_coef_idx(codec, 0xd);
6161 if ((val & 0x0c00) >> 10 != 0x1) { 6169 if ((val & 0x0c00) >> 10 != 0x1) {
6162 /* Capless ramp up clock control */ 6170 /* Capless ramp up clock control */
6163 alc_write_coef_idx(codec, 0xd, val | (1<<10)); 6171 alc_write_coef_idx(codec, 0xd, val | (1<<10));
6164 } 6172 }
6165 val = alc_read_coef_idx(codec, 0x17); 6173 val = alc_read_coef_idx(codec, 0x17);
6166 if ((val & 0x01c0) >> 6 != 0x4) { 6174 if ((val & 0x01c0) >> 6 != 0x4) {
6167 /* Class D power on reset */ 6175 /* Class D power on reset */
6168 alc_write_coef_idx(codec, 0x17, val | (1<<7)); 6176 alc_write_coef_idx(codec, 0x17, val | (1<<7));
6169 } 6177 }
6170 } 6178 }
6171 6179
6172 val = alc_read_coef_idx(codec, 0xd); /* Class D */ 6180 val = alc_read_coef_idx(codec, 0xd); /* Class D */
6173 alc_write_coef_idx(codec, 0xd, val | (1<<14)); 6181 alc_write_coef_idx(codec, 0xd, val | (1<<14));
6174 6182
6175 val = alc_read_coef_idx(codec, 0x4); /* HP */ 6183 val = alc_read_coef_idx(codec, 0x4); /* HP */
6176 alc_write_coef_idx(codec, 0x4, val | (1<<11)); 6184 alc_write_coef_idx(codec, 0x4, val | (1<<11));
6177 } 6185 }
6178 6186
6179 /* 6187 /*
6180 */ 6188 */
6181 static int patch_alc269(struct hda_codec *codec) 6189 static int patch_alc269(struct hda_codec *codec)
6182 { 6190 {
6183 struct alc_spec *spec; 6191 struct alc_spec *spec;
6184 int err = 0; 6192 int err = 0;
6185 6193
6186 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 6194 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6187 if (spec == NULL) 6195 if (spec == NULL)
6188 return -ENOMEM; 6196 return -ENOMEM;
6189 6197
6190 codec->spec = spec; 6198 codec->spec = spec;
6191 6199
6192 spec->mixer_nid = 0x0b; 6200 spec->mixer_nid = 0x0b;
6193 6201
6194 alc_auto_parse_customize_define(codec); 6202 alc_auto_parse_customize_define(codec);
6195 6203
6196 err = alc_codec_rename_from_preset(codec); 6204 err = alc_codec_rename_from_preset(codec);
6197 if (err < 0) 6205 if (err < 0)
6198 goto error; 6206 goto error;
6199 6207
6200 if (codec->vendor_id == 0x10ec0269) { 6208 if (codec->vendor_id == 0x10ec0269) {
6201 spec->codec_variant = ALC269_TYPE_ALC269VA; 6209 spec->codec_variant = ALC269_TYPE_ALC269VA;
6202 switch (alc_get_coef0(codec) & 0x00f0) { 6210 switch (alc_get_coef0(codec) & 0x00f0) {
6203 case 0x0010: 6211 case 0x0010:
6204 if (codec->bus->pci->subsystem_vendor == 0x1025 && 6212 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
6205 spec->cdefine.platform_type == 1) 6213 spec->cdefine.platform_type == 1)
6206 err = alc_codec_rename(codec, "ALC271X"); 6214 err = alc_codec_rename(codec, "ALC271X");
6207 spec->codec_variant = ALC269_TYPE_ALC269VB; 6215 spec->codec_variant = ALC269_TYPE_ALC269VB;
6208 break; 6216 break;
6209 case 0x0020: 6217 case 0x0020:
6210 if (codec->bus->pci->subsystem_vendor == 0x17aa && 6218 if (codec->bus->pci->subsystem_vendor == 0x17aa &&
6211 codec->bus->pci->subsystem_device == 0x21f3) 6219 codec->bus->pci->subsystem_device == 0x21f3)
6212 err = alc_codec_rename(codec, "ALC3202"); 6220 err = alc_codec_rename(codec, "ALC3202");
6213 spec->codec_variant = ALC269_TYPE_ALC269VC; 6221 spec->codec_variant = ALC269_TYPE_ALC269VC;
6214 break; 6222 break;
6215 default: 6223 default:
6216 alc_fix_pll_init(codec, 0x20, 0x04, 15); 6224 alc_fix_pll_init(codec, 0x20, 0x04, 15);
6217 } 6225 }
6218 if (err < 0) 6226 if (err < 0)
6219 goto error; 6227 goto error;
6220 spec->init_hook = alc269_fill_coef; 6228 spec->init_hook = alc269_fill_coef;
6221 alc269_fill_coef(codec); 6229 alc269_fill_coef(codec);
6222 } 6230 }
6223 6231
6224 alc_pick_fixup(codec, alc269_fixup_models, 6232 alc_pick_fixup(codec, alc269_fixup_models,
6225 alc269_fixup_tbl, alc269_fixups); 6233 alc269_fixup_tbl, alc269_fixups);
6226 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); 6234 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
6227 6235
6228 /* automatic parse from the BIOS config */ 6236 /* automatic parse from the BIOS config */
6229 err = alc269_parse_auto_config(codec); 6237 err = alc269_parse_auto_config(codec);
6230 if (err < 0) 6238 if (err < 0)
6231 goto error; 6239 goto error;
6232 6240
6233 if (!spec->no_analog && has_cdefine_beep(codec)) { 6241 if (!spec->no_analog && has_cdefine_beep(codec)) {
6234 err = snd_hda_attach_beep_device(codec, 0x1); 6242 err = snd_hda_attach_beep_device(codec, 0x1);
6235 if (err < 0) 6243 if (err < 0)
6236 goto error; 6244 goto error;
6237 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); 6245 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
6238 } 6246 }
6239 6247
6240 codec->patch_ops = alc_patch_ops; 6248 codec->patch_ops = alc_patch_ops;
6241 #ifdef CONFIG_PM 6249 #ifdef CONFIG_PM
6242 codec->patch_ops.resume = alc269_resume; 6250 codec->patch_ops.resume = alc269_resume;
6243 #endif 6251 #endif
6244 spec->shutup = alc269_shutup; 6252 spec->shutup = alc269_shutup;
6245 6253
6246 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 6254 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
6247 6255
6248 return 0; 6256 return 0;
6249 6257
6250 error: 6258 error:
6251 alc_free(codec); 6259 alc_free(codec);
6252 return err; 6260 return err;
6253 } 6261 }
6254 6262
6255 /* 6263 /*
6256 * ALC861 6264 * ALC861
6257 */ 6265 */
6258 6266
6259 static int alc861_parse_auto_config(struct hda_codec *codec) 6267 static int alc861_parse_auto_config(struct hda_codec *codec)
6260 { 6268 {
6261 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 }; 6269 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
6262 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 }; 6270 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
6263 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids); 6271 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
6264 } 6272 }
6265 6273
6266 /* Pin config fixes */ 6274 /* Pin config fixes */
6267 enum { 6275 enum {
6268 ALC861_FIXUP_FSC_AMILO_PI1505, 6276 ALC861_FIXUP_FSC_AMILO_PI1505,
6269 ALC861_FIXUP_AMP_VREF_0F, 6277 ALC861_FIXUP_AMP_VREF_0F,
6270 ALC861_FIXUP_NO_JACK_DETECT, 6278 ALC861_FIXUP_NO_JACK_DETECT,
6271 ALC861_FIXUP_ASUS_A6RP, 6279 ALC861_FIXUP_ASUS_A6RP,
6272 }; 6280 };
6273 6281
6274 /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */ 6282 /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
6275 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec, 6283 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
6276 const struct alc_fixup *fix, int action) 6284 const struct alc_fixup *fix, int action)
6277 { 6285 {
6278 struct alc_spec *spec = codec->spec; 6286 struct alc_spec *spec = codec->spec;
6279 unsigned int val; 6287 unsigned int val;
6280 6288
6281 if (action != ALC_FIXUP_ACT_INIT) 6289 if (action != ALC_FIXUP_ACT_INIT)
6282 return; 6290 return;
6283 val = snd_hda_codec_read(codec, 0x0f, 0, 6291 val = snd_hda_codec_read(codec, 0x0f, 0,
6284 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 6292 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
6285 if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) 6293 if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
6286 val |= AC_PINCTL_IN_EN; 6294 val |= AC_PINCTL_IN_EN;
6287 val |= AC_PINCTL_VREF_50; 6295 val |= AC_PINCTL_VREF_50;
6288 snd_hda_codec_write(codec, 0x0f, 0, 6296 snd_hda_codec_write(codec, 0x0f, 0,
6289 AC_VERB_SET_PIN_WIDGET_CONTROL, val); 6297 AC_VERB_SET_PIN_WIDGET_CONTROL, val);
6290 spec->keep_vref_in_automute = 1; 6298 spec->keep_vref_in_automute = 1;
6291 } 6299 }
6292 6300
6293 /* suppress the jack-detection */ 6301 /* suppress the jack-detection */
6294 static void alc_fixup_no_jack_detect(struct hda_codec *codec, 6302 static void alc_fixup_no_jack_detect(struct hda_codec *codec,
6295 const struct alc_fixup *fix, int action) 6303 const struct alc_fixup *fix, int action)
6296 { 6304 {
6297 if (action == ALC_FIXUP_ACT_PRE_PROBE) 6305 if (action == ALC_FIXUP_ACT_PRE_PROBE)
6298 codec->no_jack_detect = 1; 6306 codec->no_jack_detect = 1;
6299 } 6307 }
6300 6308
6301 static const struct alc_fixup alc861_fixups[] = { 6309 static const struct alc_fixup alc861_fixups[] = {
6302 [ALC861_FIXUP_FSC_AMILO_PI1505] = { 6310 [ALC861_FIXUP_FSC_AMILO_PI1505] = {
6303 .type = ALC_FIXUP_PINS, 6311 .type = ALC_FIXUP_PINS,
6304 .v.pins = (const struct alc_pincfg[]) { 6312 .v.pins = (const struct alc_pincfg[]) {
6305 { 0x0b, 0x0221101f }, /* HP */ 6313 { 0x0b, 0x0221101f }, /* HP */
6306 { 0x0f, 0x90170310 }, /* speaker */ 6314 { 0x0f, 0x90170310 }, /* speaker */
6307 { } 6315 { }
6308 } 6316 }
6309 }, 6317 },
6310 [ALC861_FIXUP_AMP_VREF_0F] = { 6318 [ALC861_FIXUP_AMP_VREF_0F] = {
6311 .type = ALC_FIXUP_FUNC, 6319 .type = ALC_FIXUP_FUNC,
6312 .v.func = alc861_fixup_asus_amp_vref_0f, 6320 .v.func = alc861_fixup_asus_amp_vref_0f,
6313 }, 6321 },
6314 [ALC861_FIXUP_NO_JACK_DETECT] = { 6322 [ALC861_FIXUP_NO_JACK_DETECT] = {
6315 .type = ALC_FIXUP_FUNC, 6323 .type = ALC_FIXUP_FUNC,
6316 .v.func = alc_fixup_no_jack_detect, 6324 .v.func = alc_fixup_no_jack_detect,
6317 }, 6325 },
6318 [ALC861_FIXUP_ASUS_A6RP] = { 6326 [ALC861_FIXUP_ASUS_A6RP] = {
6319 .type = ALC_FIXUP_FUNC, 6327 .type = ALC_FIXUP_FUNC,
6320 .v.func = alc861_fixup_asus_amp_vref_0f, 6328 .v.func = alc861_fixup_asus_amp_vref_0f,
6321 .chained = true, 6329 .chained = true,
6322 .chain_id = ALC861_FIXUP_NO_JACK_DETECT, 6330 .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
6323 } 6331 }
6324 }; 6332 };
6325 6333
6326 static const struct snd_pci_quirk alc861_fixup_tbl[] = { 6334 static const struct snd_pci_quirk alc861_fixup_tbl[] = {
6327 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP), 6335 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
6328 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F), 6336 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
6329 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT), 6337 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
6330 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F), 6338 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F),
6331 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F), 6339 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F),
6332 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505), 6340 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
6333 {} 6341 {}
6334 }; 6342 };
6335 6343
6336 /* 6344 /*
6337 */ 6345 */
6338 static int patch_alc861(struct hda_codec *codec) 6346 static int patch_alc861(struct hda_codec *codec)
6339 { 6347 {
6340 struct alc_spec *spec; 6348 struct alc_spec *spec;
6341 int err; 6349 int err;
6342 6350
6343 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 6351 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6344 if (spec == NULL) 6352 if (spec == NULL)
6345 return -ENOMEM; 6353 return -ENOMEM;
6346 6354
6347 codec->spec = spec; 6355 codec->spec = spec;
6348 6356
6349 spec->mixer_nid = 0x15; 6357 spec->mixer_nid = 0x15;
6350 6358
6351 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); 6359 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
6352 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); 6360 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
6353 6361
6354 /* automatic parse from the BIOS config */ 6362 /* automatic parse from the BIOS config */
6355 err = alc861_parse_auto_config(codec); 6363 err = alc861_parse_auto_config(codec);
6356 if (err < 0) 6364 if (err < 0)
6357 goto error; 6365 goto error;
6358 6366
6359 if (!spec->no_analog) { 6367 if (!spec->no_analog) {
6360 err = snd_hda_attach_beep_device(codec, 0x23); 6368 err = snd_hda_attach_beep_device(codec, 0x23);
6361 if (err < 0) 6369 if (err < 0)
6362 goto error; 6370 goto error;
6363 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); 6371 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
6364 } 6372 }
6365 6373
6366 codec->patch_ops = alc_patch_ops; 6374 codec->patch_ops = alc_patch_ops;
6367 #ifdef CONFIG_SND_HDA_POWER_SAVE 6375 #ifdef CONFIG_SND_HDA_POWER_SAVE
6368 spec->power_hook = alc_power_eapd; 6376 spec->power_hook = alc_power_eapd;
6369 #endif 6377 #endif
6370 6378
6371 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 6379 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
6372 6380
6373 return 0; 6381 return 0;
6374 6382
6375 error: 6383 error:
6376 alc_free(codec); 6384 alc_free(codec);
6377 return err; 6385 return err;
6378 } 6386 }
6379 6387
6380 /* 6388 /*
6381 * ALC861-VD support 6389 * ALC861-VD support
6382 * 6390 *
6383 * Based on ALC882 6391 * Based on ALC882
6384 * 6392 *
6385 * In addition, an independent DAC 6393 * In addition, an independent DAC
6386 */ 6394 */
6387 static int alc861vd_parse_auto_config(struct hda_codec *codec) 6395 static int alc861vd_parse_auto_config(struct hda_codec *codec)
6388 { 6396 {
6389 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; 6397 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
6390 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 }; 6398 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
6391 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids); 6399 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
6392 } 6400 }
6393 6401
6394 enum { 6402 enum {
6395 ALC660VD_FIX_ASUS_GPIO1, 6403 ALC660VD_FIX_ASUS_GPIO1,
6396 ALC861VD_FIX_DALLAS, 6404 ALC861VD_FIX_DALLAS,
6397 }; 6405 };
6398 6406
6399 /* exclude VREF80 */ 6407 /* exclude VREF80 */
6400 static void alc861vd_fixup_dallas(struct hda_codec *codec, 6408 static void alc861vd_fixup_dallas(struct hda_codec *codec,
6401 const struct alc_fixup *fix, int action) 6409 const struct alc_fixup *fix, int action)
6402 { 6410 {
6403 if (action == ALC_FIXUP_ACT_PRE_PROBE) { 6411 if (action == ALC_FIXUP_ACT_PRE_PROBE) {
6404 snd_hda_override_pin_caps(codec, 0x18, 0x00001714); 6412 snd_hda_override_pin_caps(codec, 0x18, 0x00001714);
6405 snd_hda_override_pin_caps(codec, 0x19, 0x0000171c); 6413 snd_hda_override_pin_caps(codec, 0x19, 0x0000171c);
6406 } 6414 }
6407 } 6415 }
6408 6416
6409 static const struct alc_fixup alc861vd_fixups[] = { 6417 static const struct alc_fixup alc861vd_fixups[] = {
6410 [ALC660VD_FIX_ASUS_GPIO1] = { 6418 [ALC660VD_FIX_ASUS_GPIO1] = {
6411 .type = ALC_FIXUP_VERBS, 6419 .type = ALC_FIXUP_VERBS,
6412 .v.verbs = (const struct hda_verb[]) { 6420 .v.verbs = (const struct hda_verb[]) {
6413 /* reset GPIO1 */ 6421 /* reset GPIO1 */
6414 {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 6422 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6415 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, 6423 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6416 {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, 6424 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6417 { } 6425 { }
6418 } 6426 }
6419 }, 6427 },
6420 [ALC861VD_FIX_DALLAS] = { 6428 [ALC861VD_FIX_DALLAS] = {
6421 .type = ALC_FIXUP_FUNC, 6429 .type = ALC_FIXUP_FUNC,
6422 .v.func = alc861vd_fixup_dallas, 6430 .v.func = alc861vd_fixup_dallas,
6423 }, 6431 },
6424 }; 6432 };
6425 6433
6426 static const struct snd_pci_quirk alc861vd_fixup_tbl[] = { 6434 static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
6427 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS), 6435 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
6428 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1), 6436 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
6429 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS), 6437 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
6430 {} 6438 {}
6431 }; 6439 };
6432 6440
6433 static const struct hda_verb alc660vd_eapd_verbs[] = { 6441 static const struct hda_verb alc660vd_eapd_verbs[] = {
6434 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, 6442 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
6435 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, 6443 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
6436 { } 6444 { }
6437 }; 6445 };
6438 6446
6439 /* 6447 /*
6440 */ 6448 */
6441 static int patch_alc861vd(struct hda_codec *codec) 6449 static int patch_alc861vd(struct hda_codec *codec)
6442 { 6450 {
6443 struct alc_spec *spec; 6451 struct alc_spec *spec;
6444 int err; 6452 int err;
6445 6453
6446 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 6454 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6447 if (spec == NULL) 6455 if (spec == NULL)
6448 return -ENOMEM; 6456 return -ENOMEM;
6449 6457
6450 codec->spec = spec; 6458 codec->spec = spec;
6451 6459
6452 spec->mixer_nid = 0x0b; 6460 spec->mixer_nid = 0x0b;
6453 6461
6454 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); 6462 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
6455 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); 6463 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
6456 6464
6457 /* automatic parse from the BIOS config */ 6465 /* automatic parse from the BIOS config */
6458 err = alc861vd_parse_auto_config(codec); 6466 err = alc861vd_parse_auto_config(codec);
6459 if (err < 0) 6467 if (err < 0)
6460 goto error; 6468 goto error;
6461 6469
6462 if (codec->vendor_id == 0x10ec0660) { 6470 if (codec->vendor_id == 0x10ec0660) {
6463 /* always turn on EAPD */ 6471 /* always turn on EAPD */
6464 add_verb(spec, alc660vd_eapd_verbs); 6472 add_verb(spec, alc660vd_eapd_verbs);
6465 } 6473 }
6466 6474
6467 if (!spec->no_analog) { 6475 if (!spec->no_analog) {
6468 err = snd_hda_attach_beep_device(codec, 0x23); 6476 err = snd_hda_attach_beep_device(codec, 0x23);
6469 if (err < 0) 6477 if (err < 0)
6470 goto error; 6478 goto error;
6471 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 6479 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
6472 } 6480 }
6473 6481
6474 codec->patch_ops = alc_patch_ops; 6482 codec->patch_ops = alc_patch_ops;
6475 6483
6476 spec->shutup = alc_eapd_shutup; 6484 spec->shutup = alc_eapd_shutup;
6477 6485
6478 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 6486 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
6479 6487
6480 return 0; 6488 return 0;
6481 6489
6482 error: 6490 error:
6483 alc_free(codec); 6491 alc_free(codec);
6484 return err; 6492 return err;
6485 } 6493 }
6486 6494
6487 /* 6495 /*
6488 * ALC662 support 6496 * ALC662 support
6489 * 6497 *
6490 * ALC662 is almost identical with ALC880 but has cleaner and more flexible 6498 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
6491 * configuration. Each pin widget can choose any input DACs and a mixer. 6499 * configuration. Each pin widget can choose any input DACs and a mixer.
6492 * Each ADC is connected from a mixer of all inputs. This makes possible 6500 * Each ADC is connected from a mixer of all inputs. This makes possible
6493 * 6-channel independent captures. 6501 * 6-channel independent captures.
6494 * 6502 *
6495 * In addition, an independent DAC for the multi-playback (not used in this 6503 * In addition, an independent DAC for the multi-playback (not used in this
6496 * driver yet). 6504 * driver yet).
6497 */ 6505 */
6498 6506
6499 /* 6507 /*
6500 * BIOS auto configuration 6508 * BIOS auto configuration
6501 */ 6509 */
6502 6510
6503 static int alc662_parse_auto_config(struct hda_codec *codec) 6511 static int alc662_parse_auto_config(struct hda_codec *codec)
6504 { 6512 {
6505 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 }; 6513 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
6506 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 }; 6514 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
6507 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; 6515 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
6508 const hda_nid_t *ssids; 6516 const hda_nid_t *ssids;
6509 6517
6510 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || 6518 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
6511 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670) 6519 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
6512 ssids = alc663_ssids; 6520 ssids = alc663_ssids;
6513 else 6521 else
6514 ssids = alc662_ssids; 6522 ssids = alc662_ssids;
6515 return alc_parse_auto_config(codec, alc662_ignore, ssids); 6523 return alc_parse_auto_config(codec, alc662_ignore, ssids);
6516 } 6524 }
6517 6525
6518 static void alc272_fixup_mario(struct hda_codec *codec, 6526 static void alc272_fixup_mario(struct hda_codec *codec,
6519 const struct alc_fixup *fix, int action) 6527 const struct alc_fixup *fix, int action)
6520 { 6528 {
6521 if (action != ALC_FIXUP_ACT_PROBE) 6529 if (action != ALC_FIXUP_ACT_PROBE)
6522 return; 6530 return;
6523 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT, 6531 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
6524 (0x3b << AC_AMPCAP_OFFSET_SHIFT) | 6532 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
6525 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) | 6533 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
6526 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) | 6534 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
6527 (0 << AC_AMPCAP_MUTE_SHIFT))) 6535 (0 << AC_AMPCAP_MUTE_SHIFT)))
6528 printk(KERN_WARNING 6536 printk(KERN_WARNING
6529 "hda_codec: failed to override amp caps for NID 0x2\n"); 6537 "hda_codec: failed to override amp caps for NID 0x2\n");
6530 } 6538 }
6531 6539
6532 enum { 6540 enum {
6533 ALC662_FIXUP_ASPIRE, 6541 ALC662_FIXUP_ASPIRE,
6534 ALC662_FIXUP_IDEAPAD, 6542 ALC662_FIXUP_IDEAPAD,
6535 ALC272_FIXUP_MARIO, 6543 ALC272_FIXUP_MARIO,
6536 ALC662_FIXUP_CZC_P10T, 6544 ALC662_FIXUP_CZC_P10T,
6537 ALC662_FIXUP_SKU_IGNORE, 6545 ALC662_FIXUP_SKU_IGNORE,
6538 ALC662_FIXUP_HP_RP5800, 6546 ALC662_FIXUP_HP_RP5800,
6539 ALC662_FIXUP_ASUS_MODE1, 6547 ALC662_FIXUP_ASUS_MODE1,
6540 ALC662_FIXUP_ASUS_MODE2, 6548 ALC662_FIXUP_ASUS_MODE2,
6541 ALC662_FIXUP_ASUS_MODE3, 6549 ALC662_FIXUP_ASUS_MODE3,
6542 ALC662_FIXUP_ASUS_MODE4, 6550 ALC662_FIXUP_ASUS_MODE4,
6543 ALC662_FIXUP_ASUS_MODE5, 6551 ALC662_FIXUP_ASUS_MODE5,
6544 ALC662_FIXUP_ASUS_MODE6, 6552 ALC662_FIXUP_ASUS_MODE6,
6545 ALC662_FIXUP_ASUS_MODE7, 6553 ALC662_FIXUP_ASUS_MODE7,
6546 ALC662_FIXUP_ASUS_MODE8, 6554 ALC662_FIXUP_ASUS_MODE8,
6547 ALC662_FIXUP_NO_JACK_DETECT, 6555 ALC662_FIXUP_NO_JACK_DETECT,
6548 }; 6556 };
6549 6557
6550 static const struct alc_fixup alc662_fixups[] = { 6558 static const struct alc_fixup alc662_fixups[] = {
6551 [ALC662_FIXUP_ASPIRE] = { 6559 [ALC662_FIXUP_ASPIRE] = {
6552 .type = ALC_FIXUP_PINS, 6560 .type = ALC_FIXUP_PINS,
6553 .v.pins = (const struct alc_pincfg[]) { 6561 .v.pins = (const struct alc_pincfg[]) {
6554 { 0x15, 0x99130112 }, /* subwoofer */ 6562 { 0x15, 0x99130112 }, /* subwoofer */
6555 { } 6563 { }
6556 } 6564 }
6557 }, 6565 },
6558 [ALC662_FIXUP_IDEAPAD] = { 6566 [ALC662_FIXUP_IDEAPAD] = {
6559 .type = ALC_FIXUP_PINS, 6567 .type = ALC_FIXUP_PINS,
6560 .v.pins = (const struct alc_pincfg[]) { 6568 .v.pins = (const struct alc_pincfg[]) {
6561 { 0x17, 0x99130112 }, /* subwoofer */ 6569 { 0x17, 0x99130112 }, /* subwoofer */
6562 { } 6570 { }
6563 } 6571 }
6564 }, 6572 },
6565 [ALC272_FIXUP_MARIO] = { 6573 [ALC272_FIXUP_MARIO] = {
6566 .type = ALC_FIXUP_FUNC, 6574 .type = ALC_FIXUP_FUNC,
6567 .v.func = alc272_fixup_mario, 6575 .v.func = alc272_fixup_mario,
6568 }, 6576 },
6569 [ALC662_FIXUP_CZC_P10T] = { 6577 [ALC662_FIXUP_CZC_P10T] = {
6570 .type = ALC_FIXUP_VERBS, 6578 .type = ALC_FIXUP_VERBS,
6571 .v.verbs = (const struct hda_verb[]) { 6579 .v.verbs = (const struct hda_verb[]) {
6572 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, 6580 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
6573 {} 6581 {}
6574 } 6582 }
6575 }, 6583 },
6576 [ALC662_FIXUP_SKU_IGNORE] = { 6584 [ALC662_FIXUP_SKU_IGNORE] = {
6577 .type = ALC_FIXUP_SKU, 6585 .type = ALC_FIXUP_SKU,
6578 .v.sku = ALC_FIXUP_SKU_IGNORE, 6586 .v.sku = ALC_FIXUP_SKU_IGNORE,
6579 }, 6587 },
6580 [ALC662_FIXUP_HP_RP5800] = { 6588 [ALC662_FIXUP_HP_RP5800] = {
6581 .type = ALC_FIXUP_PINS, 6589 .type = ALC_FIXUP_PINS,
6582 .v.pins = (const struct alc_pincfg[]) { 6590 .v.pins = (const struct alc_pincfg[]) {
6583 { 0x14, 0x0221201f }, /* HP out */ 6591 { 0x14, 0x0221201f }, /* HP out */
6584 { } 6592 { }
6585 }, 6593 },
6586 .chained = true, 6594 .chained = true,
6587 .chain_id = ALC662_FIXUP_SKU_IGNORE 6595 .chain_id = ALC662_FIXUP_SKU_IGNORE
6588 }, 6596 },
6589 [ALC662_FIXUP_ASUS_MODE1] = { 6597 [ALC662_FIXUP_ASUS_MODE1] = {
6590 .type = ALC_FIXUP_PINS, 6598 .type = ALC_FIXUP_PINS,
6591 .v.pins = (const struct alc_pincfg[]) { 6599 .v.pins = (const struct alc_pincfg[]) {
6592 { 0x14, 0x99130110 }, /* speaker */ 6600 { 0x14, 0x99130110 }, /* speaker */
6593 { 0x18, 0x01a19c20 }, /* mic */ 6601 { 0x18, 0x01a19c20 }, /* mic */
6594 { 0x19, 0x99a3092f }, /* int-mic */ 6602 { 0x19, 0x99a3092f }, /* int-mic */
6595 { 0x21, 0x0121401f }, /* HP out */ 6603 { 0x21, 0x0121401f }, /* HP out */
6596 { } 6604 { }
6597 }, 6605 },
6598 .chained = true, 6606 .chained = true,
6599 .chain_id = ALC662_FIXUP_SKU_IGNORE 6607 .chain_id = ALC662_FIXUP_SKU_IGNORE
6600 }, 6608 },
6601 [ALC662_FIXUP_ASUS_MODE2] = { 6609 [ALC662_FIXUP_ASUS_MODE2] = {
6602 .type = ALC_FIXUP_PINS, 6610 .type = ALC_FIXUP_PINS,
6603 .v.pins = (const struct alc_pincfg[]) { 6611 .v.pins = (const struct alc_pincfg[]) {
6604 { 0x14, 0x99130110 }, /* speaker */ 6612 { 0x14, 0x99130110 }, /* speaker */
6605 { 0x18, 0x01a19820 }, /* mic */ 6613 { 0x18, 0x01a19820 }, /* mic */
6606 { 0x19, 0x99a3092f }, /* int-mic */ 6614 { 0x19, 0x99a3092f }, /* int-mic */
6607 { 0x1b, 0x0121401f }, /* HP out */ 6615 { 0x1b, 0x0121401f }, /* HP out */
6608 { } 6616 { }
6609 }, 6617 },
6610 .chained = true, 6618 .chained = true,
6611 .chain_id = ALC662_FIXUP_SKU_IGNORE 6619 .chain_id = ALC662_FIXUP_SKU_IGNORE
6612 }, 6620 },
6613 [ALC662_FIXUP_ASUS_MODE3] = { 6621 [ALC662_FIXUP_ASUS_MODE3] = {
6614 .type = ALC_FIXUP_PINS, 6622 .type = ALC_FIXUP_PINS,
6615 .v.pins = (const struct alc_pincfg[]) { 6623 .v.pins = (const struct alc_pincfg[]) {
6616 { 0x14, 0x99130110 }, /* speaker */ 6624 { 0x14, 0x99130110 }, /* speaker */
6617 { 0x15, 0x0121441f }, /* HP */ 6625 { 0x15, 0x0121441f }, /* HP */
6618 { 0x18, 0x01a19840 }, /* mic */ 6626 { 0x18, 0x01a19840 }, /* mic */
6619 { 0x19, 0x99a3094f }, /* int-mic */ 6627 { 0x19, 0x99a3094f }, /* int-mic */
6620 { 0x21, 0x01211420 }, /* HP2 */ 6628 { 0x21, 0x01211420 }, /* HP2 */
6621 { } 6629 { }
6622 }, 6630 },
6623 .chained = true, 6631 .chained = true,
6624 .chain_id = ALC662_FIXUP_SKU_IGNORE 6632 .chain_id = ALC662_FIXUP_SKU_IGNORE
6625 }, 6633 },
6626 [ALC662_FIXUP_ASUS_MODE4] = { 6634 [ALC662_FIXUP_ASUS_MODE4] = {
6627 .type = ALC_FIXUP_PINS, 6635 .type = ALC_FIXUP_PINS,
6628 .v.pins = (const struct alc_pincfg[]) { 6636 .v.pins = (const struct alc_pincfg[]) {
6629 { 0x14, 0x99130110 }, /* speaker */ 6637 { 0x14, 0x99130110 }, /* speaker */
6630 { 0x16, 0x99130111 }, /* speaker */ 6638 { 0x16, 0x99130111 }, /* speaker */
6631 { 0x18, 0x01a19840 }, /* mic */ 6639 { 0x18, 0x01a19840 }, /* mic */
6632 { 0x19, 0x99a3094f }, /* int-mic */ 6640 { 0x19, 0x99a3094f }, /* int-mic */
6633 { 0x21, 0x0121441f }, /* HP */ 6641 { 0x21, 0x0121441f }, /* HP */
6634 { } 6642 { }
6635 }, 6643 },
6636 .chained = true, 6644 .chained = true,
6637 .chain_id = ALC662_FIXUP_SKU_IGNORE 6645 .chain_id = ALC662_FIXUP_SKU_IGNORE
6638 }, 6646 },
6639 [ALC662_FIXUP_ASUS_MODE5] = { 6647 [ALC662_FIXUP_ASUS_MODE5] = {
6640 .type = ALC_FIXUP_PINS, 6648 .type = ALC_FIXUP_PINS,
6641 .v.pins = (const struct alc_pincfg[]) { 6649 .v.pins = (const struct alc_pincfg[]) {
6642 { 0x14, 0x99130110 }, /* speaker */ 6650 { 0x14, 0x99130110 }, /* speaker */
6643 { 0x15, 0x0121441f }, /* HP */ 6651 { 0x15, 0x0121441f }, /* HP */
6644 { 0x16, 0x99130111 }, /* speaker */ 6652 { 0x16, 0x99130111 }, /* speaker */
6645 { 0x18, 0x01a19840 }, /* mic */ 6653 { 0x18, 0x01a19840 }, /* mic */
6646 { 0x19, 0x99a3094f }, /* int-mic */ 6654 { 0x19, 0x99a3094f }, /* int-mic */
6647 { } 6655 { }
6648 }, 6656 },
6649 .chained = true, 6657 .chained = true,
6650 .chain_id = ALC662_FIXUP_SKU_IGNORE 6658 .chain_id = ALC662_FIXUP_SKU_IGNORE
6651 }, 6659 },
6652 [ALC662_FIXUP_ASUS_MODE6] = { 6660 [ALC662_FIXUP_ASUS_MODE6] = {
6653 .type = ALC_FIXUP_PINS, 6661 .type = ALC_FIXUP_PINS,
6654 .v.pins = (const struct alc_pincfg[]) { 6662 .v.pins = (const struct alc_pincfg[]) {
6655 { 0x14, 0x99130110 }, /* speaker */ 6663 { 0x14, 0x99130110 }, /* speaker */
6656 { 0x15, 0x01211420 }, /* HP2 */ 6664 { 0x15, 0x01211420 }, /* HP2 */
6657 { 0x18, 0x01a19840 }, /* mic */ 6665 { 0x18, 0x01a19840 }, /* mic */
6658 { 0x19, 0x99a3094f }, /* int-mic */ 6666 { 0x19, 0x99a3094f }, /* int-mic */
6659 { 0x1b, 0x0121441f }, /* HP */ 6667 { 0x1b, 0x0121441f }, /* HP */
6660 { } 6668 { }
6661 }, 6669 },
6662 .chained = true, 6670 .chained = true,
6663 .chain_id = ALC662_FIXUP_SKU_IGNORE 6671 .chain_id = ALC662_FIXUP_SKU_IGNORE
6664 }, 6672 },
6665 [ALC662_FIXUP_ASUS_MODE7] = { 6673 [ALC662_FIXUP_ASUS_MODE7] = {
6666 .type = ALC_FIXUP_PINS, 6674 .type = ALC_FIXUP_PINS,
6667 .v.pins = (const struct alc_pincfg[]) { 6675 .v.pins = (const struct alc_pincfg[]) {
6668 { 0x14, 0x99130110 }, /* speaker */ 6676 { 0x14, 0x99130110 }, /* speaker */
6669 { 0x17, 0x99130111 }, /* speaker */ 6677 { 0x17, 0x99130111 }, /* speaker */
6670 { 0x18, 0x01a19840 }, /* mic */ 6678 { 0x18, 0x01a19840 }, /* mic */
6671 { 0x19, 0x99a3094f }, /* int-mic */ 6679 { 0x19, 0x99a3094f }, /* int-mic */
6672 { 0x1b, 0x01214020 }, /* HP */ 6680 { 0x1b, 0x01214020 }, /* HP */
6673 { 0x21, 0x0121401f }, /* HP */ 6681 { 0x21, 0x0121401f }, /* HP */
6674 { } 6682 { }
6675 }, 6683 },
6676 .chained = true, 6684 .chained = true,
6677 .chain_id = ALC662_FIXUP_SKU_IGNORE 6685 .chain_id = ALC662_FIXUP_SKU_IGNORE
6678 }, 6686 },
6679 [ALC662_FIXUP_ASUS_MODE8] = { 6687 [ALC662_FIXUP_ASUS_MODE8] = {
6680 .type = ALC_FIXUP_PINS, 6688 .type = ALC_FIXUP_PINS,
6681 .v.pins = (const struct alc_pincfg[]) { 6689 .v.pins = (const struct alc_pincfg[]) {
6682 { 0x14, 0x99130110 }, /* speaker */ 6690 { 0x14, 0x99130110 }, /* speaker */
6683 { 0x12, 0x99a30970 }, /* int-mic */ 6691 { 0x12, 0x99a30970 }, /* int-mic */
6684 { 0x15, 0x01214020 }, /* HP */ 6692 { 0x15, 0x01214020 }, /* HP */
6685 { 0x17, 0x99130111 }, /* speaker */ 6693 { 0x17, 0x99130111 }, /* speaker */
6686 { 0x18, 0x01a19840 }, /* mic */ 6694 { 0x18, 0x01a19840 }, /* mic */
6687 { 0x21, 0x0121401f }, /* HP */ 6695 { 0x21, 0x0121401f }, /* HP */
6688 { } 6696 { }
6689 }, 6697 },
6690 .chained = true, 6698 .chained = true,
6691 .chain_id = ALC662_FIXUP_SKU_IGNORE 6699 .chain_id = ALC662_FIXUP_SKU_IGNORE
6692 }, 6700 },
6693 [ALC662_FIXUP_NO_JACK_DETECT] = { 6701 [ALC662_FIXUP_NO_JACK_DETECT] = {
6694 .type = ALC_FIXUP_FUNC, 6702 .type = ALC_FIXUP_FUNC,
6695 .v.func = alc_fixup_no_jack_detect, 6703 .v.func = alc_fixup_no_jack_detect,
6696 }, 6704 },
6697 }; 6705 };
6698 6706
6699 static const struct snd_pci_quirk alc662_fixup_tbl[] = { 6707 static const struct snd_pci_quirk alc662_fixup_tbl[] = {
6700 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2), 6708 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
6701 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), 6709 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
6702 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), 6710 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
6703 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), 6711 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
6704 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), 6712 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
6705 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), 6713 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
6706 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), 6714 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
6707 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), 6715 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
6708 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), 6716 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
6709 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), 6717 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
6710 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), 6718 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
6711 6719
6712 #if 0 6720 #if 0
6713 /* Below is a quirk table taken from the old code. 6721 /* Below is a quirk table taken from the old code.
6714 * Basically the device should work as is without the fixup table. 6722 * Basically the device should work as is without the fixup table.
6715 * If BIOS doesn't give a proper info, enable the corresponding 6723 * If BIOS doesn't give a proper info, enable the corresponding
6716 * fixup entry. 6724 * fixup entry.
6717 */ 6725 */
6718 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1), 6726 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
6719 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3), 6727 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
6720 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), 6728 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
6721 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3), 6729 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
6722 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), 6730 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6723 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6731 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6724 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), 6732 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6725 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1), 6733 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
6726 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1), 6734 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
6727 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6735 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6728 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7), 6736 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
6729 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7), 6737 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
6730 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8), 6738 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
6731 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3), 6739 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
6732 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1), 6740 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
6733 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6741 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6734 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2), 6742 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
6735 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1), 6743 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
6736 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6744 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6737 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), 6745 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6738 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), 6746 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6739 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6747 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6740 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1), 6748 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
6741 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3), 6749 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
6742 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2), 6750 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
6743 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6751 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6744 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5), 6752 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
6745 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), 6753 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
6746 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6754 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6747 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1), 6755 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
6748 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6756 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6749 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6757 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6750 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3), 6758 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
6751 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3), 6759 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
6752 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1), 6760 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
6753 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1), 6761 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
6754 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1), 6762 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
6755 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1), 6763 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
6756 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1), 6764 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
6757 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6765 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
6758 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2), 6766 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
6759 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1), 6767 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
6760 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), 6768 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6761 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3), 6769 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
6762 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1), 6770 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
6763 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1), 6771 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
6764 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1), 6772 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
6765 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2), 6773 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
6766 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), 6774 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
6767 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4), 6775 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
6768 #endif 6776 #endif
6769 {} 6777 {}
6770 }; 6778 };
6771 6779
6772 static const struct alc_model_fixup alc662_fixup_models[] = { 6780 static const struct alc_model_fixup alc662_fixup_models[] = {
6773 {.id = ALC272_FIXUP_MARIO, .name = "mario"}, 6781 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
6774 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"}, 6782 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
6775 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"}, 6783 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
6776 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"}, 6784 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
6777 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"}, 6785 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
6778 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"}, 6786 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
6779 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"}, 6787 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
6780 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"}, 6788 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
6781 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"}, 6789 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
6782 {} 6790 {}
6783 }; 6791 };
6784 6792
6785 6793
6786 /* 6794 /*
6787 */ 6795 */
6788 static int patch_alc662(struct hda_codec *codec) 6796 static int patch_alc662(struct hda_codec *codec)
6789 { 6797 {
6790 struct alc_spec *spec; 6798 struct alc_spec *spec;
6791 int err = 0; 6799 int err = 0;
6792 6800
6793 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 6801 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6794 if (!spec) 6802 if (!spec)
6795 return -ENOMEM; 6803 return -ENOMEM;
6796 6804
6797 codec->spec = spec; 6805 codec->spec = spec;
6798 6806
6799 spec->mixer_nid = 0x0b; 6807 spec->mixer_nid = 0x0b;
6800 6808
6801 /* handle multiple HPs as is */ 6809 /* handle multiple HPs as is */
6802 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; 6810 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
6803 6811
6804 alc_auto_parse_customize_define(codec); 6812 alc_auto_parse_customize_define(codec);
6805 6813
6806 alc_fix_pll_init(codec, 0x20, 0x04, 15); 6814 alc_fix_pll_init(codec, 0x20, 0x04, 15);
6807 6815
6808 err = alc_codec_rename_from_preset(codec); 6816 err = alc_codec_rename_from_preset(codec);
6809 if (err < 0) 6817 if (err < 0)
6810 goto error; 6818 goto error;
6811 6819
6812 if ((alc_get_coef0(codec) & (1 << 14)) && 6820 if ((alc_get_coef0(codec) & (1 << 14)) &&
6813 codec->bus->pci->subsystem_vendor == 0x1025 && 6821 codec->bus->pci->subsystem_vendor == 0x1025 &&
6814 spec->cdefine.platform_type == 1) { 6822 spec->cdefine.platform_type == 1) {
6815 if (alc_codec_rename(codec, "ALC272X") < 0) 6823 if (alc_codec_rename(codec, "ALC272X") < 0)
6816 goto error; 6824 goto error;
6817 } 6825 }
6818 6826
6819 alc_pick_fixup(codec, alc662_fixup_models, 6827 alc_pick_fixup(codec, alc662_fixup_models,
6820 alc662_fixup_tbl, alc662_fixups); 6828 alc662_fixup_tbl, alc662_fixups);
6821 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); 6829 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
6822 /* automatic parse from the BIOS config */ 6830 /* automatic parse from the BIOS config */
6823 err = alc662_parse_auto_config(codec); 6831 err = alc662_parse_auto_config(codec);
6824 if (err < 0) 6832 if (err < 0)
6825 goto error; 6833 goto error;
6826 6834
6827 if (!spec->no_analog && has_cdefine_beep(codec)) { 6835 if (!spec->no_analog && has_cdefine_beep(codec)) {
6828 err = snd_hda_attach_beep_device(codec, 0x1); 6836 err = snd_hda_attach_beep_device(codec, 0x1);
6829 if (err < 0) 6837 if (err < 0)
6830 goto error; 6838 goto error;
6831 switch (codec->vendor_id) { 6839 switch (codec->vendor_id) {
6832 case 0x10ec0662: 6840 case 0x10ec0662:
6833 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 6841 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
6834 break; 6842 break;
6835 case 0x10ec0272: 6843 case 0x10ec0272:
6836 case 0x10ec0663: 6844 case 0x10ec0663:
6837 case 0x10ec0665: 6845 case 0x10ec0665:
6838 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); 6846 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
6839 break; 6847 break;
6840 case 0x10ec0273: 6848 case 0x10ec0273:
6841 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); 6849 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
6842 break; 6850 break;
6843 } 6851 }
6844 } 6852 }
6845 6853
6846 codec->patch_ops = alc_patch_ops; 6854 codec->patch_ops = alc_patch_ops;
6847 spec->shutup = alc_eapd_shutup; 6855 spec->shutup = alc_eapd_shutup;
6848 6856
6849 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); 6857 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
6850 6858
6851 return 0; 6859 return 0;
6852 6860
6853 error: 6861 error:
6854 alc_free(codec); 6862 alc_free(codec);
6855 return err; 6863 return err;
6856 } 6864 }
6857 6865
6858 /* 6866 /*
6859 * ALC680 support 6867 * ALC680 support
6860 */ 6868 */
6861 6869
6862 static int alc680_parse_auto_config(struct hda_codec *codec) 6870 static int alc680_parse_auto_config(struct hda_codec *codec)
6863 { 6871 {
6864 return alc_parse_auto_config(codec, NULL, NULL); 6872 return alc_parse_auto_config(codec, NULL, NULL);
6865 } 6873 }
6866 6874
6867 /* 6875 /*
6868 */ 6876 */
6869 static int patch_alc680(struct hda_codec *codec) 6877 static int patch_alc680(struct hda_codec *codec)
6870 { 6878 {
6871 struct alc_spec *spec; 6879 struct alc_spec *spec;
6872 int err; 6880 int err;
6873 6881
6874 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 6882 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6875 if (spec == NULL) 6883 if (spec == NULL)
6876 return -ENOMEM; 6884 return -ENOMEM;
6877 6885
6878 codec->spec = spec; 6886 codec->spec = spec;
6879 6887
6880 /* ALC680 has no aa-loopback mixer */ 6888 /* ALC680 has no aa-loopback mixer */
6881 6889
6882 /* automatic parse from the BIOS config */ 6890 /* automatic parse from the BIOS config */
6883 err = alc680_parse_auto_config(codec); 6891 err = alc680_parse_auto_config(codec);
6884 if (err < 0) { 6892 if (err < 0) {
6885 alc_free(codec); 6893 alc_free(codec);
6886 return err; 6894 return err;
6887 } 6895 }
6888 6896
6889 codec->patch_ops = alc_patch_ops; 6897 codec->patch_ops = alc_patch_ops;
6890 6898
6891 return 0; 6899 return 0;
6892 } 6900 }
6893 6901
6894 /* 6902 /*
6895 * patch entries 6903 * patch entries
6896 */ 6904 */
6897 static const struct hda_codec_preset snd_hda_preset_realtek[] = { 6905 static const struct hda_codec_preset snd_hda_preset_realtek[] = {
6898 { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, 6906 { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
6899 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, 6907 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
6900 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, 6908 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
6901 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, 6909 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
6902 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, 6910 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
6903 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, 6911 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
6904 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, 6912 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
6905 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, 6913 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
6906 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, 6914 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
6907 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 }, 6915 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
6908 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", 6916 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
6909 .patch = patch_alc861 }, 6917 .patch = patch_alc861 },
6910 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, 6918 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
6911 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, 6919 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
6912 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, 6920 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
6913 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", 6921 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
6914 .patch = patch_alc882 }, 6922 .patch = patch_alc882 },
6915 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", 6923 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
6916 .patch = patch_alc662 }, 6924 .patch = patch_alc662 },
6917 { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3", 6925 { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3",
6918 .patch = patch_alc662 }, 6926 .patch = patch_alc662 },
6919 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, 6927 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
6920 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, 6928 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
6921 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, 6929 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
6922 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, 6930 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
6923 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, 6931 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
6924 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, 6932 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
6925 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, 6933 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
6926 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", 6934 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
6927 .patch = patch_alc882 }, 6935 .patch = patch_alc882 },
6928 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", 6936 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
6929 .patch = patch_alc882 }, 6937 .patch = patch_alc882 },
6930 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, 6938 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
6931 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, 6939 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
6932 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", 6940 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
6933 .patch = patch_alc882 }, 6941 .patch = patch_alc882 },
6934 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, 6942 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
6935 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, 6943 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
6936 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, 6944 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
6937 { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, 6945 { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 },
6938 {} /* terminator */ 6946 {} /* terminator */
6939 }; 6947 };
6940 6948
6941 MODULE_ALIAS("snd-hda-codec-id:10ec*"); 6949 MODULE_ALIAS("snd-hda-codec-id:10ec*");
6942 6950
6943 MODULE_LICENSE("GPL"); 6951 MODULE_LICENSE("GPL");
6944 MODULE_DESCRIPTION("Realtek HD-audio codec"); 6952 MODULE_DESCRIPTION("Realtek HD-audio codec");
6945 6953
6946 static struct hda_codec_preset_list realtek_list = { 6954 static struct hda_codec_preset_list realtek_list = {
6947 .preset = snd_hda_preset_realtek, 6955 .preset = snd_hda_preset_realtek,
6948 .owner = THIS_MODULE, 6956 .owner = THIS_MODULE,
6949 }; 6957 };
6950 6958
6951 static int __init patch_realtek_init(void) 6959 static int __init patch_realtek_init(void)
6952 { 6960 {
6953 return snd_hda_add_codec_preset(&realtek_list); 6961 return snd_hda_add_codec_preset(&realtek_list);
6954 } 6962 }
6955 6963
6956 static void __exit patch_realtek_exit(void) 6964 static void __exit patch_realtek_exit(void)
6957 { 6965 {
6958 snd_hda_delete_codec_preset(&realtek_list); 6966 snd_hda_delete_codec_preset(&realtek_list);
6959 } 6967 }
6960 6968
6961 module_init(patch_realtek_init) 6969 module_init(patch_realtek_init)
6962 module_exit(patch_realtek_exit) 6970 module_exit(patch_realtek_exit)
6963 6971