blob: 8ae48061e8c7b0105ffbbf8ee9238ad5f0130ff9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
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
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
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
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010081 ALC260_FAVORIT100,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +010082#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010085 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020086 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
Kailang Yangdf694da2005-12-05 19:42:22 +010089/* ALC262 models */
90enum {
91 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020092 ALC262_HIPPO,
93 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010094 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020095 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010096 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010098 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010099 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200100 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200101 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200102 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200103 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100104 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200105 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200106 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200107 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000108 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
Kailang Yanga361d842007-06-05 12:30:55 +0200113/* ALC268 models */
114enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200115 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200116 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200117 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200118 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100119 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200120 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100121 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100122 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
Kailang Yangf6a92242007-12-13 16:52:54 +0100130/* ALC269 models */
131enum {
132 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200133 ALC269_QUANTA_FL1,
Kailang Yang84898e82010-02-04 14:16:14 +0100134 ALC269_AMIC,
135 ALC269_DMIC,
136 ALC269VB_AMIC,
137 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100138 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000139 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100140 ALC269_AUTO,
141 ALC269_MODEL_LAST /* last tag */
142};
143
Kailang Yangdf694da2005-12-05 19:42:22 +0100144/* ALC861 models */
145enum {
146 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200147 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100148 ALC861_3ST_DIG,
149 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200150 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200151 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200152 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100153 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100154 ALC861_AUTO,
155 ALC861_MODEL_LAST,
156};
157
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100158/* ALC861-VD models */
159enum {
160 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200161 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100162 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100163 ALC861VD_3ST,
164 ALC861VD_3ST_DIG,
165 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200166 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200167 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200168 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100169 ALC861VD_AUTO,
170 ALC861VD_MODEL_LAST,
171};
172
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200173/* ALC662 models */
174enum {
175 ALC662_3ST_2ch_DIG,
176 ALC662_3ST_6ch_DIG,
177 ALC662_3ST_6ch,
178 ALC662_5ST_DIG,
179 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200180 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100181 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200182 ALC663_ASUS_M51VA,
183 ALC663_ASUS_G71V,
184 ALC663_ASUS_H13,
185 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200186 ALC662_ECS,
187 ALC663_ASUS_MODE1,
188 ALC662_ASUS_MODE2,
189 ALC663_ASUS_MODE3,
190 ALC663_ASUS_MODE4,
191 ALC663_ASUS_MODE5,
192 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100193 ALC663_ASUS_MODE7,
194 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200195 ALC272_DELL,
196 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200197 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200198 ALC662_AUTO,
199 ALC662_MODEL_LAST,
200};
201
Kailang Yangdf694da2005-12-05 19:42:22 +0100202/* ALC882 models */
203enum {
204 ALC882_3ST_DIG,
205 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200206 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200207 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200208 ALC882_TARGA,
209 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200210 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100211 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800212 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200213 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200214 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100215 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200216 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800217 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200218 ALC883_3ST_2ch_DIG,
219 ALC883_3ST_6ch_DIG,
220 ALC883_3ST_6ch,
221 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200222 ALC883_TARGA_DIG,
223 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200224 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200225 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200226 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800227 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100228 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200229 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200230 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200231 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200232 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100233 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200234 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200235 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200236 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200237 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200238 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200239 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100240 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100241 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430242 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100243 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100244 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800245 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200246 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200247 ALC889A_INTEL,
248 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200249 ALC888_ASUS_M90V,
250 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200251 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100252 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200253 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200254 ALC882_AUTO,
255 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200256};
257
Kailang Yangdf694da2005-12-05 19:42:22 +0100258/* for GPIO Poll */
259#define GPIO_MASK 0x03
260
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200261/* extra amp-initialization sequence types */
262enum {
263 ALC_INIT_NONE,
264 ALC_INIT_DEFAULT,
265 ALC_INIT_GPIO1,
266 ALC_INIT_GPIO2,
267 ALC_INIT_GPIO3,
268};
269
Takashi Iwai6c819492009-08-10 18:47:44 +0200270struct alc_mic_route {
271 hda_nid_t pin;
272 unsigned char mux_idx;
273 unsigned char amix_idx;
274};
275
276#define MUX_IDX_UNDEF ((unsigned char)-1)
277
Kailang Yangda00c242010-03-19 11:23:45 +0100278struct alc_customize_define {
279 unsigned int sku_cfg;
280 unsigned char port_connectivity;
281 unsigned char check_sum;
282 unsigned char customization;
283 unsigned char external_amp;
284 unsigned int enable_pcbeep:1;
285 unsigned int platform_type:1;
286 unsigned int swap:1;
287 unsigned int override:1;
288};
289
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290struct alc_spec {
291 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100292 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100294 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100295 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200297 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200298 * don't forget NULL
299 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200300 */
301 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200303 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 struct hda_pcm_stream *stream_analog_playback;
305 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100306 struct hda_pcm_stream *stream_analog_alt_playback;
307 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200309 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 struct hda_pcm_stream *stream_digital_playback;
311 struct hda_pcm_stream *stream_digital_capture;
312
313 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200314 struct hda_multi_out multiout; /* playback set-up
315 * max_channels, dacs must be set
316 * dig_out_nid and hp_nid are optional
317 */
Takashi Iwai63300792008-01-24 15:31:36 +0100318 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100319 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100320 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321
322 /* capture */
323 unsigned int num_adc_nids;
324 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100325 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200326 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327
328 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200329 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 const struct hda_input_mux *input_mux;
331 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200332 struct alc_mic_route ext_mic;
333 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334
335 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100336 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200338 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200339 int const_channel_count;
340 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341
342 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100343 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200344
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200345 /* dynamic controls, init_verbs and input_mux */
346 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100347 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200348 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200349 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200350 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200351 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
352 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100353
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100354 /* hooks */
355 void (*init_hook)(struct hda_codec *codec);
356 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100357#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500358 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100359#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100360
Takashi Iwai834be882006-03-01 14:16:17 +0100361 /* for pin sensing */
362 unsigned int sense_updated: 1;
363 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100364 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200365 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200366
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100367 /* other flags */
368 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200369 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100370
Takashi Iwai2134ea42008-01-10 16:53:55 +0100371 /* for virtual master */
372 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200373#ifdef CONFIG_SND_HDA_POWER_SAVE
374 struct hda_loopback_check loopback;
375#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200376
377 /* for PLL fix */
378 hda_nid_t pll_nid;
379 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100380};
381
382/*
383 * configuration template - to be copied to the spec instance
384 */
385struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200386 struct snd_kcontrol_new *mixers[5]; /* should be identical size
387 * with spec
388 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100389 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100390 const struct hda_verb *init_verbs[5];
391 unsigned int num_dacs;
392 hda_nid_t *dac_nids;
393 hda_nid_t dig_out_nid; /* optional */
394 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800395 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100396 unsigned int num_adc_nids;
397 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100398 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100399 hda_nid_t dig_in_nid;
400 unsigned int num_channel_mode;
401 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200402 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200403 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200404 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100405 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100406 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200407 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100408 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200409#ifdef CONFIG_SND_HDA_POWER_SAVE
410 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500411 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200412#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413};
414
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415
416/*
417 * input MUX handling
418 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200419static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
420 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421{
422 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
423 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200424 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
425 if (mux_idx >= spec->num_mux_defs)
426 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100427 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
428 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200429 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430}
431
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200432static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
433 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434{
435 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
436 struct alc_spec *spec = codec->spec;
437 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
438
439 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
440 return 0;
441}
442
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200443static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
444 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445{
446 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
447 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100448 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100450 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100451 hda_nid_t nid = spec->capsrc_nids ?
452 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200453 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454
Takashi Iwaicd896c32008-11-18 12:36:33 +0100455 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
456 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100457 if (!imux->num_items && mux_idx > 0)
458 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100459
Takashi Iwaia22d5432009-07-27 12:54:26 +0200460 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200461 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100462 /* Matrix-mixer style (e.g. ALC882) */
463 unsigned int *cur_val = &spec->cur_mux[adc_idx];
464 unsigned int i, idx;
465
466 idx = ucontrol->value.enumerated.item[0];
467 if (idx >= imux->num_items)
468 idx = imux->num_items - 1;
469 if (*cur_val == idx)
470 return 0;
471 for (i = 0; i < imux->num_items; i++) {
472 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
473 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
474 imux->items[i].index,
475 HDA_AMP_MUTE, v);
476 }
477 *cur_val = idx;
478 return 1;
479 } else {
480 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100481 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100482 &spec->cur_mux[adc_idx]);
483 }
484}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200485
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486/*
487 * channel mode setting
488 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200489static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
490 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491{
492 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
493 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100494 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
495 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496}
497
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200498static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
499 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500{
501 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
502 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100503 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200504 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200505 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506}
507
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200508static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
509 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510{
511 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
512 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200513 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
514 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200515 &spec->ext_channel_count);
516 if (err >= 0 && !spec->const_channel_count) {
517 spec->multiout.max_channels = spec->ext_channel_count;
518 if (spec->need_dac_fix)
519 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
520 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200521 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522}
523
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100525 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200526 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100527 * being part of a format specifier. Maximum allowed length of a value is
528 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100529 *
530 * Note: some retasking pin complexes seem to ignore requests for input
531 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
532 * are requested. Therefore order this list so that this behaviour will not
533 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200534 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
535 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200536 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100537static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100538 "Mic 50pc bias", "Mic 80pc bias",
539 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100540};
541static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100542 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100543};
544/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200545 * in the pin being assumed to be exclusively an input or an output pin. In
546 * addition, "input" pins may or may not process the mic bias option
547 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
548 * accept requests for bias as of chip versions up to March 2006) and/or
549 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100550 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200551#define ALC_PIN_DIR_IN 0x00
552#define ALC_PIN_DIR_OUT 0x01
553#define ALC_PIN_DIR_INOUT 0x02
554#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
555#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100556
Kailang Yangea1fb292008-08-26 12:58:38 +0200557/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100558 * For each direction the minimum and maximum values are given.
559 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200560static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100561 { 0, 2 }, /* ALC_PIN_DIR_IN */
562 { 3, 4 }, /* ALC_PIN_DIR_OUT */
563 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200564 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
565 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100566};
567#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
568#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
569#define alc_pin_mode_n_items(_dir) \
570 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
571
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200572static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
573 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200574{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100575 unsigned int item_num = uinfo->value.enumerated.item;
576 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
577
578 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200579 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100580 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
581
582 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
583 item_num = alc_pin_mode_min(dir);
584 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200585 return 0;
586}
587
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200588static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
589 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200590{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100591 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200592 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
593 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100594 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200595 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200596 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
597 AC_VERB_GET_PIN_WIDGET_CONTROL,
598 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200599
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100600 /* Find enumerated value for current pinctl setting */
601 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200602 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100603 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200604 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100605 return 0;
606}
607
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200608static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
609 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100610{
611 signed int change;
612 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
613 hda_nid_t nid = kcontrol->private_value & 0xffff;
614 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
615 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200616 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
617 AC_VERB_GET_PIN_WIDGET_CONTROL,
618 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100619
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200620 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100621 val = alc_pin_mode_min(dir);
622
623 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100624 if (change) {
625 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200626 snd_hda_codec_write_cache(codec, nid, 0,
627 AC_VERB_SET_PIN_WIDGET_CONTROL,
628 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100629
Kailang Yangea1fb292008-08-26 12:58:38 +0200630 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100631 * for the requested pin mode. Enum values of 2 or less are
632 * input modes.
633 *
634 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200635 * reduces noise slightly (particularly on input) so we'll
636 * do it. However, having both input and output buffers
637 * enabled simultaneously doesn't seem to be problematic if
638 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100639 */
640 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200641 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
642 HDA_AMP_MUTE, HDA_AMP_MUTE);
643 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
644 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100645 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200646 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
647 HDA_AMP_MUTE, HDA_AMP_MUTE);
648 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
649 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100650 }
651 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200652 return change;
653}
654
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100655#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200656 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100657 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100658 .info = alc_pin_mode_info, \
659 .get = alc_pin_mode_get, \
660 .put = alc_pin_mode_put, \
661 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100662
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100663/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
664 * together using a mask with more than one bit set. This control is
665 * currently used only by the ALC260 test model. At this stage they are not
666 * needed for any "production" models.
667 */
668#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200669#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200670
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200671static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
672 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100673{
674 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
675 hda_nid_t nid = kcontrol->private_value & 0xffff;
676 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
677 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200678 unsigned int val = snd_hda_codec_read(codec, nid, 0,
679 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100680
681 *valp = (val & mask) != 0;
682 return 0;
683}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200684static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
685 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100686{
687 signed int change;
688 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
689 hda_nid_t nid = kcontrol->private_value & 0xffff;
690 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
691 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200692 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
693 AC_VERB_GET_GPIO_DATA,
694 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100695
696 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200697 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
698 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100699 gpio_data &= ~mask;
700 else
701 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200702 snd_hda_codec_write_cache(codec, nid, 0,
703 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100704
705 return change;
706}
707#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
708 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100709 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100710 .info = alc_gpio_data_info, \
711 .get = alc_gpio_data_get, \
712 .put = alc_gpio_data_put, \
713 .private_value = nid | (mask<<16) }
714#endif /* CONFIG_SND_DEBUG */
715
Jonathan Woithe92621f12006-02-28 11:47:47 +0100716/* A switch control to allow the enabling of the digital IO pins on the
717 * ALC260. This is incredibly simplistic; the intention of this control is
718 * to provide something in the test model allowing digital outputs to be
719 * identified if present. If models are found which can utilise these
720 * outputs a more complete mixer control can be devised for those models if
721 * necessary.
722 */
723#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200724#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200725
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200726static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
727 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100728{
729 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
730 hda_nid_t nid = kcontrol->private_value & 0xffff;
731 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
732 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200733 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100734 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100735
736 *valp = (val & mask) != 0;
737 return 0;
738}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200739static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
740 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100741{
742 signed int change;
743 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
744 hda_nid_t nid = kcontrol->private_value & 0xffff;
745 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
746 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200747 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100748 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200749 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100750
751 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200752 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100753 if (val==0)
754 ctrl_data &= ~mask;
755 else
756 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200757 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
758 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100759
760 return change;
761}
762#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
763 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100764 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100765 .info = alc_spdif_ctrl_info, \
766 .get = alc_spdif_ctrl_get, \
767 .put = alc_spdif_ctrl_put, \
768 .private_value = nid | (mask<<16) }
769#endif /* CONFIG_SND_DEBUG */
770
Jonathan Woithef8225f62008-01-08 12:16:54 +0100771/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
772 * Again, this is only used in the ALC26x test models to help identify when
773 * the EAPD line must be asserted for features to work.
774 */
775#ifdef CONFIG_SND_DEBUG
776#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
777
778static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
779 struct snd_ctl_elem_value *ucontrol)
780{
781 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
782 hda_nid_t nid = kcontrol->private_value & 0xffff;
783 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
784 long *valp = ucontrol->value.integer.value;
785 unsigned int val = snd_hda_codec_read(codec, nid, 0,
786 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
787
788 *valp = (val & mask) != 0;
789 return 0;
790}
791
792static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
793 struct snd_ctl_elem_value *ucontrol)
794{
795 int change;
796 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
797 hda_nid_t nid = kcontrol->private_value & 0xffff;
798 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
799 long val = *ucontrol->value.integer.value;
800 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
801 AC_VERB_GET_EAPD_BTLENABLE,
802 0x00);
803
804 /* Set/unset the masked control bit(s) as needed */
805 change = (!val ? 0 : mask) != (ctrl_data & mask);
806 if (!val)
807 ctrl_data &= ~mask;
808 else
809 ctrl_data |= mask;
810 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
811 ctrl_data);
812
813 return change;
814}
815
816#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
817 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100818 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100819 .info = alc_eapd_ctrl_info, \
820 .get = alc_eapd_ctrl_get, \
821 .put = alc_eapd_ctrl_put, \
822 .private_value = nid | (mask<<16) }
823#endif /* CONFIG_SND_DEBUG */
824
Kailang Yangdf694da2005-12-05 19:42:22 +0100825/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100826 * set up the input pin config (depending on the given auto-pin type)
827 */
828static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
829 int auto_pin_type)
830{
831 unsigned int val = PIN_IN;
832
833 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
834 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100835 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100836 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
837 if (pincap & AC_PINCAP_VREF_80)
838 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200839 else if (pincap & AC_PINCAP_VREF_50)
840 val = PIN_VREF50;
841 else if (pincap & AC_PINCAP_VREF_100)
842 val = PIN_VREF100;
843 else if (pincap & AC_PINCAP_VREF_GRD)
844 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100845 }
846 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
847}
848
849/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100850 */
851static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
852{
853 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
854 return;
855 spec->mixers[spec->num_mixers++] = mix;
856}
857
858static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
859{
860 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
861 return;
862 spec->init_verbs[spec->num_init_verbs++] = verb;
863}
864
865/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100866 * set up from the preset table
867 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200868static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200869 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100870{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200871 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100872 int i;
873
874 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100875 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100876 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200877 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
878 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100879 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200880
Kailang Yangdf694da2005-12-05 19:42:22 +0100881 spec->channel_mode = preset->channel_mode;
882 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200883 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200884 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100885
Hector Martin3b315d72009-06-02 10:54:19 +0200886 if (preset->const_channel_count)
887 spec->multiout.max_channels = preset->const_channel_count;
888 else
889 spec->multiout.max_channels = spec->channel_mode[0].channels;
890 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100891
892 spec->multiout.num_dacs = preset->num_dacs;
893 spec->multiout.dac_nids = preset->dac_nids;
894 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800895 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100896 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200897
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200898 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200899 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200900 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100901 spec->input_mux = preset->input_mux;
902
903 spec->num_adc_nids = preset->num_adc_nids;
904 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100905 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100906 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100907
908 spec->unsol_event = preset->unsol_event;
909 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200910#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100911 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200912 spec->loopback.amplist = preset->loopbacks;
913#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200914
915 if (preset->setup)
916 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100917}
918
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200919/* Enable GPIO mask and set output */
920static struct hda_verb alc_gpio1_init_verbs[] = {
921 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
922 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
923 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
924 { }
925};
926
927static struct hda_verb alc_gpio2_init_verbs[] = {
928 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
929 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
930 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
931 { }
932};
933
Kailang Yangbdd148a2007-05-08 15:19:08 +0200934static struct hda_verb alc_gpio3_init_verbs[] = {
935 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
936 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
937 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
938 { }
939};
940
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200941/*
942 * Fix hardware PLL issue
943 * On some codecs, the analog PLL gating control must be off while
944 * the default value is 1.
945 */
946static void alc_fix_pll(struct hda_codec *codec)
947{
948 struct alc_spec *spec = codec->spec;
949 unsigned int val;
950
951 if (!spec->pll_nid)
952 return;
953 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
954 spec->pll_coef_idx);
955 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
956 AC_VERB_GET_PROC_COEF, 0);
957 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
958 spec->pll_coef_idx);
959 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
960 val & ~(1 << spec->pll_coef_bit));
961}
962
963static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
964 unsigned int coef_idx, unsigned int coef_bit)
965{
966 struct alc_spec *spec = codec->spec;
967 spec->pll_nid = nid;
968 spec->pll_coef_idx = coef_idx;
969 spec->pll_coef_bit = coef_bit;
970 alc_fix_pll(codec);
971}
972
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200973static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200974{
975 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200976 unsigned int nid = spec->autocfg.hp_pins[0];
977 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200978
Takashi Iwaiad87c642009-11-02 14:23:15 +0100979 if (!nid)
980 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +0800981 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200982 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
983 nid = spec->autocfg.speaker_pins[i];
984 if (!nid)
985 break;
986 snd_hda_codec_write(codec, nid, 0,
987 AC_VERB_SET_PIN_WIDGET_CONTROL,
988 spec->jack_present ? 0 : PIN_OUT);
989 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200990}
991
Takashi Iwai6c819492009-08-10 18:47:44 +0200992static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
993 hda_nid_t nid)
994{
995 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
996 int i, nums;
997
998 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
999 for (i = 0; i < nums; i++)
1000 if (conn[i] == nid)
1001 return i;
1002 return -1;
1003}
1004
Kailang Yang7fb0d782008-10-15 11:12:35 +02001005static void alc_mic_automute(struct hda_codec *codec)
1006{
1007 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001008 struct alc_mic_route *dead, *alive;
1009 unsigned int present, type;
1010 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001011
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001012 if (!spec->auto_mic)
1013 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001014 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1015 return;
1016 if (snd_BUG_ON(!spec->adc_nids))
1017 return;
1018
1019 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1020
Wu Fengguang864f92b2009-11-18 12:38:02 +08001021 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001022 if (present) {
1023 alive = &spec->ext_mic;
1024 dead = &spec->int_mic;
1025 } else {
1026 alive = &spec->int_mic;
1027 dead = &spec->ext_mic;
1028 }
1029
Takashi Iwai6c819492009-08-10 18:47:44 +02001030 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1031 if (type == AC_WID_AUD_MIX) {
1032 /* Matrix-mixer style (e.g. ALC882) */
1033 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1034 alive->mux_idx,
1035 HDA_AMP_MUTE, 0);
1036 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1037 dead->mux_idx,
1038 HDA_AMP_MUTE, HDA_AMP_MUTE);
1039 } else {
1040 /* MUX style (e.g. ALC880) */
1041 snd_hda_codec_write_cache(codec, cap_nid, 0,
1042 AC_VERB_SET_CONNECT_SEL,
1043 alive->mux_idx);
1044 }
1045
1046 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001047}
1048
Kailang Yangc9b58002007-10-16 14:30:01 +02001049/* unsolicited event for HP jack sensing */
1050static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1051{
1052 if (codec->vendor_id == 0x10ec0880)
1053 res >>= 28;
1054 else
1055 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001056 switch (res) {
1057 case ALC880_HP_EVENT:
1058 alc_automute_pin(codec);
1059 break;
1060 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001061 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001062 break;
1063 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001064}
1065
1066static void alc_inithook(struct hda_codec *codec)
1067{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001068 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001069 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001070}
1071
Kailang Yangf9423e72008-05-27 12:32:25 +02001072/* additional initialization for ALC888 variants */
1073static void alc888_coef_init(struct hda_codec *codec)
1074{
1075 unsigned int tmp;
1076
1077 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1078 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1079 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001080 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001081 /* alc888S-VC */
1082 snd_hda_codec_read(codec, 0x20, 0,
1083 AC_VERB_SET_PROC_COEF, 0x830);
1084 else
1085 /* alc888-VB */
1086 snd_hda_codec_read(codec, 0x20, 0,
1087 AC_VERB_SET_PROC_COEF, 0x3030);
1088}
1089
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001090static void alc889_coef_init(struct hda_codec *codec)
1091{
1092 unsigned int tmp;
1093
1094 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1095 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1096 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1097 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1098}
1099
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001100/* turn on/off EAPD control (only if available) */
1101static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1102{
1103 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1104 return;
1105 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1106 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1107 on ? 2 : 0);
1108}
1109
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001110static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001111{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001112 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001113
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001114 switch (type) {
1115 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001116 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1117 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001118 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001119 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1120 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001121 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001122 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1123 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001124 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001125 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001126 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001127 set_eapd(codec, 0x0f, 1);
1128 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001129 break;
1130 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001131 case 0x10ec0267:
1132 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001133 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001134 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001135 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001136 case 0x10ec0660:
1137 case 0x10ec0662:
1138 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001139 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001140 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001141 set_eapd(codec, 0x14, 1);
1142 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001143 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001144 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001145 switch (codec->vendor_id) {
1146 case 0x10ec0260:
1147 snd_hda_codec_write(codec, 0x1a, 0,
1148 AC_VERB_SET_COEF_INDEX, 7);
1149 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1150 AC_VERB_GET_PROC_COEF, 0);
1151 snd_hda_codec_write(codec, 0x1a, 0,
1152 AC_VERB_SET_COEF_INDEX, 7);
1153 snd_hda_codec_write(codec, 0x1a, 0,
1154 AC_VERB_SET_PROC_COEF,
1155 tmp | 0x2010);
1156 break;
1157 case 0x10ec0262:
1158 case 0x10ec0880:
1159 case 0x10ec0882:
1160 case 0x10ec0883:
1161 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001162 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001163 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001164 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001165 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001166 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001167 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001168 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001169#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001170 case 0x10ec0267:
1171 case 0x10ec0268:
1172 snd_hda_codec_write(codec, 0x20, 0,
1173 AC_VERB_SET_COEF_INDEX, 7);
1174 tmp = snd_hda_codec_read(codec, 0x20, 0,
1175 AC_VERB_GET_PROC_COEF, 0);
1176 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001177 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001178 snd_hda_codec_write(codec, 0x20, 0,
1179 AC_VERB_SET_PROC_COEF,
1180 tmp | 0x3000);
1181 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001182#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001183 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001184 break;
1185 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001186}
Kailang Yangea1fb292008-08-26 12:58:38 +02001187
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001188static void alc_init_auto_hp(struct hda_codec *codec)
1189{
1190 struct alc_spec *spec = codec->spec;
1191
1192 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001193 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001194
Kailang Yangc9b58002007-10-16 14:30:01 +02001195 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001196 if (spec->autocfg.line_out_pins[0] &&
1197 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001198 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001199 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001200 else
1201 return;
1202 }
1203
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001204 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1205 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001206 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1207 AC_VERB_SET_UNSOLICITED_ENABLE,
1208 AC_USRSP_EN | ALC880_HP_EVENT);
1209 spec->unsol_event = alc_sku_unsol_event;
1210}
1211
Takashi Iwai6c819492009-08-10 18:47:44 +02001212static void alc_init_auto_mic(struct hda_codec *codec)
1213{
1214 struct alc_spec *spec = codec->spec;
1215 struct auto_pin_cfg *cfg = &spec->autocfg;
1216 hda_nid_t fixed, ext;
1217 int i;
1218
1219 /* there must be only two mic inputs exclusively */
1220 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1221 if (cfg->input_pins[i])
1222 return;
1223
1224 fixed = ext = 0;
1225 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1226 hda_nid_t nid = cfg->input_pins[i];
1227 unsigned int defcfg;
1228 if (!nid)
1229 return;
1230 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1231 switch (get_defcfg_connect(defcfg)) {
1232 case AC_JACK_PORT_FIXED:
1233 if (fixed)
1234 return; /* already occupied */
1235 fixed = nid;
1236 break;
1237 case AC_JACK_PORT_COMPLEX:
1238 if (ext)
1239 return; /* already occupied */
1240 ext = nid;
1241 break;
1242 default:
1243 return; /* invalid entry */
1244 }
1245 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001246 if (!ext || !fixed)
1247 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001248 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1249 return; /* no unsol support */
1250 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1251 ext, fixed);
1252 spec->ext_mic.pin = ext;
1253 spec->int_mic.pin = fixed;
1254 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1255 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1256 spec->auto_mic = 1;
1257 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1258 AC_VERB_SET_UNSOLICITED_ENABLE,
1259 AC_USRSP_EN | ALC880_MIC_EVENT);
1260 spec->unsol_event = alc_sku_unsol_event;
1261}
1262
Kailang Yangda00c242010-03-19 11:23:45 +01001263static int alc_auto_parse_customize_define(struct hda_codec *codec)
1264{
1265 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001266 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001267 struct alc_spec *spec = codec->spec;
1268
1269 ass = codec->subsystem_id & 0xffff;
1270 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
1271 goto do_sku;
1272
1273 nid = 0x1d;
1274 if (codec->vendor_id == 0x10ec0260)
1275 nid = 0x17;
1276 ass = snd_hda_codec_get_pincfg(codec, nid);
1277
1278 if (!(ass & 1)) {
1279 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1280 codec->chip_name, ass);
1281 return -1;
1282 }
1283
1284 /* check sum */
1285 tmp = 0;
1286 for (i = 1; i < 16; i++) {
1287 if ((ass >> i) & 1)
1288 tmp++;
1289 }
1290 if (((ass >> 16) & 0xf) != tmp)
1291 return -1;
1292
1293 spec->cdefine.port_connectivity = ass >> 30;
1294 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1295 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1296 spec->cdefine.customization = ass >> 8;
1297do_sku:
1298 spec->cdefine.sku_cfg = ass;
1299 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1300 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1301 spec->cdefine.swap = (ass & 0x2) >> 1;
1302 spec->cdefine.override = ass & 0x1;
1303
1304 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1305 nid, spec->cdefine.sku_cfg);
1306 snd_printd("SKU: port_connectivity=0x%x\n",
1307 spec->cdefine.port_connectivity);
1308 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1309 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1310 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1311 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1312 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1313 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1314 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1315
1316 return 0;
1317}
1318
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001319/* check subsystem ID and set up device-specific initialization;
1320 * return 1 if initialized, 0 if invalid SSID
1321 */
1322/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1323 * 31 ~ 16 : Manufacture ID
1324 * 15 ~ 8 : SKU ID
1325 * 7 ~ 0 : Assembly ID
1326 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1327 */
1328static int alc_subsystem_id(struct hda_codec *codec,
1329 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001330 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001331{
1332 unsigned int ass, tmp, i;
1333 unsigned nid;
1334 struct alc_spec *spec = codec->spec;
1335
1336 ass = codec->subsystem_id & 0xffff;
1337 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1338 goto do_sku;
1339
1340 /* invalid SSID, check the special NID pin defcfg instead */
1341 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001342 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001343 * 29~21 : reserve
1344 * 20 : PCBEEP input
1345 * 19~16 : Check sum (15:1)
1346 * 15~1 : Custom
1347 * 0 : override
1348 */
1349 nid = 0x1d;
1350 if (codec->vendor_id == 0x10ec0260)
1351 nid = 0x17;
1352 ass = snd_hda_codec_get_pincfg(codec, nid);
1353 snd_printd("realtek: No valid SSID, "
1354 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001355 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001356 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001357 return 0;
1358 if ((ass >> 30) != 1) /* no physical connection */
1359 return 0;
1360
1361 /* check sum */
1362 tmp = 0;
1363 for (i = 1; i < 16; i++) {
1364 if ((ass >> i) & 1)
1365 tmp++;
1366 }
1367 if (((ass >> 16) & 0xf) != tmp)
1368 return 0;
1369do_sku:
1370 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1371 ass & 0xffff, codec->vendor_id);
1372 /*
1373 * 0 : override
1374 * 1 : Swap Jack
1375 * 2 : 0 --> Desktop, 1 --> Laptop
1376 * 3~5 : External Amplifier control
1377 * 7~6 : Reserved
1378 */
1379 tmp = (ass & 0x38) >> 3; /* external Amp control */
1380 switch (tmp) {
1381 case 1:
1382 spec->init_amp = ALC_INIT_GPIO1;
1383 break;
1384 case 3:
1385 spec->init_amp = ALC_INIT_GPIO2;
1386 break;
1387 case 7:
1388 spec->init_amp = ALC_INIT_GPIO3;
1389 break;
1390 case 5:
1391 spec->init_amp = ALC_INIT_DEFAULT;
1392 break;
1393 }
1394
1395 /* is laptop or Desktop and enable the function "Mute internal speaker
1396 * when the external headphone out jack is plugged"
1397 */
1398 if (!(ass & 0x8000))
1399 return 1;
1400 /*
1401 * 10~8 : Jack location
1402 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1403 * 14~13: Resvered
1404 * 15 : 1 --> enable the function "Mute internal speaker
1405 * when the external headphone out jack is plugged"
1406 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001407 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001408 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001409 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1410 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001411 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001412 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001413 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001414 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001415 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001416 else if (tmp == 3)
1417 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001418 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001419 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001420 for (i = 0; i < spec->autocfg.line_outs; i++)
1421 if (spec->autocfg.line_out_pins[i] == nid)
1422 return 1;
1423 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001424 }
1425
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001426 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001427 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001428 return 1;
1429}
Kailang Yangea1fb292008-08-26 12:58:38 +02001430
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001431static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001432 hda_nid_t porta, hda_nid_t porte,
1433 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001434{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001435 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001436 struct alc_spec *spec = codec->spec;
1437 snd_printd("realtek: "
1438 "Enable default setup for auto mode as fallback\n");
1439 spec->init_amp = ALC_INIT_DEFAULT;
1440 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001441 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001442 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001443}
1444
Takashi Iwai41e41f12005-06-08 14:48:49 +02001445/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001446 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001447 */
1448
1449struct alc_pincfg {
1450 hda_nid_t nid;
1451 u32 val;
1452};
1453
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001454struct alc_fixup {
1455 const struct alc_pincfg *pins;
1456 const struct hda_verb *verbs;
1457};
1458
1459static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001460 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001461 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001462{
1463 const struct alc_pincfg *cfg;
1464
1465 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1466 if (!quirk)
1467 return;
1468
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001469 fix += quirk->value;
1470 cfg = fix->pins;
1471 if (cfg) {
1472 for (; cfg->nid; cfg++)
1473 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1474 }
1475 if (fix->verbs)
1476 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001477}
1478
Kailang Yang274693f2009-12-03 10:07:50 +01001479static int alc_read_coef_idx(struct hda_codec *codec,
1480 unsigned int coef_idx)
1481{
1482 unsigned int val;
1483 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1484 coef_idx);
1485 val = snd_hda_codec_read(codec, 0x20, 0,
1486 AC_VERB_GET_PROC_COEF, 0);
1487 return val;
1488}
1489
Takashi Iwaif95474e2007-07-10 00:47:43 +02001490/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001491 * ALC888
1492 */
1493
1494/*
1495 * 2ch mode
1496 */
1497static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1498/* Mic-in jack as mic in */
1499 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1500 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1501/* Line-in jack as Line in */
1502 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1503 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1504/* Line-Out as Front */
1505 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1506 { } /* end */
1507};
1508
1509/*
1510 * 4ch mode
1511 */
1512static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1513/* Mic-in jack as mic in */
1514 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1515 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1516/* Line-in jack as Surround */
1517 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1518 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1519/* Line-Out as Front */
1520 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1521 { } /* end */
1522};
1523
1524/*
1525 * 6ch mode
1526 */
1527static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1528/* Mic-in jack as CLFE */
1529 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1530 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1531/* Line-in jack as Surround */
1532 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1533 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1534/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1535 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1536 { } /* end */
1537};
1538
1539/*
1540 * 8ch mode
1541 */
1542static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1543/* Mic-in jack as CLFE */
1544 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1545 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1546/* Line-in jack as Surround */
1547 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1548 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1549/* Line-Out as Side */
1550 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1551 { } /* end */
1552};
1553
1554static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1555 { 2, alc888_4ST_ch2_intel_init },
1556 { 4, alc888_4ST_ch4_intel_init },
1557 { 6, alc888_4ST_ch6_intel_init },
1558 { 8, alc888_4ST_ch8_intel_init },
1559};
1560
1561/*
1562 * ALC888 Fujitsu Siemens Amillo xa3530
1563 */
1564
1565static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1566/* Front Mic: set to PIN_IN (empty by default) */
1567 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1568/* Connect Internal HP to Front */
1569 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1570 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1571 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1572/* Connect Bass HP to Front */
1573 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1574 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1575 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1576/* Connect Line-Out side jack (SPDIF) to Side */
1577 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1578 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1579 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1580/* Connect Mic jack to CLFE */
1581 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1582 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1583 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1584/* Connect Line-in jack to Surround */
1585 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1586 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1587 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1588/* Connect HP out jack to Front */
1589 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1590 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1591 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1592/* Enable unsolicited event for HP jack and Line-out jack */
1593 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1594 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1595 {}
1596};
1597
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001598static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001599{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001600 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001601 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001602 hda_nid_t nid;
1603 int i;
1604
1605 spec->jack_present = 0;
1606 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1607 nid = spec->autocfg.hp_pins[i];
1608 if (!nid)
1609 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001610 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001611 spec->jack_present = 1;
1612 break;
1613 }
1614 }
1615
1616 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001617 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001618 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1619 nid = spec->autocfg.speaker_pins[i];
1620 if (!nid)
1621 break;
1622 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1623 HDA_AMP_MUTE, mute);
1624 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001625}
1626
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001627static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1628 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001629{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001630 if (codec->vendor_id == 0x10ec0880)
1631 res >>= 28;
1632 else
1633 res >>= 26;
1634 if (res == ALC880_HP_EVENT)
1635 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001636}
1637
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001638static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001639{
1640 struct alc_spec *spec = codec->spec;
1641
1642 spec->autocfg.hp_pins[0] = 0x15;
1643 spec->autocfg.speaker_pins[0] = 0x14;
1644 spec->autocfg.speaker_pins[1] = 0x16;
1645 spec->autocfg.speaker_pins[2] = 0x17;
1646 spec->autocfg.speaker_pins[3] = 0x19;
1647 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001648}
1649
1650static void alc889_intel_init_hook(struct hda_codec *codec)
1651{
1652 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001653 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001654}
1655
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001656static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001657{
1658 struct alc_spec *spec = codec->spec;
1659
1660 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1661 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1662 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1663 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001664}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001665
1666/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001667 * ALC888 Acer Aspire 4930G model
1668 */
1669
1670static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1671/* Front Mic: set to PIN_IN (empty by default) */
1672 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1673/* Unselect Front Mic by default in input mixer 3 */
1674 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001675/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001676 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1677/* Connect Internal HP to front */
1678 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1679 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1680 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1681/* Connect HP out to front */
1682 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1683 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1684 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1685 { }
1686};
1687
Hector Martin3b315d72009-06-02 10:54:19 +02001688/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001689 * ALC888 Acer Aspire 6530G model
1690 */
1691
1692static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1693/* Bias voltage on for external mic port */
1694 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001695/* Front Mic: set to PIN_IN (empty by default) */
1696 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1697/* Unselect Front Mic by default in input mixer 3 */
1698 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001699/* Enable unsolicited event for HP jack */
1700 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1701/* Enable speaker output */
1702 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1704/* Enable headphone output */
1705 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1706 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1707 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1708 { }
1709};
1710
1711/*
Hector Martin018df412009-06-04 00:13:40 +02001712 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001713 */
1714
Hector Martin018df412009-06-04 00:13:40 +02001715static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001716/* Front Mic: set to PIN_IN (empty by default) */
1717 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1718/* Unselect Front Mic by default in input mixer 3 */
1719 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1720/* Enable unsolicited event for HP jack */
1721 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1722/* Connect Internal Front to Front */
1723 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1724 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1725 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1726/* Connect Internal Rear to Rear */
1727 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1728 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1729 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1730/* Connect Internal CLFE to CLFE */
1731 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1732 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1733 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1734/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001735 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001736 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1737 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1738/* Enable all DACs */
1739/* DAC DISABLE/MUTE 1? */
1740/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1741 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1742 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1743/* DAC DISABLE/MUTE 2? */
1744/* some bit here disables the other DACs. Init=0x4900 */
1745 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1746 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001747/* DMIC fix
1748 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1749 * which makes the stereo useless. However, either the mic or the ALC889
1750 * makes the signal become a difference/sum signal instead of standard
1751 * stereo, which is annoying. So instead we flip this bit which makes the
1752 * codec replicate the sum signal to both channels, turning it into a
1753 * normal mono mic.
1754 */
1755/* DMIC_CONTROL? Init value = 0x0001 */
1756 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1757 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001758 { }
1759};
1760
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001761static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001762 /* Front mic only available on one ADC */
1763 {
1764 .num_items = 4,
1765 .items = {
1766 { "Mic", 0x0 },
1767 { "Line", 0x2 },
1768 { "CD", 0x4 },
1769 { "Front Mic", 0xb },
1770 },
1771 },
1772 {
1773 .num_items = 3,
1774 .items = {
1775 { "Mic", 0x0 },
1776 { "Line", 0x2 },
1777 { "CD", 0x4 },
1778 },
1779 }
1780};
1781
Tony Vroond2fd4b02009-06-21 00:40:10 +01001782static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1783 /* Interal mic only available on one ADC */
1784 {
Tony Vroon684a8842009-06-26 09:27:50 +01001785 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001786 .items = {
1787 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001788 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001789 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001790 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001791 { "Int Mic", 0xb },
1792 },
1793 },
1794 {
Tony Vroon684a8842009-06-26 09:27:50 +01001795 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001796 .items = {
1797 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001798 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001799 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001800 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001801 },
1802 }
1803};
1804
Hector Martin018df412009-06-04 00:13:40 +02001805static struct hda_input_mux alc889_capture_sources[3] = {
1806 /* Digital mic only available on first "ADC" */
1807 {
1808 .num_items = 5,
1809 .items = {
1810 { "Mic", 0x0 },
1811 { "Line", 0x2 },
1812 { "CD", 0x4 },
1813 { "Front Mic", 0xb },
1814 { "Input Mix", 0xa },
1815 },
1816 },
1817 {
1818 .num_items = 4,
1819 .items = {
1820 { "Mic", 0x0 },
1821 { "Line", 0x2 },
1822 { "CD", 0x4 },
1823 { "Input Mix", 0xa },
1824 },
1825 },
1826 {
1827 .num_items = 4,
1828 .items = {
1829 { "Mic", 0x0 },
1830 { "Line", 0x2 },
1831 { "CD", 0x4 },
1832 { "Input Mix", 0xa },
1833 },
1834 }
1835};
1836
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001837static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001838 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1839 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1840 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1841 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1842 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1843 HDA_OUTPUT),
1844 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1845 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1846 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1847 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1848 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1849 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1850 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1851 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1852 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1853 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1854 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1855 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001856 { } /* end */
1857};
1858
Hector Martin556eea92009-12-20 22:51:23 +01001859static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1860 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1861 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1862 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1863 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1864 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1865 HDA_OUTPUT),
1866 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1867 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1868 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1869 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1870 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1871 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1872 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1873 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1874 { } /* end */
1875};
1876
1877
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001878static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001879{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001880 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001881
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001882 spec->autocfg.hp_pins[0] = 0x15;
1883 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001884 spec->autocfg.speaker_pins[1] = 0x16;
1885 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001886}
1887
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001888static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001889{
1890 struct alc_spec *spec = codec->spec;
1891
1892 spec->autocfg.hp_pins[0] = 0x15;
1893 spec->autocfg.speaker_pins[0] = 0x14;
1894 spec->autocfg.speaker_pins[1] = 0x16;
1895 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001896}
1897
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001898static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001899{
1900 struct alc_spec *spec = codec->spec;
1901
1902 spec->autocfg.hp_pins[0] = 0x15;
1903 spec->autocfg.speaker_pins[0] = 0x14;
1904 spec->autocfg.speaker_pins[1] = 0x16;
1905 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001906}
1907
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001908/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001909 * ALC880 3-stack model
1910 *
1911 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001912 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1913 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001914 */
1915
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001916static hda_nid_t alc880_dac_nids[4] = {
1917 /* front, rear, clfe, rear_surr */
1918 0x02, 0x05, 0x04, 0x03
1919};
1920
1921static hda_nid_t alc880_adc_nids[3] = {
1922 /* ADC0-2 */
1923 0x07, 0x08, 0x09,
1924};
1925
1926/* The datasheet says the node 0x07 is connected from inputs,
1927 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001928 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001929 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001930static hda_nid_t alc880_adc_nids_alt[2] = {
1931 /* ADC1-2 */
1932 0x08, 0x09,
1933};
1934
1935#define ALC880_DIGOUT_NID 0x06
1936#define ALC880_DIGIN_NID 0x0a
1937
1938static struct hda_input_mux alc880_capture_source = {
1939 .num_items = 4,
1940 .items = {
1941 { "Mic", 0x0 },
1942 { "Front Mic", 0x3 },
1943 { "Line", 0x2 },
1944 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001945 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001946};
1947
1948/* channel source setting (2/6 channel selection for 3-stack) */
1949/* 2ch mode */
1950static struct hda_verb alc880_threestack_ch2_init[] = {
1951 /* set line-in to input, mute it */
1952 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1953 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1954 /* set mic-in to input vref 80%, mute it */
1955 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1956 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001957 { } /* end */
1958};
1959
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001960/* 6ch mode */
1961static struct hda_verb alc880_threestack_ch6_init[] = {
1962 /* set line-in to output, unmute it */
1963 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1964 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1965 /* set mic-in to output, unmute it */
1966 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1967 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1968 { } /* end */
1969};
1970
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001971static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001972 { 2, alc880_threestack_ch2_init },
1973 { 6, alc880_threestack_ch6_init },
1974};
1975
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001976static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001977 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001978 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001979 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001980 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001981 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1982 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001983 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1984 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001985 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1986 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1987 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1988 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1989 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1990 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1991 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1992 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001993 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001994 {
1995 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1996 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001997 .info = alc_ch_mode_info,
1998 .get = alc_ch_mode_get,
1999 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002000 },
2001 { } /* end */
2002};
2003
2004/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002005static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2006 struct snd_ctl_elem_info *uinfo)
2007{
2008 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2009 struct alc_spec *spec = codec->spec;
2010 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002011
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002012 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002013 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2014 HDA_INPUT);
2015 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002016 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002017 return err;
2018}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002019
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002020static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2021 unsigned int size, unsigned int __user *tlv)
2022{
2023 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2024 struct alc_spec *spec = codec->spec;
2025 int err;
2026
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002027 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002028 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2029 HDA_INPUT);
2030 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002031 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002032 return err;
2033}
2034
2035typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2036 struct snd_ctl_elem_value *ucontrol);
2037
2038static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2039 struct snd_ctl_elem_value *ucontrol,
2040 getput_call_t func)
2041{
2042 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2043 struct alc_spec *spec = codec->spec;
2044 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2045 int err;
2046
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002047 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002048 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2049 3, 0, HDA_INPUT);
2050 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002051 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002052 return err;
2053}
2054
2055static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2056 struct snd_ctl_elem_value *ucontrol)
2057{
2058 return alc_cap_getput_caller(kcontrol, ucontrol,
2059 snd_hda_mixer_amp_volume_get);
2060}
2061
2062static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2063 struct snd_ctl_elem_value *ucontrol)
2064{
2065 return alc_cap_getput_caller(kcontrol, ucontrol,
2066 snd_hda_mixer_amp_volume_put);
2067}
2068
2069/* capture mixer elements */
2070#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2071
2072static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2073 struct snd_ctl_elem_value *ucontrol)
2074{
2075 return alc_cap_getput_caller(kcontrol, ucontrol,
2076 snd_hda_mixer_amp_switch_get);
2077}
2078
2079static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2080 struct snd_ctl_elem_value *ucontrol)
2081{
2082 return alc_cap_getput_caller(kcontrol, ucontrol,
2083 snd_hda_mixer_amp_switch_put);
2084}
2085
Takashi Iwaia23b6882009-03-23 15:21:36 +01002086#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002087 { \
2088 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2089 .name = "Capture Switch", \
2090 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2091 .count = num, \
2092 .info = alc_cap_sw_info, \
2093 .get = alc_cap_sw_get, \
2094 .put = alc_cap_sw_put, \
2095 }, \
2096 { \
2097 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2098 .name = "Capture Volume", \
2099 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2100 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2101 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2102 .count = num, \
2103 .info = alc_cap_vol_info, \
2104 .get = alc_cap_vol_get, \
2105 .put = alc_cap_vol_put, \
2106 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002107 }
2108
2109#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002110 { \
2111 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2112 /* .name = "Capture Source", */ \
2113 .name = "Input Source", \
2114 .count = num, \
2115 .info = alc_mux_enum_info, \
2116 .get = alc_mux_enum_get, \
2117 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002118 }
2119
2120#define DEFINE_CAPMIX(num) \
2121static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2122 _DEFINE_CAPMIX(num), \
2123 _DEFINE_CAPSRC(num), \
2124 { } /* end */ \
2125}
2126
2127#define DEFINE_CAPMIX_NOSRC(num) \
2128static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2129 _DEFINE_CAPMIX(num), \
2130 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002131}
2132
2133/* up to three ADCs */
2134DEFINE_CAPMIX(1);
2135DEFINE_CAPMIX(2);
2136DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002137DEFINE_CAPMIX_NOSRC(1);
2138DEFINE_CAPMIX_NOSRC(2);
2139DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002140
2141/*
2142 * ALC880 5-stack model
2143 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002144 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2145 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002146 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2147 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2148 */
2149
2150/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002151static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002152 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002153 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002154 { } /* end */
2155};
2156
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002157/* channel source setting (6/8 channel selection for 5-stack) */
2158/* 6ch mode */
2159static struct hda_verb alc880_fivestack_ch6_init[] = {
2160 /* set line-in to input, mute it */
2161 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2162 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002163 { } /* end */
2164};
2165
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002166/* 8ch mode */
2167static struct hda_verb alc880_fivestack_ch8_init[] = {
2168 /* set line-in to output, unmute it */
2169 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2170 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2171 { } /* end */
2172};
2173
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002174static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002175 { 6, alc880_fivestack_ch6_init },
2176 { 8, alc880_fivestack_ch8_init },
2177};
2178
2179
2180/*
2181 * ALC880 6-stack model
2182 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002183 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2184 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002185 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2186 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2187 */
2188
2189static hda_nid_t alc880_6st_dac_nids[4] = {
2190 /* front, rear, clfe, rear_surr */
2191 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002192};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002193
2194static struct hda_input_mux alc880_6stack_capture_source = {
2195 .num_items = 4,
2196 .items = {
2197 { "Mic", 0x0 },
2198 { "Front Mic", 0x1 },
2199 { "Line", 0x2 },
2200 { "CD", 0x4 },
2201 },
2202};
2203
2204/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002205static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002206 { 8, NULL },
2207};
2208
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002209static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002210 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002211 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002212 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002213 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002214 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2215 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002216 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2217 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002218 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002219 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002220 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2221 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2222 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2223 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2224 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2225 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2226 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2227 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002228 {
2229 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2230 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002231 .info = alc_ch_mode_info,
2232 .get = alc_ch_mode_get,
2233 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002234 },
2235 { } /* end */
2236};
2237
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002238
2239/*
2240 * ALC880 W810 model
2241 *
2242 * W810 has rear IO for:
2243 * Front (DAC 02)
2244 * Surround (DAC 03)
2245 * Center/LFE (DAC 04)
2246 * Digital out (06)
2247 *
2248 * The system also has a pair of internal speakers, and a headphone jack.
2249 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002250 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002251 * There is a variable resistor to control the speaker or headphone
2252 * volume. This is a hardware-only device without a software API.
2253 *
2254 * Plugging headphones in will disable the internal speakers. This is
2255 * implemented in hardware, not via the driver using jack sense. In
2256 * a similar fashion, plugging into the rear socket marked "front" will
2257 * disable both the speakers and headphones.
2258 *
2259 * For input, there's a microphone jack, and an "audio in" jack.
2260 * These may not do anything useful with this driver yet, because I
2261 * haven't setup any initialization verbs for these yet...
2262 */
2263
2264static hda_nid_t alc880_w810_dac_nids[3] = {
2265 /* front, rear/surround, clfe */
2266 0x02, 0x03, 0x04
2267};
2268
2269/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002270static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002271 { 6, NULL }
2272};
2273
2274/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002275static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002276 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002277 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002278 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002279 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002280 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2281 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002282 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2283 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002284 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2285 { } /* end */
2286};
2287
2288
2289/*
2290 * Z710V model
2291 *
2292 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002293 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2294 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002295 */
2296
2297static hda_nid_t alc880_z71v_dac_nids[1] = {
2298 0x02
2299};
2300#define ALC880_Z71V_HP_DAC 0x03
2301
2302/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002303static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002304 { 2, NULL }
2305};
2306
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002307static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002308 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002309 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002310 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002311 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002312 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2313 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2314 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2315 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2316 { } /* end */
2317};
2318
2319
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002320/*
2321 * ALC880 F1734 model
2322 *
2323 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2324 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2325 */
2326
2327static hda_nid_t alc880_f1734_dac_nids[1] = {
2328 0x03
2329};
2330#define ALC880_F1734_HP_DAC 0x02
2331
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002332static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002333 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002334 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002335 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2336 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002337 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2338 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002339 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2340 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002341 { } /* end */
2342};
2343
Takashi Iwai937b4162008-02-11 14:52:36 +01002344static struct hda_input_mux alc880_f1734_capture_source = {
2345 .num_items = 2,
2346 .items = {
2347 { "Mic", 0x1 },
2348 { "CD", 0x4 },
2349 },
2350};
2351
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002352
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002353/*
2354 * ALC880 ASUS model
2355 *
2356 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2357 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2358 * Mic = 0x18, Line = 0x1a
2359 */
2360
2361#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2362#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2363
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002364static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002365 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002366 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002367 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002368 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002369 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2370 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002371 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2372 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002373 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2374 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2375 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2376 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2377 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2378 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002379 {
2380 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2381 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002382 .info = alc_ch_mode_info,
2383 .get = alc_ch_mode_get,
2384 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002385 },
2386 { } /* end */
2387};
2388
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002389/*
2390 * ALC880 ASUS W1V model
2391 *
2392 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2393 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2394 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2395 */
2396
2397/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002398static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002399 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2400 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002401 { } /* end */
2402};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002403
Kailang Yangdf694da2005-12-05 19:42:22 +01002404/* TCL S700 */
2405static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2406 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2407 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2408 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2409 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2410 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2411 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2412 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2413 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2414 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002415 { } /* end */
2416};
2417
Kailang Yangccc656c2006-10-17 12:32:26 +02002418/* Uniwill */
2419static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002420 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2421 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2422 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2423 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002424 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2425 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2426 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2427 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2428 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2429 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2430 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2431 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2432 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2433 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2434 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2435 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002436 {
2437 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2438 .name = "Channel Mode",
2439 .info = alc_ch_mode_info,
2440 .get = alc_ch_mode_get,
2441 .put = alc_ch_mode_put,
2442 },
2443 { } /* end */
2444};
2445
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002446static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2447 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2448 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2449 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2450 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2451 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2452 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2453 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2454 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2455 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2456 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2457 { } /* end */
2458};
2459
Kailang Yangccc656c2006-10-17 12:32:26 +02002460static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002461 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2462 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2463 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2464 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002465 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2466 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2467 { } /* end */
2468};
2469
Linus Torvalds1da177e2005-04-16 15:20:36 -07002470/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002471 * virtual master controls
2472 */
2473
2474/*
2475 * slave controls for virtual master
2476 */
2477static const char *alc_slave_vols[] = {
2478 "Front Playback Volume",
2479 "Surround Playback Volume",
2480 "Center Playback Volume",
2481 "LFE Playback Volume",
2482 "Side Playback Volume",
2483 "Headphone Playback Volume",
2484 "Speaker Playback Volume",
2485 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002486 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002487 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002488 NULL,
2489};
2490
2491static const char *alc_slave_sws[] = {
2492 "Front Playback Switch",
2493 "Surround Playback Switch",
2494 "Center Playback Switch",
2495 "LFE Playback Switch",
2496 "Side Playback Switch",
2497 "Headphone Playback Switch",
2498 "Speaker Playback Switch",
2499 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002500 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002501 "Line-Out Playback Switch",
2502 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002503 NULL,
2504};
2505
2506/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002507 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002508 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002509
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002510#define NID_MAPPING (-1)
2511
2512#define SUBDEV_SPEAKER_ (0 << 6)
2513#define SUBDEV_HP_ (1 << 6)
2514#define SUBDEV_LINE_ (2 << 6)
2515#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2516#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2517#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2518
Takashi Iwai603c4012008-07-30 15:01:44 +02002519static void alc_free_kctls(struct hda_codec *codec);
2520
Takashi Iwai67d634c2009-11-16 15:35:59 +01002521#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002522/* additional beep mixers; the actual parameters are overwritten at build */
2523static struct snd_kcontrol_new alc_beep_mixer[] = {
2524 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002525 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002526 { } /* end */
2527};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002528#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002529
Linus Torvalds1da177e2005-04-16 15:20:36 -07002530static int alc_build_controls(struct hda_codec *codec)
2531{
2532 struct alc_spec *spec = codec->spec;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002533 struct snd_kcontrol *kctl;
2534 struct snd_kcontrol_new *knew;
2535 int i, j, err;
2536 unsigned int u;
2537 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002538
2539 for (i = 0; i < spec->num_mixers; i++) {
2540 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2541 if (err < 0)
2542 return err;
2543 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002544 if (spec->cap_mixer) {
2545 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2546 if (err < 0)
2547 return err;
2548 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002549 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002550 err = snd_hda_create_spdif_out_ctls(codec,
2551 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002552 if (err < 0)
2553 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002554 if (!spec->no_analog) {
2555 err = snd_hda_create_spdif_share_sw(codec,
2556 &spec->multiout);
2557 if (err < 0)
2558 return err;
2559 spec->multiout.share_spdif = 1;
2560 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002561 }
2562 if (spec->dig_in_nid) {
2563 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2564 if (err < 0)
2565 return err;
2566 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002567
Takashi Iwai67d634c2009-11-16 15:35:59 +01002568#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002569 /* create beep controls if needed */
2570 if (spec->beep_amp) {
2571 struct snd_kcontrol_new *knew;
2572 for (knew = alc_beep_mixer; knew->name; knew++) {
2573 struct snd_kcontrol *kctl;
2574 kctl = snd_ctl_new1(knew, codec);
2575 if (!kctl)
2576 return -ENOMEM;
2577 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002578 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002579 if (err < 0)
2580 return err;
2581 }
2582 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002583#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002584
Takashi Iwai2134ea42008-01-10 16:53:55 +01002585 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002586 if (!spec->no_analog &&
2587 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002588 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002589 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002590 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002591 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002592 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002593 if (err < 0)
2594 return err;
2595 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002596 if (!spec->no_analog &&
2597 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002598 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2599 NULL, alc_slave_sws);
2600 if (err < 0)
2601 return err;
2602 }
2603
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002604 /* assign Capture Source enums to NID */
2605 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2606 if (!kctl)
2607 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2608 for (i = 0; kctl && i < kctl->count; i++) {
Takashi Iwaid1409ae2009-12-17 15:01:31 +01002609 hda_nid_t *nids = spec->capsrc_nids;
2610 if (!nids)
2611 nids = spec->adc_nids;
Takashi Iwai21949f02009-12-23 08:31:59 +01002612 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002613 if (err < 0)
2614 return err;
2615 }
2616 if (spec->cap_mixer) {
2617 const char *kname = kctl ? kctl->id.name : NULL;
2618 for (knew = spec->cap_mixer; knew->name; knew++) {
2619 if (kname && strcmp(knew->name, kname) == 0)
2620 continue;
2621 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2622 for (i = 0; kctl && i < kctl->count; i++) {
2623 err = snd_hda_add_nid(codec, kctl, i,
2624 spec->adc_nids[i]);
2625 if (err < 0)
2626 return err;
2627 }
2628 }
2629 }
2630
2631 /* other nid->control mapping */
2632 for (i = 0; i < spec->num_mixers; i++) {
2633 for (knew = spec->mixers[i]; knew->name; knew++) {
2634 if (knew->iface != NID_MAPPING)
2635 continue;
2636 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2637 if (kctl == NULL)
2638 continue;
2639 u = knew->subdevice;
2640 for (j = 0; j < 4; j++, u >>= 8) {
2641 nid = u & 0x3f;
2642 if (nid == 0)
2643 continue;
2644 switch (u & 0xc0) {
2645 case SUBDEV_SPEAKER_:
2646 nid = spec->autocfg.speaker_pins[nid];
2647 break;
2648 case SUBDEV_LINE_:
2649 nid = spec->autocfg.line_out_pins[nid];
2650 break;
2651 case SUBDEV_HP_:
2652 nid = spec->autocfg.hp_pins[nid];
2653 break;
2654 default:
2655 continue;
2656 }
2657 err = snd_hda_add_nid(codec, kctl, 0, nid);
2658 if (err < 0)
2659 return err;
2660 }
2661 u = knew->private_value;
2662 for (j = 0; j < 4; j++, u >>= 8) {
2663 nid = u & 0xff;
2664 if (nid == 0)
2665 continue;
2666 err = snd_hda_add_nid(codec, kctl, 0, nid);
2667 if (err < 0)
2668 return err;
2669 }
2670 }
2671 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01002672
2673 alc_free_kctls(codec); /* no longer needed */
2674
Linus Torvalds1da177e2005-04-16 15:20:36 -07002675 return 0;
2676}
2677
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002678
Linus Torvalds1da177e2005-04-16 15:20:36 -07002679/*
2680 * initialize the codec volumes, etc
2681 */
2682
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002683/*
2684 * generic initialization of ADC, input mixers and output mixers
2685 */
2686static struct hda_verb alc880_volume_init_verbs[] = {
2687 /*
2688 * Unmute ADC0-2 and set the default input to mic-in
2689 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002690 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002691 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002692 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002693 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002694 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002695 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002696
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002697 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2698 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002699 * Note: PASD motherboards uses the Line In 2 as the input for front
2700 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002701 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002702 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002703 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2704 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2705 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2706 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2707 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2708 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2709 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002710
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002711 /*
2712 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002713 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002714 /* set vol=0 to output mixers */
2715 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2716 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2717 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2718 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2719 /* set up input amps for analog loopback */
2720 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002721 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2722 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002723 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2724 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002725 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2726 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002727 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2728 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002729
2730 { }
2731};
2732
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002733/*
2734 * 3-stack pin configuration:
2735 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2736 */
2737static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2738 /*
2739 * preset connection lists of input pins
2740 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2741 */
2742 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2743 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2744 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2745
2746 /*
2747 * Set pin mode and muting
2748 */
2749 /* set front pin widgets 0x14 for output */
2750 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2751 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2752 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2753 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2754 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2755 /* Mic2 (as headphone out) for HP output */
2756 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2757 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2758 /* Line In pin widget for input */
2759 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2760 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2761 /* Line2 (as front mic) pin widget for input and vref at 80% */
2762 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2763 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2764 /* CD pin widget for input */
2765 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2766
2767 { }
2768};
2769
2770/*
2771 * 5-stack pin configuration:
2772 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2773 * line-in/side = 0x1a, f-mic = 0x1b
2774 */
2775static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2776 /*
2777 * preset connection lists of input pins
2778 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2779 */
2780 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2781 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2782
2783 /*
2784 * Set pin mode and muting
2785 */
2786 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002787 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2788 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2789 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2790 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002791 /* unmute pins for output (no gain on this amp) */
2792 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2794 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2795 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2796
Linus Torvalds1da177e2005-04-16 15:20:36 -07002797 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002798 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002799 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2800 /* Mic2 (as headphone out) for HP output */
2801 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002802 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002803 /* Line In pin widget for input */
2804 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2805 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2806 /* Line2 (as front mic) pin widget for input and vref at 80% */
2807 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2808 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2809 /* CD pin widget for input */
2810 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002811
2812 { }
2813};
2814
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002815/*
2816 * W810 pin configuration:
2817 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2818 */
2819static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002820 /* hphone/speaker input selector: front DAC */
2821 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2822
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002823 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2824 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2825 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2826 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2827 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2828 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2829
2830 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002831 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002832
Linus Torvalds1da177e2005-04-16 15:20:36 -07002833 { }
2834};
2835
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002836/*
2837 * Z71V pin configuration:
2838 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2839 */
2840static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002841 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002842 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002843 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002844 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002845
Takashi Iwai16ded522005-06-10 19:58:24 +02002846 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002847 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002848 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002849 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002850
2851 { }
2852};
2853
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002854/*
2855 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002856 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2857 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002858 */
2859static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2860 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2861
Takashi Iwai16ded522005-06-10 19:58:24 +02002862 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002863 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002864 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002865 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002866 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002867 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002868 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002869 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2870
Takashi Iwai16ded522005-06-10 19:58:24 +02002871 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002872 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002873 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002874 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002875 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002876 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002877 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002878 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002879 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002880
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002881 { }
2882};
Takashi Iwai16ded522005-06-10 19:58:24 +02002883
Kailang Yangccc656c2006-10-17 12:32:26 +02002884/*
2885 * Uniwill pin configuration:
2886 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2887 * line = 0x1a
2888 */
2889static struct hda_verb alc880_uniwill_init_verbs[] = {
2890 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2891
2892 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2893 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2894 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2895 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2896 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2897 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2898 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2899 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2900 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2901 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2902 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2903 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2904 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2905 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2906
2907 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2908 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2909 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2910 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2911 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2912 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2913 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2914 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2915 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2916
2917 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2918 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2919
2920 { }
2921};
2922
2923/*
2924* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002925* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002926 */
2927static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2928 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2929
2930 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2931 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2932 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2933 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2934 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2935 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2936 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2937 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2938 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2939 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2940 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2941 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2942
2943 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2944 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2945 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2946 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2947 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2948 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2949
2950 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2951 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2952
2953 { }
2954};
2955
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002956static struct hda_verb alc880_beep_init_verbs[] = {
2957 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2958 { }
2959};
2960
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002961/* auto-toggle front mic */
2962static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2963{
2964 unsigned int present;
2965 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002966
Wu Fengguang864f92b2009-11-18 12:38:02 +08002967 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002968 bits = present ? HDA_AMP_MUTE : 0;
2969 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002970}
2971
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002972static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002973{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002974 struct alc_spec *spec = codec->spec;
2975
2976 spec->autocfg.hp_pins[0] = 0x14;
2977 spec->autocfg.speaker_pins[0] = 0x15;
2978 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002979}
2980
2981static void alc880_uniwill_init_hook(struct hda_codec *codec)
2982{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002983 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002984 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002985}
2986
2987static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2988 unsigned int res)
2989{
2990 /* Looks like the unsol event is incompatible with the standard
2991 * definition. 4bit tag is placed at 28 bit!
2992 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002993 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002994 case ALC880_MIC_EVENT:
2995 alc880_uniwill_mic_automute(codec);
2996 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002997 default:
2998 alc_automute_amp_unsol_event(codec, res);
2999 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003000 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003001}
3002
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003003static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003004{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003005 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003006
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003007 spec->autocfg.hp_pins[0] = 0x14;
3008 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003009}
3010
3011static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3012{
3013 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003014
Kailang Yangccc656c2006-10-17 12:32:26 +02003015 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003016 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3017 present &= HDA_AMP_VOLMASK;
3018 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3019 HDA_AMP_VOLMASK, present);
3020 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3021 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003022}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003023
Kailang Yangccc656c2006-10-17 12:32:26 +02003024static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3025 unsigned int res)
3026{
3027 /* Looks like the unsol event is incompatible with the standard
3028 * definition. 4bit tag is placed at 28 bit!
3029 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003030 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003031 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003032 else
3033 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003034}
3035
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003036/*
3037 * F1734 pin configuration:
3038 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3039 */
3040static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003041 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003042 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3043 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3044 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3045 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3046
3047 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3048 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3049 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3050 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3051
3052 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3053 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003054 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003055 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3056 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3057 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3058 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3059 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3060 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003061
Takashi Iwai937b4162008-02-11 14:52:36 +01003062 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3063 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3064
Takashi Iwai16ded522005-06-10 19:58:24 +02003065 { }
3066};
3067
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003068/*
3069 * ASUS pin configuration:
3070 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3071 */
3072static struct hda_verb alc880_pin_asus_init_verbs[] = {
3073 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3074 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3075 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3076 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3077
3078 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3079 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3080 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3081 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3082 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3083 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3084 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3085 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3086
3087 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3088 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3089 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3090 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3091 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3092 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3093 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3094 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3095 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003096
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003097 { }
3098};
3099
3100/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003101#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3102#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003103#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003104
Kailang Yangdf694da2005-12-05 19:42:22 +01003105/* Clevo m520g init */
3106static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3107 /* headphone output */
3108 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3109 /* line-out */
3110 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3111 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3112 /* Line-in */
3113 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3114 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3115 /* CD */
3116 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3117 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3118 /* Mic1 (rear panel) */
3119 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3120 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3121 /* Mic2 (front panel) */
3122 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3123 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3124 /* headphone */
3125 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3126 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3127 /* change to EAPD mode */
3128 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3129 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3130
3131 { }
3132};
3133
3134static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003135 /* change to EAPD mode */
3136 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3137 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3138
Kailang Yangdf694da2005-12-05 19:42:22 +01003139 /* Headphone output */
3140 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3141 /* Front output*/
3142 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3143 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3144
3145 /* Line In pin widget for input */
3146 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3147 /* CD pin widget for input */
3148 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3149 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3150 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3151
3152 /* change to EAPD mode */
3153 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3154 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3155
3156 { }
3157};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003158
3159/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003160 * LG m1 express dual
3161 *
3162 * Pin assignment:
3163 * Rear Line-In/Out (blue): 0x14
3164 * Build-in Mic-In: 0x15
3165 * Speaker-out: 0x17
3166 * HP-Out (green): 0x1b
3167 * Mic-In/Out (red): 0x19
3168 * SPDIF-Out: 0x1e
3169 */
3170
3171/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3172static hda_nid_t alc880_lg_dac_nids[3] = {
3173 0x05, 0x02, 0x03
3174};
3175
3176/* seems analog CD is not working */
3177static struct hda_input_mux alc880_lg_capture_source = {
3178 .num_items = 3,
3179 .items = {
3180 { "Mic", 0x1 },
3181 { "Line", 0x5 },
3182 { "Internal Mic", 0x6 },
3183 },
3184};
3185
3186/* 2,4,6 channel modes */
3187static struct hda_verb alc880_lg_ch2_init[] = {
3188 /* set line-in and mic-in to input */
3189 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3190 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3191 { }
3192};
3193
3194static struct hda_verb alc880_lg_ch4_init[] = {
3195 /* set line-in to out and mic-in to input */
3196 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3197 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3198 { }
3199};
3200
3201static struct hda_verb alc880_lg_ch6_init[] = {
3202 /* set line-in and mic-in to output */
3203 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3204 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3205 { }
3206};
3207
3208static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3209 { 2, alc880_lg_ch2_init },
3210 { 4, alc880_lg_ch4_init },
3211 { 6, alc880_lg_ch6_init },
3212};
3213
3214static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003215 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3216 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003217 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3218 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3219 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3220 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3221 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3222 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3223 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3224 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3225 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3226 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3227 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3228 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3229 {
3230 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3231 .name = "Channel Mode",
3232 .info = alc_ch_mode_info,
3233 .get = alc_ch_mode_get,
3234 .put = alc_ch_mode_put,
3235 },
3236 { } /* end */
3237};
3238
3239static struct hda_verb alc880_lg_init_verbs[] = {
3240 /* set capture source to mic-in */
3241 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3242 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3243 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3244 /* mute all amp mixer inputs */
3245 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003246 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3247 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003248 /* line-in to input */
3249 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3250 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3251 /* built-in mic */
3252 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3253 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3254 /* speaker-out */
3255 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3256 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3257 /* mic-in to input */
3258 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3259 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3260 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3261 /* HP-out */
3262 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3263 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3264 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3265 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003266 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003267 { }
3268};
3269
3270/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003271static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003272{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003273 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003274
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003275 spec->autocfg.hp_pins[0] = 0x1b;
3276 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003277}
3278
3279/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003280 * LG LW20
3281 *
3282 * Pin assignment:
3283 * Speaker-out: 0x14
3284 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003285 * Built-in Mic-In: 0x19
3286 * Line-In: 0x1b
3287 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003288 * SPDIF-Out: 0x1e
3289 */
3290
Takashi Iwaid6815182006-03-23 16:06:23 +01003291static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003292 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003293 .items = {
3294 { "Mic", 0x0 },
3295 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003296 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003297 },
3298};
3299
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003300#define alc880_lg_lw_modes alc880_threestack_modes
3301
Takashi Iwaid6815182006-03-23 16:06:23 +01003302static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003303 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3304 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3305 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3306 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3307 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3308 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3309 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3310 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3311 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3312 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003313 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3314 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3315 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3316 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003317 {
3318 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3319 .name = "Channel Mode",
3320 .info = alc_ch_mode_info,
3321 .get = alc_ch_mode_get,
3322 .put = alc_ch_mode_put,
3323 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003324 { } /* end */
3325};
3326
3327static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003328 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3329 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3330 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3331
Takashi Iwaid6815182006-03-23 16:06:23 +01003332 /* set capture source to mic-in */
3333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3334 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3335 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003336 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003337 /* speaker-out */
3338 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3339 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3340 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003341 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3342 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3343 /* mic-in to input */
3344 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3345 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3346 /* built-in mic */
3347 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3348 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3349 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003350 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003351 { }
3352};
3353
3354/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003355static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003356{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003357 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003358
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003359 spec->autocfg.hp_pins[0] = 0x1b;
3360 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003361}
3362
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003363static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3364 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3365 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3367 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3368 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3369 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3370 { } /* end */
3371};
3372
3373static struct hda_input_mux alc880_medion_rim_capture_source = {
3374 .num_items = 2,
3375 .items = {
3376 { "Mic", 0x0 },
3377 { "Internal Mic", 0x1 },
3378 },
3379};
3380
3381static struct hda_verb alc880_medion_rim_init_verbs[] = {
3382 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3383
3384 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3385 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3386
3387 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3388 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3389 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3390 /* Mic2 (as headphone out) for HP output */
3391 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3392 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3393 /* Internal Speaker */
3394 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3395 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3396
3397 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3398 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3399
3400 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3401 { }
3402};
3403
3404/* toggle speaker-output according to the hp-jack state */
3405static void alc880_medion_rim_automute(struct hda_codec *codec)
3406{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003407 struct alc_spec *spec = codec->spec;
3408 alc_automute_amp(codec);
3409 /* toggle EAPD */
3410 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003411 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3412 else
3413 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3414}
3415
3416static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3417 unsigned int res)
3418{
3419 /* Looks like the unsol event is incompatible with the standard
3420 * definition. 4bit tag is placed at 28 bit!
3421 */
3422 if ((res >> 28) == ALC880_HP_EVENT)
3423 alc880_medion_rim_automute(codec);
3424}
3425
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003426static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003427{
3428 struct alc_spec *spec = codec->spec;
3429
3430 spec->autocfg.hp_pins[0] = 0x14;
3431 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003432}
3433
Takashi Iwaicb53c622007-08-10 17:21:45 +02003434#ifdef CONFIG_SND_HDA_POWER_SAVE
3435static struct hda_amp_list alc880_loopbacks[] = {
3436 { 0x0b, HDA_INPUT, 0 },
3437 { 0x0b, HDA_INPUT, 1 },
3438 { 0x0b, HDA_INPUT, 2 },
3439 { 0x0b, HDA_INPUT, 3 },
3440 { 0x0b, HDA_INPUT, 4 },
3441 { } /* end */
3442};
3443
3444static struct hda_amp_list alc880_lg_loopbacks[] = {
3445 { 0x0b, HDA_INPUT, 1 },
3446 { 0x0b, HDA_INPUT, 6 },
3447 { 0x0b, HDA_INPUT, 7 },
3448 { } /* end */
3449};
3450#endif
3451
Takashi Iwaid6815182006-03-23 16:06:23 +01003452/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003453 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003454 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003455
Linus Torvalds1da177e2005-04-16 15:20:36 -07003456static int alc_init(struct hda_codec *codec)
3457{
3458 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003459 unsigned int i;
3460
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003461 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003462 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003463
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003464 for (i = 0; i < spec->num_init_verbs; i++)
3465 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003466
3467 if (spec->init_hook)
3468 spec->init_hook(codec);
3469
Takashi Iwaiad358792010-03-30 18:00:59 +02003470#ifdef CONFIG_SND_HDA_POWER_SAVE
3471 if (codec->patch_ops.check_power_status)
3472 codec->patch_ops.check_power_status(codec, 0x01);
3473#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003474 return 0;
3475}
3476
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003477static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3478{
3479 struct alc_spec *spec = codec->spec;
3480
3481 if (spec->unsol_event)
3482 spec->unsol_event(codec, res);
3483}
3484
Takashi Iwaicb53c622007-08-10 17:21:45 +02003485#ifdef CONFIG_SND_HDA_POWER_SAVE
3486static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3487{
3488 struct alc_spec *spec = codec->spec;
3489 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3490}
3491#endif
3492
Linus Torvalds1da177e2005-04-16 15:20:36 -07003493/*
3494 * Analog playback callbacks
3495 */
3496static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3497 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003498 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003499{
3500 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003501 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3502 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003503}
3504
3505static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3506 struct hda_codec *codec,
3507 unsigned int stream_tag,
3508 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003509 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003510{
3511 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003512 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3513 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003514}
3515
3516static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3517 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003518 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003519{
3520 struct alc_spec *spec = codec->spec;
3521 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3522}
3523
3524/*
3525 * Digital out
3526 */
3527static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3528 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003529 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003530{
3531 struct alc_spec *spec = codec->spec;
3532 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3533}
3534
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003535static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3536 struct hda_codec *codec,
3537 unsigned int stream_tag,
3538 unsigned int format,
3539 struct snd_pcm_substream *substream)
3540{
3541 struct alc_spec *spec = codec->spec;
3542 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3543 stream_tag, format, substream);
3544}
3545
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003546static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3547 struct hda_codec *codec,
3548 struct snd_pcm_substream *substream)
3549{
3550 struct alc_spec *spec = codec->spec;
3551 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3552}
3553
Linus Torvalds1da177e2005-04-16 15:20:36 -07003554static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3555 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003556 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003557{
3558 struct alc_spec *spec = codec->spec;
3559 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3560}
3561
3562/*
3563 * Analog capture
3564 */
Takashi Iwai63300792008-01-24 15:31:36 +01003565static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003566 struct hda_codec *codec,
3567 unsigned int stream_tag,
3568 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003569 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003570{
3571 struct alc_spec *spec = codec->spec;
3572
Takashi Iwai63300792008-01-24 15:31:36 +01003573 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003574 stream_tag, 0, format);
3575 return 0;
3576}
3577
Takashi Iwai63300792008-01-24 15:31:36 +01003578static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003579 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003580 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003581{
3582 struct alc_spec *spec = codec->spec;
3583
Takashi Iwai888afa12008-03-18 09:57:50 +01003584 snd_hda_codec_cleanup_stream(codec,
3585 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003586 return 0;
3587}
3588
3589
3590/*
3591 */
3592static struct hda_pcm_stream alc880_pcm_analog_playback = {
3593 .substreams = 1,
3594 .channels_min = 2,
3595 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003596 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003597 .ops = {
3598 .open = alc880_playback_pcm_open,
3599 .prepare = alc880_playback_pcm_prepare,
3600 .cleanup = alc880_playback_pcm_cleanup
3601 },
3602};
3603
3604static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003605 .substreams = 1,
3606 .channels_min = 2,
3607 .channels_max = 2,
3608 /* NID is set in alc_build_pcms */
3609};
3610
3611static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3612 .substreams = 1,
3613 .channels_min = 2,
3614 .channels_max = 2,
3615 /* NID is set in alc_build_pcms */
3616};
3617
3618static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3619 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003620 .channels_min = 2,
3621 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003622 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003623 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003624 .prepare = alc880_alt_capture_pcm_prepare,
3625 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003626 },
3627};
3628
3629static struct hda_pcm_stream alc880_pcm_digital_playback = {
3630 .substreams = 1,
3631 .channels_min = 2,
3632 .channels_max = 2,
3633 /* NID is set in alc_build_pcms */
3634 .ops = {
3635 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003636 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003637 .prepare = alc880_dig_playback_pcm_prepare,
3638 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003639 },
3640};
3641
3642static struct hda_pcm_stream alc880_pcm_digital_capture = {
3643 .substreams = 1,
3644 .channels_min = 2,
3645 .channels_max = 2,
3646 /* NID is set in alc_build_pcms */
3647};
3648
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003649/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003650static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003651 .substreams = 0,
3652 .channels_min = 0,
3653 .channels_max = 0,
3654};
3655
Linus Torvalds1da177e2005-04-16 15:20:36 -07003656static int alc_build_pcms(struct hda_codec *codec)
3657{
3658 struct alc_spec *spec = codec->spec;
3659 struct hda_pcm *info = spec->pcm_rec;
3660 int i;
3661
3662 codec->num_pcms = 1;
3663 codec->pcm_info = info;
3664
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003665 if (spec->no_analog)
3666 goto skip_analog;
3667
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003668 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3669 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003670 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003671
Takashi Iwai4a471b72005-12-07 13:56:29 +01003672 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003673 if (snd_BUG_ON(!spec->multiout.dac_nids))
3674 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003675 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3676 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3677 }
3678 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003679 if (snd_BUG_ON(!spec->adc_nids))
3680 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003681 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3682 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3683 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003684
Takashi Iwai4a471b72005-12-07 13:56:29 +01003685 if (spec->channel_mode) {
3686 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3687 for (i = 0; i < spec->num_channel_mode; i++) {
3688 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3689 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3690 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003691 }
3692 }
3693
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003694 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003695 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003696 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003697 snprintf(spec->stream_name_digital,
3698 sizeof(spec->stream_name_digital),
3699 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003700 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003701 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003702 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003703 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003704 if (spec->dig_out_type)
3705 info->pcm_type = spec->dig_out_type;
3706 else
3707 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003708 if (spec->multiout.dig_out_nid &&
3709 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003710 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3711 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3712 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003713 if (spec->dig_in_nid &&
3714 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003715 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3716 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3717 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003718 /* FIXME: do we need this for all Realtek codec models? */
3719 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003720 }
3721
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003722 if (spec->no_analog)
3723 return 0;
3724
Takashi Iwaie08a0072006-09-07 17:52:14 +02003725 /* If the use of more than one ADC is requested for the current
3726 * model, configure a second analog capture-only PCM.
3727 */
3728 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003729 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3730 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003731 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003732 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003733 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003734 if (spec->alt_dac_nid) {
3735 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3736 *spec->stream_analog_alt_playback;
3737 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3738 spec->alt_dac_nid;
3739 } else {
3740 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3741 alc_pcm_null_stream;
3742 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3743 }
3744 if (spec->num_adc_nids > 1) {
3745 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3746 *spec->stream_analog_alt_capture;
3747 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3748 spec->adc_nids[1];
3749 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3750 spec->num_adc_nids - 1;
3751 } else {
3752 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3753 alc_pcm_null_stream;
3754 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003755 }
3756 }
3757
Linus Torvalds1da177e2005-04-16 15:20:36 -07003758 return 0;
3759}
3760
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003761static inline void alc_shutup(struct hda_codec *codec)
3762{
3763 snd_hda_shutup_pins(codec);
3764}
3765
Takashi Iwai603c4012008-07-30 15:01:44 +02003766static void alc_free_kctls(struct hda_codec *codec)
3767{
3768 struct alc_spec *spec = codec->spec;
3769
3770 if (spec->kctls.list) {
3771 struct snd_kcontrol_new *kctl = spec->kctls.list;
3772 int i;
3773 for (i = 0; i < spec->kctls.used; i++)
3774 kfree(kctl[i].name);
3775 }
3776 snd_array_free(&spec->kctls);
3777}
3778
Linus Torvalds1da177e2005-04-16 15:20:36 -07003779static void alc_free(struct hda_codec *codec)
3780{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003781 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003782
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003783 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003784 return;
3785
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003786 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02003787 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003788 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003789 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003790}
3791
Hector Martinf5de24b2009-12-20 22:51:31 +01003792#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05003793static void alc_power_eapd(struct hda_codec *codec)
3794{
3795 /* We currently only handle front, HP */
3796 switch (codec->vendor_id) {
3797 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003798 set_eapd(codec, 0x0f, 0);
3799 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003800 break;
3801 case 0x10ec0262:
3802 case 0x10ec0267:
3803 case 0x10ec0268:
3804 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003805 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05003806 case 0x10ec0272:
3807 case 0x10ec0660:
3808 case 0x10ec0662:
3809 case 0x10ec0663:
3810 case 0x10ec0862:
3811 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003812 set_eapd(codec, 0x14, 0);
3813 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003814 break;
3815 }
3816}
3817
Hector Martinf5de24b2009-12-20 22:51:31 +01003818static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3819{
3820 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003821 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003822 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05003823 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003824 return 0;
3825}
3826#endif
3827
Takashi Iwaie044c392008-10-27 16:56:24 +01003828#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003829static int alc_resume(struct hda_codec *codec)
3830{
Takashi Iwaie044c392008-10-27 16:56:24 +01003831 codec->patch_ops.init(codec);
3832 snd_hda_codec_resume_amp(codec);
3833 snd_hda_codec_resume_cache(codec);
Takashi Iwaiad358792010-03-30 18:00:59 +02003834#ifdef CONFIG_SND_HDA_POWER_SAVE
3835 if (codec->patch_ops.check_power_status)
3836 codec->patch_ops.check_power_status(codec, 0x01);
3837#endif
Takashi Iwaie044c392008-10-27 16:56:24 +01003838 return 0;
3839}
Takashi Iwaie044c392008-10-27 16:56:24 +01003840#endif
3841
Linus Torvalds1da177e2005-04-16 15:20:36 -07003842/*
3843 */
3844static struct hda_codec_ops alc_patch_ops = {
3845 .build_controls = alc_build_controls,
3846 .build_pcms = alc_build_pcms,
3847 .init = alc_init,
3848 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003849 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003850#ifdef SND_HDA_NEEDS_RESUME
3851 .resume = alc_resume,
3852#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003853#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01003854 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003855 .check_power_status = alc_check_power_status,
3856#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05003857 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003858};
3859
Kailang Yangc027ddc2010-03-19 11:33:06 +01003860/* replace the codec chip_name with the given string */
3861static int alc_codec_rename(struct hda_codec *codec, const char *name)
3862{
3863 kfree(codec->chip_name);
3864 codec->chip_name = kstrdup(name, GFP_KERNEL);
3865 if (!codec->chip_name) {
3866 alc_free(codec);
3867 return -ENOMEM;
3868 }
3869 return 0;
3870}
3871
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003872/*
3873 * Test configuration for debugging
3874 *
3875 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3876 * enum controls.
3877 */
3878#ifdef CONFIG_SND_DEBUG
3879static hda_nid_t alc880_test_dac_nids[4] = {
3880 0x02, 0x03, 0x04, 0x05
3881};
3882
3883static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003884 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003885 .items = {
3886 { "In-1", 0x0 },
3887 { "In-2", 0x1 },
3888 { "In-3", 0x2 },
3889 { "In-4", 0x3 },
3890 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003891 { "Front", 0x5 },
3892 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003893 },
3894};
3895
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003896static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003897 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003898 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003899 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003900 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003901};
3902
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003903static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3904 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003905{
3906 static char *texts[] = {
3907 "N/A", "Line Out", "HP Out",
3908 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3909 };
3910 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3911 uinfo->count = 1;
3912 uinfo->value.enumerated.items = 8;
3913 if (uinfo->value.enumerated.item >= 8)
3914 uinfo->value.enumerated.item = 7;
3915 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3916 return 0;
3917}
3918
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003919static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3920 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003921{
3922 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3923 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3924 unsigned int pin_ctl, item = 0;
3925
3926 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3927 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3928 if (pin_ctl & AC_PINCTL_OUT_EN) {
3929 if (pin_ctl & AC_PINCTL_HP_EN)
3930 item = 2;
3931 else
3932 item = 1;
3933 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3934 switch (pin_ctl & AC_PINCTL_VREFEN) {
3935 case AC_PINCTL_VREF_HIZ: item = 3; break;
3936 case AC_PINCTL_VREF_50: item = 4; break;
3937 case AC_PINCTL_VREF_GRD: item = 5; break;
3938 case AC_PINCTL_VREF_80: item = 6; break;
3939 case AC_PINCTL_VREF_100: item = 7; break;
3940 }
3941 }
3942 ucontrol->value.enumerated.item[0] = item;
3943 return 0;
3944}
3945
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003946static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3947 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003948{
3949 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3950 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3951 static unsigned int ctls[] = {
3952 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3953 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3954 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3955 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3956 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3957 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3958 };
3959 unsigned int old_ctl, new_ctl;
3960
3961 old_ctl = snd_hda_codec_read(codec, nid, 0,
3962 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3963 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3964 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003965 int val;
3966 snd_hda_codec_write_cache(codec, nid, 0,
3967 AC_VERB_SET_PIN_WIDGET_CONTROL,
3968 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003969 val = ucontrol->value.enumerated.item[0] >= 3 ?
3970 HDA_AMP_MUTE : 0;
3971 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3972 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003973 return 1;
3974 }
3975 return 0;
3976}
3977
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003978static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3979 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003980{
3981 static char *texts[] = {
3982 "Front", "Surround", "CLFE", "Side"
3983 };
3984 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3985 uinfo->count = 1;
3986 uinfo->value.enumerated.items = 4;
3987 if (uinfo->value.enumerated.item >= 4)
3988 uinfo->value.enumerated.item = 3;
3989 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3990 return 0;
3991}
3992
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003993static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3994 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003995{
3996 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3997 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3998 unsigned int sel;
3999
4000 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4001 ucontrol->value.enumerated.item[0] = sel & 3;
4002 return 0;
4003}
4004
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004005static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4006 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004007{
4008 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4009 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4010 unsigned int sel;
4011
4012 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4013 if (ucontrol->value.enumerated.item[0] != sel) {
4014 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004015 snd_hda_codec_write_cache(codec, nid, 0,
4016 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004017 return 1;
4018 }
4019 return 0;
4020}
4021
4022#define PIN_CTL_TEST(xname,nid) { \
4023 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4024 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004025 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004026 .info = alc_test_pin_ctl_info, \
4027 .get = alc_test_pin_ctl_get, \
4028 .put = alc_test_pin_ctl_put, \
4029 .private_value = nid \
4030 }
4031
4032#define PIN_SRC_TEST(xname,nid) { \
4033 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4034 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004035 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004036 .info = alc_test_pin_src_info, \
4037 .get = alc_test_pin_src_get, \
4038 .put = alc_test_pin_src_put, \
4039 .private_value = nid \
4040 }
4041
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004042static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004043 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4044 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4045 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4046 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004047 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4048 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4049 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4050 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004051 PIN_CTL_TEST("Front Pin Mode", 0x14),
4052 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4053 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4054 PIN_CTL_TEST("Side Pin Mode", 0x17),
4055 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4056 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4057 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4058 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4059 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4060 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4061 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4062 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4063 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4064 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4065 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4066 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4067 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4068 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4069 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4070 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4071 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4072 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004073 {
4074 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4075 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004076 .info = alc_ch_mode_info,
4077 .get = alc_ch_mode_get,
4078 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004079 },
4080 { } /* end */
4081};
4082
4083static struct hda_verb alc880_test_init_verbs[] = {
4084 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004085 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4086 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4087 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4088 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4089 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4090 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4091 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4092 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004093 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004094 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4095 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4096 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4097 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004098 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004099 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4100 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4101 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4102 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004103 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004104 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4105 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4106 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4107 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004108 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004109 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4110 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004111 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4112 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4113 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004114 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004115 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4116 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4117 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4118 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004119 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004120 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004121 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004122 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004123 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004124 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004125 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004126 /* Analog input/passthru */
4127 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004132 { }
4133};
4134#endif
4135
Linus Torvalds1da177e2005-04-16 15:20:36 -07004136/*
4137 */
4138
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004139static const char *alc880_models[ALC880_MODEL_LAST] = {
4140 [ALC880_3ST] = "3stack",
4141 [ALC880_TCL_S700] = "tcl",
4142 [ALC880_3ST_DIG] = "3stack-digout",
4143 [ALC880_CLEVO] = "clevo",
4144 [ALC880_5ST] = "5stack",
4145 [ALC880_5ST_DIG] = "5stack-digout",
4146 [ALC880_W810] = "w810",
4147 [ALC880_Z71V] = "z71v",
4148 [ALC880_6ST] = "6stack",
4149 [ALC880_6ST_DIG] = "6stack-digout",
4150 [ALC880_ASUS] = "asus",
4151 [ALC880_ASUS_W1V] = "asus-w1v",
4152 [ALC880_ASUS_DIG] = "asus-dig",
4153 [ALC880_ASUS_DIG2] = "asus-dig2",
4154 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004155 [ALC880_UNIWILL_P53] = "uniwill-p53",
4156 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004157 [ALC880_F1734] = "F1734",
4158 [ALC880_LG] = "lg",
4159 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004160 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004161#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004162 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004163#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004164 [ALC880_AUTO] = "auto",
4165};
4166
4167static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004168 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004169 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4170 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4171 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4172 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4173 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4174 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4175 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4176 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004177 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4178 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004179 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4180 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4181 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4182 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4183 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4184 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4185 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4186 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4187 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4188 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004189 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004190 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4191 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4192 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004193 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004194 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004195 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4196 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004197 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4198 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004199 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4200 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4201 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4202 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004203 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4204 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004205 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004206 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004207 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004208 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004209 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4210 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004211 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004212 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004213 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004214 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004215 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004216 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004217 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004218 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004219 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004220 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4221 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004222 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004223 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4224 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4225 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4226 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004227 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4228 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004229 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004230 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004231 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4232 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004233 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4234 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4235 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004236 /* default Intel */
4237 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004238 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4239 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004240 {}
4241};
4242
Takashi Iwai16ded522005-06-10 19:58:24 +02004243/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004244 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004245 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004246static struct alc_config_preset alc880_presets[] = {
4247 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004248 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004249 .init_verbs = { alc880_volume_init_verbs,
4250 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004251 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004252 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004253 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4254 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004255 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004256 .input_mux = &alc880_capture_source,
4257 },
4258 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004259 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004260 .init_verbs = { alc880_volume_init_verbs,
4261 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004262 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004263 .dac_nids = alc880_dac_nids,
4264 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004265 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4266 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004267 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004268 .input_mux = &alc880_capture_source,
4269 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004270 [ALC880_TCL_S700] = {
4271 .mixers = { alc880_tcl_s700_mixer },
4272 .init_verbs = { alc880_volume_init_verbs,
4273 alc880_pin_tcl_S700_init_verbs,
4274 alc880_gpio2_init_verbs },
4275 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4276 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004277 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4278 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004279 .hp_nid = 0x03,
4280 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4281 .channel_mode = alc880_2_jack_modes,
4282 .input_mux = &alc880_capture_source,
4283 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004284 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004285 .mixers = { alc880_three_stack_mixer,
4286 alc880_five_stack_mixer},
4287 .init_verbs = { alc880_volume_init_verbs,
4288 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004289 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4290 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004291 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4292 .channel_mode = alc880_fivestack_modes,
4293 .input_mux = &alc880_capture_source,
4294 },
4295 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004296 .mixers = { alc880_three_stack_mixer,
4297 alc880_five_stack_mixer },
4298 .init_verbs = { alc880_volume_init_verbs,
4299 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004300 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4301 .dac_nids = alc880_dac_nids,
4302 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004303 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4304 .channel_mode = alc880_fivestack_modes,
4305 .input_mux = &alc880_capture_source,
4306 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004307 [ALC880_6ST] = {
4308 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004309 .init_verbs = { alc880_volume_init_verbs,
4310 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004311 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4312 .dac_nids = alc880_6st_dac_nids,
4313 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4314 .channel_mode = alc880_sixstack_modes,
4315 .input_mux = &alc880_6stack_capture_source,
4316 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004317 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004318 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004319 .init_verbs = { alc880_volume_init_verbs,
4320 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004321 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4322 .dac_nids = alc880_6st_dac_nids,
4323 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004324 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4325 .channel_mode = alc880_sixstack_modes,
4326 .input_mux = &alc880_6stack_capture_source,
4327 },
4328 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004329 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004330 .init_verbs = { alc880_volume_init_verbs,
4331 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004332 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004333 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4334 .dac_nids = alc880_w810_dac_nids,
4335 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004336 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4337 .channel_mode = alc880_w810_modes,
4338 .input_mux = &alc880_capture_source,
4339 },
4340 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004341 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004342 .init_verbs = { alc880_volume_init_verbs,
4343 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004344 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4345 .dac_nids = alc880_z71v_dac_nids,
4346 .dig_out_nid = ALC880_DIGOUT_NID,
4347 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004348 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4349 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004350 .input_mux = &alc880_capture_source,
4351 },
4352 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004353 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004354 .init_verbs = { alc880_volume_init_verbs,
4355 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004356 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4357 .dac_nids = alc880_f1734_dac_nids,
4358 .hp_nid = 0x02,
4359 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4360 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004361 .input_mux = &alc880_f1734_capture_source,
4362 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004363 .setup = alc880_uniwill_p53_setup,
4364 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004365 },
4366 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004367 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004368 .init_verbs = { alc880_volume_init_verbs,
4369 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004370 alc880_gpio1_init_verbs },
4371 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4372 .dac_nids = alc880_asus_dac_nids,
4373 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4374 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004375 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004376 .input_mux = &alc880_capture_source,
4377 },
4378 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004379 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004380 .init_verbs = { alc880_volume_init_verbs,
4381 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004382 alc880_gpio1_init_verbs },
4383 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4384 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004385 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004386 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4387 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004388 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004389 .input_mux = &alc880_capture_source,
4390 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004391 [ALC880_ASUS_DIG2] = {
4392 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004393 .init_verbs = { alc880_volume_init_verbs,
4394 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004395 alc880_gpio2_init_verbs }, /* use GPIO2 */
4396 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4397 .dac_nids = alc880_asus_dac_nids,
4398 .dig_out_nid = ALC880_DIGOUT_NID,
4399 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4400 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004401 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004402 .input_mux = &alc880_capture_source,
4403 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004404 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004405 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004406 .init_verbs = { alc880_volume_init_verbs,
4407 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004408 alc880_gpio1_init_verbs },
4409 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4410 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004411 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004412 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4413 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004414 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004415 .input_mux = &alc880_capture_source,
4416 },
4417 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004418 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004419 .init_verbs = { alc880_volume_init_verbs,
4420 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004421 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4422 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004423 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004424 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4425 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004426 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004427 .input_mux = &alc880_capture_source,
4428 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004429 [ALC880_UNIWILL] = {
4430 .mixers = { alc880_uniwill_mixer },
4431 .init_verbs = { alc880_volume_init_verbs,
4432 alc880_uniwill_init_verbs },
4433 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4434 .dac_nids = alc880_asus_dac_nids,
4435 .dig_out_nid = ALC880_DIGOUT_NID,
4436 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4437 .channel_mode = alc880_threestack_modes,
4438 .need_dac_fix = 1,
4439 .input_mux = &alc880_capture_source,
4440 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004441 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004442 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004443 },
4444 [ALC880_UNIWILL_P53] = {
4445 .mixers = { alc880_uniwill_p53_mixer },
4446 .init_verbs = { alc880_volume_init_verbs,
4447 alc880_uniwill_p53_init_verbs },
4448 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4449 .dac_nids = alc880_asus_dac_nids,
4450 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004451 .channel_mode = alc880_threestack_modes,
4452 .input_mux = &alc880_capture_source,
4453 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004454 .setup = alc880_uniwill_p53_setup,
4455 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004456 },
4457 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004458 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004459 .init_verbs = { alc880_volume_init_verbs,
4460 alc880_uniwill_p53_init_verbs,
4461 alc880_beep_init_verbs },
4462 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4463 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004464 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004465 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4466 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004467 .input_mux = &alc880_capture_source,
4468 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004469 .setup = alc880_uniwill_p53_setup,
4470 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004471 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004472 [ALC880_CLEVO] = {
4473 .mixers = { alc880_three_stack_mixer },
4474 .init_verbs = { alc880_volume_init_verbs,
4475 alc880_pin_clevo_init_verbs },
4476 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4477 .dac_nids = alc880_dac_nids,
4478 .hp_nid = 0x03,
4479 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4480 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004481 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004482 .input_mux = &alc880_capture_source,
4483 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004484 [ALC880_LG] = {
4485 .mixers = { alc880_lg_mixer },
4486 .init_verbs = { alc880_volume_init_verbs,
4487 alc880_lg_init_verbs },
4488 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4489 .dac_nids = alc880_lg_dac_nids,
4490 .dig_out_nid = ALC880_DIGOUT_NID,
4491 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4492 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004493 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004494 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004495 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004496 .setup = alc880_lg_setup,
4497 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004498#ifdef CONFIG_SND_HDA_POWER_SAVE
4499 .loopbacks = alc880_lg_loopbacks,
4500#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004501 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004502 [ALC880_LG_LW] = {
4503 .mixers = { alc880_lg_lw_mixer },
4504 .init_verbs = { alc880_volume_init_verbs,
4505 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004506 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004507 .dac_nids = alc880_dac_nids,
4508 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004509 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4510 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004511 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004512 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004513 .setup = alc880_lg_lw_setup,
4514 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004515 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004516 [ALC880_MEDION_RIM] = {
4517 .mixers = { alc880_medion_rim_mixer },
4518 .init_verbs = { alc880_volume_init_verbs,
4519 alc880_medion_rim_init_verbs,
4520 alc_gpio2_init_verbs },
4521 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4522 .dac_nids = alc880_dac_nids,
4523 .dig_out_nid = ALC880_DIGOUT_NID,
4524 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4525 .channel_mode = alc880_2_jack_modes,
4526 .input_mux = &alc880_medion_rim_capture_source,
4527 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004528 .setup = alc880_medion_rim_setup,
4529 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004530 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004531#ifdef CONFIG_SND_DEBUG
4532 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004533 .mixers = { alc880_test_mixer },
4534 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004535 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4536 .dac_nids = alc880_test_dac_nids,
4537 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004538 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4539 .channel_mode = alc880_test_modes,
4540 .input_mux = &alc880_test_capture_source,
4541 },
4542#endif
4543};
4544
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004545/*
4546 * Automatic parse of I/O pins from the BIOS configuration
4547 */
4548
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004549enum {
4550 ALC_CTL_WIDGET_VOL,
4551 ALC_CTL_WIDGET_MUTE,
4552 ALC_CTL_BIND_MUTE,
4553};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004554static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004555 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4556 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004557 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004558};
4559
4560/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004561static int add_control(struct alc_spec *spec, int type, const char *name,
4562 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004563{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004564 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004565
Takashi Iwai603c4012008-07-30 15:01:44 +02004566 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4567 knew = snd_array_new(&spec->kctls);
4568 if (!knew)
4569 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004570 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004571 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004572 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004573 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004574 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004575 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004576 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004577 return 0;
4578}
4579
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004580static int add_control_with_pfx(struct alc_spec *spec, int type,
4581 const char *pfx, const char *dir,
4582 const char *sfx, unsigned long val)
4583{
4584 char name[32];
4585 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4586 return add_control(spec, type, name, val);
4587}
4588
4589#define add_pb_vol_ctrl(spec, type, pfx, val) \
4590 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4591#define add_pb_sw_ctrl(spec, type, pfx, val) \
4592 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4593
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004594#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4595#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4596#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4597#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004598#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4599#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4600#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4601#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4602#define ALC880_PIN_CD_NID 0x1c
4603
4604/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004605static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4606 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004607{
4608 hda_nid_t nid;
4609 int assigned[4];
4610 int i, j;
4611
4612 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004613 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004614
4615 /* check the pins hardwired to audio widget */
4616 for (i = 0; i < cfg->line_outs; i++) {
4617 nid = cfg->line_out_pins[i];
4618 if (alc880_is_fixed_pin(nid)) {
4619 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004620 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004621 assigned[idx] = 1;
4622 }
4623 }
4624 /* left pins can be connect to any audio widget */
4625 for (i = 0; i < cfg->line_outs; i++) {
4626 nid = cfg->line_out_pins[i];
4627 if (alc880_is_fixed_pin(nid))
4628 continue;
4629 /* search for an empty channel */
4630 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004631 if (!assigned[j]) {
4632 spec->multiout.dac_nids[i] =
4633 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004634 assigned[j] = 1;
4635 break;
4636 }
4637 }
4638 }
4639 spec->multiout.num_dacs = cfg->line_outs;
4640 return 0;
4641}
4642
4643/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004644static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4645 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004646{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004647 static const char *chname[4] = {
4648 "Front", "Surround", NULL /*CLFE*/, "Side"
4649 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004650 hda_nid_t nid;
4651 int i, err;
4652
4653 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004654 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004655 continue;
4656 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4657 if (i == 2) {
4658 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004659 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4660 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004661 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4662 HDA_OUTPUT));
4663 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004664 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004665 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4666 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004667 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4668 HDA_OUTPUT));
4669 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004670 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004671 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4672 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004673 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4674 HDA_INPUT));
4675 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004676 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004677 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4678 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004679 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4680 HDA_INPUT));
4681 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004682 return err;
4683 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004684 const char *pfx;
4685 if (cfg->line_outs == 1 &&
4686 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4687 pfx = "Speaker";
4688 else
4689 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004690 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004691 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4692 HDA_OUTPUT));
4693 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004694 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004695 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004696 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4697 HDA_INPUT));
4698 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004699 return err;
4700 }
4701 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004702 return 0;
4703}
4704
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004705/* add playback controls for speaker and HP outputs */
4706static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4707 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004708{
4709 hda_nid_t nid;
4710 int err;
4711
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004712 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004713 return 0;
4714
4715 if (alc880_is_fixed_pin(pin)) {
4716 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004717 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004718 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004719 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004720 else
4721 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004722 /* control HP volume/switch on the output mixer amp */
4723 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004724 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004725 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4726 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004727 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004728 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004729 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4730 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004731 return err;
4732 } else if (alc880_is_multi_pin(pin)) {
4733 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004734 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004735 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004736 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4737 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004738 return err;
4739 }
4740 return 0;
4741}
4742
4743/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004744static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4745 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004746 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004747{
Kailang Yangdf694da2005-12-05 19:42:22 +01004748 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004749
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004750 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004751 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4752 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004753 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004754 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004755 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4756 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004757 return err;
4758 return 0;
4759}
4760
Takashi Iwai05f5f472009-08-25 13:10:18 +02004761static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004762{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004763 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4764 return (pincap & AC_PINCAP_IN) != 0;
4765}
4766
4767/* create playback/capture controls for input pins */
4768static int alc_auto_create_input_ctls(struct hda_codec *codec,
4769 const struct auto_pin_cfg *cfg,
4770 hda_nid_t mixer,
4771 hda_nid_t cap1, hda_nid_t cap2)
4772{
4773 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004774 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004775 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004776
4777 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004778 hda_nid_t pin;
4779
4780 pin = cfg->input_pins[i];
4781 if (!alc_is_input_pin(codec, pin))
4782 continue;
4783
4784 if (mixer) {
4785 idx = get_connection_index(codec, mixer, pin);
4786 if (idx >= 0) {
4787 err = new_analog_input(spec, pin,
4788 auto_pin_cfg_labels[i],
4789 idx, mixer);
4790 if (err < 0)
4791 return err;
4792 }
4793 }
4794
4795 if (!cap1)
4796 continue;
4797 idx = get_connection_index(codec, cap1, pin);
4798 if (idx < 0 && cap2)
4799 idx = get_connection_index(codec, cap2, pin);
4800 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004801 imux->items[imux->num_items].label =
4802 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004803 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004804 imux->num_items++;
4805 }
4806 }
4807 return 0;
4808}
4809
Takashi Iwai05f5f472009-08-25 13:10:18 +02004810static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4811 const struct auto_pin_cfg *cfg)
4812{
4813 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4814}
4815
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004816static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4817 unsigned int pin_type)
4818{
4819 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4820 pin_type);
4821 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004822 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4823 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004824}
4825
Kailang Yangdf694da2005-12-05 19:42:22 +01004826static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4827 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004828 int dac_idx)
4829{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004830 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004831 /* need the manual connection? */
4832 if (alc880_is_multi_pin(nid)) {
4833 struct alc_spec *spec = codec->spec;
4834 int idx = alc880_multi_pin_idx(nid);
4835 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4836 AC_VERB_SET_CONNECT_SEL,
4837 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4838 }
4839}
4840
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004841static int get_pin_type(int line_out_type)
4842{
4843 if (line_out_type == AUTO_PIN_HP_OUT)
4844 return PIN_HP;
4845 else
4846 return PIN_OUT;
4847}
4848
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004849static void alc880_auto_init_multi_out(struct hda_codec *codec)
4850{
4851 struct alc_spec *spec = codec->spec;
4852 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004853
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004854 for (i = 0; i < spec->autocfg.line_outs; i++) {
4855 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004856 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4857 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004858 }
4859}
4860
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004861static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004862{
4863 struct alc_spec *spec = codec->spec;
4864 hda_nid_t pin;
4865
Takashi Iwai82bc9552006-03-21 11:24:42 +01004866 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004867 if (pin) /* connect to front */
4868 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004869 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004870 if (pin) /* connect to front */
4871 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4872}
4873
4874static void alc880_auto_init_analog_input(struct hda_codec *codec)
4875{
4876 struct alc_spec *spec = codec->spec;
4877 int i;
4878
4879 for (i = 0; i < AUTO_PIN_LAST; i++) {
4880 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004881 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004882 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004883 if (nid != ALC880_PIN_CD_NID &&
4884 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004885 snd_hda_codec_write(codec, nid, 0,
4886 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004887 AMP_OUT_MUTE);
4888 }
4889 }
4890}
4891
4892/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004893/* return 1 if successful, 0 if the proper config is not found,
4894 * or a negative error code
4895 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004896static int alc880_parse_auto_config(struct hda_codec *codec)
4897{
4898 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004899 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004900 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004901
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004902 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4903 alc880_ignore);
4904 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004905 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004906 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004907 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004908
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004909 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4910 if (err < 0)
4911 return err;
4912 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4913 if (err < 0)
4914 return err;
4915 err = alc880_auto_create_extra_out(spec,
4916 spec->autocfg.speaker_pins[0],
4917 "Speaker");
4918 if (err < 0)
4919 return err;
4920 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4921 "Headphone");
4922 if (err < 0)
4923 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004924 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004925 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004926 return err;
4927
4928 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4929
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004930 /* check multiple SPDIF-out (for recent codecs) */
4931 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4932 hda_nid_t dig_nid;
4933 err = snd_hda_get_connections(codec,
4934 spec->autocfg.dig_out_pins[i],
4935 &dig_nid, 1);
4936 if (err < 0)
4937 continue;
4938 if (!i)
4939 spec->multiout.dig_out_nid = dig_nid;
4940 else {
4941 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004942 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004943 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004944 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004945 }
4946 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004947 if (spec->autocfg.dig_in_pin)
4948 spec->dig_in_nid = ALC880_DIGIN_NID;
4949
Takashi Iwai603c4012008-07-30 15:01:44 +02004950 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004951 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004952
Takashi Iwaid88897e2008-10-31 15:01:37 +01004953 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004954
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004955 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004956 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004957
Kailang Yang6227cdc2010-02-25 08:36:52 +01004958 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004959
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004960 return 1;
4961}
4962
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004963/* additional initialization for auto-configuration model */
4964static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004965{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004966 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004967 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004968 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004969 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004970 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004971 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004972}
4973
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004974/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4975 * one of two digital mic pins, e.g. on ALC272
4976 */
4977static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004978{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004979 struct alc_spec *spec = codec->spec;
4980 int i;
4981
4982 for (i = 0; i < spec->num_adc_nids; i++) {
4983 hda_nid_t cap = spec->capsrc_nids ?
4984 spec->capsrc_nids[i] : spec->adc_nids[i];
4985 int iidx, eidx;
4986
4987 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4988 if (iidx < 0)
4989 continue;
4990 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4991 if (eidx < 0)
4992 continue;
4993 spec->int_mic.mux_idx = iidx;
4994 spec->ext_mic.mux_idx = eidx;
4995 if (spec->capsrc_nids)
4996 spec->capsrc_nids += i;
4997 spec->adc_nids += i;
4998 spec->num_adc_nids = 1;
4999 return;
5000 }
5001 snd_printd(KERN_INFO "hda_codec: %s: "
5002 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5003 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5004 spec->auto_mic = 0; /* disable auto-mic to be sure */
5005}
5006
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005007/* choose the ADC/MUX containing the input pin and initialize the setup */
5008static void fixup_single_adc(struct hda_codec *codec)
5009{
5010 struct alc_spec *spec = codec->spec;
Frederik Deweerdtd2db09b2010-03-05 16:34:31 +01005011 hda_nid_t pin = 0;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005012 int i;
5013
5014 /* search for the input pin; there must be only one */
5015 for (i = 0; i < AUTO_PIN_LAST; i++) {
5016 if (spec->autocfg.input_pins[i]) {
5017 pin = spec->autocfg.input_pins[i];
5018 break;
5019 }
5020 }
5021 if (!pin)
5022 return;
5023
5024 /* set the default connection to that pin */
5025 for (i = 0; i < spec->num_adc_nids; i++) {
5026 hda_nid_t cap = spec->capsrc_nids ?
5027 spec->capsrc_nids[i] : spec->adc_nids[i];
5028 int idx;
5029
5030 idx = get_connection_index(codec, cap, pin);
5031 if (idx < 0)
5032 continue;
5033 /* use only this ADC */
5034 if (spec->capsrc_nids)
5035 spec->capsrc_nids += i;
5036 spec->adc_nids += i;
5037 spec->num_adc_nids = 1;
5038 /* select or unmute this route */
5039 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5040 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5041 HDA_AMP_MUTE, 0);
5042 } else {
5043 snd_hda_codec_write_cache(codec, cap, 0,
5044 AC_VERB_SET_CONNECT_SEL, idx);
5045 }
5046 return;
5047 }
5048}
5049
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005050static void set_capture_mixer(struct hda_codec *codec)
5051{
5052 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005053 static struct snd_kcontrol_new *caps[2][3] = {
5054 { alc_capture_mixer_nosrc1,
5055 alc_capture_mixer_nosrc2,
5056 alc_capture_mixer_nosrc3 },
5057 { alc_capture_mixer1,
5058 alc_capture_mixer2,
5059 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005060 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005061 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005062 int mux = 0;
5063 if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005064 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005065 else if (spec->input_mux) {
5066 if (spec->input_mux->num_items > 1)
5067 mux = 1;
5068 else if (spec->input_mux->num_items == 1)
5069 fixup_single_adc(codec);
5070 }
Takashi Iwaia23b6882009-03-23 15:21:36 +01005071 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
5072 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005073}
5074
Takashi Iwai66946352010-03-29 17:21:45 +02005075/* fill adc_nids (and capsrc_nids) containing all active input pins */
5076static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5077 int num_nids)
5078{
5079 struct alc_spec *spec = codec->spec;
5080 int n;
5081 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5082
5083 for (n = 0; n < num_nids; n++) {
5084 hda_nid_t adc, cap;
5085 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5086 int nconns, i, j;
5087
5088 adc = nids[n];
5089 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5090 continue;
5091 cap = adc;
5092 nconns = snd_hda_get_connections(codec, cap, conn,
5093 ARRAY_SIZE(conn));
5094 if (nconns == 1) {
5095 cap = conn[0];
5096 nconns = snd_hda_get_connections(codec, cap, conn,
5097 ARRAY_SIZE(conn));
5098 }
5099 if (nconns <= 0)
5100 continue;
5101 if (!fallback_adc) {
5102 fallback_adc = adc;
5103 fallback_cap = cap;
5104 }
5105 for (i = 0; i < AUTO_PIN_LAST; i++) {
5106 hda_nid_t nid = spec->autocfg.input_pins[i];
5107 if (!nid)
5108 continue;
5109 for (j = 0; j < nconns; j++) {
5110 if (conn[j] == nid)
5111 break;
5112 }
5113 if (j >= nconns)
5114 break;
5115 }
5116 if (i >= AUTO_PIN_LAST) {
5117 int num_adcs = spec->num_adc_nids;
5118 spec->private_adc_nids[num_adcs] = adc;
5119 spec->private_capsrc_nids[num_adcs] = cap;
5120 spec->num_adc_nids++;
5121 spec->adc_nids = spec->private_adc_nids;
5122 if (adc != cap)
5123 spec->capsrc_nids = spec->private_capsrc_nids;
5124 }
5125 }
5126 if (!spec->num_adc_nids) {
5127 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005128 " using fallback 0x%x\n",
5129 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005130 spec->private_adc_nids[0] = fallback_adc;
5131 spec->adc_nids = spec->private_adc_nids;
5132 if (fallback_adc != fallback_cap) {
5133 spec->private_capsrc_nids[0] = fallback_cap;
5134 spec->capsrc_nids = spec->private_adc_nids;
5135 }
5136 }
5137}
5138
Takashi Iwai67d634c2009-11-16 15:35:59 +01005139#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005140#define set_beep_amp(spec, nid, idx, dir) \
5141 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01005142#else
5143#define set_beep_amp(spec, nid, idx, dir) /* NOP */
5144#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005145
5146/*
5147 * OK, here we have finally the patch for ALC880
5148 */
5149
Linus Torvalds1da177e2005-04-16 15:20:36 -07005150static int patch_alc880(struct hda_codec *codec)
5151{
5152 struct alc_spec *spec;
5153 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005154 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005155
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005156 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005157 if (spec == NULL)
5158 return -ENOMEM;
5159
5160 codec->spec = spec;
5161
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005162 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5163 alc880_models,
5164 alc880_cfg_tbl);
5165 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005166 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5167 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005168 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005169 }
5170
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005171 if (board_config == ALC880_AUTO) {
5172 /* automatic parse from the BIOS config */
5173 err = alc880_parse_auto_config(codec);
5174 if (err < 0) {
5175 alc_free(codec);
5176 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005177 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005178 printk(KERN_INFO
5179 "hda_codec: Cannot set up configuration "
5180 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005181 board_config = ALC880_3ST;
5182 }
5183 }
5184
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005185 err = snd_hda_attach_beep_device(codec, 0x1);
5186 if (err < 0) {
5187 alc_free(codec);
5188 return err;
5189 }
5190
Kailang Yangdf694da2005-12-05 19:42:22 +01005191 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005192 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005193
Linus Torvalds1da177e2005-04-16 15:20:36 -07005194 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5195 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005196 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005197
Linus Torvalds1da177e2005-04-16 15:20:36 -07005198 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5199 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5200
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005201 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005202 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005203 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005204 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005205 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005206 if (wcap != AC_WID_AUD_IN) {
5207 spec->adc_nids = alc880_adc_nids_alt;
5208 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005209 } else {
5210 spec->adc_nids = alc880_adc_nids;
5211 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005212 }
5213 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005214 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005215 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005216
Takashi Iwai2134ea42008-01-10 16:53:55 +01005217 spec->vmaster_nid = 0x0c;
5218
Linus Torvalds1da177e2005-04-16 15:20:36 -07005219 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005220 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005221 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005222#ifdef CONFIG_SND_HDA_POWER_SAVE
5223 if (!spec->loopback.amplist)
5224 spec->loopback.amplist = alc880_loopbacks;
5225#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005226
5227 return 0;
5228}
5229
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005230
Linus Torvalds1da177e2005-04-16 15:20:36 -07005231/*
5232 * ALC260 support
5233 */
5234
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005235static hda_nid_t alc260_dac_nids[1] = {
5236 /* front */
5237 0x02,
5238};
5239
5240static hda_nid_t alc260_adc_nids[1] = {
5241 /* ADC0 */
5242 0x04,
5243};
5244
Kailang Yangdf694da2005-12-05 19:42:22 +01005245static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005246 /* ADC1 */
5247 0x05,
5248};
5249
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005250/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5251 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5252 */
5253static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005254 /* ADC0, ADC1 */
5255 0x04, 0x05
5256};
5257
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005258#define ALC260_DIGOUT_NID 0x03
5259#define ALC260_DIGIN_NID 0x06
5260
5261static struct hda_input_mux alc260_capture_source = {
5262 .num_items = 4,
5263 .items = {
5264 { "Mic", 0x0 },
5265 { "Front Mic", 0x1 },
5266 { "Line", 0x2 },
5267 { "CD", 0x4 },
5268 },
5269};
5270
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005271/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005272 * headphone jack and the internal CD lines since these are the only pins at
5273 * which audio can appear. For flexibility, also allow the option of
5274 * recording the mixer output on the second ADC (ADC0 doesn't have a
5275 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005276 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005277static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5278 {
5279 .num_items = 3,
5280 .items = {
5281 { "Mic/Line", 0x0 },
5282 { "CD", 0x4 },
5283 { "Headphone", 0x2 },
5284 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005285 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005286 {
5287 .num_items = 4,
5288 .items = {
5289 { "Mic/Line", 0x0 },
5290 { "CD", 0x4 },
5291 { "Headphone", 0x2 },
5292 { "Mixer", 0x5 },
5293 },
5294 },
5295
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005296};
5297
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005298/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5299 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005300 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005301static struct hda_input_mux alc260_acer_capture_sources[2] = {
5302 {
5303 .num_items = 4,
5304 .items = {
5305 { "Mic", 0x0 },
5306 { "Line", 0x2 },
5307 { "CD", 0x4 },
5308 { "Headphone", 0x5 },
5309 },
5310 },
5311 {
5312 .num_items = 5,
5313 .items = {
5314 { "Mic", 0x0 },
5315 { "Line", 0x2 },
5316 { "CD", 0x4 },
5317 { "Headphone", 0x6 },
5318 { "Mixer", 0x5 },
5319 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005320 },
5321};
Michael Schwingencc959482009-02-22 18:58:45 +01005322
5323/* Maxdata Favorit 100XS */
5324static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5325 {
5326 .num_items = 2,
5327 .items = {
5328 { "Line/Mic", 0x0 },
5329 { "CD", 0x4 },
5330 },
5331 },
5332 {
5333 .num_items = 3,
5334 .items = {
5335 { "Line/Mic", 0x0 },
5336 { "CD", 0x4 },
5337 { "Mixer", 0x5 },
5338 },
5339 },
5340};
5341
Linus Torvalds1da177e2005-04-16 15:20:36 -07005342/*
5343 * This is just place-holder, so there's something for alc_build_pcms to look
5344 * at when it calculates the maximum number of channels. ALC260 has no mixer
5345 * element which allows changing the channel mode, so the verb list is
5346 * never used.
5347 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005348static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005349 { 2, NULL },
5350};
5351
Kailang Yangdf694da2005-12-05 19:42:22 +01005352
5353/* Mixer combinations
5354 *
5355 * basic: base_output + input + pc_beep + capture
5356 * HP: base_output + input + capture_alt
5357 * HP_3013: hp_3013 + input + capture
5358 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005359 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005360 */
5361
5362static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005363 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005364 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005365 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5366 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5367 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5368 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5369 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005370};
Kailang Yangdf694da2005-12-05 19:42:22 +01005371
5372static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005373 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5374 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5375 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5376 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5377 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5378 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5379 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5380 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005381 { } /* end */
5382};
5383
Takashi Iwaibec15c32008-01-28 18:16:30 +01005384/* update HP, line and mono out pins according to the master switch */
5385static void alc260_hp_master_update(struct hda_codec *codec,
5386 hda_nid_t hp, hda_nid_t line,
5387 hda_nid_t mono)
5388{
5389 struct alc_spec *spec = codec->spec;
5390 unsigned int val = spec->master_sw ? PIN_HP : 0;
5391 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005392 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005393 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005394 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005395 val);
5396 /* mono (speaker) depending on the HP jack sense */
5397 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005398 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005399 val);
5400}
5401
5402static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5403 struct snd_ctl_elem_value *ucontrol)
5404{
5405 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5406 struct alc_spec *spec = codec->spec;
5407 *ucontrol->value.integer.value = spec->master_sw;
5408 return 0;
5409}
5410
5411static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5412 struct snd_ctl_elem_value *ucontrol)
5413{
5414 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5415 struct alc_spec *spec = codec->spec;
5416 int val = !!*ucontrol->value.integer.value;
5417 hda_nid_t hp, line, mono;
5418
5419 if (val == spec->master_sw)
5420 return 0;
5421 spec->master_sw = val;
5422 hp = (kcontrol->private_value >> 16) & 0xff;
5423 line = (kcontrol->private_value >> 8) & 0xff;
5424 mono = kcontrol->private_value & 0xff;
5425 alc260_hp_master_update(codec, hp, line, mono);
5426 return 1;
5427}
5428
5429static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5430 {
5431 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5432 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005433 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005434 .info = snd_ctl_boolean_mono_info,
5435 .get = alc260_hp_master_sw_get,
5436 .put = alc260_hp_master_sw_put,
5437 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5438 },
5439 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5440 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5441 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5442 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5443 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5444 HDA_OUTPUT),
5445 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5446 { } /* end */
5447};
5448
5449static struct hda_verb alc260_hp_unsol_verbs[] = {
5450 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5451 {},
5452};
5453
5454static void alc260_hp_automute(struct hda_codec *codec)
5455{
5456 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005457
Wu Fengguang864f92b2009-11-18 12:38:02 +08005458 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005459 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5460}
5461
5462static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5463{
5464 if ((res >> 26) == ALC880_HP_EVENT)
5465 alc260_hp_automute(codec);
5466}
5467
Kailang Yangdf694da2005-12-05 19:42:22 +01005468static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005469 {
5470 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5471 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005472 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005473 .info = snd_ctl_boolean_mono_info,
5474 .get = alc260_hp_master_sw_get,
5475 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005476 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005477 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005478 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5479 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5480 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5481 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5482 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5483 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005484 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5485 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005486 { } /* end */
5487};
5488
Kailang Yang3f878302008-08-26 13:02:23 +02005489static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5490 .ops = &snd_hda_bind_vol,
5491 .values = {
5492 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5493 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5494 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5495 0
5496 },
5497};
5498
5499static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5500 .ops = &snd_hda_bind_sw,
5501 .values = {
5502 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5503 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5504 0
5505 },
5506};
5507
5508static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5509 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5510 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5511 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5512 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5513 { } /* end */
5514};
5515
Takashi Iwaibec15c32008-01-28 18:16:30 +01005516static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5517 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5518 {},
5519};
5520
5521static void alc260_hp_3013_automute(struct hda_codec *codec)
5522{
5523 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005524
Wu Fengguang864f92b2009-11-18 12:38:02 +08005525 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005526 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005527}
5528
5529static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5530 unsigned int res)
5531{
5532 if ((res >> 26) == ALC880_HP_EVENT)
5533 alc260_hp_3013_automute(codec);
5534}
5535
Kailang Yang3f878302008-08-26 13:02:23 +02005536static void alc260_hp_3012_automute(struct hda_codec *codec)
5537{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005538 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005539
Kailang Yang3f878302008-08-26 13:02:23 +02005540 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5541 bits);
5542 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5543 bits);
5544 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5545 bits);
5546}
5547
5548static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5549 unsigned int res)
5550{
5551 if ((res >> 26) == ALC880_HP_EVENT)
5552 alc260_hp_3012_automute(codec);
5553}
5554
5555/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005556 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5557 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005558static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005559 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005560 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005561 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005562 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5563 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5564 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5565 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005566 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005567 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5568 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005569 { } /* end */
5570};
5571
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005572/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5573 * versions of the ALC260 don't act on requests to enable mic bias from NID
5574 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5575 * datasheet doesn't mention this restriction. At this stage it's not clear
5576 * whether this behaviour is intentional or is a hardware bug in chip
5577 * revisions available in early 2006. Therefore for now allow the
5578 * "Headphone Jack Mode" control to span all choices, but if it turns out
5579 * that the lack of mic bias for this NID is intentional we could change the
5580 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5581 *
5582 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5583 * don't appear to make the mic bias available from the "line" jack, even
5584 * though the NID used for this jack (0x14) can supply it. The theory is
5585 * that perhaps Acer have included blocking capacitors between the ALC260
5586 * and the output jack. If this turns out to be the case for all such
5587 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5588 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005589 *
5590 * The C20x Tablet series have a mono internal speaker which is controlled
5591 * via the chip's Mono sum widget and pin complex, so include the necessary
5592 * controls for such models. On models without a "mono speaker" the control
5593 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005594 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005595static struct snd_kcontrol_new alc260_acer_mixer[] = {
5596 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5597 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005598 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005599 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005600 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005601 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005602 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005603 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5604 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5605 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5606 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5607 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5608 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5609 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5610 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005611 { } /* end */
5612};
5613
Michael Schwingencc959482009-02-22 18:58:45 +01005614/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5615 */
5616static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5617 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5618 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5619 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5620 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5621 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5622 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5623 { } /* end */
5624};
5625
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005626/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5627 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5628 */
5629static struct snd_kcontrol_new alc260_will_mixer[] = {
5630 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5631 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5633 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5634 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5635 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5636 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5637 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5638 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5639 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005640 { } /* end */
5641};
5642
5643/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5644 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5645 */
5646static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5647 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5648 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5649 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5650 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5651 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5652 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5653 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5654 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5655 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5656 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5657 { } /* end */
5658};
5659
Kailang Yangdf694da2005-12-05 19:42:22 +01005660/*
5661 * initialization verbs
5662 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005663static struct hda_verb alc260_init_verbs[] = {
5664 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005665 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005666 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005667 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005668 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005669 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005670 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005671 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005672 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005673 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005674 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005675 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005676 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005677 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005678 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005679 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005680 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005681 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5682 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005683 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005684 /* set connection select to line in (default select for this ADC) */
5685 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005686 /* mute capture amp left and right */
5687 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5688 /* set connection select to line in (default select for this ADC) */
5689 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005690 /* set vol=0 Line-Out mixer amp left and right */
5691 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5692 /* unmute pin widget amp left and right (no gain on this amp) */
5693 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5694 /* set vol=0 HP mixer amp left and right */
5695 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5696 /* unmute pin widget amp left and right (no gain on this amp) */
5697 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5698 /* set vol=0 Mono mixer amp left and right */
5699 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5700 /* unmute pin widget amp left and right (no gain on this amp) */
5701 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5702 /* unmute LINE-2 out pin */
5703 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005704 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5705 * Line In 2 = 0x03
5706 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005707 /* mute analog inputs */
5708 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5709 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5710 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5711 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005713 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005714 /* mute Front out path */
5715 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5716 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5717 /* mute Headphone out path */
5718 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5719 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5720 /* mute Mono out path */
5721 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5722 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005723 { }
5724};
5725
Takashi Iwai474167d2006-05-17 17:17:43 +02005726#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005727static struct hda_verb alc260_hp_init_verbs[] = {
5728 /* Headphone and output */
5729 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5730 /* mono output */
5731 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5732 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5733 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5734 /* Mic2 (front panel) pin widget for input and vref at 80% */
5735 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5736 /* Line In pin widget for input */
5737 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5738 /* Line-2 pin widget for output */
5739 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5740 /* CD pin widget for input */
5741 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5742 /* unmute amp left and right */
5743 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5744 /* set connection select to line in (default select for this ADC) */
5745 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5746 /* unmute Line-Out mixer amp left and right (volume = 0) */
5747 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5748 /* mute pin widget amp left and right (no gain on this amp) */
5749 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5750 /* unmute HP mixer amp left and right (volume = 0) */
5751 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5752 /* mute pin widget amp left and right (no gain on this amp) */
5753 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005754 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5755 * Line In 2 = 0x03
5756 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005757 /* mute analog inputs */
5758 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5759 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5760 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5761 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5762 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005763 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5764 /* Unmute Front out path */
5765 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5766 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5767 /* Unmute Headphone out path */
5768 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5769 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5770 /* Unmute Mono out path */
5771 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5772 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5773 { }
5774};
Takashi Iwai474167d2006-05-17 17:17:43 +02005775#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005776
5777static struct hda_verb alc260_hp_3013_init_verbs[] = {
5778 /* Line out and output */
5779 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5780 /* mono output */
5781 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5782 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5783 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5784 /* Mic2 (front panel) pin widget for input and vref at 80% */
5785 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5786 /* Line In pin widget for input */
5787 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5788 /* Headphone pin widget for output */
5789 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5790 /* CD pin widget for input */
5791 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5792 /* unmute amp left and right */
5793 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5794 /* set connection select to line in (default select for this ADC) */
5795 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5796 /* unmute Line-Out mixer amp left and right (volume = 0) */
5797 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5798 /* mute pin widget amp left and right (no gain on this amp) */
5799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5800 /* unmute HP mixer amp left and right (volume = 0) */
5801 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5802 /* mute pin widget amp left and right (no gain on this amp) */
5803 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005804 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5805 * Line In 2 = 0x03
5806 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005807 /* mute analog inputs */
5808 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5809 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5810 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5811 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5812 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005813 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5814 /* Unmute Front out path */
5815 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5816 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5817 /* Unmute Headphone out path */
5818 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5819 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5820 /* Unmute Mono out path */
5821 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5822 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5823 { }
5824};
5825
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005826/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005827 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5828 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005829 */
5830static struct hda_verb alc260_fujitsu_init_verbs[] = {
5831 /* Disable all GPIOs */
5832 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5833 /* Internal speaker is connected to headphone pin */
5834 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5835 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5836 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005837 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5838 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5839 /* Ensure all other unused pins are disabled and muted. */
5840 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5841 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005842 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005843 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005844 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005845 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5846 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5847 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005848
Jonathan Woithef7ace402006-02-28 11:46:14 +01005849 /* Disable digital (SPDIF) pins */
5850 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5851 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005852
Kailang Yangea1fb292008-08-26 12:58:38 +02005853 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005854 * when acting as an output.
5855 */
5856 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5857
5858 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005859 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5860 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5861 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5862 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5863 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5864 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5865 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5866 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5867 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005868
Jonathan Woithef7ace402006-02-28 11:46:14 +01005869 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5870 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5871 /* Unmute Line1 pin widget output buffer since it starts as an output.
5872 * If the pin mode is changed by the user the pin mode control will
5873 * take care of enabling the pin's input/output buffers as needed.
5874 * Therefore there's no need to enable the input buffer at this
5875 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005876 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005877 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005878 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005879 * mixer ctrl)
5880 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005881 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005882
Jonathan Woithef7ace402006-02-28 11:46:14 +01005883 /* Mute capture amp left and right */
5884 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005885 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005886 * in (on mic1 pin)
5887 */
5888 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005889
Jonathan Woithef7ace402006-02-28 11:46:14 +01005890 /* Do the same for the second ADC: mute capture input amp and
5891 * set ADC connection to line in (on mic1 pin)
5892 */
5893 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5894 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005895
Jonathan Woithef7ace402006-02-28 11:46:14 +01005896 /* Mute all inputs to mixer widget (even unconnected ones) */
5897 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5898 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5899 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5900 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5901 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5902 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5903 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5904 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005905
5906 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005907};
5908
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005909/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5910 * similar laptops (adapted from Fujitsu init verbs).
5911 */
5912static struct hda_verb alc260_acer_init_verbs[] = {
5913 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5914 * the headphone jack. Turn this on and rely on the standard mute
5915 * methods whenever the user wants to turn these outputs off.
5916 */
5917 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5918 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5919 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5920 /* Internal speaker/Headphone jack is connected to Line-out pin */
5921 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5922 /* Internal microphone/Mic jack is connected to Mic1 pin */
5923 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5924 /* Line In jack is connected to Line1 pin */
5925 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005926 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5927 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005928 /* Ensure all other unused pins are disabled and muted. */
5929 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5930 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005931 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5932 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5933 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5934 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5935 /* Disable digital (SPDIF) pins */
5936 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5937 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5938
Kailang Yangea1fb292008-08-26 12:58:38 +02005939 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005940 * bus when acting as outputs.
5941 */
5942 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5943 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5944
5945 /* Start with output sum widgets muted and their output gains at min */
5946 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5947 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5948 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5949 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5950 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5951 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5952 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5953 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5954 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5955
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005956 /* Unmute Line-out pin widget amp left and right
5957 * (no equiv mixer ctrl)
5958 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005959 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005960 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5961 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005962 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5963 * inputs. If the pin mode is changed by the user the pin mode control
5964 * will take care of enabling the pin's input/output buffers as needed.
5965 * Therefore there's no need to enable the input buffer at this
5966 * stage.
5967 */
5968 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5969 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5970
5971 /* Mute capture amp left and right */
5972 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5973 /* Set ADC connection select to match default mixer setting - mic
5974 * (on mic1 pin)
5975 */
5976 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5977
5978 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005979 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005980 */
5981 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005982 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005983
5984 /* Mute all inputs to mixer widget (even unconnected ones) */
5985 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5986 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5987 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5988 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5989 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5990 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5991 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5992 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5993
5994 { }
5995};
5996
Michael Schwingencc959482009-02-22 18:58:45 +01005997/* Initialisation sequence for Maxdata Favorit 100XS
5998 * (adapted from Acer init verbs).
5999 */
6000static struct hda_verb alc260_favorit100_init_verbs[] = {
6001 /* GPIO 0 enables the output jack.
6002 * Turn this on and rely on the standard mute
6003 * methods whenever the user wants to turn these outputs off.
6004 */
6005 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6006 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6007 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6008 /* Line/Mic input jack is connected to Mic1 pin */
6009 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6010 /* Ensure all other unused pins are disabled and muted. */
6011 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6012 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6013 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6014 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6015 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6016 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6017 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6018 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6019 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6020 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6021 /* Disable digital (SPDIF) pins */
6022 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6023 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6024
6025 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6026 * bus when acting as outputs.
6027 */
6028 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6029 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6030
6031 /* Start with output sum widgets muted and their output gains at min */
6032 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6033 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6034 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6035 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6036 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6037 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6038 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6039 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6040 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6041
6042 /* Unmute Line-out pin widget amp left and right
6043 * (no equiv mixer ctrl)
6044 */
6045 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6046 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6047 * inputs. If the pin mode is changed by the user the pin mode control
6048 * will take care of enabling the pin's input/output buffers as needed.
6049 * Therefore there's no need to enable the input buffer at this
6050 * stage.
6051 */
6052 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6053
6054 /* Mute capture amp left and right */
6055 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6056 /* Set ADC connection select to match default mixer setting - mic
6057 * (on mic1 pin)
6058 */
6059 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6060
6061 /* Do similar with the second ADC: mute capture input amp and
6062 * set ADC connection to mic to match ALSA's default state.
6063 */
6064 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6065 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6066
6067 /* Mute all inputs to mixer widget (even unconnected ones) */
6068 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6069 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6070 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6071 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6072 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6073 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6074 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6075 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6076
6077 { }
6078};
6079
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006080static struct hda_verb alc260_will_verbs[] = {
6081 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6082 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6083 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6084 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6085 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6086 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6087 {}
6088};
6089
6090static struct hda_verb alc260_replacer_672v_verbs[] = {
6091 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6092 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6093 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6094
6095 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6096 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6097 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6098
6099 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6100 {}
6101};
6102
6103/* toggle speaker-output according to the hp-jack state */
6104static void alc260_replacer_672v_automute(struct hda_codec *codec)
6105{
6106 unsigned int present;
6107
6108 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006109 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006110 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006111 snd_hda_codec_write_cache(codec, 0x01, 0,
6112 AC_VERB_SET_GPIO_DATA, 1);
6113 snd_hda_codec_write_cache(codec, 0x0f, 0,
6114 AC_VERB_SET_PIN_WIDGET_CONTROL,
6115 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006116 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006117 snd_hda_codec_write_cache(codec, 0x01, 0,
6118 AC_VERB_SET_GPIO_DATA, 0);
6119 snd_hda_codec_write_cache(codec, 0x0f, 0,
6120 AC_VERB_SET_PIN_WIDGET_CONTROL,
6121 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006122 }
6123}
6124
6125static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6126 unsigned int res)
6127{
6128 if ((res >> 26) == ALC880_HP_EVENT)
6129 alc260_replacer_672v_automute(codec);
6130}
6131
Kailang Yang3f878302008-08-26 13:02:23 +02006132static struct hda_verb alc260_hp_dc7600_verbs[] = {
6133 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6134 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6135 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6136 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6137 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6138 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6139 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6140 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6141 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6142 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6143 {}
6144};
6145
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006146/* Test configuration for debugging, modelled after the ALC880 test
6147 * configuration.
6148 */
6149#ifdef CONFIG_SND_DEBUG
6150static hda_nid_t alc260_test_dac_nids[1] = {
6151 0x02,
6152};
6153static hda_nid_t alc260_test_adc_nids[2] = {
6154 0x04, 0x05,
6155};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006156/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006157 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006158 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006159 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006160static struct hda_input_mux alc260_test_capture_sources[2] = {
6161 {
6162 .num_items = 7,
6163 .items = {
6164 { "MIC1 pin", 0x0 },
6165 { "MIC2 pin", 0x1 },
6166 { "LINE1 pin", 0x2 },
6167 { "LINE2 pin", 0x3 },
6168 { "CD pin", 0x4 },
6169 { "LINE-OUT pin", 0x5 },
6170 { "HP-OUT pin", 0x6 },
6171 },
6172 },
6173 {
6174 .num_items = 8,
6175 .items = {
6176 { "MIC1 pin", 0x0 },
6177 { "MIC2 pin", 0x1 },
6178 { "LINE1 pin", 0x2 },
6179 { "LINE2 pin", 0x3 },
6180 { "CD pin", 0x4 },
6181 { "Mixer", 0x5 },
6182 { "LINE-OUT pin", 0x6 },
6183 { "HP-OUT pin", 0x7 },
6184 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006185 },
6186};
6187static struct snd_kcontrol_new alc260_test_mixer[] = {
6188 /* Output driver widgets */
6189 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6190 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6191 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6192 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6193 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6194 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6195
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006196 /* Modes for retasking pin widgets
6197 * Note: the ALC260 doesn't seem to act on requests to enable mic
6198 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6199 * mention this restriction. At this stage it's not clear whether
6200 * this behaviour is intentional or is a hardware bug in chip
6201 * revisions available at least up until early 2006. Therefore for
6202 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6203 * choices, but if it turns out that the lack of mic bias for these
6204 * NIDs is intentional we could change their modes from
6205 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6206 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006207 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6208 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6209 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6210 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6211 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6212 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6213
6214 /* Loopback mixer controls */
6215 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6216 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6217 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6218 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6219 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6220 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6221 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6222 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6223 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6224 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006225 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6226 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6227 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6228 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006229
6230 /* Controls for GPIO pins, assuming they are configured as outputs */
6231 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6232 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6233 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6234 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6235
Jonathan Woithe92621f12006-02-28 11:47:47 +01006236 /* Switches to allow the digital IO pins to be enabled. The datasheet
6237 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006238 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006239 */
6240 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6241 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6242
Jonathan Woithef8225f62008-01-08 12:16:54 +01006243 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6244 * this output to turn on an external amplifier.
6245 */
6246 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6247 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6248
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006249 { } /* end */
6250};
6251static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006252 /* Enable all GPIOs as outputs with an initial value of 0 */
6253 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6254 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6255 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6256
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006257 /* Enable retasking pins as output, initially without power amp */
6258 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6259 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6260 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6261 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6262 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6263 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6264
Jonathan Woithe92621f12006-02-28 11:47:47 +01006265 /* Disable digital (SPDIF) pins initially, but users can enable
6266 * them via a mixer switch. In the case of SPDIF-out, this initverb
6267 * payload also sets the generation to 0, output to be in "consumer"
6268 * PCM format, copyright asserted, no pre-emphasis and no validity
6269 * control.
6270 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006271 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6272 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6273
Kailang Yangea1fb292008-08-26 12:58:38 +02006274 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006275 * OUT1 sum bus when acting as an output.
6276 */
6277 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6278 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6279 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6280 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6281
6282 /* Start with output sum widgets muted and their output gains at min */
6283 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6284 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6285 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6286 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6287 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6288 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6289 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6290 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6291 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6292
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006293 /* Unmute retasking pin widget output buffers since the default
6294 * state appears to be output. As the pin mode is changed by the
6295 * user the pin mode control will take care of enabling the pin's
6296 * input/output buffers as needed.
6297 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006298 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6299 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6300 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6301 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6302 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6303 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6304 /* Also unmute the mono-out pin widget */
6305 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6306
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006307 /* Mute capture amp left and right */
6308 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006309 /* Set ADC connection select to match default mixer setting (mic1
6310 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006311 */
6312 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6313
6314 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006315 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006316 */
6317 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6318 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6319
6320 /* Mute all inputs to mixer widget (even unconnected ones) */
6321 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6322 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6323 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6324 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6325 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6326 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6327 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6328 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6329
6330 { }
6331};
6332#endif
6333
Takashi Iwai63300792008-01-24 15:31:36 +01006334#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6335#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006336
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006337#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6338#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6339
Kailang Yangdf694da2005-12-05 19:42:22 +01006340/*
6341 * for BIOS auto-configuration
6342 */
6343
6344static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006345 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006346{
6347 hda_nid_t nid_vol;
6348 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006349 int err;
6350
6351 if (nid >= 0x0f && nid < 0x11) {
6352 nid_vol = nid - 0x7;
6353 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6354 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6355 } else if (nid == 0x11) {
6356 nid_vol = nid - 0x7;
6357 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6358 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6359 } else if (nid >= 0x12 && nid <= 0x15) {
6360 nid_vol = 0x08;
6361 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6362 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6363 } else
6364 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006365
Takashi Iwai863b4512008-10-21 17:01:47 +02006366 if (!(*vol_bits & (1 << nid_vol))) {
6367 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006368 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006369 if (err < 0)
6370 return err;
6371 *vol_bits |= (1 << nid_vol);
6372 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006373 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006374 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006375 return err;
6376 return 1;
6377}
6378
6379/* add playback controls from the parsed DAC table */
6380static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6381 const struct auto_pin_cfg *cfg)
6382{
6383 hda_nid_t nid;
6384 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006385 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006386
6387 spec->multiout.num_dacs = 1;
6388 spec->multiout.dac_nids = spec->private_dac_nids;
6389 spec->multiout.dac_nids[0] = 0x02;
6390
6391 nid = cfg->line_out_pins[0];
6392 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006393 const char *pfx;
6394 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6395 pfx = "Master";
6396 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6397 pfx = "Speaker";
6398 else
6399 pfx = "Front";
6400 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006401 if (err < 0)
6402 return err;
6403 }
6404
Takashi Iwai82bc9552006-03-21 11:24:42 +01006405 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006406 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006407 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006408 if (err < 0)
6409 return err;
6410 }
6411
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006412 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006413 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006414 err = alc260_add_playback_controls(spec, nid, "Headphone",
6415 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006416 if (err < 0)
6417 return err;
6418 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006419 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006420}
6421
6422/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006423static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006424 const struct auto_pin_cfg *cfg)
6425{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006426 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006427}
6428
6429static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6430 hda_nid_t nid, int pin_type,
6431 int sel_idx)
6432{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006433 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006434 /* need the manual connection? */
6435 if (nid >= 0x12) {
6436 int idx = nid - 0x12;
6437 snd_hda_codec_write(codec, idx + 0x0b, 0,
6438 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006439 }
6440}
6441
6442static void alc260_auto_init_multi_out(struct hda_codec *codec)
6443{
6444 struct alc_spec *spec = codec->spec;
6445 hda_nid_t nid;
6446
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006447 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006448 if (nid) {
6449 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6450 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6451 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006452
Takashi Iwai82bc9552006-03-21 11:24:42 +01006453 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006454 if (nid)
6455 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6456
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006457 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006458 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006459 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006460}
Kailang Yangdf694da2005-12-05 19:42:22 +01006461
6462#define ALC260_PIN_CD_NID 0x16
6463static void alc260_auto_init_analog_input(struct hda_codec *codec)
6464{
6465 struct alc_spec *spec = codec->spec;
6466 int i;
6467
6468 for (i = 0; i < AUTO_PIN_LAST; i++) {
6469 hda_nid_t nid = spec->autocfg.input_pins[i];
6470 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006471 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006472 if (nid != ALC260_PIN_CD_NID &&
6473 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006474 snd_hda_codec_write(codec, nid, 0,
6475 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006476 AMP_OUT_MUTE);
6477 }
6478 }
6479}
6480
6481/*
6482 * generic initialization of ADC, input mixers and output mixers
6483 */
6484static struct hda_verb alc260_volume_init_verbs[] = {
6485 /*
6486 * Unmute ADC0-1 and set the default input to mic-in
6487 */
6488 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6489 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6490 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6491 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006492
Kailang Yangdf694da2005-12-05 19:42:22 +01006493 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6494 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006495 * Note: PASD motherboards uses the Line In 2 as the input for
6496 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006497 */
6498 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006499 /* mute analog inputs */
6500 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6501 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6502 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6504 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006505
6506 /*
6507 * Set up output mixers (0x08 - 0x0a)
6508 */
6509 /* set vol=0 to output mixers */
6510 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6511 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6512 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6513 /* set up input amps for analog loopback */
6514 /* Amp Indices: DAC = 0, mixer = 1 */
6515 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6516 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6517 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6518 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6519 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6520 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006521
Kailang Yangdf694da2005-12-05 19:42:22 +01006522 { }
6523};
6524
6525static int alc260_parse_auto_config(struct hda_codec *codec)
6526{
6527 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006528 int err;
6529 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6530
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006531 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6532 alc260_ignore);
6533 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006534 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006535 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6536 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006537 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006538 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006539 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006540 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006541 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006542 return err;
6543
6544 spec->multiout.max_channels = 2;
6545
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006546 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006547 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006548 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006549 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006550
Takashi Iwaid88897e2008-10-31 15:01:37 +01006551 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006552
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006553 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006554 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006555
Kailang Yang6227cdc2010-02-25 08:36:52 +01006556 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006557
Kailang Yangdf694da2005-12-05 19:42:22 +01006558 return 1;
6559}
6560
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006561/* additional initialization for auto-configuration model */
6562static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006563{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006564 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006565 alc260_auto_init_multi_out(codec);
6566 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006567 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006568 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006569}
6570
Takashi Iwaicb53c622007-08-10 17:21:45 +02006571#ifdef CONFIG_SND_HDA_POWER_SAVE
6572static struct hda_amp_list alc260_loopbacks[] = {
6573 { 0x07, HDA_INPUT, 0 },
6574 { 0x07, HDA_INPUT, 1 },
6575 { 0x07, HDA_INPUT, 2 },
6576 { 0x07, HDA_INPUT, 3 },
6577 { 0x07, HDA_INPUT, 4 },
6578 { } /* end */
6579};
6580#endif
6581
Kailang Yangdf694da2005-12-05 19:42:22 +01006582/*
6583 * ALC260 configurations
6584 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006585static const char *alc260_models[ALC260_MODEL_LAST] = {
6586 [ALC260_BASIC] = "basic",
6587 [ALC260_HP] = "hp",
6588 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006589 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006590 [ALC260_FUJITSU_S702X] = "fujitsu",
6591 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006592 [ALC260_WILL] = "will",
6593 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006594 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006595#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006596 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006597#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006598 [ALC260_AUTO] = "auto",
6599};
6600
6601static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006602 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006603 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006604 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006605 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006606 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006607 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006608 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006609 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006610 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006611 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6612 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6613 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6614 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6615 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6616 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6617 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6618 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6619 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006620 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006621 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006622 {}
6623};
6624
Kailang Yangdf694da2005-12-05 19:42:22 +01006625static struct alc_config_preset alc260_presets[] = {
6626 [ALC260_BASIC] = {
6627 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006628 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006629 .init_verbs = { alc260_init_verbs },
6630 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6631 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006632 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01006633 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006634 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6635 .channel_mode = alc260_modes,
6636 .input_mux = &alc260_capture_source,
6637 },
6638 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006639 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006640 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006641 .init_verbs = { alc260_init_verbs,
6642 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006643 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6644 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006645 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6646 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006647 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6648 .channel_mode = alc260_modes,
6649 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006650 .unsol_event = alc260_hp_unsol_event,
6651 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006652 },
Kailang Yang3f878302008-08-26 13:02:23 +02006653 [ALC260_HP_DC7600] = {
6654 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006655 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006656 .init_verbs = { alc260_init_verbs,
6657 alc260_hp_dc7600_verbs },
6658 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6659 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006660 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6661 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006662 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6663 .channel_mode = alc260_modes,
6664 .input_mux = &alc260_capture_source,
6665 .unsol_event = alc260_hp_3012_unsol_event,
6666 .init_hook = alc260_hp_3012_automute,
6667 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006668 [ALC260_HP_3013] = {
6669 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006670 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006671 .init_verbs = { alc260_hp_3013_init_verbs,
6672 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006673 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6674 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006675 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6676 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006677 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6678 .channel_mode = alc260_modes,
6679 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006680 .unsol_event = alc260_hp_3013_unsol_event,
6681 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006682 },
6683 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006684 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006685 .init_verbs = { alc260_fujitsu_init_verbs },
6686 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6687 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006688 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6689 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006690 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6691 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006692 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6693 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006694 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006695 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006696 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006697 .init_verbs = { alc260_acer_init_verbs },
6698 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6699 .dac_nids = alc260_dac_nids,
6700 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6701 .adc_nids = alc260_dual_adc_nids,
6702 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6703 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006704 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6705 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006706 },
Michael Schwingencc959482009-02-22 18:58:45 +01006707 [ALC260_FAVORIT100] = {
6708 .mixers = { alc260_favorit100_mixer },
6709 .init_verbs = { alc260_favorit100_init_verbs },
6710 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6711 .dac_nids = alc260_dac_nids,
6712 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6713 .adc_nids = alc260_dual_adc_nids,
6714 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6715 .channel_mode = alc260_modes,
6716 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6717 .input_mux = alc260_favorit100_capture_sources,
6718 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006719 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006720 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006721 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6722 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6723 .dac_nids = alc260_dac_nids,
6724 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6725 .adc_nids = alc260_adc_nids,
6726 .dig_out_nid = ALC260_DIGOUT_NID,
6727 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6728 .channel_mode = alc260_modes,
6729 .input_mux = &alc260_capture_source,
6730 },
6731 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006732 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006733 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6734 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6735 .dac_nids = alc260_dac_nids,
6736 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6737 .adc_nids = alc260_adc_nids,
6738 .dig_out_nid = ALC260_DIGOUT_NID,
6739 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6740 .channel_mode = alc260_modes,
6741 .input_mux = &alc260_capture_source,
6742 .unsol_event = alc260_replacer_672v_unsol_event,
6743 .init_hook = alc260_replacer_672v_automute,
6744 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006745#ifdef CONFIG_SND_DEBUG
6746 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006747 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006748 .init_verbs = { alc260_test_init_verbs },
6749 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6750 .dac_nids = alc260_test_dac_nids,
6751 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6752 .adc_nids = alc260_test_adc_nids,
6753 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6754 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006755 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6756 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006757 },
6758#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006759};
6760
Linus Torvalds1da177e2005-04-16 15:20:36 -07006761static int patch_alc260(struct hda_codec *codec)
6762{
6763 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006764 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006765
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006766 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006767 if (spec == NULL)
6768 return -ENOMEM;
6769
6770 codec->spec = spec;
6771
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006772 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6773 alc260_models,
6774 alc260_cfg_tbl);
6775 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006776 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006777 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006778 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006779 }
6780
Kailang Yangdf694da2005-12-05 19:42:22 +01006781 if (board_config == ALC260_AUTO) {
6782 /* automatic parse from the BIOS config */
6783 err = alc260_parse_auto_config(codec);
6784 if (err < 0) {
6785 alc_free(codec);
6786 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006787 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006788 printk(KERN_INFO
6789 "hda_codec: Cannot set up configuration "
6790 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006791 board_config = ALC260_BASIC;
6792 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006793 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006794
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006795 err = snd_hda_attach_beep_device(codec, 0x1);
6796 if (err < 0) {
6797 alc_free(codec);
6798 return err;
6799 }
6800
Kailang Yangdf694da2005-12-05 19:42:22 +01006801 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006802 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006803
Linus Torvalds1da177e2005-04-16 15:20:36 -07006804 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6805 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6806
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006807 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6808 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6809
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006810 if (!spec->adc_nids && spec->input_mux) {
6811 /* check whether NID 0x04 is valid */
6812 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006813 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006814 /* get type */
6815 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6816 spec->adc_nids = alc260_adc_nids_alt;
6817 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6818 } else {
6819 spec->adc_nids = alc260_adc_nids;
6820 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6821 }
6822 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006823 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006824 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006825
Takashi Iwai2134ea42008-01-10 16:53:55 +01006826 spec->vmaster_nid = 0x08;
6827
Linus Torvalds1da177e2005-04-16 15:20:36 -07006828 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006829 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006830 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006831#ifdef CONFIG_SND_HDA_POWER_SAVE
6832 if (!spec->loopback.amplist)
6833 spec->loopback.amplist = alc260_loopbacks;
6834#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006835
6836 return 0;
6837}
6838
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006839
Linus Torvalds1da177e2005-04-16 15:20:36 -07006840/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006841 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006842 *
6843 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6844 * configuration. Each pin widget can choose any input DACs and a mixer.
6845 * Each ADC is connected from a mixer of all inputs. This makes possible
6846 * 6-channel independent captures.
6847 *
6848 * In addition, an independent DAC for the multi-playback (not used in this
6849 * driver yet).
6850 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006851#define ALC882_DIGOUT_NID 0x06
6852#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006853#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6854#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6855#define ALC1200_DIGOUT_NID 0x10
6856
Linus Torvalds1da177e2005-04-16 15:20:36 -07006857
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006858static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006859 { 8, NULL }
6860};
6861
Takashi Iwai4953550a2009-06-30 15:28:30 +02006862/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006863static hda_nid_t alc882_dac_nids[4] = {
6864 /* front, rear, clfe, rear_surr */
6865 0x02, 0x03, 0x04, 0x05
6866};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006867#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006868
Takashi Iwai4953550a2009-06-30 15:28:30 +02006869/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006870#define alc882_adc_nids alc880_adc_nids
6871#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006872#define alc883_adc_nids alc882_adc_nids_alt
6873static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6874static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6875#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006876
Takashi Iwaie1406342008-02-11 18:32:32 +01006877static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6878static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006879#define alc883_capsrc_nids alc882_capsrc_nids_alt
6880static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6881#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006882
Linus Torvalds1da177e2005-04-16 15:20:36 -07006883/* input MUX */
6884/* FIXME: should be a matrix-type input source selection */
6885
6886static struct hda_input_mux alc882_capture_source = {
6887 .num_items = 4,
6888 .items = {
6889 { "Mic", 0x0 },
6890 { "Front Mic", 0x1 },
6891 { "Line", 0x2 },
6892 { "CD", 0x4 },
6893 },
6894};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006895
Takashi Iwai4953550a2009-06-30 15:28:30 +02006896#define alc883_capture_source alc882_capture_source
6897
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006898static struct hda_input_mux alc889_capture_source = {
6899 .num_items = 3,
6900 .items = {
6901 { "Front Mic", 0x0 },
6902 { "Mic", 0x3 },
6903 { "Line", 0x2 },
6904 },
6905};
6906
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006907static struct hda_input_mux mb5_capture_source = {
6908 .num_items = 3,
6909 .items = {
6910 { "Mic", 0x1 },
6911 { "Line", 0x2 },
6912 { "CD", 0x4 },
6913 },
6914};
6915
Luke Yelaviche458b1f2010-02-12 16:28:29 +11006916static struct hda_input_mux macmini3_capture_source = {
6917 .num_items = 2,
6918 .items = {
6919 { "Line", 0x2 },
6920 { "CD", 0x4 },
6921 },
6922};
6923
Takashi Iwai4953550a2009-06-30 15:28:30 +02006924static struct hda_input_mux alc883_3stack_6ch_intel = {
6925 .num_items = 4,
6926 .items = {
6927 { "Mic", 0x1 },
6928 { "Front Mic", 0x0 },
6929 { "Line", 0x2 },
6930 { "CD", 0x4 },
6931 },
6932};
6933
6934static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6935 .num_items = 2,
6936 .items = {
6937 { "Mic", 0x1 },
6938 { "Line", 0x2 },
6939 },
6940};
6941
6942static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6943 .num_items = 4,
6944 .items = {
6945 { "Mic", 0x0 },
6946 { "iMic", 0x1 },
6947 { "Line", 0x2 },
6948 { "CD", 0x4 },
6949 },
6950};
6951
6952static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6953 .num_items = 2,
6954 .items = {
6955 { "Mic", 0x0 },
6956 { "Int Mic", 0x1 },
6957 },
6958};
6959
6960static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6961 .num_items = 3,
6962 .items = {
6963 { "Mic", 0x0 },
6964 { "Front Mic", 0x1 },
6965 { "Line", 0x4 },
6966 },
6967};
6968
6969static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6970 .num_items = 2,
6971 .items = {
6972 { "Mic", 0x0 },
6973 { "Line", 0x2 },
6974 },
6975};
6976
6977static struct hda_input_mux alc889A_mb31_capture_source = {
6978 .num_items = 2,
6979 .items = {
6980 { "Mic", 0x0 },
6981 /* Front Mic (0x01) unused */
6982 { "Line", 0x2 },
6983 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02006984 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006985 },
6986};
6987
6988/*
6989 * 2ch mode
6990 */
6991static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6992 { 2, NULL }
6993};
6994
Kailang Yangdf694da2005-12-05 19:42:22 +01006995/*
Kailang Yang272a5272007-05-14 11:00:38 +02006996 * 2ch mode
6997 */
6998static struct hda_verb alc882_3ST_ch2_init[] = {
6999 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7000 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7001 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7002 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7003 { } /* end */
7004};
7005
7006/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007007 * 4ch mode
7008 */
7009static struct hda_verb alc882_3ST_ch4_init[] = {
7010 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7011 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7012 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7013 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7014 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7015 { } /* end */
7016};
7017
7018/*
Kailang Yang272a5272007-05-14 11:00:38 +02007019 * 6ch mode
7020 */
7021static struct hda_verb alc882_3ST_ch6_init[] = {
7022 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7023 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7024 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7025 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7026 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7027 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7028 { } /* end */
7029};
7030
Takashi Iwai4953550a2009-06-30 15:28:30 +02007031static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007032 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007033 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007034 { 6, alc882_3ST_ch6_init },
7035};
7036
Takashi Iwai4953550a2009-06-30 15:28:30 +02007037#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7038
Kailang Yang272a5272007-05-14 11:00:38 +02007039/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307040 * 2ch mode
7041 */
7042static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7043 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7044 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7045 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7046 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7047 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7048 { } /* end */
7049};
7050
7051/*
7052 * 4ch mode
7053 */
7054static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7055 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7056 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7057 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7058 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7059 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7060 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7061 { } /* end */
7062};
7063
7064/*
7065 * 6ch mode
7066 */
7067static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7068 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7069 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7070 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7071 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7072 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7073 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7074 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7075 { } /* end */
7076};
7077
7078static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7079 { 2, alc883_3ST_ch2_clevo_init },
7080 { 4, alc883_3ST_ch4_clevo_init },
7081 { 6, alc883_3ST_ch6_clevo_init },
7082};
7083
7084
7085/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007086 * 6ch mode
7087 */
7088static struct hda_verb alc882_sixstack_ch6_init[] = {
7089 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7090 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7091 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7092 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7093 { } /* end */
7094};
7095
7096/*
7097 * 8ch mode
7098 */
7099static struct hda_verb alc882_sixstack_ch8_init[] = {
7100 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7101 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7102 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7103 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7104 { } /* end */
7105};
7106
7107static struct hda_channel_mode alc882_sixstack_modes[2] = {
7108 { 6, alc882_sixstack_ch6_init },
7109 { 8, alc882_sixstack_ch8_init },
7110};
7111
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007112
7113/* Macbook Air 2,1 */
7114
7115static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7116 { 2, NULL },
7117};
7118
Takashi Iwai87350ad2007-08-16 18:19:38 +02007119/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007120 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007121 */
7122
7123/*
7124 * 2ch mode
7125 */
7126static struct hda_verb alc885_mbp_ch2_init[] = {
7127 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7128 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7129 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7130 { } /* end */
7131};
7132
7133/*
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007134 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007135 */
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007136static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007137 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7138 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7139 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7140 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7141 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7142 { } /* end */
7143};
7144
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007145static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007146 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007147 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007148};
7149
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007150/*
7151 * 2ch
7152 * Speakers/Woofer/HP = Front
7153 * LineIn = Input
7154 */
7155static struct hda_verb alc885_mb5_ch2_init[] = {
7156 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7157 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7158 { } /* end */
7159};
7160
7161/*
7162 * 6ch mode
7163 * Speakers/HP = Front
7164 * Woofer = LFE
7165 * LineIn = Surround
7166 */
7167static struct hda_verb alc885_mb5_ch6_init[] = {
7168 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7169 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7170 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7171 { } /* end */
7172};
7173
7174static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7175 { 2, alc885_mb5_ch2_init },
7176 { 6, alc885_mb5_ch6_init },
7177};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007178
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007179#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007180
7181/*
7182 * 2ch mode
7183 */
7184static struct hda_verb alc883_4ST_ch2_init[] = {
7185 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7186 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7187 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7188 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7189 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7190 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7191 { } /* end */
7192};
7193
7194/*
7195 * 4ch mode
7196 */
7197static struct hda_verb alc883_4ST_ch4_init[] = {
7198 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7199 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7200 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7201 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7202 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7203 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7204 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7205 { } /* end */
7206};
7207
7208/*
7209 * 6ch mode
7210 */
7211static struct hda_verb alc883_4ST_ch6_init[] = {
7212 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7213 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7214 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7215 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7216 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7217 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7218 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7219 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7220 { } /* end */
7221};
7222
7223/*
7224 * 8ch mode
7225 */
7226static struct hda_verb alc883_4ST_ch8_init[] = {
7227 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7228 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7229 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7230 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7231 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7232 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7233 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7234 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7235 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7236 { } /* end */
7237};
7238
7239static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7240 { 2, alc883_4ST_ch2_init },
7241 { 4, alc883_4ST_ch4_init },
7242 { 6, alc883_4ST_ch6_init },
7243 { 8, alc883_4ST_ch8_init },
7244};
7245
7246
7247/*
7248 * 2ch mode
7249 */
7250static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7251 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7252 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7253 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7254 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7255 { } /* end */
7256};
7257
7258/*
7259 * 4ch mode
7260 */
7261static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7262 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7263 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7264 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7265 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7266 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7267 { } /* end */
7268};
7269
7270/*
7271 * 6ch mode
7272 */
7273static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7274 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7275 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7276 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7277 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7278 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7279 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7280 { } /* end */
7281};
7282
7283static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7284 { 2, alc883_3ST_ch2_intel_init },
7285 { 4, alc883_3ST_ch4_intel_init },
7286 { 6, alc883_3ST_ch6_intel_init },
7287};
7288
7289/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007290 * 2ch mode
7291 */
7292static struct hda_verb alc889_ch2_intel_init[] = {
7293 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7294 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7295 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7296 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7297 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7298 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7299 { } /* end */
7300};
7301
7302/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007303 * 6ch mode
7304 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007305static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007306 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7307 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7308 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7309 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7310 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007311 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7312 { } /* end */
7313};
7314
7315/*
7316 * 8ch mode
7317 */
7318static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007319 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7320 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7321 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7322 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7323 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007324 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7325 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007326 { } /* end */
7327};
7328
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007329static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7330 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007331 { 6, alc889_ch6_intel_init },
7332 { 8, alc889_ch8_intel_init },
7333};
7334
7335/*
7336 * 6ch mode
7337 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007338static struct hda_verb alc883_sixstack_ch6_init[] = {
7339 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7340 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7341 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7342 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7343 { } /* end */
7344};
7345
7346/*
7347 * 8ch mode
7348 */
7349static struct hda_verb alc883_sixstack_ch8_init[] = {
7350 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7351 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7352 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7353 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7354 { } /* end */
7355};
7356
7357static struct hda_channel_mode alc883_sixstack_modes[2] = {
7358 { 6, alc883_sixstack_ch6_init },
7359 { 8, alc883_sixstack_ch8_init },
7360};
7361
7362
Linus Torvalds1da177e2005-04-16 15:20:36 -07007363/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7364 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7365 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007366static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007367 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007368 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007369 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007370 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007371 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7372 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007373 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7374 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007375 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007376 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007377 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7378 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7379 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7380 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7381 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007383 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007384 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7385 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007386 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007387 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007388 { } /* end */
7389};
7390
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007391/* Macbook Air 2,1 same control for HP and internal Speaker */
7392
7393static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7394 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7395 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7396 { }
7397};
7398
7399
Takashi Iwai87350ad2007-08-16 18:19:38 +02007400static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007401 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7402 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7403 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7404 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7405 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007406 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7407 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007408 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7409 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007410 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007411 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7412 { } /* end */
7413};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007414
7415static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007416 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7417 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7418 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7419 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7420 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7421 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307422 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7423 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007424 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7425 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7426 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7427 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7428 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7429 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7430 { } /* end */
7431};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007432
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007433static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7434 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7435 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7436 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7437 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7438 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7439 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7440 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7441 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7442 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7443 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7444 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7445 { } /* end */
7446};
7447
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007448static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7449 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7450 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7451 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7452 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7453 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7454 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7455 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7456 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7457 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7458 { } /* end */
7459};
7460
7461
Kailang Yangbdd148a2007-05-08 15:19:08 +02007462static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7463 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7464 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7465 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7466 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7467 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7468 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7469 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7470 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7471 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007472 { } /* end */
7473};
7474
Kailang Yang272a5272007-05-14 11:00:38 +02007475static struct snd_kcontrol_new alc882_targa_mixer[] = {
7476 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7477 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7478 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7479 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7480 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7481 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7482 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7483 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7484 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007485 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007486 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7487 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007488 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007489 { } /* end */
7490};
7491
7492/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7493 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7494 */
7495static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7496 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7497 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7498 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7499 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7500 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7501 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7502 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7503 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7504 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7505 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7507 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007508 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007509 { } /* end */
7510};
7511
Takashi Iwai914759b2007-09-06 14:52:04 +02007512static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7513 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7514 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7515 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7516 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7517 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7518 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7519 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7520 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7521 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7522 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007523 { } /* end */
7524};
7525
Kailang Yangdf694da2005-12-05 19:42:22 +01007526static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7527 {
7528 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7529 .name = "Channel Mode",
7530 .info = alc_ch_mode_info,
7531 .get = alc_ch_mode_get,
7532 .put = alc_ch_mode_put,
7533 },
7534 { } /* end */
7535};
7536
Takashi Iwai4953550a2009-06-30 15:28:30 +02007537static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007538 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007539 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007541 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007542 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7543 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007544 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007545 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7546 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007547 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007548 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7549 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007550
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007551 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007552 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007553 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007554 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007555 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007556 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007557 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007558 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007559 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007560 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007561 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007562 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007563 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007564 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007565 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007566 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007567 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007568 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007569 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7570 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007571 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007572 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7573 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007574 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007575 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7576 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7577 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7578 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7579 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007580 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007581 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007582
7583 /* FIXME: use matrix-type input source selection */
7584 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007585 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007586 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007587 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007588 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007589 /* ADC2: mute amp left and right */
7590 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007591 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007592 /* ADC3: mute amp left and right */
7593 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007594 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007595
7596 { }
7597};
7598
Takashi Iwai4953550a2009-06-30 15:28:30 +02007599static struct hda_verb alc882_adc1_init_verbs[] = {
7600 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7601 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7602 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7603 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7604 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7605 /* ADC1: mute amp left and right */
7606 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7607 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7608 { }
7609};
7610
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007611static struct hda_verb alc882_eapd_verbs[] = {
7612 /* change to EAPD mode */
7613 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007614 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007615 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007616};
7617
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007618static struct hda_verb alc889_eapd_verbs[] = {
7619 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7620 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7621 { }
7622};
7623
Wu Fengguang6732bd02009-07-30 09:19:14 +02007624static struct hda_verb alc_hp15_unsol_verbs[] = {
7625 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7626 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7627 {}
7628};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007629
7630static struct hda_verb alc885_init_verbs[] = {
7631 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007632 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7633 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007634 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007635 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7636 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007637 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007638 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7639 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007640 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007641 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7642 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007643
7644 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007645 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7647 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7648 /* Front Pin: output 0 (0x0c) */
7649 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7650 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7651 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7652 /* Rear Pin: output 1 (0x0d) */
7653 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7654 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7655 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7656 /* CLFE Pin: output 2 (0x0e) */
7657 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7658 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7659 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7660 /* Side Pin: output 3 (0x0f) */
7661 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7662 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7663 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7664 /* Mic (rear) pin: input vref at 80% */
7665 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7666 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7667 /* Front Mic pin: input vref at 80% */
7668 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7669 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7670 /* Line In pin: input */
7671 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7672 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7673
7674 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7675 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007676 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007677 /* Input mixer2 */
7678 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007679 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007680 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007681 /* ADC2: mute amp left and right */
7682 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7683 /* ADC3: mute amp left and right */
7684 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7685
7686 { }
7687};
7688
7689static struct hda_verb alc885_init_input_verbs[] = {
7690 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7691 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7692 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7693 { }
7694};
7695
7696
7697/* Unmute Selector 24h and set the default input to front mic */
7698static struct hda_verb alc889_init_input_verbs[] = {
7699 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7700 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7701 { }
7702};
7703
7704
Takashi Iwai4953550a2009-06-30 15:28:30 +02007705#define alc883_init_verbs alc882_base_init_verbs
7706
Tobin Davis9102cd12006-12-15 10:02:12 +01007707/* Mac Pro test */
7708static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7709 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7710 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7711 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7712 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7713 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007714 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007715 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7716 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007717 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007718 { } /* end */
7719};
7720
7721static struct hda_verb alc882_macpro_init_verbs[] = {
7722 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7723 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7725 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7726 /* Front Pin: output 0 (0x0c) */
7727 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7728 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7729 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7730 /* Front Mic pin: input vref at 80% */
7731 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7732 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7733 /* Speaker: output */
7734 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7735 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7736 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7737 /* Headphone output (output 0 - 0x0c) */
7738 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7739 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7740 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7741
7742 /* FIXME: use matrix-type input source selection */
7743 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7744 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7745 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7746 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7747 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7748 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7749 /* Input mixer2 */
7750 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7751 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7752 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7753 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7754 /* Input mixer3 */
7755 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7756 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7757 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7758 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7759 /* ADC1: mute amp left and right */
7760 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7761 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7762 /* ADC2: mute amp left and right */
7763 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7764 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7765 /* ADC3: mute amp left and right */
7766 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7767 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7768
7769 { }
7770};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007771
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007772/* Macbook 5,1 */
7773static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007774 /* DACs */
7775 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7776 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7777 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7778 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007779 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007780 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7781 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7782 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007783 /* Surround mixer */
7784 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7785 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7786 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7787 /* LFE mixer */
7788 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7789 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7790 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7791 /* HP mixer */
7792 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7793 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7794 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7795 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007796 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7797 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007798 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7799 /* LFE Pin (0x0e) */
7800 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7801 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7802 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7803 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007804 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7805 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007806 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10307807 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007808 /* Front Mic pin: input vref at 80% */
7809 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7810 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7811 /* Line In pin */
7812 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7813 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7814
7815 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7816 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7817 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7818 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7819 { }
7820};
7821
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007822/* Macmini 3,1 */
7823static struct hda_verb alc885_macmini3_init_verbs[] = {
7824 /* DACs */
7825 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7826 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7827 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7828 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7829 /* Front mixer */
7830 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7831 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7832 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7833 /* Surround mixer */
7834 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7835 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7836 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7837 /* LFE mixer */
7838 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7839 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7840 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7841 /* HP mixer */
7842 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7843 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7844 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7845 /* Front Pin (0x0c) */
7846 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7847 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7848 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7849 /* LFE Pin (0x0e) */
7850 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7851 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7852 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7853 /* HP Pin (0x0f) */
7854 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7855 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7856 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
7857 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7858 /* Line In pin */
7859 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7860 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7861
7862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7864 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7865 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7866 { }
7867};
7868
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007869
7870static struct hda_verb alc885_mba21_init_verbs[] = {
7871 /*Internal and HP Speaker Mixer*/
7872 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7873 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7874 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7875 /*Internal Speaker Pin (0x0c)*/
7876 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
7877 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7878 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7879 /* HP Pin: output 0 (0x0e) */
7880 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7881 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7882 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7883 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
7884 /* Line in (is hp when jack connected)*/
7885 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
7886 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7887
7888 { }
7889 };
7890
7891
Takashi Iwai87350ad2007-08-16 18:19:38 +02007892/* Macbook Pro rev3 */
7893static struct hda_verb alc885_mbp3_init_verbs[] = {
7894 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7895 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7896 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7897 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7898 /* Rear mixer */
7899 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7900 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7901 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007902 /* HP mixer */
7903 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7904 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7905 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007906 /* Front Pin: output 0 (0x0c) */
7907 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7909 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007910 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007911 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007912 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7913 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007914 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7915 /* Mic (rear) pin: input vref at 80% */
7916 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7917 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7918 /* Front Mic pin: input vref at 80% */
7919 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7920 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7921 /* Line In pin: use output 1 when in LineOut mode */
7922 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7923 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7924 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7925
7926 /* FIXME: use matrix-type input source selection */
7927 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7928 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7929 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7930 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7931 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7932 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7933 /* Input mixer2 */
7934 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7935 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7936 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7937 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7938 /* Input mixer3 */
7939 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7940 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7941 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7942 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7943 /* ADC1: mute amp left and right */
7944 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7945 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7946 /* ADC2: mute amp left and right */
7947 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7948 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7949 /* ADC3: mute amp left and right */
7950 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7951 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7952
7953 { }
7954};
7955
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007956/* iMac 9,1 */
7957static struct hda_verb alc885_imac91_init_verbs[] = {
7958 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7959 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7960 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7961 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7962 /* Rear mixer */
7963 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7964 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7965 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7966 /* HP Pin: output 0 (0x0c) */
7967 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7968 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7969 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7970 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7971 /* Internal Speakers: output 0 (0x0d) */
7972 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7973 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7974 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7975 /* Mic (rear) pin: input vref at 80% */
7976 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7977 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7978 /* Front Mic pin: input vref at 80% */
7979 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7980 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7981 /* Line In pin: use output 1 when in LineOut mode */
7982 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7983 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7984 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7985
7986 /* FIXME: use matrix-type input source selection */
7987 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7988 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7989 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7990 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7991 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7992 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7993 /* Input mixer2 */
7994 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7995 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7996 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7997 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7998 /* Input mixer3 */
7999 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8000 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8001 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8002 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8003 /* ADC1: mute amp left and right */
8004 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8005 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8006 /* ADC2: mute amp left and right */
8007 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8008 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8009 /* ADC3: mute amp left and right */
8010 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8011 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8012
8013 { }
8014};
8015
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008016/* iMac 24 mixer. */
8017static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8018 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8019 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8020 { } /* end */
8021};
8022
8023/* iMac 24 init verbs. */
8024static struct hda_verb alc885_imac24_init_verbs[] = {
8025 /* Internal speakers: output 0 (0x0c) */
8026 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8027 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8028 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8029 /* Internal speakers: output 0 (0x0c) */
8030 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8031 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8032 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8033 /* Headphone: output 0 (0x0c) */
8034 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8035 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8036 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8037 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8038 /* Front Mic: input vref at 80% */
8039 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8040 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8041 { }
8042};
8043
8044/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008045static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008046{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008047 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008048
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008049 spec->autocfg.hp_pins[0] = 0x14;
8050 spec->autocfg.speaker_pins[0] = 0x18;
8051 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008052}
8053
Takashi Iwai9d54f082010-02-22 08:34:40 +01008054#define alc885_mb5_setup alc885_imac24_setup
8055#define alc885_macmini3_setup alc885_imac24_setup
8056
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008057/* Macbook Air 2,1 */
8058static void alc885_mba21_setup(struct hda_codec *codec)
8059{
8060 struct alc_spec *spec = codec->spec;
8061
8062 spec->autocfg.hp_pins[0] = 0x14;
8063 spec->autocfg.speaker_pins[0] = 0x18;
8064}
8065
8066
8067
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008068static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008069{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008070 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008071
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008072 spec->autocfg.hp_pins[0] = 0x15;
8073 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008074}
8075
Takashi Iwai9d54f082010-02-22 08:34:40 +01008076static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308077{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008078 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308079
Takashi Iwai9d54f082010-02-22 08:34:40 +01008080 spec->autocfg.hp_pins[0] = 0x14;
8081 spec->autocfg.speaker_pins[0] = 0x15;
8082 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008083}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008084
Kailang Yang272a5272007-05-14 11:00:38 +02008085static struct hda_verb alc882_targa_verbs[] = {
8086 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8087 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8088
8089 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8090 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008091
Kailang Yang272a5272007-05-14 11:00:38 +02008092 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8093 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8094 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8095
8096 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008097 { } /* end */
8098};
8099
8100/* toggle speaker-output according to the hp-jack state */
8101static void alc882_targa_automute(struct hda_codec *codec)
8102{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008103 struct alc_spec *spec = codec->spec;
8104 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008105 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008106 spec->jack_present ? 1 : 3);
8107}
8108
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008109static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008110{
8111 struct alc_spec *spec = codec->spec;
8112
8113 spec->autocfg.hp_pins[0] = 0x14;
8114 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008115}
8116
8117static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8118{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008119 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008120 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008121}
8122
8123static struct hda_verb alc882_asus_a7j_verbs[] = {
8124 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8125 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8126
8127 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8128 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8129 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008130
Kailang Yang272a5272007-05-14 11:00:38 +02008131 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8132 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8133 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8134
8135 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8136 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8137 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8138 { } /* end */
8139};
8140
Takashi Iwai914759b2007-09-06 14:52:04 +02008141static struct hda_verb alc882_asus_a7m_verbs[] = {
8142 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8143 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8144
8145 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8146 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8147 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008148
Takashi Iwai914759b2007-09-06 14:52:04 +02008149 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8150 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8151 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8152
8153 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8154 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8155 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8156 { } /* end */
8157};
8158
Tobin Davis9102cd12006-12-15 10:02:12 +01008159static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8160{
8161 unsigned int gpiostate, gpiomask, gpiodir;
8162
8163 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8164 AC_VERB_GET_GPIO_DATA, 0);
8165
8166 if (!muted)
8167 gpiostate |= (1 << pin);
8168 else
8169 gpiostate &= ~(1 << pin);
8170
8171 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8172 AC_VERB_GET_GPIO_MASK, 0);
8173 gpiomask |= (1 << pin);
8174
8175 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8176 AC_VERB_GET_GPIO_DIRECTION, 0);
8177 gpiodir |= (1 << pin);
8178
8179
8180 snd_hda_codec_write(codec, codec->afg, 0,
8181 AC_VERB_SET_GPIO_MASK, gpiomask);
8182 snd_hda_codec_write(codec, codec->afg, 0,
8183 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8184
8185 msleep(1);
8186
8187 snd_hda_codec_write(codec, codec->afg, 0,
8188 AC_VERB_SET_GPIO_DATA, gpiostate);
8189}
8190
Takashi Iwai7debbe52007-08-16 15:01:03 +02008191/* set up GPIO at initialization */
8192static void alc885_macpro_init_hook(struct hda_codec *codec)
8193{
8194 alc882_gpio_mute(codec, 0, 0);
8195 alc882_gpio_mute(codec, 1, 0);
8196}
8197
8198/* set up GPIO and update auto-muting at initialization */
8199static void alc885_imac24_init_hook(struct hda_codec *codec)
8200{
8201 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008202 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008203}
8204
Kailang Yangdf694da2005-12-05 19:42:22 +01008205/*
8206 * generic initialization of ADC, input mixers and output mixers
8207 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008208static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008209 /*
8210 * Unmute ADC0-2 and set the default input to mic-in
8211 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008212 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8213 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8214 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8215 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8216
Kailang Yangdf694da2005-12-05 19:42:22 +01008217 /*
8218 * Set up output mixers (0x0c - 0x0f)
8219 */
8220 /* set vol=0 to output mixers */
8221 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8222 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8223 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8224 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8225 /* set up input amps for analog loopback */
8226 /* Amp Indices: DAC = 0, mixer = 1 */
8227 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8228 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8229 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8230 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8231 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8232 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8233 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8234 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8235 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8236 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8237
8238 /* FIXME: use matrix-type input source selection */
8239 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008240 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008241 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008242 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008243 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008244 { }
8245};
8246
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008247/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8248static struct hda_verb alc889A_mb31_ch2_init[] = {
8249 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8250 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8251 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8252 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8253 { } /* end */
8254};
8255
8256/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8257static struct hda_verb alc889A_mb31_ch4_init[] = {
8258 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8259 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8260 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8261 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8262 { } /* end */
8263};
8264
8265/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8266static struct hda_verb alc889A_mb31_ch5_init[] = {
8267 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8268 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8269 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8270 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8271 { } /* end */
8272};
8273
8274/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8275static struct hda_verb alc889A_mb31_ch6_init[] = {
8276 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8277 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8278 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8279 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8280 { } /* end */
8281};
8282
8283static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8284 { 2, alc889A_mb31_ch2_init },
8285 { 4, alc889A_mb31_ch4_init },
8286 { 5, alc889A_mb31_ch5_init },
8287 { 6, alc889A_mb31_ch6_init },
8288};
8289
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008290static struct hda_verb alc883_medion_eapd_verbs[] = {
8291 /* eanable EAPD on medion laptop */
8292 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8293 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8294 { }
8295};
8296
Takashi Iwai4953550a2009-06-30 15:28:30 +02008297#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008298
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008299static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8300 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8301 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8302 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8303 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8304 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8305 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8306 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8307 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8308 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8309 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8310 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8311 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8312 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008313 { } /* end */
8314};
8315
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008316static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008317 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8318 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8319 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8320 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8321 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8322 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8323 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8324 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8325 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8326 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008327 { } /* end */
8328};
8329
Jiang zhefb97dc62008-03-06 11:07:11 +01008330static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8331 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8332 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8333 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8334 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8336 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8337 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8338 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8339 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8340 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008341 { } /* end */
8342};
8343
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008344static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8345 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8346 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8347 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8348 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8349 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8350 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8351 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8352 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008353 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008354 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8355 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008356 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008357 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008358 { } /* end */
8359};
8360
8361static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8362 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8363 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8364 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8365 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8366 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8367 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8368 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8369 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8370 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8371 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8372 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8373 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8374 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8375 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008376 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008377 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8378 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008379 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008380 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008381 { } /* end */
8382};
8383
Jiang zhe17bba1b2008-06-04 12:11:07 +02008384static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8385 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8386 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8387 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8388 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8389 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8390 HDA_OUTPUT),
8391 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8392 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8393 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8394 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8395 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8396 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8397 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8398 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8399 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8400 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8401 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8402 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8403 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8404 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008405 { } /* end */
8406};
8407
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008408static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8409 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8410 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8411 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8412 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8413 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8414 HDA_OUTPUT),
8415 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8416 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8417 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8418 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8419 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8420 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8421 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8422 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8423 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8424 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8425 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8426 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8427 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8428 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8429 { } /* end */
8430};
8431
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008432static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008433 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008434 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008435 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008436 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008437 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8438 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008439 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8440 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008441 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8442 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8443 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8444 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8445 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8446 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008447 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008448 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8449 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008450 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008451 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008452 { } /* end */
8453};
8454
Sasha Alexandrc2592492009-06-16 14:52:54 -04008455static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008456 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008457 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008458 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008459 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008460 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8461 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8462 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8463 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8464 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8465 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8466 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8467 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8468 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8469 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8470 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008471 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008472 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008473 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008474};
Kailang Yangccc656c2006-10-17 12:32:26 +02008475
Sasha Alexandrc2592492009-06-16 14:52:54 -04008476static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008477 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008478 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008479 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008480 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008481 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8482 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8483 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008484 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008485 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008486 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8487 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8488 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008489 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008490};
Kailang Yangccc656c2006-10-17 12:32:26 +02008491
Takashi Iwaib99dba32009-09-17 18:23:00 +02008492static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8493 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8494 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8495 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8496 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8497 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8498 { } /* end */
8499};
8500
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008501static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8502 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8503 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008504 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8505 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008506 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8507 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8508 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8509 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008510 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008511};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008512
Kailang Yang272a5272007-05-14 11:00:38 +02008513static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8514 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8515 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8516 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8517 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8518 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8519 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8520 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8521 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8522 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008523 { } /* end */
8524};
8525
8526static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8527 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8528 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8529 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8530 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8531 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8532 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8533 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8534 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8535 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008536 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008537};
Kailang Yang272a5272007-05-14 11:00:38 +02008538
Tobin Davis2880a862007-08-07 11:50:26 +02008539static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008540 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8541 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008542 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008543 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8544 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8546 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8547 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008548 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008549};
Tobin Davis2880a862007-08-07 11:50:26 +02008550
Tony Vroond2fd4b02009-06-21 00:40:10 +01008551static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8552 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8553 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8554 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8555 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008556 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8557 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008558 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8559 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8560 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8561 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8562 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8563 { } /* end */
8564};
8565
Kailang Yange2757d52008-08-26 13:17:46 +02008566static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8567 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8568 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8569 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8570 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8571 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8572 0x0d, 1, 0x0, HDA_OUTPUT),
8573 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8574 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8575 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8576 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8577 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008578 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8579 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8580 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8581 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8582 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8583 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8584 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8585 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8586 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8587 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008588 { } /* end */
8589};
8590
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008591static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8592 /* Output mixers */
8593 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8594 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8595 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8596 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8597 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8598 HDA_OUTPUT),
8599 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8600 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8601 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8602 /* Output switches */
8603 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8604 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8605 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8606 /* Boost mixers */
8607 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8608 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8609 /* Input mixers */
8610 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8611 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8612 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8613 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8614 { } /* end */
8615};
8616
Guido Günther3e1647c2009-06-05 00:47:26 +02008617static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8618 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8619 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8620 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8621 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8622 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8623 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8624 { } /* end */
8625};
8626
Kailang Yange2757d52008-08-26 13:17:46 +02008627static struct hda_bind_ctls alc883_bind_cap_vol = {
8628 .ops = &snd_hda_bind_vol,
8629 .values = {
8630 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8631 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8632 0
8633 },
8634};
8635
8636static struct hda_bind_ctls alc883_bind_cap_switch = {
8637 .ops = &snd_hda_bind_sw,
8638 .values = {
8639 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8640 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8641 0
8642 },
8643};
8644
8645static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8646 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8647 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8648 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8649 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8650 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8651 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8652 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8653 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008654 { } /* end */
8655};
8656
8657static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008658 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8659 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8660 {
8661 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8662 /* .name = "Capture Source", */
8663 .name = "Input Source",
8664 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008665 .info = alc_mux_enum_info,
8666 .get = alc_mux_enum_get,
8667 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008668 },
8669 { } /* end */
8670};
8671
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008672static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8673 {
8674 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8675 .name = "Channel Mode",
8676 .info = alc_ch_mode_info,
8677 .get = alc_ch_mode_get,
8678 .put = alc_ch_mode_put,
8679 },
8680 { } /* end */
8681};
8682
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008683/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008684static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008685{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008686 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008687
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008688 spec->autocfg.hp_pins[0] = 0x15;
8689 spec->autocfg.speaker_pins[0] = 0x14;
8690 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008691}
8692
8693/* auto-toggle front mic */
8694/*
8695static void alc883_mitac_mic_automute(struct hda_codec *codec)
8696{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008697 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008698
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008699 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8700}
8701*/
8702
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008703static struct hda_verb alc883_mitac_verbs[] = {
8704 /* HP */
8705 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8706 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8707 /* Subwoofer */
8708 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8709 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8710
8711 /* enable unsolicited event */
8712 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8713 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8714
8715 { } /* end */
8716};
8717
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308718static struct hda_verb alc883_clevo_m540r_verbs[] = {
8719 /* HP */
8720 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8721 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8722 /* Int speaker */
8723 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8724
8725 /* enable unsolicited event */
8726 /*
8727 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8728 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8729 */
8730
8731 { } /* end */
8732};
8733
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008734static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008735 /* HP */
8736 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8737 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8738 /* Int speaker */
8739 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8740 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8741
8742 /* enable unsolicited event */
8743 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008744 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008745
8746 { } /* end */
8747};
8748
Jiang zhefb97dc62008-03-06 11:07:11 +01008749static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8750 /* HP */
8751 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8752 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8753 /* Subwoofer */
8754 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8755 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8756
8757 /* enable unsolicited event */
8758 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8759
8760 { } /* end */
8761};
8762
Sasha Alexandrc2592492009-06-16 14:52:54 -04008763static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008764 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8765 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8766
8767 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8768 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008769
David Heidelberger64a8be72009-06-08 16:15:18 +02008770/* Connect Line-Out side jack (SPDIF) to Side */
8771 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8772 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8773 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8774/* Connect Mic jack to CLFE */
8775 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8776 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8777 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8778/* Connect Line-in jack to Surround */
8779 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8780 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8781 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8782/* Connect HP out jack to Front */
8783 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8784 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8785 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008786
8787 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008788
8789 { } /* end */
8790};
8791
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008792static struct hda_verb alc883_lenovo_101e_verbs[] = {
8793 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8794 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8795 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8796 { } /* end */
8797};
8798
Kailang Yang272a5272007-05-14 11:00:38 +02008799static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8800 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8801 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8802 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8803 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8804 { } /* end */
8805};
8806
8807static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8808 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8809 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8810 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8811 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8812 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8813 { } /* end */
8814};
8815
Kailang Yang189609a2007-08-20 11:31:23 +02008816static struct hda_verb alc883_haier_w66_verbs[] = {
8817 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8818 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8819
8820 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8821
8822 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8823 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8824 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8825 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8826 { } /* end */
8827};
8828
Kailang Yange2757d52008-08-26 13:17:46 +02008829static struct hda_verb alc888_lenovo_sky_verbs[] = {
8830 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8831 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8832 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8833 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8834 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8835 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8836 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8837 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8838 { } /* end */
8839};
8840
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008841static struct hda_verb alc888_6st_dell_verbs[] = {
8842 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8843 { }
8844};
8845
Guido Günther3e1647c2009-06-05 00:47:26 +02008846static struct hda_verb alc883_vaiott_verbs[] = {
8847 /* HP */
8848 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8849 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8850
8851 /* enable unsolicited event */
8852 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8853
8854 { } /* end */
8855};
8856
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008857static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008858{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008859 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008860
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008861 spec->autocfg.hp_pins[0] = 0x1b;
8862 spec->autocfg.speaker_pins[0] = 0x14;
8863 spec->autocfg.speaker_pins[1] = 0x16;
8864 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008865}
8866
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008867static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008868 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008869 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8870 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008871 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008872 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008873};
8874
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008875/*
8876 * 2ch mode
8877 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008878static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008879 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8880 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8881 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8882 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008883 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008884};
8885
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008886/*
8887 * 4ch mode
8888 */
8889static struct hda_verb alc888_3st_hp_4ch_init[] = {
8890 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8891 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8892 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8893 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8894 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8895 { } /* end */
8896};
8897
8898/*
8899 * 6ch mode
8900 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008901static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008902 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8903 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008904 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008905 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8906 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008907 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8908 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008909};
8910
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008911static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008912 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008913 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008914 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008915};
8916
Kailang Yang272a5272007-05-14 11:00:38 +02008917/* toggle front-jack and RCA according to the hp-jack state */
8918static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8919{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008920 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008921
Takashi Iwai47fd8302007-08-10 17:11:07 +02008922 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8923 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8924 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8925 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008926}
8927
8928/* toggle RCA according to the front-jack state */
8929static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8930{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008931 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008932
Takashi Iwai47fd8302007-08-10 17:11:07 +02008933 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8934 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008935}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008936
Kailang Yang272a5272007-05-14 11:00:38 +02008937static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8938 unsigned int res)
8939{
8940 if ((res >> 26) == ALC880_HP_EVENT)
8941 alc888_lenovo_ms7195_front_automute(codec);
8942 if ((res >> 26) == ALC880_FRONT_EVENT)
8943 alc888_lenovo_ms7195_rca_automute(codec);
8944}
8945
8946static struct hda_verb alc883_medion_md2_verbs[] = {
8947 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8948 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8949
8950 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8951
8952 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8953 { } /* end */
8954};
8955
8956/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008957static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008958{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008959 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008960
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008961 spec->autocfg.hp_pins[0] = 0x14;
8962 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008963}
8964
Kailang Yangccc656c2006-10-17 12:32:26 +02008965/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008966#define alc883_targa_init_hook alc882_targa_init_hook
8967#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008968
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008969static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8970{
8971 unsigned int present;
8972
Takashi Iwaid56757a2009-11-18 08:00:14 +01008973 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008974 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8975 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8976}
8977
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008978static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008979{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008980 struct alc_spec *spec = codec->spec;
8981
8982 spec->autocfg.hp_pins[0] = 0x15;
8983 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008984}
8985
8986static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8987{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008988 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008989 alc883_clevo_m720_mic_automute(codec);
8990}
8991
8992static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008993 unsigned int res)
8994{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008995 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008996 case ALC880_MIC_EVENT:
8997 alc883_clevo_m720_mic_automute(codec);
8998 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008999 default:
9000 alc_automute_amp_unsol_event(codec, res);
9001 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009002 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009003}
9004
Jiang zhefb97dc62008-03-06 11:07:11 +01009005/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009006static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009007{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009008 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009009
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009010 spec->autocfg.hp_pins[0] = 0x14;
9011 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009012}
9013
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009014static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009015{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009016 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009017
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009018 spec->autocfg.hp_pins[0] = 0x1b;
9019 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009020}
9021
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009022static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9023{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009024 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009025
Takashi Iwai47fd8302007-08-10 17:11:07 +02009026 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9027 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009028}
9029
9030static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9031{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009032 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009033
Takashi Iwai47fd8302007-08-10 17:11:07 +02009034 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9035 HDA_AMP_MUTE, bits);
9036 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9037 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009038}
9039
9040static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9041 unsigned int res)
9042{
9043 if ((res >> 26) == ALC880_HP_EVENT)
9044 alc883_lenovo_101e_all_automute(codec);
9045 if ((res >> 26) == ALC880_FRONT_EVENT)
9046 alc883_lenovo_101e_ispeaker_automute(codec);
9047}
9048
Takashi Iwai676a9b52007-08-16 15:23:35 +02009049/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009050static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009051{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009052 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009053
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009054 spec->autocfg.hp_pins[0] = 0x14;
9055 spec->autocfg.speaker_pins[0] = 0x15;
9056 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009057}
9058
Kailang Yangd1a991a2007-08-15 16:21:59 +02009059static struct hda_verb alc883_acer_eapd_verbs[] = {
9060 /* HP Pin: output 0 (0x0c) */
9061 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9062 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9063 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9064 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009065 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9066 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009067 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009068 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9069 /* eanable EAPD on medion laptop */
9070 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9071 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009072 /* enable unsolicited event */
9073 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009074 { }
9075};
9076
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009077static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
9078 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9079 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9080 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9081 { } /* end */
9082};
9083
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009084static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009085{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009086 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009087
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009088 spec->autocfg.hp_pins[0] = 0x1b;
9089 spec->autocfg.speaker_pins[0] = 0x14;
9090 spec->autocfg.speaker_pins[1] = 0x15;
9091 spec->autocfg.speaker_pins[2] = 0x16;
9092 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009093}
9094
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009095static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009096{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009097 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009098
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009099 spec->autocfg.hp_pins[0] = 0x1b;
9100 spec->autocfg.speaker_pins[0] = 0x14;
9101 spec->autocfg.speaker_pins[1] = 0x15;
9102 spec->autocfg.speaker_pins[2] = 0x16;
9103 spec->autocfg.speaker_pins[3] = 0x17;
9104 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009105}
9106
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009107static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009108{
9109 struct alc_spec *spec = codec->spec;
9110
9111 spec->autocfg.hp_pins[0] = 0x15;
9112 spec->autocfg.speaker_pins[0] = 0x14;
9113 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009114}
9115
Kailang Yange2757d52008-08-26 13:17:46 +02009116static struct hda_verb alc888_asus_m90v_verbs[] = {
9117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9118 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9119 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9120 /* enable unsolicited event */
9121 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9122 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9123 { } /* end */
9124};
9125
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009126static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009127{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009128 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009129
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009130 spec->autocfg.hp_pins[0] = 0x1b;
9131 spec->autocfg.speaker_pins[0] = 0x14;
9132 spec->autocfg.speaker_pins[1] = 0x15;
9133 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009134 spec->ext_mic.pin = 0x18;
9135 spec->int_mic.pin = 0x19;
9136 spec->ext_mic.mux_idx = 0;
9137 spec->int_mic.mux_idx = 1;
9138 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009139}
9140
9141static struct hda_verb alc888_asus_eee1601_verbs[] = {
9142 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9143 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9144 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9145 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9146 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9147 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9148 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9149 /* enable unsolicited event */
9150 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9151 { } /* end */
9152};
9153
Kailang Yange2757d52008-08-26 13:17:46 +02009154static void alc883_eee1601_inithook(struct hda_codec *codec)
9155{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009156 struct alc_spec *spec = codec->spec;
9157
9158 spec->autocfg.hp_pins[0] = 0x14;
9159 spec->autocfg.speaker_pins[0] = 0x1b;
9160 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009161}
9162
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009163static struct hda_verb alc889A_mb31_verbs[] = {
9164 /* Init rear pin (used as headphone output) */
9165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9166 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9167 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9168 /* Init line pin (used as output in 4ch and 6ch mode) */
9169 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9170 /* Init line 2 pin (used as headphone out by default) */
9171 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9172 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9173 { } /* end */
9174};
9175
9176/* Mute speakers according to the headphone jack state */
9177static void alc889A_mb31_automute(struct hda_codec *codec)
9178{
9179 unsigned int present;
9180
9181 /* Mute only in 2ch or 4ch mode */
9182 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9183 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009184 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009185 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9186 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9187 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9188 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9189 }
9190}
9191
9192static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9193{
9194 if ((res >> 26) == ALC880_HP_EVENT)
9195 alc889A_mb31_automute(codec);
9196}
9197
Takashi Iwai4953550a2009-06-30 15:28:30 +02009198
Takashi Iwaicb53c622007-08-10 17:21:45 +02009199#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009200#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009201#endif
9202
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009203/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009204#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9205#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9206#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9207#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9208
9209static hda_nid_t alc883_slave_dig_outs[] = {
9210 ALC1200_DIGOUT_NID, 0,
9211};
9212
9213static hda_nid_t alc1200_slave_dig_outs[] = {
9214 ALC883_DIGOUT_NID, 0,
9215};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009216
9217/*
9218 * configuration and preset
9219 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009220static const char *alc882_models[ALC882_MODEL_LAST] = {
9221 [ALC882_3ST_DIG] = "3stack-dig",
9222 [ALC882_6ST_DIG] = "6stack-dig",
9223 [ALC882_ARIMA] = "arima",
9224 [ALC882_W2JC] = "w2jc",
9225 [ALC882_TARGA] = "targa",
9226 [ALC882_ASUS_A7J] = "asus-a7j",
9227 [ALC882_ASUS_A7M] = "asus-a7m",
9228 [ALC885_MACPRO] = "macpro",
9229 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009230 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009231 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009232 [ALC885_MBP3] = "mbp3",
9233 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009234 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009235 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009236 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9237 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009238 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009239 [ALC883_TARGA_DIG] = "targa-dig",
9240 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009241 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009242 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009243 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009244 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009245 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009246 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009247 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009248 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009249 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009250 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009251 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009252 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9253 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009254 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009255 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009256 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009257 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009258 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309259 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009260 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009261 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009262 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009263 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009264 [ALC889A_INTEL] = "intel-alc889a",
9265 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009266 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009267 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009268 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009269 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009270};
9271
Takashi Iwai4953550a2009-06-30 15:28:30 +02009272static struct snd_pci_quirk alc882_cfg_tbl[] = {
9273 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9274
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009275 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009276 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009277 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009278 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9279 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009280 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009281 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9282 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009283 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009284 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009285 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9286 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009287 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9288 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009289 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9290 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009291 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009292 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009293 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009294 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009295 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9296 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009297 /* default Acer -- disabled as it causes more problems.
9298 * model=auto should work fine now
9299 */
9300 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009301
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009302 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009303
Tobin Davisfebe3372007-06-12 11:27:46 +02009304 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009305 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9306 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009307 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009308 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009309 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009310
9311 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9312 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9313 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009314 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009315 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9316 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9317 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009318 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009319 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009320 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009321 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009322
9323 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009324 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009325 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009326 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009327 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9328 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009329 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009330 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009331 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9332
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009333 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9334 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9335 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009336 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009337 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009338 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009339 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009340 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009341 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9342 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9343 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9344 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9345 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9346 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009347 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009348 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9349 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9350 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009351 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009352 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009353 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9354 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009355 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009356 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009357 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009358 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009359 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009360 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009361 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009362 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009363 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009364
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009365 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009366 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9367 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309368 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009369 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009370 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009371 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009372 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009373 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009374 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009375 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009376 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009377 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009378 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009379 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9380 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009381 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009382 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009383 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009384 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009385 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009386
Jiang zhe17bba1b2008-06-04 12:11:07 +02009387 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9388 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009389 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009390 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9391 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9392 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009393 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009394
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009395 {}
9396};
9397
Takashi Iwai4953550a2009-06-30 15:28:30 +02009398/* codec SSID table for Intel Mac */
9399static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9400 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9401 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9402 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9403 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9404 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9405 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9406 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
9407 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9408 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9409 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009410 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009411 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009412 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9413 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009414 */
9415 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009416 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009417 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009418 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009419};
9420
Takashi Iwai4953550a2009-06-30 15:28:30 +02009421static struct alc_config_preset alc882_presets[] = {
9422 [ALC882_3ST_DIG] = {
9423 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009424 .init_verbs = { alc882_base_init_verbs,
9425 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009426 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9427 .dac_nids = alc882_dac_nids,
9428 .dig_out_nid = ALC882_DIGOUT_NID,
9429 .dig_in_nid = ALC882_DIGIN_NID,
9430 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9431 .channel_mode = alc882_ch_modes,
9432 .need_dac_fix = 1,
9433 .input_mux = &alc882_capture_source,
9434 },
9435 [ALC882_6ST_DIG] = {
9436 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009437 .init_verbs = { alc882_base_init_verbs,
9438 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009439 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9440 .dac_nids = alc882_dac_nids,
9441 .dig_out_nid = ALC882_DIGOUT_NID,
9442 .dig_in_nid = ALC882_DIGIN_NID,
9443 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9444 .channel_mode = alc882_sixstack_modes,
9445 .input_mux = &alc882_capture_source,
9446 },
9447 [ALC882_ARIMA] = {
9448 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009449 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9450 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009451 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9452 .dac_nids = alc882_dac_nids,
9453 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9454 .channel_mode = alc882_sixstack_modes,
9455 .input_mux = &alc882_capture_source,
9456 },
9457 [ALC882_W2JC] = {
9458 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009459 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9460 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009461 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9462 .dac_nids = alc882_dac_nids,
9463 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9464 .channel_mode = alc880_threestack_modes,
9465 .need_dac_fix = 1,
9466 .input_mux = &alc882_capture_source,
9467 .dig_out_nid = ALC882_DIGOUT_NID,
9468 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009469 [ALC885_MBA21] = {
9470 .mixers = { alc885_mba21_mixer },
9471 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9472 .num_dacs = 2,
9473 .dac_nids = alc882_dac_nids,
9474 .channel_mode = alc885_mba21_ch_modes,
9475 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9476 .input_mux = &alc882_capture_source,
9477 .unsol_event = alc_automute_amp_unsol_event,
9478 .setup = alc885_mba21_setup,
9479 .init_hook = alc_automute_amp,
9480 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009481 [ALC885_MBP3] = {
9482 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9483 .init_verbs = { alc885_mbp3_init_verbs,
9484 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009485 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009486 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009487 .hp_nid = 0x04,
9488 .channel_mode = alc885_mbp_4ch_modes,
9489 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009490 .input_mux = &alc882_capture_source,
9491 .dig_out_nid = ALC882_DIGOUT_NID,
9492 .dig_in_nid = ALC882_DIGIN_NID,
9493 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009494 .setup = alc885_mbp3_setup,
9495 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009496 },
9497 [ALC885_MB5] = {
9498 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9499 .init_verbs = { alc885_mb5_init_verbs,
9500 alc880_gpio1_init_verbs },
9501 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9502 .dac_nids = alc882_dac_nids,
9503 .channel_mode = alc885_mb5_6ch_modes,
9504 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9505 .input_mux = &mb5_capture_source,
9506 .dig_out_nid = ALC882_DIGOUT_NID,
9507 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009508 .unsol_event = alc_automute_amp_unsol_event,
9509 .setup = alc885_mb5_setup,
9510 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009511 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009512 [ALC885_MACMINI3] = {
9513 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9514 .init_verbs = { alc885_macmini3_init_verbs,
9515 alc880_gpio1_init_verbs },
9516 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9517 .dac_nids = alc882_dac_nids,
9518 .channel_mode = alc885_macmini3_6ch_modes,
9519 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9520 .input_mux = &macmini3_capture_source,
9521 .dig_out_nid = ALC882_DIGOUT_NID,
9522 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009523 .unsol_event = alc_automute_amp_unsol_event,
9524 .setup = alc885_macmini3_setup,
9525 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009526 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009527 [ALC885_MACPRO] = {
9528 .mixers = { alc882_macpro_mixer },
9529 .init_verbs = { alc882_macpro_init_verbs },
9530 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9531 .dac_nids = alc882_dac_nids,
9532 .dig_out_nid = ALC882_DIGOUT_NID,
9533 .dig_in_nid = ALC882_DIGIN_NID,
9534 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9535 .channel_mode = alc882_ch_modes,
9536 .input_mux = &alc882_capture_source,
9537 .init_hook = alc885_macpro_init_hook,
9538 },
9539 [ALC885_IMAC24] = {
9540 .mixers = { alc885_imac24_mixer },
9541 .init_verbs = { alc885_imac24_init_verbs },
9542 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9543 .dac_nids = alc882_dac_nids,
9544 .dig_out_nid = ALC882_DIGOUT_NID,
9545 .dig_in_nid = ALC882_DIGIN_NID,
9546 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9547 .channel_mode = alc882_ch_modes,
9548 .input_mux = &alc882_capture_source,
9549 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009550 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009551 .init_hook = alc885_imac24_init_hook,
9552 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009553 [ALC885_IMAC91] = {
9554 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9555 .init_verbs = { alc885_imac91_init_verbs,
9556 alc880_gpio1_init_verbs },
9557 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9558 .dac_nids = alc882_dac_nids,
9559 .channel_mode = alc885_mbp_4ch_modes,
9560 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9561 .input_mux = &alc882_capture_source,
9562 .dig_out_nid = ALC882_DIGOUT_NID,
9563 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009564 .unsol_event = alc_automute_amp_unsol_event,
9565 .setup = alc885_imac91_setup,
9566 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009567 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009568 [ALC882_TARGA] = {
9569 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009570 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009571 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009572 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9573 .dac_nids = alc882_dac_nids,
9574 .dig_out_nid = ALC882_DIGOUT_NID,
9575 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9576 .adc_nids = alc882_adc_nids,
9577 .capsrc_nids = alc882_capsrc_nids,
9578 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9579 .channel_mode = alc882_3ST_6ch_modes,
9580 .need_dac_fix = 1,
9581 .input_mux = &alc882_capture_source,
9582 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009583 .setup = alc882_targa_setup,
9584 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009585 },
9586 [ALC882_ASUS_A7J] = {
9587 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009588 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9589 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009590 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9591 .dac_nids = alc882_dac_nids,
9592 .dig_out_nid = ALC882_DIGOUT_NID,
9593 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9594 .adc_nids = alc882_adc_nids,
9595 .capsrc_nids = alc882_capsrc_nids,
9596 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9597 .channel_mode = alc882_3ST_6ch_modes,
9598 .need_dac_fix = 1,
9599 .input_mux = &alc882_capture_source,
9600 },
9601 [ALC882_ASUS_A7M] = {
9602 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009603 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9604 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009605 alc882_asus_a7m_verbs },
9606 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9607 .dac_nids = alc882_dac_nids,
9608 .dig_out_nid = ALC882_DIGOUT_NID,
9609 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9610 .channel_mode = alc880_threestack_modes,
9611 .need_dac_fix = 1,
9612 .input_mux = &alc882_capture_source,
9613 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009614 [ALC883_3ST_2ch_DIG] = {
9615 .mixers = { alc883_3ST_2ch_mixer },
9616 .init_verbs = { alc883_init_verbs },
9617 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9618 .dac_nids = alc883_dac_nids,
9619 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009620 .dig_in_nid = ALC883_DIGIN_NID,
9621 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9622 .channel_mode = alc883_3ST_2ch_modes,
9623 .input_mux = &alc883_capture_source,
9624 },
9625 [ALC883_3ST_6ch_DIG] = {
9626 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9627 .init_verbs = { alc883_init_verbs },
9628 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9629 .dac_nids = alc883_dac_nids,
9630 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009631 .dig_in_nid = ALC883_DIGIN_NID,
9632 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9633 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009634 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009635 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009636 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009637 [ALC883_3ST_6ch] = {
9638 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9639 .init_verbs = { alc883_init_verbs },
9640 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9641 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009642 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9643 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009644 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009645 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009646 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009647 [ALC883_3ST_6ch_INTEL] = {
9648 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9649 .init_verbs = { alc883_init_verbs },
9650 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9651 .dac_nids = alc883_dac_nids,
9652 .dig_out_nid = ALC883_DIGOUT_NID,
9653 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009654 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009655 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9656 .channel_mode = alc883_3ST_6ch_intel_modes,
9657 .need_dac_fix = 1,
9658 .input_mux = &alc883_3stack_6ch_intel,
9659 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009660 [ALC889A_INTEL] = {
9661 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009662 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9663 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009664 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9665 .dac_nids = alc883_dac_nids,
9666 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9667 .adc_nids = alc889_adc_nids,
9668 .dig_out_nid = ALC883_DIGOUT_NID,
9669 .dig_in_nid = ALC883_DIGIN_NID,
9670 .slave_dig_outs = alc883_slave_dig_outs,
9671 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9672 .channel_mode = alc889_8ch_intel_modes,
9673 .capsrc_nids = alc889_capsrc_nids,
9674 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009675 .setup = alc889_automute_setup,
9676 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009677 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009678 .need_dac_fix = 1,
9679 },
9680 [ALC889_INTEL] = {
9681 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9682 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009683 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009684 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9685 .dac_nids = alc883_dac_nids,
9686 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9687 .adc_nids = alc889_adc_nids,
9688 .dig_out_nid = ALC883_DIGOUT_NID,
9689 .dig_in_nid = ALC883_DIGIN_NID,
9690 .slave_dig_outs = alc883_slave_dig_outs,
9691 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9692 .channel_mode = alc889_8ch_intel_modes,
9693 .capsrc_nids = alc889_capsrc_nids,
9694 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009695 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009696 .init_hook = alc889_intel_init_hook,
9697 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009698 .need_dac_fix = 1,
9699 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009700 [ALC883_6ST_DIG] = {
9701 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9702 .init_verbs = { alc883_init_verbs },
9703 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9704 .dac_nids = alc883_dac_nids,
9705 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009706 .dig_in_nid = ALC883_DIGIN_NID,
9707 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9708 .channel_mode = alc883_sixstack_modes,
9709 .input_mux = &alc883_capture_source,
9710 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009711 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009712 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009713 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9714 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009715 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9716 .dac_nids = alc883_dac_nids,
9717 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009718 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9719 .channel_mode = alc883_3ST_6ch_modes,
9720 .need_dac_fix = 1,
9721 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009722 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009723 .setup = alc882_targa_setup,
9724 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009725 },
9726 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009727 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009728 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9729 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009730 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9731 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009732 .adc_nids = alc883_adc_nids_alt,
9733 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009734 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009735 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009736 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9737 .channel_mode = alc883_3ST_2ch_modes,
9738 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009739 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009740 .setup = alc882_targa_setup,
9741 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009742 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009743 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009744 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9745 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009746 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009747 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009748 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9749 .dac_nids = alc883_dac_nids,
9750 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9751 .adc_nids = alc883_adc_nids_rev,
9752 .capsrc_nids = alc883_capsrc_nids_rev,
9753 .dig_out_nid = ALC883_DIGOUT_NID,
9754 .dig_in_nid = ALC883_DIGIN_NID,
9755 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9756 .channel_mode = alc883_4ST_8ch_modes,
9757 .need_dac_fix = 1,
9758 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009759 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009760 .setup = alc882_targa_setup,
9761 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009762 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009763 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009764 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009765 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9766 * and the headphone jack. Turn this on and rely on the
9767 * standard mute methods whenever the user wants to turn
9768 * these outputs off.
9769 */
9770 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9771 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9772 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009773 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9774 .channel_mode = alc883_3ST_2ch_modes,
9775 .input_mux = &alc883_capture_source,
9776 },
Tobin Davis2880a862007-08-07 11:50:26 +02009777 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009778 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009779 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009780 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9781 .dac_nids = alc883_dac_nids,
9782 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009783 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9784 .channel_mode = alc883_3ST_2ch_modes,
9785 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009786 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009787 .setup = alc883_acer_aspire_setup,
9788 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009789 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009790 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009791 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009792 alc883_chmode_mixer },
9793 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9794 alc888_acer_aspire_4930g_verbs },
9795 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9796 .dac_nids = alc883_dac_nids,
9797 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9798 .adc_nids = alc883_adc_nids_rev,
9799 .capsrc_nids = alc883_capsrc_nids_rev,
9800 .dig_out_nid = ALC883_DIGOUT_NID,
9801 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9802 .channel_mode = alc883_3ST_6ch_modes,
9803 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +01009804 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009805 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009806 ARRAY_SIZE(alc888_2_capture_sources),
9807 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009808 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009809 .setup = alc888_acer_aspire_4930g_setup,
9810 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009811 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009812 [ALC888_ACER_ASPIRE_6530G] = {
9813 .mixers = { alc888_acer_aspire_6530_mixer },
9814 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9815 alc888_acer_aspire_6530g_verbs },
9816 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9817 .dac_nids = alc883_dac_nids,
9818 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9819 .adc_nids = alc883_adc_nids_rev,
9820 .capsrc_nids = alc883_capsrc_nids_rev,
9821 .dig_out_nid = ALC883_DIGOUT_NID,
9822 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9823 .channel_mode = alc883_3ST_2ch_modes,
9824 .num_mux_defs =
9825 ARRAY_SIZE(alc888_2_capture_sources),
9826 .input_mux = alc888_acer_aspire_6530_sources,
9827 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009828 .setup = alc888_acer_aspire_6530g_setup,
9829 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009830 },
Hector Martin3b315d72009-06-02 10:54:19 +02009831 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009832 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009833 alc883_chmode_mixer },
9834 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009835 alc889_acer_aspire_8930g_verbs,
9836 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009837 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9838 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009839 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9840 .adc_nids = alc889_adc_nids,
9841 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009842 .dig_out_nid = ALC883_DIGOUT_NID,
9843 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9844 .channel_mode = alc883_3ST_6ch_modes,
9845 .need_dac_fix = 1,
9846 .const_channel_count = 6,
9847 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009848 ARRAY_SIZE(alc889_capture_sources),
9849 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009850 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009851 .setup = alc889_acer_aspire_8930g_setup,
9852 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +01009853#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05009854 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +01009855#endif
Hector Martin3b315d72009-06-02 10:54:19 +02009856 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009857 [ALC888_ACER_ASPIRE_7730G] = {
9858 .mixers = { alc883_3ST_6ch_mixer,
9859 alc883_chmode_mixer },
9860 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9861 alc888_acer_aspire_7730G_verbs },
9862 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9863 .dac_nids = alc883_dac_nids,
9864 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9865 .adc_nids = alc883_adc_nids_rev,
9866 .capsrc_nids = alc883_capsrc_nids_rev,
9867 .dig_out_nid = ALC883_DIGOUT_NID,
9868 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9869 .channel_mode = alc883_3ST_6ch_modes,
9870 .need_dac_fix = 1,
9871 .const_channel_count = 6,
9872 .input_mux = &alc883_capture_source,
9873 .unsol_event = alc_automute_amp_unsol_event,
9874 .setup = alc888_acer_aspire_6530g_setup,
9875 .init_hook = alc_automute_amp,
9876 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009877 [ALC883_MEDION] = {
9878 .mixers = { alc883_fivestack_mixer,
9879 alc883_chmode_mixer },
9880 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009881 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009882 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9883 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009884 .adc_nids = alc883_adc_nids_alt,
9885 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009886 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009887 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9888 .channel_mode = alc883_sixstack_modes,
9889 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009890 },
Kailang Yang272a5272007-05-14 11:00:38 +02009891 [ALC883_MEDION_MD2] = {
9892 .mixers = { alc883_medion_md2_mixer},
9893 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9894 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9895 .dac_nids = alc883_dac_nids,
9896 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009897 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9898 .channel_mode = alc883_3ST_2ch_modes,
9899 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009900 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009901 .setup = alc883_medion_md2_setup,
9902 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009903 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009904 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009905 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009906 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9907 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9908 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009909 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9910 .channel_mode = alc883_3ST_2ch_modes,
9911 .input_mux = &alc883_capture_source,
9912 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309913 [ALC883_CLEVO_M540R] = {
9914 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9915 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9916 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9917 .dac_nids = alc883_dac_nids,
9918 .dig_out_nid = ALC883_DIGOUT_NID,
9919 .dig_in_nid = ALC883_DIGIN_NID,
9920 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9921 .channel_mode = alc883_3ST_6ch_clevo_modes,
9922 .need_dac_fix = 1,
9923 .input_mux = &alc883_capture_source,
9924 /* This machine has the hardware HP auto-muting, thus
9925 * we need no software mute via unsol event
9926 */
9927 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009928 [ALC883_CLEVO_M720] = {
9929 .mixers = { alc883_clevo_m720_mixer },
9930 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009931 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9932 .dac_nids = alc883_dac_nids,
9933 .dig_out_nid = ALC883_DIGOUT_NID,
9934 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9935 .channel_mode = alc883_3ST_2ch_modes,
9936 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009937 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009938 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009939 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009940 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009941 [ALC883_LENOVO_101E_2ch] = {
9942 .mixers = { alc883_lenovo_101e_2ch_mixer},
9943 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9944 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9945 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009946 .adc_nids = alc883_adc_nids_alt,
9947 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009948 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009949 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9950 .channel_mode = alc883_3ST_2ch_modes,
9951 .input_mux = &alc883_lenovo_101e_capture_source,
9952 .unsol_event = alc883_lenovo_101e_unsol_event,
9953 .init_hook = alc883_lenovo_101e_all_automute,
9954 },
Kailang Yang272a5272007-05-14 11:00:38 +02009955 [ALC883_LENOVO_NB0763] = {
9956 .mixers = { alc883_lenovo_nb0763_mixer },
9957 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9958 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9959 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009960 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9961 .channel_mode = alc883_3ST_2ch_modes,
9962 .need_dac_fix = 1,
9963 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009964 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009965 .setup = alc883_medion_md2_setup,
9966 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009967 },
9968 [ALC888_LENOVO_MS7195_DIG] = {
9969 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9970 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9971 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9972 .dac_nids = alc883_dac_nids,
9973 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009974 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9975 .channel_mode = alc883_3ST_6ch_modes,
9976 .need_dac_fix = 1,
9977 .input_mux = &alc883_capture_source,
9978 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9979 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009980 },
9981 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009982 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009983 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9984 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9985 .dac_nids = alc883_dac_nids,
9986 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009987 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9988 .channel_mode = alc883_3ST_2ch_modes,
9989 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009990 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009991 .setup = alc883_haier_w66_setup,
9992 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009993 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009994 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009995 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009996 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009997 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9998 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009999 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10000 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010001 .need_dac_fix = 1,
10002 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010003 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010004 .setup = alc888_3st_hp_setup,
10005 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010006 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010007 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010008 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010009 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10010 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10011 .dac_nids = alc883_dac_nids,
10012 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010013 .dig_in_nid = ALC883_DIGIN_NID,
10014 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10015 .channel_mode = alc883_sixstack_modes,
10016 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010017 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010018 .setup = alc888_6st_dell_setup,
10019 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010020 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010021 [ALC883_MITAC] = {
10022 .mixers = { alc883_mitac_mixer },
10023 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10024 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10025 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010026 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10027 .channel_mode = alc883_3ST_2ch_modes,
10028 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010029 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010030 .setup = alc883_mitac_setup,
10031 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010032 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010033 [ALC883_FUJITSU_PI2515] = {
10034 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10035 .init_verbs = { alc883_init_verbs,
10036 alc883_2ch_fujitsu_pi2515_verbs},
10037 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10038 .dac_nids = alc883_dac_nids,
10039 .dig_out_nid = ALC883_DIGOUT_NID,
10040 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10041 .channel_mode = alc883_3ST_2ch_modes,
10042 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010043 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010044 .setup = alc883_2ch_fujitsu_pi2515_setup,
10045 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010046 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010047 [ALC888_FUJITSU_XA3530] = {
10048 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10049 .init_verbs = { alc883_init_verbs,
10050 alc888_fujitsu_xa3530_verbs },
10051 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10052 .dac_nids = alc883_dac_nids,
10053 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10054 .adc_nids = alc883_adc_nids_rev,
10055 .capsrc_nids = alc883_capsrc_nids_rev,
10056 .dig_out_nid = ALC883_DIGOUT_NID,
10057 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10058 .channel_mode = alc888_4ST_8ch_intel_modes,
10059 .num_mux_defs =
10060 ARRAY_SIZE(alc888_2_capture_sources),
10061 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010062 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010063 .setup = alc888_fujitsu_xa3530_setup,
10064 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010065 },
Kailang Yange2757d52008-08-26 13:17:46 +020010066 [ALC888_LENOVO_SKY] = {
10067 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10068 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10069 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10070 .dac_nids = alc883_dac_nids,
10071 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010072 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10073 .channel_mode = alc883_sixstack_modes,
10074 .need_dac_fix = 1,
10075 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010076 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010077 .setup = alc888_lenovo_sky_setup,
10078 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010079 },
10080 [ALC888_ASUS_M90V] = {
10081 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10082 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10083 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10084 .dac_nids = alc883_dac_nids,
10085 .dig_out_nid = ALC883_DIGOUT_NID,
10086 .dig_in_nid = ALC883_DIGIN_NID,
10087 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10088 .channel_mode = alc883_3ST_6ch_modes,
10089 .need_dac_fix = 1,
10090 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010091 .unsol_event = alc_sku_unsol_event,
10092 .setup = alc883_mode2_setup,
10093 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010094 },
10095 [ALC888_ASUS_EEE1601] = {
10096 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010097 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010098 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10099 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10100 .dac_nids = alc883_dac_nids,
10101 .dig_out_nid = ALC883_DIGOUT_NID,
10102 .dig_in_nid = ALC883_DIGIN_NID,
10103 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10104 .channel_mode = alc883_3ST_2ch_modes,
10105 .need_dac_fix = 1,
10106 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010107 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010108 .init_hook = alc883_eee1601_inithook,
10109 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010110 [ALC1200_ASUS_P5Q] = {
10111 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10112 .init_verbs = { alc883_init_verbs },
10113 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10114 .dac_nids = alc883_dac_nids,
10115 .dig_out_nid = ALC1200_DIGOUT_NID,
10116 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010117 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010118 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10119 .channel_mode = alc883_sixstack_modes,
10120 .input_mux = &alc883_capture_source,
10121 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010122 [ALC889A_MB31] = {
10123 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10124 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10125 alc880_gpio1_init_verbs },
10126 .adc_nids = alc883_adc_nids,
10127 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010128 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010129 .dac_nids = alc883_dac_nids,
10130 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10131 .channel_mode = alc889A_mb31_6ch_modes,
10132 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10133 .input_mux = &alc889A_mb31_capture_source,
10134 .dig_out_nid = ALC883_DIGOUT_NID,
10135 .unsol_event = alc889A_mb31_unsol_event,
10136 .init_hook = alc889A_mb31_automute,
10137 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010138 [ALC883_SONY_VAIO_TT] = {
10139 .mixers = { alc883_vaiott_mixer },
10140 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10141 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10142 .dac_nids = alc883_dac_nids,
10143 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10144 .channel_mode = alc883_3ST_2ch_modes,
10145 .input_mux = &alc883_capture_source,
10146 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010147 .setup = alc883_vaiott_setup,
10148 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010149 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010150};
10151
10152
10153/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010154 * Pin config fixes
10155 */
10156enum {
10157 PINFIX_ABIT_AW9D_MAX
10158};
10159
10160static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
10161 { 0x15, 0x01080104 }, /* side */
10162 { 0x16, 0x01011012 }, /* rear */
10163 { 0x17, 0x01016011 }, /* clfe */
10164 { }
10165};
10166
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010167static const struct alc_fixup alc882_fixups[] = {
10168 [PINFIX_ABIT_AW9D_MAX] = {
10169 .pins = alc882_abit_aw9d_pinfix
10170 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010171};
10172
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010173static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +020010174 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10175 {}
10176};
10177
10178/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010179 * BIOS auto configuration
10180 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010181static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10182 const struct auto_pin_cfg *cfg)
10183{
10184 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10185}
10186
Takashi Iwai4953550a2009-06-30 15:28:30 +020010187static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010188 hda_nid_t nid, int pin_type,
10189 int dac_idx)
10190{
10191 /* set as output */
10192 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010193 int idx;
10194
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010195 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010196 if (spec->multiout.dac_nids[dac_idx] == 0x25)
10197 idx = 4;
Takashi Iwai6a4f2cc2010-03-25 15:00:15 +010010198 else {
10199 if (spec->multiout.num_dacs >= dac_idx)
10200 return;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010201 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai6a4f2cc2010-03-25 15:00:15 +010010202 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010203 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
10204
10205}
10206
Takashi Iwai4953550a2009-06-30 15:28:30 +020010207static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010208{
10209 struct alc_spec *spec = codec->spec;
10210 int i;
10211
10212 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010213 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010214 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010215 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010216 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010217 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010218 }
10219}
10220
Takashi Iwai4953550a2009-06-30 15:28:30 +020010221static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010222{
10223 struct alc_spec *spec = codec->spec;
10224 hda_nid_t pin;
10225
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010226 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010227 if (pin) /* connect to front */
10228 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010229 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010230 pin = spec->autocfg.speaker_pins[0];
10231 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010232 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010233}
10234
Takashi Iwai4953550a2009-06-30 15:28:30 +020010235static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010236{
10237 struct alc_spec *spec = codec->spec;
10238 int i;
10239
10240 for (i = 0; i < AUTO_PIN_LAST; i++) {
10241 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010242 if (!nid)
10243 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010244 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010245 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10246 snd_hda_codec_write(codec, nid, 0,
10247 AC_VERB_SET_AMP_GAIN_MUTE,
10248 AMP_OUT_MUTE);
10249 }
10250}
10251
10252static void alc882_auto_init_input_src(struct hda_codec *codec)
10253{
10254 struct alc_spec *spec = codec->spec;
10255 int c;
10256
10257 for (c = 0; c < spec->num_adc_nids; c++) {
10258 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10259 hda_nid_t nid = spec->capsrc_nids[c];
10260 unsigned int mux_idx;
10261 const struct hda_input_mux *imux;
10262 int conns, mute, idx, item;
10263
10264 conns = snd_hda_get_connections(codec, nid, conn_list,
10265 ARRAY_SIZE(conn_list));
10266 if (conns < 0)
10267 continue;
10268 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10269 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010270 if (!imux->num_items && mux_idx > 0)
10271 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010272 for (idx = 0; idx < conns; idx++) {
10273 /* if the current connection is the selected one,
10274 * unmute it as default - otherwise mute it
10275 */
10276 mute = AMP_IN_MUTE(idx);
10277 for (item = 0; item < imux->num_items; item++) {
10278 if (imux->items[item].index == idx) {
10279 if (spec->cur_mux[c] == item)
10280 mute = AMP_IN_UNMUTE(idx);
10281 break;
10282 }
10283 }
10284 /* check if we have a selector or mixer
10285 * we could check for the widget type instead, but
10286 * just check for Amp-In presence (in case of mixer
10287 * without amp-in there is something wrong, this
10288 * function shouldn't be used or capsrc nid is wrong)
10289 */
10290 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010291 snd_hda_codec_write(codec, nid, 0,
10292 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010293 mute);
10294 else if (mute != AMP_IN_MUTE(idx))
10295 snd_hda_codec_write(codec, nid, 0,
10296 AC_VERB_SET_CONNECT_SEL,
10297 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010298 }
10299 }
10300}
10301
Takashi Iwai4953550a2009-06-30 15:28:30 +020010302/* add mic boosts if needed */
10303static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010304{
10305 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010306 int err;
10307 hda_nid_t nid;
10308
10309 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
10310 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10311 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10312 "Mic Boost",
10313 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10314 if (err < 0)
10315 return err;
10316 }
10317 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
10318 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10319 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10320 "Front Mic Boost",
10321 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10322 if (err < 0)
10323 return err;
10324 }
10325 return 0;
10326}
10327
10328/* almost identical with ALC880 parser... */
10329static int alc882_parse_auto_config(struct hda_codec *codec)
10330{
10331 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010332 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
10333 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010334
Takashi Iwai05f5f472009-08-25 13:10:18 +020010335 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10336 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010337 if (err < 0)
10338 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010339 if (!spec->autocfg.line_outs)
10340 return 0; /* can't find valid BIOS pin config */
10341
10342 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10343 if (err < 0)
10344 return err;
10345 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10346 if (err < 0)
10347 return err;
10348 err = alc880_auto_create_extra_out(spec,
10349 spec->autocfg.speaker_pins[0],
10350 "Speaker");
10351 if (err < 0)
10352 return err;
10353 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10354 "Headphone");
10355 if (err < 0)
10356 return err;
10357 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10358 if (err < 0)
10359 return err;
10360
10361 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10362
10363 /* check multiple SPDIF-out (for recent codecs) */
10364 for (i = 0; i < spec->autocfg.dig_outs; i++) {
10365 hda_nid_t dig_nid;
10366 err = snd_hda_get_connections(codec,
10367 spec->autocfg.dig_out_pins[i],
10368 &dig_nid, 1);
10369 if (err < 0)
10370 continue;
10371 if (!i)
10372 spec->multiout.dig_out_nid = dig_nid;
10373 else {
10374 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010375 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +020010376 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010377 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010378 }
10379 }
10380 if (spec->autocfg.dig_in_pin)
10381 spec->dig_in_nid = ALC880_DIGIN_NID;
10382
10383 if (spec->kctls.list)
10384 add_mixer(spec, spec->kctls.list);
10385
10386 add_verb(spec, alc883_auto_init_verbs);
10387 /* if ADC 0x07 is available, initialize it, too */
10388 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10389 add_verb(spec, alc882_adc1_init_verbs);
10390
10391 spec->num_mux_defs = 1;
10392 spec->input_mux = &spec->private_imux[0];
10393
Kailang Yang6227cdc2010-02-25 08:36:52 +010010394 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010395
10396 err = alc_auto_add_mic_boost(codec);
10397 if (err < 0)
10398 return err;
10399
Takashi Iwai776e1842007-08-29 15:07:11 +020010400 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010401}
10402
10403/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010404static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010405{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010406 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010407 alc882_auto_init_multi_out(codec);
10408 alc882_auto_init_hp_out(codec);
10409 alc882_auto_init_analog_input(codec);
10410 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010411 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010412 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010413}
10414
Takashi Iwai4953550a2009-06-30 15:28:30 +020010415static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010416{
10417 struct alc_spec *spec;
10418 int err, board_config;
10419
10420 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10421 if (spec == NULL)
10422 return -ENOMEM;
10423
10424 codec->spec = spec;
10425
Kailang Yangda00c242010-03-19 11:23:45 +010010426 alc_auto_parse_customize_define(codec);
10427
Takashi Iwai4953550a2009-06-30 15:28:30 +020010428 switch (codec->vendor_id) {
10429 case 0x10ec0882:
10430 case 0x10ec0885:
10431 break;
10432 default:
10433 /* ALC883 and variants */
10434 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10435 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010436 }
10437
Takashi Iwai4953550a2009-06-30 15:28:30 +020010438 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10439 alc882_models,
10440 alc882_cfg_tbl);
10441
10442 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10443 board_config = snd_hda_check_board_codec_sid_config(codec,
10444 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10445
10446 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010447 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010448 codec->chip_name);
10449 board_config = ALC882_AUTO;
10450 }
10451
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010452 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010453
10454 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010455 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010456 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010457 if (err < 0) {
10458 alc_free(codec);
10459 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010460 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010461 printk(KERN_INFO
10462 "hda_codec: Cannot set up configuration "
10463 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010464 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010465 }
10466 }
10467
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010468 err = snd_hda_attach_beep_device(codec, 0x1);
10469 if (err < 0) {
10470 alc_free(codec);
10471 return err;
10472 }
10473
Takashi Iwai4953550a2009-06-30 15:28:30 +020010474 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010475 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010476
Takashi Iwai4953550a2009-06-30 15:28:30 +020010477 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10478 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10479 /* FIXME: setup DAC5 */
10480 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10481 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10482
10483 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10484 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10485
10486 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010487 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010488
10489 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010490 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010491 spec->num_adc_nids = 0;
10492 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010493 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010494 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010495 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010496 hda_nid_t nid = alc882_adc_nids[i];
10497 unsigned int wcap = get_wcaps(codec, nid);
10498 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010499 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010500 if (wcap != AC_WID_AUD_IN)
10501 continue;
10502 spec->private_adc_nids[spec->num_adc_nids] = nid;
10503 err = snd_hda_get_connections(codec, nid, &cap, 1);
10504 if (err < 0)
10505 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010506 err = snd_hda_get_connections(codec, cap, items,
10507 ARRAY_SIZE(items));
10508 if (err < 0)
10509 continue;
10510 for (j = 0; j < imux->num_items; j++)
10511 if (imux->items[j].index >= err)
10512 break;
10513 if (j < imux->num_items)
10514 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010515 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10516 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010517 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010518 spec->adc_nids = spec->private_adc_nids;
10519 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010520 }
10521
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010522 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010010523
10524 if (spec->cdefine.enable_pcbeep)
10525 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010526
Takashi Iwai2134ea42008-01-10 16:53:55 +010010527 spec->vmaster_nid = 0x0c;
10528
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010529 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010530 if (board_config == ALC882_AUTO)
10531 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010532#ifdef CONFIG_SND_HDA_POWER_SAVE
10533 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010534 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010535#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010536
10537 return 0;
10538}
10539
Takashi Iwai4953550a2009-06-30 15:28:30 +020010540
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010541/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010542 * ALC262 support
10543 */
10544
10545#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10546#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10547
10548#define alc262_dac_nids alc260_dac_nids
10549#define alc262_adc_nids alc882_adc_nids
10550#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010551#define alc262_capsrc_nids alc882_capsrc_nids
10552#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010553
10554#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010555#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010556
Kailang Yang4e555fe2008-08-26 13:05:55 +020010557static hda_nid_t alc262_dmic_adc_nids[1] = {
10558 /* ADC0 */
10559 0x09
10560};
10561
10562static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10563
Kailang Yangdf694da2005-12-05 19:42:22 +010010564static struct snd_kcontrol_new alc262_base_mixer[] = {
10565 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10566 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10567 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10568 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10569 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10570 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10571 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10572 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010573 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010574 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10575 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010576 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010577 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10578 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10579 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10580 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010581 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010582};
10583
Takashi Iwaice875f02008-01-28 18:17:43 +010010584/* update HP, line and mono-out pins according to the master switch */
10585static void alc262_hp_master_update(struct hda_codec *codec)
10586{
10587 struct alc_spec *spec = codec->spec;
10588 int val = spec->master_sw;
10589
10590 /* HP & line-out */
10591 snd_hda_codec_write_cache(codec, 0x1b, 0,
10592 AC_VERB_SET_PIN_WIDGET_CONTROL,
10593 val ? PIN_HP : 0);
10594 snd_hda_codec_write_cache(codec, 0x15, 0,
10595 AC_VERB_SET_PIN_WIDGET_CONTROL,
10596 val ? PIN_HP : 0);
10597 /* mono (speaker) depending on the HP jack sense */
10598 val = val && !spec->jack_present;
10599 snd_hda_codec_write_cache(codec, 0x16, 0,
10600 AC_VERB_SET_PIN_WIDGET_CONTROL,
10601 val ? PIN_OUT : 0);
10602}
10603
10604static void alc262_hp_bpc_automute(struct hda_codec *codec)
10605{
10606 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010607
10608 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010609 alc262_hp_master_update(codec);
10610}
10611
10612static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10613{
10614 if ((res >> 26) != ALC880_HP_EVENT)
10615 return;
10616 alc262_hp_bpc_automute(codec);
10617}
10618
10619static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10620{
10621 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010622
10623 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010624 alc262_hp_master_update(codec);
10625}
10626
10627static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10628 unsigned int res)
10629{
10630 if ((res >> 26) != ALC880_HP_EVENT)
10631 return;
10632 alc262_hp_wildwest_automute(codec);
10633}
10634
Takashi Iwaib72519b2009-05-08 14:31:55 +020010635#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010636
10637static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10638 struct snd_ctl_elem_value *ucontrol)
10639{
10640 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10641 struct alc_spec *spec = codec->spec;
10642 int val = !!*ucontrol->value.integer.value;
10643
10644 if (val == spec->master_sw)
10645 return 0;
10646 spec->master_sw = val;
10647 alc262_hp_master_update(codec);
10648 return 1;
10649}
10650
Takashi Iwaib72519b2009-05-08 14:31:55 +020010651#define ALC262_HP_MASTER_SWITCH \
10652 { \
10653 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10654 .name = "Master Playback Switch", \
10655 .info = snd_ctl_boolean_mono_info, \
10656 .get = alc262_hp_master_sw_get, \
10657 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010658 }, \
10659 { \
10660 .iface = NID_MAPPING, \
10661 .name = "Master Playback Switch", \
10662 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010663 }
10664
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010665
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010666static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010667 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010668 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10669 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10670 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010671 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10672 HDA_OUTPUT),
10673 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10674 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010675 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10676 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010677 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010678 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10679 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010680 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010681 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10682 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10683 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10684 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010685 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10686 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10687 { } /* end */
10688};
10689
Kailang Yangcd7509a2007-01-26 18:33:17 +010010690static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010691 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010692 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10693 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10694 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10695 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010696 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10697 HDA_OUTPUT),
10698 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10699 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010700 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10701 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010702 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010703 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10704 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10705 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10706 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010707 { } /* end */
10708};
10709
10710static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10711 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10712 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010713 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010714 { } /* end */
10715};
10716
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010717/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010718static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010719{
10720 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010721
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010722 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010010723 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010724}
10725
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010726static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010727 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10728 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010729 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10730 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10731 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10732 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10733 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10734 { } /* end */
10735};
10736
10737static struct hda_verb alc262_hp_t5735_verbs[] = {
10738 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10739 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10740
10741 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10742 { }
10743};
10744
Kailang Yang8c427222008-01-10 13:03:59 +010010745static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010746 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10747 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010748 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10749 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010750 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10751 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10752 { } /* end */
10753};
10754
10755static struct hda_verb alc262_hp_rp5700_verbs[] = {
10756 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10757 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10758 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10759 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10760 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10761 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10762 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10763 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10764 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10765 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10766 {}
10767};
10768
10769static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10770 .num_items = 1,
10771 .items = {
10772 { "Line", 0x1 },
10773 },
10774};
10775
Takashi Iwai42171c12009-05-08 14:11:43 +020010776/* bind hp and internal speaker mute (with plug check) as master switch */
10777static void alc262_hippo_master_update(struct hda_codec *codec)
10778{
10779 struct alc_spec *spec = codec->spec;
10780 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10781 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10782 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10783 unsigned int mute;
10784
10785 /* HP */
10786 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10787 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10788 HDA_AMP_MUTE, mute);
10789 /* mute internal speaker per jack sense */
10790 if (spec->jack_present)
10791 mute = HDA_AMP_MUTE;
10792 if (line_nid)
10793 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10794 HDA_AMP_MUTE, mute);
10795 if (speaker_nid && speaker_nid != line_nid)
10796 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10797 HDA_AMP_MUTE, mute);
10798}
10799
10800#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10801
10802static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10803 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010804{
10805 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010806 struct alc_spec *spec = codec->spec;
10807 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010808
Takashi Iwai42171c12009-05-08 14:11:43 +020010809 if (val == spec->master_sw)
10810 return 0;
10811 spec->master_sw = val;
10812 alc262_hippo_master_update(codec);
10813 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010814}
Takashi Iwai5b319542007-07-26 11:49:22 +020010815
Takashi Iwai42171c12009-05-08 14:11:43 +020010816#define ALC262_HIPPO_MASTER_SWITCH \
10817 { \
10818 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10819 .name = "Master Playback Switch", \
10820 .info = snd_ctl_boolean_mono_info, \
10821 .get = alc262_hippo_master_sw_get, \
10822 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010823 }, \
10824 { \
10825 .iface = NID_MAPPING, \
10826 .name = "Master Playback Switch", \
10827 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
10828 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020010829 }
10830
10831static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10832 ALC262_HIPPO_MASTER_SWITCH,
10833 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10834 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10835 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10836 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10837 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10839 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10840 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10841 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10842 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10843 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10844 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10845 { } /* end */
10846};
10847
10848static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10849 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10850 ALC262_HIPPO_MASTER_SWITCH,
10851 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10852 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10853 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10854 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10855 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10856 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10857 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10858 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10859 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10860 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10861 { } /* end */
10862};
10863
10864/* mute/unmute internal speaker according to the hp jack and mute state */
10865static void alc262_hippo_automute(struct hda_codec *codec)
10866{
10867 struct alc_spec *spec = codec->spec;
10868 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010869
Wu Fengguang864f92b2009-11-18 12:38:02 +080010870 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010871 alc262_hippo_master_update(codec);
10872}
10873
10874static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10875{
10876 if ((res >> 26) != ALC880_HP_EVENT)
10877 return;
10878 alc262_hippo_automute(codec);
10879}
10880
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010881static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010882{
10883 struct alc_spec *spec = codec->spec;
10884
10885 spec->autocfg.hp_pins[0] = 0x15;
10886 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010887}
10888
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010889static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010890{
10891 struct alc_spec *spec = codec->spec;
10892
10893 spec->autocfg.hp_pins[0] = 0x1b;
10894 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010895}
10896
10897
Kailang Yang272a5272007-05-14 11:00:38 +020010898static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010899 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010900 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010901 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10902 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10903 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10904 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10905 { } /* end */
10906};
10907
Kailang Yang83c34212007-07-05 11:43:05 +020010908static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010909 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10910 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010911 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10913 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10914 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10915 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10916 { } /* end */
10917};
Kailang Yang272a5272007-05-14 11:00:38 +020010918
Tony Vroonba340e82009-02-02 19:01:30 +000010919static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10920 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10921 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10922 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10923 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10924 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10925 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10926 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10927 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10928 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10929 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10930 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10931 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10932 { } /* end */
10933};
10934
10935static struct hda_verb alc262_tyan_verbs[] = {
10936 /* Headphone automute */
10937 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10938 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10939 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10940
10941 /* P11 AUX_IN, white 4-pin connector */
10942 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10943 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10944 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10945 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10946
10947 {}
10948};
10949
10950/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010951static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010952{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010953 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010954
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010955 spec->autocfg.hp_pins[0] = 0x1b;
10956 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010957}
10958
Tony Vroonba340e82009-02-02 19:01:30 +000010959
Kailang Yangdf694da2005-12-05 19:42:22 +010010960#define alc262_capture_mixer alc882_capture_mixer
10961#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10962
10963/*
10964 * generic initialization of ADC, input mixers and output mixers
10965 */
10966static struct hda_verb alc262_init_verbs[] = {
10967 /*
10968 * Unmute ADC0-2 and set the default input to mic-in
10969 */
10970 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10972 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10973 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10974 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10975 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10976
Takashi Iwaicb53c622007-08-10 17:21:45 +020010977 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010978 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010979 * Note: PASD motherboards uses the Line In 2 as the input for
10980 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010981 */
10982 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010983 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10984 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10985 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10986 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10987 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010988
10989 /*
10990 * Set up output mixers (0x0c - 0x0e)
10991 */
10992 /* set vol=0 to output mixers */
10993 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10994 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10995 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10996 /* set up input amps for analog loopback */
10997 /* Amp Indices: DAC = 0, mixer = 1 */
10998 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10999 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11000 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11001 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11002 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11003 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11004
11005 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11006 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11007 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11008 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11009 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11010 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11011
11012 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11013 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11014 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11015 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11016 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011017
Kailang Yangdf694da2005-12-05 19:42:22 +010011018 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11019 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011020
Kailang Yangdf694da2005-12-05 19:42:22 +010011021 /* FIXME: use matrix-type input source selection */
11022 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11023 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11024 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11025 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11026 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11027 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11028 /* Input mixer2 */
11029 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11030 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11031 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11032 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11033 /* Input mixer3 */
11034 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11035 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11036 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011037 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011038
11039 { }
11040};
11041
Kailang Yang4e555fe2008-08-26 13:05:55 +020011042static struct hda_verb alc262_eapd_verbs[] = {
11043 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11044 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11045 { }
11046};
11047
Kailang Yangccc656c2006-10-17 12:32:26 +020011048static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11049 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11050 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11051 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11052
11053 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11054 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11055 {}
11056};
11057
Kailang Yang272a5272007-05-14 11:00:38 +020011058static struct hda_verb alc262_sony_unsol_verbs[] = {
11059 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11060 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11061 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11062
11063 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11064 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011065 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011066};
11067
Kailang Yang4e555fe2008-08-26 13:05:55 +020011068static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11069 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11070 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11071 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011074 { } /* end */
11075};
11076
11077static struct hda_verb alc262_toshiba_s06_verbs[] = {
11078 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11079 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11080 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11081 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11082 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11083 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11084 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11085 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11086 {}
11087};
11088
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011089static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011090{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011091 struct alc_spec *spec = codec->spec;
11092
11093 spec->autocfg.hp_pins[0] = 0x15;
11094 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011095 spec->ext_mic.pin = 0x18;
11096 spec->ext_mic.mux_idx = 0;
11097 spec->int_mic.pin = 0x12;
11098 spec->int_mic.mux_idx = 9;
11099 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011100}
11101
Takashi Iwai834be882006-03-01 14:16:17 +010011102/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011103 * nec model
11104 * 0x15 = headphone
11105 * 0x16 = internal speaker
11106 * 0x18 = external mic
11107 */
11108
11109static struct snd_kcontrol_new alc262_nec_mixer[] = {
11110 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11111 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11112
11113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11115 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11116
11117 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11118 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11119 { } /* end */
11120};
11121
11122static struct hda_verb alc262_nec_verbs[] = {
11123 /* Unmute Speaker */
11124 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11125
11126 /* Headphone */
11127 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11128 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11129
11130 /* External mic to headphone */
11131 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11132 /* External mic to speaker */
11133 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11134 {}
11135};
11136
11137/*
Takashi Iwai834be882006-03-01 14:16:17 +010011138 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011139 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11140 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011141 */
11142
11143#define ALC_HP_EVENT 0x37
11144
11145static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11146 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11147 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011148 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11149 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011150 {}
11151};
11152
Jiang zhe0e31daf2008-03-20 12:12:39 +010011153static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11154 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11155 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11156 {}
11157};
11158
Daniel T Chene2595322009-12-19 18:19:02 -050011159static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11160 /* Front Mic pin: input vref at 50% */
11161 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11162 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11163 {}
11164};
11165
Takashi Iwai834be882006-03-01 14:16:17 +010011166static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011167 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011168 .items = {
11169 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011170 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011171 { "CD", 0x4 },
11172 },
11173};
11174
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011175static struct hda_input_mux alc262_HP_capture_source = {
11176 .num_items = 5,
11177 .items = {
11178 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011179 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011180 { "Line", 0x2 },
11181 { "CD", 0x4 },
11182 { "AUX IN", 0x6 },
11183 },
11184};
11185
zhejiangaccbe492007-08-31 12:36:05 +020011186static struct hda_input_mux alc262_HP_D7000_capture_source = {
11187 .num_items = 4,
11188 .items = {
11189 { "Mic", 0x0 },
11190 { "Front Mic", 0x2 },
11191 { "Line", 0x1 },
11192 { "CD", 0x4 },
11193 },
11194};
11195
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011196/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011197static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11198{
11199 struct alc_spec *spec = codec->spec;
11200 unsigned int mute;
11201
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011202 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011203 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11204 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011205 spec->sense_updated = 1;
11206 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011207 /* unmute internal speaker only if both HPs are unplugged and
11208 * master switch is on
11209 */
11210 if (spec->jack_present)
11211 mute = HDA_AMP_MUTE;
11212 else
Takashi Iwai834be882006-03-01 14:16:17 +010011213 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011214 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11215 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011216}
11217
11218/* unsolicited event for HP jack sensing */
11219static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11220 unsigned int res)
11221{
11222 if ((res >> 26) != ALC_HP_EVENT)
11223 return;
11224 alc262_fujitsu_automute(codec, 1);
11225}
11226
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011227static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11228{
11229 alc262_fujitsu_automute(codec, 1);
11230}
11231
Takashi Iwai834be882006-03-01 14:16:17 +010011232/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011233static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11234 .ops = &snd_hda_bind_vol,
11235 .values = {
11236 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11237 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11238 0
11239 },
11240};
Takashi Iwai834be882006-03-01 14:16:17 +010011241
Jiang zhe0e31daf2008-03-20 12:12:39 +010011242/* mute/unmute internal speaker according to the hp jack and mute state */
11243static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11244{
11245 struct alc_spec *spec = codec->spec;
11246 unsigned int mute;
11247
11248 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011249 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011250 spec->sense_updated = 1;
11251 }
11252 if (spec->jack_present) {
11253 /* mute internal speaker */
11254 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11255 HDA_AMP_MUTE, HDA_AMP_MUTE);
11256 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11257 HDA_AMP_MUTE, HDA_AMP_MUTE);
11258 } else {
11259 /* unmute internal speaker if necessary */
11260 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11261 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11262 HDA_AMP_MUTE, mute);
11263 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11264 HDA_AMP_MUTE, mute);
11265 }
11266}
11267
11268/* unsolicited event for HP jack sensing */
11269static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11270 unsigned int res)
11271{
11272 if ((res >> 26) != ALC_HP_EVENT)
11273 return;
11274 alc262_lenovo_3000_automute(codec, 1);
11275}
11276
Takashi Iwai8de56b72009-07-24 16:51:47 +020011277static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11278 int dir, int idx, long *valp)
11279{
11280 int i, change = 0;
11281
11282 for (i = 0; i < 2; i++, valp++)
11283 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11284 HDA_AMP_MUTE,
11285 *valp ? 0 : HDA_AMP_MUTE);
11286 return change;
11287}
11288
Takashi Iwai834be882006-03-01 14:16:17 +010011289/* bind hp and internal speaker mute (with plug check) */
11290static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11291 struct snd_ctl_elem_value *ucontrol)
11292{
11293 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11294 long *valp = ucontrol->value.integer.value;
11295 int change;
11296
Takashi Iwai8de56b72009-07-24 16:51:47 +020011297 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11298 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011299 if (change)
11300 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011301 return change;
11302}
11303
11304static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011305 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011306 {
11307 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11308 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011309 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011310 .info = snd_hda_mixer_amp_switch_info,
11311 .get = snd_hda_mixer_amp_switch_get,
11312 .put = alc262_fujitsu_master_sw_put,
11313 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11314 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011315 {
11316 .iface = NID_MAPPING,
11317 .name = "Master Playback Switch",
11318 .private_value = 0x1b,
11319 },
Takashi Iwai834be882006-03-01 14:16:17 +010011320 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11321 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11322 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11323 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11324 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011325 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11326 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11327 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011328 { } /* end */
11329};
11330
Jiang zhe0e31daf2008-03-20 12:12:39 +010011331/* bind hp and internal speaker mute (with plug check) */
11332static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11333 struct snd_ctl_elem_value *ucontrol)
11334{
11335 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11336 long *valp = ucontrol->value.integer.value;
11337 int change;
11338
Takashi Iwai8de56b72009-07-24 16:51:47 +020011339 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011340 if (change)
11341 alc262_lenovo_3000_automute(codec, 0);
11342 return change;
11343}
11344
11345static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11346 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11347 {
11348 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11349 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011350 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011351 .info = snd_hda_mixer_amp_switch_info,
11352 .get = snd_hda_mixer_amp_switch_get,
11353 .put = alc262_lenovo_3000_master_sw_put,
11354 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11355 },
11356 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11357 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11358 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11359 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11360 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11361 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11362 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11363 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11364 { } /* end */
11365};
11366
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011367static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11368 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011369 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011370 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11371 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11372 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11373 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11374 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11375 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11376 { } /* end */
11377};
11378
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011379/* additional init verbs for Benq laptops */
11380static struct hda_verb alc262_EAPD_verbs[] = {
11381 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11382 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11383 {}
11384};
11385
Kailang Yang83c34212007-07-05 11:43:05 +020011386static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11387 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11388 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11389
11390 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11391 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11392 {}
11393};
11394
Tobin Davisf651b502007-10-26 12:40:47 +020011395/* Samsung Q1 Ultra Vista model setup */
11396static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011397 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11398 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011399 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11400 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11401 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011402 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011403 { } /* end */
11404};
11405
11406static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011407 /* output mixer */
11408 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11409 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11410 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11411 /* speaker */
11412 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11413 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11414 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11415 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11416 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011417 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011418 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11419 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11420 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11421 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11422 /* internal mic */
11423 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11424 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11425 /* ADC, choose mic */
11426 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11427 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11428 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11429 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11430 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11431 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11432 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11433 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11434 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11435 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011436 {}
11437};
11438
Tobin Davisf651b502007-10-26 12:40:47 +020011439/* mute/unmute internal speaker according to the hp jack and mute state */
11440static void alc262_ultra_automute(struct hda_codec *codec)
11441{
11442 struct alc_spec *spec = codec->spec;
11443 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011444
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011445 mute = 0;
11446 /* auto-mute only when HP is used as HP */
11447 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011448 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011449 if (spec->jack_present)
11450 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011451 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011452 /* mute/unmute internal speaker */
11453 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11454 HDA_AMP_MUTE, mute);
11455 /* mute/unmute HP */
11456 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11457 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011458}
11459
11460/* unsolicited event for HP jack sensing */
11461static void alc262_ultra_unsol_event(struct hda_codec *codec,
11462 unsigned int res)
11463{
11464 if ((res >> 26) != ALC880_HP_EVENT)
11465 return;
11466 alc262_ultra_automute(codec);
11467}
11468
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011469static struct hda_input_mux alc262_ultra_capture_source = {
11470 .num_items = 2,
11471 .items = {
11472 { "Mic", 0x1 },
11473 { "Headphone", 0x7 },
11474 },
11475};
11476
11477static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11478 struct snd_ctl_elem_value *ucontrol)
11479{
11480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11481 struct alc_spec *spec = codec->spec;
11482 int ret;
11483
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011484 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011485 if (!ret)
11486 return 0;
11487 /* reprogram the HP pin as mic or HP according to the input source */
11488 snd_hda_codec_write_cache(codec, 0x15, 0,
11489 AC_VERB_SET_PIN_WIDGET_CONTROL,
11490 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11491 alc262_ultra_automute(codec); /* mute/unmute HP */
11492 return ret;
11493}
11494
11495static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11496 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11497 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11498 {
11499 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11500 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011501 .info = alc_mux_enum_info,
11502 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011503 .put = alc262_ultra_mux_enum_put,
11504 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011505 {
11506 .iface = NID_MAPPING,
11507 .name = "Capture Source",
11508 .private_value = 0x15,
11509 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011510 { } /* end */
11511};
11512
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011513/* We use two mixers depending on the output pin; 0x16 is a mono output
11514 * and thus it's bound with a different mixer.
11515 * This function returns which mixer amp should be used.
11516 */
11517static int alc262_check_volbit(hda_nid_t nid)
11518{
11519 if (!nid)
11520 return 0;
11521 else if (nid == 0x16)
11522 return 2;
11523 else
11524 return 1;
11525}
11526
11527static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11528 const char *pfx, int *vbits)
11529{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011530 unsigned long val;
11531 int vbit;
11532
11533 vbit = alc262_check_volbit(nid);
11534 if (!vbit)
11535 return 0;
11536 if (*vbits & vbit) /* a volume control for this mixer already there */
11537 return 0;
11538 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011539 if (vbit == 2)
11540 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11541 else
11542 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011543 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011544}
11545
11546static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11547 const char *pfx)
11548{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011549 unsigned long val;
11550
11551 if (!nid)
11552 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011553 if (nid == 0x16)
11554 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11555 else
11556 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011557 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011558}
11559
Kailang Yangdf694da2005-12-05 19:42:22 +010011560/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011561static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11562 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011563{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011564 const char *pfx;
11565 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011566 int err;
11567
11568 spec->multiout.num_dacs = 1; /* only use one dac */
11569 spec->multiout.dac_nids = spec->private_dac_nids;
11570 spec->multiout.dac_nids[0] = 2;
11571
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011572 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11573 pfx = "Master";
11574 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11575 pfx = "Speaker";
11576 else
11577 pfx = "Front";
11578 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11579 if (err < 0)
11580 return err;
11581 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11582 if (err < 0)
11583 return err;
11584 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11585 if (err < 0)
11586 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011587
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011588 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11589 alc262_check_volbit(cfg->speaker_pins[0]) |
11590 alc262_check_volbit(cfg->hp_pins[0]);
11591 if (vbits == 1 || vbits == 2)
11592 pfx = "Master"; /* only one mixer is used */
11593 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11594 pfx = "Speaker";
11595 else
11596 pfx = "Front";
11597 vbits = 0;
11598 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11599 if (err < 0)
11600 return err;
11601 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11602 &vbits);
11603 if (err < 0)
11604 return err;
11605 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11606 &vbits);
11607 if (err < 0)
11608 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011609 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011610}
11611
Takashi Iwai05f5f472009-08-25 13:10:18 +020011612#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011613 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011614
11615/*
11616 * generic initialization of ADC, input mixers and output mixers
11617 */
11618static struct hda_verb alc262_volume_init_verbs[] = {
11619 /*
11620 * Unmute ADC0-2 and set the default input to mic-in
11621 */
11622 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11623 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11624 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11625 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11626 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11627 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11628
Takashi Iwaicb53c622007-08-10 17:21:45 +020011629 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011630 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011631 * Note: PASD motherboards uses the Line In 2 as the input for
11632 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011633 */
11634 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011635 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11636 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11637 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11638 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011640
11641 /*
11642 * Set up output mixers (0x0c - 0x0f)
11643 */
11644 /* set vol=0 to output mixers */
11645 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11646 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11647 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011648
Kailang Yangdf694da2005-12-05 19:42:22 +010011649 /* set up input amps for analog loopback */
11650 /* Amp Indices: DAC = 0, mixer = 1 */
11651 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11652 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11653 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11654 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11655 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11656 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11657
11658 /* FIXME: use matrix-type input source selection */
11659 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11660 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11661 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11662 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11663 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11664 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11665 /* Input mixer2 */
11666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11667 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11668 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11669 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11670 /* Input mixer3 */
11671 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11672 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11673 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11674 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11675
11676 { }
11677};
11678
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011679static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11680 /*
11681 * Unmute ADC0-2 and set the default input to mic-in
11682 */
11683 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11685 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11686 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11687 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11688 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11689
Takashi Iwaicb53c622007-08-10 17:21:45 +020011690 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011691 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011692 * Note: PASD motherboards uses the Line In 2 as the input for
11693 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011694 */
11695 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011696 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11697 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11698 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11699 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11700 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11701 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11702 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011703
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011704 /*
11705 * Set up output mixers (0x0c - 0x0e)
11706 */
11707 /* set vol=0 to output mixers */
11708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11709 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11710 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11711
11712 /* set up input amps for analog loopback */
11713 /* Amp Indices: DAC = 0, mixer = 1 */
11714 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11715 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11716 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11717 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11718 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11719 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11720
Takashi Iwaice875f02008-01-28 18:17:43 +010011721 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011722 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11723 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11724
11725 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11726 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11727
11728 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11729 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11730
11731 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11732 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11733 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11734 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11735 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11736
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011737 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011738 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11739 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011740 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011741 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11742 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11743
11744
11745 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011746 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11747 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011748 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011749 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11750 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11751 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11752 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11753 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11754 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11755 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11756 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011757 /* Input mixer2 */
11758 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011759 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11760 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11761 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11762 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11763 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11764 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11765 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11766 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011767 /* Input mixer3 */
11768 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011769 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11770 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11772 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11773 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11774 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11775 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011777
Takashi Iwaice875f02008-01-28 18:17:43 +010011778 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11779
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011780 { }
11781};
11782
Kailang Yangcd7509a2007-01-26 18:33:17 +010011783static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11784 /*
11785 * Unmute ADC0-2 and set the default input to mic-in
11786 */
11787 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11788 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11789 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11790 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11791 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11792 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11793
Takashi Iwaicb53c622007-08-10 17:21:45 +020011794 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011795 * mixer widget
11796 * Note: PASD motherboards uses the Line In 2 as the input for front
11797 * panel mic (mic 2)
11798 */
11799 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011800 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11801 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11802 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11803 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11804 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11805 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11806 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11807 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011808 /*
11809 * Set up output mixers (0x0c - 0x0e)
11810 */
11811 /* set vol=0 to output mixers */
11812 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11813 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11814 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11815
11816 /* set up input amps for analog loopback */
11817 /* Amp Indices: DAC = 0, mixer = 1 */
11818 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11819 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11820 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11821 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11822 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11823 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11824
11825
11826 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11827 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11828 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11829 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11830 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11831 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11832 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11833
11834 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11835 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11836
11837 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11838 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11839
11840 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11841 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11842 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11843 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11844 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11845 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11846
11847 /* FIXME: use matrix-type input source selection */
11848 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11849 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11850 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11851 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11852 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11853 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11854 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11855 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11856 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11857 /* Input mixer2 */
11858 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11859 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11860 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11861 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11862 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11863 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11864 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11865 /* Input mixer3 */
11866 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11867 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11868 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11869 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11870 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11871 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11872 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11873
Takashi Iwaice875f02008-01-28 18:17:43 +010011874 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11875
Kailang Yangcd7509a2007-01-26 18:33:17 +010011876 { }
11877};
11878
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011879static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11880
11881 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11883 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11884
11885 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11886 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11887 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11888 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11889
11890 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11891 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11892 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11893 {}
11894};
11895
11896
Takashi Iwaicb53c622007-08-10 17:21:45 +020011897#ifdef CONFIG_SND_HDA_POWER_SAVE
11898#define alc262_loopbacks alc880_loopbacks
11899#endif
11900
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011901/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011902#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11903#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11904#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11905#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11906
11907/*
11908 * BIOS auto configuration
11909 */
11910static int alc262_parse_auto_config(struct hda_codec *codec)
11911{
11912 struct alc_spec *spec = codec->spec;
11913 int err;
11914 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11915
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011916 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11917 alc262_ignore);
11918 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011919 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011920 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011921 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011922 spec->multiout.max_channels = 2;
11923 spec->no_analog = 1;
11924 goto dig_only;
11925 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011926 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011927 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011928 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11929 if (err < 0)
11930 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011931 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011932 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011933 return err;
11934
11935 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11936
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011937 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011938 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011939 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011940 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011941 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011942 if (spec->autocfg.dig_in_pin)
11943 spec->dig_in_nid = ALC262_DIGIN_NID;
11944
Takashi Iwai603c4012008-07-30 15:01:44 +020011945 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011946 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011947
Takashi Iwaid88897e2008-10-31 15:01:37 +010011948 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011949 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011950 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011951
Takashi Iwai776e1842007-08-29 15:07:11 +020011952 err = alc_auto_add_mic_boost(codec);
11953 if (err < 0)
11954 return err;
11955
Kailang Yang6227cdc2010-02-25 08:36:52 +010011956 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011957
Kailang Yangdf694da2005-12-05 19:42:22 +010011958 return 1;
11959}
11960
11961#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11962#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11963#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011964#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011965
11966
11967/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011968static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011969{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011970 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011971 alc262_auto_init_multi_out(codec);
11972 alc262_auto_init_hp_out(codec);
11973 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011974 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011975 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011976 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011977}
11978
11979/*
11980 * configuration and preset
11981 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011982static const char *alc262_models[ALC262_MODEL_LAST] = {
11983 [ALC262_BASIC] = "basic",
11984 [ALC262_HIPPO] = "hippo",
11985 [ALC262_HIPPO_1] = "hippo_1",
11986 [ALC262_FUJITSU] = "fujitsu",
11987 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011988 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011989 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011990 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011991 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011992 [ALC262_BENQ_T31] = "benq-t31",
11993 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011994 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011995 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011996 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011997 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011998 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011999 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012000 [ALC262_AUTO] = "auto",
12001};
12002
12003static struct snd_pci_quirk alc262_cfg_tbl[] = {
12004 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012005 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012006 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12007 ALC262_HP_BPC),
12008 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12009 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012010 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12011 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012012 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012013 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012014 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012015 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012016 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012017 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012018 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012019 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012020 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12021 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12022 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012023 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12024 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012025 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012026 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012027 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012028 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012029 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012030 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012031 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012032 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012033#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012034 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12035 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012036#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012037 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012038 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012039 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012040 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012041 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012042 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012043 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12044 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012045 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012046 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012047 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012048 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012049 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012050 {}
12051};
12052
12053static struct alc_config_preset alc262_presets[] = {
12054 [ALC262_BASIC] = {
12055 .mixers = { alc262_base_mixer },
12056 .init_verbs = { alc262_init_verbs },
12057 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12058 .dac_nids = alc262_dac_nids,
12059 .hp_nid = 0x03,
12060 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12061 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012062 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012063 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012064 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012065 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012066 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012067 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12068 .dac_nids = alc262_dac_nids,
12069 .hp_nid = 0x03,
12070 .dig_out_nid = ALC262_DIGOUT_NID,
12071 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12072 .channel_mode = alc262_modes,
12073 .input_mux = &alc262_capture_source,
12074 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012075 .setup = alc262_hippo_setup,
12076 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012077 },
12078 [ALC262_HIPPO_1] = {
12079 .mixers = { alc262_hippo1_mixer },
12080 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12081 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12082 .dac_nids = alc262_dac_nids,
12083 .hp_nid = 0x02,
12084 .dig_out_nid = ALC262_DIGOUT_NID,
12085 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12086 .channel_mode = alc262_modes,
12087 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012088 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012089 .setup = alc262_hippo1_setup,
12090 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012091 },
Takashi Iwai834be882006-03-01 14:16:17 +010012092 [ALC262_FUJITSU] = {
12093 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012094 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12095 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012096 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12097 .dac_nids = alc262_dac_nids,
12098 .hp_nid = 0x03,
12099 .dig_out_nid = ALC262_DIGOUT_NID,
12100 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12101 .channel_mode = alc262_modes,
12102 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012103 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012104 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012105 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012106 [ALC262_HP_BPC] = {
12107 .mixers = { alc262_HP_BPC_mixer },
12108 .init_verbs = { alc262_HP_BPC_init_verbs },
12109 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12110 .dac_nids = alc262_dac_nids,
12111 .hp_nid = 0x03,
12112 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12113 .channel_mode = alc262_modes,
12114 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012115 .unsol_event = alc262_hp_bpc_unsol_event,
12116 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012117 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012118 [ALC262_HP_BPC_D7000_WF] = {
12119 .mixers = { alc262_HP_BPC_WildWest_mixer },
12120 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12121 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12122 .dac_nids = alc262_dac_nids,
12123 .hp_nid = 0x03,
12124 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12125 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012126 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012127 .unsol_event = alc262_hp_wildwest_unsol_event,
12128 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012129 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012130 [ALC262_HP_BPC_D7000_WL] = {
12131 .mixers = { alc262_HP_BPC_WildWest_mixer,
12132 alc262_HP_BPC_WildWest_option_mixer },
12133 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12134 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12135 .dac_nids = alc262_dac_nids,
12136 .hp_nid = 0x03,
12137 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12138 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012139 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012140 .unsol_event = alc262_hp_wildwest_unsol_event,
12141 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012142 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012143 [ALC262_HP_TC_T5735] = {
12144 .mixers = { alc262_hp_t5735_mixer },
12145 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12146 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12147 .dac_nids = alc262_dac_nids,
12148 .hp_nid = 0x03,
12149 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12150 .channel_mode = alc262_modes,
12151 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012152 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012153 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012154 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012155 },
12156 [ALC262_HP_RP5700] = {
12157 .mixers = { alc262_hp_rp5700_mixer },
12158 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12159 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12160 .dac_nids = alc262_dac_nids,
12161 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12162 .channel_mode = alc262_modes,
12163 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012164 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012165 [ALC262_BENQ_ED8] = {
12166 .mixers = { alc262_base_mixer },
12167 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12168 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12169 .dac_nids = alc262_dac_nids,
12170 .hp_nid = 0x03,
12171 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12172 .channel_mode = alc262_modes,
12173 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012174 },
Kailang Yang272a5272007-05-14 11:00:38 +020012175 [ALC262_SONY_ASSAMD] = {
12176 .mixers = { alc262_sony_mixer },
12177 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12178 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12179 .dac_nids = alc262_dac_nids,
12180 .hp_nid = 0x02,
12181 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12182 .channel_mode = alc262_modes,
12183 .input_mux = &alc262_capture_source,
12184 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012185 .setup = alc262_hippo_setup,
12186 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012187 },
12188 [ALC262_BENQ_T31] = {
12189 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012190 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12191 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012192 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12193 .dac_nids = alc262_dac_nids,
12194 .hp_nid = 0x03,
12195 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12196 .channel_mode = alc262_modes,
12197 .input_mux = &alc262_capture_source,
12198 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012199 .setup = alc262_hippo_setup,
12200 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012201 },
Tobin Davisf651b502007-10-26 12:40:47 +020012202 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012203 .mixers = { alc262_ultra_mixer },
12204 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012205 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012206 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12207 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012208 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12209 .channel_mode = alc262_modes,
12210 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012211 .adc_nids = alc262_adc_nids, /* ADC0 */
12212 .capsrc_nids = alc262_capsrc_nids,
12213 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012214 .unsol_event = alc262_ultra_unsol_event,
12215 .init_hook = alc262_ultra_automute,
12216 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012217 [ALC262_LENOVO_3000] = {
12218 .mixers = { alc262_lenovo_3000_mixer },
12219 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012220 alc262_lenovo_3000_unsol_verbs,
12221 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012222 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12223 .dac_nids = alc262_dac_nids,
12224 .hp_nid = 0x03,
12225 .dig_out_nid = ALC262_DIGOUT_NID,
12226 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12227 .channel_mode = alc262_modes,
12228 .input_mux = &alc262_fujitsu_capture_source,
12229 .unsol_event = alc262_lenovo_3000_unsol_event,
12230 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012231 [ALC262_NEC] = {
12232 .mixers = { alc262_nec_mixer },
12233 .init_verbs = { alc262_nec_verbs },
12234 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12235 .dac_nids = alc262_dac_nids,
12236 .hp_nid = 0x03,
12237 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12238 .channel_mode = alc262_modes,
12239 .input_mux = &alc262_capture_source,
12240 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012241 [ALC262_TOSHIBA_S06] = {
12242 .mixers = { alc262_toshiba_s06_mixer },
12243 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12244 alc262_eapd_verbs },
12245 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12246 .capsrc_nids = alc262_dmic_capsrc_nids,
12247 .dac_nids = alc262_dac_nids,
12248 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012249 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012250 .dig_out_nid = ALC262_DIGOUT_NID,
12251 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12252 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012253 .unsol_event = alc_sku_unsol_event,
12254 .setup = alc262_toshiba_s06_setup,
12255 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012256 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012257 [ALC262_TOSHIBA_RX1] = {
12258 .mixers = { alc262_toshiba_rx1_mixer },
12259 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12260 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12261 .dac_nids = alc262_dac_nids,
12262 .hp_nid = 0x03,
12263 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12264 .channel_mode = alc262_modes,
12265 .input_mux = &alc262_capture_source,
12266 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012267 .setup = alc262_hippo_setup,
12268 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012269 },
Tony Vroonba340e82009-02-02 19:01:30 +000012270 [ALC262_TYAN] = {
12271 .mixers = { alc262_tyan_mixer },
12272 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12273 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12274 .dac_nids = alc262_dac_nids,
12275 .hp_nid = 0x02,
12276 .dig_out_nid = ALC262_DIGOUT_NID,
12277 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12278 .channel_mode = alc262_modes,
12279 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012280 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012281 .setup = alc262_tyan_setup,
12282 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012283 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012284};
12285
12286static int patch_alc262(struct hda_codec *codec)
12287{
12288 struct alc_spec *spec;
12289 int board_config;
12290 int err;
12291
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012292 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012293 if (spec == NULL)
12294 return -ENOMEM;
12295
12296 codec->spec = spec;
12297#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012298 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12299 * under-run
12300 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012301 {
12302 int tmp;
12303 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12304 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12305 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12306 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12307 }
12308#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012309 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012310
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012311 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12312
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012313 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12314 alc262_models,
12315 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012316
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012317 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012318 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12319 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012320 board_config = ALC262_AUTO;
12321 }
12322
12323 if (board_config == ALC262_AUTO) {
12324 /* automatic parse from the BIOS config */
12325 err = alc262_parse_auto_config(codec);
12326 if (err < 0) {
12327 alc_free(codec);
12328 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012329 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012330 printk(KERN_INFO
12331 "hda_codec: Cannot set up configuration "
12332 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012333 board_config = ALC262_BASIC;
12334 }
12335 }
12336
Takashi Iwai07eba612009-02-19 08:06:35 +010012337 if (!spec->no_analog) {
12338 err = snd_hda_attach_beep_device(codec, 0x1);
12339 if (err < 0) {
12340 alc_free(codec);
12341 return err;
12342 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012343 }
12344
Kailang Yangdf694da2005-12-05 19:42:22 +010012345 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012346 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012347
Kailang Yangdf694da2005-12-05 19:42:22 +010012348 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12349 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012350
Kailang Yangdf694da2005-12-05 19:42:22 +010012351 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12352 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12353
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012354 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012355 int i;
12356 /* check whether the digital-mic has to be supported */
12357 for (i = 0; i < spec->input_mux->num_items; i++) {
12358 if (spec->input_mux->items[i].index >= 9)
12359 break;
12360 }
12361 if (i < spec->input_mux->num_items) {
12362 /* use only ADC0 */
12363 spec->adc_nids = alc262_dmic_adc_nids;
12364 spec->num_adc_nids = 1;
12365 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012366 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012367 /* all analog inputs */
12368 /* check whether NID 0x07 is valid */
12369 unsigned int wcap = get_wcaps(codec, 0x07);
12370
12371 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012372 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012373 if (wcap != AC_WID_AUD_IN) {
12374 spec->adc_nids = alc262_adc_nids_alt;
12375 spec->num_adc_nids =
12376 ARRAY_SIZE(alc262_adc_nids_alt);
12377 spec->capsrc_nids = alc262_capsrc_nids_alt;
12378 } else {
12379 spec->adc_nids = alc262_adc_nids;
12380 spec->num_adc_nids =
12381 ARRAY_SIZE(alc262_adc_nids);
12382 spec->capsrc_nids = alc262_capsrc_nids;
12383 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012384 }
12385 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012386 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012387 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010012388 if (!spec->no_analog && spec->cdefine.enable_pcbeep)
Takashi Iwai07eba612009-02-19 08:06:35 +010012389 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012390
Takashi Iwai2134ea42008-01-10 16:53:55 +010012391 spec->vmaster_nid = 0x0c;
12392
Kailang Yangdf694da2005-12-05 19:42:22 +010012393 codec->patch_ops = alc_patch_ops;
12394 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012395 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012396#ifdef CONFIG_SND_HDA_POWER_SAVE
12397 if (!spec->loopback.amplist)
12398 spec->loopback.amplist = alc262_loopbacks;
12399#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012400
Kailang Yangdf694da2005-12-05 19:42:22 +010012401 return 0;
12402}
12403
Kailang Yangdf694da2005-12-05 19:42:22 +010012404/*
Kailang Yanga361d842007-06-05 12:30:55 +020012405 * ALC268 channel source setting (2 channel)
12406 */
12407#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12408#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012409
Kailang Yanga361d842007-06-05 12:30:55 +020012410static hda_nid_t alc268_dac_nids[2] = {
12411 /* front, hp */
12412 0x02, 0x03
12413};
12414
12415static hda_nid_t alc268_adc_nids[2] = {
12416 /* ADC0-1 */
12417 0x08, 0x07
12418};
12419
12420static hda_nid_t alc268_adc_nids_alt[1] = {
12421 /* ADC0 */
12422 0x08
12423};
12424
Takashi Iwaie1406342008-02-11 18:32:32 +010012425static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12426
Kailang Yanga361d842007-06-05 12:30:55 +020012427static struct snd_kcontrol_new alc268_base_mixer[] = {
12428 /* output mixer control */
12429 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12430 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12431 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12432 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012433 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12434 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12435 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012436 { }
12437};
12438
Takashi Iwai42171c12009-05-08 14:11:43 +020012439static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12440 /* output mixer control */
12441 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12442 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12443 ALC262_HIPPO_MASTER_SWITCH,
12444 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12445 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12446 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12447 { }
12448};
12449
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012450/* bind Beep switches of both NID 0x0f and 0x10 */
12451static struct hda_bind_ctls alc268_bind_beep_sw = {
12452 .ops = &snd_hda_bind_sw,
12453 .values = {
12454 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12455 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12456 0
12457 },
12458};
12459
12460static struct snd_kcontrol_new alc268_beep_mixer[] = {
12461 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12462 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12463 { }
12464};
12465
Kailang Yangd1a991a2007-08-15 16:21:59 +020012466static struct hda_verb alc268_eapd_verbs[] = {
12467 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12468 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12469 { }
12470};
12471
Takashi Iwaid2738092007-08-16 14:59:45 +020012472/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012473static struct hda_verb alc268_toshiba_verbs[] = {
12474 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12475 { } /* end */
12476};
12477
12478/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012479/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012480static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12481 .ops = &snd_hda_bind_vol,
12482 .values = {
12483 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12484 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12485 0
12486 },
12487};
12488
Takashi Iwai889c4392007-08-23 18:56:52 +020012489/* mute/unmute internal speaker according to the hp jack and mute state */
12490static void alc268_acer_automute(struct hda_codec *codec, int force)
12491{
12492 struct alc_spec *spec = codec->spec;
12493 unsigned int mute;
12494
12495 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012496 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012497 spec->sense_updated = 1;
12498 }
12499 if (spec->jack_present)
12500 mute = HDA_AMP_MUTE; /* mute internal speaker */
12501 else /* unmute internal speaker if necessary */
12502 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12503 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12504 HDA_AMP_MUTE, mute);
12505}
12506
12507
12508/* bind hp and internal speaker mute (with plug check) */
12509static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12510 struct snd_ctl_elem_value *ucontrol)
12511{
12512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12513 long *valp = ucontrol->value.integer.value;
12514 int change;
12515
Takashi Iwai8de56b72009-07-24 16:51:47 +020012516 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012517 if (change)
12518 alc268_acer_automute(codec, 0);
12519 return change;
12520}
Takashi Iwaid2738092007-08-16 14:59:45 +020012521
Kailang Yang8ef355d2008-08-26 13:10:22 +020012522static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12523 /* output mixer control */
12524 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12525 {
12526 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12527 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012528 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012529 .info = snd_hda_mixer_amp_switch_info,
12530 .get = snd_hda_mixer_amp_switch_get,
12531 .put = alc268_acer_master_sw_put,
12532 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12533 },
12534 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12535 { }
12536};
12537
Takashi Iwaid2738092007-08-16 14:59:45 +020012538static struct snd_kcontrol_new alc268_acer_mixer[] = {
12539 /* output mixer control */
12540 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12541 {
12542 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12543 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012544 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012545 .info = snd_hda_mixer_amp_switch_info,
12546 .get = snd_hda_mixer_amp_switch_get,
12547 .put = alc268_acer_master_sw_put,
12548 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12549 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012550 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12551 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12552 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012553 { }
12554};
12555
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012556static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12557 /* output mixer control */
12558 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12559 {
12560 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12561 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012562 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012563 .info = snd_hda_mixer_amp_switch_info,
12564 .get = snd_hda_mixer_amp_switch_get,
12565 .put = alc268_acer_master_sw_put,
12566 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12567 },
12568 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12569 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12570 { }
12571};
12572
Kailang Yang8ef355d2008-08-26 13:10:22 +020012573static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12574 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12575 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12576 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12577 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12578 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12579 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12580 { }
12581};
12582
Takashi Iwaid2738092007-08-16 14:59:45 +020012583static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012584 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12585 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012586 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12587 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012588 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12589 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012590 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12591 { }
12592};
12593
12594/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012595#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012596#define alc268_toshiba_setup alc262_hippo_setup
12597#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012598
12599static void alc268_acer_unsol_event(struct hda_codec *codec,
12600 unsigned int res)
12601{
Takashi Iwai889c4392007-08-23 18:56:52 +020012602 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012603 return;
12604 alc268_acer_automute(codec, 1);
12605}
12606
Takashi Iwai889c4392007-08-23 18:56:52 +020012607static void alc268_acer_init_hook(struct hda_codec *codec)
12608{
12609 alc268_acer_automute(codec, 1);
12610}
12611
Kailang Yang8ef355d2008-08-26 13:10:22 +020012612/* toggle speaker-output according to the hp-jack state */
12613static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12614{
12615 unsigned int present;
12616 unsigned char bits;
12617
Wu Fengguang864f92b2009-11-18 12:38:02 +080012618 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012619 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012620 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012621 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012622 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012623 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012624}
12625
Kailang Yang8ef355d2008-08-26 13:10:22 +020012626static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12627 unsigned int res)
12628{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012629 switch (res >> 26) {
12630 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012631 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012632 break;
12633 case ALC880_MIC_EVENT:
12634 alc_mic_automute(codec);
12635 break;
12636 }
12637}
12638
12639static void alc268_acer_lc_setup(struct hda_codec *codec)
12640{
12641 struct alc_spec *spec = codec->spec;
12642 spec->ext_mic.pin = 0x18;
12643 spec->ext_mic.mux_idx = 0;
12644 spec->int_mic.pin = 0x12;
12645 spec->int_mic.mux_idx = 6;
12646 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012647}
12648
12649static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12650{
12651 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012652 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012653}
12654
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012655static struct snd_kcontrol_new alc268_dell_mixer[] = {
12656 /* output mixer control */
12657 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12658 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12659 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12660 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12661 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12662 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12663 { }
12664};
12665
12666static struct hda_verb alc268_dell_verbs[] = {
12667 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12668 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12669 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012670 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012671 { }
12672};
12673
12674/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012675static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012676{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012677 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012678
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012679 spec->autocfg.hp_pins[0] = 0x15;
12680 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012681 spec->ext_mic.pin = 0x18;
12682 spec->ext_mic.mux_idx = 0;
12683 spec->int_mic.pin = 0x19;
12684 spec->int_mic.mux_idx = 1;
12685 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012686}
12687
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012688static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12689 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12690 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12691 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12692 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12693 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12694 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12695 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12696 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12697 { }
12698};
12699
12700static struct hda_verb alc267_quanta_il1_verbs[] = {
12701 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12702 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12703 { }
12704};
12705
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012706static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012707{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012708 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012709 spec->autocfg.hp_pins[0] = 0x15;
12710 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012711 spec->ext_mic.pin = 0x18;
12712 spec->ext_mic.mux_idx = 0;
12713 spec->int_mic.pin = 0x19;
12714 spec->int_mic.mux_idx = 1;
12715 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012716}
12717
Kailang Yanga361d842007-06-05 12:30:55 +020012718/*
12719 * generic initialization of ADC, input mixers and output mixers
12720 */
12721static struct hda_verb alc268_base_init_verbs[] = {
12722 /* Unmute DAC0-1 and set vol = 0 */
12723 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012724 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012725
12726 /*
12727 * Set up output mixers (0x0c - 0x0e)
12728 */
12729 /* set vol=0 to output mixers */
12730 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012731 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12732
12733 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12734 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12735
12736 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12737 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12738 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12739 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12740 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12741 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12742 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12743 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12744
12745 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12746 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12747 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12748 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012749 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012750
12751 /* set PCBEEP vol = 0, mute connections */
12752 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12753 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12754 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012755
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012756 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012757
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012758 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12759 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12760 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12761 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012762
Kailang Yanga361d842007-06-05 12:30:55 +020012763 { }
12764};
12765
12766/*
12767 * generic initialization of ADC, input mixers and output mixers
12768 */
12769static struct hda_verb alc268_volume_init_verbs[] = {
12770 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012771 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12772 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012773
12774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12775 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12776 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12777 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12778 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12779
Kailang Yanga361d842007-06-05 12:30:55 +020012780 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012781 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12782 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12783
12784 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012785 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012786
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012787 /* set PCBEEP vol = 0, mute connections */
12788 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12789 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12790 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012791
12792 { }
12793};
12794
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012795static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12796 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12797 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12798 { } /* end */
12799};
12800
Kailang Yanga361d842007-06-05 12:30:55 +020012801static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12802 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12803 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012804 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012805 { } /* end */
12806};
12807
12808static struct snd_kcontrol_new alc268_capture_mixer[] = {
12809 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12810 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12811 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12812 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012813 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012814 { } /* end */
12815};
12816
12817static struct hda_input_mux alc268_capture_source = {
12818 .num_items = 4,
12819 .items = {
12820 { "Mic", 0x0 },
12821 { "Front Mic", 0x1 },
12822 { "Line", 0x2 },
12823 { "CD", 0x3 },
12824 },
12825};
12826
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012827static struct hda_input_mux alc268_acer_capture_source = {
12828 .num_items = 3,
12829 .items = {
12830 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012831 { "Internal Mic", 0x1 },
12832 { "Line", 0x2 },
12833 },
12834};
12835
12836static struct hda_input_mux alc268_acer_dmic_capture_source = {
12837 .num_items = 3,
12838 .items = {
12839 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012840 { "Internal Mic", 0x6 },
12841 { "Line", 0x2 },
12842 },
12843};
12844
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012845#ifdef CONFIG_SND_DEBUG
12846static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012847 /* Volume widgets */
12848 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12849 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12850 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12851 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12852 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12853 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12854 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12855 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12856 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12857 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12858 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12859 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12860 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012861 /* The below appears problematic on some hardwares */
12862 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012863 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12864 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12865 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12866 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12867
12868 /* Modes for retasking pin widgets */
12869 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12870 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12871 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12872 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12873
12874 /* Controls for GPIO pins, assuming they are configured as outputs */
12875 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12876 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12877 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12878 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12879
12880 /* Switches to allow the digital SPDIF output pin to be enabled.
12881 * The ALC268 does not have an SPDIF input.
12882 */
12883 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12884
12885 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12886 * this output to turn on an external amplifier.
12887 */
12888 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12889 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12890
12891 { } /* end */
12892};
12893#endif
12894
Kailang Yanga361d842007-06-05 12:30:55 +020012895/* create input playback/capture controls for the given pin */
12896static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12897 const char *ctlname, int idx)
12898{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012899 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012900 int err;
12901
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012902 switch (nid) {
12903 case 0x14:
12904 case 0x16:
12905 dac = 0x02;
12906 break;
12907 case 0x15:
12908 dac = 0x03;
12909 break;
12910 default:
12911 return 0;
12912 }
12913 if (spec->multiout.dac_nids[0] != dac &&
12914 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012915 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012916 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012917 HDA_OUTPUT));
12918 if (err < 0)
12919 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012920 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12921 }
12922
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012923 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012924 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012925 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012926 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012927 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012928 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012929 if (err < 0)
12930 return err;
12931 return 0;
12932}
12933
12934/* add playback controls from the parsed DAC table */
12935static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12936 const struct auto_pin_cfg *cfg)
12937{
12938 hda_nid_t nid;
12939 int err;
12940
Kailang Yanga361d842007-06-05 12:30:55 +020012941 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012942
12943 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012944 if (nid) {
12945 const char *name;
12946 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12947 name = "Speaker";
12948 else
12949 name = "Front";
12950 err = alc268_new_analog_output(spec, nid, name, 0);
12951 if (err < 0)
12952 return err;
12953 }
Kailang Yanga361d842007-06-05 12:30:55 +020012954
12955 nid = cfg->speaker_pins[0];
12956 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012957 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012958 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12959 if (err < 0)
12960 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012961 } else {
12962 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12963 if (err < 0)
12964 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012965 }
12966 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012967 if (nid) {
12968 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12969 if (err < 0)
12970 return err;
12971 }
Kailang Yanga361d842007-06-05 12:30:55 +020012972
12973 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12974 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012975 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012976 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012977 if (err < 0)
12978 return err;
12979 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012980 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012981}
12982
12983/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012984static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012985 const struct auto_pin_cfg *cfg)
12986{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012987 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012988}
12989
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012990static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12991 hda_nid_t nid, int pin_type)
12992{
12993 int idx;
12994
12995 alc_set_pin_output(codec, nid, pin_type);
12996 if (nid == 0x14 || nid == 0x16)
12997 idx = 0;
12998 else
12999 idx = 1;
13000 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13001}
13002
13003static void alc268_auto_init_multi_out(struct hda_codec *codec)
13004{
13005 struct alc_spec *spec = codec->spec;
13006 hda_nid_t nid = spec->autocfg.line_out_pins[0];
13007 if (nid) {
13008 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13009 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13010 }
13011}
13012
13013static void alc268_auto_init_hp_out(struct hda_codec *codec)
13014{
13015 struct alc_spec *spec = codec->spec;
13016 hda_nid_t pin;
13017
13018 pin = spec->autocfg.hp_pins[0];
13019 if (pin)
13020 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
13021 pin = spec->autocfg.speaker_pins[0];
13022 if (pin)
13023 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
13024}
13025
Kailang Yanga361d842007-06-05 12:30:55 +020013026static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13027{
13028 struct alc_spec *spec = codec->spec;
13029 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13030 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13031 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13032 unsigned int dac_vol1, dac_vol2;
13033
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013034 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013035 snd_hda_codec_write(codec, speaker_nid, 0,
13036 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013037 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013038 snd_hda_codec_write(codec, 0x0f, 0,
13039 AC_VERB_SET_AMP_GAIN_MUTE,
13040 AMP_IN_UNMUTE(1));
13041 snd_hda_codec_write(codec, 0x10, 0,
13042 AC_VERB_SET_AMP_GAIN_MUTE,
13043 AMP_IN_UNMUTE(1));
13044 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013045 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013046 snd_hda_codec_write(codec, 0x0f, 0,
13047 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13048 snd_hda_codec_write(codec, 0x10, 0,
13049 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13050 }
13051
13052 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013053 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013054 dac_vol2 = AMP_OUT_ZERO;
13055 else if (line_nid == 0x15)
13056 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013057 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013058 dac_vol2 = AMP_OUT_ZERO;
13059 else if (hp_nid == 0x15)
13060 dac_vol1 = AMP_OUT_ZERO;
13061 if (line_nid != 0x16 || hp_nid != 0x16 ||
13062 spec->autocfg.line_out_pins[1] != 0x16 ||
13063 spec->autocfg.line_out_pins[2] != 0x16)
13064 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13065
13066 snd_hda_codec_write(codec, 0x02, 0,
13067 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13068 snd_hda_codec_write(codec, 0x03, 0,
13069 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13070}
13071
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013072/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013073#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13074#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013075#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013076#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13077
13078/*
13079 * BIOS auto configuration
13080 */
13081static int alc268_parse_auto_config(struct hda_codec *codec)
13082{
13083 struct alc_spec *spec = codec->spec;
13084 int err;
13085 static hda_nid_t alc268_ignore[] = { 0 };
13086
13087 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13088 alc268_ignore);
13089 if (err < 0)
13090 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013091 if (!spec->autocfg.line_outs) {
13092 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13093 spec->multiout.max_channels = 2;
13094 spec->no_analog = 1;
13095 goto dig_only;
13096 }
Kailang Yanga361d842007-06-05 12:30:55 +020013097 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013098 }
Kailang Yanga361d842007-06-05 12:30:55 +020013099 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13100 if (err < 0)
13101 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013102 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013103 if (err < 0)
13104 return err;
13105
13106 spec->multiout.max_channels = 2;
13107
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013108 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013109 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013110 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020013111 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013112 spec->dig_out_type = spec->autocfg.dig_out_type[0];
13113 }
Takashi Iwai603c4012008-07-30 15:01:44 +020013114 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013115 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013116
Takashi Iwai892981f2009-03-02 08:04:35 +010013117 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013118 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013119
Takashi Iwaid88897e2008-10-31 15:01:37 +010013120 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013121 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013122 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013123
Takashi Iwai776e1842007-08-29 15:07:11 +020013124 err = alc_auto_add_mic_boost(codec);
13125 if (err < 0)
13126 return err;
13127
Kailang Yang6227cdc2010-02-25 08:36:52 +010013128 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013129
Kailang Yanga361d842007-06-05 12:30:55 +020013130 return 1;
13131}
13132
Kailang Yanga361d842007-06-05 12:30:55 +020013133#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13134
13135/* init callback for auto-configuration model -- overriding the default init */
13136static void alc268_auto_init(struct hda_codec *codec)
13137{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013138 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013139 alc268_auto_init_multi_out(codec);
13140 alc268_auto_init_hp_out(codec);
13141 alc268_auto_init_mono_speaker_out(codec);
13142 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013143 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013144 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013145}
13146
13147/*
13148 * configuration and preset
13149 */
13150static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013151 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013152 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013153 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013154 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013155 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013156 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013157 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013158 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013159#ifdef CONFIG_SND_DEBUG
13160 [ALC268_TEST] = "test",
13161#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013162 [ALC268_AUTO] = "auto",
13163};
13164
13165static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013166 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013167 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013168 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013169 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013170 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013171 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13172 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013173 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013174 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13175 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013176 /* almost compatible with toshiba but with optional digital outs;
13177 * auto-probing seems working fine
13178 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013179 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013180 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013181 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013182 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013183 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013184 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013185 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013186 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020013187 {}
13188};
13189
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013190/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13191static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13192 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13193 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13194 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13195 ALC268_TOSHIBA),
13196 {}
13197};
13198
Kailang Yanga361d842007-06-05 12:30:55 +020013199static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013200 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013201 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13202 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013203 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13204 alc267_quanta_il1_verbs },
13205 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13206 .dac_nids = alc268_dac_nids,
13207 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13208 .adc_nids = alc268_adc_nids_alt,
13209 .hp_nid = 0x03,
13210 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13211 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013212 .unsol_event = alc_sku_unsol_event,
13213 .setup = alc267_quanta_il1_setup,
13214 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013215 },
Kailang Yanga361d842007-06-05 12:30:55 +020013216 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013217 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13218 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013219 .init_verbs = { alc268_base_init_verbs },
13220 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13221 .dac_nids = alc268_dac_nids,
13222 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13223 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013224 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013225 .hp_nid = 0x03,
13226 .dig_out_nid = ALC268_DIGOUT_NID,
13227 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13228 .channel_mode = alc268_modes,
13229 .input_mux = &alc268_capture_source,
13230 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013231 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013232 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013233 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013234 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13235 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013236 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13237 .dac_nids = alc268_dac_nids,
13238 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13239 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013240 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013241 .hp_nid = 0x03,
13242 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13243 .channel_mode = alc268_modes,
13244 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013245 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013246 .setup = alc268_toshiba_setup,
13247 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013248 },
13249 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013250 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013251 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013252 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13253 alc268_acer_verbs },
13254 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13255 .dac_nids = alc268_dac_nids,
13256 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13257 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013258 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013259 .hp_nid = 0x02,
13260 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13261 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013262 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013263 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013264 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013265 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013266 [ALC268_ACER_DMIC] = {
13267 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13268 alc268_beep_mixer },
13269 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13270 alc268_acer_verbs },
13271 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13272 .dac_nids = alc268_dac_nids,
13273 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13274 .adc_nids = alc268_adc_nids_alt,
13275 .capsrc_nids = alc268_capsrc_nids,
13276 .hp_nid = 0x02,
13277 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13278 .channel_mode = alc268_modes,
13279 .input_mux = &alc268_acer_dmic_capture_source,
13280 .unsol_event = alc268_acer_unsol_event,
13281 .init_hook = alc268_acer_init_hook,
13282 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013283 [ALC268_ACER_ASPIRE_ONE] = {
13284 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013285 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013286 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013287 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13288 alc268_acer_aspire_one_verbs },
13289 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13290 .dac_nids = alc268_dac_nids,
13291 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13292 .adc_nids = alc268_adc_nids_alt,
13293 .capsrc_nids = alc268_capsrc_nids,
13294 .hp_nid = 0x03,
13295 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13296 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013297 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013298 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013299 .init_hook = alc268_acer_lc_init_hook,
13300 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013301 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013302 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13303 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013304 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13305 alc268_dell_verbs },
13306 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13307 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013308 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13309 .adc_nids = alc268_adc_nids_alt,
13310 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013311 .hp_nid = 0x02,
13312 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13313 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013314 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013315 .setup = alc268_dell_setup,
13316 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013317 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013318 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013319 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13320 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013321 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13322 alc268_toshiba_verbs },
13323 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13324 .dac_nids = alc268_dac_nids,
13325 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13326 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013327 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013328 .hp_nid = 0x03,
13329 .dig_out_nid = ALC268_DIGOUT_NID,
13330 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13331 .channel_mode = alc268_modes,
13332 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013333 .setup = alc268_toshiba_setup,
13334 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013335 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013336#ifdef CONFIG_SND_DEBUG
13337 [ALC268_TEST] = {
13338 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13339 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13340 alc268_volume_init_verbs },
13341 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13342 .dac_nids = alc268_dac_nids,
13343 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13344 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013345 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013346 .hp_nid = 0x03,
13347 .dig_out_nid = ALC268_DIGOUT_NID,
13348 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13349 .channel_mode = alc268_modes,
13350 .input_mux = &alc268_capture_source,
13351 },
13352#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013353};
13354
13355static int patch_alc268(struct hda_codec *codec)
13356{
13357 struct alc_spec *spec;
13358 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013359 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013360
Julia Lawallef86f582009-12-19 08:18:03 +010013361 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013362 if (spec == NULL)
13363 return -ENOMEM;
13364
13365 codec->spec = spec;
13366
13367 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13368 alc268_models,
13369 alc268_cfg_tbl);
13370
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013371 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13372 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013373 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013374
Kailang Yanga361d842007-06-05 12:30:55 +020013375 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013376 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13377 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013378 board_config = ALC268_AUTO;
13379 }
13380
13381 if (board_config == ALC268_AUTO) {
13382 /* automatic parse from the BIOS config */
13383 err = alc268_parse_auto_config(codec);
13384 if (err < 0) {
13385 alc_free(codec);
13386 return err;
13387 } else if (!err) {
13388 printk(KERN_INFO
13389 "hda_codec: Cannot set up configuration "
13390 "from BIOS. Using base mode...\n");
13391 board_config = ALC268_3ST;
13392 }
13393 }
13394
13395 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013396 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013397
Kailang Yanga361d842007-06-05 12:30:55 +020013398 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13399 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013400 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013401
Kailang Yanga361d842007-06-05 12:30:55 +020013402 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13403
Takashi Iwai22971e32009-02-10 11:56:44 +010013404 has_beep = 0;
13405 for (i = 0; i < spec->num_mixers; i++) {
13406 if (spec->mixers[i] == alc268_beep_mixer) {
13407 has_beep = 1;
13408 break;
13409 }
13410 }
13411
13412 if (has_beep) {
13413 err = snd_hda_attach_beep_device(codec, 0x1);
13414 if (err < 0) {
13415 alc_free(codec);
13416 return err;
13417 }
13418 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13419 /* override the amp caps for beep generator */
13420 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013421 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13422 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13423 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13424 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013425 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013426
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013427 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013428 /* check whether NID 0x07 is valid */
13429 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013430 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013431
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013432 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013433 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013434 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013435 if (spec->auto_mic ||
13436 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013437 spec->adc_nids = alc268_adc_nids_alt;
13438 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013439 if (spec->auto_mic)
13440 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013441 if (spec->auto_mic || spec->input_mux->num_items == 1)
13442 add_mixer(spec, alc268_capture_nosrc_mixer);
13443 else
13444 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013445 } else {
13446 spec->adc_nids = alc268_adc_nids;
13447 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013448 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013449 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013450 /* set default input source */
13451 for (i = 0; i < spec->num_adc_nids; i++)
13452 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13453 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013454 i < spec->num_mux_defs ?
13455 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013456 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013457 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013458
13459 spec->vmaster_nid = 0x02;
13460
Kailang Yanga361d842007-06-05 12:30:55 +020013461 codec->patch_ops = alc_patch_ops;
13462 if (board_config == ALC268_AUTO)
13463 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013464
Kailang Yanga361d842007-06-05 12:30:55 +020013465 return 0;
13466}
13467
13468/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013469 * ALC269 channel source setting (2 channel)
13470 */
13471#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13472
13473#define alc269_dac_nids alc260_dac_nids
13474
13475static hda_nid_t alc269_adc_nids[1] = {
13476 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013477 0x08,
13478};
13479
Takashi Iwaie01bf502008-08-21 16:25:07 +020013480static hda_nid_t alc269_capsrc_nids[1] = {
13481 0x23,
13482};
13483
Kailang Yang84898e82010-02-04 14:16:14 +010013484static hda_nid_t alc269vb_adc_nids[1] = {
13485 /* ADC1 */
13486 0x09,
13487};
13488
13489static hda_nid_t alc269vb_capsrc_nids[1] = {
13490 0x22,
13491};
13492
Takashi Iwai66946352010-03-29 17:21:45 +020013493static hda_nid_t alc269_adc_candidates[] = {
13494 0x08, 0x09, 0x07,
13495};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013496
Kailang Yangf6a92242007-12-13 16:52:54 +010013497#define alc269_modes alc260_modes
13498#define alc269_capture_source alc880_lg_lw_capture_source
13499
13500static struct snd_kcontrol_new alc269_base_mixer[] = {
13501 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13502 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13503 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13504 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13505 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13506 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13507 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13508 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13509 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13510 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13511 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13512 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13513 { } /* end */
13514};
13515
Kailang Yang60db6b52008-08-26 13:13:00 +020013516static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13517 /* output mixer control */
13518 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13519 {
13520 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13521 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013522 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013523 .info = snd_hda_mixer_amp_switch_info,
13524 .get = snd_hda_mixer_amp_switch_get,
13525 .put = alc268_acer_master_sw_put,
13526 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13527 },
13528 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13529 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13530 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13531 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13532 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13533 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013534 { }
13535};
13536
Tony Vroon64154832008-11-06 15:08:49 +000013537static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13538 /* output mixer control */
13539 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13540 {
13541 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13542 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013543 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013544 .info = snd_hda_mixer_amp_switch_info,
13545 .get = snd_hda_mixer_amp_switch_get,
13546 .put = alc268_acer_master_sw_put,
13547 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13548 },
13549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13550 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13551 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13552 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13553 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13554 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13555 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13556 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13557 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013558 { }
13559};
13560
Kailang Yang84898e82010-02-04 14:16:14 +010013561static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013562 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013563 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013564 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013565 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013566 { } /* end */
13567};
13568
Kailang Yang84898e82010-02-04 14:16:14 +010013569static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13570 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13571 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13572 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13573 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13574 { } /* end */
13575};
13576
Kailang Yangf6a92242007-12-13 16:52:54 +010013577/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013578static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13579 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13580 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13581 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13582 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13583 { } /* end */
13584};
13585
13586static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013587 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13588 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013589 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13590 { } /* end */
13591};
13592
Kailang Yang84898e82010-02-04 14:16:14 +010013593static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13594 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13595 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13596 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13597 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13598 { } /* end */
13599};
13600
13601static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13602 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13603 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13604 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13605 { } /* end */
13606};
13607
Takashi Iwai26f5df22008-11-03 17:39:46 +010013608/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013609#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013610
Kailang Yang60db6b52008-08-26 13:13:00 +020013611static struct hda_verb alc269_quanta_fl1_verbs[] = {
13612 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13613 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13614 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13615 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13616 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13617 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13618 { }
13619};
13620
Tony Vroon64154832008-11-06 15:08:49 +000013621static struct hda_verb alc269_lifebook_verbs[] = {
13622 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13623 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13624 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13625 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13626 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13627 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13628 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13629 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13630 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13631 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13632 { }
13633};
13634
Kailang Yang60db6b52008-08-26 13:13:00 +020013635/* toggle speaker-output according to the hp-jack state */
13636static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13637{
13638 unsigned int present;
13639 unsigned char bits;
13640
Wu Fengguang864f92b2009-11-18 12:38:02 +080013641 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013642 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013643 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013644 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013645 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013646 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013647
13648 snd_hda_codec_write(codec, 0x20, 0,
13649 AC_VERB_SET_COEF_INDEX, 0x0c);
13650 snd_hda_codec_write(codec, 0x20, 0,
13651 AC_VERB_SET_PROC_COEF, 0x680);
13652
13653 snd_hda_codec_write(codec, 0x20, 0,
13654 AC_VERB_SET_COEF_INDEX, 0x0c);
13655 snd_hda_codec_write(codec, 0x20, 0,
13656 AC_VERB_SET_PROC_COEF, 0x480);
13657}
13658
Tony Vroon64154832008-11-06 15:08:49 +000013659/* toggle speaker-output according to the hp-jacks state */
13660static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13661{
13662 unsigned int present;
13663 unsigned char bits;
13664
13665 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013666 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013667
13668 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013669 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013670
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013671 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000013672 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013673 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013674 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013675 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013676
13677 snd_hda_codec_write(codec, 0x20, 0,
13678 AC_VERB_SET_COEF_INDEX, 0x0c);
13679 snd_hda_codec_write(codec, 0x20, 0,
13680 AC_VERB_SET_PROC_COEF, 0x680);
13681
13682 snd_hda_codec_write(codec, 0x20, 0,
13683 AC_VERB_SET_COEF_INDEX, 0x0c);
13684 snd_hda_codec_write(codec, 0x20, 0,
13685 AC_VERB_SET_PROC_COEF, 0x480);
13686}
13687
Tony Vroon64154832008-11-06 15:08:49 +000013688static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13689{
13690 unsigned int present_laptop;
13691 unsigned int present_dock;
13692
Wu Fengguang864f92b2009-11-18 12:38:02 +080013693 present_laptop = snd_hda_jack_detect(codec, 0x18);
13694 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013695
13696 /* Laptop mic port overrides dock mic port, design decision */
13697 if (present_dock)
13698 snd_hda_codec_write(codec, 0x23, 0,
13699 AC_VERB_SET_CONNECT_SEL, 0x3);
13700 if (present_laptop)
13701 snd_hda_codec_write(codec, 0x23, 0,
13702 AC_VERB_SET_CONNECT_SEL, 0x0);
13703 if (!present_dock && !present_laptop)
13704 snd_hda_codec_write(codec, 0x23, 0,
13705 AC_VERB_SET_CONNECT_SEL, 0x1);
13706}
13707
Kailang Yang60db6b52008-08-26 13:13:00 +020013708static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13709 unsigned int res)
13710{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013711 switch (res >> 26) {
13712 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013713 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013714 break;
13715 case ALC880_MIC_EVENT:
13716 alc_mic_automute(codec);
13717 break;
13718 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013719}
13720
Tony Vroon64154832008-11-06 15:08:49 +000013721static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13722 unsigned int res)
13723{
13724 if ((res >> 26) == ALC880_HP_EVENT)
13725 alc269_lifebook_speaker_automute(codec);
13726 if ((res >> 26) == ALC880_MIC_EVENT)
13727 alc269_lifebook_mic_autoswitch(codec);
13728}
13729
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013730static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13731{
13732 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013733 spec->autocfg.hp_pins[0] = 0x15;
13734 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013735 spec->ext_mic.pin = 0x18;
13736 spec->ext_mic.mux_idx = 0;
13737 spec->int_mic.pin = 0x19;
13738 spec->int_mic.mux_idx = 1;
13739 spec->auto_mic = 1;
13740}
13741
Kailang Yang60db6b52008-08-26 13:13:00 +020013742static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13743{
13744 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013745 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013746}
13747
Tony Vroon64154832008-11-06 15:08:49 +000013748static void alc269_lifebook_init_hook(struct hda_codec *codec)
13749{
13750 alc269_lifebook_speaker_automute(codec);
13751 alc269_lifebook_mic_autoswitch(codec);
13752}
13753
Kailang Yang84898e82010-02-04 14:16:14 +010013754static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013755 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13756 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13757 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13758 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13759 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13760 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13761 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13762 {}
13763};
13764
Kailang Yang84898e82010-02-04 14:16:14 +010013765static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013766 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13767 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13768 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13769 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13770 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13771 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13772 {}
13773};
13774
Kailang Yang84898e82010-02-04 14:16:14 +010013775static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
13776 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13777 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
13778 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13779 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13780 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13781 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13782 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13783 {}
13784};
13785
13786static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
13787 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13788 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
13789 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13790 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13791 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13792 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13793 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13794 {}
13795};
13796
Kailang Yang60db6b52008-08-26 13:13:00 +020013797/* toggle speaker-output according to the hp-jack state */
13798static void alc269_speaker_automute(struct hda_codec *codec)
13799{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013800 struct alc_spec *spec = codec->spec;
13801 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013802 unsigned int present;
13803 unsigned char bits;
13804
Kailang Yangebb83ee2009-12-17 12:23:00 +010013805 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013806 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013807 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013808 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013809 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013810 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013811}
13812
Kailang Yang60db6b52008-08-26 13:13:00 +020013813/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010013814static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013815 unsigned int res)
13816{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013817 switch (res >> 26) {
13818 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013819 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013820 break;
13821 case ALC880_MIC_EVENT:
13822 alc_mic_automute(codec);
13823 break;
13824 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013825}
13826
Kailang Yang84898e82010-02-04 14:16:14 +010013827static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013828{
13829 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013830 spec->autocfg.hp_pins[0] = 0x15;
13831 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013832 spec->ext_mic.pin = 0x18;
13833 spec->ext_mic.mux_idx = 0;
13834 spec->int_mic.pin = 0x12;
13835 spec->int_mic.mux_idx = 5;
13836 spec->auto_mic = 1;
13837}
13838
Kailang Yang84898e82010-02-04 14:16:14 +010013839static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
13840{
13841 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013842 spec->autocfg.hp_pins[0] = 0x15;
13843 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang84898e82010-02-04 14:16:14 +010013844 spec->ext_mic.pin = 0x18;
13845 spec->ext_mic.mux_idx = 0;
13846 spec->int_mic.pin = 0x12;
13847 spec->int_mic.mux_idx = 6;
13848 spec->auto_mic = 1;
13849}
13850
13851static void alc269_laptop_amic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013852{
13853 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013854 spec->autocfg.hp_pins[0] = 0x15;
13855 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013856 spec->ext_mic.pin = 0x18;
13857 spec->ext_mic.mux_idx = 0;
13858 spec->int_mic.pin = 0x19;
13859 spec->int_mic.mux_idx = 1;
13860 spec->auto_mic = 1;
13861}
13862
Kailang Yang84898e82010-02-04 14:16:14 +010013863static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013864{
13865 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013866 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013867}
13868
Kailang Yangf6a92242007-12-13 16:52:54 +010013869/*
13870 * generic initialization of ADC, input mixers and output mixers
13871 */
13872static struct hda_verb alc269_init_verbs[] = {
13873 /*
13874 * Unmute ADC0 and set the default input to mic-in
13875 */
Kailang Yang84898e82010-02-04 14:16:14 +010013876 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013877
13878 /*
Kailang Yang84898e82010-02-04 14:16:14 +010013879 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010013880 */
13881 /* set vol=0 to output mixers */
13882 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13883 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13884
13885 /* set up input amps for analog loopback */
13886 /* Amp Indices: DAC = 0, mixer = 1 */
13887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13889 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13890 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13891 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13892 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13893
13894 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13895 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13896 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13897 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13898 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13899 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13900 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13901
13902 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13903 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010013904
Kailang Yang84898e82010-02-04 14:16:14 +010013905 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010013906 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13907 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010013908 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010013909
13910 /* set EAPD */
13911 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010013912 { }
13913};
13914
13915static struct hda_verb alc269vb_init_verbs[] = {
13916 /*
13917 * Unmute ADC0 and set the default input to mic-in
13918 */
13919 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13920
13921 /*
13922 * Set up output mixers (0x02 - 0x03)
13923 */
13924 /* set vol=0 to output mixers */
13925 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13926 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13927
13928 /* set up input amps for analog loopback */
13929 /* Amp Indices: DAC = 0, mixer = 1 */
13930 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13931 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13932 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13933 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13934 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13935 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13936
13937 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13938 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13939 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13940 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13941 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13942 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13943 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13944
13945 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13946 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13947
13948 /* FIXME: use Mux-type input source selection */
13949 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13950 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
13951 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
13952
13953 /* set EAPD */
13954 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010013955 { }
13956};
13957
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013958#define alc269_auto_create_multi_out_ctls \
13959 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013960#define alc269_auto_create_input_ctls \
13961 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013962
13963#ifdef CONFIG_SND_HDA_POWER_SAVE
13964#define alc269_loopbacks alc880_loopbacks
13965#endif
13966
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013967/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013968#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13969#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13970#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13971#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13972
Takashi Iwaif03d3112009-03-05 14:18:16 +010013973static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13974 .substreams = 1,
13975 .channels_min = 2,
13976 .channels_max = 8,
13977 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13978 /* NID is set in alc_build_pcms */
13979 .ops = {
13980 .open = alc880_playback_pcm_open,
13981 .prepare = alc880_playback_pcm_prepare,
13982 .cleanup = alc880_playback_pcm_cleanup
13983 },
13984};
13985
13986static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13987 .substreams = 1,
13988 .channels_min = 2,
13989 .channels_max = 2,
13990 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13991 /* NID is set in alc_build_pcms */
13992};
13993
Takashi Iwaiad358792010-03-30 18:00:59 +020013994#ifdef CONFIG_SND_HDA_POWER_SAVE
13995static int alc269_mic2_for_mute_led(struct hda_codec *codec)
13996{
13997 switch (codec->subsystem_id) {
13998 case 0x103c1586:
13999 return 1;
14000 }
14001 return 0;
14002}
14003
14004static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14005{
14006 /* update mute-LED according to the speaker mute state */
14007 if (nid == 0x01 || nid == 0x14) {
14008 int pinval;
14009 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14010 HDA_AMP_MUTE)
14011 pinval = 0x24;
14012 else
14013 pinval = 0x20;
14014 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a52010-03-30 18:03:44 +020014015 snd_hda_codec_update_cache(codec, 0x19, 0,
14016 AC_VERB_SET_PIN_WIDGET_CONTROL,
14017 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014018 }
14019 return alc_check_power_status(codec, nid);
14020}
14021#endif /* CONFIG_SND_HDA_POWER_SAVE */
14022
Kailang Yangf6a92242007-12-13 16:52:54 +010014023/*
14024 * BIOS auto configuration
14025 */
14026static int alc269_parse_auto_config(struct hda_codec *codec)
14027{
14028 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014029 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014030 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14031
14032 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14033 alc269_ignore);
14034 if (err < 0)
14035 return err;
14036
14037 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14038 if (err < 0)
14039 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014040 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010014041 if (err < 0)
14042 return err;
14043
14044 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14045
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014046 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010014047 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
14048
Takashi Iwai603c4012008-07-30 15:01:44 +020014049 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014050 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014051
Kailang Yang84898e82010-02-04 14:16:14 +010014052 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
14053 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014054 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014055 } else {
14056 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014057 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014058 }
14059
Kailang Yangf6a92242007-12-13 16:52:54 +010014060 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014061 spec->input_mux = &spec->private_imux[0];
Takashi Iwai66946352010-03-29 17:21:45 +020014062 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14063 sizeof(alc269_adc_candidates));
14064
Takashi Iwaie01bf502008-08-21 16:25:07 +020014065 /* set default input source */
Takashi Iwai66946352010-03-29 17:21:45 +020014066 snd_hda_codec_write_cache(codec, spec->capsrc_nids[0],
Takashi Iwaie01bf502008-08-21 16:25:07 +020014067 0, AC_VERB_SET_CONNECT_SEL,
14068 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014069
14070 err = alc_auto_add_mic_boost(codec);
14071 if (err < 0)
14072 return err;
14073
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014074 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014075 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014076
Kailang Yangf6a92242007-12-13 16:52:54 +010014077 return 1;
14078}
14079
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014080#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14081#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014082#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14083
14084
14085/* init callback for auto-configuration model -- overriding the default init */
14086static void alc269_auto_init(struct hda_codec *codec)
14087{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014088 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014089 alc269_auto_init_multi_out(codec);
14090 alc269_auto_init_hp_out(codec);
14091 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014092 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014093 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014094}
14095
14096/*
14097 * configuration and preset
14098 */
14099static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014100 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014101 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014102 [ALC269_AMIC] = "laptop-amic",
14103 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014104 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014105 [ALC269_LIFEBOOK] = "lifebook",
14106 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014107};
14108
14109static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014110 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020014111 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014112 ALC269_AMIC),
14113 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14114 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14115 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14116 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14117 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14118 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14119 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14120 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14121 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14122 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14123 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14124 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14125 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14126 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14127 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14128 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14129 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14130 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14131 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14132 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14133 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14134 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14135 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14136 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14137 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14138 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14139 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14140 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14141 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14142 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14143 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14144 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14145 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14146 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14147 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14148 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014149 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014150 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014151 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014152 ALC269_DMIC),
14153 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14154 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014155 SND_PCI_QUIRK(0x104d, 0x9071, "SONY XTB", ALC269_DMIC),
Tony Vroon64154832008-11-06 15:08:49 +000014156 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014157 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14158 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14159 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14160 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14161 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14162 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014163 {}
14164};
14165
14166static struct alc_config_preset alc269_presets[] = {
14167 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014168 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014169 .init_verbs = { alc269_init_verbs },
14170 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14171 .dac_nids = alc269_dac_nids,
14172 .hp_nid = 0x03,
14173 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14174 .channel_mode = alc269_modes,
14175 .input_mux = &alc269_capture_source,
14176 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014177 [ALC269_QUANTA_FL1] = {
14178 .mixers = { alc269_quanta_fl1_mixer },
14179 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14180 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14181 .dac_nids = alc269_dac_nids,
14182 .hp_nid = 0x03,
14183 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14184 .channel_mode = alc269_modes,
14185 .input_mux = &alc269_capture_source,
14186 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014187 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014188 .init_hook = alc269_quanta_fl1_init_hook,
14189 },
Kailang Yang84898e82010-02-04 14:16:14 +010014190 [ALC269_AMIC] = {
14191 .mixers = { alc269_laptop_mixer },
14192 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014193 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014194 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014195 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14196 .dac_nids = alc269_dac_nids,
14197 .hp_nid = 0x03,
14198 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14199 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014200 .unsol_event = alc269_laptop_unsol_event,
14201 .setup = alc269_laptop_amic_setup,
14202 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014203 },
Kailang Yang84898e82010-02-04 14:16:14 +010014204 [ALC269_DMIC] = {
14205 .mixers = { alc269_laptop_mixer },
14206 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014207 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014208 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014209 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14210 .dac_nids = alc269_dac_nids,
14211 .hp_nid = 0x03,
14212 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14213 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014214 .unsol_event = alc269_laptop_unsol_event,
14215 .setup = alc269_laptop_dmic_setup,
14216 .init_hook = alc269_laptop_inithook,
14217 },
14218 [ALC269VB_AMIC] = {
14219 .mixers = { alc269vb_laptop_mixer },
14220 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14221 .init_verbs = { alc269vb_init_verbs,
14222 alc269vb_laptop_amic_init_verbs },
14223 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14224 .dac_nids = alc269_dac_nids,
14225 .hp_nid = 0x03,
14226 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14227 .channel_mode = alc269_modes,
14228 .unsol_event = alc269_laptop_unsol_event,
14229 .setup = alc269_laptop_amic_setup,
14230 .init_hook = alc269_laptop_inithook,
14231 },
14232 [ALC269VB_DMIC] = {
14233 .mixers = { alc269vb_laptop_mixer },
14234 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14235 .init_verbs = { alc269vb_init_verbs,
14236 alc269vb_laptop_dmic_init_verbs },
14237 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14238 .dac_nids = alc269_dac_nids,
14239 .hp_nid = 0x03,
14240 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14241 .channel_mode = alc269_modes,
14242 .unsol_event = alc269_laptop_unsol_event,
14243 .setup = alc269vb_laptop_dmic_setup,
14244 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014245 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014246 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014247 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014248 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014249 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014250 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014251 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14252 .dac_nids = alc269_dac_nids,
14253 .hp_nid = 0x03,
14254 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14255 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014256 .unsol_event = alc269_laptop_unsol_event,
14257 .setup = alc269_laptop_dmic_setup,
14258 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014259 },
Tony Vroon64154832008-11-06 15:08:49 +000014260 [ALC269_LIFEBOOK] = {
14261 .mixers = { alc269_lifebook_mixer },
14262 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14263 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14264 .dac_nids = alc269_dac_nids,
14265 .hp_nid = 0x03,
14266 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14267 .channel_mode = alc269_modes,
14268 .input_mux = &alc269_capture_source,
14269 .unsol_event = alc269_lifebook_unsol_event,
14270 .init_hook = alc269_lifebook_init_hook,
14271 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014272};
14273
14274static int patch_alc269(struct hda_codec *codec)
14275{
14276 struct alc_spec *spec;
14277 int board_config;
14278 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014279 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014280
14281 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14282 if (spec == NULL)
14283 return -ENOMEM;
14284
14285 codec->spec = spec;
14286
Kailang Yangda00c242010-03-19 11:23:45 +010014287 alc_auto_parse_customize_define(codec);
14288
Kailang Yang274693f2009-12-03 10:07:50 +010014289 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
Kailang Yangc027ddc2010-03-19 11:33:06 +010014290 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
14291 spec->cdefine.platform_type == 1)
14292 alc_codec_rename(codec, "ALC271X");
14293 else
14294 alc_codec_rename(codec, "ALC259");
Kailang Yang84898e82010-02-04 14:16:14 +010014295 is_alc269vb = 1;
Kailang Yangc027ddc2010-03-19 11:33:06 +010014296 } else
14297 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010014298
Kailang Yangf6a92242007-12-13 16:52:54 +010014299 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14300 alc269_models,
14301 alc269_cfg_tbl);
14302
14303 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014304 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14305 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014306 board_config = ALC269_AUTO;
14307 }
14308
14309 if (board_config == ALC269_AUTO) {
14310 /* automatic parse from the BIOS config */
14311 err = alc269_parse_auto_config(codec);
14312 if (err < 0) {
14313 alc_free(codec);
14314 return err;
14315 } else if (!err) {
14316 printk(KERN_INFO
14317 "hda_codec: Cannot set up configuration "
14318 "from BIOS. Using base mode...\n");
14319 board_config = ALC269_BASIC;
14320 }
14321 }
14322
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014323 err = snd_hda_attach_beep_device(codec, 0x1);
14324 if (err < 0) {
14325 alc_free(codec);
14326 return err;
14327 }
14328
Kailang Yangf6a92242007-12-13 16:52:54 +010014329 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014330 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014331
Kailang Yang84898e82010-02-04 14:16:14 +010014332 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014333 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14334 * fix the sample rate of analog I/O to 44.1kHz
14335 */
14336 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14337 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
14338 } else {
14339 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14340 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14341 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014342 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14343 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14344
Takashi Iwai66946352010-03-29 17:21:45 +020014345 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
14346 if (!is_alc269vb) {
14347 spec->adc_nids = alc269_adc_nids;
14348 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14349 spec->capsrc_nids = alc269_capsrc_nids;
14350 } else {
14351 spec->adc_nids = alc269vb_adc_nids;
14352 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14353 spec->capsrc_nids = alc269vb_capsrc_nids;
14354 }
Kailang Yang84898e82010-02-04 14:16:14 +010014355 }
14356
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014357 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014358 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010014359 if (spec->cdefine.enable_pcbeep)
14360 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014361
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014362 spec->vmaster_nid = 0x02;
14363
Kailang Yangf6a92242007-12-13 16:52:54 +010014364 codec->patch_ops = alc_patch_ops;
14365 if (board_config == ALC269_AUTO)
14366 spec->init_hook = alc269_auto_init;
14367#ifdef CONFIG_SND_HDA_POWER_SAVE
14368 if (!spec->loopback.amplist)
14369 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020014370 if (alc269_mic2_for_mute_led(codec))
14371 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010014372#endif
14373
14374 return 0;
14375}
14376
14377/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014378 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14379 */
14380
14381/*
14382 * set the path ways for 2 channel output
14383 * need to set the codec line out and mic 1 pin widgets to inputs
14384 */
14385static struct hda_verb alc861_threestack_ch2_init[] = {
14386 /* set pin widget 1Ah (line in) for input */
14387 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014388 /* set pin widget 18h (mic1/2) for input, for mic also enable
14389 * the vref
14390 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014391 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14392
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014393 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14394#if 0
14395 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14396 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14397#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014398 { } /* end */
14399};
14400/*
14401 * 6ch mode
14402 * need to set the codec line out and mic 1 pin widgets to outputs
14403 */
14404static struct hda_verb alc861_threestack_ch6_init[] = {
14405 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14406 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14407 /* set pin widget 18h (mic1) for output (CLFE)*/
14408 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14409
14410 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014411 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014412
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014413 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14414#if 0
14415 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14416 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14417#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014418 { } /* end */
14419};
14420
14421static struct hda_channel_mode alc861_threestack_modes[2] = {
14422 { 2, alc861_threestack_ch2_init },
14423 { 6, alc861_threestack_ch6_init },
14424};
Takashi Iwai22309c32006-08-09 16:57:28 +020014425/* Set mic1 as input and unmute the mixer */
14426static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14427 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14428 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14429 { } /* end */
14430};
14431/* Set mic1 as output and mute mixer */
14432static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14433 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14434 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14435 { } /* end */
14436};
14437
14438static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14439 { 2, alc861_uniwill_m31_ch2_init },
14440 { 4, alc861_uniwill_m31_ch4_init },
14441};
Kailang Yangdf694da2005-12-05 19:42:22 +010014442
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014443/* Set mic1 and line-in as input and unmute the mixer */
14444static struct hda_verb alc861_asus_ch2_init[] = {
14445 /* set pin widget 1Ah (line in) for input */
14446 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014447 /* set pin widget 18h (mic1/2) for input, for mic also enable
14448 * the vref
14449 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014450 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14451
14452 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14453#if 0
14454 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14455 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14456#endif
14457 { } /* end */
14458};
14459/* Set mic1 nad line-in as output and mute mixer */
14460static struct hda_verb alc861_asus_ch6_init[] = {
14461 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14462 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14463 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14464 /* set pin widget 18h (mic1) for output (CLFE)*/
14465 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14466 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14467 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14468 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14469
14470 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14471#if 0
14472 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14473 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14474#endif
14475 { } /* end */
14476};
14477
14478static struct hda_channel_mode alc861_asus_modes[2] = {
14479 { 2, alc861_asus_ch2_init },
14480 { 6, alc861_asus_ch6_init },
14481};
14482
Kailang Yangdf694da2005-12-05 19:42:22 +010014483/* patch-ALC861 */
14484
14485static struct snd_kcontrol_new alc861_base_mixer[] = {
14486 /* output mixer control */
14487 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14488 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14489 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14490 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14491 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14492
14493 /*Input mixer control */
14494 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14495 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14496 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14497 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14498 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14499 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14500 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14501 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14502 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14503 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014504
Kailang Yangdf694da2005-12-05 19:42:22 +010014505 { } /* end */
14506};
14507
14508static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14509 /* output mixer control */
14510 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14511 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14512 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14513 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14514 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14515
14516 /* Input mixer control */
14517 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14518 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14519 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14520 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14521 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14522 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14523 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14524 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14525 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14526 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014527
Kailang Yangdf694da2005-12-05 19:42:22 +010014528 {
14529 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14530 .name = "Channel Mode",
14531 .info = alc_ch_mode_info,
14532 .get = alc_ch_mode_get,
14533 .put = alc_ch_mode_put,
14534 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14535 },
14536 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014537};
14538
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014539static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014540 /* output mixer control */
14541 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14542 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14543 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014544
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014545 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014546};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014547
Takashi Iwai22309c32006-08-09 16:57:28 +020014548static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14549 /* output mixer control */
14550 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14551 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14552 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14553 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14554 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14555
14556 /* Input mixer control */
14557 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14558 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14559 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14560 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14561 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14562 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14563 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14564 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14565 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14566 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014567
Takashi Iwai22309c32006-08-09 16:57:28 +020014568 {
14569 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14570 .name = "Channel Mode",
14571 .info = alc_ch_mode_info,
14572 .get = alc_ch_mode_get,
14573 .put = alc_ch_mode_put,
14574 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14575 },
14576 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014577};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014578
14579static struct snd_kcontrol_new alc861_asus_mixer[] = {
14580 /* output mixer control */
14581 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14582 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14583 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14584 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14585 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14586
14587 /* Input mixer control */
14588 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14589 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14590 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14591 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14592 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14593 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14594 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14595 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14596 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014597 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
14598
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014599 {
14600 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14601 .name = "Channel Mode",
14602 .info = alc_ch_mode_info,
14603 .get = alc_ch_mode_get,
14604 .put = alc_ch_mode_put,
14605 .private_value = ARRAY_SIZE(alc861_asus_modes),
14606 },
14607 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014608};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014609
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014610/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014611static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014612 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14613 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014614 { }
14615};
14616
Kailang Yangdf694da2005-12-05 19:42:22 +010014617/*
14618 * generic initialization of ADC, input mixers and output mixers
14619 */
14620static struct hda_verb alc861_base_init_verbs[] = {
14621 /*
14622 * Unmute ADC0 and set the default input to mic-in
14623 */
14624 /* port-A for surround (rear panel) */
14625 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14626 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
14627 /* port-B for mic-in (rear panel) with vref */
14628 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14629 /* port-C for line-in (rear panel) */
14630 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14631 /* port-D for Front */
14632 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14633 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14634 /* port-E for HP out (front panel) */
14635 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14636 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014637 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014638 /* port-F for mic-in (front panel) with vref */
14639 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14640 /* port-G for CLFE (rear panel) */
14641 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14642 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14643 /* port-H for side (rear panel) */
14644 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14645 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
14646 /* CD-in */
14647 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14648 /* route front mic to ADC1*/
14649 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14650 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014651
Kailang Yangdf694da2005-12-05 19:42:22 +010014652 /* Unmute DAC0~3 & spdif out*/
14653 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14654 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14655 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14656 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14657 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014658
Kailang Yangdf694da2005-12-05 19:42:22 +010014659 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14660 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14661 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14662 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14663 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014664
Kailang Yangdf694da2005-12-05 19:42:22 +010014665 /* Unmute Stereo Mixer 15 */
14666 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14667 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14668 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014669 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014670
14671 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14672 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14673 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14674 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14675 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14676 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14677 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14678 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014679 /* hp used DAC 3 (Front) */
14680 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014681 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14682
14683 { }
14684};
14685
14686static struct hda_verb alc861_threestack_init_verbs[] = {
14687 /*
14688 * Unmute ADC0 and set the default input to mic-in
14689 */
14690 /* port-A for surround (rear panel) */
14691 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14692 /* port-B for mic-in (rear panel) with vref */
14693 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14694 /* port-C for line-in (rear panel) */
14695 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14696 /* port-D for Front */
14697 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14698 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14699 /* port-E for HP out (front panel) */
14700 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14701 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014702 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014703 /* port-F for mic-in (front panel) with vref */
14704 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14705 /* port-G for CLFE (rear panel) */
14706 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14707 /* port-H for side (rear panel) */
14708 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14709 /* CD-in */
14710 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14711 /* route front mic to ADC1*/
14712 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14713 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14714 /* Unmute DAC0~3 & spdif out*/
14715 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14716 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14717 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14718 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14719 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014720
Kailang Yangdf694da2005-12-05 19:42:22 +010014721 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14722 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14723 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14724 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14725 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014726
Kailang Yangdf694da2005-12-05 19:42:22 +010014727 /* Unmute Stereo Mixer 15 */
14728 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14729 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14730 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014731 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014732
14733 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14734 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14735 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14736 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14737 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14738 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14739 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14740 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014741 /* hp used DAC 3 (Front) */
14742 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014743 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14744 { }
14745};
Takashi Iwai22309c32006-08-09 16:57:28 +020014746
14747static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14748 /*
14749 * Unmute ADC0 and set the default input to mic-in
14750 */
14751 /* port-A for surround (rear panel) */
14752 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14753 /* port-B for mic-in (rear panel) with vref */
14754 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14755 /* port-C for line-in (rear panel) */
14756 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14757 /* port-D for Front */
14758 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14759 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14760 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014761 /* this has to be set to VREF80 */
14762 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014763 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014764 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014765 /* port-F for mic-in (front panel) with vref */
14766 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14767 /* port-G for CLFE (rear panel) */
14768 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14769 /* port-H for side (rear panel) */
14770 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14771 /* CD-in */
14772 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14773 /* route front mic to ADC1*/
14774 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14775 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14776 /* Unmute DAC0~3 & spdif out*/
14777 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14778 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14779 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14780 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14781 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014782
Takashi Iwai22309c32006-08-09 16:57:28 +020014783 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14784 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14785 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14786 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14787 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014788
Takashi Iwai22309c32006-08-09 16:57:28 +020014789 /* Unmute Stereo Mixer 15 */
14790 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14791 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14792 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014794
14795 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14796 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14797 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14798 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14799 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14800 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14801 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14802 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014803 /* hp used DAC 3 (Front) */
14804 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014805 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14806 { }
14807};
14808
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014809static struct hda_verb alc861_asus_init_verbs[] = {
14810 /*
14811 * Unmute ADC0 and set the default input to mic-in
14812 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014813 /* port-A for surround (rear panel)
14814 * according to codec#0 this is the HP jack
14815 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014816 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14817 /* route front PCM to HP */
14818 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14819 /* port-B for mic-in (rear panel) with vref */
14820 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14821 /* port-C for line-in (rear panel) */
14822 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14823 /* port-D for Front */
14824 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14825 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14826 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014827 /* this has to be set to VREF80 */
14828 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014829 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014830 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014831 /* port-F for mic-in (front panel) with vref */
14832 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14833 /* port-G for CLFE (rear panel) */
14834 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14835 /* port-H for side (rear panel) */
14836 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14837 /* CD-in */
14838 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14839 /* route front mic to ADC1*/
14840 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14841 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14842 /* Unmute DAC0~3 & spdif out*/
14843 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14844 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14845 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14846 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14847 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14848 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14849 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14850 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14851 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14852 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014853
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014854 /* Unmute Stereo Mixer 15 */
14855 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14857 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014858 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014859
14860 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14861 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14862 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14863 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14864 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14865 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14866 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14867 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014868 /* hp used DAC 3 (Front) */
14869 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014870 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14871 { }
14872};
14873
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014874/* additional init verbs for ASUS laptops */
14875static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14876 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14877 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14878 { }
14879};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014880
Kailang Yangdf694da2005-12-05 19:42:22 +010014881/*
14882 * generic initialization of ADC, input mixers and output mixers
14883 */
14884static struct hda_verb alc861_auto_init_verbs[] = {
14885 /*
14886 * Unmute ADC0 and set the default input to mic-in
14887 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014888 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014889 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014890
Kailang Yangdf694da2005-12-05 19:42:22 +010014891 /* Unmute DAC0~3 & spdif out*/
14892 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14893 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14894 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14895 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14896 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014897
Kailang Yangdf694da2005-12-05 19:42:22 +010014898 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14899 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14900 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14901 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14902 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014903
Kailang Yangdf694da2005-12-05 19:42:22 +010014904 /* Unmute Stereo Mixer 15 */
14905 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14906 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14907 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14908 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14909
Takashi Iwai1c209302009-07-22 15:17:45 +020014910 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14911 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14912 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14913 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14914 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14915 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14916 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14917 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014918
14919 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14920 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014921 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14922 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014923 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14924 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014925 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14926 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014927
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014928 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014929
14930 { }
14931};
14932
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014933static struct hda_verb alc861_toshiba_init_verbs[] = {
14934 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014935
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014936 { }
14937};
14938
14939/* toggle speaker-output according to the hp-jack state */
14940static void alc861_toshiba_automute(struct hda_codec *codec)
14941{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014942 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014943
Takashi Iwai47fd8302007-08-10 17:11:07 +020014944 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14945 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14946 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14947 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014948}
14949
14950static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14951 unsigned int res)
14952{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014953 if ((res >> 26) == ALC880_HP_EVENT)
14954 alc861_toshiba_automute(codec);
14955}
14956
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014957/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014958#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14959#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14960#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14961#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14962
14963
14964#define ALC861_DIGOUT_NID 0x07
14965
14966static struct hda_channel_mode alc861_8ch_modes[1] = {
14967 { 8, NULL }
14968};
14969
14970static hda_nid_t alc861_dac_nids[4] = {
14971 /* front, surround, clfe, side */
14972 0x03, 0x06, 0x05, 0x04
14973};
14974
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014975static hda_nid_t alc660_dac_nids[3] = {
14976 /* front, clfe, surround */
14977 0x03, 0x05, 0x06
14978};
14979
Kailang Yangdf694da2005-12-05 19:42:22 +010014980static hda_nid_t alc861_adc_nids[1] = {
14981 /* ADC0-2 */
14982 0x08,
14983};
14984
14985static struct hda_input_mux alc861_capture_source = {
14986 .num_items = 5,
14987 .items = {
14988 { "Mic", 0x0 },
14989 { "Front Mic", 0x3 },
14990 { "Line", 0x1 },
14991 { "CD", 0x4 },
14992 { "Mixer", 0x5 },
14993 },
14994};
14995
Takashi Iwai1c209302009-07-22 15:17:45 +020014996static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14997{
14998 struct alc_spec *spec = codec->spec;
14999 hda_nid_t mix, srcs[5];
15000 int i, j, num;
15001
15002 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15003 return 0;
15004 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15005 if (num < 0)
15006 return 0;
15007 for (i = 0; i < num; i++) {
15008 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015009 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015010 if (type != AC_WID_AUD_OUT)
15011 continue;
15012 for (j = 0; j < spec->multiout.num_dacs; j++)
15013 if (spec->multiout.dac_nids[j] == srcs[i])
15014 break;
15015 if (j >= spec->multiout.num_dacs)
15016 return srcs[i];
15017 }
15018 return 0;
15019}
15020
Kailang Yangdf694da2005-12-05 19:42:22 +010015021/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015022static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015023 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015024{
Takashi Iwai1c209302009-07-22 15:17:45 +020015025 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015026 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015027 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015028
15029 spec->multiout.dac_nids = spec->private_dac_nids;
15030 for (i = 0; i < cfg->line_outs; i++) {
15031 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015032 dac = alc861_look_for_dac(codec, nid);
15033 if (!dac)
15034 continue;
15035 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015036 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015037 return 0;
15038}
15039
Takashi Iwai1c209302009-07-22 15:17:45 +020015040static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15041 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015042{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015043 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015044 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15045}
15046
15047/* add playback controls from the parsed DAC table */
15048static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15049 const struct auto_pin_cfg *cfg)
15050{
15051 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015052 static const char *chname[4] = {
15053 "Front", "Surround", NULL /*CLFE*/, "Side"
15054 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015055 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015056 int i, err;
15057
15058 if (cfg->line_outs == 1) {
15059 const char *pfx = NULL;
15060 if (!cfg->hp_outs)
15061 pfx = "Master";
15062 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15063 pfx = "Speaker";
15064 if (pfx) {
15065 nid = spec->multiout.dac_nids[0];
15066 return alc861_create_out_sw(codec, pfx, nid, 3);
15067 }
15068 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015069
15070 for (i = 0; i < cfg->line_outs; i++) {
15071 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015072 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015073 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015074 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015075 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015076 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015077 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015078 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015079 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015080 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015081 return err;
15082 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015083 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015084 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015085 return err;
15086 }
15087 }
15088 return 0;
15089}
15090
Takashi Iwai1c209302009-07-22 15:17:45 +020015091static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015092{
Takashi Iwai1c209302009-07-22 15:17:45 +020015093 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015094 int err;
15095 hda_nid_t nid;
15096
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015097 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015098 return 0;
15099
15100 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015101 nid = alc861_look_for_dac(codec, pin);
15102 if (nid) {
15103 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15104 if (err < 0)
15105 return err;
15106 spec->multiout.hp_nid = nid;
15107 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015108 }
15109 return 0;
15110}
15111
15112/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015113static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015114 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015115{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015116 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015117}
15118
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015119static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15120 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015121 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015122{
Takashi Iwai1c209302009-07-22 15:17:45 +020015123 hda_nid_t mix, srcs[5];
15124 int i, num;
15125
Jacek Luczak564c5be2008-05-03 18:41:23 +020015126 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15127 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015128 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015129 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015130 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15131 return;
15132 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15133 if (num < 0)
15134 return;
15135 for (i = 0; i < num; i++) {
15136 unsigned int mute;
15137 if (srcs[i] == dac || srcs[i] == 0x15)
15138 mute = AMP_IN_UNMUTE(i);
15139 else
15140 mute = AMP_IN_MUTE(i);
15141 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15142 mute);
15143 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015144}
15145
15146static void alc861_auto_init_multi_out(struct hda_codec *codec)
15147{
15148 struct alc_spec *spec = codec->spec;
15149 int i;
15150
15151 for (i = 0; i < spec->autocfg.line_outs; i++) {
15152 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015153 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015154 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015155 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015156 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015157 }
15158}
15159
15160static void alc861_auto_init_hp_out(struct hda_codec *codec)
15161{
15162 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015163
Takashi Iwai15870f02009-10-05 08:25:13 +020015164 if (spec->autocfg.hp_outs)
15165 alc861_auto_set_output_and_unmute(codec,
15166 spec->autocfg.hp_pins[0],
15167 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015168 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015169 if (spec->autocfg.speaker_outs)
15170 alc861_auto_set_output_and_unmute(codec,
15171 spec->autocfg.speaker_pins[0],
15172 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015173 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015174}
15175
15176static void alc861_auto_init_analog_input(struct hda_codec *codec)
15177{
15178 struct alc_spec *spec = codec->spec;
15179 int i;
15180
15181 for (i = 0; i < AUTO_PIN_LAST; i++) {
15182 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010015183 if (nid >= 0x0c && nid <= 0x11)
15184 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010015185 }
15186}
15187
15188/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015189/* return 1 if successful, 0 if the proper config is not found,
15190 * or a negative error code
15191 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015192static int alc861_parse_auto_config(struct hda_codec *codec)
15193{
15194 struct alc_spec *spec = codec->spec;
15195 int err;
15196 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15197
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015198 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15199 alc861_ignore);
15200 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015201 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015202 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015203 return 0; /* can't find valid BIOS pin config */
15204
Takashi Iwai1c209302009-07-22 15:17:45 +020015205 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015206 if (err < 0)
15207 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015208 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015209 if (err < 0)
15210 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015211 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015212 if (err < 0)
15213 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015214 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015215 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015216 return err;
15217
15218 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15219
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015220 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015221 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
15222
Takashi Iwai603c4012008-07-30 15:01:44 +020015223 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015224 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015225
Takashi Iwaid88897e2008-10-31 15:01:37 +010015226 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015227
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015228 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015229 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015230
15231 spec->adc_nids = alc861_adc_nids;
15232 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015233 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015234
Kailang Yang6227cdc2010-02-25 08:36:52 +010015235 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015236
Kailang Yangdf694da2005-12-05 19:42:22 +010015237 return 1;
15238}
15239
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015240/* additional initialization for auto-configuration model */
15241static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015242{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015243 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015244 alc861_auto_init_multi_out(codec);
15245 alc861_auto_init_hp_out(codec);
15246 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015247 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015248 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015249}
15250
Takashi Iwaicb53c622007-08-10 17:21:45 +020015251#ifdef CONFIG_SND_HDA_POWER_SAVE
15252static struct hda_amp_list alc861_loopbacks[] = {
15253 { 0x15, HDA_INPUT, 0 },
15254 { 0x15, HDA_INPUT, 1 },
15255 { 0x15, HDA_INPUT, 2 },
15256 { 0x15, HDA_INPUT, 3 },
15257 { } /* end */
15258};
15259#endif
15260
Kailang Yangdf694da2005-12-05 19:42:22 +010015261
15262/*
15263 * configuration and preset
15264 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015265static const char *alc861_models[ALC861_MODEL_LAST] = {
15266 [ALC861_3ST] = "3stack",
15267 [ALC660_3ST] = "3stack-660",
15268 [ALC861_3ST_DIG] = "3stack-dig",
15269 [ALC861_6ST_DIG] = "6stack-dig",
15270 [ALC861_UNIWILL_M31] = "uniwill-m31",
15271 [ALC861_TOSHIBA] = "toshiba",
15272 [ALC861_ASUS] = "asus",
15273 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15274 [ALC861_AUTO] = "auto",
15275};
15276
15277static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015278 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015279 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15280 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15281 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015282 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015283 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015284 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015285 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15286 * Any other models that need this preset?
15287 */
15288 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015289 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15290 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015291 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15292 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15293 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15294 /* FIXME: the below seems conflict */
15295 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15296 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15297 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015298 {}
15299};
15300
15301static struct alc_config_preset alc861_presets[] = {
15302 [ALC861_3ST] = {
15303 .mixers = { alc861_3ST_mixer },
15304 .init_verbs = { alc861_threestack_init_verbs },
15305 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15306 .dac_nids = alc861_dac_nids,
15307 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15308 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015309 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015310 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15311 .adc_nids = alc861_adc_nids,
15312 .input_mux = &alc861_capture_source,
15313 },
15314 [ALC861_3ST_DIG] = {
15315 .mixers = { alc861_base_mixer },
15316 .init_verbs = { alc861_threestack_init_verbs },
15317 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15318 .dac_nids = alc861_dac_nids,
15319 .dig_out_nid = ALC861_DIGOUT_NID,
15320 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15321 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015322 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015323 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15324 .adc_nids = alc861_adc_nids,
15325 .input_mux = &alc861_capture_source,
15326 },
15327 [ALC861_6ST_DIG] = {
15328 .mixers = { alc861_base_mixer },
15329 .init_verbs = { alc861_base_init_verbs },
15330 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15331 .dac_nids = alc861_dac_nids,
15332 .dig_out_nid = ALC861_DIGOUT_NID,
15333 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15334 .channel_mode = alc861_8ch_modes,
15335 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15336 .adc_nids = alc861_adc_nids,
15337 .input_mux = &alc861_capture_source,
15338 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015339 [ALC660_3ST] = {
15340 .mixers = { alc861_3ST_mixer },
15341 .init_verbs = { alc861_threestack_init_verbs },
15342 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15343 .dac_nids = alc660_dac_nids,
15344 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15345 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015346 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015347 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15348 .adc_nids = alc861_adc_nids,
15349 .input_mux = &alc861_capture_source,
15350 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015351 [ALC861_UNIWILL_M31] = {
15352 .mixers = { alc861_uniwill_m31_mixer },
15353 .init_verbs = { alc861_uniwill_m31_init_verbs },
15354 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15355 .dac_nids = alc861_dac_nids,
15356 .dig_out_nid = ALC861_DIGOUT_NID,
15357 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15358 .channel_mode = alc861_uniwill_m31_modes,
15359 .need_dac_fix = 1,
15360 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15361 .adc_nids = alc861_adc_nids,
15362 .input_mux = &alc861_capture_source,
15363 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015364 [ALC861_TOSHIBA] = {
15365 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015366 .init_verbs = { alc861_base_init_verbs,
15367 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015368 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15369 .dac_nids = alc861_dac_nids,
15370 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15371 .channel_mode = alc883_3ST_2ch_modes,
15372 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15373 .adc_nids = alc861_adc_nids,
15374 .input_mux = &alc861_capture_source,
15375 .unsol_event = alc861_toshiba_unsol_event,
15376 .init_hook = alc861_toshiba_automute,
15377 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015378 [ALC861_ASUS] = {
15379 .mixers = { alc861_asus_mixer },
15380 .init_verbs = { alc861_asus_init_verbs },
15381 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15382 .dac_nids = alc861_dac_nids,
15383 .dig_out_nid = ALC861_DIGOUT_NID,
15384 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15385 .channel_mode = alc861_asus_modes,
15386 .need_dac_fix = 1,
15387 .hp_nid = 0x06,
15388 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15389 .adc_nids = alc861_adc_nids,
15390 .input_mux = &alc861_capture_source,
15391 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015392 [ALC861_ASUS_LAPTOP] = {
15393 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15394 .init_verbs = { alc861_asus_init_verbs,
15395 alc861_asus_laptop_init_verbs },
15396 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15397 .dac_nids = alc861_dac_nids,
15398 .dig_out_nid = ALC861_DIGOUT_NID,
15399 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15400 .channel_mode = alc883_3ST_2ch_modes,
15401 .need_dac_fix = 1,
15402 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15403 .adc_nids = alc861_adc_nids,
15404 .input_mux = &alc861_capture_source,
15405 },
15406};
Kailang Yangdf694da2005-12-05 19:42:22 +010015407
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015408/* Pin config fixes */
15409enum {
15410 PINFIX_FSC_AMILO_PI1505,
15411};
15412
15413static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
15414 { 0x0b, 0x0221101f }, /* HP */
15415 { 0x0f, 0x90170310 }, /* speaker */
15416 { }
15417};
15418
15419static const struct alc_fixup alc861_fixups[] = {
15420 [PINFIX_FSC_AMILO_PI1505] = {
15421 .pins = alc861_fsc_amilo_pi1505_pinfix
15422 },
15423};
15424
15425static struct snd_pci_quirk alc861_fixup_tbl[] = {
15426 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15427 {}
15428};
Kailang Yangdf694da2005-12-05 19:42:22 +010015429
15430static int patch_alc861(struct hda_codec *codec)
15431{
15432 struct alc_spec *spec;
15433 int board_config;
15434 int err;
15435
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015436 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015437 if (spec == NULL)
15438 return -ENOMEM;
15439
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015440 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015441
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015442 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15443 alc861_models,
15444 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015445
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015446 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015447 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15448 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015449 board_config = ALC861_AUTO;
15450 }
15451
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015452 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
15453
Kailang Yangdf694da2005-12-05 19:42:22 +010015454 if (board_config == ALC861_AUTO) {
15455 /* automatic parse from the BIOS config */
15456 err = alc861_parse_auto_config(codec);
15457 if (err < 0) {
15458 alc_free(codec);
15459 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015460 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015461 printk(KERN_INFO
15462 "hda_codec: Cannot set up configuration "
15463 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015464 board_config = ALC861_3ST_DIG;
15465 }
15466 }
15467
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015468 err = snd_hda_attach_beep_device(codec, 0x23);
15469 if (err < 0) {
15470 alc_free(codec);
15471 return err;
15472 }
15473
Kailang Yangdf694da2005-12-05 19:42:22 +010015474 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015475 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015476
Kailang Yangdf694da2005-12-05 19:42:22 +010015477 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15478 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15479
Kailang Yangdf694da2005-12-05 19:42:22 +010015480 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15481 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15482
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015483 if (!spec->cap_mixer)
15484 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015485 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15486
Takashi Iwai2134ea42008-01-10 16:53:55 +010015487 spec->vmaster_nid = 0x03;
15488
Kailang Yangdf694da2005-12-05 19:42:22 +010015489 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015490 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015491 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015492#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015493 spec->power_hook = alc_power_eapd;
15494#endif
15495 }
15496#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015497 if (!spec->loopback.amplist)
15498 spec->loopback.amplist = alc861_loopbacks;
15499#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015500
Kailang Yangdf694da2005-12-05 19:42:22 +010015501 return 0;
15502}
15503
15504/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015505 * ALC861-VD support
15506 *
15507 * Based on ALC882
15508 *
15509 * In addition, an independent DAC
15510 */
15511#define ALC861VD_DIGOUT_NID 0x06
15512
15513static hda_nid_t alc861vd_dac_nids[4] = {
15514 /* front, surr, clfe, side surr */
15515 0x02, 0x03, 0x04, 0x05
15516};
15517
15518/* dac_nids for ALC660vd are in a different order - according to
15519 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015520 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015521 * of ALC660vd codecs, but for now there is only 3stack mixer
15522 * - and it is the same as in 861vd.
15523 * adc_nids in ALC660vd are (is) the same as in 861vd
15524 */
15525static hda_nid_t alc660vd_dac_nids[3] = {
15526 /* front, rear, clfe, rear_surr */
15527 0x02, 0x04, 0x03
15528};
15529
15530static hda_nid_t alc861vd_adc_nids[1] = {
15531 /* ADC0 */
15532 0x09,
15533};
15534
Takashi Iwaie1406342008-02-11 18:32:32 +010015535static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15536
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015537/* input MUX */
15538/* FIXME: should be a matrix-type input source selection */
15539static struct hda_input_mux alc861vd_capture_source = {
15540 .num_items = 4,
15541 .items = {
15542 { "Mic", 0x0 },
15543 { "Front Mic", 0x1 },
15544 { "Line", 0x2 },
15545 { "CD", 0x4 },
15546 },
15547};
15548
Kailang Yang272a5272007-05-14 11:00:38 +020015549static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015550 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015551 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015552 { "Ext Mic", 0x0 },
15553 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015554 },
15555};
15556
Kailang Yangd1a991a2007-08-15 16:21:59 +020015557static struct hda_input_mux alc861vd_hp_capture_source = {
15558 .num_items = 2,
15559 .items = {
15560 { "Front Mic", 0x0 },
15561 { "ATAPI Mic", 0x1 },
15562 },
15563};
15564
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015565/*
15566 * 2ch mode
15567 */
15568static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15569 { 2, NULL }
15570};
15571
15572/*
15573 * 6ch mode
15574 */
15575static struct hda_verb alc861vd_6stack_ch6_init[] = {
15576 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15577 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15578 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15579 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15580 { } /* end */
15581};
15582
15583/*
15584 * 8ch mode
15585 */
15586static struct hda_verb alc861vd_6stack_ch8_init[] = {
15587 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15588 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15589 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15590 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15591 { } /* end */
15592};
15593
15594static struct hda_channel_mode alc861vd_6stack_modes[2] = {
15595 { 6, alc861vd_6stack_ch6_init },
15596 { 8, alc861vd_6stack_ch8_init },
15597};
15598
15599static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
15600 {
15601 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15602 .name = "Channel Mode",
15603 .info = alc_ch_mode_info,
15604 .get = alc_ch_mode_get,
15605 .put = alc_ch_mode_put,
15606 },
15607 { } /* end */
15608};
15609
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015610/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15611 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15612 */
15613static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
15614 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15615 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15616
15617 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15618 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
15619
15620 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
15621 HDA_OUTPUT),
15622 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
15623 HDA_OUTPUT),
15624 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
15625 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
15626
15627 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
15628 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
15629
15630 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15631
15632 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15633 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15634 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15635
15636 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15637 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15638 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15639
15640 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15641 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15642
15643 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15644 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15645
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015646 { } /* end */
15647};
15648
15649static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
15650 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15651 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15652
15653 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15654
15655 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15656 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15657 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15658
15659 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15660 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15661 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15662
15663 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15664 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15665
15666 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15667 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15668
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015669 { } /* end */
15670};
15671
Kailang Yangbdd148a2007-05-08 15:19:08 +020015672static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15673 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15674 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15675 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15676
15677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15678
15679 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15681 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15682
15683 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15684 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15685 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15686
15687 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15688 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15689
15690 { } /* end */
15691};
15692
Tobin Davisb419f342008-03-07 11:57:51 +010015693/* Pin assignment: Speaker=0x14, HP = 0x15,
15694 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015695 */
15696static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015697 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15698 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015699 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15700 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015701 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15702 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15703 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15704 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15705 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15706 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015707 { } /* end */
15708};
15709
Kailang Yangd1a991a2007-08-15 16:21:59 +020015710/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15711 * Front Mic=0x18, ATAPI Mic = 0x19,
15712 */
15713static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15714 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15715 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15716 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15717 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15718 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15719 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15720 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15721 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015722
Kailang Yangd1a991a2007-08-15 16:21:59 +020015723 { } /* end */
15724};
15725
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015726/*
15727 * generic initialization of ADC, input mixers and output mixers
15728 */
15729static struct hda_verb alc861vd_volume_init_verbs[] = {
15730 /*
15731 * Unmute ADC0 and set the default input to mic-in
15732 */
15733 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15734 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15735
15736 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15737 * the analog-loopback mixer widget
15738 */
15739 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015740 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15741 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15742 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15743 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015745
15746 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015747 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15748 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15749 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015750 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015751
15752 /*
15753 * Set up output mixers (0x02 - 0x05)
15754 */
15755 /* set vol=0 to output mixers */
15756 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15757 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15758 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15759 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15760
15761 /* set up input amps for analog loopback */
15762 /* Amp Indices: DAC = 0, mixer = 1 */
15763 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15764 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15765 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15766 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15767 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15768 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15769 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15770 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15771
15772 { }
15773};
15774
15775/*
15776 * 3-stack pin configuration:
15777 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15778 */
15779static struct hda_verb alc861vd_3stack_init_verbs[] = {
15780 /*
15781 * Set pin mode and muting
15782 */
15783 /* set front pin widgets 0x14 for output */
15784 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15785 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15786 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15787
15788 /* Mic (rear) pin: input vref at 80% */
15789 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15790 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15791 /* Front Mic pin: input vref at 80% */
15792 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15793 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15794 /* Line In pin: input */
15795 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15796 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15797 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15798 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15799 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15800 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15801 /* CD pin widget for input */
15802 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15803
15804 { }
15805};
15806
15807/*
15808 * 6-stack pin configuration:
15809 */
15810static struct hda_verb alc861vd_6stack_init_verbs[] = {
15811 /*
15812 * Set pin mode and muting
15813 */
15814 /* set front pin widgets 0x14 for output */
15815 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15816 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15817 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15818
15819 /* Rear Pin: output 1 (0x0d) */
15820 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15821 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15822 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15823 /* CLFE Pin: output 2 (0x0e) */
15824 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15825 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15826 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15827 /* Side Pin: output 3 (0x0f) */
15828 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15829 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15830 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15831
15832 /* Mic (rear) pin: input vref at 80% */
15833 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15834 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15835 /* Front Mic pin: input vref at 80% */
15836 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15837 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15838 /* Line In pin: input */
15839 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15840 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15841 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15842 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15843 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15844 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15845 /* CD pin widget for input */
15846 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15847
15848 { }
15849};
15850
Kailang Yangbdd148a2007-05-08 15:19:08 +020015851static struct hda_verb alc861vd_eapd_verbs[] = {
15852 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15853 { }
15854};
15855
Kailang Yangf9423e72008-05-27 12:32:25 +020015856static struct hda_verb alc660vd_eapd_verbs[] = {
15857 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15858 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15859 { }
15860};
15861
Kailang Yangbdd148a2007-05-08 15:19:08 +020015862static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15863 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15864 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15865 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15866 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015867 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015868 {}
15869};
15870
Kailang Yangbdd148a2007-05-08 15:19:08 +020015871static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15872{
15873 unsigned int present;
15874 unsigned char bits;
15875
Wu Fengguang864f92b2009-11-18 12:38:02 +080015876 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015877 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015878
Takashi Iwai47fd8302007-08-10 17:11:07 +020015879 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15880 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015881}
15882
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015883static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015884{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015885 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015886 spec->autocfg.hp_pins[0] = 0x1b;
15887 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015888}
15889
15890static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15891{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015892 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015893 alc861vd_lenovo_mic_automute(codec);
15894}
15895
15896static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15897 unsigned int res)
15898{
15899 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015900 case ALC880_MIC_EVENT:
15901 alc861vd_lenovo_mic_automute(codec);
15902 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015903 default:
15904 alc_automute_amp_unsol_event(codec, res);
15905 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015906 }
15907}
15908
Kailang Yang272a5272007-05-14 11:00:38 +020015909static struct hda_verb alc861vd_dallas_verbs[] = {
15910 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15911 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15912 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15913 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15914
15915 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15916 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15917 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15918 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15919 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15920 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15921 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15922 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015923
Kailang Yang272a5272007-05-14 11:00:38 +020015924 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15925 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15926 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15927 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15928 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15929 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15930 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15931 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15932
15933 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15934 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15935 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15936 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15937 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15938 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15939 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15940 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15941
15942 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15943 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15944 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15945 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15946
15947 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015948 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015949 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15950
15951 { } /* end */
15952};
15953
15954/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015955static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015956{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015957 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015958
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015959 spec->autocfg.hp_pins[0] = 0x15;
15960 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015961}
15962
Takashi Iwaicb53c622007-08-10 17:21:45 +020015963#ifdef CONFIG_SND_HDA_POWER_SAVE
15964#define alc861vd_loopbacks alc880_loopbacks
15965#endif
15966
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015967/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015968#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15969#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15970#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15971#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15972
15973/*
15974 * configuration and preset
15975 */
15976static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15977 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015978 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015979 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015980 [ALC861VD_3ST] = "3stack",
15981 [ALC861VD_3ST_DIG] = "3stack-digout",
15982 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015983 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015984 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015985 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015986 [ALC861VD_AUTO] = "auto",
15987};
15988
15989static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015990 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15991 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015992 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015993 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015994 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015995 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015996 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015997 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015998 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015999 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016000 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016001 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016002 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016003 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016004 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016005 {}
16006};
16007
16008static struct alc_config_preset alc861vd_presets[] = {
16009 [ALC660VD_3ST] = {
16010 .mixers = { alc861vd_3st_mixer },
16011 .init_verbs = { alc861vd_volume_init_verbs,
16012 alc861vd_3stack_init_verbs },
16013 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16014 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016015 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16016 .channel_mode = alc861vd_3stack_2ch_modes,
16017 .input_mux = &alc861vd_capture_source,
16018 },
Mike Crash6963f842007-06-25 12:12:51 +020016019 [ALC660VD_3ST_DIG] = {
16020 .mixers = { alc861vd_3st_mixer },
16021 .init_verbs = { alc861vd_volume_init_verbs,
16022 alc861vd_3stack_init_verbs },
16023 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16024 .dac_nids = alc660vd_dac_nids,
16025 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016026 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16027 .channel_mode = alc861vd_3stack_2ch_modes,
16028 .input_mux = &alc861vd_capture_source,
16029 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016030 [ALC861VD_3ST] = {
16031 .mixers = { alc861vd_3st_mixer },
16032 .init_verbs = { alc861vd_volume_init_verbs,
16033 alc861vd_3stack_init_verbs },
16034 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16035 .dac_nids = alc861vd_dac_nids,
16036 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16037 .channel_mode = alc861vd_3stack_2ch_modes,
16038 .input_mux = &alc861vd_capture_source,
16039 },
16040 [ALC861VD_3ST_DIG] = {
16041 .mixers = { alc861vd_3st_mixer },
16042 .init_verbs = { alc861vd_volume_init_verbs,
16043 alc861vd_3stack_init_verbs },
16044 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16045 .dac_nids = alc861vd_dac_nids,
16046 .dig_out_nid = ALC861VD_DIGOUT_NID,
16047 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16048 .channel_mode = alc861vd_3stack_2ch_modes,
16049 .input_mux = &alc861vd_capture_source,
16050 },
16051 [ALC861VD_6ST_DIG] = {
16052 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16053 .init_verbs = { alc861vd_volume_init_verbs,
16054 alc861vd_6stack_init_verbs },
16055 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16056 .dac_nids = alc861vd_dac_nids,
16057 .dig_out_nid = ALC861VD_DIGOUT_NID,
16058 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16059 .channel_mode = alc861vd_6stack_modes,
16060 .input_mux = &alc861vd_capture_source,
16061 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016062 [ALC861VD_LENOVO] = {
16063 .mixers = { alc861vd_lenovo_mixer },
16064 .init_verbs = { alc861vd_volume_init_verbs,
16065 alc861vd_3stack_init_verbs,
16066 alc861vd_eapd_verbs,
16067 alc861vd_lenovo_unsol_verbs },
16068 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16069 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016070 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16071 .channel_mode = alc861vd_3stack_2ch_modes,
16072 .input_mux = &alc861vd_capture_source,
16073 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016074 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016075 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016076 },
Kailang Yang272a5272007-05-14 11:00:38 +020016077 [ALC861VD_DALLAS] = {
16078 .mixers = { alc861vd_dallas_mixer },
16079 .init_verbs = { alc861vd_dallas_verbs },
16080 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16081 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016082 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16083 .channel_mode = alc861vd_3stack_2ch_modes,
16084 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016085 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016086 .setup = alc861vd_dallas_setup,
16087 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016088 },
16089 [ALC861VD_HP] = {
16090 .mixers = { alc861vd_hp_mixer },
16091 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16092 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16093 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016094 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016095 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16096 .channel_mode = alc861vd_3stack_2ch_modes,
16097 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016098 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016099 .setup = alc861vd_dallas_setup,
16100 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016101 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016102 [ALC660VD_ASUS_V1S] = {
16103 .mixers = { alc861vd_lenovo_mixer },
16104 .init_verbs = { alc861vd_volume_init_verbs,
16105 alc861vd_3stack_init_verbs,
16106 alc861vd_eapd_verbs,
16107 alc861vd_lenovo_unsol_verbs },
16108 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16109 .dac_nids = alc660vd_dac_nids,
16110 .dig_out_nid = ALC861VD_DIGOUT_NID,
16111 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16112 .channel_mode = alc861vd_3stack_2ch_modes,
16113 .input_mux = &alc861vd_capture_source,
16114 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016115 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016116 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016117 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016118};
16119
16120/*
16121 * BIOS auto configuration
16122 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016123static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16124 const struct auto_pin_cfg *cfg)
16125{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016126 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016127}
16128
16129
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016130static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16131 hda_nid_t nid, int pin_type, int dac_idx)
16132{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016133 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016134}
16135
16136static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16137{
16138 struct alc_spec *spec = codec->spec;
16139 int i;
16140
16141 for (i = 0; i <= HDA_SIDE; i++) {
16142 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016143 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016144 if (nid)
16145 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016146 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016147 }
16148}
16149
16150
16151static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16152{
16153 struct alc_spec *spec = codec->spec;
16154 hda_nid_t pin;
16155
16156 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016157 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016158 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016159 pin = spec->autocfg.speaker_pins[0];
16160 if (pin)
16161 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016162}
16163
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016164#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16165
16166static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16167{
16168 struct alc_spec *spec = codec->spec;
16169 int i;
16170
16171 for (i = 0; i < AUTO_PIN_LAST; i++) {
16172 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020016173 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016174 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016175 if (nid != ALC861VD_PIN_CD_NID &&
16176 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016177 snd_hda_codec_write(codec, nid, 0,
16178 AC_VERB_SET_AMP_GAIN_MUTE,
16179 AMP_OUT_MUTE);
16180 }
16181 }
16182}
16183
Takashi Iwaif511b012008-08-15 16:46:42 +020016184#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16185
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016186#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16187#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16188
16189/* add playback controls from the parsed DAC table */
16190/* Based on ALC880 version. But ALC861VD has separate,
16191 * different NIDs for mute/unmute switch and volume control */
16192static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16193 const struct auto_pin_cfg *cfg)
16194{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016195 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16196 hda_nid_t nid_v, nid_s;
16197 int i, err;
16198
16199 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016200 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016201 continue;
16202 nid_v = alc861vd_idx_to_mixer_vol(
16203 alc880_dac_to_idx(
16204 spec->multiout.dac_nids[i]));
16205 nid_s = alc861vd_idx_to_mixer_switch(
16206 alc880_dac_to_idx(
16207 spec->multiout.dac_nids[i]));
16208
16209 if (i == 2) {
16210 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016211 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16212 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016213 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16214 HDA_OUTPUT));
16215 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016216 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016217 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16218 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016219 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16220 HDA_OUTPUT));
16221 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016222 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016223 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16224 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016225 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16226 HDA_INPUT));
16227 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016228 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016229 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16230 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016231 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16232 HDA_INPUT));
16233 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016234 return err;
16235 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016236 const char *pfx;
16237 if (cfg->line_outs == 1 &&
16238 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16239 if (!cfg->hp_pins)
16240 pfx = "Speaker";
16241 else
16242 pfx = "PCM";
16243 } else
16244 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016245 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016246 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16247 HDA_OUTPUT));
16248 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016249 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016250 if (cfg->line_outs == 1 &&
16251 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16252 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016253 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016254 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016255 HDA_INPUT));
16256 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016257 return err;
16258 }
16259 }
16260 return 0;
16261}
16262
16263/* add playback controls for speaker and HP outputs */
16264/* Based on ALC880 version. But ALC861VD has separate,
16265 * different NIDs for mute/unmute switch and volume control */
16266static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16267 hda_nid_t pin, const char *pfx)
16268{
16269 hda_nid_t nid_v, nid_s;
16270 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016271
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016272 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016273 return 0;
16274
16275 if (alc880_is_fixed_pin(pin)) {
16276 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16277 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016278 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016279 spec->multiout.hp_nid = nid_v;
16280 else
16281 spec->multiout.extra_out_nid[0] = nid_v;
16282 /* control HP volume/switch on the output mixer amp */
16283 nid_v = alc861vd_idx_to_mixer_vol(
16284 alc880_fixed_pin_idx(pin));
16285 nid_s = alc861vd_idx_to_mixer_switch(
16286 alc880_fixed_pin_idx(pin));
16287
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016288 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016289 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16290 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016291 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016292 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016293 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16294 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016295 return err;
16296 } else if (alc880_is_multi_pin(pin)) {
16297 /* set manual connection */
16298 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016299 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016300 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16301 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016302 return err;
16303 }
16304 return 0;
16305}
16306
16307/* parse the BIOS configuration and set up the alc_spec
16308 * return 1 if successful, 0 if the proper config is not found,
16309 * or a negative error code
16310 * Based on ALC880 version - had to change it to override
16311 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16312static int alc861vd_parse_auto_config(struct hda_codec *codec)
16313{
16314 struct alc_spec *spec = codec->spec;
16315 int err;
16316 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16317
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016318 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16319 alc861vd_ignore);
16320 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016321 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016322 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016323 return 0; /* can't find valid BIOS pin config */
16324
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016325 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16326 if (err < 0)
16327 return err;
16328 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16329 if (err < 0)
16330 return err;
16331 err = alc861vd_auto_create_extra_out(spec,
16332 spec->autocfg.speaker_pins[0],
16333 "Speaker");
16334 if (err < 0)
16335 return err;
16336 err = alc861vd_auto_create_extra_out(spec,
16337 spec->autocfg.hp_pins[0],
16338 "Headphone");
16339 if (err < 0)
16340 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016341 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016342 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016343 return err;
16344
16345 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16346
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016347 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016348 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
16349
Takashi Iwai603c4012008-07-30 15:01:44 +020016350 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016351 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016352
Takashi Iwaid88897e2008-10-31 15:01:37 +010016353 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016354
16355 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016356 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016357
Takashi Iwai776e1842007-08-29 15:07:11 +020016358 err = alc_auto_add_mic_boost(codec);
16359 if (err < 0)
16360 return err;
16361
Kailang Yang6227cdc2010-02-25 08:36:52 +010016362 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016363
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016364 return 1;
16365}
16366
16367/* additional initialization for auto-configuration model */
16368static void alc861vd_auto_init(struct hda_codec *codec)
16369{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016370 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016371 alc861vd_auto_init_multi_out(codec);
16372 alc861vd_auto_init_hp_out(codec);
16373 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016374 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016375 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016376 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016377}
16378
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016379enum {
16380 ALC660VD_FIX_ASUS_GPIO1
16381};
16382
16383/* reset GPIO1 */
16384static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
16385 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16386 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16387 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16388 { }
16389};
16390
16391static const struct alc_fixup alc861vd_fixups[] = {
16392 [ALC660VD_FIX_ASUS_GPIO1] = {
16393 .verbs = alc660vd_fix_asus_gpio1_verbs,
16394 },
16395};
16396
16397static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16398 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16399 {}
16400};
16401
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016402static int patch_alc861vd(struct hda_codec *codec)
16403{
16404 struct alc_spec *spec;
16405 int err, board_config;
16406
16407 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16408 if (spec == NULL)
16409 return -ENOMEM;
16410
16411 codec->spec = spec;
16412
16413 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16414 alc861vd_models,
16415 alc861vd_cfg_tbl);
16416
16417 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016418 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16419 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016420 board_config = ALC861VD_AUTO;
16421 }
16422
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016423 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
16424
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016425 if (board_config == ALC861VD_AUTO) {
16426 /* automatic parse from the BIOS config */
16427 err = alc861vd_parse_auto_config(codec);
16428 if (err < 0) {
16429 alc_free(codec);
16430 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016431 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016432 printk(KERN_INFO
16433 "hda_codec: Cannot set up configuration "
16434 "from BIOS. Using base mode...\n");
16435 board_config = ALC861VD_3ST;
16436 }
16437 }
16438
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016439 err = snd_hda_attach_beep_device(codec, 0x23);
16440 if (err < 0) {
16441 alc_free(codec);
16442 return err;
16443 }
16444
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016445 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016446 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016447
Kailang Yang2f893282008-05-27 12:14:47 +020016448 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016449 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016450 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016451 }
16452
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016453 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16454 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16455
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016456 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16457 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16458
Takashi Iwaidd704692009-08-11 08:45:11 +020016459 if (!spec->adc_nids) {
16460 spec->adc_nids = alc861vd_adc_nids;
16461 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16462 }
16463 if (!spec->capsrc_nids)
16464 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016465
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016466 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016467 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016468
Takashi Iwai2134ea42008-01-10 16:53:55 +010016469 spec->vmaster_nid = 0x02;
16470
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016471 codec->patch_ops = alc_patch_ops;
16472
16473 if (board_config == ALC861VD_AUTO)
16474 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016475#ifdef CONFIG_SND_HDA_POWER_SAVE
16476 if (!spec->loopback.amplist)
16477 spec->loopback.amplist = alc861vd_loopbacks;
16478#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016479
16480 return 0;
16481}
16482
16483/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016484 * ALC662 support
16485 *
16486 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16487 * configuration. Each pin widget can choose any input DACs and a mixer.
16488 * Each ADC is connected from a mixer of all inputs. This makes possible
16489 * 6-channel independent captures.
16490 *
16491 * In addition, an independent DAC for the multi-playback (not used in this
16492 * driver yet).
16493 */
16494#define ALC662_DIGOUT_NID 0x06
16495#define ALC662_DIGIN_NID 0x0a
16496
16497static hda_nid_t alc662_dac_nids[4] = {
16498 /* front, rear, clfe, rear_surr */
16499 0x02, 0x03, 0x04
16500};
16501
Kailang Yang622e84c2009-04-21 07:39:04 +020016502static hda_nid_t alc272_dac_nids[2] = {
16503 0x02, 0x03
16504};
16505
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016506static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016507 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016508 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016509};
Takashi Iwaie1406342008-02-11 18:32:32 +010016510
Kailang Yang622e84c2009-04-21 07:39:04 +020016511static hda_nid_t alc272_adc_nids[1] = {
16512 /* ADC1-2 */
16513 0x08,
16514};
16515
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016516static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016517static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16518
Takashi Iwaie1406342008-02-11 18:32:32 +010016519
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016520/* input MUX */
16521/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016522static struct hda_input_mux alc662_capture_source = {
16523 .num_items = 4,
16524 .items = {
16525 { "Mic", 0x0 },
16526 { "Front Mic", 0x1 },
16527 { "Line", 0x2 },
16528 { "CD", 0x4 },
16529 },
16530};
16531
16532static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16533 .num_items = 2,
16534 .items = {
16535 { "Mic", 0x1 },
16536 { "Line", 0x2 },
16537 },
16538};
Kailang Yang291702f2007-10-16 14:28:03 +020016539
Kailang Yang6dda9f42008-05-27 12:05:31 +020016540static struct hda_input_mux alc663_capture_source = {
16541 .num_items = 3,
16542 .items = {
16543 { "Mic", 0x0 },
16544 { "Front Mic", 0x1 },
16545 { "Line", 0x2 },
16546 },
16547};
16548
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016549#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016550static struct hda_input_mux alc272_nc10_capture_source = {
16551 .num_items = 16,
16552 .items = {
16553 { "Autoselect Mic", 0x0 },
16554 { "Internal Mic", 0x1 },
16555 { "In-0x02", 0x2 },
16556 { "In-0x03", 0x3 },
16557 { "In-0x04", 0x4 },
16558 { "In-0x05", 0x5 },
16559 { "In-0x06", 0x6 },
16560 { "In-0x07", 0x7 },
16561 { "In-0x08", 0x8 },
16562 { "In-0x09", 0x9 },
16563 { "In-0x0a", 0x0a },
16564 { "In-0x0b", 0x0b },
16565 { "In-0x0c", 0x0c },
16566 { "In-0x0d", 0x0d },
16567 { "In-0x0e", 0x0e },
16568 { "In-0x0f", 0x0f },
16569 },
16570};
16571#endif
16572
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016573/*
16574 * 2ch mode
16575 */
16576static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16577 { 2, NULL }
16578};
16579
16580/*
16581 * 2ch mode
16582 */
16583static struct hda_verb alc662_3ST_ch2_init[] = {
16584 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16585 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16586 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16587 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16588 { } /* end */
16589};
16590
16591/*
16592 * 6ch mode
16593 */
16594static struct hda_verb alc662_3ST_ch6_init[] = {
16595 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16596 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16597 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
16598 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16599 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16600 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
16601 { } /* end */
16602};
16603
16604static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
16605 { 2, alc662_3ST_ch2_init },
16606 { 6, alc662_3ST_ch6_init },
16607};
16608
16609/*
16610 * 2ch mode
16611 */
16612static struct hda_verb alc662_sixstack_ch6_init[] = {
16613 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16614 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16615 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16616 { } /* end */
16617};
16618
16619/*
16620 * 6ch mode
16621 */
16622static struct hda_verb alc662_sixstack_ch8_init[] = {
16623 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16624 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16625 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16626 { } /* end */
16627};
16628
16629static struct hda_channel_mode alc662_5stack_modes[2] = {
16630 { 2, alc662_sixstack_ch6_init },
16631 { 6, alc662_sixstack_ch8_init },
16632};
16633
16634/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16635 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16636 */
16637
16638static struct snd_kcontrol_new alc662_base_mixer[] = {
16639 /* output mixer control */
16640 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016641 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016642 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016643 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016644 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16645 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016646 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16647 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016648 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16649
16650 /*Input mixer control */
16651 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
16652 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
16653 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
16654 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
16655 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
16656 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
16657 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
16658 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016659 { } /* end */
16660};
16661
16662static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16663 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016664 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016665 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16666 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16667 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16668 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16669 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16670 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16671 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16672 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16673 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016674 { } /* end */
16675};
16676
16677static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16678 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016679 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016680 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016681 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016682 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16683 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016684 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16685 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016686 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16687 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16688 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16689 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16690 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16691 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16692 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16693 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16694 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016695 { } /* end */
16696};
16697
16698static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16699 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16700 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016701 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16702 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016703 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16704 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16705 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16707 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016708 { } /* end */
16709};
16710
Kailang Yang291702f2007-10-16 14:28:03 +020016711static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016712 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16713 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016714
16715 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16716 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16717 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16718
16719 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16720 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16721 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16722 { } /* end */
16723};
16724
Kailang Yang8c427222008-01-10 13:03:59 +010016725static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016726 ALC262_HIPPO_MASTER_SWITCH,
16727 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016728 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016729 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16730 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016731 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16732 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16733 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16734 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16735 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16736 { } /* end */
16737};
16738
Kailang Yangf1d4e282008-08-26 14:03:29 +020016739static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16740 .ops = &snd_hda_bind_vol,
16741 .values = {
16742 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16743 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16744 0
16745 },
16746};
16747
16748static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16749 .ops = &snd_hda_bind_sw,
16750 .values = {
16751 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16752 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16753 0
16754 },
16755};
16756
Kailang Yang6dda9f42008-05-27 12:05:31 +020016757static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016758 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16759 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16762 { } /* end */
16763};
16764
16765static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16766 .ops = &snd_hda_bind_sw,
16767 .values = {
16768 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16769 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16770 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16771 0
16772 },
16773};
16774
16775static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16776 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16777 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16778 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16779 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16780 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16781 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16782
16783 { } /* end */
16784};
16785
16786static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16787 .ops = &snd_hda_bind_sw,
16788 .values = {
16789 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16790 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16791 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16792 0
16793 },
16794};
16795
16796static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16797 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16798 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16800 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16801 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16802 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16803 { } /* end */
16804};
16805
16806static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016807 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16808 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016809 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16811 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16812 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16813 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16814 { } /* end */
16815};
16816
16817static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16818 .ops = &snd_hda_bind_vol,
16819 .values = {
16820 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16821 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16822 0
16823 },
16824};
16825
16826static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16827 .ops = &snd_hda_bind_sw,
16828 .values = {
16829 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16830 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16831 0
16832 },
16833};
16834
16835static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16836 HDA_BIND_VOL("Master Playback Volume",
16837 &alc663_asus_two_bind_master_vol),
16838 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16839 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016840 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16841 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16842 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016843 { } /* end */
16844};
16845
16846static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16847 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16848 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16849 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16850 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16851 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16852 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016853 { } /* end */
16854};
16855
16856static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16857 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16858 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16859 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16860 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16861 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16862
16863 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16864 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16865 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16866 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16867 { } /* end */
16868};
16869
16870static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16871 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16872 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16873 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16874
16875 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16876 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16877 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16878 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16879 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16880 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16881 { } /* end */
16882};
16883
Kailang Yangebb83ee2009-12-17 12:23:00 +010016884static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
16885 .ops = &snd_hda_bind_sw,
16886 .values = {
16887 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16888 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16889 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16890 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16891 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16892 0
16893 },
16894};
16895
16896static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
16897 .ops = &snd_hda_bind_sw,
16898 .values = {
16899 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16900 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16901 0
16902 },
16903};
16904
16905static struct snd_kcontrol_new alc663_mode7_mixer[] = {
16906 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16907 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16908 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16909 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16910 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16911 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16912 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16913 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16914 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16915 { } /* end */
16916};
16917
16918static struct snd_kcontrol_new alc663_mode8_mixer[] = {
16919 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16920 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16921 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16922 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16923 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16924 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16925 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16926 { } /* end */
16927};
16928
16929
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016930static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16931 {
16932 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16933 .name = "Channel Mode",
16934 .info = alc_ch_mode_info,
16935 .get = alc_ch_mode_get,
16936 .put = alc_ch_mode_put,
16937 },
16938 { } /* end */
16939};
16940
16941static struct hda_verb alc662_init_verbs[] = {
16942 /* ADC: mute amp left and right */
16943 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16944 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016945
Kailang Yangb60dd392007-09-20 12:50:29 +020016946 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16947 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16948 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16949 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16950 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16951 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016952
16953 /* Front Pin: output 0 (0x0c) */
16954 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16955 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16956
16957 /* Rear Pin: output 1 (0x0d) */
16958 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16959 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16960
16961 /* CLFE Pin: output 2 (0x0e) */
16962 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16963 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16964
16965 /* Mic (rear) pin: input vref at 80% */
16966 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16967 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16968 /* Front Mic pin: input vref at 80% */
16969 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16970 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16971 /* Line In pin: input */
16972 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16973 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16974 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16975 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16976 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16977 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16978 /* CD pin widget for input */
16979 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16980
16981 /* FIXME: use matrix-type input source selection */
16982 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16983 /* Input mixer */
16984 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016985 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016986
16987 /* always trun on EAPD */
16988 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16989 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16990
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016991 { }
16992};
16993
Kailang Yangcec27c82010-02-04 14:18:18 +010016994static struct hda_verb alc663_init_verbs[] = {
16995 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16996 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16997 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16998 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16999 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17000 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17001 { }
17002};
17003
17004static struct hda_verb alc272_init_verbs[] = {
17005 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17006 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17007 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17008 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17009 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17010 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17011 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17012 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17013 { }
17014};
17015
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017016static struct hda_verb alc662_sue_init_verbs[] = {
17017 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17018 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017019 {}
17020};
17021
17022static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17023 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17024 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17025 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017026};
17027
Kailang Yang8c427222008-01-10 13:03:59 +010017028/* Set Unsolicited Event*/
17029static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17030 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17031 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17032 {}
17033};
17034
Kailang Yang6dda9f42008-05-27 12:05:31 +020017035static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017036 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17037 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017038 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17039 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017040 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17041 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17042 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017043 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17044 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17045 {}
17046};
17047
Kailang Yangf1d4e282008-08-26 14:03:29 +020017048static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17049 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17050 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17051 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17052 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17053 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17054 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17055 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17056 {}
17057};
17058
17059static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17060 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17061 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17062 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17063 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17064 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17065 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17066 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17067 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17068 {}
17069};
17070
17071static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17072 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17073 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17074 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17075 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17076 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17077 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17078 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17079 {}
17080};
17081
17082static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17083 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17084 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17085 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17086 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17087 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17088 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17089 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17092 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17093 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17094 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17095 {}
17096};
17097
17098static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17099 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17100 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17101 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17102 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17103 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17104 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17105 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17108 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17109 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17110 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17111 {}
17112};
17113
Kailang Yang6dda9f42008-05-27 12:05:31 +020017114static struct hda_verb alc663_g71v_init_verbs[] = {
17115 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17116 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17117 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17118
17119 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17120 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17121 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17122
17123 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17124 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17125 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17126 {}
17127};
17128
17129static struct hda_verb alc663_g50v_init_verbs[] = {
17130 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17131 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17132 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17133
17134 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17135 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17136 {}
17137};
17138
Kailang Yangf1d4e282008-08-26 14:03:29 +020017139static struct hda_verb alc662_ecs_init_verbs[] = {
17140 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17141 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17142 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17143 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17144 {}
17145};
17146
Kailang Yang622e84c2009-04-21 07:39:04 +020017147static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17148 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17149 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17150 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17151 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17152 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17153 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17154 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17155 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17156 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17157 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17158 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17159 {}
17160};
17161
17162static struct hda_verb alc272_dell_init_verbs[] = {
17163 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17164 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17166 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17167 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17168 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17169 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17170 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17171 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17172 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17173 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17174 {}
17175};
17176
Kailang Yangebb83ee2009-12-17 12:23:00 +010017177static struct hda_verb alc663_mode7_init_verbs[] = {
17178 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17179 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17180 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17181 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17182 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17183 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17184 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17185 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17186 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17187 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17188 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17190 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17191 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17192 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17193 {}
17194};
17195
17196static struct hda_verb alc663_mode8_init_verbs[] = {
17197 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17198 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17199 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17200 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17201 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17202 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17203 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17204 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17205 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17206 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17207 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17208 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17209 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17210 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17211 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17212 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17213 {}
17214};
17215
Kailang Yangf1d4e282008-08-26 14:03:29 +020017216static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17217 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17218 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17219 { } /* end */
17220};
17221
Kailang Yang622e84c2009-04-21 07:39:04 +020017222static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17223 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17224 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17225 { } /* end */
17226};
17227
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017228static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17229{
17230 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017231 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017232
Wu Fengguang864f92b2009-11-18 12:38:02 +080017233 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017234 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017235
Takashi Iwai47fd8302007-08-10 17:11:07 +020017236 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17237 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017238}
17239
17240static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17241{
17242 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017243 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017244
Wu Fengguang864f92b2009-11-18 12:38:02 +080017245 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017246 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017247
Takashi Iwai47fd8302007-08-10 17:11:07 +020017248 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17249 HDA_AMP_MUTE, bits);
17250 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17251 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017252}
17253
17254static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17255 unsigned int res)
17256{
17257 if ((res >> 26) == ALC880_HP_EVENT)
17258 alc662_lenovo_101e_all_automute(codec);
17259 if ((res >> 26) == ALC880_FRONT_EVENT)
17260 alc662_lenovo_101e_ispeaker_automute(codec);
17261}
17262
Kailang Yang291702f2007-10-16 14:28:03 +020017263/* unsolicited event for HP jack sensing */
17264static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17265 unsigned int res)
17266{
Kailang Yang291702f2007-10-16 14:28:03 +020017267 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017268 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017269 else
17270 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017271}
17272
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017273static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017274{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017275 struct alc_spec *spec = codec->spec;
17276
17277 alc262_hippo1_setup(codec);
17278 spec->ext_mic.pin = 0x18;
17279 spec->ext_mic.mux_idx = 0;
17280 spec->int_mic.pin = 0x19;
17281 spec->int_mic.mux_idx = 1;
17282 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017283}
17284
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017285static void alc662_eeepc_inithook(struct hda_codec *codec)
17286{
17287 alc262_hippo_automute(codec);
17288 alc_mic_automute(codec);
17289}
17290
17291static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017292{
Takashi Iwai42171c12009-05-08 14:11:43 +020017293 struct alc_spec *spec = codec->spec;
17294
17295 spec->autocfg.hp_pins[0] = 0x14;
17296 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017297}
17298
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017299#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17300
Kailang Yang6dda9f42008-05-27 12:05:31 +020017301static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17302{
17303 unsigned int present;
17304 unsigned char bits;
17305
Wu Fengguang864f92b2009-11-18 12:38:02 +080017306 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017307 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017308 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017309 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017310 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017311 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017312}
17313
17314static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17315{
17316 unsigned int present;
17317 unsigned char bits;
17318
Wu Fengguang864f92b2009-11-18 12:38:02 +080017319 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017320 bits = present ? HDA_AMP_MUTE : 0;
17321 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017322 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017323 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017324 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017325 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017326 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017327 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017328 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017329}
17330
17331static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17332{
17333 unsigned int present;
17334 unsigned char bits;
17335
Wu Fengguang864f92b2009-11-18 12:38:02 +080017336 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017337 bits = present ? HDA_AMP_MUTE : 0;
17338 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017339 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017340 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017341 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017342 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017343 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017344 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017345 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017346}
17347
17348static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17349{
17350 unsigned int present;
17351 unsigned char bits;
17352
Wu Fengguang864f92b2009-11-18 12:38:02 +080017353 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017354 bits = present ? 0 : PIN_OUT;
17355 snd_hda_codec_write(codec, 0x14, 0,
17356 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17357}
17358
17359static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17360{
17361 unsigned int present1, present2;
17362
Wu Fengguang864f92b2009-11-18 12:38:02 +080017363 present1 = snd_hda_jack_detect(codec, 0x21);
17364 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017365
17366 if (present1 || present2) {
17367 snd_hda_codec_write_cache(codec, 0x14, 0,
17368 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17369 } else {
17370 snd_hda_codec_write_cache(codec, 0x14, 0,
17371 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17372 }
17373}
17374
17375static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17376{
17377 unsigned int present1, present2;
17378
Wu Fengguang864f92b2009-11-18 12:38:02 +080017379 present1 = snd_hda_jack_detect(codec, 0x1b);
17380 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017381
17382 if (present1 || present2) {
17383 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017384 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017385 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017386 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017387 } else {
17388 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017389 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017390 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017391 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017392 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017393}
17394
Kailang Yangebb83ee2009-12-17 12:23:00 +010017395static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17396{
17397 unsigned int present1, present2;
17398
17399 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17400 AC_VERB_GET_PIN_SENSE, 0)
17401 & AC_PINSENSE_PRESENCE;
17402 present2 = snd_hda_codec_read(codec, 0x21, 0,
17403 AC_VERB_GET_PIN_SENSE, 0)
17404 & AC_PINSENSE_PRESENCE;
17405
17406 if (present1 || present2) {
17407 snd_hda_codec_write_cache(codec, 0x14, 0,
17408 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17409 snd_hda_codec_write_cache(codec, 0x17, 0,
17410 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17411 } else {
17412 snd_hda_codec_write_cache(codec, 0x14, 0,
17413 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17414 snd_hda_codec_write_cache(codec, 0x17, 0,
17415 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17416 }
17417}
17418
17419static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17420{
17421 unsigned int present1, present2;
17422
17423 present1 = snd_hda_codec_read(codec, 0x21, 0,
17424 AC_VERB_GET_PIN_SENSE, 0)
17425 & AC_PINSENSE_PRESENCE;
17426 present2 = snd_hda_codec_read(codec, 0x15, 0,
17427 AC_VERB_GET_PIN_SENSE, 0)
17428 & AC_PINSENSE_PRESENCE;
17429
17430 if (present1 || present2) {
17431 snd_hda_codec_write_cache(codec, 0x14, 0,
17432 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17433 snd_hda_codec_write_cache(codec, 0x17, 0,
17434 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17435 } else {
17436 snd_hda_codec_write_cache(codec, 0x14, 0,
17437 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17438 snd_hda_codec_write_cache(codec, 0x17, 0,
17439 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17440 }
17441}
17442
Kailang Yang6dda9f42008-05-27 12:05:31 +020017443static void alc663_m51va_unsol_event(struct hda_codec *codec,
17444 unsigned int res)
17445{
17446 switch (res >> 26) {
17447 case ALC880_HP_EVENT:
17448 alc663_m51va_speaker_automute(codec);
17449 break;
17450 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017451 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017452 break;
17453 }
17454}
17455
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017456static void alc663_m51va_setup(struct hda_codec *codec)
17457{
17458 struct alc_spec *spec = codec->spec;
17459 spec->ext_mic.pin = 0x18;
17460 spec->ext_mic.mux_idx = 0;
17461 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017462 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017463 spec->auto_mic = 1;
17464}
17465
Kailang Yang6dda9f42008-05-27 12:05:31 +020017466static void alc663_m51va_inithook(struct hda_codec *codec)
17467{
17468 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017469 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017470}
17471
Kailang Yangf1d4e282008-08-26 14:03:29 +020017472/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017473#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017474
17475static void alc663_mode1_setup(struct hda_codec *codec)
17476{
17477 struct alc_spec *spec = codec->spec;
17478 spec->ext_mic.pin = 0x18;
17479 spec->ext_mic.mux_idx = 0;
17480 spec->int_mic.pin = 0x19;
17481 spec->int_mic.mux_idx = 1;
17482 spec->auto_mic = 1;
17483}
17484
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017485#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017486
Kailang Yangf1d4e282008-08-26 14:03:29 +020017487/* ***************** Mode2 ******************************/
17488static void alc662_mode2_unsol_event(struct hda_codec *codec,
17489 unsigned int res)
17490{
17491 switch (res >> 26) {
17492 case ALC880_HP_EVENT:
17493 alc662_f5z_speaker_automute(codec);
17494 break;
17495 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017496 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017497 break;
17498 }
17499}
17500
Kailang Yangebb83ee2009-12-17 12:23:00 +010017501#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017502
Kailang Yangf1d4e282008-08-26 14:03:29 +020017503static void alc662_mode2_inithook(struct hda_codec *codec)
17504{
17505 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017506 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017507}
17508/* ***************** Mode3 ******************************/
17509static void alc663_mode3_unsol_event(struct hda_codec *codec,
17510 unsigned int res)
17511{
17512 switch (res >> 26) {
17513 case ALC880_HP_EVENT:
17514 alc663_two_hp_m1_speaker_automute(codec);
17515 break;
17516 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017517 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017518 break;
17519 }
17520}
17521
Kailang Yangebb83ee2009-12-17 12:23:00 +010017522#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017523
Kailang Yangf1d4e282008-08-26 14:03:29 +020017524static void alc663_mode3_inithook(struct hda_codec *codec)
17525{
17526 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017527 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017528}
17529/* ***************** Mode4 ******************************/
17530static void alc663_mode4_unsol_event(struct hda_codec *codec,
17531 unsigned int res)
17532{
17533 switch (res >> 26) {
17534 case ALC880_HP_EVENT:
17535 alc663_21jd_two_speaker_automute(codec);
17536 break;
17537 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017538 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017539 break;
17540 }
17541}
17542
Kailang Yangebb83ee2009-12-17 12:23:00 +010017543#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017544
Kailang Yangf1d4e282008-08-26 14:03:29 +020017545static void alc663_mode4_inithook(struct hda_codec *codec)
17546{
17547 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017548 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017549}
17550/* ***************** Mode5 ******************************/
17551static void alc663_mode5_unsol_event(struct hda_codec *codec,
17552 unsigned int res)
17553{
17554 switch (res >> 26) {
17555 case ALC880_HP_EVENT:
17556 alc663_15jd_two_speaker_automute(codec);
17557 break;
17558 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017559 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017560 break;
17561 }
17562}
17563
Kailang Yangebb83ee2009-12-17 12:23:00 +010017564#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017565
Kailang Yangf1d4e282008-08-26 14:03:29 +020017566static void alc663_mode5_inithook(struct hda_codec *codec)
17567{
17568 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017569 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017570}
17571/* ***************** Mode6 ******************************/
17572static void alc663_mode6_unsol_event(struct hda_codec *codec,
17573 unsigned int res)
17574{
17575 switch (res >> 26) {
17576 case ALC880_HP_EVENT:
17577 alc663_two_hp_m2_speaker_automute(codec);
17578 break;
17579 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017580 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017581 break;
17582 }
17583}
17584
Kailang Yangebb83ee2009-12-17 12:23:00 +010017585#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017586
Kailang Yangf1d4e282008-08-26 14:03:29 +020017587static void alc663_mode6_inithook(struct hda_codec *codec)
17588{
17589 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017590 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017591}
17592
Kailang Yangebb83ee2009-12-17 12:23:00 +010017593/* ***************** Mode7 ******************************/
17594static void alc663_mode7_unsol_event(struct hda_codec *codec,
17595 unsigned int res)
17596{
17597 switch (res >> 26) {
17598 case ALC880_HP_EVENT:
17599 alc663_two_hp_m7_speaker_automute(codec);
17600 break;
17601 case ALC880_MIC_EVENT:
17602 alc_mic_automute(codec);
17603 break;
17604 }
17605}
17606
17607#define alc663_mode7_setup alc663_mode1_setup
17608
17609static void alc663_mode7_inithook(struct hda_codec *codec)
17610{
17611 alc663_two_hp_m7_speaker_automute(codec);
17612 alc_mic_automute(codec);
17613}
17614
17615/* ***************** Mode8 ******************************/
17616static void alc663_mode8_unsol_event(struct hda_codec *codec,
17617 unsigned int res)
17618{
17619 switch (res >> 26) {
17620 case ALC880_HP_EVENT:
17621 alc663_two_hp_m8_speaker_automute(codec);
17622 break;
17623 case ALC880_MIC_EVENT:
17624 alc_mic_automute(codec);
17625 break;
17626 }
17627}
17628
17629#define alc663_mode8_setup alc663_m51va_setup
17630
17631static void alc663_mode8_inithook(struct hda_codec *codec)
17632{
17633 alc663_two_hp_m8_speaker_automute(codec);
17634 alc_mic_automute(codec);
17635}
17636
Kailang Yang6dda9f42008-05-27 12:05:31 +020017637static void alc663_g71v_hp_automute(struct hda_codec *codec)
17638{
17639 unsigned int present;
17640 unsigned char bits;
17641
Wu Fengguang864f92b2009-11-18 12:38:02 +080017642 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017643 bits = present ? HDA_AMP_MUTE : 0;
17644 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17645 HDA_AMP_MUTE, bits);
17646 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17647 HDA_AMP_MUTE, bits);
17648}
17649
17650static void alc663_g71v_front_automute(struct hda_codec *codec)
17651{
17652 unsigned int present;
17653 unsigned char bits;
17654
Wu Fengguang864f92b2009-11-18 12:38:02 +080017655 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017656 bits = present ? HDA_AMP_MUTE : 0;
17657 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17658 HDA_AMP_MUTE, bits);
17659}
17660
17661static void alc663_g71v_unsol_event(struct hda_codec *codec,
17662 unsigned int res)
17663{
17664 switch (res >> 26) {
17665 case ALC880_HP_EVENT:
17666 alc663_g71v_hp_automute(codec);
17667 break;
17668 case ALC880_FRONT_EVENT:
17669 alc663_g71v_front_automute(codec);
17670 break;
17671 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017672 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017673 break;
17674 }
17675}
17676
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017677#define alc663_g71v_setup alc663_m51va_setup
17678
Kailang Yang6dda9f42008-05-27 12:05:31 +020017679static void alc663_g71v_inithook(struct hda_codec *codec)
17680{
17681 alc663_g71v_front_automute(codec);
17682 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017683 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017684}
17685
17686static void alc663_g50v_unsol_event(struct hda_codec *codec,
17687 unsigned int res)
17688{
17689 switch (res >> 26) {
17690 case ALC880_HP_EVENT:
17691 alc663_m51va_speaker_automute(codec);
17692 break;
17693 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017694 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017695 break;
17696 }
17697}
17698
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017699#define alc663_g50v_setup alc663_m51va_setup
17700
Kailang Yang6dda9f42008-05-27 12:05:31 +020017701static void alc663_g50v_inithook(struct hda_codec *codec)
17702{
17703 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017704 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017705}
17706
Kailang Yangf1d4e282008-08-26 14:03:29 +020017707static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17708 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017709 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017710
17711 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17712 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17713 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17714
17715 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17716 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17717 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17718 { } /* end */
17719};
17720
Chris Pockelé9541ba12009-05-12 08:08:53 +020017721static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17722 /* Master Playback automatically created from Speaker and Headphone */
17723 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17724 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17725 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17726 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17727
17728 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17729 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17730 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17731
17732 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17733 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17734 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17735 { } /* end */
17736};
17737
Takashi Iwaicb53c622007-08-10 17:21:45 +020017738#ifdef CONFIG_SND_HDA_POWER_SAVE
17739#define alc662_loopbacks alc880_loopbacks
17740#endif
17741
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017742
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017743/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017744#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17745#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17746#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17747#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17748
17749/*
17750 * configuration and preset
17751 */
17752static const char *alc662_models[ALC662_MODEL_LAST] = {
17753 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17754 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17755 [ALC662_3ST_6ch] = "3stack-6ch",
17756 [ALC662_5ST_DIG] = "6stack-dig",
17757 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017758 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017759 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017760 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017761 [ALC663_ASUS_M51VA] = "m51va",
17762 [ALC663_ASUS_G71V] = "g71v",
17763 [ALC663_ASUS_H13] = "h13",
17764 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017765 [ALC663_ASUS_MODE1] = "asus-mode1",
17766 [ALC662_ASUS_MODE2] = "asus-mode2",
17767 [ALC663_ASUS_MODE3] = "asus-mode3",
17768 [ALC663_ASUS_MODE4] = "asus-mode4",
17769 [ALC663_ASUS_MODE5] = "asus-mode5",
17770 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017771 [ALC663_ASUS_MODE7] = "asus-mode7",
17772 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017773 [ALC272_DELL] = "dell",
17774 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017775 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017776 [ALC662_AUTO] = "auto",
17777};
17778
17779static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017780 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017781 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17782 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017783 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17784 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010017785 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017786 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17787 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17788 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17789 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017790 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17791 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017792 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017793 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17794 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17795 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17796 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17797 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017798 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017799 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17800 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017801 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17802 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17803 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17804 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017805 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017806 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17807 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17808 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017809 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17810 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17811 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17812 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017813 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017814 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17815 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017816 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017817 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17818 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17819 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017820 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010017821 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017822 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17823 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017824 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17825 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17826 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017827 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017828 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17829 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017830 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017831 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017832 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017833 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17834 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17835 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017836 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017837 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17838 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017839 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017840 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017841 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017842 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017843 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17844 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010017845 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017846 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017847 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17848 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010017849 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017850 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017851 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017852 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017853 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017854 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017855 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17856 ALC663_ASUS_H13),
David Santinoli7aee6742009-12-09 12:34:26 +010017857 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017858 {}
17859};
17860
17861static struct alc_config_preset alc662_presets[] = {
17862 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017863 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017864 .init_verbs = { alc662_init_verbs },
17865 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17866 .dac_nids = alc662_dac_nids,
17867 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017868 .dig_in_nid = ALC662_DIGIN_NID,
17869 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17870 .channel_mode = alc662_3ST_2ch_modes,
17871 .input_mux = &alc662_capture_source,
17872 },
17873 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017874 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017875 .init_verbs = { alc662_init_verbs },
17876 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17877 .dac_nids = alc662_dac_nids,
17878 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017879 .dig_in_nid = ALC662_DIGIN_NID,
17880 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17881 .channel_mode = alc662_3ST_6ch_modes,
17882 .need_dac_fix = 1,
17883 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017884 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017885 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017886 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017887 .init_verbs = { alc662_init_verbs },
17888 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17889 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017890 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17891 .channel_mode = alc662_3ST_6ch_modes,
17892 .need_dac_fix = 1,
17893 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017894 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017895 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017896 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017897 .init_verbs = { alc662_init_verbs },
17898 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17899 .dac_nids = alc662_dac_nids,
17900 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017901 .dig_in_nid = ALC662_DIGIN_NID,
17902 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17903 .channel_mode = alc662_5stack_modes,
17904 .input_mux = &alc662_capture_source,
17905 },
17906 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017907 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017908 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17909 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17910 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017911 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17912 .channel_mode = alc662_3ST_2ch_modes,
17913 .input_mux = &alc662_lenovo_101e_capture_source,
17914 .unsol_event = alc662_lenovo_101e_unsol_event,
17915 .init_hook = alc662_lenovo_101e_all_automute,
17916 },
Kailang Yang291702f2007-10-16 14:28:03 +020017917 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017918 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017919 .init_verbs = { alc662_init_verbs,
17920 alc662_eeepc_sue_init_verbs },
17921 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17922 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017923 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17924 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017925 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017926 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017927 .init_hook = alc662_eeepc_inithook,
17928 },
Kailang Yang8c427222008-01-10 13:03:59 +010017929 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017930 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017931 alc662_chmode_mixer },
17932 .init_verbs = { alc662_init_verbs,
17933 alc662_eeepc_ep20_sue_init_verbs },
17934 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17935 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017936 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17937 .channel_mode = alc662_3ST_6ch_modes,
17938 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017939 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017940 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017941 .init_hook = alc662_eeepc_ep20_inithook,
17942 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017943 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017944 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017945 .init_verbs = { alc662_init_verbs,
17946 alc662_ecs_init_verbs },
17947 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17948 .dac_nids = alc662_dac_nids,
17949 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17950 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017951 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017952 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017953 .init_hook = alc662_eeepc_inithook,
17954 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017955 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017956 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017957 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17958 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17959 .dac_nids = alc662_dac_nids,
17960 .dig_out_nid = ALC662_DIGOUT_NID,
17961 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17962 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017963 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017964 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017965 .init_hook = alc663_m51va_inithook,
17966 },
17967 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017968 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017969 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17970 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17971 .dac_nids = alc662_dac_nids,
17972 .dig_out_nid = ALC662_DIGOUT_NID,
17973 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17974 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017975 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017976 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017977 .init_hook = alc663_g71v_inithook,
17978 },
17979 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017980 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017981 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17982 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17983 .dac_nids = alc662_dac_nids,
17984 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17985 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017986 .unsol_event = alc663_m51va_unsol_event,
17987 .init_hook = alc663_m51va_inithook,
17988 },
17989 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017990 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017991 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17992 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17993 .dac_nids = alc662_dac_nids,
17994 .dig_out_nid = ALC662_DIGOUT_NID,
17995 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17996 .channel_mode = alc662_3ST_6ch_modes,
17997 .input_mux = &alc663_capture_source,
17998 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017999 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018000 .init_hook = alc663_g50v_inithook,
18001 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018002 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018003 .mixers = { alc663_m51va_mixer },
18004 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018005 .init_verbs = { alc662_init_verbs,
18006 alc663_21jd_amic_init_verbs },
18007 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18008 .hp_nid = 0x03,
18009 .dac_nids = alc662_dac_nids,
18010 .dig_out_nid = ALC662_DIGOUT_NID,
18011 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18012 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018013 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018014 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018015 .init_hook = alc663_mode1_inithook,
18016 },
18017 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018018 .mixers = { alc662_1bjd_mixer },
18019 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018020 .init_verbs = { alc662_init_verbs,
18021 alc662_1bjd_amic_init_verbs },
18022 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18023 .dac_nids = alc662_dac_nids,
18024 .dig_out_nid = ALC662_DIGOUT_NID,
18025 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18026 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018027 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018028 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018029 .init_hook = alc662_mode2_inithook,
18030 },
18031 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018032 .mixers = { alc663_two_hp_m1_mixer },
18033 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018034 .init_verbs = { alc662_init_verbs,
18035 alc663_two_hp_amic_m1_init_verbs },
18036 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18037 .hp_nid = 0x03,
18038 .dac_nids = alc662_dac_nids,
18039 .dig_out_nid = ALC662_DIGOUT_NID,
18040 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18041 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018042 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018043 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018044 .init_hook = alc663_mode3_inithook,
18045 },
18046 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018047 .mixers = { alc663_asus_21jd_clfe_mixer },
18048 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018049 .init_verbs = { alc662_init_verbs,
18050 alc663_21jd_amic_init_verbs},
18051 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18052 .hp_nid = 0x03,
18053 .dac_nids = alc662_dac_nids,
18054 .dig_out_nid = ALC662_DIGOUT_NID,
18055 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18056 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018057 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018058 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018059 .init_hook = alc663_mode4_inithook,
18060 },
18061 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018062 .mixers = { alc663_asus_15jd_clfe_mixer },
18063 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018064 .init_verbs = { alc662_init_verbs,
18065 alc663_15jd_amic_init_verbs },
18066 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18067 .hp_nid = 0x03,
18068 .dac_nids = alc662_dac_nids,
18069 .dig_out_nid = ALC662_DIGOUT_NID,
18070 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18071 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018072 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018073 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018074 .init_hook = alc663_mode5_inithook,
18075 },
18076 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018077 .mixers = { alc663_two_hp_m2_mixer },
18078 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018079 .init_verbs = { alc662_init_verbs,
18080 alc663_two_hp_amic_m2_init_verbs },
18081 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18082 .hp_nid = 0x03,
18083 .dac_nids = alc662_dac_nids,
18084 .dig_out_nid = ALC662_DIGOUT_NID,
18085 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18086 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018087 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018088 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018089 .init_hook = alc663_mode6_inithook,
18090 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018091 [ALC663_ASUS_MODE7] = {
18092 .mixers = { alc663_mode7_mixer },
18093 .cap_mixer = alc662_auto_capture_mixer,
18094 .init_verbs = { alc662_init_verbs,
18095 alc663_mode7_init_verbs },
18096 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18097 .hp_nid = 0x03,
18098 .dac_nids = alc662_dac_nids,
18099 .dig_out_nid = ALC662_DIGOUT_NID,
18100 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18101 .channel_mode = alc662_3ST_2ch_modes,
18102 .unsol_event = alc663_mode7_unsol_event,
18103 .setup = alc663_mode7_setup,
18104 .init_hook = alc663_mode7_inithook,
18105 },
18106 [ALC663_ASUS_MODE8] = {
18107 .mixers = { alc663_mode8_mixer },
18108 .cap_mixer = alc662_auto_capture_mixer,
18109 .init_verbs = { alc662_init_verbs,
18110 alc663_mode8_init_verbs },
18111 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18112 .hp_nid = 0x03,
18113 .dac_nids = alc662_dac_nids,
18114 .dig_out_nid = ALC662_DIGOUT_NID,
18115 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18116 .channel_mode = alc662_3ST_2ch_modes,
18117 .unsol_event = alc663_mode8_unsol_event,
18118 .setup = alc663_mode8_setup,
18119 .init_hook = alc663_mode8_inithook,
18120 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018121 [ALC272_DELL] = {
18122 .mixers = { alc663_m51va_mixer },
18123 .cap_mixer = alc272_auto_capture_mixer,
18124 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18125 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18126 .dac_nids = alc662_dac_nids,
18127 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18128 .adc_nids = alc272_adc_nids,
18129 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18130 .capsrc_nids = alc272_capsrc_nids,
18131 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018132 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018133 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018134 .init_hook = alc663_m51va_inithook,
18135 },
18136 [ALC272_DELL_ZM1] = {
18137 .mixers = { alc663_m51va_mixer },
18138 .cap_mixer = alc662_auto_capture_mixer,
18139 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18140 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18141 .dac_nids = alc662_dac_nids,
18142 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18143 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018144 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018145 .capsrc_nids = alc662_capsrc_nids,
18146 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018147 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018148 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018149 .init_hook = alc663_m51va_inithook,
18150 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018151 [ALC272_SAMSUNG_NC10] = {
18152 .mixers = { alc272_nc10_mixer },
18153 .init_verbs = { alc662_init_verbs,
18154 alc663_21jd_amic_init_verbs },
18155 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18156 .dac_nids = alc272_dac_nids,
18157 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18158 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018159 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018160 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018161 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018162 .init_hook = alc663_mode4_inithook,
18163 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018164};
18165
18166
18167/*
18168 * BIOS auto configuration
18169 */
18170
Takashi Iwai7085ec12009-10-02 09:03:58 +020018171/* convert from MIX nid to DAC */
18172static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18173{
18174 if (nid == 0x0f)
18175 return 0x02;
18176 else if (nid >= 0x0c && nid <= 0x0e)
18177 return nid - 0x0c + 0x02;
18178 else
18179 return 0;
18180}
18181
18182/* get MIX nid connected to the given pin targeted to DAC */
18183static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18184 hda_nid_t dac)
18185{
18186 hda_nid_t mix[4];
18187 int i, num;
18188
18189 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18190 for (i = 0; i < num; i++) {
18191 if (alc662_mix_to_dac(mix[i]) == dac)
18192 return mix[i];
18193 }
18194 return 0;
18195}
18196
18197/* look for an empty DAC slot */
18198static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18199{
18200 struct alc_spec *spec = codec->spec;
18201 hda_nid_t srcs[5];
18202 int i, j, num;
18203
18204 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18205 if (num < 0)
18206 return 0;
18207 for (i = 0; i < num; i++) {
18208 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18209 if (!nid)
18210 continue;
18211 for (j = 0; j < spec->multiout.num_dacs; j++)
18212 if (spec->multiout.dac_nids[j] == nid)
18213 break;
18214 if (j >= spec->multiout.num_dacs)
18215 return nid;
18216 }
18217 return 0;
18218}
18219
18220/* fill in the dac_nids table from the parsed pin configuration */
18221static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18222 const struct auto_pin_cfg *cfg)
18223{
18224 struct alc_spec *spec = codec->spec;
18225 int i;
18226 hda_nid_t dac;
18227
18228 spec->multiout.dac_nids = spec->private_dac_nids;
18229 for (i = 0; i < cfg->line_outs; i++) {
18230 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18231 if (!dac)
18232 continue;
18233 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18234 }
18235 return 0;
18236}
18237
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018238static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018239 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018240{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018241 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018242 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18243}
18244
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018245static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018246 hda_nid_t nid, unsigned int chs)
18247{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018248 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018249 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18250}
18251
18252#define alc662_add_stereo_vol(spec, pfx, nid) \
18253 alc662_add_vol_ctl(spec, pfx, nid, 3)
18254#define alc662_add_stereo_sw(spec, pfx, nid) \
18255 alc662_add_sw_ctl(spec, pfx, nid, 3)
18256
18257/* add playback controls from the parsed DAC table */
18258static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18259 const struct auto_pin_cfg *cfg)
18260{
18261 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018262 static const char *chname[4] = {
18263 "Front", "Surround", NULL /*CLFE*/, "Side"
18264 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018265 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018266 int i, err;
18267
18268 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018269 nid = spec->multiout.dac_nids[i];
18270 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018271 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018272 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18273 if (!mix)
18274 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018275 if (i == 2) {
18276 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018277 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018278 if (err < 0)
18279 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018280 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018281 if (err < 0)
18282 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018283 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018284 if (err < 0)
18285 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018286 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018287 if (err < 0)
18288 return err;
18289 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018290 const char *pfx;
18291 if (cfg->line_outs == 1 &&
18292 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018293 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018294 pfx = "Speaker";
18295 else
18296 pfx = "PCM";
18297 } else
18298 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018299 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018300 if (err < 0)
18301 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018302 if (cfg->line_outs == 1 &&
18303 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18304 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018305 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018306 if (err < 0)
18307 return err;
18308 }
18309 }
18310 return 0;
18311}
18312
18313/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018314/* return DAC nid if any new DAC is assigned */
18315static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018316 const char *pfx)
18317{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018318 struct alc_spec *spec = codec->spec;
18319 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018320 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018321
18322 if (!pin)
18323 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018324 nid = alc662_look_for_dac(codec, pin);
18325 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018326 /* the corresponding DAC is already occupied */
18327 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18328 return 0; /* no way */
18329 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018330 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018331 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18332 }
18333
18334 mix = alc662_dac_to_mix(codec, pin, nid);
18335 if (!mix)
18336 return 0;
18337 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18338 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018339 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018340 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18341 if (err < 0)
18342 return err;
18343 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018344}
18345
18346/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018347#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018348 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018349
18350static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18351 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018352 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018353{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018354 int i, num;
18355 hda_nid_t srcs[4];
18356
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018357 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018358 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018359 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18360 if (num <= 1)
18361 return;
18362 for (i = 0; i < num; i++) {
18363 if (alc662_mix_to_dac(srcs[i]) != dac)
18364 continue;
18365 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18366 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018367 }
18368}
18369
18370static void alc662_auto_init_multi_out(struct hda_codec *codec)
18371{
18372 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018373 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018374 int i;
18375
18376 for (i = 0; i <= HDA_SIDE; i++) {
18377 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18378 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018379 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018380 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018381 }
18382}
18383
18384static void alc662_auto_init_hp_out(struct hda_codec *codec)
18385{
18386 struct alc_spec *spec = codec->spec;
18387 hda_nid_t pin;
18388
18389 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018390 if (pin)
18391 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18392 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018393 pin = spec->autocfg.speaker_pins[0];
18394 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018395 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18396 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018397}
18398
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018399#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18400
18401static void alc662_auto_init_analog_input(struct hda_codec *codec)
18402{
18403 struct alc_spec *spec = codec->spec;
18404 int i;
18405
18406 for (i = 0; i < AUTO_PIN_LAST; i++) {
18407 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020018408 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018409 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018410 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018411 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018412 snd_hda_codec_write(codec, nid, 0,
18413 AC_VERB_SET_AMP_GAIN_MUTE,
18414 AMP_OUT_MUTE);
18415 }
18416 }
18417}
18418
Takashi Iwaif511b012008-08-15 16:46:42 +020018419#define alc662_auto_init_input_src alc882_auto_init_input_src
18420
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018421static int alc662_parse_auto_config(struct hda_codec *codec)
18422{
18423 struct alc_spec *spec = codec->spec;
18424 int err;
18425 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18426
18427 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18428 alc662_ignore);
18429 if (err < 0)
18430 return err;
18431 if (!spec->autocfg.line_outs)
18432 return 0; /* can't find valid BIOS pin config */
18433
Takashi Iwai7085ec12009-10-02 09:03:58 +020018434 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018435 if (err < 0)
18436 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018437 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018438 if (err < 0)
18439 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018440 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018441 spec->autocfg.speaker_pins[0],
18442 "Speaker");
18443 if (err < 0)
18444 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018445 if (err)
18446 spec->multiout.extra_out_nid[0] = err;
18447 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018448 "Headphone");
18449 if (err < 0)
18450 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018451 if (err)
18452 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018453 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018454 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018455 return err;
18456
18457 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18458
Takashi Iwai0852d7a2009-02-11 11:35:15 +010018459 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018460 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
18461
Takashi Iwai603c4012008-07-30 15:01:44 +020018462 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018463 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018464
18465 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018466 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018467
Kailang Yangcec27c82010-02-04 14:18:18 +010018468 add_verb(spec, alc662_init_verbs);
18469 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18470 codec->vendor_id == 0x10ec0665)
18471 add_verb(spec, alc663_init_verbs);
18472
18473 if (codec->vendor_id == 0x10ec0272)
18474 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018475
18476 err = alc_auto_add_mic_boost(codec);
18477 if (err < 0)
18478 return err;
18479
Kailang Yang6227cdc2010-02-25 08:36:52 +010018480 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18481 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
18482 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
18483 else
18484 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018485
Takashi Iwai8c872862007-06-19 12:11:16 +020018486 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018487}
18488
18489/* additional initialization for auto-configuration model */
18490static void alc662_auto_init(struct hda_codec *codec)
18491{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018492 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018493 alc662_auto_init_multi_out(codec);
18494 alc662_auto_init_hp_out(codec);
18495 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018496 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018497 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018498 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018499}
18500
18501static int patch_alc662(struct hda_codec *codec)
18502{
18503 struct alc_spec *spec;
18504 int err, board_config;
18505
18506 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18507 if (!spec)
18508 return -ENOMEM;
18509
18510 codec->spec = spec;
18511
Kailang Yangda00c242010-03-19 11:23:45 +010018512 alc_auto_parse_customize_define(codec);
18513
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018514 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18515
Kailang Yangc027ddc2010-03-19 11:33:06 +010018516 if (alc_read_coef_idx(codec, 0) == 0x8020)
18517 alc_codec_rename(codec, "ALC661");
18518 else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) &&
18519 codec->bus->pci->subsystem_vendor == 0x1025 &&
18520 spec->cdefine.platform_type == 1)
18521 alc_codec_rename(codec, "ALC272X");
Kailang Yang274693f2009-12-03 10:07:50 +010018522
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018523 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18524 alc662_models,
18525 alc662_cfg_tbl);
18526 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018527 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18528 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018529 board_config = ALC662_AUTO;
18530 }
18531
18532 if (board_config == ALC662_AUTO) {
18533 /* automatic parse from the BIOS config */
18534 err = alc662_parse_auto_config(codec);
18535 if (err < 0) {
18536 alc_free(codec);
18537 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020018538 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018539 printk(KERN_INFO
18540 "hda_codec: Cannot set up configuration "
18541 "from BIOS. Using base mode...\n");
18542 board_config = ALC662_3ST_2ch_DIG;
18543 }
18544 }
18545
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018546 err = snd_hda_attach_beep_device(codec, 0x1);
18547 if (err < 0) {
18548 alc_free(codec);
18549 return err;
18550 }
18551
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018552 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018553 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018554
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018555 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18556 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18557
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018558 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18559 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18560
Takashi Iwaidd704692009-08-11 08:45:11 +020018561 if (!spec->adc_nids) {
18562 spec->adc_nids = alc662_adc_nids;
18563 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18564 }
18565 if (!spec->capsrc_nids)
18566 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018567
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018568 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018569 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018570
Kailang Yangda00c242010-03-19 11:23:45 +010018571 if (spec->cdefine.enable_pcbeep) {
18572 switch (codec->vendor_id) {
18573 case 0x10ec0662:
18574 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18575 break;
18576 case 0x10ec0272:
18577 case 0x10ec0663:
18578 case 0x10ec0665:
18579 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
18580 break;
18581 case 0x10ec0273:
18582 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
18583 break;
18584 }
Kailang Yangcec27c82010-02-04 14:18:18 +010018585 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010018586 spec->vmaster_nid = 0x02;
18587
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018588 codec->patch_ops = alc_patch_ops;
18589 if (board_config == ALC662_AUTO)
18590 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018591#ifdef CONFIG_SND_HDA_POWER_SAVE
18592 if (!spec->loopback.amplist)
18593 spec->loopback.amplist = alc662_loopbacks;
18594#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018595
18596 return 0;
18597}
18598
Kailang Yang274693f2009-12-03 10:07:50 +010018599static int patch_alc888(struct hda_codec *codec)
18600{
18601 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
18602 kfree(codec->chip_name);
18603 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018604 if (!codec->chip_name) {
18605 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018606 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018607 }
18608 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018609 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018610 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018611}
18612
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018613/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070018614 * patch entries
18615 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018616static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070018617 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018618 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018619 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020018620 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018621 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018622 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020018623 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018624 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018625 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018626 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018627 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
18628 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
18629 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018630 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018631 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018632 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
18633 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018634 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010018635 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010018636 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018637 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018638 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018639 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020018640 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018641 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020018642 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018643 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018644 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018645 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018646 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018647 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018648 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018649 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018650 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018651 {} /* terminator */
18652};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018653
18654MODULE_ALIAS("snd-hda-codec-id:10ec*");
18655
18656MODULE_LICENSE("GPL");
18657MODULE_DESCRIPTION("Realtek HD-audio codec");
18658
18659static struct hda_codec_preset_list realtek_list = {
18660 .preset = snd_hda_preset_realtek,
18661 .owner = THIS_MODULE,
18662};
18663
18664static int __init patch_realtek_init(void)
18665{
18666 return snd_hda_add_codec_preset(&realtek_list);
18667}
18668
18669static void __exit patch_realtek_exit(void)
18670{
18671 snd_hda_delete_codec_preset(&realtek_list);
18672}
18673
18674module_init(patch_realtek_init)
18675module_exit(patch_realtek_exit)