blob: d0786e9c331012aed6a321ea670cad6f724eae42 [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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Yangf53281e2008-07-18 12:36:43 +0200134 ALC269_ASUS_EEEPC_P703,
135 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100136 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000137 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100138 ALC269_AUTO,
139 ALC269_MODEL_LAST /* last tag */
140};
141
Kailang Yangdf694da2005-12-05 19:42:22 +0100142/* ALC861 models */
143enum {
144 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200145 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100146 ALC861_3ST_DIG,
147 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200148 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200149 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200150 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100151 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100152 ALC861_AUTO,
153 ALC861_MODEL_LAST,
154};
155
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100156/* ALC861-VD models */
157enum {
158 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200159 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100160 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100161 ALC861VD_3ST,
162 ALC861VD_3ST_DIG,
163 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200164 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200165 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200166 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100167 ALC861VD_AUTO,
168 ALC861VD_MODEL_LAST,
169};
170
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200171/* ALC662 models */
172enum {
173 ALC662_3ST_2ch_DIG,
174 ALC662_3ST_6ch_DIG,
175 ALC662_3ST_6ch,
176 ALC662_5ST_DIG,
177 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200178 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100179 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200180 ALC663_ASUS_M51VA,
181 ALC663_ASUS_G71V,
182 ALC663_ASUS_H13,
183 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200184 ALC662_ECS,
185 ALC663_ASUS_MODE1,
186 ALC662_ASUS_MODE2,
187 ALC663_ASUS_MODE3,
188 ALC663_ASUS_MODE4,
189 ALC663_ASUS_MODE5,
190 ALC663_ASUS_MODE6,
Kailang Yang622e84c2009-04-21 07:39:04 +0200191 ALC272_DELL,
192 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200193 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200194 ALC662_AUTO,
195 ALC662_MODEL_LAST,
196};
197
Kailang Yangdf694da2005-12-05 19:42:22 +0100198/* ALC882 models */
199enum {
200 ALC882_3ST_DIG,
201 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200202 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200203 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200204 ALC882_TARGA,
205 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200206 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100207 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200208 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200209 ALC885_MB5,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200210 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200211 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100212 ALC882_MODEL_LAST,
213};
214
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200215/* ALC883 models */
216enum {
217 ALC883_3ST_2ch_DIG,
218 ALC883_3ST_6ch_DIG,
219 ALC883_3ST_6ch,
220 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200221 ALC883_TARGA_DIG,
222 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200223 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200224 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800225 ALC888_ACER_ASPIRE_4930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200226 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200227 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100228 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200229 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200230 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200231 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200232 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200233 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200234 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100235 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100236 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100237 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100238 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800239 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200240 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200241 ALC888_ASUS_M90V,
242 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200243 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100244 ALC1200_ASUS_P5Q,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200245 ALC883_AUTO,
246 ALC883_MODEL_LAST,
247};
248
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200249/* styles of capture selection */
250enum {
251 CAPT_MUX = 0, /* only mux based */
252 CAPT_MIX, /* only mixer based */
253 CAPT_1MUX_MIX, /* first mux and other mixers */
254};
255
Kailang Yangdf694da2005-12-05 19:42:22 +0100256/* for GPIO Poll */
257#define GPIO_MASK 0x03
258
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200259/* extra amp-initialization sequence types */
260enum {
261 ALC_INIT_NONE,
262 ALC_INIT_DEFAULT,
263 ALC_INIT_GPIO1,
264 ALC_INIT_GPIO2,
265 ALC_INIT_GPIO3,
266};
267
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268struct alc_spec {
269 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100270 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100272 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100273 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274
Kailang Yangdf694da2005-12-05 19:42:22 +0100275 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200276 * don't forget NULL
277 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200278 */
279 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280
Takashi Iwai812a2cc2009-05-16 10:00:49 +0200281 char stream_name_analog[16]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 struct hda_pcm_stream *stream_analog_playback;
283 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100284 struct hda_pcm_stream *stream_analog_alt_playback;
285 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
Takashi Iwai812a2cc2009-05-16 10:00:49 +0200287 char stream_name_digital[16]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 struct hda_pcm_stream *stream_digital_playback;
289 struct hda_pcm_stream *stream_digital_capture;
290
291 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200292 struct hda_multi_out multiout; /* playback set-up
293 * max_channels, dacs must be set
294 * dig_out_nid and hp_nid are optional
295 */
Takashi Iwai63300792008-01-24 15:31:36 +0100296 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100297 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100298 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299
300 /* capture */
301 unsigned int num_adc_nids;
302 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100303 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200304 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200305 int capture_style; /* capture style (CAPT_*) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
307 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200308 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 const struct hda_input_mux *input_mux;
310 unsigned int cur_mux[3];
311
312 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100313 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200315 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316
317 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100318 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200319
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200320 /* dynamic controls, init_verbs and input_mux */
321 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200322 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200323 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200324 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100325
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100326 /* hooks */
327 void (*init_hook)(struct hda_codec *codec);
328 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
329
Takashi Iwai834be882006-03-01 14:16:17 +0100330 /* for pin sensing */
331 unsigned int sense_updated: 1;
332 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100333 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200334
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100335 /* other flags */
336 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200337 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100338
Takashi Iwai2134ea42008-01-10 16:53:55 +0100339 /* for virtual master */
340 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200341#ifdef CONFIG_SND_HDA_POWER_SAVE
342 struct hda_loopback_check loopback;
343#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200344
345 /* for PLL fix */
346 hda_nid_t pll_nid;
347 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100348};
349
350/*
351 * configuration template - to be copied to the spec instance
352 */
353struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200354 struct snd_kcontrol_new *mixers[5]; /* should be identical size
355 * with spec
356 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100357 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100358 const struct hda_verb *init_verbs[5];
359 unsigned int num_dacs;
360 hda_nid_t *dac_nids;
361 hda_nid_t dig_out_nid; /* optional */
362 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800363 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100364 unsigned int num_adc_nids;
365 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100366 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100367 hda_nid_t dig_in_nid;
368 unsigned int num_channel_mode;
369 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200370 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200371 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100372 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100373 void (*unsol_event)(struct hda_codec *, unsigned int);
374 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200375#ifdef CONFIG_SND_HDA_POWER_SAVE
376 struct hda_amp_list *loopbacks;
377#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378};
379
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380
381/*
382 * input MUX handling
383 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200384static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
385 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386{
387 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
388 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200389 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
390 if (mux_idx >= spec->num_mux_defs)
391 mux_idx = 0;
392 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393}
394
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200395static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
396 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397{
398 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
399 struct alc_spec *spec = codec->spec;
400 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
401
402 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
403 return 0;
404}
405
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200406static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
407 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408{
409 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
410 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100411 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100413 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100414 hda_nid_t nid = spec->capsrc_nids ?
415 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416
Takashi Iwaicd896c32008-11-18 12:36:33 +0100417 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
418 imux = &spec->input_mux[mux_idx];
419
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200420 if (spec->capture_style &&
421 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100422 /* Matrix-mixer style (e.g. ALC882) */
423 unsigned int *cur_val = &spec->cur_mux[adc_idx];
424 unsigned int i, idx;
425
426 idx = ucontrol->value.enumerated.item[0];
427 if (idx >= imux->num_items)
428 idx = imux->num_items - 1;
429 if (*cur_val == idx)
430 return 0;
431 for (i = 0; i < imux->num_items; i++) {
432 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
433 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
434 imux->items[i].index,
435 HDA_AMP_MUTE, v);
436 }
437 *cur_val = idx;
438 return 1;
439 } else {
440 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100441 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100442 &spec->cur_mux[adc_idx]);
443 }
444}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200445
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446/*
447 * channel mode setting
448 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200449static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
450 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451{
452 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
453 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100454 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
455 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456}
457
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200458static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
459 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460{
461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
462 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100463 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200464 spec->num_channel_mode,
465 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466}
467
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200468static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
469 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470{
471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
472 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200473 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
474 spec->num_channel_mode,
475 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200476 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200477 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
478 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479}
480
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100482 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200483 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100484 * being part of a format specifier. Maximum allowed length of a value is
485 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100486 *
487 * Note: some retasking pin complexes seem to ignore requests for input
488 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
489 * are requested. Therefore order this list so that this behaviour will not
490 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200491 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
492 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200493 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100494static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100495 "Mic 50pc bias", "Mic 80pc bias",
496 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100497};
498static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100499 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100500};
501/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200502 * in the pin being assumed to be exclusively an input or an output pin. In
503 * addition, "input" pins may or may not process the mic bias option
504 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
505 * accept requests for bias as of chip versions up to March 2006) and/or
506 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100507 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200508#define ALC_PIN_DIR_IN 0x00
509#define ALC_PIN_DIR_OUT 0x01
510#define ALC_PIN_DIR_INOUT 0x02
511#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
512#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100513
Kailang Yangea1fb292008-08-26 12:58:38 +0200514/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100515 * For each direction the minimum and maximum values are given.
516 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200517static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100518 { 0, 2 }, /* ALC_PIN_DIR_IN */
519 { 3, 4 }, /* ALC_PIN_DIR_OUT */
520 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200521 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
522 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100523};
524#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
525#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
526#define alc_pin_mode_n_items(_dir) \
527 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
528
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200529static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
530 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200531{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100532 unsigned int item_num = uinfo->value.enumerated.item;
533 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
534
535 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200536 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100537 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
538
539 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
540 item_num = alc_pin_mode_min(dir);
541 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200542 return 0;
543}
544
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200545static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
546 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200547{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100548 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
550 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100551 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200552 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200553 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
554 AC_VERB_GET_PIN_WIDGET_CONTROL,
555 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200556
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100557 /* Find enumerated value for current pinctl setting */
558 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200559 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100560 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200561 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100562 return 0;
563}
564
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200565static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
566 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100567{
568 signed int change;
569 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
570 hda_nid_t nid = kcontrol->private_value & 0xffff;
571 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
572 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200573 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
574 AC_VERB_GET_PIN_WIDGET_CONTROL,
575 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100576
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200577 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100578 val = alc_pin_mode_min(dir);
579
580 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100581 if (change) {
582 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200583 snd_hda_codec_write_cache(codec, nid, 0,
584 AC_VERB_SET_PIN_WIDGET_CONTROL,
585 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100586
Kailang Yangea1fb292008-08-26 12:58:38 +0200587 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100588 * for the requested pin mode. Enum values of 2 or less are
589 * input modes.
590 *
591 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200592 * reduces noise slightly (particularly on input) so we'll
593 * do it. However, having both input and output buffers
594 * enabled simultaneously doesn't seem to be problematic if
595 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100596 */
597 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200598 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
599 HDA_AMP_MUTE, HDA_AMP_MUTE);
600 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
601 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100602 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200603 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
604 HDA_AMP_MUTE, HDA_AMP_MUTE);
605 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
606 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100607 }
608 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200609 return change;
610}
611
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100612#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200613 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100614 .info = alc_pin_mode_info, \
615 .get = alc_pin_mode_get, \
616 .put = alc_pin_mode_put, \
617 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100618
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100619/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
620 * together using a mask with more than one bit set. This control is
621 * currently used only by the ALC260 test model. At this stage they are not
622 * needed for any "production" models.
623 */
624#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200625#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200626
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200627static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
628 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100629{
630 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
631 hda_nid_t nid = kcontrol->private_value & 0xffff;
632 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
633 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200634 unsigned int val = snd_hda_codec_read(codec, nid, 0,
635 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100636
637 *valp = (val & mask) != 0;
638 return 0;
639}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200640static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100642{
643 signed int change;
644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
645 hda_nid_t nid = kcontrol->private_value & 0xffff;
646 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
647 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200648 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
649 AC_VERB_GET_GPIO_DATA,
650 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100651
652 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200653 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
654 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100655 gpio_data &= ~mask;
656 else
657 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200658 snd_hda_codec_write_cache(codec, nid, 0,
659 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100660
661 return change;
662}
663#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
664 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
665 .info = alc_gpio_data_info, \
666 .get = alc_gpio_data_get, \
667 .put = alc_gpio_data_put, \
668 .private_value = nid | (mask<<16) }
669#endif /* CONFIG_SND_DEBUG */
670
Jonathan Woithe92621f12006-02-28 11:47:47 +0100671/* A switch control to allow the enabling of the digital IO pins on the
672 * ALC260. This is incredibly simplistic; the intention of this control is
673 * to provide something in the test model allowing digital outputs to be
674 * identified if present. If models are found which can utilise these
675 * outputs a more complete mixer control can be devised for those models if
676 * necessary.
677 */
678#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200679#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200680
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200681static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
682 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100683{
684 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
685 hda_nid_t nid = kcontrol->private_value & 0xffff;
686 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
687 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200688 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100689 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100690
691 *valp = (val & mask) != 0;
692 return 0;
693}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200694static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
695 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100696{
697 signed int change;
698 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
699 hda_nid_t nid = kcontrol->private_value & 0xffff;
700 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
701 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200702 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100703 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200704 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100705
706 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200707 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100708 if (val==0)
709 ctrl_data &= ~mask;
710 else
711 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200712 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
713 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100714
715 return change;
716}
717#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
718 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
719 .info = alc_spdif_ctrl_info, \
720 .get = alc_spdif_ctrl_get, \
721 .put = alc_spdif_ctrl_put, \
722 .private_value = nid | (mask<<16) }
723#endif /* CONFIG_SND_DEBUG */
724
Jonathan Woithef8225f62008-01-08 12:16:54 +0100725/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
726 * Again, this is only used in the ALC26x test models to help identify when
727 * the EAPD line must be asserted for features to work.
728 */
729#ifdef CONFIG_SND_DEBUG
730#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
731
732static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
733 struct snd_ctl_elem_value *ucontrol)
734{
735 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
736 hda_nid_t nid = kcontrol->private_value & 0xffff;
737 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
738 long *valp = ucontrol->value.integer.value;
739 unsigned int val = snd_hda_codec_read(codec, nid, 0,
740 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
741
742 *valp = (val & mask) != 0;
743 return 0;
744}
745
746static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
747 struct snd_ctl_elem_value *ucontrol)
748{
749 int change;
750 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
751 hda_nid_t nid = kcontrol->private_value & 0xffff;
752 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
753 long val = *ucontrol->value.integer.value;
754 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
755 AC_VERB_GET_EAPD_BTLENABLE,
756 0x00);
757
758 /* Set/unset the masked control bit(s) as needed */
759 change = (!val ? 0 : mask) != (ctrl_data & mask);
760 if (!val)
761 ctrl_data &= ~mask;
762 else
763 ctrl_data |= mask;
764 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
765 ctrl_data);
766
767 return change;
768}
769
770#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
771 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
772 .info = alc_eapd_ctrl_info, \
773 .get = alc_eapd_ctrl_get, \
774 .put = alc_eapd_ctrl_put, \
775 .private_value = nid | (mask<<16) }
776#endif /* CONFIG_SND_DEBUG */
777
Kailang Yangdf694da2005-12-05 19:42:22 +0100778/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100779 * set up the input pin config (depending on the given auto-pin type)
780 */
781static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
782 int auto_pin_type)
783{
784 unsigned int val = PIN_IN;
785
786 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
787 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100788 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100789 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
790 if (pincap & AC_PINCAP_VREF_80)
791 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200792 else if (pincap & AC_PINCAP_VREF_50)
793 val = PIN_VREF50;
794 else if (pincap & AC_PINCAP_VREF_100)
795 val = PIN_VREF100;
796 else if (pincap & AC_PINCAP_VREF_GRD)
797 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100798 }
799 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
800}
801
802/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100803 */
804static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
805{
806 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
807 return;
808 spec->mixers[spec->num_mixers++] = mix;
809}
810
811static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
812{
813 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
814 return;
815 spec->init_verbs[spec->num_init_verbs++] = verb;
816}
817
Takashi Iwaidaead532008-11-28 12:55:36 +0100818#ifdef CONFIG_PROC_FS
819/*
820 * hook for proc
821 */
822static void print_realtek_coef(struct snd_info_buffer *buffer,
823 struct hda_codec *codec, hda_nid_t nid)
824{
825 int coeff;
826
827 if (nid != 0x20)
828 return;
829 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
830 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
831 coeff = snd_hda_codec_read(codec, nid, 0,
832 AC_VERB_GET_COEF_INDEX, 0);
833 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
834}
835#else
836#define print_realtek_coef NULL
837#endif
838
Takashi Iwaid88897e2008-10-31 15:01:37 +0100839/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100840 * set up from the preset table
841 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200842static void setup_preset(struct alc_spec *spec,
843 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100844{
845 int i;
846
847 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100848 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100849 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200850 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
851 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100852 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200853
Kailang Yangdf694da2005-12-05 19:42:22 +0100854 spec->channel_mode = preset->channel_mode;
855 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200856 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100857
858 spec->multiout.max_channels = spec->channel_mode[0].channels;
859
860 spec->multiout.num_dacs = preset->num_dacs;
861 spec->multiout.dac_nids = preset->dac_nids;
862 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800863 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100864 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200865
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200866 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200867 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200868 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100869 spec->input_mux = preset->input_mux;
870
871 spec->num_adc_nids = preset->num_adc_nids;
872 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100873 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100874 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100875
876 spec->unsol_event = preset->unsol_event;
877 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200878#ifdef CONFIG_SND_HDA_POWER_SAVE
879 spec->loopback.amplist = preset->loopbacks;
880#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100881}
882
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200883/* Enable GPIO mask and set output */
884static struct hda_verb alc_gpio1_init_verbs[] = {
885 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
886 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
887 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
888 { }
889};
890
891static struct hda_verb alc_gpio2_init_verbs[] = {
892 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
893 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
894 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
895 { }
896};
897
Kailang Yangbdd148a2007-05-08 15:19:08 +0200898static struct hda_verb alc_gpio3_init_verbs[] = {
899 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
900 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
901 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
902 { }
903};
904
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200905/*
906 * Fix hardware PLL issue
907 * On some codecs, the analog PLL gating control must be off while
908 * the default value is 1.
909 */
910static void alc_fix_pll(struct hda_codec *codec)
911{
912 struct alc_spec *spec = codec->spec;
913 unsigned int val;
914
915 if (!spec->pll_nid)
916 return;
917 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
918 spec->pll_coef_idx);
919 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
920 AC_VERB_GET_PROC_COEF, 0);
921 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
922 spec->pll_coef_idx);
923 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
924 val & ~(1 << spec->pll_coef_bit));
925}
926
927static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
928 unsigned int coef_idx, unsigned int coef_bit)
929{
930 struct alc_spec *spec = codec->spec;
931 spec->pll_nid = nid;
932 spec->pll_coef_idx = coef_idx;
933 spec->pll_coef_bit = coef_bit;
934 alc_fix_pll(codec);
935}
936
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200937static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200938{
939 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200940 unsigned int present;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200941 unsigned int nid = spec->autocfg.hp_pins[0];
942 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200943
944 /* need to execute and sync at first */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200945 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
946 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200947 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200948 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
949 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
950 nid = spec->autocfg.speaker_pins[i];
951 if (!nid)
952 break;
953 snd_hda_codec_write(codec, nid, 0,
954 AC_VERB_SET_PIN_WIDGET_CONTROL,
955 spec->jack_present ? 0 : PIN_OUT);
956 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200957}
958
Takashi Iwai4605b712008-10-31 14:18:24 +0100959#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200960static void alc_mic_automute(struct hda_codec *codec)
961{
962 struct alc_spec *spec = codec->spec;
963 unsigned int present;
964 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
965 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
966 unsigned int mix_nid = spec->capsrc_nids[0];
967 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
968
969 capsrc_idx_mic = mic_nid - 0x18;
970 capsrc_idx_fmic = fmic_nid - 0x18;
971 present = snd_hda_codec_read(codec, mic_nid, 0,
972 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
973 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
974 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
975 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
976 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
977 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
978 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
979}
Takashi Iwai4605b712008-10-31 14:18:24 +0100980#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100981#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100982#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200983
Kailang Yangc9b58002007-10-16 14:30:01 +0200984/* unsolicited event for HP jack sensing */
985static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
986{
987 if (codec->vendor_id == 0x10ec0880)
988 res >>= 28;
989 else
990 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200991 switch (res) {
992 case ALC880_HP_EVENT:
993 alc_automute_pin(codec);
994 break;
995 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +0200996 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200997 break;
998 }
Kailang Yang7fb0d782008-10-15 11:12:35 +0200999}
1000
1001static void alc_inithook(struct hda_codec *codec)
1002{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001003 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001004 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001005}
1006
Kailang Yangf9423e72008-05-27 12:32:25 +02001007/* additional initialization for ALC888 variants */
1008static void alc888_coef_init(struct hda_codec *codec)
1009{
1010 unsigned int tmp;
1011
1012 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1013 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1014 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001015 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001016 /* alc888S-VC */
1017 snd_hda_codec_read(codec, 0x20, 0,
1018 AC_VERB_SET_PROC_COEF, 0x830);
1019 else
1020 /* alc888-VB */
1021 snd_hda_codec_read(codec, 0x20, 0,
1022 AC_VERB_SET_PROC_COEF, 0x3030);
1023}
1024
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001025static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001026{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001027 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001028
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001029 switch (type) {
1030 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001031 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1032 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001033 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001034 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1035 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001036 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001037 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1038 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001039 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001040 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001041 case 0x10ec0260:
1042 snd_hda_codec_write(codec, 0x0f, 0,
1043 AC_VERB_SET_EAPD_BTLENABLE, 2);
1044 snd_hda_codec_write(codec, 0x10, 0,
1045 AC_VERB_SET_EAPD_BTLENABLE, 2);
1046 break;
1047 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001048 case 0x10ec0267:
1049 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001050 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001051 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001052 case 0x10ec0660:
1053 case 0x10ec0662:
1054 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001055 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001056 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001057 snd_hda_codec_write(codec, 0x14, 0,
1058 AC_VERB_SET_EAPD_BTLENABLE, 2);
1059 snd_hda_codec_write(codec, 0x15, 0,
1060 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001061 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001062 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001063 switch (codec->vendor_id) {
1064 case 0x10ec0260:
1065 snd_hda_codec_write(codec, 0x1a, 0,
1066 AC_VERB_SET_COEF_INDEX, 7);
1067 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1068 AC_VERB_GET_PROC_COEF, 0);
1069 snd_hda_codec_write(codec, 0x1a, 0,
1070 AC_VERB_SET_COEF_INDEX, 7);
1071 snd_hda_codec_write(codec, 0x1a, 0,
1072 AC_VERB_SET_PROC_COEF,
1073 tmp | 0x2010);
1074 break;
1075 case 0x10ec0262:
1076 case 0x10ec0880:
1077 case 0x10ec0882:
1078 case 0x10ec0883:
1079 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001080 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001081 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001082 snd_hda_codec_write(codec, 0x20, 0,
1083 AC_VERB_SET_COEF_INDEX, 7);
1084 tmp = snd_hda_codec_read(codec, 0x20, 0,
1085 AC_VERB_GET_PROC_COEF, 0);
1086 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001087 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001088 snd_hda_codec_write(codec, 0x20, 0,
1089 AC_VERB_SET_PROC_COEF,
1090 tmp | 0x2010);
1091 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001092 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001093 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001094 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001095 case 0x10ec0267:
1096 case 0x10ec0268:
1097 snd_hda_codec_write(codec, 0x20, 0,
1098 AC_VERB_SET_COEF_INDEX, 7);
1099 tmp = snd_hda_codec_read(codec, 0x20, 0,
1100 AC_VERB_GET_PROC_COEF, 0);
1101 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001102 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001103 snd_hda_codec_write(codec, 0x20, 0,
1104 AC_VERB_SET_PROC_COEF,
1105 tmp | 0x3000);
1106 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001107 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001108 break;
1109 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001110}
Kailang Yangea1fb292008-08-26 12:58:38 +02001111
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001112static void alc_init_auto_hp(struct hda_codec *codec)
1113{
1114 struct alc_spec *spec = codec->spec;
1115
1116 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001117 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001118
Kailang Yangc9b58002007-10-16 14:30:01 +02001119 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001120 if (spec->autocfg.line_out_pins[0] &&
1121 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001122 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001123 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001124 else
1125 return;
1126 }
1127
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001128 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1129 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001130 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1131 AC_VERB_SET_UNSOLICITED_ENABLE,
1132 AC_USRSP_EN | ALC880_HP_EVENT);
1133 spec->unsol_event = alc_sku_unsol_event;
1134}
1135
1136/* check subsystem ID and set up device-specific initialization;
1137 * return 1 if initialized, 0 if invalid SSID
1138 */
1139/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1140 * 31 ~ 16 : Manufacture ID
1141 * 15 ~ 8 : SKU ID
1142 * 7 ~ 0 : Assembly ID
1143 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1144 */
1145static int alc_subsystem_id(struct hda_codec *codec,
1146 hda_nid_t porta, hda_nid_t porte,
1147 hda_nid_t portd)
1148{
1149 unsigned int ass, tmp, i;
1150 unsigned nid;
1151 struct alc_spec *spec = codec->spec;
1152
1153 ass = codec->subsystem_id & 0xffff;
1154 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1155 goto do_sku;
1156
1157 /* invalid SSID, check the special NID pin defcfg instead */
1158 /*
1159 * 31~30 : port conetcivity
1160 * 29~21 : reserve
1161 * 20 : PCBEEP input
1162 * 19~16 : Check sum (15:1)
1163 * 15~1 : Custom
1164 * 0 : override
1165 */
1166 nid = 0x1d;
1167 if (codec->vendor_id == 0x10ec0260)
1168 nid = 0x17;
1169 ass = snd_hda_codec_get_pincfg(codec, nid);
1170 snd_printd("realtek: No valid SSID, "
1171 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001172 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001173 if (!(ass & 1) && !(ass & 0x100000))
1174 return 0;
1175 if ((ass >> 30) != 1) /* no physical connection */
1176 return 0;
1177
1178 /* check sum */
1179 tmp = 0;
1180 for (i = 1; i < 16; i++) {
1181 if ((ass >> i) & 1)
1182 tmp++;
1183 }
1184 if (((ass >> 16) & 0xf) != tmp)
1185 return 0;
1186do_sku:
1187 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1188 ass & 0xffff, codec->vendor_id);
1189 /*
1190 * 0 : override
1191 * 1 : Swap Jack
1192 * 2 : 0 --> Desktop, 1 --> Laptop
1193 * 3~5 : External Amplifier control
1194 * 7~6 : Reserved
1195 */
1196 tmp = (ass & 0x38) >> 3; /* external Amp control */
1197 switch (tmp) {
1198 case 1:
1199 spec->init_amp = ALC_INIT_GPIO1;
1200 break;
1201 case 3:
1202 spec->init_amp = ALC_INIT_GPIO2;
1203 break;
1204 case 7:
1205 spec->init_amp = ALC_INIT_GPIO3;
1206 break;
1207 case 5:
1208 spec->init_amp = ALC_INIT_DEFAULT;
1209 break;
1210 }
1211
1212 /* is laptop or Desktop and enable the function "Mute internal speaker
1213 * when the external headphone out jack is plugged"
1214 */
1215 if (!(ass & 0x8000))
1216 return 1;
1217 /*
1218 * 10~8 : Jack location
1219 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1220 * 14~13: Resvered
1221 * 15 : 1 --> enable the function "Mute internal speaker
1222 * when the external headphone out jack is plugged"
1223 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001224 if (!spec->autocfg.hp_pins[0]) {
1225 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1226 if (tmp == 0)
1227 spec->autocfg.hp_pins[0] = porta;
1228 else if (tmp == 1)
1229 spec->autocfg.hp_pins[0] = porte;
1230 else if (tmp == 2)
1231 spec->autocfg.hp_pins[0] = portd;
1232 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001233 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001234 }
1235
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001236 alc_init_auto_hp(codec);
1237 return 1;
1238}
Kailang Yangea1fb292008-08-26 12:58:38 +02001239
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001240static void alc_ssid_check(struct hda_codec *codec,
1241 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1242{
1243 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1244 struct alc_spec *spec = codec->spec;
1245 snd_printd("realtek: "
1246 "Enable default setup for auto mode as fallback\n");
1247 spec->init_amp = ALC_INIT_DEFAULT;
1248 alc_init_auto_hp(codec);
1249 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001250}
1251
Takashi Iwai41e41f12005-06-08 14:48:49 +02001252/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001253 * Fix-up pin default configurations
1254 */
1255
1256struct alc_pincfg {
1257 hda_nid_t nid;
1258 u32 val;
1259};
1260
1261static void alc_fix_pincfg(struct hda_codec *codec,
1262 const struct snd_pci_quirk *quirk,
1263 const struct alc_pincfg **pinfix)
1264{
1265 const struct alc_pincfg *cfg;
1266
1267 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1268 if (!quirk)
1269 return;
1270
1271 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001272 for (; cfg->nid; cfg++)
1273 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001274}
1275
1276/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001277 * ALC888
1278 */
1279
1280/*
1281 * 2ch mode
1282 */
1283static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1284/* Mic-in jack as mic in */
1285 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1286 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1287/* Line-in jack as Line in */
1288 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1289 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1290/* Line-Out as Front */
1291 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1292 { } /* end */
1293};
1294
1295/*
1296 * 4ch mode
1297 */
1298static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1299/* Mic-in jack as mic in */
1300 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1301 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1302/* Line-in jack as Surround */
1303 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1304 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1305/* Line-Out as Front */
1306 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1307 { } /* end */
1308};
1309
1310/*
1311 * 6ch mode
1312 */
1313static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1314/* Mic-in jack as CLFE */
1315 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1316 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1317/* Line-in jack as Surround */
1318 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1319 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1320/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1321 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1322 { } /* end */
1323};
1324
1325/*
1326 * 8ch mode
1327 */
1328static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1329/* Mic-in jack as CLFE */
1330 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1331 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1332/* Line-in jack as Surround */
1333 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1334 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1335/* Line-Out as Side */
1336 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1337 { } /* end */
1338};
1339
1340static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1341 { 2, alc888_4ST_ch2_intel_init },
1342 { 4, alc888_4ST_ch4_intel_init },
1343 { 6, alc888_4ST_ch6_intel_init },
1344 { 8, alc888_4ST_ch8_intel_init },
1345};
1346
1347/*
1348 * ALC888 Fujitsu Siemens Amillo xa3530
1349 */
1350
1351static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1352/* Front Mic: set to PIN_IN (empty by default) */
1353 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1354/* Connect Internal HP to Front */
1355 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1356 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1357 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1358/* Connect Bass HP to Front */
1359 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1361 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1362/* Connect Line-Out side jack (SPDIF) to Side */
1363 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1364 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1365 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1366/* Connect Mic jack to CLFE */
1367 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1368 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1369 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1370/* Connect Line-in jack to Surround */
1371 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1372 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1373 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1374/* Connect HP out jack to Front */
1375 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1376 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1377 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1378/* Enable unsolicited event for HP jack and Line-out jack */
1379 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1380 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1381 {}
1382};
1383
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001384static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001385{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001386 struct alc_spec *spec = codec->spec;
1387 unsigned int val, mute;
1388 hda_nid_t nid;
1389 int i;
1390
1391 spec->jack_present = 0;
1392 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1393 nid = spec->autocfg.hp_pins[i];
1394 if (!nid)
1395 break;
1396 val = snd_hda_codec_read(codec, nid, 0,
1397 AC_VERB_GET_PIN_SENSE, 0);
1398 if (val & AC_PINSENSE_PRESENCE) {
1399 spec->jack_present = 1;
1400 break;
1401 }
1402 }
1403
1404 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001405 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001406 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1407 nid = spec->autocfg.speaker_pins[i];
1408 if (!nid)
1409 break;
1410 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1411 HDA_AMP_MUTE, mute);
1412 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001413}
1414
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001415static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1416 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001417{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001418 if (codec->vendor_id == 0x10ec0880)
1419 res >>= 28;
1420 else
1421 res >>= 26;
1422 if (res == ALC880_HP_EVENT)
1423 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001424}
1425
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001426static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1427{
1428 struct alc_spec *spec = codec->spec;
1429
1430 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1431 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1432 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1433 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1434 alc_automute_amp(codec);
1435}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001436
1437/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001438 * ALC888 Acer Aspire 4930G model
1439 */
1440
1441static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1442/* Front Mic: set to PIN_IN (empty by default) */
1443 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1444/* Unselect Front Mic by default in input mixer 3 */
1445 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001446/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001447 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1448/* Connect Internal HP to front */
1449 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1450 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1451 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1452/* Connect HP out to front */
1453 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1454 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1455 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1456 { }
1457};
1458
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001459static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001460 /* Front mic only available on one ADC */
1461 {
1462 .num_items = 4,
1463 .items = {
1464 { "Mic", 0x0 },
1465 { "Line", 0x2 },
1466 { "CD", 0x4 },
1467 { "Front Mic", 0xb },
1468 },
1469 },
1470 {
1471 .num_items = 3,
1472 .items = {
1473 { "Mic", 0x0 },
1474 { "Line", 0x2 },
1475 { "CD", 0x4 },
1476 },
1477 }
1478};
1479
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001480static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001481 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1482 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1483 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1484 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1485 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1486 HDA_OUTPUT),
1487 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1488 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1489 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1490 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1491 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1492 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1493 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1494 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1495 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1496 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1497 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1498 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001499 { } /* end */
1500};
1501
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001502static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001503{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001504 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001505
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001506 spec->autocfg.hp_pins[0] = 0x15;
1507 spec->autocfg.speaker_pins[0] = 0x14;
1508 alc_automute_amp(codec);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001509}
1510
1511/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001512 * ALC880 3-stack model
1513 *
1514 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001515 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1516 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001517 */
1518
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001519static hda_nid_t alc880_dac_nids[4] = {
1520 /* front, rear, clfe, rear_surr */
1521 0x02, 0x05, 0x04, 0x03
1522};
1523
1524static hda_nid_t alc880_adc_nids[3] = {
1525 /* ADC0-2 */
1526 0x07, 0x08, 0x09,
1527};
1528
1529/* The datasheet says the node 0x07 is connected from inputs,
1530 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001531 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001532 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001533static hda_nid_t alc880_adc_nids_alt[2] = {
1534 /* ADC1-2 */
1535 0x08, 0x09,
1536};
1537
1538#define ALC880_DIGOUT_NID 0x06
1539#define ALC880_DIGIN_NID 0x0a
1540
1541static struct hda_input_mux alc880_capture_source = {
1542 .num_items = 4,
1543 .items = {
1544 { "Mic", 0x0 },
1545 { "Front Mic", 0x3 },
1546 { "Line", 0x2 },
1547 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001548 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001549};
1550
1551/* channel source setting (2/6 channel selection for 3-stack) */
1552/* 2ch mode */
1553static struct hda_verb alc880_threestack_ch2_init[] = {
1554 /* set line-in to input, mute it */
1555 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1556 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1557 /* set mic-in to input vref 80%, mute it */
1558 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1559 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001560 { } /* end */
1561};
1562
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001563/* 6ch mode */
1564static struct hda_verb alc880_threestack_ch6_init[] = {
1565 /* set line-in to output, unmute it */
1566 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1567 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1568 /* set mic-in to output, unmute it */
1569 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1570 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1571 { } /* end */
1572};
1573
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001574static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001575 { 2, alc880_threestack_ch2_init },
1576 { 6, alc880_threestack_ch6_init },
1577};
1578
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001579static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001580 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001581 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001582 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001583 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001584 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1585 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001586 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1587 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001588 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1589 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1590 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1591 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1592 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1593 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1594 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1595 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001596 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001597 {
1598 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1599 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001600 .info = alc_ch_mode_info,
1601 .get = alc_ch_mode_get,
1602 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001603 },
1604 { } /* end */
1605};
1606
1607/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001608static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1609 struct snd_ctl_elem_info *uinfo)
1610{
1611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1612 struct alc_spec *spec = codec->spec;
1613 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001614
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001615 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001616 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1617 HDA_INPUT);
1618 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001619 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001620 return err;
1621}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001622
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001623static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1624 unsigned int size, unsigned int __user *tlv)
1625{
1626 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1627 struct alc_spec *spec = codec->spec;
1628 int err;
1629
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001630 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001631 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1632 HDA_INPUT);
1633 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001634 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001635 return err;
1636}
1637
1638typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1639 struct snd_ctl_elem_value *ucontrol);
1640
1641static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1642 struct snd_ctl_elem_value *ucontrol,
1643 getput_call_t func)
1644{
1645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1646 struct alc_spec *spec = codec->spec;
1647 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1648 int err;
1649
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001650 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001651 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1652 3, 0, HDA_INPUT);
1653 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001654 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001655 return err;
1656}
1657
1658static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1659 struct snd_ctl_elem_value *ucontrol)
1660{
1661 return alc_cap_getput_caller(kcontrol, ucontrol,
1662 snd_hda_mixer_amp_volume_get);
1663}
1664
1665static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1666 struct snd_ctl_elem_value *ucontrol)
1667{
1668 return alc_cap_getput_caller(kcontrol, ucontrol,
1669 snd_hda_mixer_amp_volume_put);
1670}
1671
1672/* capture mixer elements */
1673#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1674
1675static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1676 struct snd_ctl_elem_value *ucontrol)
1677{
1678 return alc_cap_getput_caller(kcontrol, ucontrol,
1679 snd_hda_mixer_amp_switch_get);
1680}
1681
1682static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1683 struct snd_ctl_elem_value *ucontrol)
1684{
1685 return alc_cap_getput_caller(kcontrol, ucontrol,
1686 snd_hda_mixer_amp_switch_put);
1687}
1688
Takashi Iwaia23b6882009-03-23 15:21:36 +01001689#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001690 { \
1691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1692 .name = "Capture Switch", \
1693 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1694 .count = num, \
1695 .info = alc_cap_sw_info, \
1696 .get = alc_cap_sw_get, \
1697 .put = alc_cap_sw_put, \
1698 }, \
1699 { \
1700 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1701 .name = "Capture Volume", \
1702 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1703 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1704 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1705 .count = num, \
1706 .info = alc_cap_vol_info, \
1707 .get = alc_cap_vol_get, \
1708 .put = alc_cap_vol_put, \
1709 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001710 }
1711
1712#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001713 { \
1714 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1715 /* .name = "Capture Source", */ \
1716 .name = "Input Source", \
1717 .count = num, \
1718 .info = alc_mux_enum_info, \
1719 .get = alc_mux_enum_get, \
1720 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001721 }
1722
1723#define DEFINE_CAPMIX(num) \
1724static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1725 _DEFINE_CAPMIX(num), \
1726 _DEFINE_CAPSRC(num), \
1727 { } /* end */ \
1728}
1729
1730#define DEFINE_CAPMIX_NOSRC(num) \
1731static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1732 _DEFINE_CAPMIX(num), \
1733 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001734}
1735
1736/* up to three ADCs */
1737DEFINE_CAPMIX(1);
1738DEFINE_CAPMIX(2);
1739DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01001740DEFINE_CAPMIX_NOSRC(1);
1741DEFINE_CAPMIX_NOSRC(2);
1742DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001743
1744/*
1745 * ALC880 5-stack model
1746 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001747 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1748 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001749 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1750 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1751 */
1752
1753/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001754static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001755 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001756 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001757 { } /* end */
1758};
1759
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001760/* channel source setting (6/8 channel selection for 5-stack) */
1761/* 6ch mode */
1762static struct hda_verb alc880_fivestack_ch6_init[] = {
1763 /* set line-in to input, mute it */
1764 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1765 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001766 { } /* end */
1767};
1768
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001769/* 8ch mode */
1770static struct hda_verb alc880_fivestack_ch8_init[] = {
1771 /* set line-in to output, unmute it */
1772 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1773 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1774 { } /* end */
1775};
1776
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001777static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001778 { 6, alc880_fivestack_ch6_init },
1779 { 8, alc880_fivestack_ch8_init },
1780};
1781
1782
1783/*
1784 * ALC880 6-stack model
1785 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001786 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1787 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001788 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1789 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1790 */
1791
1792static hda_nid_t alc880_6st_dac_nids[4] = {
1793 /* front, rear, clfe, rear_surr */
1794 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001795};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001796
1797static struct hda_input_mux alc880_6stack_capture_source = {
1798 .num_items = 4,
1799 .items = {
1800 { "Mic", 0x0 },
1801 { "Front Mic", 0x1 },
1802 { "Line", 0x2 },
1803 { "CD", 0x4 },
1804 },
1805};
1806
1807/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001808static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001809 { 8, NULL },
1810};
1811
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001812static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001813 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001814 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001815 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001816 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001817 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1818 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001819 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1820 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001821 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001822 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001823 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1824 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1825 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1826 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1827 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1828 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1829 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1830 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001831 {
1832 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1833 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001834 .info = alc_ch_mode_info,
1835 .get = alc_ch_mode_get,
1836 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001837 },
1838 { } /* end */
1839};
1840
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001841
1842/*
1843 * ALC880 W810 model
1844 *
1845 * W810 has rear IO for:
1846 * Front (DAC 02)
1847 * Surround (DAC 03)
1848 * Center/LFE (DAC 04)
1849 * Digital out (06)
1850 *
1851 * The system also has a pair of internal speakers, and a headphone jack.
1852 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001853 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001854 * There is a variable resistor to control the speaker or headphone
1855 * volume. This is a hardware-only device without a software API.
1856 *
1857 * Plugging headphones in will disable the internal speakers. This is
1858 * implemented in hardware, not via the driver using jack sense. In
1859 * a similar fashion, plugging into the rear socket marked "front" will
1860 * disable both the speakers and headphones.
1861 *
1862 * For input, there's a microphone jack, and an "audio in" jack.
1863 * These may not do anything useful with this driver yet, because I
1864 * haven't setup any initialization verbs for these yet...
1865 */
1866
1867static hda_nid_t alc880_w810_dac_nids[3] = {
1868 /* front, rear/surround, clfe */
1869 0x02, 0x03, 0x04
1870};
1871
1872/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001873static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001874 { 6, NULL }
1875};
1876
1877/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001878static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001879 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001880 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001881 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001882 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001883 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1884 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001885 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1886 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001887 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1888 { } /* end */
1889};
1890
1891
1892/*
1893 * Z710V model
1894 *
1895 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001896 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1897 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001898 */
1899
1900static hda_nid_t alc880_z71v_dac_nids[1] = {
1901 0x02
1902};
1903#define ALC880_Z71V_HP_DAC 0x03
1904
1905/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001906static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001907 { 2, NULL }
1908};
1909
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001910static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001911 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001912 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001913 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001914 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001915 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1916 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1918 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1919 { } /* end */
1920};
1921
1922
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001923/*
1924 * ALC880 F1734 model
1925 *
1926 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1927 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1928 */
1929
1930static hda_nid_t alc880_f1734_dac_nids[1] = {
1931 0x03
1932};
1933#define ALC880_F1734_HP_DAC 0x02
1934
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001935static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001936 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001937 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001938 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1939 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001940 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1941 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001942 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1943 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001944 { } /* end */
1945};
1946
Takashi Iwai937b4162008-02-11 14:52:36 +01001947static struct hda_input_mux alc880_f1734_capture_source = {
1948 .num_items = 2,
1949 .items = {
1950 { "Mic", 0x1 },
1951 { "CD", 0x4 },
1952 },
1953};
1954
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001955
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001956/*
1957 * ALC880 ASUS model
1958 *
1959 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1960 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1961 * Mic = 0x18, Line = 0x1a
1962 */
1963
1964#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1965#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1966
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001967static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001968 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001969 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001970 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001971 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001972 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1973 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001974 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1975 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001976 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1977 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1978 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1979 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1980 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1981 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001982 {
1983 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1984 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001985 .info = alc_ch_mode_info,
1986 .get = alc_ch_mode_get,
1987 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001988 },
1989 { } /* end */
1990};
1991
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001992/*
1993 * ALC880 ASUS W1V model
1994 *
1995 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1996 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1997 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1998 */
1999
2000/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002001static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002002 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2003 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002004 { } /* end */
2005};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002006
Kailang Yangdf694da2005-12-05 19:42:22 +01002007/* TCL S700 */
2008static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2009 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2010 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2011 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2012 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2013 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2014 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2015 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2016 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2017 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002018 { } /* end */
2019};
2020
Kailang Yangccc656c2006-10-17 12:32:26 +02002021/* Uniwill */
2022static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002023 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2024 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2025 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2026 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002027 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2028 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2029 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2030 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2031 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2032 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2033 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2034 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2035 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2036 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2037 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2038 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002039 {
2040 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2041 .name = "Channel Mode",
2042 .info = alc_ch_mode_info,
2043 .get = alc_ch_mode_get,
2044 .put = alc_ch_mode_put,
2045 },
2046 { } /* end */
2047};
2048
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002049static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2050 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2051 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2052 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2053 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2054 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2055 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2056 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2057 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2058 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2059 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2060 { } /* end */
2061};
2062
Kailang Yangccc656c2006-10-17 12:32:26 +02002063static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002064 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2065 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2066 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2067 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002068 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2069 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2070 { } /* end */
2071};
2072
Linus Torvalds1da177e2005-04-16 15:20:36 -07002073/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002074 * virtual master controls
2075 */
2076
2077/*
2078 * slave controls for virtual master
2079 */
2080static const char *alc_slave_vols[] = {
2081 "Front Playback Volume",
2082 "Surround Playback Volume",
2083 "Center Playback Volume",
2084 "LFE Playback Volume",
2085 "Side Playback Volume",
2086 "Headphone Playback Volume",
2087 "Speaker Playback Volume",
2088 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002089 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002090 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002091 NULL,
2092};
2093
2094static const char *alc_slave_sws[] = {
2095 "Front Playback Switch",
2096 "Surround Playback Switch",
2097 "Center Playback Switch",
2098 "LFE Playback Switch",
2099 "Side Playback Switch",
2100 "Headphone Playback Switch",
2101 "Speaker Playback Switch",
2102 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002103 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002104 NULL,
2105};
2106
2107/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002108 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002109 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002110
2111static void alc_free_kctls(struct hda_codec *codec);
2112
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002113/* additional beep mixers; the actual parameters are overwritten at build */
2114static struct snd_kcontrol_new alc_beep_mixer[] = {
2115 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2116 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2117 { } /* end */
2118};
2119
Linus Torvalds1da177e2005-04-16 15:20:36 -07002120static int alc_build_controls(struct hda_codec *codec)
2121{
2122 struct alc_spec *spec = codec->spec;
2123 int err;
2124 int i;
2125
2126 for (i = 0; i < spec->num_mixers; i++) {
2127 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2128 if (err < 0)
2129 return err;
2130 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002131 if (spec->cap_mixer) {
2132 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2133 if (err < 0)
2134 return err;
2135 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002136 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002137 err = snd_hda_create_spdif_out_ctls(codec,
2138 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002139 if (err < 0)
2140 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002141 if (!spec->no_analog) {
2142 err = snd_hda_create_spdif_share_sw(codec,
2143 &spec->multiout);
2144 if (err < 0)
2145 return err;
2146 spec->multiout.share_spdif = 1;
2147 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002148 }
2149 if (spec->dig_in_nid) {
2150 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2151 if (err < 0)
2152 return err;
2153 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002154
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002155 /* create beep controls if needed */
2156 if (spec->beep_amp) {
2157 struct snd_kcontrol_new *knew;
2158 for (knew = alc_beep_mixer; knew->name; knew++) {
2159 struct snd_kcontrol *kctl;
2160 kctl = snd_ctl_new1(knew, codec);
2161 if (!kctl)
2162 return -ENOMEM;
2163 kctl->private_value = spec->beep_amp;
2164 err = snd_hda_ctl_add(codec, kctl);
2165 if (err < 0)
2166 return err;
2167 }
2168 }
2169
Takashi Iwai2134ea42008-01-10 16:53:55 +01002170 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002171 if (!spec->no_analog &&
2172 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002173 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002174 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002175 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002176 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002177 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002178 if (err < 0)
2179 return err;
2180 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002181 if (!spec->no_analog &&
2182 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002183 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2184 NULL, alc_slave_sws);
2185 if (err < 0)
2186 return err;
2187 }
2188
Takashi Iwai603c4012008-07-30 15:01:44 +02002189 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002190 return 0;
2191}
2192
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002193
Linus Torvalds1da177e2005-04-16 15:20:36 -07002194/*
2195 * initialize the codec volumes, etc
2196 */
2197
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002198/*
2199 * generic initialization of ADC, input mixers and output mixers
2200 */
2201static struct hda_verb alc880_volume_init_verbs[] = {
2202 /*
2203 * Unmute ADC0-2 and set the default input to mic-in
2204 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002205 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002206 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002207 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002208 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002209 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002210 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002211
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002212 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2213 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002214 * Note: PASD motherboards uses the Line In 2 as the input for front
2215 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002216 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002217 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002218 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2219 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2220 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2221 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2222 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2223 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2224 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002225
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002226 /*
2227 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002228 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002229 /* set vol=0 to output mixers */
2230 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2231 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2232 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2233 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2234 /* set up input amps for analog loopback */
2235 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002236 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2237 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002238 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2239 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002240 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2241 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002242 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2243 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002244
2245 { }
2246};
2247
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002248/*
2249 * 3-stack pin configuration:
2250 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2251 */
2252static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2253 /*
2254 * preset connection lists of input pins
2255 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2256 */
2257 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2258 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2259 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2260
2261 /*
2262 * Set pin mode and muting
2263 */
2264 /* set front pin widgets 0x14 for output */
2265 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2266 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2267 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2268 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2269 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2270 /* Mic2 (as headphone out) for HP output */
2271 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2272 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2273 /* Line In pin widget for input */
2274 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2275 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2276 /* Line2 (as front mic) pin widget for input and vref at 80% */
2277 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2278 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2279 /* CD pin widget for input */
2280 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2281
2282 { }
2283};
2284
2285/*
2286 * 5-stack pin configuration:
2287 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2288 * line-in/side = 0x1a, f-mic = 0x1b
2289 */
2290static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2291 /*
2292 * preset connection lists of input pins
2293 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2294 */
2295 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2296 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2297
2298 /*
2299 * Set pin mode and muting
2300 */
2301 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002302 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2303 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2304 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2305 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002306 /* unmute pins for output (no gain on this amp) */
2307 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2308 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2309 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2310 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2311
Linus Torvalds1da177e2005-04-16 15:20:36 -07002312 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002313 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002314 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2315 /* Mic2 (as headphone out) for HP output */
2316 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002317 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002318 /* Line In pin widget for input */
2319 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2320 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2321 /* Line2 (as front mic) pin widget for input and vref at 80% */
2322 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2323 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2324 /* CD pin widget for input */
2325 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002326
2327 { }
2328};
2329
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002330/*
2331 * W810 pin configuration:
2332 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2333 */
2334static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002335 /* hphone/speaker input selector: front DAC */
2336 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2337
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002338 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2339 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2340 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2341 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2342 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2343 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2344
2345 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002346 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002347
Linus Torvalds1da177e2005-04-16 15:20:36 -07002348 { }
2349};
2350
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002351/*
2352 * Z71V pin configuration:
2353 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2354 */
2355static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002356 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002357 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002358 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002359 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002360
Takashi Iwai16ded522005-06-10 19:58:24 +02002361 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002362 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002363 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002364 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002365
2366 { }
2367};
2368
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002369/*
2370 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002371 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2372 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002373 */
2374static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2375 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2376
Takashi Iwai16ded522005-06-10 19:58:24 +02002377 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002378 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002379 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002380 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002381 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002382 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002383 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002384 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2385
Takashi Iwai16ded522005-06-10 19:58:24 +02002386 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002387 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002388 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002389 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002390 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002391 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002392 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002393 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002394 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002395
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002396 { }
2397};
Takashi Iwai16ded522005-06-10 19:58:24 +02002398
Kailang Yangccc656c2006-10-17 12:32:26 +02002399/*
2400 * Uniwill pin configuration:
2401 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2402 * line = 0x1a
2403 */
2404static struct hda_verb alc880_uniwill_init_verbs[] = {
2405 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2406
2407 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2408 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2409 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2410 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2411 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2412 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2413 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2414 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2415 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2416 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2417 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2418 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2419 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2420 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2421
2422 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2423 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2424 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2425 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2426 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2427 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2428 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2429 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2430 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2431
2432 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2433 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2434
2435 { }
2436};
2437
2438/*
2439* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002440* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002441 */
2442static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2443 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2444
2445 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2446 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2447 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2449 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2450 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2451 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2452 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2453 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2454 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2455 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2456 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2457
2458 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2459 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2460 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2461 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2462 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2463 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2464
2465 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2466 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2467
2468 { }
2469};
2470
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002471static struct hda_verb alc880_beep_init_verbs[] = {
2472 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2473 { }
2474};
2475
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002476/* auto-toggle front mic */
2477static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2478{
2479 unsigned int present;
2480 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002481
2482 present = snd_hda_codec_read(codec, 0x18, 0,
2483 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002484 bits = present ? HDA_AMP_MUTE : 0;
2485 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002486}
2487
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002488static void alc880_uniwill_init_hook(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002489{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002490 struct alc_spec *spec = codec->spec;
2491
2492 spec->autocfg.hp_pins[0] = 0x14;
2493 spec->autocfg.speaker_pins[0] = 0x15;
2494 spec->autocfg.speaker_pins[0] = 0x16;
2495 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002496 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002497}
2498
2499static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2500 unsigned int res)
2501{
2502 /* Looks like the unsol event is incompatible with the standard
2503 * definition. 4bit tag is placed at 28 bit!
2504 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002505 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002506 case ALC880_MIC_EVENT:
2507 alc880_uniwill_mic_automute(codec);
2508 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002509 default:
2510 alc_automute_amp_unsol_event(codec, res);
2511 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002512 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002513}
2514
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002515static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002516{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002517 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002518
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002519 spec->autocfg.hp_pins[0] = 0x14;
2520 spec->autocfg.speaker_pins[0] = 0x15;
2521 alc_automute_amp(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002522}
2523
2524static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2525{
2526 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002527
Kailang Yangccc656c2006-10-17 12:32:26 +02002528 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002529 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2530 present &= HDA_AMP_VOLMASK;
2531 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2532 HDA_AMP_VOLMASK, present);
2533 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2534 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002535}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002536
Kailang Yangccc656c2006-10-17 12:32:26 +02002537static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2538 unsigned int res)
2539{
2540 /* Looks like the unsol event is incompatible with the standard
2541 * definition. 4bit tag is placed at 28 bit!
2542 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002543 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002544 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002545 else
2546 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002547}
2548
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002549/*
2550 * F1734 pin configuration:
2551 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2552 */
2553static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002554 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002555 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2556 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2557 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2558 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2559
2560 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2561 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2562 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2563 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2564
2565 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2566 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002567 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002568 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2569 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2570 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2571 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2572 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2573 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002574
Takashi Iwai937b4162008-02-11 14:52:36 +01002575 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2576 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2577
Takashi Iwai16ded522005-06-10 19:58:24 +02002578 { }
2579};
2580
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002581/*
2582 * ASUS pin configuration:
2583 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2584 */
2585static struct hda_verb alc880_pin_asus_init_verbs[] = {
2586 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2587 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2588 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2589 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2590
2591 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2592 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2593 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2594 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2595 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2596 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2597 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2598 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2599
2600 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2601 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2602 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2603 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2604 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2605 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2606 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2607 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2608 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002609
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002610 { }
2611};
2612
2613/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002614#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2615#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002616
Kailang Yangdf694da2005-12-05 19:42:22 +01002617/* Clevo m520g init */
2618static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2619 /* headphone output */
2620 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2621 /* line-out */
2622 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2623 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2624 /* Line-in */
2625 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2626 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2627 /* CD */
2628 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2629 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2630 /* Mic1 (rear panel) */
2631 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2632 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2633 /* Mic2 (front panel) */
2634 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2635 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2636 /* headphone */
2637 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2638 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2639 /* change to EAPD mode */
2640 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2641 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2642
2643 { }
2644};
2645
2646static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002647 /* change to EAPD mode */
2648 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2649 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2650
Kailang Yangdf694da2005-12-05 19:42:22 +01002651 /* Headphone output */
2652 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2653 /* Front output*/
2654 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2655 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2656
2657 /* Line In pin widget for input */
2658 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2659 /* CD pin widget for input */
2660 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2661 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2662 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2663
2664 /* change to EAPD mode */
2665 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2666 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2667
2668 { }
2669};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002670
2671/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002672 * LG m1 express dual
2673 *
2674 * Pin assignment:
2675 * Rear Line-In/Out (blue): 0x14
2676 * Build-in Mic-In: 0x15
2677 * Speaker-out: 0x17
2678 * HP-Out (green): 0x1b
2679 * Mic-In/Out (red): 0x19
2680 * SPDIF-Out: 0x1e
2681 */
2682
2683/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2684static hda_nid_t alc880_lg_dac_nids[3] = {
2685 0x05, 0x02, 0x03
2686};
2687
2688/* seems analog CD is not working */
2689static struct hda_input_mux alc880_lg_capture_source = {
2690 .num_items = 3,
2691 .items = {
2692 { "Mic", 0x1 },
2693 { "Line", 0x5 },
2694 { "Internal Mic", 0x6 },
2695 },
2696};
2697
2698/* 2,4,6 channel modes */
2699static struct hda_verb alc880_lg_ch2_init[] = {
2700 /* set line-in and mic-in to input */
2701 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2702 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2703 { }
2704};
2705
2706static struct hda_verb alc880_lg_ch4_init[] = {
2707 /* set line-in to out and mic-in to input */
2708 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2709 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2710 { }
2711};
2712
2713static struct hda_verb alc880_lg_ch6_init[] = {
2714 /* set line-in and mic-in to output */
2715 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2716 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2717 { }
2718};
2719
2720static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2721 { 2, alc880_lg_ch2_init },
2722 { 4, alc880_lg_ch4_init },
2723 { 6, alc880_lg_ch6_init },
2724};
2725
2726static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002727 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2728 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002729 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2730 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2731 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2732 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2733 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2734 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2735 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2736 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2737 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2738 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2739 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2740 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2741 {
2742 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2743 .name = "Channel Mode",
2744 .info = alc_ch_mode_info,
2745 .get = alc_ch_mode_get,
2746 .put = alc_ch_mode_put,
2747 },
2748 { } /* end */
2749};
2750
2751static struct hda_verb alc880_lg_init_verbs[] = {
2752 /* set capture source to mic-in */
2753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2754 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2755 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2756 /* mute all amp mixer inputs */
2757 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002758 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2759 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002760 /* line-in to input */
2761 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2762 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2763 /* built-in mic */
2764 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2765 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2766 /* speaker-out */
2767 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2768 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2769 /* mic-in to input */
2770 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2771 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2772 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2773 /* HP-out */
2774 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2775 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2776 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2777 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002778 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002779 { }
2780};
2781
2782/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002783static void alc880_lg_init_hook(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002784{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002785 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002786
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002787 spec->autocfg.hp_pins[0] = 0x1b;
2788 spec->autocfg.speaker_pins[0] = 0x17;
2789 alc_automute_amp(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002790}
2791
2792/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002793 * LG LW20
2794 *
2795 * Pin assignment:
2796 * Speaker-out: 0x14
2797 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002798 * Built-in Mic-In: 0x19
2799 * Line-In: 0x1b
2800 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002801 * SPDIF-Out: 0x1e
2802 */
2803
Takashi Iwaid6815182006-03-23 16:06:23 +01002804static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002805 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002806 .items = {
2807 { "Mic", 0x0 },
2808 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002809 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002810 },
2811};
2812
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002813#define alc880_lg_lw_modes alc880_threestack_modes
2814
Takashi Iwaid6815182006-03-23 16:06:23 +01002815static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002816 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2817 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2818 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2819 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2820 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2821 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2822 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2823 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2824 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2825 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002826 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2827 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2828 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2829 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002830 {
2831 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2832 .name = "Channel Mode",
2833 .info = alc_ch_mode_info,
2834 .get = alc_ch_mode_get,
2835 .put = alc_ch_mode_put,
2836 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002837 { } /* end */
2838};
2839
2840static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002841 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2842 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2843 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2844
Takashi Iwaid6815182006-03-23 16:06:23 +01002845 /* set capture source to mic-in */
2846 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2847 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2848 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002849 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002850 /* speaker-out */
2851 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2852 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2853 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002854 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2855 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2856 /* mic-in to input */
2857 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2858 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2859 /* built-in mic */
2860 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2861 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2862 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002863 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01002864 { }
2865};
2866
2867/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002868static void alc880_lg_lw_init_hook(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01002869{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002870 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01002871
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002872 spec->autocfg.hp_pins[0] = 0x1b;
2873 spec->autocfg.speaker_pins[0] = 0x14;
2874 alc_automute_amp(codec);
Takashi Iwaid6815182006-03-23 16:06:23 +01002875}
2876
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002877static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2878 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2879 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2880 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2881 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2882 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2883 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2884 { } /* end */
2885};
2886
2887static struct hda_input_mux alc880_medion_rim_capture_source = {
2888 .num_items = 2,
2889 .items = {
2890 { "Mic", 0x0 },
2891 { "Internal Mic", 0x1 },
2892 },
2893};
2894
2895static struct hda_verb alc880_medion_rim_init_verbs[] = {
2896 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2897
2898 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2899 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2900
2901 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2902 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2903 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2904 /* Mic2 (as headphone out) for HP output */
2905 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2906 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2907 /* Internal Speaker */
2908 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2909 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2910
2911 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2912 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2913
2914 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2915 { }
2916};
2917
2918/* toggle speaker-output according to the hp-jack state */
2919static void alc880_medion_rim_automute(struct hda_codec *codec)
2920{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002921 struct alc_spec *spec = codec->spec;
2922 alc_automute_amp(codec);
2923 /* toggle EAPD */
2924 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002925 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2926 else
2927 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2928}
2929
2930static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2931 unsigned int res)
2932{
2933 /* Looks like the unsol event is incompatible with the standard
2934 * definition. 4bit tag is placed at 28 bit!
2935 */
2936 if ((res >> 28) == ALC880_HP_EVENT)
2937 alc880_medion_rim_automute(codec);
2938}
2939
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002940static void alc880_medion_rim_init_hook(struct hda_codec *codec)
2941{
2942 struct alc_spec *spec = codec->spec;
2943
2944 spec->autocfg.hp_pins[0] = 0x14;
2945 spec->autocfg.speaker_pins[0] = 0x1b;
2946 alc880_medion_rim_automute(codec);
2947}
2948
Takashi Iwaicb53c622007-08-10 17:21:45 +02002949#ifdef CONFIG_SND_HDA_POWER_SAVE
2950static struct hda_amp_list alc880_loopbacks[] = {
2951 { 0x0b, HDA_INPUT, 0 },
2952 { 0x0b, HDA_INPUT, 1 },
2953 { 0x0b, HDA_INPUT, 2 },
2954 { 0x0b, HDA_INPUT, 3 },
2955 { 0x0b, HDA_INPUT, 4 },
2956 { } /* end */
2957};
2958
2959static struct hda_amp_list alc880_lg_loopbacks[] = {
2960 { 0x0b, HDA_INPUT, 1 },
2961 { 0x0b, HDA_INPUT, 6 },
2962 { 0x0b, HDA_INPUT, 7 },
2963 { } /* end */
2964};
2965#endif
2966
Takashi Iwaid6815182006-03-23 16:06:23 +01002967/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002968 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002969 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002970
Linus Torvalds1da177e2005-04-16 15:20:36 -07002971static int alc_init(struct hda_codec *codec)
2972{
2973 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002974 unsigned int i;
2975
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002976 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02002977 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002978
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002979 for (i = 0; i < spec->num_init_verbs; i++)
2980 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002981
2982 if (spec->init_hook)
2983 spec->init_hook(codec);
2984
Linus Torvalds1da177e2005-04-16 15:20:36 -07002985 return 0;
2986}
2987
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002988static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2989{
2990 struct alc_spec *spec = codec->spec;
2991
2992 if (spec->unsol_event)
2993 spec->unsol_event(codec, res);
2994}
2995
Takashi Iwaicb53c622007-08-10 17:21:45 +02002996#ifdef CONFIG_SND_HDA_POWER_SAVE
2997static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2998{
2999 struct alc_spec *spec = codec->spec;
3000 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3001}
3002#endif
3003
Linus Torvalds1da177e2005-04-16 15:20:36 -07003004/*
3005 * Analog playback callbacks
3006 */
3007static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3008 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003009 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003010{
3011 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003012 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3013 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003014}
3015
3016static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3017 struct hda_codec *codec,
3018 unsigned int stream_tag,
3019 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003020 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003021{
3022 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003023 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3024 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003025}
3026
3027static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3028 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003029 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003030{
3031 struct alc_spec *spec = codec->spec;
3032 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3033}
3034
3035/*
3036 * Digital out
3037 */
3038static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3039 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003040 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003041{
3042 struct alc_spec *spec = codec->spec;
3043 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3044}
3045
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003046static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3047 struct hda_codec *codec,
3048 unsigned int stream_tag,
3049 unsigned int format,
3050 struct snd_pcm_substream *substream)
3051{
3052 struct alc_spec *spec = codec->spec;
3053 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3054 stream_tag, format, substream);
3055}
3056
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003057static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3058 struct hda_codec *codec,
3059 struct snd_pcm_substream *substream)
3060{
3061 struct alc_spec *spec = codec->spec;
3062 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3063}
3064
Linus Torvalds1da177e2005-04-16 15:20:36 -07003065static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3066 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003067 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003068{
3069 struct alc_spec *spec = codec->spec;
3070 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3071}
3072
3073/*
3074 * Analog capture
3075 */
Takashi Iwai63300792008-01-24 15:31:36 +01003076static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003077 struct hda_codec *codec,
3078 unsigned int stream_tag,
3079 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003080 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003081{
3082 struct alc_spec *spec = codec->spec;
3083
Takashi Iwai63300792008-01-24 15:31:36 +01003084 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003085 stream_tag, 0, format);
3086 return 0;
3087}
3088
Takashi Iwai63300792008-01-24 15:31:36 +01003089static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003090 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003091 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003092{
3093 struct alc_spec *spec = codec->spec;
3094
Takashi Iwai888afa12008-03-18 09:57:50 +01003095 snd_hda_codec_cleanup_stream(codec,
3096 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003097 return 0;
3098}
3099
3100
3101/*
3102 */
3103static struct hda_pcm_stream alc880_pcm_analog_playback = {
3104 .substreams = 1,
3105 .channels_min = 2,
3106 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003107 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003108 .ops = {
3109 .open = alc880_playback_pcm_open,
3110 .prepare = alc880_playback_pcm_prepare,
3111 .cleanup = alc880_playback_pcm_cleanup
3112 },
3113};
3114
3115static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003116 .substreams = 1,
3117 .channels_min = 2,
3118 .channels_max = 2,
3119 /* NID is set in alc_build_pcms */
3120};
3121
3122static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3123 .substreams = 1,
3124 .channels_min = 2,
3125 .channels_max = 2,
3126 /* NID is set in alc_build_pcms */
3127};
3128
3129static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3130 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003131 .channels_min = 2,
3132 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003133 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003134 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003135 .prepare = alc880_alt_capture_pcm_prepare,
3136 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003137 },
3138};
3139
3140static struct hda_pcm_stream alc880_pcm_digital_playback = {
3141 .substreams = 1,
3142 .channels_min = 2,
3143 .channels_max = 2,
3144 /* NID is set in alc_build_pcms */
3145 .ops = {
3146 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003147 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003148 .prepare = alc880_dig_playback_pcm_prepare,
3149 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003150 },
3151};
3152
3153static struct hda_pcm_stream alc880_pcm_digital_capture = {
3154 .substreams = 1,
3155 .channels_min = 2,
3156 .channels_max = 2,
3157 /* NID is set in alc_build_pcms */
3158};
3159
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003160/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003161static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003162 .substreams = 0,
3163 .channels_min = 0,
3164 .channels_max = 0,
3165};
3166
Linus Torvalds1da177e2005-04-16 15:20:36 -07003167static int alc_build_pcms(struct hda_codec *codec)
3168{
3169 struct alc_spec *spec = codec->spec;
3170 struct hda_pcm *info = spec->pcm_rec;
3171 int i;
3172
3173 codec->num_pcms = 1;
3174 codec->pcm_info = info;
3175
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003176 if (spec->no_analog)
3177 goto skip_analog;
3178
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003179 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3180 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003181 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003182
Takashi Iwai4a471b72005-12-07 13:56:29 +01003183 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003184 if (snd_BUG_ON(!spec->multiout.dac_nids))
3185 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003186 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3187 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3188 }
3189 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003190 if (snd_BUG_ON(!spec->adc_nids))
3191 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003192 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3193 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3194 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003195
Takashi Iwai4a471b72005-12-07 13:56:29 +01003196 if (spec->channel_mode) {
3197 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3198 for (i = 0; i < spec->num_channel_mode; i++) {
3199 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3200 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3201 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003202 }
3203 }
3204
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003205 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003206 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003207 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003208 snprintf(spec->stream_name_digital,
3209 sizeof(spec->stream_name_digital),
3210 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003211 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003212 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003213 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003214 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003215 if (spec->dig_out_type)
3216 info->pcm_type = spec->dig_out_type;
3217 else
3218 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003219 if (spec->multiout.dig_out_nid &&
3220 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003221 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3222 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3223 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003224 if (spec->dig_in_nid &&
3225 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003226 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3227 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3228 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003229 /* FIXME: do we need this for all Realtek codec models? */
3230 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003231 }
3232
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003233 if (spec->no_analog)
3234 return 0;
3235
Takashi Iwaie08a0072006-09-07 17:52:14 +02003236 /* If the use of more than one ADC is requested for the current
3237 * model, configure a second analog capture-only PCM.
3238 */
3239 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003240 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3241 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003242 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003243 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003244 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003245 if (spec->alt_dac_nid) {
3246 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3247 *spec->stream_analog_alt_playback;
3248 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3249 spec->alt_dac_nid;
3250 } else {
3251 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3252 alc_pcm_null_stream;
3253 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3254 }
3255 if (spec->num_adc_nids > 1) {
3256 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3257 *spec->stream_analog_alt_capture;
3258 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3259 spec->adc_nids[1];
3260 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3261 spec->num_adc_nids - 1;
3262 } else {
3263 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3264 alc_pcm_null_stream;
3265 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003266 }
3267 }
3268
Linus Torvalds1da177e2005-04-16 15:20:36 -07003269 return 0;
3270}
3271
Takashi Iwai603c4012008-07-30 15:01:44 +02003272static void alc_free_kctls(struct hda_codec *codec)
3273{
3274 struct alc_spec *spec = codec->spec;
3275
3276 if (spec->kctls.list) {
3277 struct snd_kcontrol_new *kctl = spec->kctls.list;
3278 int i;
3279 for (i = 0; i < spec->kctls.used; i++)
3280 kfree(kctl[i].name);
3281 }
3282 snd_array_free(&spec->kctls);
3283}
3284
Linus Torvalds1da177e2005-04-16 15:20:36 -07003285static void alc_free(struct hda_codec *codec)
3286{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003287 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003288
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003289 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003290 return;
3291
Takashi Iwai603c4012008-07-30 15:01:44 +02003292 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003293 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003294 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003295}
3296
Takashi Iwaie044c392008-10-27 16:56:24 +01003297#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003298static int alc_resume(struct hda_codec *codec)
3299{
Takashi Iwaie044c392008-10-27 16:56:24 +01003300 codec->patch_ops.init(codec);
3301 snd_hda_codec_resume_amp(codec);
3302 snd_hda_codec_resume_cache(codec);
3303 return 0;
3304}
Takashi Iwaie044c392008-10-27 16:56:24 +01003305#endif
3306
Linus Torvalds1da177e2005-04-16 15:20:36 -07003307/*
3308 */
3309static struct hda_codec_ops alc_patch_ops = {
3310 .build_controls = alc_build_controls,
3311 .build_pcms = alc_build_pcms,
3312 .init = alc_init,
3313 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003314 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003315#ifdef SND_HDA_NEEDS_RESUME
3316 .resume = alc_resume,
3317#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003318#ifdef CONFIG_SND_HDA_POWER_SAVE
3319 .check_power_status = alc_check_power_status,
3320#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003321};
3322
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003323
3324/*
3325 * Test configuration for debugging
3326 *
3327 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3328 * enum controls.
3329 */
3330#ifdef CONFIG_SND_DEBUG
3331static hda_nid_t alc880_test_dac_nids[4] = {
3332 0x02, 0x03, 0x04, 0x05
3333};
3334
3335static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003336 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003337 .items = {
3338 { "In-1", 0x0 },
3339 { "In-2", 0x1 },
3340 { "In-3", 0x2 },
3341 { "In-4", 0x3 },
3342 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003343 { "Front", 0x5 },
3344 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003345 },
3346};
3347
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003348static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003349 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003350 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003351 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003352 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003353};
3354
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003355static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3356 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003357{
3358 static char *texts[] = {
3359 "N/A", "Line Out", "HP Out",
3360 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3361 };
3362 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3363 uinfo->count = 1;
3364 uinfo->value.enumerated.items = 8;
3365 if (uinfo->value.enumerated.item >= 8)
3366 uinfo->value.enumerated.item = 7;
3367 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3368 return 0;
3369}
3370
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003371static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3372 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003373{
3374 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3375 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3376 unsigned int pin_ctl, item = 0;
3377
3378 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3379 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3380 if (pin_ctl & AC_PINCTL_OUT_EN) {
3381 if (pin_ctl & AC_PINCTL_HP_EN)
3382 item = 2;
3383 else
3384 item = 1;
3385 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3386 switch (pin_ctl & AC_PINCTL_VREFEN) {
3387 case AC_PINCTL_VREF_HIZ: item = 3; break;
3388 case AC_PINCTL_VREF_50: item = 4; break;
3389 case AC_PINCTL_VREF_GRD: item = 5; break;
3390 case AC_PINCTL_VREF_80: item = 6; break;
3391 case AC_PINCTL_VREF_100: item = 7; break;
3392 }
3393 }
3394 ucontrol->value.enumerated.item[0] = item;
3395 return 0;
3396}
3397
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003398static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3399 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003400{
3401 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3402 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3403 static unsigned int ctls[] = {
3404 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3405 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3406 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3407 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3408 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3409 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3410 };
3411 unsigned int old_ctl, new_ctl;
3412
3413 old_ctl = snd_hda_codec_read(codec, nid, 0,
3414 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3415 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3416 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003417 int val;
3418 snd_hda_codec_write_cache(codec, nid, 0,
3419 AC_VERB_SET_PIN_WIDGET_CONTROL,
3420 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003421 val = ucontrol->value.enumerated.item[0] >= 3 ?
3422 HDA_AMP_MUTE : 0;
3423 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3424 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003425 return 1;
3426 }
3427 return 0;
3428}
3429
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003430static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3431 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003432{
3433 static char *texts[] = {
3434 "Front", "Surround", "CLFE", "Side"
3435 };
3436 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3437 uinfo->count = 1;
3438 uinfo->value.enumerated.items = 4;
3439 if (uinfo->value.enumerated.item >= 4)
3440 uinfo->value.enumerated.item = 3;
3441 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3442 return 0;
3443}
3444
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003445static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3446 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003447{
3448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3449 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3450 unsigned int sel;
3451
3452 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3453 ucontrol->value.enumerated.item[0] = sel & 3;
3454 return 0;
3455}
3456
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003457static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3458 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003459{
3460 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3461 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3462 unsigned int sel;
3463
3464 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3465 if (ucontrol->value.enumerated.item[0] != sel) {
3466 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003467 snd_hda_codec_write_cache(codec, nid, 0,
3468 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003469 return 1;
3470 }
3471 return 0;
3472}
3473
3474#define PIN_CTL_TEST(xname,nid) { \
3475 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3476 .name = xname, \
3477 .info = alc_test_pin_ctl_info, \
3478 .get = alc_test_pin_ctl_get, \
3479 .put = alc_test_pin_ctl_put, \
3480 .private_value = nid \
3481 }
3482
3483#define PIN_SRC_TEST(xname,nid) { \
3484 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3485 .name = xname, \
3486 .info = alc_test_pin_src_info, \
3487 .get = alc_test_pin_src_get, \
3488 .put = alc_test_pin_src_put, \
3489 .private_value = nid \
3490 }
3491
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003492static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003493 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3494 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3495 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3496 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003497 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3498 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3499 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3500 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003501 PIN_CTL_TEST("Front Pin Mode", 0x14),
3502 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3503 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3504 PIN_CTL_TEST("Side Pin Mode", 0x17),
3505 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3506 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3507 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3508 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3509 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3510 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3511 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3512 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3513 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3514 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3515 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3516 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3517 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3518 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3519 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3520 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3521 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3522 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003523 {
3524 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3525 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003526 .info = alc_ch_mode_info,
3527 .get = alc_ch_mode_get,
3528 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003529 },
3530 { } /* end */
3531};
3532
3533static struct hda_verb alc880_test_init_verbs[] = {
3534 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003535 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3537 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3540 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3541 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3542 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003543 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3545 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3546 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3547 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003548 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003549 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3550 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3551 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3552 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003553 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003554 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3555 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3556 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3557 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003558 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003559 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3560 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003561 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3562 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3563 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003564 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003565 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3566 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3567 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3568 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003569 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003570 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003571 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003572 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003573 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003574 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003575 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003576 /* Analog input/passthru */
3577 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3578 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3579 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3580 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3581 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003582 { }
3583};
3584#endif
3585
Linus Torvalds1da177e2005-04-16 15:20:36 -07003586/*
3587 */
3588
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003589static const char *alc880_models[ALC880_MODEL_LAST] = {
3590 [ALC880_3ST] = "3stack",
3591 [ALC880_TCL_S700] = "tcl",
3592 [ALC880_3ST_DIG] = "3stack-digout",
3593 [ALC880_CLEVO] = "clevo",
3594 [ALC880_5ST] = "5stack",
3595 [ALC880_5ST_DIG] = "5stack-digout",
3596 [ALC880_W810] = "w810",
3597 [ALC880_Z71V] = "z71v",
3598 [ALC880_6ST] = "6stack",
3599 [ALC880_6ST_DIG] = "6stack-digout",
3600 [ALC880_ASUS] = "asus",
3601 [ALC880_ASUS_W1V] = "asus-w1v",
3602 [ALC880_ASUS_DIG] = "asus-dig",
3603 [ALC880_ASUS_DIG2] = "asus-dig2",
3604 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003605 [ALC880_UNIWILL_P53] = "uniwill-p53",
3606 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003607 [ALC880_F1734] = "F1734",
3608 [ALC880_LG] = "lg",
3609 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003610 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003611#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003612 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003613#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003614 [ALC880_AUTO] = "auto",
3615};
3616
3617static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003618 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003619 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3620 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3621 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3622 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3623 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3624 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3625 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3626 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003627 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3628 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003629 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3630 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3631 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3632 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3633 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3634 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3635 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3636 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3637 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3638 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003639 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003640 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3641 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3642 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003643 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003644 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003645 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3646 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003647 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3648 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003649 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3650 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3651 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3652 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003653 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3654 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003655 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003656 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003657 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003658 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003659 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3660 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003661 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003662 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003663 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003664 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003665 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003666 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003667 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003668 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003669 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003670 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3671 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003672 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003673 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3674 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3675 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3676 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003677 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3678 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003679 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003680 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003681 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3682 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003683 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3684 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3685 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003686 /* default Intel */
3687 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003688 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3689 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003690 {}
3691};
3692
Takashi Iwai16ded522005-06-10 19:58:24 +02003693/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003694 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003695 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003696static struct alc_config_preset alc880_presets[] = {
3697 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003698 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003699 .init_verbs = { alc880_volume_init_verbs,
3700 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003701 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003702 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003703 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3704 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003705 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003706 .input_mux = &alc880_capture_source,
3707 },
3708 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003709 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003710 .init_verbs = { alc880_volume_init_verbs,
3711 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003712 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003713 .dac_nids = alc880_dac_nids,
3714 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003715 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3716 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003717 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003718 .input_mux = &alc880_capture_source,
3719 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003720 [ALC880_TCL_S700] = {
3721 .mixers = { alc880_tcl_s700_mixer },
3722 .init_verbs = { alc880_volume_init_verbs,
3723 alc880_pin_tcl_S700_init_verbs,
3724 alc880_gpio2_init_verbs },
3725 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3726 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003727 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3728 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003729 .hp_nid = 0x03,
3730 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3731 .channel_mode = alc880_2_jack_modes,
3732 .input_mux = &alc880_capture_source,
3733 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003734 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003735 .mixers = { alc880_three_stack_mixer,
3736 alc880_five_stack_mixer},
3737 .init_verbs = { alc880_volume_init_verbs,
3738 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003739 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3740 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003741 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3742 .channel_mode = alc880_fivestack_modes,
3743 .input_mux = &alc880_capture_source,
3744 },
3745 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003746 .mixers = { alc880_three_stack_mixer,
3747 alc880_five_stack_mixer },
3748 .init_verbs = { alc880_volume_init_verbs,
3749 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003750 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3751 .dac_nids = alc880_dac_nids,
3752 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003753 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3754 .channel_mode = alc880_fivestack_modes,
3755 .input_mux = &alc880_capture_source,
3756 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003757 [ALC880_6ST] = {
3758 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003759 .init_verbs = { alc880_volume_init_verbs,
3760 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003761 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3762 .dac_nids = alc880_6st_dac_nids,
3763 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3764 .channel_mode = alc880_sixstack_modes,
3765 .input_mux = &alc880_6stack_capture_source,
3766 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003767 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003768 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003769 .init_verbs = { alc880_volume_init_verbs,
3770 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003771 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3772 .dac_nids = alc880_6st_dac_nids,
3773 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003774 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3775 .channel_mode = alc880_sixstack_modes,
3776 .input_mux = &alc880_6stack_capture_source,
3777 },
3778 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003779 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003780 .init_verbs = { alc880_volume_init_verbs,
3781 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003782 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003783 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3784 .dac_nids = alc880_w810_dac_nids,
3785 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003786 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3787 .channel_mode = alc880_w810_modes,
3788 .input_mux = &alc880_capture_source,
3789 },
3790 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003791 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003792 .init_verbs = { alc880_volume_init_verbs,
3793 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003794 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3795 .dac_nids = alc880_z71v_dac_nids,
3796 .dig_out_nid = ALC880_DIGOUT_NID,
3797 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003798 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3799 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003800 .input_mux = &alc880_capture_source,
3801 },
3802 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003803 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003804 .init_verbs = { alc880_volume_init_verbs,
3805 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003806 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3807 .dac_nids = alc880_f1734_dac_nids,
3808 .hp_nid = 0x02,
3809 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3810 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003811 .input_mux = &alc880_f1734_capture_source,
3812 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003813 .init_hook = alc880_uniwill_p53_init_hook,
Takashi Iwai16ded522005-06-10 19:58:24 +02003814 },
3815 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003816 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003817 .init_verbs = { alc880_volume_init_verbs,
3818 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003819 alc880_gpio1_init_verbs },
3820 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3821 .dac_nids = alc880_asus_dac_nids,
3822 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3823 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003824 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003825 .input_mux = &alc880_capture_source,
3826 },
3827 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003828 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003829 .init_verbs = { alc880_volume_init_verbs,
3830 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003831 alc880_gpio1_init_verbs },
3832 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3833 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003834 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003835 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3836 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003837 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003838 .input_mux = &alc880_capture_source,
3839 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003840 [ALC880_ASUS_DIG2] = {
3841 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003842 .init_verbs = { alc880_volume_init_verbs,
3843 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003844 alc880_gpio2_init_verbs }, /* use GPIO2 */
3845 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3846 .dac_nids = alc880_asus_dac_nids,
3847 .dig_out_nid = ALC880_DIGOUT_NID,
3848 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3849 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003850 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003851 .input_mux = &alc880_capture_source,
3852 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003853 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003854 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003855 .init_verbs = { alc880_volume_init_verbs,
3856 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003857 alc880_gpio1_init_verbs },
3858 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3859 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003860 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003861 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3862 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003863 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003864 .input_mux = &alc880_capture_source,
3865 },
3866 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003867 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003868 .init_verbs = { alc880_volume_init_verbs,
3869 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003870 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3871 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003872 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003873 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3874 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003875 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003876 .input_mux = &alc880_capture_source,
3877 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003878 [ALC880_UNIWILL] = {
3879 .mixers = { alc880_uniwill_mixer },
3880 .init_verbs = { alc880_volume_init_verbs,
3881 alc880_uniwill_init_verbs },
3882 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3883 .dac_nids = alc880_asus_dac_nids,
3884 .dig_out_nid = ALC880_DIGOUT_NID,
3885 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3886 .channel_mode = alc880_threestack_modes,
3887 .need_dac_fix = 1,
3888 .input_mux = &alc880_capture_source,
3889 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003890 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02003891 },
3892 [ALC880_UNIWILL_P53] = {
3893 .mixers = { alc880_uniwill_p53_mixer },
3894 .init_verbs = { alc880_volume_init_verbs,
3895 alc880_uniwill_p53_init_verbs },
3896 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3897 .dac_nids = alc880_asus_dac_nids,
3898 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003899 .channel_mode = alc880_threestack_modes,
3900 .input_mux = &alc880_capture_source,
3901 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003902 .init_hook = alc880_uniwill_p53_init_hook,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003903 },
3904 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003905 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003906 .init_verbs = { alc880_volume_init_verbs,
3907 alc880_uniwill_p53_init_verbs,
3908 alc880_beep_init_verbs },
3909 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3910 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003911 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003912 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3913 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003914 .input_mux = &alc880_capture_source,
3915 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003916 .init_hook = alc880_uniwill_p53_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02003917 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003918 [ALC880_CLEVO] = {
3919 .mixers = { alc880_three_stack_mixer },
3920 .init_verbs = { alc880_volume_init_verbs,
3921 alc880_pin_clevo_init_verbs },
3922 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3923 .dac_nids = alc880_dac_nids,
3924 .hp_nid = 0x03,
3925 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3926 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003927 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003928 .input_mux = &alc880_capture_source,
3929 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003930 [ALC880_LG] = {
3931 .mixers = { alc880_lg_mixer },
3932 .init_verbs = { alc880_volume_init_verbs,
3933 alc880_lg_init_verbs },
3934 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3935 .dac_nids = alc880_lg_dac_nids,
3936 .dig_out_nid = ALC880_DIGOUT_NID,
3937 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3938 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003939 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003940 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003941 .unsol_event = alc_automute_amp_unsol_event,
3942 .init_hook = alc880_lg_init_hook,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003943#ifdef CONFIG_SND_HDA_POWER_SAVE
3944 .loopbacks = alc880_lg_loopbacks,
3945#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003946 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003947 [ALC880_LG_LW] = {
3948 .mixers = { alc880_lg_lw_mixer },
3949 .init_verbs = { alc880_volume_init_verbs,
3950 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003951 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003952 .dac_nids = alc880_dac_nids,
3953 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003954 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3955 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003956 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003957 .unsol_event = alc_automute_amp_unsol_event,
3958 .init_hook = alc880_lg_lw_init_hook,
Takashi Iwaid6815182006-03-23 16:06:23 +01003959 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003960 [ALC880_MEDION_RIM] = {
3961 .mixers = { alc880_medion_rim_mixer },
3962 .init_verbs = { alc880_volume_init_verbs,
3963 alc880_medion_rim_init_verbs,
3964 alc_gpio2_init_verbs },
3965 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3966 .dac_nids = alc880_dac_nids,
3967 .dig_out_nid = ALC880_DIGOUT_NID,
3968 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3969 .channel_mode = alc880_2_jack_modes,
3970 .input_mux = &alc880_medion_rim_capture_source,
3971 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003972 .init_hook = alc880_medion_rim_init_hook,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003973 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003974#ifdef CONFIG_SND_DEBUG
3975 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003976 .mixers = { alc880_test_mixer },
3977 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003978 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3979 .dac_nids = alc880_test_dac_nids,
3980 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003981 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3982 .channel_mode = alc880_test_modes,
3983 .input_mux = &alc880_test_capture_source,
3984 },
3985#endif
3986};
3987
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003988/*
3989 * Automatic parse of I/O pins from the BIOS configuration
3990 */
3991
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003992enum {
3993 ALC_CTL_WIDGET_VOL,
3994 ALC_CTL_WIDGET_MUTE,
3995 ALC_CTL_BIND_MUTE,
3996};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003997static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003998 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3999 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004000 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004001};
4002
4003/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004004static int add_control(struct alc_spec *spec, int type, const char *name,
4005 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004006{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004007 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004008
Takashi Iwai603c4012008-07-30 15:01:44 +02004009 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4010 knew = snd_array_new(&spec->kctls);
4011 if (!knew)
4012 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004013 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004014 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004015 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004016 return -ENOMEM;
4017 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004018 return 0;
4019}
4020
4021#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4022#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4023#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4024#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4025#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4026#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4027#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4028#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4029#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4030#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4031#define ALC880_PIN_CD_NID 0x1c
4032
4033/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004034static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4035 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004036{
4037 hda_nid_t nid;
4038 int assigned[4];
4039 int i, j;
4040
4041 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004042 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004043
4044 /* check the pins hardwired to audio widget */
4045 for (i = 0; i < cfg->line_outs; i++) {
4046 nid = cfg->line_out_pins[i];
4047 if (alc880_is_fixed_pin(nid)) {
4048 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004049 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004050 assigned[idx] = 1;
4051 }
4052 }
4053 /* left pins can be connect to any audio widget */
4054 for (i = 0; i < cfg->line_outs; i++) {
4055 nid = cfg->line_out_pins[i];
4056 if (alc880_is_fixed_pin(nid))
4057 continue;
4058 /* search for an empty channel */
4059 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004060 if (!assigned[j]) {
4061 spec->multiout.dac_nids[i] =
4062 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004063 assigned[j] = 1;
4064 break;
4065 }
4066 }
4067 }
4068 spec->multiout.num_dacs = cfg->line_outs;
4069 return 0;
4070}
4071
4072/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004073static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4074 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004075{
4076 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004077 static const char *chname[4] = {
4078 "Front", "Surround", NULL /*CLFE*/, "Side"
4079 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004080 hda_nid_t nid;
4081 int i, err;
4082
4083 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004084 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004085 continue;
4086 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4087 if (i == 2) {
4088 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004089 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4090 "Center Playback Volume",
4091 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4092 HDA_OUTPUT));
4093 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004094 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004095 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4096 "LFE Playback Volume",
4097 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4098 HDA_OUTPUT));
4099 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004100 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004101 err = add_control(spec, ALC_CTL_BIND_MUTE,
4102 "Center Playback Switch",
4103 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4104 HDA_INPUT));
4105 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004106 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004107 err = add_control(spec, ALC_CTL_BIND_MUTE,
4108 "LFE Playback Switch",
4109 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4110 HDA_INPUT));
4111 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004112 return err;
4113 } else {
4114 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004115 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4116 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4117 HDA_OUTPUT));
4118 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004119 return err;
4120 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004121 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4122 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4123 HDA_INPUT));
4124 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004125 return err;
4126 }
4127 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004128 return 0;
4129}
4130
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004131/* add playback controls for speaker and HP outputs */
4132static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4133 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004134{
4135 hda_nid_t nid;
4136 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004137 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004138
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004139 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004140 return 0;
4141
4142 if (alc880_is_fixed_pin(pin)) {
4143 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004144 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004145 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004146 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004147 else
4148 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004149 /* control HP volume/switch on the output mixer amp */
4150 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004151 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004152 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4153 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4154 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004155 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004156 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004157 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4158 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4159 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004160 return err;
4161 } else if (alc880_is_multi_pin(pin)) {
4162 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004163 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004164 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004165 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4166 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4167 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004168 return err;
4169 }
4170 return 0;
4171}
4172
4173/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004174static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4175 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004176 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004177{
4178 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004179 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004180
4181 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004182 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4183 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4184 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004185 return err;
4186 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004187 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4188 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4189 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004190 return err;
4191 return 0;
4192}
4193
4194/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004195static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4196 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004197{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004198 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004199 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004200
4201 for (i = 0; i < AUTO_PIN_LAST; i++) {
4202 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004203 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004204 err = new_analog_input(spec, cfg->input_pins[i],
4205 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004206 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004207 if (err < 0)
4208 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004209 imux->items[imux->num_items].label =
4210 auto_pin_cfg_labels[i];
4211 imux->items[imux->num_items].index =
4212 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004213 imux->num_items++;
4214 }
4215 }
4216 return 0;
4217}
4218
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004219static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4220 unsigned int pin_type)
4221{
4222 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4223 pin_type);
4224 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004225 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4226 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004227}
4228
Kailang Yangdf694da2005-12-05 19:42:22 +01004229static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4230 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004231 int dac_idx)
4232{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004233 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004234 /* need the manual connection? */
4235 if (alc880_is_multi_pin(nid)) {
4236 struct alc_spec *spec = codec->spec;
4237 int idx = alc880_multi_pin_idx(nid);
4238 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4239 AC_VERB_SET_CONNECT_SEL,
4240 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4241 }
4242}
4243
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004244static int get_pin_type(int line_out_type)
4245{
4246 if (line_out_type == AUTO_PIN_HP_OUT)
4247 return PIN_HP;
4248 else
4249 return PIN_OUT;
4250}
4251
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004252static void alc880_auto_init_multi_out(struct hda_codec *codec)
4253{
4254 struct alc_spec *spec = codec->spec;
4255 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004256
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004257 for (i = 0; i < spec->autocfg.line_outs; i++) {
4258 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004259 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4260 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004261 }
4262}
4263
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004264static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004265{
4266 struct alc_spec *spec = codec->spec;
4267 hda_nid_t pin;
4268
Takashi Iwai82bc9552006-03-21 11:24:42 +01004269 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004270 if (pin) /* connect to front */
4271 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004272 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004273 if (pin) /* connect to front */
4274 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4275}
4276
4277static void alc880_auto_init_analog_input(struct hda_codec *codec)
4278{
4279 struct alc_spec *spec = codec->spec;
4280 int i;
4281
4282 for (i = 0; i < AUTO_PIN_LAST; i++) {
4283 hda_nid_t nid = spec->autocfg.input_pins[i];
4284 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004285 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004286 if (nid != ALC880_PIN_CD_NID &&
4287 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004288 snd_hda_codec_write(codec, nid, 0,
4289 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004290 AMP_OUT_MUTE);
4291 }
4292 }
4293}
4294
4295/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004296/* return 1 if successful, 0 if the proper config is not found,
4297 * or a negative error code
4298 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004299static int alc880_parse_auto_config(struct hda_codec *codec)
4300{
4301 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004302 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004303 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004304
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004305 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4306 alc880_ignore);
4307 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004308 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004309 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004310 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004311
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004312 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4313 if (err < 0)
4314 return err;
4315 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4316 if (err < 0)
4317 return err;
4318 err = alc880_auto_create_extra_out(spec,
4319 spec->autocfg.speaker_pins[0],
4320 "Speaker");
4321 if (err < 0)
4322 return err;
4323 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4324 "Headphone");
4325 if (err < 0)
4326 return err;
4327 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4328 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004329 return err;
4330
4331 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4332
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004333 /* check multiple SPDIF-out (for recent codecs) */
4334 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4335 hda_nid_t dig_nid;
4336 err = snd_hda_get_connections(codec,
4337 spec->autocfg.dig_out_pins[i],
4338 &dig_nid, 1);
4339 if (err < 0)
4340 continue;
4341 if (!i)
4342 spec->multiout.dig_out_nid = dig_nid;
4343 else {
4344 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4345 spec->slave_dig_outs[i - 1] = dig_nid;
4346 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4347 break;
4348 }
4349 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004350 if (spec->autocfg.dig_in_pin)
4351 spec->dig_in_nid = ALC880_DIGIN_NID;
4352
Takashi Iwai603c4012008-07-30 15:01:44 +02004353 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004354 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004355
Takashi Iwaid88897e2008-10-31 15:01:37 +01004356 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004357
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004358 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004359 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004360
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004361 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4362
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004363 return 1;
4364}
4365
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004366/* additional initialization for auto-configuration model */
4367static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004368{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004369 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004370 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004371 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004372 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004373 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004374 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004375}
4376
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004377static void set_capture_mixer(struct alc_spec *spec)
4378{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004379 static struct snd_kcontrol_new *caps[2][3] = {
4380 { alc_capture_mixer_nosrc1,
4381 alc_capture_mixer_nosrc2,
4382 alc_capture_mixer_nosrc3 },
4383 { alc_capture_mixer1,
4384 alc_capture_mixer2,
4385 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004386 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004387 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4388 int mux;
4389 if (spec->input_mux && spec->input_mux->num_items > 1)
4390 mux = 1;
4391 else
4392 mux = 0;
4393 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4394 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004395}
4396
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004397#define set_beep_amp(spec, nid, idx, dir) \
4398 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4399
4400/*
4401 * OK, here we have finally the patch for ALC880
4402 */
4403
Linus Torvalds1da177e2005-04-16 15:20:36 -07004404static int patch_alc880(struct hda_codec *codec)
4405{
4406 struct alc_spec *spec;
4407 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004408 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004409
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004410 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004411 if (spec == NULL)
4412 return -ENOMEM;
4413
4414 codec->spec = spec;
4415
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004416 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4417 alc880_models,
4418 alc880_cfg_tbl);
4419 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02004420 printk(KERN_INFO "hda_codec: Unknown model for %s, "
4421 "trying auto-probe from BIOS...\n", codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004422 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004423 }
4424
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004425 if (board_config == ALC880_AUTO) {
4426 /* automatic parse from the BIOS config */
4427 err = alc880_parse_auto_config(codec);
4428 if (err < 0) {
4429 alc_free(codec);
4430 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004431 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004432 printk(KERN_INFO
4433 "hda_codec: Cannot set up configuration "
4434 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004435 board_config = ALC880_3ST;
4436 }
4437 }
4438
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004439 err = snd_hda_attach_beep_device(codec, 0x1);
4440 if (err < 0) {
4441 alc_free(codec);
4442 return err;
4443 }
4444
Kailang Yangdf694da2005-12-05 19:42:22 +01004445 if (board_config != ALC880_AUTO)
4446 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004447
Linus Torvalds1da177e2005-04-16 15:20:36 -07004448 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4449 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004450 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004451
Linus Torvalds1da177e2005-04-16 15:20:36 -07004452 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4453 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4454
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004455 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004456 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004457 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004458 /* get type */
4459 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004460 if (wcap != AC_WID_AUD_IN) {
4461 spec->adc_nids = alc880_adc_nids_alt;
4462 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004463 } else {
4464 spec->adc_nids = alc880_adc_nids;
4465 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004466 }
4467 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004468 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004469 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004470
Takashi Iwai2134ea42008-01-10 16:53:55 +01004471 spec->vmaster_nid = 0x0c;
4472
Linus Torvalds1da177e2005-04-16 15:20:36 -07004473 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004474 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004475 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004476#ifdef CONFIG_SND_HDA_POWER_SAVE
4477 if (!spec->loopback.amplist)
4478 spec->loopback.amplist = alc880_loopbacks;
4479#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004480 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004481
4482 return 0;
4483}
4484
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004485
Linus Torvalds1da177e2005-04-16 15:20:36 -07004486/*
4487 * ALC260 support
4488 */
4489
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004490static hda_nid_t alc260_dac_nids[1] = {
4491 /* front */
4492 0x02,
4493};
4494
4495static hda_nid_t alc260_adc_nids[1] = {
4496 /* ADC0 */
4497 0x04,
4498};
4499
Kailang Yangdf694da2005-12-05 19:42:22 +01004500static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004501 /* ADC1 */
4502 0x05,
4503};
4504
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004505/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4506 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4507 */
4508static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004509 /* ADC0, ADC1 */
4510 0x04, 0x05
4511};
4512
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004513#define ALC260_DIGOUT_NID 0x03
4514#define ALC260_DIGIN_NID 0x06
4515
4516static struct hda_input_mux alc260_capture_source = {
4517 .num_items = 4,
4518 .items = {
4519 { "Mic", 0x0 },
4520 { "Front Mic", 0x1 },
4521 { "Line", 0x2 },
4522 { "CD", 0x4 },
4523 },
4524};
4525
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004526/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004527 * headphone jack and the internal CD lines since these are the only pins at
4528 * which audio can appear. For flexibility, also allow the option of
4529 * recording the mixer output on the second ADC (ADC0 doesn't have a
4530 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004531 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004532static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4533 {
4534 .num_items = 3,
4535 .items = {
4536 { "Mic/Line", 0x0 },
4537 { "CD", 0x4 },
4538 { "Headphone", 0x2 },
4539 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004540 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004541 {
4542 .num_items = 4,
4543 .items = {
4544 { "Mic/Line", 0x0 },
4545 { "CD", 0x4 },
4546 { "Headphone", 0x2 },
4547 { "Mixer", 0x5 },
4548 },
4549 },
4550
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004551};
4552
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004553/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4554 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004555 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004556static struct hda_input_mux alc260_acer_capture_sources[2] = {
4557 {
4558 .num_items = 4,
4559 .items = {
4560 { "Mic", 0x0 },
4561 { "Line", 0x2 },
4562 { "CD", 0x4 },
4563 { "Headphone", 0x5 },
4564 },
4565 },
4566 {
4567 .num_items = 5,
4568 .items = {
4569 { "Mic", 0x0 },
4570 { "Line", 0x2 },
4571 { "CD", 0x4 },
4572 { "Headphone", 0x6 },
4573 { "Mixer", 0x5 },
4574 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004575 },
4576};
Michael Schwingencc959482009-02-22 18:58:45 +01004577
4578/* Maxdata Favorit 100XS */
4579static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4580 {
4581 .num_items = 2,
4582 .items = {
4583 { "Line/Mic", 0x0 },
4584 { "CD", 0x4 },
4585 },
4586 },
4587 {
4588 .num_items = 3,
4589 .items = {
4590 { "Line/Mic", 0x0 },
4591 { "CD", 0x4 },
4592 { "Mixer", 0x5 },
4593 },
4594 },
4595};
4596
Linus Torvalds1da177e2005-04-16 15:20:36 -07004597/*
4598 * This is just place-holder, so there's something for alc_build_pcms to look
4599 * at when it calculates the maximum number of channels. ALC260 has no mixer
4600 * element which allows changing the channel mode, so the verb list is
4601 * never used.
4602 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004603static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004604 { 2, NULL },
4605};
4606
Kailang Yangdf694da2005-12-05 19:42:22 +01004607
4608/* Mixer combinations
4609 *
4610 * basic: base_output + input + pc_beep + capture
4611 * HP: base_output + input + capture_alt
4612 * HP_3013: hp_3013 + input + capture
4613 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004614 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004615 */
4616
4617static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004618 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004619 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004620 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4621 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4622 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4623 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4624 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004625};
Kailang Yangdf694da2005-12-05 19:42:22 +01004626
4627static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004628 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4629 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4630 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4631 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4633 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4634 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4635 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004636 { } /* end */
4637};
4638
Takashi Iwaibec15c32008-01-28 18:16:30 +01004639/* update HP, line and mono out pins according to the master switch */
4640static void alc260_hp_master_update(struct hda_codec *codec,
4641 hda_nid_t hp, hda_nid_t line,
4642 hda_nid_t mono)
4643{
4644 struct alc_spec *spec = codec->spec;
4645 unsigned int val = spec->master_sw ? PIN_HP : 0;
4646 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004647 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004648 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004649 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004650 val);
4651 /* mono (speaker) depending on the HP jack sense */
4652 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004653 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004654 val);
4655}
4656
4657static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4658 struct snd_ctl_elem_value *ucontrol)
4659{
4660 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4661 struct alc_spec *spec = codec->spec;
4662 *ucontrol->value.integer.value = spec->master_sw;
4663 return 0;
4664}
4665
4666static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4667 struct snd_ctl_elem_value *ucontrol)
4668{
4669 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4670 struct alc_spec *spec = codec->spec;
4671 int val = !!*ucontrol->value.integer.value;
4672 hda_nid_t hp, line, mono;
4673
4674 if (val == spec->master_sw)
4675 return 0;
4676 spec->master_sw = val;
4677 hp = (kcontrol->private_value >> 16) & 0xff;
4678 line = (kcontrol->private_value >> 8) & 0xff;
4679 mono = kcontrol->private_value & 0xff;
4680 alc260_hp_master_update(codec, hp, line, mono);
4681 return 1;
4682}
4683
4684static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4685 {
4686 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4687 .name = "Master Playback Switch",
4688 .info = snd_ctl_boolean_mono_info,
4689 .get = alc260_hp_master_sw_get,
4690 .put = alc260_hp_master_sw_put,
4691 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4692 },
4693 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4694 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4695 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4696 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4697 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4698 HDA_OUTPUT),
4699 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4700 { } /* end */
4701};
4702
4703static struct hda_verb alc260_hp_unsol_verbs[] = {
4704 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4705 {},
4706};
4707
4708static void alc260_hp_automute(struct hda_codec *codec)
4709{
4710 struct alc_spec *spec = codec->spec;
4711 unsigned int present;
4712
4713 present = snd_hda_codec_read(codec, 0x10, 0,
4714 AC_VERB_GET_PIN_SENSE, 0);
4715 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4716 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4717}
4718
4719static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4720{
4721 if ((res >> 26) == ALC880_HP_EVENT)
4722 alc260_hp_automute(codec);
4723}
4724
Kailang Yangdf694da2005-12-05 19:42:22 +01004725static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004726 {
4727 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4728 .name = "Master Playback Switch",
4729 .info = snd_ctl_boolean_mono_info,
4730 .get = alc260_hp_master_sw_get,
4731 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004732 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004733 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004734 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4735 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4736 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4737 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4738 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4739 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004740 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4741 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004742 { } /* end */
4743};
4744
Kailang Yang3f878302008-08-26 13:02:23 +02004745static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4746 .ops = &snd_hda_bind_vol,
4747 .values = {
4748 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4749 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4750 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4751 0
4752 },
4753};
4754
4755static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4756 .ops = &snd_hda_bind_sw,
4757 .values = {
4758 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4759 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4760 0
4761 },
4762};
4763
4764static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4765 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4766 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4767 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4768 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4769 { } /* end */
4770};
4771
Takashi Iwaibec15c32008-01-28 18:16:30 +01004772static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4773 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4774 {},
4775};
4776
4777static void alc260_hp_3013_automute(struct hda_codec *codec)
4778{
4779 struct alc_spec *spec = codec->spec;
4780 unsigned int present;
4781
4782 present = snd_hda_codec_read(codec, 0x15, 0,
4783 AC_VERB_GET_PIN_SENSE, 0);
4784 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004785 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004786}
4787
4788static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4789 unsigned int res)
4790{
4791 if ((res >> 26) == ALC880_HP_EVENT)
4792 alc260_hp_3013_automute(codec);
4793}
4794
Kailang Yang3f878302008-08-26 13:02:23 +02004795static void alc260_hp_3012_automute(struct hda_codec *codec)
4796{
4797 unsigned int present, bits;
4798
4799 present = snd_hda_codec_read(codec, 0x10, 0,
4800 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4801
4802 bits = present ? 0 : PIN_OUT;
4803 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4804 bits);
4805 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4806 bits);
4807 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4808 bits);
4809}
4810
4811static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4812 unsigned int res)
4813{
4814 if ((res >> 26) == ALC880_HP_EVENT)
4815 alc260_hp_3012_automute(codec);
4816}
4817
4818/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004819 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4820 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004821static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004822 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004823 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004824 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004825 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4826 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4827 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4828 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004829 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004830 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4831 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004832 { } /* end */
4833};
4834
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004835/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4836 * versions of the ALC260 don't act on requests to enable mic bias from NID
4837 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4838 * datasheet doesn't mention this restriction. At this stage it's not clear
4839 * whether this behaviour is intentional or is a hardware bug in chip
4840 * revisions available in early 2006. Therefore for now allow the
4841 * "Headphone Jack Mode" control to span all choices, but if it turns out
4842 * that the lack of mic bias for this NID is intentional we could change the
4843 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4844 *
4845 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4846 * don't appear to make the mic bias available from the "line" jack, even
4847 * though the NID used for this jack (0x14) can supply it. The theory is
4848 * that perhaps Acer have included blocking capacitors between the ALC260
4849 * and the output jack. If this turns out to be the case for all such
4850 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4851 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004852 *
4853 * The C20x Tablet series have a mono internal speaker which is controlled
4854 * via the chip's Mono sum widget and pin complex, so include the necessary
4855 * controls for such models. On models without a "mono speaker" the control
4856 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004857 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004858static struct snd_kcontrol_new alc260_acer_mixer[] = {
4859 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4860 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004861 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004862 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004863 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004864 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004865 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004866 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4867 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4868 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4869 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4870 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4871 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4872 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4873 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004874 { } /* end */
4875};
4876
Michael Schwingencc959482009-02-22 18:58:45 +01004877/* Maxdata Favorit 100XS: one output and one input (0x12) jack
4878 */
4879static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
4880 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4881 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4882 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4883 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4884 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4885 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4886 { } /* end */
4887};
4888
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004889/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4890 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4891 */
4892static struct snd_kcontrol_new alc260_will_mixer[] = {
4893 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4894 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4895 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4896 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4897 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4898 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4899 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4900 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4901 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4902 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004903 { } /* end */
4904};
4905
4906/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4907 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4908 */
4909static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4910 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4911 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4913 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4914 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4915 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4916 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4917 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4918 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4919 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4920 { } /* end */
4921};
4922
Kailang Yangdf694da2005-12-05 19:42:22 +01004923/*
4924 * initialization verbs
4925 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004926static struct hda_verb alc260_init_verbs[] = {
4927 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004928 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004929 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004930 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004931 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004932 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004933 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004934 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004935 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004936 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004937 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004938 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004939 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004940 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004941 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004942 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004943 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004944 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4945 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004946 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004947 /* set connection select to line in (default select for this ADC) */
4948 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004949 /* mute capture amp left and right */
4950 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4951 /* set connection select to line in (default select for this ADC) */
4952 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004953 /* set vol=0 Line-Out mixer amp left and right */
4954 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4955 /* unmute pin widget amp left and right (no gain on this amp) */
4956 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4957 /* set vol=0 HP mixer amp left and right */
4958 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4959 /* unmute pin widget amp left and right (no gain on this amp) */
4960 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4961 /* set vol=0 Mono mixer amp left and right */
4962 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4963 /* unmute pin widget amp left and right (no gain on this amp) */
4964 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4965 /* unmute LINE-2 out pin */
4966 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004967 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4968 * Line In 2 = 0x03
4969 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004970 /* mute analog inputs */
4971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4972 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4974 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4975 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004976 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004977 /* mute Front out path */
4978 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4979 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4980 /* mute Headphone out path */
4981 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4982 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4983 /* mute Mono out path */
4984 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4985 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004986 { }
4987};
4988
Takashi Iwai474167d2006-05-17 17:17:43 +02004989#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004990static struct hda_verb alc260_hp_init_verbs[] = {
4991 /* Headphone and output */
4992 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4993 /* mono output */
4994 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4995 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4996 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4997 /* Mic2 (front panel) pin widget for input and vref at 80% */
4998 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4999 /* Line In pin widget for input */
5000 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5001 /* Line-2 pin widget for output */
5002 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5003 /* CD pin widget for input */
5004 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5005 /* unmute amp left and right */
5006 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5007 /* set connection select to line in (default select for this ADC) */
5008 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5009 /* unmute Line-Out mixer amp left and right (volume = 0) */
5010 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5011 /* mute pin widget amp left and right (no gain on this amp) */
5012 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5013 /* unmute HP mixer amp left and right (volume = 0) */
5014 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5015 /* mute pin widget amp left and right (no gain on this amp) */
5016 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005017 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5018 * Line In 2 = 0x03
5019 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005020 /* mute analog inputs */
5021 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5022 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5025 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005026 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5027 /* Unmute Front out path */
5028 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5029 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5030 /* Unmute Headphone out path */
5031 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5032 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5033 /* Unmute Mono out path */
5034 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5035 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5036 { }
5037};
Takashi Iwai474167d2006-05-17 17:17:43 +02005038#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005039
5040static struct hda_verb alc260_hp_3013_init_verbs[] = {
5041 /* Line out and output */
5042 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5043 /* mono output */
5044 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5045 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5046 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5047 /* Mic2 (front panel) pin widget for input and vref at 80% */
5048 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5049 /* Line In pin widget for input */
5050 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5051 /* Headphone pin widget for output */
5052 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5053 /* CD pin widget for input */
5054 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5055 /* unmute amp left and right */
5056 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5057 /* set connection select to line in (default select for this ADC) */
5058 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5059 /* unmute Line-Out mixer amp left and right (volume = 0) */
5060 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5061 /* mute pin widget amp left and right (no gain on this amp) */
5062 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5063 /* unmute HP mixer amp left and right (volume = 0) */
5064 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5065 /* mute pin widget amp left and right (no gain on this amp) */
5066 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005067 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5068 * Line In 2 = 0x03
5069 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005070 /* mute analog inputs */
5071 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5072 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5073 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5074 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5075 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005076 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5077 /* Unmute Front out path */
5078 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5079 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5080 /* Unmute Headphone out path */
5081 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5082 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5083 /* Unmute Mono out path */
5084 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5085 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5086 { }
5087};
5088
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005089/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005090 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5091 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005092 */
5093static struct hda_verb alc260_fujitsu_init_verbs[] = {
5094 /* Disable all GPIOs */
5095 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5096 /* Internal speaker is connected to headphone pin */
5097 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5098 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5099 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005100 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5101 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5102 /* Ensure all other unused pins are disabled and muted. */
5103 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5104 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005105 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005106 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005107 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005108 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5109 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5110 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005111
Jonathan Woithef7ace402006-02-28 11:46:14 +01005112 /* Disable digital (SPDIF) pins */
5113 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5114 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005115
Kailang Yangea1fb292008-08-26 12:58:38 +02005116 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005117 * when acting as an output.
5118 */
5119 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5120
5121 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005122 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5123 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5124 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5125 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5126 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5127 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5128 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5129 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5130 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005131
Jonathan Woithef7ace402006-02-28 11:46:14 +01005132 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5133 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5134 /* Unmute Line1 pin widget output buffer since it starts as an output.
5135 * If the pin mode is changed by the user the pin mode control will
5136 * take care of enabling the pin's input/output buffers as needed.
5137 * Therefore there's no need to enable the input buffer at this
5138 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005139 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005140 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005141 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005142 * mixer ctrl)
5143 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005144 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005145
Jonathan Woithef7ace402006-02-28 11:46:14 +01005146 /* Mute capture amp left and right */
5147 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005148 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005149 * in (on mic1 pin)
5150 */
5151 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005152
Jonathan Woithef7ace402006-02-28 11:46:14 +01005153 /* Do the same for the second ADC: mute capture input amp and
5154 * set ADC connection to line in (on mic1 pin)
5155 */
5156 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5157 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005158
Jonathan Woithef7ace402006-02-28 11:46:14 +01005159 /* Mute all inputs to mixer widget (even unconnected ones) */
5160 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5161 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5162 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5163 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5164 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5165 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5166 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5167 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005168
5169 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005170};
5171
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005172/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5173 * similar laptops (adapted from Fujitsu init verbs).
5174 */
5175static struct hda_verb alc260_acer_init_verbs[] = {
5176 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5177 * the headphone jack. Turn this on and rely on the standard mute
5178 * methods whenever the user wants to turn these outputs off.
5179 */
5180 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5181 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5182 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5183 /* Internal speaker/Headphone jack is connected to Line-out pin */
5184 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5185 /* Internal microphone/Mic jack is connected to Mic1 pin */
5186 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5187 /* Line In jack is connected to Line1 pin */
5188 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005189 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5190 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005191 /* Ensure all other unused pins are disabled and muted. */
5192 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5193 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005194 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5195 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5196 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5197 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5198 /* Disable digital (SPDIF) pins */
5199 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5200 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5201
Kailang Yangea1fb292008-08-26 12:58:38 +02005202 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005203 * bus when acting as outputs.
5204 */
5205 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5206 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5207
5208 /* Start with output sum widgets muted and their output gains at min */
5209 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5210 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5211 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5212 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5213 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5214 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5215 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5216 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5217 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5218
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005219 /* Unmute Line-out pin widget amp left and right
5220 * (no equiv mixer ctrl)
5221 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005222 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005223 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5224 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005225 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5226 * inputs. If the pin mode is changed by the user the pin mode control
5227 * will take care of enabling the pin's input/output buffers as needed.
5228 * Therefore there's no need to enable the input buffer at this
5229 * stage.
5230 */
5231 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5232 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5233
5234 /* Mute capture amp left and right */
5235 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5236 /* Set ADC connection select to match default mixer setting - mic
5237 * (on mic1 pin)
5238 */
5239 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5240
5241 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005242 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005243 */
5244 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005245 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005246
5247 /* Mute all inputs to mixer widget (even unconnected ones) */
5248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5252 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5253 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5254 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5255 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5256
5257 { }
5258};
5259
Michael Schwingencc959482009-02-22 18:58:45 +01005260/* Initialisation sequence for Maxdata Favorit 100XS
5261 * (adapted from Acer init verbs).
5262 */
5263static struct hda_verb alc260_favorit100_init_verbs[] = {
5264 /* GPIO 0 enables the output jack.
5265 * Turn this on and rely on the standard mute
5266 * methods whenever the user wants to turn these outputs off.
5267 */
5268 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5269 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5270 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5271 /* Line/Mic input jack is connected to Mic1 pin */
5272 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5273 /* Ensure all other unused pins are disabled and muted. */
5274 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5275 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5276 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5277 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5278 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5279 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5280 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5281 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5283 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5284 /* Disable digital (SPDIF) pins */
5285 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5286 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5287
5288 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5289 * bus when acting as outputs.
5290 */
5291 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5292 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5293
5294 /* Start with output sum widgets muted and their output gains at min */
5295 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5296 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5297 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5298 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5299 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5300 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5301 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5302 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5303 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5304
5305 /* Unmute Line-out pin widget amp left and right
5306 * (no equiv mixer ctrl)
5307 */
5308 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5309 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5310 * inputs. If the pin mode is changed by the user the pin mode control
5311 * will take care of enabling the pin's input/output buffers as needed.
5312 * Therefore there's no need to enable the input buffer at this
5313 * stage.
5314 */
5315 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5316
5317 /* Mute capture amp left and right */
5318 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5319 /* Set ADC connection select to match default mixer setting - mic
5320 * (on mic1 pin)
5321 */
5322 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5323
5324 /* Do similar with the second ADC: mute capture input amp and
5325 * set ADC connection to mic to match ALSA's default state.
5326 */
5327 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5328 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5329
5330 /* Mute all inputs to mixer widget (even unconnected ones) */
5331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5335 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5336 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5337 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5338 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5339
5340 { }
5341};
5342
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005343static struct hda_verb alc260_will_verbs[] = {
5344 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5345 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5346 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5347 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5348 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5349 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5350 {}
5351};
5352
5353static struct hda_verb alc260_replacer_672v_verbs[] = {
5354 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5355 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5356 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5357
5358 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5359 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5360 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5361
5362 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5363 {}
5364};
5365
5366/* toggle speaker-output according to the hp-jack state */
5367static void alc260_replacer_672v_automute(struct hda_codec *codec)
5368{
5369 unsigned int present;
5370
5371 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5372 present = snd_hda_codec_read(codec, 0x0f, 0,
5373 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5374 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005375 snd_hda_codec_write_cache(codec, 0x01, 0,
5376 AC_VERB_SET_GPIO_DATA, 1);
5377 snd_hda_codec_write_cache(codec, 0x0f, 0,
5378 AC_VERB_SET_PIN_WIDGET_CONTROL,
5379 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005380 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005381 snd_hda_codec_write_cache(codec, 0x01, 0,
5382 AC_VERB_SET_GPIO_DATA, 0);
5383 snd_hda_codec_write_cache(codec, 0x0f, 0,
5384 AC_VERB_SET_PIN_WIDGET_CONTROL,
5385 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005386 }
5387}
5388
5389static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5390 unsigned int res)
5391{
5392 if ((res >> 26) == ALC880_HP_EVENT)
5393 alc260_replacer_672v_automute(codec);
5394}
5395
Kailang Yang3f878302008-08-26 13:02:23 +02005396static struct hda_verb alc260_hp_dc7600_verbs[] = {
5397 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5398 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5399 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5400 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5401 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5402 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5403 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5404 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5405 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5406 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5407 {}
5408};
5409
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005410/* Test configuration for debugging, modelled after the ALC880 test
5411 * configuration.
5412 */
5413#ifdef CONFIG_SND_DEBUG
5414static hda_nid_t alc260_test_dac_nids[1] = {
5415 0x02,
5416};
5417static hda_nid_t alc260_test_adc_nids[2] = {
5418 0x04, 0x05,
5419};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005420/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005421 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005422 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005423 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005424static struct hda_input_mux alc260_test_capture_sources[2] = {
5425 {
5426 .num_items = 7,
5427 .items = {
5428 { "MIC1 pin", 0x0 },
5429 { "MIC2 pin", 0x1 },
5430 { "LINE1 pin", 0x2 },
5431 { "LINE2 pin", 0x3 },
5432 { "CD pin", 0x4 },
5433 { "LINE-OUT pin", 0x5 },
5434 { "HP-OUT pin", 0x6 },
5435 },
5436 },
5437 {
5438 .num_items = 8,
5439 .items = {
5440 { "MIC1 pin", 0x0 },
5441 { "MIC2 pin", 0x1 },
5442 { "LINE1 pin", 0x2 },
5443 { "LINE2 pin", 0x3 },
5444 { "CD pin", 0x4 },
5445 { "Mixer", 0x5 },
5446 { "LINE-OUT pin", 0x6 },
5447 { "HP-OUT pin", 0x7 },
5448 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005449 },
5450};
5451static struct snd_kcontrol_new alc260_test_mixer[] = {
5452 /* Output driver widgets */
5453 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5454 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5455 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5456 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5457 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5458 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5459
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005460 /* Modes for retasking pin widgets
5461 * Note: the ALC260 doesn't seem to act on requests to enable mic
5462 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5463 * mention this restriction. At this stage it's not clear whether
5464 * this behaviour is intentional or is a hardware bug in chip
5465 * revisions available at least up until early 2006. Therefore for
5466 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5467 * choices, but if it turns out that the lack of mic bias for these
5468 * NIDs is intentional we could change their modes from
5469 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5470 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005471 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5472 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5473 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5474 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5475 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5476 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5477
5478 /* Loopback mixer controls */
5479 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5480 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5481 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5482 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5483 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5484 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5485 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5486 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5487 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5488 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005489 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5490 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5491 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5492 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005493
5494 /* Controls for GPIO pins, assuming they are configured as outputs */
5495 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5496 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5497 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5498 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5499
Jonathan Woithe92621f12006-02-28 11:47:47 +01005500 /* Switches to allow the digital IO pins to be enabled. The datasheet
5501 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005502 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005503 */
5504 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5505 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5506
Jonathan Woithef8225f62008-01-08 12:16:54 +01005507 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5508 * this output to turn on an external amplifier.
5509 */
5510 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5511 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5512
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005513 { } /* end */
5514};
5515static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005516 /* Enable all GPIOs as outputs with an initial value of 0 */
5517 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5518 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5519 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5520
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005521 /* Enable retasking pins as output, initially without power amp */
5522 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5523 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5524 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5525 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5526 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5527 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5528
Jonathan Woithe92621f12006-02-28 11:47:47 +01005529 /* Disable digital (SPDIF) pins initially, but users can enable
5530 * them via a mixer switch. In the case of SPDIF-out, this initverb
5531 * payload also sets the generation to 0, output to be in "consumer"
5532 * PCM format, copyright asserted, no pre-emphasis and no validity
5533 * control.
5534 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005535 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5536 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5537
Kailang Yangea1fb292008-08-26 12:58:38 +02005538 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005539 * OUT1 sum bus when acting as an output.
5540 */
5541 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5542 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5543 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5544 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5545
5546 /* Start with output sum widgets muted and their output gains at min */
5547 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5548 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5549 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5550 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5551 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5552 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5553 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5554 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5555 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5556
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005557 /* Unmute retasking pin widget output buffers since the default
5558 * state appears to be output. As the pin mode is changed by the
5559 * user the pin mode control will take care of enabling the pin's
5560 * input/output buffers as needed.
5561 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005562 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5563 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5564 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5565 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5566 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5567 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5568 /* Also unmute the mono-out pin widget */
5569 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5570
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005571 /* Mute capture amp left and right */
5572 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005573 /* Set ADC connection select to match default mixer setting (mic1
5574 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005575 */
5576 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5577
5578 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005579 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005580 */
5581 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5582 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5583
5584 /* Mute all inputs to mixer widget (even unconnected ones) */
5585 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5586 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5587 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5588 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5589 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5590 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5591 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5592 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5593
5594 { }
5595};
5596#endif
5597
Takashi Iwai63300792008-01-24 15:31:36 +01005598#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5599#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005600
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005601#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5602#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5603
Kailang Yangdf694da2005-12-05 19:42:22 +01005604/*
5605 * for BIOS auto-configuration
5606 */
5607
5608static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005609 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005610{
5611 hda_nid_t nid_vol;
5612 unsigned long vol_val, sw_val;
5613 char name[32];
5614 int err;
5615
5616 if (nid >= 0x0f && nid < 0x11) {
5617 nid_vol = nid - 0x7;
5618 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5619 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5620 } else if (nid == 0x11) {
5621 nid_vol = nid - 0x7;
5622 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5623 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5624 } else if (nid >= 0x12 && nid <= 0x15) {
5625 nid_vol = 0x08;
5626 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5627 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5628 } else
5629 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005630
Takashi Iwai863b4512008-10-21 17:01:47 +02005631 if (!(*vol_bits & (1 << nid_vol))) {
5632 /* first control for the volume widget */
5633 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5634 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5635 if (err < 0)
5636 return err;
5637 *vol_bits |= (1 << nid_vol);
5638 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005639 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005640 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5641 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005642 return err;
5643 return 1;
5644}
5645
5646/* add playback controls from the parsed DAC table */
5647static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5648 const struct auto_pin_cfg *cfg)
5649{
5650 hda_nid_t nid;
5651 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005652 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005653
5654 spec->multiout.num_dacs = 1;
5655 spec->multiout.dac_nids = spec->private_dac_nids;
5656 spec->multiout.dac_nids[0] = 0x02;
5657
5658 nid = cfg->line_out_pins[0];
5659 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005660 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005661 if (err < 0)
5662 return err;
5663 }
5664
Takashi Iwai82bc9552006-03-21 11:24:42 +01005665 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005666 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005667 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005668 if (err < 0)
5669 return err;
5670 }
5671
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005672 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005673 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005674 err = alc260_add_playback_controls(spec, nid, "Headphone",
5675 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005676 if (err < 0)
5677 return err;
5678 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005679 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005680}
5681
5682/* create playback/capture controls for input pins */
5683static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5684 const struct auto_pin_cfg *cfg)
5685{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005686 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005687 int i, err, idx;
5688
5689 for (i = 0; i < AUTO_PIN_LAST; i++) {
5690 if (cfg->input_pins[i] >= 0x12) {
5691 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005692 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005693 auto_pin_cfg_labels[i], idx,
5694 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005695 if (err < 0)
5696 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005697 imux->items[imux->num_items].label =
5698 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005699 imux->items[imux->num_items].index = idx;
5700 imux->num_items++;
5701 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005702 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005703 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005704 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005705 auto_pin_cfg_labels[i], idx,
5706 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005707 if (err < 0)
5708 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005709 imux->items[imux->num_items].label =
5710 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005711 imux->items[imux->num_items].index = idx;
5712 imux->num_items++;
5713 }
5714 }
5715 return 0;
5716}
5717
5718static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5719 hda_nid_t nid, int pin_type,
5720 int sel_idx)
5721{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005722 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005723 /* need the manual connection? */
5724 if (nid >= 0x12) {
5725 int idx = nid - 0x12;
5726 snd_hda_codec_write(codec, idx + 0x0b, 0,
5727 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005728 }
5729}
5730
5731static void alc260_auto_init_multi_out(struct hda_codec *codec)
5732{
5733 struct alc_spec *spec = codec->spec;
5734 hda_nid_t nid;
5735
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005736 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005737 if (nid) {
5738 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5739 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5740 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005741
Takashi Iwai82bc9552006-03-21 11:24:42 +01005742 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005743 if (nid)
5744 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5745
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005746 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005747 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005748 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005749}
Kailang Yangdf694da2005-12-05 19:42:22 +01005750
5751#define ALC260_PIN_CD_NID 0x16
5752static void alc260_auto_init_analog_input(struct hda_codec *codec)
5753{
5754 struct alc_spec *spec = codec->spec;
5755 int i;
5756
5757 for (i = 0; i < AUTO_PIN_LAST; i++) {
5758 hda_nid_t nid = spec->autocfg.input_pins[i];
5759 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005760 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005761 if (nid != ALC260_PIN_CD_NID &&
5762 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005763 snd_hda_codec_write(codec, nid, 0,
5764 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005765 AMP_OUT_MUTE);
5766 }
5767 }
5768}
5769
5770/*
5771 * generic initialization of ADC, input mixers and output mixers
5772 */
5773static struct hda_verb alc260_volume_init_verbs[] = {
5774 /*
5775 * Unmute ADC0-1 and set the default input to mic-in
5776 */
5777 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5778 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5779 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5780 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005781
Kailang Yangdf694da2005-12-05 19:42:22 +01005782 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5783 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005784 * Note: PASD motherboards uses the Line In 2 as the input for
5785 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005786 */
5787 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005788 /* mute analog inputs */
5789 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5790 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5791 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5792 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5793 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005794
5795 /*
5796 * Set up output mixers (0x08 - 0x0a)
5797 */
5798 /* set vol=0 to output mixers */
5799 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5800 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5801 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5802 /* set up input amps for analog loopback */
5803 /* Amp Indices: DAC = 0, mixer = 1 */
5804 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5805 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5806 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5807 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5808 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5809 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005810
Kailang Yangdf694da2005-12-05 19:42:22 +01005811 { }
5812};
5813
5814static int alc260_parse_auto_config(struct hda_codec *codec)
5815{
5816 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005817 int err;
5818 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5819
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005820 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5821 alc260_ignore);
5822 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005823 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005824 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5825 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005826 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005827 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005828 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005829 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5830 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005831 return err;
5832
5833 spec->multiout.max_channels = 2;
5834
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005835 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005836 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005837 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005838 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005839
Takashi Iwaid88897e2008-10-31 15:01:37 +01005840 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005841
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005842 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005843 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005844
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005845 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
5846
Kailang Yangdf694da2005-12-05 19:42:22 +01005847 return 1;
5848}
5849
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005850/* additional initialization for auto-configuration model */
5851static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005852{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005853 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005854 alc260_auto_init_multi_out(codec);
5855 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005856 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005857 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005858}
5859
Takashi Iwaicb53c622007-08-10 17:21:45 +02005860#ifdef CONFIG_SND_HDA_POWER_SAVE
5861static struct hda_amp_list alc260_loopbacks[] = {
5862 { 0x07, HDA_INPUT, 0 },
5863 { 0x07, HDA_INPUT, 1 },
5864 { 0x07, HDA_INPUT, 2 },
5865 { 0x07, HDA_INPUT, 3 },
5866 { 0x07, HDA_INPUT, 4 },
5867 { } /* end */
5868};
5869#endif
5870
Kailang Yangdf694da2005-12-05 19:42:22 +01005871/*
5872 * ALC260 configurations
5873 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005874static const char *alc260_models[ALC260_MODEL_LAST] = {
5875 [ALC260_BASIC] = "basic",
5876 [ALC260_HP] = "hp",
5877 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005878 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005879 [ALC260_FUJITSU_S702X] = "fujitsu",
5880 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005881 [ALC260_WILL] = "will",
5882 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01005883 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005884#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005885 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005886#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005887 [ALC260_AUTO] = "auto",
5888};
5889
5890static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005891 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005892 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01005893 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01005894 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005895 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005896 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005897 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005898 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005899 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5900 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5901 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5902 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5903 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5904 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5905 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5906 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5907 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005908 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005909 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005910 {}
5911};
5912
Kailang Yangdf694da2005-12-05 19:42:22 +01005913static struct alc_config_preset alc260_presets[] = {
5914 [ALC260_BASIC] = {
5915 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005916 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005917 .init_verbs = { alc260_init_verbs },
5918 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5919 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005920 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005921 .adc_nids = alc260_adc_nids,
5922 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5923 .channel_mode = alc260_modes,
5924 .input_mux = &alc260_capture_source,
5925 },
5926 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005927 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005928 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005929 .init_verbs = { alc260_init_verbs,
5930 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005931 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5932 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005933 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5934 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005935 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5936 .channel_mode = alc260_modes,
5937 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005938 .unsol_event = alc260_hp_unsol_event,
5939 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005940 },
Kailang Yang3f878302008-08-26 13:02:23 +02005941 [ALC260_HP_DC7600] = {
5942 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005943 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005944 .init_verbs = { alc260_init_verbs,
5945 alc260_hp_dc7600_verbs },
5946 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5947 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005948 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5949 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005950 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5951 .channel_mode = alc260_modes,
5952 .input_mux = &alc260_capture_source,
5953 .unsol_event = alc260_hp_3012_unsol_event,
5954 .init_hook = alc260_hp_3012_automute,
5955 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005956 [ALC260_HP_3013] = {
5957 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005958 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005959 .init_verbs = { alc260_hp_3013_init_verbs,
5960 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005961 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5962 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005963 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5964 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005965 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5966 .channel_mode = alc260_modes,
5967 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005968 .unsol_event = alc260_hp_3013_unsol_event,
5969 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005970 },
5971 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005972 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005973 .init_verbs = { alc260_fujitsu_init_verbs },
5974 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5975 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005976 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5977 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005978 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5979 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005980 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5981 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005982 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005983 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005984 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005985 .init_verbs = { alc260_acer_init_verbs },
5986 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5987 .dac_nids = alc260_dac_nids,
5988 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5989 .adc_nids = alc260_dual_adc_nids,
5990 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5991 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005992 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5993 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005994 },
Michael Schwingencc959482009-02-22 18:58:45 +01005995 [ALC260_FAVORIT100] = {
5996 .mixers = { alc260_favorit100_mixer },
5997 .init_verbs = { alc260_favorit100_init_verbs },
5998 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5999 .dac_nids = alc260_dac_nids,
6000 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6001 .adc_nids = alc260_dual_adc_nids,
6002 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6003 .channel_mode = alc260_modes,
6004 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6005 .input_mux = alc260_favorit100_capture_sources,
6006 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006007 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006008 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006009 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6010 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6011 .dac_nids = alc260_dac_nids,
6012 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6013 .adc_nids = alc260_adc_nids,
6014 .dig_out_nid = ALC260_DIGOUT_NID,
6015 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6016 .channel_mode = alc260_modes,
6017 .input_mux = &alc260_capture_source,
6018 },
6019 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006020 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006021 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6022 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6023 .dac_nids = alc260_dac_nids,
6024 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6025 .adc_nids = alc260_adc_nids,
6026 .dig_out_nid = ALC260_DIGOUT_NID,
6027 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6028 .channel_mode = alc260_modes,
6029 .input_mux = &alc260_capture_source,
6030 .unsol_event = alc260_replacer_672v_unsol_event,
6031 .init_hook = alc260_replacer_672v_automute,
6032 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006033#ifdef CONFIG_SND_DEBUG
6034 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006035 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006036 .init_verbs = { alc260_test_init_verbs },
6037 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6038 .dac_nids = alc260_test_dac_nids,
6039 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6040 .adc_nids = alc260_test_adc_nids,
6041 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6042 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006043 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6044 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006045 },
6046#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006047};
6048
Linus Torvalds1da177e2005-04-16 15:20:36 -07006049static int patch_alc260(struct hda_codec *codec)
6050{
6051 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006052 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006053
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006054 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006055 if (spec == NULL)
6056 return -ENOMEM;
6057
6058 codec->spec = spec;
6059
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006060 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6061 alc260_models,
6062 alc260_cfg_tbl);
6063 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02006064 snd_printd(KERN_INFO "hda_codec: Unknown model for %s, "
6065 "trying auto-probe from BIOS...\n",
6066 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006067 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006068 }
6069
Kailang Yangdf694da2005-12-05 19:42:22 +01006070 if (board_config == ALC260_AUTO) {
6071 /* automatic parse from the BIOS config */
6072 err = alc260_parse_auto_config(codec);
6073 if (err < 0) {
6074 alc_free(codec);
6075 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006076 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006077 printk(KERN_INFO
6078 "hda_codec: Cannot set up configuration "
6079 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006080 board_config = ALC260_BASIC;
6081 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006082 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006083
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006084 err = snd_hda_attach_beep_device(codec, 0x1);
6085 if (err < 0) {
6086 alc_free(codec);
6087 return err;
6088 }
6089
Kailang Yangdf694da2005-12-05 19:42:22 +01006090 if (board_config != ALC260_AUTO)
6091 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006092
Linus Torvalds1da177e2005-04-16 15:20:36 -07006093 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6094 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6095
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006096 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6097 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6098
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006099 if (!spec->adc_nids && spec->input_mux) {
6100 /* check whether NID 0x04 is valid */
6101 unsigned int wcap = get_wcaps(codec, 0x04);
6102 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6103 /* get type */
6104 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6105 spec->adc_nids = alc260_adc_nids_alt;
6106 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6107 } else {
6108 spec->adc_nids = alc260_adc_nids;
6109 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6110 }
6111 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006112 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006113 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006114
Takashi Iwai2134ea42008-01-10 16:53:55 +01006115 spec->vmaster_nid = 0x08;
6116
Linus Torvalds1da177e2005-04-16 15:20:36 -07006117 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006118 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006119 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006120#ifdef CONFIG_SND_HDA_POWER_SAVE
6121 if (!spec->loopback.amplist)
6122 spec->loopback.amplist = alc260_loopbacks;
6123#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006124 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006125
6126 return 0;
6127}
6128
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006129
Linus Torvalds1da177e2005-04-16 15:20:36 -07006130/*
6131 * ALC882 support
6132 *
6133 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6134 * configuration. Each pin widget can choose any input DACs and a mixer.
6135 * Each ADC is connected from a mixer of all inputs. This makes possible
6136 * 6-channel independent captures.
6137 *
6138 * In addition, an independent DAC for the multi-playback (not used in this
6139 * driver yet).
6140 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006141#define ALC882_DIGOUT_NID 0x06
6142#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006143
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006144static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006145 { 8, NULL }
6146};
6147
6148static hda_nid_t alc882_dac_nids[4] = {
6149 /* front, rear, clfe, rear_surr */
6150 0x02, 0x03, 0x04, 0x05
6151};
6152
Kailang Yangdf694da2005-12-05 19:42:22 +01006153/* identical with ALC880 */
6154#define alc882_adc_nids alc880_adc_nids
6155#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006156
Takashi Iwaie1406342008-02-11 18:32:32 +01006157static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6158static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6159
Linus Torvalds1da177e2005-04-16 15:20:36 -07006160/* input MUX */
6161/* FIXME: should be a matrix-type input source selection */
6162
6163static struct hda_input_mux alc882_capture_source = {
6164 .num_items = 4,
6165 .items = {
6166 { "Mic", 0x0 },
6167 { "Front Mic", 0x1 },
6168 { "Line", 0x2 },
6169 { "CD", 0x4 },
6170 },
6171};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006172
6173static struct hda_input_mux mb5_capture_source = {
6174 .num_items = 3,
6175 .items = {
6176 { "Mic", 0x1 },
6177 { "Line", 0x2 },
6178 { "CD", 0x4 },
6179 },
6180};
6181
Kailang Yangdf694da2005-12-05 19:42:22 +01006182/*
Kailang Yang272a5272007-05-14 11:00:38 +02006183 * 2ch mode
6184 */
6185static struct hda_verb alc882_3ST_ch2_init[] = {
6186 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6187 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6188 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6189 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6190 { } /* end */
6191};
6192
6193/*
6194 * 6ch mode
6195 */
6196static struct hda_verb alc882_3ST_ch6_init[] = {
6197 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6198 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6199 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6200 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6201 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6202 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6203 { } /* end */
6204};
6205
6206static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6207 { 2, alc882_3ST_ch2_init },
6208 { 6, alc882_3ST_ch6_init },
6209};
6210
6211/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006212 * 6ch mode
6213 */
6214static struct hda_verb alc882_sixstack_ch6_init[] = {
6215 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6216 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6217 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6218 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6219 { } /* end */
6220};
6221
6222/*
6223 * 8ch mode
6224 */
6225static struct hda_verb alc882_sixstack_ch8_init[] = {
6226 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6227 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6228 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6229 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6230 { } /* end */
6231};
6232
6233static struct hda_channel_mode alc882_sixstack_modes[2] = {
6234 { 6, alc882_sixstack_ch6_init },
6235 { 8, alc882_sixstack_ch8_init },
6236};
6237
Takashi Iwai87350ad2007-08-16 18:19:38 +02006238/*
6239 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6240 */
6241
6242/*
6243 * 2ch mode
6244 */
6245static struct hda_verb alc885_mbp_ch2_init[] = {
6246 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6247 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6248 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6249 { } /* end */
6250};
6251
6252/*
6253 * 6ch mode
6254 */
6255static struct hda_verb alc885_mbp_ch6_init[] = {
6256 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6257 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6258 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6259 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6260 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6261 { } /* end */
6262};
6263
6264static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6265 { 2, alc885_mbp_ch2_init },
6266 { 6, alc885_mbp_ch6_init },
6267};
6268
6269
Linus Torvalds1da177e2005-04-16 15:20:36 -07006270/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6271 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6272 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006273static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006274 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006275 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006276 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006277 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006278 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6279 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006280 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6281 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006282 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006283 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006284 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6285 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6286 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6287 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6288 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6289 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006290 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006291 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6292 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006293 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006294 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006295 { } /* end */
6296};
6297
Takashi Iwai87350ad2007-08-16 18:19:38 +02006298static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006299 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6300 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6301 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6302 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6303 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6304 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006305 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6306 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006307 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006308 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6309 { } /* end */
6310};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006311
6312static struct snd_kcontrol_new alc885_mb5_mixer[] = {
6313 HDA_CODEC_VOLUME("Front Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6314 HDA_BIND_MUTE ("Front Playback Switch", 0x0d, 0x02, HDA_INPUT),
6315 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6316 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
6317 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6318 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6319 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6320 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6321 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6322 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6323 { } /* end */
6324};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006325static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6326 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6327 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6328 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6329 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6330 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6331 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6332 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6333 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6334 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006335 { } /* end */
6336};
6337
Kailang Yang272a5272007-05-14 11:00:38 +02006338static struct snd_kcontrol_new alc882_targa_mixer[] = {
6339 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6340 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6341 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6342 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6343 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6344 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6345 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6346 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6347 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006348 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006349 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6350 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006351 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006352 { } /* end */
6353};
6354
6355/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6356 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6357 */
6358static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6359 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6360 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6361 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6362 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6363 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6364 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6365 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6366 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6367 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6368 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6369 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6370 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006371 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006372 { } /* end */
6373};
6374
Takashi Iwai914759b2007-09-06 14:52:04 +02006375static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6376 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6377 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6378 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6379 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6380 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6381 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6382 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6383 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6384 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6385 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006386 { } /* end */
6387};
6388
Kailang Yangdf694da2005-12-05 19:42:22 +01006389static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6390 {
6391 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6392 .name = "Channel Mode",
6393 .info = alc_ch_mode_info,
6394 .get = alc_ch_mode_get,
6395 .put = alc_ch_mode_put,
6396 },
6397 { } /* end */
6398};
6399
Linus Torvalds1da177e2005-04-16 15:20:36 -07006400static struct hda_verb alc882_init_verbs[] = {
6401 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006402 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006405 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006406 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6407 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6408 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006409 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006410 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6411 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6412 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006413 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006414 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6415 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6416 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006417
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006418 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006419 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006420 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006421 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006422 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006423 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006424 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006425 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006426 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006427 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006428 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006429 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006430 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006431 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006432 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006433 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006434 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006435 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006436 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6437 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006438 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006439 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6440 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006441 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006442 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6443 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6444 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6445 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6446 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006447 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006448 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006449
6450 /* FIXME: use matrix-type input source selection */
6451 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6452 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006453 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6454 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6455 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6456 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006457 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006458 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6459 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6460 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6461 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006462 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006463 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6464 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6465 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6466 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6467 /* ADC1: mute amp left and right */
6468 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006469 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006470 /* ADC2: mute amp left and right */
6471 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006472 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006473 /* ADC3: mute amp left and right */
6474 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006475 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006476
6477 { }
6478};
6479
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006480static struct hda_verb alc882_eapd_verbs[] = {
6481 /* change to EAPD mode */
6482 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006483 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006484 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006485};
6486
Tobin Davis9102cd12006-12-15 10:02:12 +01006487/* Mac Pro test */
6488static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6489 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6490 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6491 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6492 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6493 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006494 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006495 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6496 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006497 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006498 { } /* end */
6499};
6500
6501static struct hda_verb alc882_macpro_init_verbs[] = {
6502 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6505 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6506 /* Front Pin: output 0 (0x0c) */
6507 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6508 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6509 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6510 /* Front Mic pin: input vref at 80% */
6511 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6512 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6513 /* Speaker: output */
6514 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6515 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6516 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6517 /* Headphone output (output 0 - 0x0c) */
6518 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6519 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6520 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6521
6522 /* FIXME: use matrix-type input source selection */
6523 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6524 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6525 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6526 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6527 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6528 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6529 /* Input mixer2 */
6530 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6531 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6532 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6533 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6534 /* Input mixer3 */
6535 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6536 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6537 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6538 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6539 /* ADC1: mute amp left and right */
6540 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6541 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6542 /* ADC2: mute amp left and right */
6543 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6544 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6545 /* ADC3: mute amp left and right */
6546 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6547 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6548
6549 { }
6550};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006551
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006552/* Macbook 5,1 */
6553static struct hda_verb alc885_mb5_init_verbs[] = {
6554 /* Front mixer */
6555 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6556 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6557 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6558 /* LineOut mixer */
6559 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6560 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6561 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6562 /* Front Pin: output 0 (0x0d) */
6563 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6564 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6565 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01},
6566 /* HP Pin: output 0 (0x0c) */
6567 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6568 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6569 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6570 /* Front Mic pin: input vref at 80% */
6571 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6572 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6573 /* Line In pin */
6574 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6575 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6576
6577 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6578 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6579 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6580 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6581 { }
6582};
6583
Takashi Iwai87350ad2007-08-16 18:19:38 +02006584/* Macbook Pro rev3 */
6585static struct hda_verb alc885_mbp3_init_verbs[] = {
6586 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6587 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6590 /* Rear mixer */
6591 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6592 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6593 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6594 /* Front Pin: output 0 (0x0c) */
6595 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6596 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6597 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6598 /* HP Pin: output 0 (0x0d) */
6599 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6600 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6601 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6602 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6603 /* Mic (rear) pin: input vref at 80% */
6604 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6605 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6606 /* Front Mic pin: input vref at 80% */
6607 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6608 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6609 /* Line In pin: use output 1 when in LineOut mode */
6610 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6611 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6612 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6613
6614 /* FIXME: use matrix-type input source selection */
6615 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6616 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6617 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6618 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6619 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6620 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6621 /* Input mixer2 */
6622 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6623 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6624 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6625 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6626 /* Input mixer3 */
6627 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6628 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6629 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6630 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6631 /* ADC1: mute amp left and right */
6632 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6633 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6634 /* ADC2: mute amp left and right */
6635 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6636 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6637 /* ADC3: mute amp left and right */
6638 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6639 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6640
6641 { }
6642};
6643
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006644/* iMac 24 mixer. */
6645static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6646 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6647 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6648 { } /* end */
6649};
6650
6651/* iMac 24 init verbs. */
6652static struct hda_verb alc885_imac24_init_verbs[] = {
6653 /* Internal speakers: output 0 (0x0c) */
6654 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6655 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6656 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6657 /* Internal speakers: output 0 (0x0c) */
6658 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6659 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6660 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6661 /* Headphone: output 0 (0x0c) */
6662 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6663 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6664 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6665 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6666 /* Front Mic: input vref at 80% */
6667 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6668 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6669 { }
6670};
6671
6672/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006673static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006674{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006675 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006676
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006677 spec->autocfg.hp_pins[0] = 0x14;
6678 spec->autocfg.speaker_pins[0] = 0x18;
6679 spec->autocfg.speaker_pins[1] = 0x1a;
6680 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006681}
6682
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006683static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006684{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006685 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006686
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006687 spec->autocfg.hp_pins[0] = 0x15;
6688 spec->autocfg.speaker_pins[0] = 0x14;
6689 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02006690}
6691
6692
Kailang Yang272a5272007-05-14 11:00:38 +02006693static struct hda_verb alc882_targa_verbs[] = {
6694 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6695 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6696
6697 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6698 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006699
Kailang Yang272a5272007-05-14 11:00:38 +02006700 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6701 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6702 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6703
6704 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6705 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6706 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6707 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6708 { } /* end */
6709};
6710
6711/* toggle speaker-output according to the hp-jack state */
6712static void alc882_targa_automute(struct hda_codec *codec)
6713{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006714 struct alc_spec *spec = codec->spec;
6715 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006716 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006717 spec->jack_present ? 1 : 3);
6718}
6719
6720static void alc882_targa_init_hook(struct hda_codec *codec)
6721{
6722 struct alc_spec *spec = codec->spec;
6723
6724 spec->autocfg.hp_pins[0] = 0x14;
6725 spec->autocfg.speaker_pins[0] = 0x1b;
6726 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006727}
6728
6729static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6730{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006731 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02006732 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006733}
6734
6735static struct hda_verb alc882_asus_a7j_verbs[] = {
6736 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6737 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6738
6739 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6740 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6741 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006742
Kailang Yang272a5272007-05-14 11:00:38 +02006743 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6744 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6745 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6746
6747 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6748 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6749 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6750 { } /* end */
6751};
6752
Takashi Iwai914759b2007-09-06 14:52:04 +02006753static struct hda_verb alc882_asus_a7m_verbs[] = {
6754 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6755 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6756
6757 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6758 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6759 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006760
Takashi Iwai914759b2007-09-06 14:52:04 +02006761 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6762 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6763 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6764
6765 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6766 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6767 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6768 { } /* end */
6769};
6770
Tobin Davis9102cd12006-12-15 10:02:12 +01006771static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6772{
6773 unsigned int gpiostate, gpiomask, gpiodir;
6774
6775 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6776 AC_VERB_GET_GPIO_DATA, 0);
6777
6778 if (!muted)
6779 gpiostate |= (1 << pin);
6780 else
6781 gpiostate &= ~(1 << pin);
6782
6783 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6784 AC_VERB_GET_GPIO_MASK, 0);
6785 gpiomask |= (1 << pin);
6786
6787 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6788 AC_VERB_GET_GPIO_DIRECTION, 0);
6789 gpiodir |= (1 << pin);
6790
6791
6792 snd_hda_codec_write(codec, codec->afg, 0,
6793 AC_VERB_SET_GPIO_MASK, gpiomask);
6794 snd_hda_codec_write(codec, codec->afg, 0,
6795 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6796
6797 msleep(1);
6798
6799 snd_hda_codec_write(codec, codec->afg, 0,
6800 AC_VERB_SET_GPIO_DATA, gpiostate);
6801}
6802
Takashi Iwai7debbe52007-08-16 15:01:03 +02006803/* set up GPIO at initialization */
6804static void alc885_macpro_init_hook(struct hda_codec *codec)
6805{
6806 alc882_gpio_mute(codec, 0, 0);
6807 alc882_gpio_mute(codec, 1, 0);
6808}
6809
6810/* set up GPIO and update auto-muting at initialization */
6811static void alc885_imac24_init_hook(struct hda_codec *codec)
6812{
6813 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006814 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02006815}
6816
Kailang Yangdf694da2005-12-05 19:42:22 +01006817/*
6818 * generic initialization of ADC, input mixers and output mixers
6819 */
6820static struct hda_verb alc882_auto_init_verbs[] = {
6821 /*
6822 * Unmute ADC0-2 and set the default input to mic-in
6823 */
6824 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6826 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6827 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6828 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6829 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6830
Takashi Iwaicb53c622007-08-10 17:21:45 +02006831 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006832 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006833 * Note: PASD motherboards uses the Line In 2 as the input for
6834 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006835 */
6836 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006837 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6838 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6839 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6840 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6841 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006842
6843 /*
6844 * Set up output mixers (0x0c - 0x0f)
6845 */
6846 /* set vol=0 to output mixers */
6847 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6848 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6849 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6850 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6851 /* set up input amps for analog loopback */
6852 /* Amp Indices: DAC = 0, mixer = 1 */
6853 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6854 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6855 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6856 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6857 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6858 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6859 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6860 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6861 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6862 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6863
6864 /* FIXME: use matrix-type input source selection */
6865 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6866 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6867 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6868 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6869 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6870 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6871 /* Input mixer2 */
6872 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6873 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6874 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6875 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6876 /* Input mixer3 */
6877 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6878 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6879 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6880 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6881
6882 { }
6883};
6884
Takashi Iwaicb53c622007-08-10 17:21:45 +02006885#ifdef CONFIG_SND_HDA_POWER_SAVE
6886#define alc882_loopbacks alc880_loopbacks
6887#endif
6888
Kailang Yangdf694da2005-12-05 19:42:22 +01006889/* pcm configuration: identiacal with ALC880 */
6890#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6891#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6892#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6893#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6894
6895/*
6896 * configuration and preset
6897 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006898static const char *alc882_models[ALC882_MODEL_LAST] = {
6899 [ALC882_3ST_DIG] = "3stack-dig",
6900 [ALC882_6ST_DIG] = "6stack-dig",
6901 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006902 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006903 [ALC882_TARGA] = "targa",
6904 [ALC882_ASUS_A7J] = "asus-a7j",
6905 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006906 [ALC885_MACPRO] = "macpro",
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006907 [ALC885_MB5] = "mb5",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006908 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006909 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006910 [ALC882_AUTO] = "auto",
6911};
6912
6913static struct snd_pci_quirk alc882_cfg_tbl[] = {
6914 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006915 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006916 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006917 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006918 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006919 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006920 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006921 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006922 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006923 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6924 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6925 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006926 {}
6927};
6928
6929static struct alc_config_preset alc882_presets[] = {
6930 [ALC882_3ST_DIG] = {
6931 .mixers = { alc882_base_mixer },
6932 .init_verbs = { alc882_init_verbs },
6933 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6934 .dac_nids = alc882_dac_nids,
6935 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006936 .dig_in_nid = ALC882_DIGIN_NID,
6937 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6938 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006939 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006940 .input_mux = &alc882_capture_source,
6941 },
6942 [ALC882_6ST_DIG] = {
6943 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6944 .init_verbs = { alc882_init_verbs },
6945 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6946 .dac_nids = alc882_dac_nids,
6947 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006948 .dig_in_nid = ALC882_DIGIN_NID,
6949 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6950 .channel_mode = alc882_sixstack_modes,
6951 .input_mux = &alc882_capture_source,
6952 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006953 [ALC882_ARIMA] = {
6954 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6955 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6956 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6957 .dac_nids = alc882_dac_nids,
6958 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6959 .channel_mode = alc882_sixstack_modes,
6960 .input_mux = &alc882_capture_source,
6961 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006962 [ALC882_W2JC] = {
6963 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6964 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6965 alc880_gpio1_init_verbs },
6966 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6967 .dac_nids = alc882_dac_nids,
6968 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6969 .channel_mode = alc880_threestack_modes,
6970 .need_dac_fix = 1,
6971 .input_mux = &alc882_capture_source,
6972 .dig_out_nid = ALC882_DIGOUT_NID,
6973 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006974 [ALC885_MBP3] = {
6975 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6976 .init_verbs = { alc885_mbp3_init_verbs,
6977 alc880_gpio1_init_verbs },
6978 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6979 .dac_nids = alc882_dac_nids,
6980 .channel_mode = alc885_mbp_6ch_modes,
6981 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6982 .input_mux = &alc882_capture_source,
6983 .dig_out_nid = ALC882_DIGOUT_NID,
6984 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006985 .unsol_event = alc_automute_amp_unsol_event,
6986 .init_hook = alc885_mbp3_init_hook,
Takashi Iwai87350ad2007-08-16 18:19:38 +02006987 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006988 [ALC885_MB5] = {
6989 .mixers = { alc885_mb5_mixer },
6990 .init_verbs = { alc885_mb5_init_verbs,
6991 alc880_gpio1_init_verbs },
6992 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6993 .dac_nids = alc882_dac_nids,
6994 .channel_mode = alc885_mbp_6ch_modes,
6995 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6996 .input_mux = &mb5_capture_source,
6997 .dig_out_nid = ALC882_DIGOUT_NID,
6998 .dig_in_nid = ALC882_DIGIN_NID,
6999 },
Tobin Davis9102cd12006-12-15 10:02:12 +01007000 [ALC885_MACPRO] = {
7001 .mixers = { alc882_macpro_mixer },
7002 .init_verbs = { alc882_macpro_init_verbs },
7003 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7004 .dac_nids = alc882_dac_nids,
7005 .dig_out_nid = ALC882_DIGOUT_NID,
7006 .dig_in_nid = ALC882_DIGIN_NID,
7007 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7008 .channel_mode = alc882_ch_modes,
7009 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007010 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01007011 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007012 [ALC885_IMAC24] = {
7013 .mixers = { alc885_imac24_mixer },
7014 .init_verbs = { alc885_imac24_init_verbs },
7015 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7016 .dac_nids = alc882_dac_nids,
7017 .dig_out_nid = ALC882_DIGOUT_NID,
7018 .dig_in_nid = ALC882_DIGIN_NID,
7019 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7020 .channel_mode = alc882_ch_modes,
7021 .input_mux = &alc882_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007022 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007023 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007024 },
Kailang Yang272a5272007-05-14 11:00:38 +02007025 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007026 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007027 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
7028 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7029 .dac_nids = alc882_dac_nids,
7030 .dig_out_nid = ALC882_DIGOUT_NID,
7031 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7032 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007033 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007034 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7035 .channel_mode = alc882_3ST_6ch_modes,
7036 .need_dac_fix = 1,
7037 .input_mux = &alc882_capture_source,
7038 .unsol_event = alc882_targa_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007039 .init_hook = alc882_targa_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02007040 },
7041 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007042 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007043 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
7044 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7045 .dac_nids = alc882_dac_nids,
7046 .dig_out_nid = ALC882_DIGOUT_NID,
7047 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7048 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007049 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007050 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7051 .channel_mode = alc882_3ST_6ch_modes,
7052 .need_dac_fix = 1,
7053 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007054 },
Takashi Iwai914759b2007-09-06 14:52:04 +02007055 [ALC882_ASUS_A7M] = {
7056 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7057 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7058 alc880_gpio1_init_verbs,
7059 alc882_asus_a7m_verbs },
7060 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7061 .dac_nids = alc882_dac_nids,
7062 .dig_out_nid = ALC882_DIGOUT_NID,
7063 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7064 .channel_mode = alc880_threestack_modes,
7065 .need_dac_fix = 1,
7066 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007067 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007068};
7069
7070
7071/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02007072 * Pin config fixes
7073 */
Kailang Yangea1fb292008-08-26 12:58:38 +02007074enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02007075 PINFIX_ABIT_AW9D_MAX
7076};
7077
7078static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7079 { 0x15, 0x01080104 }, /* side */
7080 { 0x16, 0x01011012 }, /* rear */
7081 { 0x17, 0x01016011 }, /* clfe */
7082 { }
7083};
7084
7085static const struct alc_pincfg *alc882_pin_fixes[] = {
7086 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7087};
7088
7089static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7090 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7091 {}
7092};
7093
7094/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007095 * BIOS auto configuration
7096 */
7097static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7098 hda_nid_t nid, int pin_type,
7099 int dac_idx)
7100{
7101 /* set as output */
7102 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007103 int idx;
7104
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007105 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007106 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7107 idx = 4;
7108 else
7109 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007110 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7111
7112}
7113
7114static void alc882_auto_init_multi_out(struct hda_codec *codec)
7115{
7116 struct alc_spec *spec = codec->spec;
7117 int i;
7118
7119 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007120 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007121 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007122 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007123 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007124 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007125 }
7126}
7127
7128static void alc882_auto_init_hp_out(struct hda_codec *codec)
7129{
7130 struct alc_spec *spec = codec->spec;
7131 hda_nid_t pin;
7132
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007133 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007134 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007135 /* use dac 0 */
7136 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007137 pin = spec->autocfg.speaker_pins[0];
7138 if (pin)
7139 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007140}
7141
7142#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7143#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7144
7145static void alc882_auto_init_analog_input(struct hda_codec *codec)
7146{
7147 struct alc_spec *spec = codec->spec;
7148 int i;
7149
7150 for (i = 0; i < AUTO_PIN_LAST; i++) {
7151 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007152 if (!nid)
7153 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007154 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007155 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7156 snd_hda_codec_write(codec, nid, 0,
7157 AC_VERB_SET_AMP_GAIN_MUTE,
7158 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007159 }
7160}
7161
Takashi Iwaif511b012008-08-15 16:46:42 +02007162static void alc882_auto_init_input_src(struct hda_codec *codec)
7163{
7164 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007165 int c;
7166
7167 for (c = 0; c < spec->num_adc_nids; c++) {
7168 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7169 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007170 unsigned int mux_idx;
7171 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007172 int conns, mute, idx, item;
7173
7174 conns = snd_hda_get_connections(codec, nid, conn_list,
7175 ARRAY_SIZE(conn_list));
7176 if (conns < 0)
7177 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007178 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7179 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007180 for (idx = 0; idx < conns; idx++) {
7181 /* if the current connection is the selected one,
7182 * unmute it as default - otherwise mute it
7183 */
7184 mute = AMP_IN_MUTE(idx);
7185 for (item = 0; item < imux->num_items; item++) {
7186 if (imux->items[item].index == idx) {
7187 if (spec->cur_mux[c] == item)
7188 mute = AMP_IN_UNMUTE(idx);
7189 break;
7190 }
7191 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007192 /* check if we have a selector or mixer
7193 * we could check for the widget type instead, but
7194 * just check for Amp-In presence (in case of mixer
7195 * without amp-in there is something wrong, this
7196 * function shouldn't be used or capsrc nid is wrong)
7197 */
7198 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7199 snd_hda_codec_write(codec, nid, 0,
7200 AC_VERB_SET_AMP_GAIN_MUTE,
7201 mute);
7202 else if (mute != AMP_IN_MUTE(idx))
7203 snd_hda_codec_write(codec, nid, 0,
7204 AC_VERB_SET_CONNECT_SEL,
7205 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007206 }
7207 }
7208}
7209
Takashi Iwai776e1842007-08-29 15:07:11 +02007210/* add mic boosts if needed */
7211static int alc_auto_add_mic_boost(struct hda_codec *codec)
7212{
7213 struct alc_spec *spec = codec->spec;
7214 int err;
7215 hda_nid_t nid;
7216
7217 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007218 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007219 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7220 "Mic Boost",
7221 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7222 if (err < 0)
7223 return err;
7224 }
7225 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007226 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007227 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7228 "Front Mic Boost",
7229 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7230 if (err < 0)
7231 return err;
7232 }
7233 return 0;
7234}
7235
Kailang Yangdf694da2005-12-05 19:42:22 +01007236/* almost identical with ALC880 parser... */
7237static int alc882_parse_auto_config(struct hda_codec *codec)
7238{
7239 struct alc_spec *spec = codec->spec;
7240 int err = alc880_parse_auto_config(codec);
7241
7242 if (err < 0)
7243 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007244 else if (!err)
7245 return 0; /* no config found */
7246
7247 err = alc_auto_add_mic_boost(codec);
7248 if (err < 0)
7249 return err;
7250
7251 /* hack - override the init verbs */
7252 spec->init_verbs[0] = alc882_auto_init_verbs;
7253
7254 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007255}
7256
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007257/* additional initialization for auto-configuration model */
7258static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007259{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007260 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007261 alc882_auto_init_multi_out(codec);
7262 alc882_auto_init_hp_out(codec);
7263 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007264 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007265 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007266 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007267}
7268
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007269static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7270
Linus Torvalds1da177e2005-04-16 15:20:36 -07007271static int patch_alc882(struct hda_codec *codec)
7272{
7273 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007274 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007275
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007276 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007277 if (spec == NULL)
7278 return -ENOMEM;
7279
Linus Torvalds1da177e2005-04-16 15:20:36 -07007280 codec->spec = spec;
7281
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007282 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7283 alc882_models,
7284 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007285
Kailang Yangdf694da2005-12-05 19:42:22 +01007286 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007287 /* Pick up systems that don't supply PCI SSID */
7288 switch (codec->subsystem_id) {
7289 case 0x106b0c00: /* Mac Pro */
7290 board_config = ALC885_MACPRO;
7291 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007292 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007293 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007294 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007295 board_config = ALC885_IMAC24;
7296 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007297 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007298 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007299 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007300 case 0x106b2c00: /* Macbook Pro rev3 */
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007301 /* Macbook 3.1 (0x106b3600) is handled by patch_alc883() */
Luke Yelavich2a884642009-01-28 15:58:38 +11007302 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007303 board_config = ALC885_MBP3;
7304 break;
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007305 case 0x106b3f00: /* Macbook 5,1 */
Takashi Iwai7442f9d2009-05-14 18:20:33 +02007306 case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense
7307 * seems not working, so apparently
7308 * no perfect solution yet
7309 */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007310 board_config = ALC885_MB5;
7311 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007312 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007313 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007314 if (codec->revision_id == 0x100101 ||
7315 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007316 alc_free(codec);
7317 return patch_alc883(codec);
7318 }
Takashi Iwai6c627f32009-05-18 12:33:36 +02007319 printk(KERN_INFO "hda_codec: Unknown model for %s, "
7320 "trying auto-probe from BIOS...\n",
7321 codec->chip_name);
Tobin Davis081d17c2007-02-15 17:46:18 +01007322 board_config = ALC882_AUTO;
7323 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007324 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007325
Takashi Iwaif95474e2007-07-10 00:47:43 +02007326 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7327
Kailang Yangdf694da2005-12-05 19:42:22 +01007328 if (board_config == ALC882_AUTO) {
7329 /* automatic parse from the BIOS config */
7330 err = alc882_parse_auto_config(codec);
7331 if (err < 0) {
7332 alc_free(codec);
7333 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007334 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007335 printk(KERN_INFO
7336 "hda_codec: Cannot set up configuration "
7337 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007338 board_config = ALC882_3ST_DIG;
7339 }
7340 }
7341
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007342 err = snd_hda_attach_beep_device(codec, 0x1);
7343 if (err < 0) {
7344 alc_free(codec);
7345 return err;
7346 }
7347
Kailang Yangdf694da2005-12-05 19:42:22 +01007348 if (board_config != ALC882_AUTO)
7349 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007350
Kailang Yangdf694da2005-12-05 19:42:22 +01007351 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7352 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007353 /* FIXME: setup DAC5 */
7354 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7355 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007356
Kailang Yangdf694da2005-12-05 19:42:22 +01007357 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7358 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007359
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007360 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007361 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007362 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007363 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007364 /* get type */
7365 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007366 if (wcap != AC_WID_AUD_IN) {
7367 spec->adc_nids = alc882_adc_nids_alt;
7368 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007369 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007370 } else {
7371 spec->adc_nids = alc882_adc_nids;
7372 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007373 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007374 }
7375 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007376 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007377 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007378
Takashi Iwai2134ea42008-01-10 16:53:55 +01007379 spec->vmaster_nid = 0x0c;
7380
Linus Torvalds1da177e2005-04-16 15:20:36 -07007381 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007382 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007383 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007384#ifdef CONFIG_SND_HDA_POWER_SAVE
7385 if (!spec->loopback.amplist)
7386 spec->loopback.amplist = alc882_loopbacks;
7387#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007388 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007389
7390 return 0;
7391}
7392
7393/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007394 * ALC883 support
7395 *
7396 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7397 * configuration. Each pin widget can choose any input DACs and a mixer.
7398 * Each ADC is connected from a mixer of all inputs. This makes possible
7399 * 6-channel independent captures.
7400 *
7401 * In addition, an independent DAC for the multi-playback (not used in this
7402 * driver yet).
7403 */
7404#define ALC883_DIGOUT_NID 0x06
7405#define ALC883_DIGIN_NID 0x0a
7406
Wu Fengguang3ab90932008-11-17 09:51:09 +01007407#define ALC1200_DIGOUT_NID 0x10
7408
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007409static hda_nid_t alc883_dac_nids[4] = {
7410 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007411 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007412};
7413
7414static hda_nid_t alc883_adc_nids[2] = {
7415 /* ADC1-2 */
7416 0x08, 0x09,
7417};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007418
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007419static hda_nid_t alc883_adc_nids_alt[1] = {
7420 /* ADC1 */
7421 0x08,
7422};
7423
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007424static hda_nid_t alc883_adc_nids_rev[2] = {
7425 /* ADC2-1 */
7426 0x09, 0x08
7427};
7428
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007429#define alc889_adc_nids alc880_adc_nids
7430
Takashi Iwaie1406342008-02-11 18:32:32 +01007431static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7432
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007433static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7434
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007435#define alc889_capsrc_nids alc882_capsrc_nids
7436
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007437/* input MUX */
7438/* FIXME: should be a matrix-type input source selection */
7439
7440static struct hda_input_mux alc883_capture_source = {
7441 .num_items = 4,
7442 .items = {
7443 { "Mic", 0x0 },
7444 { "Front Mic", 0x1 },
7445 { "Line", 0x2 },
7446 { "CD", 0x4 },
7447 },
7448};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007449
Jiang zhe17bba1b2008-06-04 12:11:07 +02007450static struct hda_input_mux alc883_3stack_6ch_intel = {
7451 .num_items = 4,
7452 .items = {
7453 { "Mic", 0x1 },
7454 { "Front Mic", 0x0 },
7455 { "Line", 0x2 },
7456 { "CD", 0x4 },
7457 },
7458};
7459
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007460static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7461 .num_items = 2,
7462 .items = {
7463 { "Mic", 0x1 },
7464 { "Line", 0x2 },
7465 },
7466};
7467
Kailang Yang272a5272007-05-14 11:00:38 +02007468static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7469 .num_items = 4,
7470 .items = {
7471 { "Mic", 0x0 },
7472 { "iMic", 0x1 },
7473 { "Line", 0x2 },
7474 { "CD", 0x4 },
7475 },
7476};
7477
Jiang zhefb97dc62008-03-06 11:07:11 +01007478static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7479 .num_items = 2,
7480 .items = {
7481 { "Mic", 0x0 },
7482 { "Int Mic", 0x1 },
7483 },
7484};
7485
Kailang Yange2757d52008-08-26 13:17:46 +02007486static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7487 .num_items = 3,
7488 .items = {
7489 { "Mic", 0x0 },
7490 { "Front Mic", 0x1 },
7491 { "Line", 0x4 },
7492 },
7493};
7494
7495static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7496 .num_items = 2,
7497 .items = {
7498 { "Mic", 0x0 },
7499 { "Line", 0x2 },
7500 },
7501};
7502
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007503static struct hda_input_mux alc889A_mb31_capture_source = {
7504 .num_items = 2,
7505 .items = {
7506 { "Mic", 0x0 },
7507 /* Front Mic (0x01) unused */
7508 { "Line", 0x2 },
7509 /* Line 2 (0x03) unused */
7510 /* CD (0x04) unsused? */
7511 },
7512};
7513
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007514/*
7515 * 2ch mode
7516 */
7517static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7518 { 2, NULL }
7519};
7520
7521/*
7522 * 2ch mode
7523 */
7524static struct hda_verb alc883_3ST_ch2_init[] = {
7525 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7526 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7527 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7528 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7529 { } /* end */
7530};
7531
7532/*
Tobin Davisb2011312007-09-17 12:45:11 +02007533 * 4ch mode
7534 */
7535static struct hda_verb alc883_3ST_ch4_init[] = {
7536 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7537 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7538 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7539 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7540 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7541 { } /* end */
7542};
7543
7544/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007545 * 6ch mode
7546 */
7547static struct hda_verb alc883_3ST_ch6_init[] = {
7548 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7549 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7550 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7551 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7552 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7553 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7554 { } /* end */
7555};
7556
Tobin Davisb2011312007-09-17 12:45:11 +02007557static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007558 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007559 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007560 { 6, alc883_3ST_ch6_init },
7561};
7562
7563/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007564 * 2ch mode
7565 */
7566static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7567 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7568 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7569 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7570 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7571 { } /* end */
7572};
7573
7574/*
7575 * 4ch mode
7576 */
7577static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7578 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7579 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7580 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7581 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7582 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7583 { } /* end */
7584};
7585
7586/*
7587 * 6ch mode
7588 */
7589static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7590 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7591 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7592 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7593 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7594 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7595 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7596 { } /* end */
7597};
7598
7599static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7600 { 2, alc883_3ST_ch2_intel_init },
7601 { 4, alc883_3ST_ch4_intel_init },
7602 { 6, alc883_3ST_ch6_intel_init },
7603};
7604
7605/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007606 * 6ch mode
7607 */
7608static struct hda_verb alc883_sixstack_ch6_init[] = {
7609 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7610 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7611 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7612 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7613 { } /* end */
7614};
7615
7616/*
7617 * 8ch mode
7618 */
7619static struct hda_verb alc883_sixstack_ch8_init[] = {
7620 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7621 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7622 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7623 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7624 { } /* end */
7625};
7626
7627static struct hda_channel_mode alc883_sixstack_modes[2] = {
7628 { 6, alc883_sixstack_ch6_init },
7629 { 8, alc883_sixstack_ch8_init },
7630};
7631
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007632/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7633static struct hda_verb alc889A_mb31_ch2_init[] = {
7634 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7635 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7636 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7637 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7638 { } /* end */
7639};
7640
7641/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7642static struct hda_verb alc889A_mb31_ch4_init[] = {
7643 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7644 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7645 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7646 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7647 { } /* end */
7648};
7649
7650/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7651static struct hda_verb alc889A_mb31_ch5_init[] = {
7652 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7653 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7654 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7655 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7656 { } /* end */
7657};
7658
7659/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7660static struct hda_verb alc889A_mb31_ch6_init[] = {
7661 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7662 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7663 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7664 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7665 { } /* end */
7666};
7667
7668static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7669 { 2, alc889A_mb31_ch2_init },
7670 { 4, alc889A_mb31_ch4_init },
7671 { 5, alc889A_mb31_ch5_init },
7672 { 6, alc889A_mb31_ch6_init },
7673};
7674
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007675static struct hda_verb alc883_medion_eapd_verbs[] = {
7676 /* eanable EAPD on medion laptop */
7677 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7678 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7679 { }
7680};
7681
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007682/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7683 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7684 */
7685
7686static struct snd_kcontrol_new alc883_base_mixer[] = {
7687 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7688 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7689 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7690 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7691 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7692 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7693 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7694 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7695 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7696 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7697 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7698 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7699 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7700 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7701 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7702 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007703 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007704 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7705 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007706 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007707 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007708 { } /* end */
7709};
7710
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007711static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7712 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7713 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7714 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7715 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7716 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7717 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7718 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7719 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7720 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7721 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7722 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7723 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7724 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007725 { } /* end */
7726};
7727
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007728static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007729 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7730 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7731 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7732 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7733 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7734 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7735 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7736 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7737 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7738 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007739 { } /* end */
7740};
7741
Jiang zhefb97dc62008-03-06 11:07:11 +01007742static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7743 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7744 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7745 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7746 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7747 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7748 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7749 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7750 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7751 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7752 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007753 { } /* end */
7754};
7755
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007756static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7757 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7758 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7759 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7760 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7761 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7762 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7763 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7764 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007765 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007766 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7767 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007768 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007769 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007770 { } /* end */
7771};
7772
7773static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7774 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7775 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7776 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7777 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7778 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7779 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7780 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7781 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7782 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7783 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7784 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7785 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7786 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7787 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007788 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007789 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7790 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007791 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007792 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007793 { } /* end */
7794};
7795
Jiang zhe17bba1b2008-06-04 12:11:07 +02007796static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7797 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7798 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7799 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7800 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7801 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7802 HDA_OUTPUT),
7803 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7804 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7805 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7806 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7807 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7808 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7809 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7810 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7812 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7814 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7815 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7816 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007817 { } /* end */
7818};
7819
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007820static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007821 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007822 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007823 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007824 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007825 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7826 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007827 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7828 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007829 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7830 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7831 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7832 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7833 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7834 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007835 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007836 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7837 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007838 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007839 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007840 { } /* end */
7841};
7842
Kailang Yangccc656c2006-10-17 12:32:26 +02007843static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7844 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7845 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7846 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7847 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7848 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7849 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7850 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7851 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7852 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7853 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7854 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7855 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7856 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7857 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007858 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007859 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007860 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007861};
Kailang Yangccc656c2006-10-17 12:32:26 +02007862
7863static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7864 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7865 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7866 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7867 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7868 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7869 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007870 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007871 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007872 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7873 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7874 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007875 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007876};
Kailang Yangccc656c2006-10-17 12:32:26 +02007877
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007878static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7879 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7880 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007881 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7882 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007883 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7884 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7885 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7886 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007887 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007888};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007889
Kailang Yang272a5272007-05-14 11:00:38 +02007890static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7891 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7892 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7893 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7894 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7895 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7896 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7897 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7898 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7899 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007900 { } /* end */
7901};
7902
7903static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7904 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7905 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7906 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7907 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7908 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7909 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7910 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7911 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7912 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007913 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007914};
Kailang Yang272a5272007-05-14 11:00:38 +02007915
Tobin Davis2880a862007-08-07 11:50:26 +02007916static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007917 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7918 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007919 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007920 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7921 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007922 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7923 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7924 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007925 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007926};
Tobin Davis2880a862007-08-07 11:50:26 +02007927
Kailang Yange2757d52008-08-26 13:17:46 +02007928static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7929 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7930 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7931 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7932 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7933 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7934 0x0d, 1, 0x0, HDA_OUTPUT),
7935 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7936 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7937 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7938 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7939 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007940 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7941 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7942 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7943 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7944 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7945 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7946 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7947 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7948 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7949 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007950 { } /* end */
7951};
7952
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007953static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
7954 /* Output mixers */
7955 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7956 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7957 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7958 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7959 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
7960 HDA_OUTPUT),
7961 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
7962 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
7963 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
7964 /* Output switches */
7965 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
7966 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
7967 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
7968 /* Boost mixers */
7969 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7970 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
7971 /* Input mixers */
7972 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7973 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7974 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7975 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7976 { } /* end */
7977};
7978
Kailang Yange2757d52008-08-26 13:17:46 +02007979static struct hda_bind_ctls alc883_bind_cap_vol = {
7980 .ops = &snd_hda_bind_vol,
7981 .values = {
7982 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7983 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7984 0
7985 },
7986};
7987
7988static struct hda_bind_ctls alc883_bind_cap_switch = {
7989 .ops = &snd_hda_bind_sw,
7990 .values = {
7991 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7992 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7993 0
7994 },
7995};
7996
7997static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7998 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7999 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8000 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8001 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8002 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8003 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8004 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8005 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008006 { } /* end */
8007};
8008
8009static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008010 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8011 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8012 {
8013 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8014 /* .name = "Capture Source", */
8015 .name = "Input Source",
8016 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008017 .info = alc_mux_enum_info,
8018 .get = alc_mux_enum_get,
8019 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008020 },
8021 { } /* end */
8022};
8023
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008024static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8025 {
8026 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8027 .name = "Channel Mode",
8028 .info = alc_ch_mode_info,
8029 .get = alc_ch_mode_get,
8030 .put = alc_ch_mode_put,
8031 },
8032 { } /* end */
8033};
8034
8035static struct hda_verb alc883_init_verbs[] = {
8036 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02008037 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008038 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8039 /* ADC2: mute amp left and right */
8040 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8041 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8042 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8043 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8044 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8045 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8046 /* Rear mixer */
8047 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8048 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8049 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8050 /* CLFE mixer */
8051 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8052 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8053 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8054 /* Side mixer */
8055 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8056 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8057 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8058
Takashi Iwaicb53c622007-08-10 17:21:45 +02008059 /* mute analog input loopbacks */
8060 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008065
8066 /* Front Pin: output 0 (0x0c) */
8067 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8068 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8069 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8070 /* Rear Pin: output 1 (0x0d) */
8071 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8073 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8074 /* CLFE Pin: output 2 (0x0e) */
8075 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8076 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8077 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8078 /* Side Pin: output 3 (0x0f) */
8079 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8080 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8081 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8082 /* Mic (rear) pin: input vref at 80% */
8083 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8084 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8085 /* Front Mic pin: input vref at 80% */
8086 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8087 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8088 /* Line In pin: input */
8089 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8090 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8091 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8092 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8093 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8094 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8095 /* CD pin widget for input */
8096 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8097
8098 /* FIXME: use matrix-type input source selection */
8099 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8100 /* Input mixer2 */
8101 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008102 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8103 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8104 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008105 /* Input mixer3 */
8106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8108 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008110 { }
8111};
8112
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008113/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008114static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008115{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008116 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008117
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008118 spec->autocfg.hp_pins[0] = 0x15;
8119 spec->autocfg.speaker_pins[0] = 0x14;
8120 spec->autocfg.speaker_pins[1] = 0x17;
8121 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008122}
8123
8124/* auto-toggle front mic */
8125/*
8126static void alc883_mitac_mic_automute(struct hda_codec *codec)
8127{
8128 unsigned int present;
8129 unsigned char bits;
8130
8131 present = snd_hda_codec_read(codec, 0x18, 0,
8132 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8133 bits = present ? HDA_AMP_MUTE : 0;
8134 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8135}
8136*/
8137
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008138static struct hda_verb alc883_mitac_verbs[] = {
8139 /* HP */
8140 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8141 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8142 /* Subwoofer */
8143 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8144 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8145
8146 /* enable unsolicited event */
8147 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8148 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8149
8150 { } /* end */
8151};
8152
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008153static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008154 /* HP */
8155 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8156 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8157 /* Int speaker */
8158 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8159 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8160
8161 /* enable unsolicited event */
8162 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008163 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008164
8165 { } /* end */
8166};
8167
Jiang zhefb97dc62008-03-06 11:07:11 +01008168static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8169 /* HP */
8170 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8171 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8172 /* Subwoofer */
8173 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8174 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8175
8176 /* enable unsolicited event */
8177 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8178
8179 { } /* end */
8180};
8181
Kailang Yangccc656c2006-10-17 12:32:26 +02008182static struct hda_verb alc883_tagra_verbs[] = {
8183 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8184 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8185
8186 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8187 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008188
Kailang Yangccc656c2006-10-17 12:32:26 +02008189 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8190 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8191 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8192
8193 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008194 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
8195 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
8196 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02008197
8198 { } /* end */
8199};
8200
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008201static struct hda_verb alc883_lenovo_101e_verbs[] = {
8202 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8203 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8204 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8205 { } /* end */
8206};
8207
Kailang Yang272a5272007-05-14 11:00:38 +02008208static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8209 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8210 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8211 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8212 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8213 { } /* end */
8214};
8215
8216static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8217 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8218 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8219 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8220 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8221 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8222 { } /* end */
8223};
8224
Kailang Yang189609a2007-08-20 11:31:23 +02008225static struct hda_verb alc883_haier_w66_verbs[] = {
8226 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8227 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8228
8229 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8230
8231 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8232 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8233 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8234 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8235 { } /* end */
8236};
8237
Kailang Yange2757d52008-08-26 13:17:46 +02008238static struct hda_verb alc888_lenovo_sky_verbs[] = {
8239 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8240 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8241 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8242 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8243 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8244 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8245 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8246 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8247 { } /* end */
8248};
8249
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008250static struct hda_verb alc888_6st_dell_verbs[] = {
8251 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8252 { }
8253};
8254
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008255static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008256{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008257 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008258
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008259 spec->autocfg.hp_pins[0] = 0x1b;
8260 spec->autocfg.speaker_pins[0] = 0x14;
8261 spec->autocfg.speaker_pins[1] = 0x16;
8262 spec->autocfg.speaker_pins[2] = 0x18;
8263 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008264}
8265
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008266static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008267 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008268 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8269 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008270 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008271 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008272};
8273
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008274/*
8275 * 2ch mode
8276 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008277static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008278 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8279 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8280 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8281 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008282 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008283};
8284
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008285/*
8286 * 4ch mode
8287 */
8288static struct hda_verb alc888_3st_hp_4ch_init[] = {
8289 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8290 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8291 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8292 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8293 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8294 { } /* end */
8295};
8296
8297/*
8298 * 6ch mode
8299 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008300static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008301 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8302 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008303 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008304 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8305 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008306 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8307 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008308};
8309
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008310static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008311 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008312 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008313 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008314};
8315
Kailang Yang272a5272007-05-14 11:00:38 +02008316/* toggle front-jack and RCA according to the hp-jack state */
8317static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8318{
8319 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008320
Kailang Yang272a5272007-05-14 11:00:38 +02008321 present = snd_hda_codec_read(codec, 0x1b, 0,
8322 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008323 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8324 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8325 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8326 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008327}
8328
8329/* toggle RCA according to the front-jack state */
8330static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8331{
8332 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008333
Kailang Yang272a5272007-05-14 11:00:38 +02008334 present = snd_hda_codec_read(codec, 0x14, 0,
8335 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008336 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8337 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008338}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008339
Kailang Yang272a5272007-05-14 11:00:38 +02008340static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8341 unsigned int res)
8342{
8343 if ((res >> 26) == ALC880_HP_EVENT)
8344 alc888_lenovo_ms7195_front_automute(codec);
8345 if ((res >> 26) == ALC880_FRONT_EVENT)
8346 alc888_lenovo_ms7195_rca_automute(codec);
8347}
8348
8349static struct hda_verb alc883_medion_md2_verbs[] = {
8350 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8351 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8352
8353 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8354
8355 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8356 { } /* end */
8357};
8358
8359/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008360static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008361{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008362 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008363
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008364 spec->autocfg.hp_pins[0] = 0x14;
8365 spec->autocfg.speaker_pins[0] = 0x15;
8366 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008367}
8368
Kailang Yangccc656c2006-10-17 12:32:26 +02008369/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008370#define alc883_tagra_init_hook alc882_targa_init_hook
8371#define alc883_tagra_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008372
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008373static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8374{
8375 unsigned int present;
8376
8377 present = snd_hda_codec_read(codec, 0x18, 0,
8378 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8379 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8380 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8381}
8382
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008383static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008384{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008385 struct alc_spec *spec = codec->spec;
8386
8387 spec->autocfg.hp_pins[0] = 0x15;
8388 spec->autocfg.speaker_pins[0] = 0x14;
8389 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008390 alc883_clevo_m720_mic_automute(codec);
8391}
8392
8393static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008394 unsigned int res)
8395{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008396 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008397 case ALC880_MIC_EVENT:
8398 alc883_clevo_m720_mic_automute(codec);
8399 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008400 default:
8401 alc_automute_amp_unsol_event(codec, res);
8402 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008403 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008404}
8405
Jiang zhefb97dc62008-03-06 11:07:11 +01008406/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008407static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008408{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008409 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008410
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008411 spec->autocfg.hp_pins[0] = 0x14;
8412 spec->autocfg.speaker_pins[0] = 0x15;
8413 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008414}
8415
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008416static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008417{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008418 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008419
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008420 spec->autocfg.hp_pins[0] = 0x1b;
8421 spec->autocfg.speaker_pins[0] = 0x14;
8422 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008423}
8424
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008425static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8426{
8427 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008428 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008429
8430 present = snd_hda_codec_read(codec, 0x14, 0,
8431 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008432 bits = present ? HDA_AMP_MUTE : 0;
8433 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8434 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008435}
8436
8437static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8438{
8439 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008440 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008441
8442 present = snd_hda_codec_read(codec, 0x1b, 0,
8443 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008444 bits = present ? HDA_AMP_MUTE : 0;
8445 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8446 HDA_AMP_MUTE, bits);
8447 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8448 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008449}
8450
8451static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8452 unsigned int res)
8453{
8454 if ((res >> 26) == ALC880_HP_EVENT)
8455 alc883_lenovo_101e_all_automute(codec);
8456 if ((res >> 26) == ALC880_FRONT_EVENT)
8457 alc883_lenovo_101e_ispeaker_automute(codec);
8458}
8459
Takashi Iwai676a9b52007-08-16 15:23:35 +02008460/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008461static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008462{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008463 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008464
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008465 spec->autocfg.hp_pins[0] = 0x14;
8466 spec->autocfg.speaker_pins[0] = 0x15;
8467 spec->autocfg.speaker_pins[1] = 0x16;
8468 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008469}
8470
Kailang Yangd1a991a2007-08-15 16:21:59 +02008471static struct hda_verb alc883_acer_eapd_verbs[] = {
8472 /* HP Pin: output 0 (0x0c) */
8473 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8474 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8475 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8476 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008477 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8478 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008479 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008480 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8481 /* eanable EAPD on medion laptop */
8482 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8483 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008484 /* enable unsolicited event */
8485 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008486 { }
8487};
8488
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008489static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008490{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008491 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008492
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008493 spec->autocfg.hp_pins[0] = 0x1b;
8494 spec->autocfg.speaker_pins[0] = 0x14;
8495 spec->autocfg.speaker_pins[1] = 0x15;
8496 spec->autocfg.speaker_pins[2] = 0x16;
8497 spec->autocfg.speaker_pins[3] = 0x17;
8498 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008499}
8500
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008501static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008502{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008503 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008504
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008505 spec->autocfg.hp_pins[0] = 0x1b;
8506 spec->autocfg.speaker_pins[0] = 0x14;
8507 spec->autocfg.speaker_pins[1] = 0x15;
8508 spec->autocfg.speaker_pins[2] = 0x16;
8509 spec->autocfg.speaker_pins[3] = 0x17;
8510 spec->autocfg.speaker_pins[4] = 0x1a;
8511 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008512}
8513
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008514/*
8515 * generic initialization of ADC, input mixers and output mixers
8516 */
8517static struct hda_verb alc883_auto_init_verbs[] = {
8518 /*
8519 * Unmute ADC0-2 and set the default input to mic-in
8520 */
8521 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8522 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8523 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8524 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8525
Takashi Iwaicb53c622007-08-10 17:21:45 +02008526 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008527 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008528 * Note: PASD motherboards uses the Line In 2 as the input for
8529 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008530 */
8531 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008532 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8533 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8534 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8535 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8536 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008537
8538 /*
8539 * Set up output mixers (0x0c - 0x0f)
8540 */
8541 /* set vol=0 to output mixers */
8542 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8543 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8544 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8545 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8546 /* set up input amps for analog loopback */
8547 /* Amp Indices: DAC = 0, mixer = 1 */
8548 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8549 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8550 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8551 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8552 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8553 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8554 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8555 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8556 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8557 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8558
8559 /* FIXME: use matrix-type input source selection */
8560 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8561 /* Input mixer1 */
8562 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8563 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8564 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008565 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008566 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8567 /* Input mixer2 */
8568 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8569 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8570 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008571 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008573
8574 { }
8575};
8576
Kailang Yange2757d52008-08-26 13:17:46 +02008577static struct hda_verb alc888_asus_m90v_verbs[] = {
8578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8579 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8580 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8581 /* enable unsolicited event */
8582 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8583 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8584 { } /* end */
8585};
8586
8587static void alc883_nb_mic_automute(struct hda_codec *codec)
8588{
8589 unsigned int present;
8590
8591 present = snd_hda_codec_read(codec, 0x18, 0,
8592 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8593 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8594 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8595 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8596 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8597}
8598
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008599static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008600{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008601 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008602
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008603 spec->autocfg.hp_pins[0] = 0x1b;
8604 spec->autocfg.speaker_pins[0] = 0x14;
8605 spec->autocfg.speaker_pins[1] = 0x15;
8606 spec->autocfg.speaker_pins[2] = 0x16;
8607 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008608}
8609
8610static void alc883_mode2_unsol_event(struct hda_codec *codec,
8611 unsigned int res)
8612{
8613 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008614 case ALC880_MIC_EVENT:
8615 alc883_nb_mic_automute(codec);
8616 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008617 default:
8618 alc_sku_unsol_event(codec, res);
8619 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008620 }
8621}
8622
8623static void alc883_mode2_inithook(struct hda_codec *codec)
8624{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008625 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008626 alc883_nb_mic_automute(codec);
8627}
8628
8629static struct hda_verb alc888_asus_eee1601_verbs[] = {
8630 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8631 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8632 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8633 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8634 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8635 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8636 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8637 /* enable unsolicited event */
8638 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8639 { } /* end */
8640};
8641
Kailang Yange2757d52008-08-26 13:17:46 +02008642static void alc883_eee1601_inithook(struct hda_codec *codec)
8643{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008644 struct alc_spec *spec = codec->spec;
8645
8646 spec->autocfg.hp_pins[0] = 0x14;
8647 spec->autocfg.speaker_pins[0] = 0x1b;
8648 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008649}
8650
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008651static struct hda_verb alc889A_mb31_verbs[] = {
8652 /* Init rear pin (used as headphone output) */
8653 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8654 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8655 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8656 /* Init line pin (used as output in 4ch and 6ch mode) */
8657 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8658 /* Init line 2 pin (used as headphone out by default) */
8659 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8660 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8661 { } /* end */
8662};
8663
8664/* Mute speakers according to the headphone jack state */
8665static void alc889A_mb31_automute(struct hda_codec *codec)
8666{
8667 unsigned int present;
8668
8669 /* Mute only in 2ch or 4ch mode */
8670 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8671 == 0x00) {
8672 present = snd_hda_codec_read(codec, 0x15, 0,
8673 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8674 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8675 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8676 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8677 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8678 }
8679}
8680
8681static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8682{
8683 if ((res >> 26) == ALC880_HP_EVENT)
8684 alc889A_mb31_automute(codec);
8685}
8686
Takashi Iwaicb53c622007-08-10 17:21:45 +02008687#ifdef CONFIG_SND_HDA_POWER_SAVE
8688#define alc883_loopbacks alc880_loopbacks
8689#endif
8690
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008691/* pcm configuration: identiacal with ALC880 */
8692#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8693#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008694#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008695#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8696#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8697
8698/*
8699 * configuration and preset
8700 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008701static const char *alc883_models[ALC883_MODEL_LAST] = {
8702 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8703 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8704 [ALC883_3ST_6ch] = "3stack-6ch",
8705 [ALC883_6ST_DIG] = "6stack-dig",
8706 [ALC883_TARGA_DIG] = "targa-dig",
8707 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008708 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008709 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008710 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008711 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008712 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008713 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008714 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008715 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8716 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008717 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008718 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008719 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008720 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008721 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008722 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008723 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008724 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008725 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008726 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008727 [ALC889A_MB31] = "mb31",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008728 [ALC883_AUTO] = "auto",
8729};
8730
8731static struct snd_pci_quirk alc883_cfg_tbl[] = {
8732 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008733 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008734 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008735 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008736 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8737 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008738 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008739 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8740 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008741 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8742 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01008743 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01008744 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008745 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8746 ALC888_ACER_ASPIRE_4930G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008747 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8748 ALC888_ACER_ASPIRE_4930G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008749 /* default Acer -- disabled as it causes more problems.
8750 * model=auto should work fine now
8751 */
8752 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008753 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008754 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008755 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8756 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008757 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008758 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008759 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008760 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008761 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008762 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008763 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008764 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008765 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008766 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008767 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008768 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8769 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008770 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008771 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008772 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008773 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8774 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8775 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008776 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008777 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008778 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008779 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8780 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8781 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8782 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8783 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8784 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8785 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8786 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8787 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008788 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8789 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008790 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008791 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008792 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008793 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008794 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008795 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008796 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008797 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8798 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008799 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008800 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008801 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008802 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008803 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008804 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008805 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008806 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008807 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008808 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8809 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008810 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008811 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008812 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008813 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008814 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008815 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8816 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008817 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008818 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008819 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008820 {}
8821};
8822
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008823static hda_nid_t alc883_slave_dig_outs[] = {
8824 ALC1200_DIGOUT_NID, 0,
8825};
8826
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008827static hda_nid_t alc1200_slave_dig_outs[] = {
8828 ALC883_DIGOUT_NID, 0,
8829};
8830
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008831static struct alc_config_preset alc883_presets[] = {
8832 [ALC883_3ST_2ch_DIG] = {
8833 .mixers = { alc883_3ST_2ch_mixer },
8834 .init_verbs = { alc883_init_verbs },
8835 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8836 .dac_nids = alc883_dac_nids,
8837 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008838 .dig_in_nid = ALC883_DIGIN_NID,
8839 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8840 .channel_mode = alc883_3ST_2ch_modes,
8841 .input_mux = &alc883_capture_source,
8842 },
8843 [ALC883_3ST_6ch_DIG] = {
8844 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8845 .init_verbs = { alc883_init_verbs },
8846 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8847 .dac_nids = alc883_dac_nids,
8848 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008849 .dig_in_nid = ALC883_DIGIN_NID,
8850 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8851 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008852 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008853 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008854 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008855 [ALC883_3ST_6ch] = {
8856 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8857 .init_verbs = { alc883_init_verbs },
8858 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8859 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008860 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8861 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008862 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008863 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008864 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008865 [ALC883_3ST_6ch_INTEL] = {
8866 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8867 .init_verbs = { alc883_init_verbs },
8868 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8869 .dac_nids = alc883_dac_nids,
8870 .dig_out_nid = ALC883_DIGOUT_NID,
8871 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008872 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02008873 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8874 .channel_mode = alc883_3ST_6ch_intel_modes,
8875 .need_dac_fix = 1,
8876 .input_mux = &alc883_3stack_6ch_intel,
8877 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008878 [ALC883_6ST_DIG] = {
8879 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8880 .init_verbs = { alc883_init_verbs },
8881 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8882 .dac_nids = alc883_dac_nids,
8883 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008884 .dig_in_nid = ALC883_DIGIN_NID,
8885 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8886 .channel_mode = alc883_sixstack_modes,
8887 .input_mux = &alc883_capture_source,
8888 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008889 [ALC883_TARGA_DIG] = {
8890 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8891 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8892 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8893 .dac_nids = alc883_dac_nids,
8894 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008895 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8896 .channel_mode = alc883_3ST_6ch_modes,
8897 .need_dac_fix = 1,
8898 .input_mux = &alc883_capture_source,
8899 .unsol_event = alc883_tagra_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008900 .init_hook = alc883_tagra_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02008901 },
8902 [ALC883_TARGA_2ch_DIG] = {
8903 .mixers = { alc883_tagra_2ch_mixer},
8904 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8905 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8906 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008907 .adc_nids = alc883_adc_nids_alt,
8908 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008909 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008910 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8911 .channel_mode = alc883_3ST_2ch_modes,
8912 .input_mux = &alc883_capture_source,
8913 .unsol_event = alc883_tagra_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008914 .init_hook = alc883_tagra_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02008915 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008916 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008917 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008918 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8919 * and the headphone jack. Turn this on and rely on the
8920 * standard mute methods whenever the user wants to turn
8921 * these outputs off.
8922 */
8923 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8924 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8925 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008926 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8927 .channel_mode = alc883_3ST_2ch_modes,
8928 .input_mux = &alc883_capture_source,
8929 },
Tobin Davis2880a862007-08-07 11:50:26 +02008930 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008931 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008932 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008933 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8934 .dac_nids = alc883_dac_nids,
8935 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008936 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8937 .channel_mode = alc883_3ST_2ch_modes,
8938 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008939 .unsol_event = alc_automute_amp_unsol_event,
8940 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008941 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008942 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008943 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008944 alc883_chmode_mixer },
8945 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8946 alc888_acer_aspire_4930g_verbs },
8947 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8948 .dac_nids = alc883_dac_nids,
8949 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8950 .adc_nids = alc883_adc_nids_rev,
8951 .capsrc_nids = alc883_capsrc_nids_rev,
8952 .dig_out_nid = ALC883_DIGOUT_NID,
8953 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8954 .channel_mode = alc883_3ST_6ch_modes,
8955 .need_dac_fix = 1,
8956 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008957 ARRAY_SIZE(alc888_2_capture_sources),
8958 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008959 .unsol_event = alc_automute_amp_unsol_event,
8960 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008961 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008962 [ALC883_MEDION] = {
8963 .mixers = { alc883_fivestack_mixer,
8964 alc883_chmode_mixer },
8965 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008966 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008967 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8968 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008969 .adc_nids = alc883_adc_nids_alt,
8970 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008971 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8972 .channel_mode = alc883_sixstack_modes,
8973 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008974 },
Kailang Yang272a5272007-05-14 11:00:38 +02008975 [ALC883_MEDION_MD2] = {
8976 .mixers = { alc883_medion_md2_mixer},
8977 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8978 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8979 .dac_nids = alc883_dac_nids,
8980 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008981 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8982 .channel_mode = alc883_3ST_2ch_modes,
8983 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008984 .unsol_event = alc_automute_amp_unsol_event,
8985 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02008986 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008987 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008988 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008989 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8990 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8991 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008992 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8993 .channel_mode = alc883_3ST_2ch_modes,
8994 .input_mux = &alc883_capture_source,
8995 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008996 [ALC883_CLEVO_M720] = {
8997 .mixers = { alc883_clevo_m720_mixer },
8998 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008999 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9000 .dac_nids = alc883_dac_nids,
9001 .dig_out_nid = ALC883_DIGOUT_NID,
9002 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9003 .channel_mode = alc883_3ST_2ch_modes,
9004 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009005 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009006 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009007 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009008 [ALC883_LENOVO_101E_2ch] = {
9009 .mixers = { alc883_lenovo_101e_2ch_mixer},
9010 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9011 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9012 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009013 .adc_nids = alc883_adc_nids_alt,
9014 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009015 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9016 .channel_mode = alc883_3ST_2ch_modes,
9017 .input_mux = &alc883_lenovo_101e_capture_source,
9018 .unsol_event = alc883_lenovo_101e_unsol_event,
9019 .init_hook = alc883_lenovo_101e_all_automute,
9020 },
Kailang Yang272a5272007-05-14 11:00:38 +02009021 [ALC883_LENOVO_NB0763] = {
9022 .mixers = { alc883_lenovo_nb0763_mixer },
9023 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9024 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9025 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009026 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9027 .channel_mode = alc883_3ST_2ch_modes,
9028 .need_dac_fix = 1,
9029 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009030 .unsol_event = alc_automute_amp_unsol_event,
9031 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02009032 },
9033 [ALC888_LENOVO_MS7195_DIG] = {
9034 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9035 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9036 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9037 .dac_nids = alc883_dac_nids,
9038 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009039 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9040 .channel_mode = alc883_3ST_6ch_modes,
9041 .need_dac_fix = 1,
9042 .input_mux = &alc883_capture_source,
9043 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9044 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009045 },
9046 [ALC883_HAIER_W66] = {
9047 .mixers = { alc883_tagra_2ch_mixer},
9048 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9049 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9050 .dac_nids = alc883_dac_nids,
9051 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009052 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9053 .channel_mode = alc883_3ST_2ch_modes,
9054 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009055 .unsol_event = alc_automute_amp_unsol_event,
9056 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009057 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009058 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009059 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009060 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009061 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9062 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009063 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9064 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009065 .need_dac_fix = 1,
9066 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009067 .unsol_event = alc_automute_amp_unsol_event,
9068 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009069 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009070 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009071 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009072 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9073 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9074 .dac_nids = alc883_dac_nids,
9075 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009076 .dig_in_nid = ALC883_DIGIN_NID,
9077 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9078 .channel_mode = alc883_sixstack_modes,
9079 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009080 .unsol_event = alc_automute_amp_unsol_event,
9081 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009082 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009083 [ALC883_MITAC] = {
9084 .mixers = { alc883_mitac_mixer },
9085 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9086 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9087 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009088 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9089 .channel_mode = alc883_3ST_2ch_modes,
9090 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009091 .unsol_event = alc_automute_amp_unsol_event,
9092 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009093 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009094 [ALC883_FUJITSU_PI2515] = {
9095 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9096 .init_verbs = { alc883_init_verbs,
9097 alc883_2ch_fujitsu_pi2515_verbs},
9098 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9099 .dac_nids = alc883_dac_nids,
9100 .dig_out_nid = ALC883_DIGOUT_NID,
9101 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9102 .channel_mode = alc883_3ST_2ch_modes,
9103 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009104 .unsol_event = alc_automute_amp_unsol_event,
9105 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01009106 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009107 [ALC888_FUJITSU_XA3530] = {
9108 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9109 .init_verbs = { alc883_init_verbs,
9110 alc888_fujitsu_xa3530_verbs },
9111 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9112 .dac_nids = alc883_dac_nids,
9113 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9114 .adc_nids = alc883_adc_nids_rev,
9115 .capsrc_nids = alc883_capsrc_nids_rev,
9116 .dig_out_nid = ALC883_DIGOUT_NID,
9117 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9118 .channel_mode = alc888_4ST_8ch_intel_modes,
9119 .num_mux_defs =
9120 ARRAY_SIZE(alc888_2_capture_sources),
9121 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009122 .unsol_event = alc_automute_amp_unsol_event,
9123 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009124 },
Kailang Yange2757d52008-08-26 13:17:46 +02009125 [ALC888_LENOVO_SKY] = {
9126 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9127 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9128 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9129 .dac_nids = alc883_dac_nids,
9130 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009131 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9132 .channel_mode = alc883_sixstack_modes,
9133 .need_dac_fix = 1,
9134 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009135 .unsol_event = alc_automute_amp_unsol_event,
9136 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009137 },
9138 [ALC888_ASUS_M90V] = {
9139 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9140 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9141 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9142 .dac_nids = alc883_dac_nids,
9143 .dig_out_nid = ALC883_DIGOUT_NID,
9144 .dig_in_nid = ALC883_DIGIN_NID,
9145 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9146 .channel_mode = alc883_3ST_6ch_modes,
9147 .need_dac_fix = 1,
9148 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9149 .unsol_event = alc883_mode2_unsol_event,
9150 .init_hook = alc883_mode2_inithook,
9151 },
9152 [ALC888_ASUS_EEE1601] = {
9153 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009154 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009155 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9156 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9157 .dac_nids = alc883_dac_nids,
9158 .dig_out_nid = ALC883_DIGOUT_NID,
9159 .dig_in_nid = ALC883_DIGIN_NID,
9160 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9161 .channel_mode = alc883_3ST_2ch_modes,
9162 .need_dac_fix = 1,
9163 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009164 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009165 .init_hook = alc883_eee1601_inithook,
9166 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009167 [ALC1200_ASUS_P5Q] = {
9168 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9169 .init_verbs = { alc883_init_verbs },
9170 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9171 .dac_nids = alc883_dac_nids,
9172 .dig_out_nid = ALC1200_DIGOUT_NID,
9173 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009174 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009175 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9176 .channel_mode = alc883_sixstack_modes,
9177 .input_mux = &alc883_capture_source,
9178 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009179 [ALC889A_MB31] = {
9180 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9181 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9182 alc880_gpio1_init_verbs },
9183 .adc_nids = alc883_adc_nids,
9184 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9185 .dac_nids = alc883_dac_nids,
9186 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9187 .channel_mode = alc889A_mb31_6ch_modes,
9188 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9189 .input_mux = &alc889A_mb31_capture_source,
9190 .dig_out_nid = ALC883_DIGOUT_NID,
9191 .unsol_event = alc889A_mb31_unsol_event,
9192 .init_hook = alc889A_mb31_automute,
9193 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009194};
9195
9196
9197/*
9198 * BIOS auto configuration
9199 */
9200static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9201 hda_nid_t nid, int pin_type,
9202 int dac_idx)
9203{
9204 /* set as output */
9205 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009206 int idx;
9207
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009208 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009209 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9210 idx = 4;
9211 else
9212 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009213 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9214
9215}
9216
9217static void alc883_auto_init_multi_out(struct hda_codec *codec)
9218{
9219 struct alc_spec *spec = codec->spec;
9220 int i;
9221
9222 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009223 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009224 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009225 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009226 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009227 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009228 }
9229}
9230
9231static void alc883_auto_init_hp_out(struct hda_codec *codec)
9232{
9233 struct alc_spec *spec = codec->spec;
9234 hda_nid_t pin;
9235
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009236 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009237 if (pin) /* connect to front */
9238 /* use dac 0 */
9239 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009240 pin = spec->autocfg.speaker_pins[0];
9241 if (pin)
9242 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009243}
9244
9245#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9246#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9247
9248static void alc883_auto_init_analog_input(struct hda_codec *codec)
9249{
9250 struct alc_spec *spec = codec->spec;
9251 int i;
9252
9253 for (i = 0; i < AUTO_PIN_LAST; i++) {
9254 hda_nid_t nid = spec->autocfg.input_pins[i];
9255 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009256 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01009257 if (nid != ALC883_PIN_CD_NID &&
9258 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009259 snd_hda_codec_write(codec, nid, 0,
9260 AC_VERB_SET_AMP_GAIN_MUTE,
9261 AMP_OUT_MUTE);
9262 }
9263 }
9264}
9265
Takashi Iwaif511b012008-08-15 16:46:42 +02009266#define alc883_auto_init_input_src alc882_auto_init_input_src
9267
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009268/* almost identical with ALC880 parser... */
9269static int alc883_parse_auto_config(struct hda_codec *codec)
9270{
9271 struct alc_spec *spec = codec->spec;
9272 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009273 struct auto_pin_cfg *cfg = &spec->autocfg;
9274 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009275
9276 if (err < 0)
9277 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009278 else if (!err)
9279 return 0; /* no config found */
9280
9281 err = alc_auto_add_mic_boost(codec);
9282 if (err < 0)
9283 return err;
9284
9285 /* hack - override the init verbs */
9286 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009287
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009288 /* setup input_mux for ALC889 */
9289 if (codec->vendor_id == 0x10ec0889) {
9290 /* digital-mic input pin is excluded in alc880_auto_create..()
9291 * because it's under 0x18
9292 */
9293 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9294 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9295 struct hda_input_mux *imux = &spec->private_imux[0];
9296 for (i = 1; i < 3; i++)
9297 memcpy(&spec->private_imux[i],
9298 &spec->private_imux[0],
9299 sizeof(spec->private_imux[0]));
9300 imux->items[imux->num_items].label = "Int DMic";
9301 imux->items[imux->num_items].index = 0x0b;
9302 imux->num_items++;
9303 spec->num_mux_defs = 3;
9304 spec->input_mux = spec->private_imux;
9305 }
9306 }
9307
Takashi Iwai776e1842007-08-29 15:07:11 +02009308 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009309}
9310
9311/* additional initialization for auto-configuration model */
9312static void alc883_auto_init(struct hda_codec *codec)
9313{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009314 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009315 alc883_auto_init_multi_out(codec);
9316 alc883_auto_init_hp_out(codec);
9317 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009318 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009319 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009320 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009321}
9322
9323static int patch_alc883(struct hda_codec *codec)
9324{
9325 struct alc_spec *spec;
9326 int err, board_config;
9327
9328 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9329 if (spec == NULL)
9330 return -ENOMEM;
9331
9332 codec->spec = spec;
9333
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009334 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9335
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009336 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9337 alc883_models,
9338 alc883_cfg_tbl);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009339 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
9340 /* Pick up systems that don't supply PCI SSID */
9341 switch (codec->subsystem_id) {
9342 case 0x106b3600: /* Macbook 3.1 */
9343 board_config = ALC889A_MB31;
9344 break;
9345 default:
9346 printk(KERN_INFO
9347 "hda_codec: Unknown model for %s, trying "
9348 "auto-probe from BIOS...\n", codec->chip_name);
9349 board_config = ALC883_AUTO;
9350 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009351 }
9352
9353 if (board_config == ALC883_AUTO) {
9354 /* automatic parse from the BIOS config */
9355 err = alc883_parse_auto_config(codec);
9356 if (err < 0) {
9357 alc_free(codec);
9358 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009359 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009360 printk(KERN_INFO
9361 "hda_codec: Cannot set up configuration "
9362 "from BIOS. Using base mode...\n");
9363 board_config = ALC883_3ST_2ch_DIG;
9364 }
9365 }
9366
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009367 err = snd_hda_attach_beep_device(codec, 0x1);
9368 if (err < 0) {
9369 alc_free(codec);
9370 return err;
9371 }
9372
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009373 if (board_config != ALC883_AUTO)
9374 setup_preset(spec, &alc883_presets[board_config]);
9375
Kailang Yang2f893282008-05-27 12:14:47 +02009376 switch (codec->vendor_id) {
9377 case 0x10ec0888:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009378 if (!spec->num_adc_nids) {
9379 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9380 spec->adc_nids = alc883_adc_nids;
9381 }
9382 if (!spec->capsrc_nids)
9383 spec->capsrc_nids = alc883_capsrc_nids;
9384 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009385 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Kailang Yang2f893282008-05-27 12:14:47 +02009386 break;
9387 case 0x10ec0889:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009388 if (!spec->num_adc_nids) {
9389 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9390 spec->adc_nids = alc889_adc_nids;
9391 }
9392 if (!spec->capsrc_nids)
9393 spec->capsrc_nids = alc889_capsrc_nids;
9394 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9395 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009396 break;
9397 default:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009398 if (!spec->num_adc_nids) {
9399 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9400 spec->adc_nids = alc883_adc_nids;
9401 }
9402 if (!spec->capsrc_nids)
9403 spec->capsrc_nids = alc883_capsrc_nids;
9404 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009405 break;
9406 }
9407
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009408 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9409 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009410 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009411
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009412 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9413 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9414
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009415 if (!spec->cap_mixer)
9416 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009417 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009418
Takashi Iwai2134ea42008-01-10 16:53:55 +01009419 spec->vmaster_nid = 0x0c;
9420
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009421 codec->patch_ops = alc_patch_ops;
9422 if (board_config == ALC883_AUTO)
9423 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009424
Takashi Iwaicb53c622007-08-10 17:21:45 +02009425#ifdef CONFIG_SND_HDA_POWER_SAVE
9426 if (!spec->loopback.amplist)
9427 spec->loopback.amplist = alc883_loopbacks;
9428#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009429 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009430
9431 return 0;
9432}
9433
9434/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009435 * ALC262 support
9436 */
9437
9438#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9439#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9440
9441#define alc262_dac_nids alc260_dac_nids
9442#define alc262_adc_nids alc882_adc_nids
9443#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009444#define alc262_capsrc_nids alc882_capsrc_nids
9445#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009446
9447#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009448#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009449
Kailang Yang4e555fe2008-08-26 13:05:55 +02009450static hda_nid_t alc262_dmic_adc_nids[1] = {
9451 /* ADC0 */
9452 0x09
9453};
9454
9455static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9456
Kailang Yangdf694da2005-12-05 19:42:22 +01009457static struct snd_kcontrol_new alc262_base_mixer[] = {
9458 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9459 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9460 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9461 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9462 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9463 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9464 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9465 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009466 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009467 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9468 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009469 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009470 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9471 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9472 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9473 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009474 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009475};
9476
Takashi Iwaice875f02008-01-28 18:17:43 +01009477/* update HP, line and mono-out pins according to the master switch */
9478static void alc262_hp_master_update(struct hda_codec *codec)
9479{
9480 struct alc_spec *spec = codec->spec;
9481 int val = spec->master_sw;
9482
9483 /* HP & line-out */
9484 snd_hda_codec_write_cache(codec, 0x1b, 0,
9485 AC_VERB_SET_PIN_WIDGET_CONTROL,
9486 val ? PIN_HP : 0);
9487 snd_hda_codec_write_cache(codec, 0x15, 0,
9488 AC_VERB_SET_PIN_WIDGET_CONTROL,
9489 val ? PIN_HP : 0);
9490 /* mono (speaker) depending on the HP jack sense */
9491 val = val && !spec->jack_present;
9492 snd_hda_codec_write_cache(codec, 0x16, 0,
9493 AC_VERB_SET_PIN_WIDGET_CONTROL,
9494 val ? PIN_OUT : 0);
9495}
9496
9497static void alc262_hp_bpc_automute(struct hda_codec *codec)
9498{
9499 struct alc_spec *spec = codec->spec;
9500 unsigned int presence;
9501 presence = snd_hda_codec_read(codec, 0x1b, 0,
9502 AC_VERB_GET_PIN_SENSE, 0);
9503 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9504 alc262_hp_master_update(codec);
9505}
9506
9507static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9508{
9509 if ((res >> 26) != ALC880_HP_EVENT)
9510 return;
9511 alc262_hp_bpc_automute(codec);
9512}
9513
9514static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9515{
9516 struct alc_spec *spec = codec->spec;
9517 unsigned int presence;
9518 presence = snd_hda_codec_read(codec, 0x15, 0,
9519 AC_VERB_GET_PIN_SENSE, 0);
9520 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9521 alc262_hp_master_update(codec);
9522}
9523
9524static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9525 unsigned int res)
9526{
9527 if ((res >> 26) != ALC880_HP_EVENT)
9528 return;
9529 alc262_hp_wildwest_automute(codec);
9530}
9531
Takashi Iwaib72519b2009-05-08 14:31:55 +02009532#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009533
9534static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9535 struct snd_ctl_elem_value *ucontrol)
9536{
9537 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9538 struct alc_spec *spec = codec->spec;
9539 int val = !!*ucontrol->value.integer.value;
9540
9541 if (val == spec->master_sw)
9542 return 0;
9543 spec->master_sw = val;
9544 alc262_hp_master_update(codec);
9545 return 1;
9546}
9547
Takashi Iwaib72519b2009-05-08 14:31:55 +02009548#define ALC262_HP_MASTER_SWITCH \
9549 { \
9550 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9551 .name = "Master Playback Switch", \
9552 .info = snd_ctl_boolean_mono_info, \
9553 .get = alc262_hp_master_sw_get, \
9554 .put = alc262_hp_master_sw_put, \
9555 }
9556
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009557static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009558 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009559 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9560 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9561 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009562 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9563 HDA_OUTPUT),
9564 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9565 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009566 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9567 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009568 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009569 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9570 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009571 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009572 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9573 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9574 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9575 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009576 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9577 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9578 { } /* end */
9579};
9580
Kailang Yangcd7509a2007-01-26 18:33:17 +01009581static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009582 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009583 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9584 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9585 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9586 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009587 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9588 HDA_OUTPUT),
9589 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9590 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009591 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9592 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009593 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009594 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9595 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9596 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9597 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009598 { } /* end */
9599};
9600
9601static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9602 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9603 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009604 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009605 { } /* end */
9606};
9607
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009608/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009609static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009610{
9611 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009612
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009613 spec->autocfg.hp_pins[0] = 0x15;
9614 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
9615 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009616}
9617
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009618static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009619 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9620 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009621 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9622 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9623 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9624 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9625 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9626 { } /* end */
9627};
9628
9629static struct hda_verb alc262_hp_t5735_verbs[] = {
9630 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9631 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9632
9633 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9634 { }
9635};
9636
Kailang Yang8c427222008-01-10 13:03:59 +01009637static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009638 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9639 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009640 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9641 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009642 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9643 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9644 { } /* end */
9645};
9646
9647static struct hda_verb alc262_hp_rp5700_verbs[] = {
9648 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9649 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9650 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9651 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9652 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9653 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9654 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9655 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9656 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9657 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9658 {}
9659};
9660
9661static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9662 .num_items = 1,
9663 .items = {
9664 { "Line", 0x1 },
9665 },
9666};
9667
Takashi Iwai42171c12009-05-08 14:11:43 +02009668/* bind hp and internal speaker mute (with plug check) as master switch */
9669static void alc262_hippo_master_update(struct hda_codec *codec)
9670{
9671 struct alc_spec *spec = codec->spec;
9672 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9673 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9674 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9675 unsigned int mute;
9676
9677 /* HP */
9678 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
9679 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
9680 HDA_AMP_MUTE, mute);
9681 /* mute internal speaker per jack sense */
9682 if (spec->jack_present)
9683 mute = HDA_AMP_MUTE;
9684 if (line_nid)
9685 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
9686 HDA_AMP_MUTE, mute);
9687 if (speaker_nid && speaker_nid != line_nid)
9688 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
9689 HDA_AMP_MUTE, mute);
9690}
9691
9692#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
9693
9694static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
9695 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +02009696{
9697 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +02009698 struct alc_spec *spec = codec->spec;
9699 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009700
Takashi Iwai42171c12009-05-08 14:11:43 +02009701 if (val == spec->master_sw)
9702 return 0;
9703 spec->master_sw = val;
9704 alc262_hippo_master_update(codec);
9705 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +02009706}
Takashi Iwai5b319542007-07-26 11:49:22 +02009707
Takashi Iwai42171c12009-05-08 14:11:43 +02009708#define ALC262_HIPPO_MASTER_SWITCH \
9709 { \
9710 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9711 .name = "Master Playback Switch", \
9712 .info = snd_ctl_boolean_mono_info, \
9713 .get = alc262_hippo_master_sw_get, \
9714 .put = alc262_hippo_master_sw_put, \
9715 }
9716
9717static struct snd_kcontrol_new alc262_hippo_mixer[] = {
9718 ALC262_HIPPO_MASTER_SWITCH,
9719 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9720 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9721 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9722 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9723 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9724 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9725 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9726 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9727 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9728 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9729 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9730 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9731 { } /* end */
9732};
9733
9734static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9735 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9736 ALC262_HIPPO_MASTER_SWITCH,
9737 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9738 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9739 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9740 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9741 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9742 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9743 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9744 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9745 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9746 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9747 { } /* end */
9748};
9749
9750/* mute/unmute internal speaker according to the hp jack and mute state */
9751static void alc262_hippo_automute(struct hda_codec *codec)
9752{
9753 struct alc_spec *spec = codec->spec;
9754 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9755 unsigned int present;
9756
9757 /* need to execute and sync at first */
9758 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
9759 present = snd_hda_codec_read(codec, hp_nid, 0,
9760 AC_VERB_GET_PIN_SENSE, 0);
9761 spec->jack_present = (present & 0x80000000) != 0;
9762 alc262_hippo_master_update(codec);
9763}
9764
9765static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
9766{
9767 if ((res >> 26) != ALC880_HP_EVENT)
9768 return;
9769 alc262_hippo_automute(codec);
9770}
9771
9772static void alc262_hippo_init_hook(struct hda_codec *codec)
9773{
9774 struct alc_spec *spec = codec->spec;
9775
9776 spec->autocfg.hp_pins[0] = 0x15;
9777 spec->autocfg.speaker_pins[0] = 0x14;
9778 alc262_hippo_automute(codec);
9779}
9780
9781static void alc262_hippo1_init_hook(struct hda_codec *codec)
9782{
9783 struct alc_spec *spec = codec->spec;
9784
9785 spec->autocfg.hp_pins[0] = 0x1b;
9786 spec->autocfg.speaker_pins[0] = 0x14;
9787 alc262_hippo_automute(codec);
9788}
9789
9790
Kailang Yang272a5272007-05-14 11:00:38 +02009791static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009792 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +02009793 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +02009794 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9795 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9796 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9797 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9798 { } /* end */
9799};
9800
Kailang Yang83c34212007-07-05 11:43:05 +02009801static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +02009802 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9803 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +02009804 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9805 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9806 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9807 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9808 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9809 { } /* end */
9810};
Kailang Yang272a5272007-05-14 11:00:38 +02009811
Tony Vroonba340e82009-02-02 19:01:30 +00009812static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9813 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9814 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9815 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9816 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9817 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9818 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9821 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9822 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9823 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9824 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9825 { } /* end */
9826};
9827
9828static struct hda_verb alc262_tyan_verbs[] = {
9829 /* Headphone automute */
9830 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9831 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9832 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9833
9834 /* P11 AUX_IN, white 4-pin connector */
9835 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9836 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9837 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9838 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9839
9840 {}
9841};
9842
9843/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009844static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +00009845{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009846 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +00009847
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009848 spec->autocfg.hp_pins[0] = 0x1b;
9849 spec->autocfg.speaker_pins[0] = 0x15;
9850 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +00009851}
9852
Tony Vroonba340e82009-02-02 19:01:30 +00009853
Kailang Yangdf694da2005-12-05 19:42:22 +01009854#define alc262_capture_mixer alc882_capture_mixer
9855#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9856
9857/*
9858 * generic initialization of ADC, input mixers and output mixers
9859 */
9860static struct hda_verb alc262_init_verbs[] = {
9861 /*
9862 * Unmute ADC0-2 and set the default input to mic-in
9863 */
9864 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9865 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9866 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9867 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9868 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9869 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9870
Takashi Iwaicb53c622007-08-10 17:21:45 +02009871 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009872 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009873 * Note: PASD motherboards uses the Line In 2 as the input for
9874 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009875 */
9876 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009877 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9878 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9879 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9880 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9881 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009882
9883 /*
9884 * Set up output mixers (0x0c - 0x0e)
9885 */
9886 /* set vol=0 to output mixers */
9887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9888 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9889 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9890 /* set up input amps for analog loopback */
9891 /* Amp Indices: DAC = 0, mixer = 1 */
9892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9893 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9895 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9896 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9897 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9898
9899 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9900 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9901 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9902 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9903 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9904 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9905
9906 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9907 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9908 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9909 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9910 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009911
Kailang Yangdf694da2005-12-05 19:42:22 +01009912 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9913 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009914
Kailang Yangdf694da2005-12-05 19:42:22 +01009915 /* FIXME: use matrix-type input source selection */
9916 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9917 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9918 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9919 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9920 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9921 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9922 /* Input mixer2 */
9923 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9924 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9925 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9926 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9927 /* Input mixer3 */
9928 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9929 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9930 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009931 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009932
9933 { }
9934};
9935
Kailang Yang4e555fe2008-08-26 13:05:55 +02009936static struct hda_verb alc262_eapd_verbs[] = {
9937 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9938 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9939 { }
9940};
9941
Kailang Yangccc656c2006-10-17 12:32:26 +02009942static struct hda_verb alc262_hippo_unsol_verbs[] = {
9943 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9944 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9945 {}
9946};
9947
9948static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9949 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9950 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9951 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9952
9953 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9954 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9955 {}
9956};
9957
Kailang Yang272a5272007-05-14 11:00:38 +02009958static struct hda_verb alc262_sony_unsol_verbs[] = {
9959 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9960 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9961 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9962
9963 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9964 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009965 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009966};
9967
Kailang Yang4e555fe2008-08-26 13:05:55 +02009968static struct hda_input_mux alc262_dmic_capture_source = {
9969 .num_items = 2,
9970 .items = {
9971 { "Int DMic", 0x9 },
9972 { "Mic", 0x0 },
9973 },
9974};
9975
9976static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9977 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9978 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9979 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9980 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9981 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009982 { } /* end */
9983};
9984
9985static struct hda_verb alc262_toshiba_s06_verbs[] = {
9986 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9987 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9988 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9989 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9990 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9991 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9992 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9993 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9994 {}
9995};
9996
9997static void alc262_dmic_automute(struct hda_codec *codec)
9998{
9999 unsigned int present;
10000
10001 present = snd_hda_codec_read(codec, 0x18, 0,
10002 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10003 snd_hda_codec_write(codec, 0x22, 0,
10004 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10005}
10006
Kailang Yang4e555fe2008-08-26 13:05:55 +020010007
10008/* unsolicited event for HP jack sensing */
10009static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10010 unsigned int res)
10011{
Kailang Yang4e555fe2008-08-26 13:05:55 +020010012 if ((res >> 26) == ALC880_MIC_EVENT)
10013 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010014 else
10015 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010016}
10017
10018static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10019{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010020 struct alc_spec *spec = codec->spec;
10021
10022 spec->autocfg.hp_pins[0] = 0x15;
10023 spec->autocfg.speaker_pins[0] = 0x14;
10024 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010025 alc262_dmic_automute(codec);
10026}
10027
Takashi Iwai834be882006-03-01 14:16:17 +010010028/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010029 * nec model
10030 * 0x15 = headphone
10031 * 0x16 = internal speaker
10032 * 0x18 = external mic
10033 */
10034
10035static struct snd_kcontrol_new alc262_nec_mixer[] = {
10036 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10037 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10038
10039 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10040 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10041 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10042
10043 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10044 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10045 { } /* end */
10046};
10047
10048static struct hda_verb alc262_nec_verbs[] = {
10049 /* Unmute Speaker */
10050 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10051
10052 /* Headphone */
10053 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10054 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10055
10056 /* External mic to headphone */
10057 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10058 /* External mic to speaker */
10059 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10060 {}
10061};
10062
10063/*
Takashi Iwai834be882006-03-01 14:16:17 +010010064 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010065 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10066 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010067 */
10068
10069#define ALC_HP_EVENT 0x37
10070
10071static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10072 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10073 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010074 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10075 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010076 {}
10077};
10078
Jiang zhe0e31daf2008-03-20 12:12:39 +010010079static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10080 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10081 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10082 {}
10083};
10084
Takashi Iwai834be882006-03-01 14:16:17 +010010085static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010086 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010087 .items = {
10088 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010089 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010090 { "CD", 0x4 },
10091 },
10092};
10093
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010094static struct hda_input_mux alc262_HP_capture_source = {
10095 .num_items = 5,
10096 .items = {
10097 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010098 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010099 { "Line", 0x2 },
10100 { "CD", 0x4 },
10101 { "AUX IN", 0x6 },
10102 },
10103};
10104
zhejiangaccbe492007-08-31 12:36:05 +020010105static struct hda_input_mux alc262_HP_D7000_capture_source = {
10106 .num_items = 4,
10107 .items = {
10108 { "Mic", 0x0 },
10109 { "Front Mic", 0x2 },
10110 { "Line", 0x1 },
10111 { "CD", 0x4 },
10112 },
10113};
10114
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010115/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010116static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10117{
10118 struct alc_spec *spec = codec->spec;
10119 unsigned int mute;
10120
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010121 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010122 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010123 /* need to execute and sync at first */
10124 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010125 /* check laptop HP jack */
10126 present = snd_hda_codec_read(codec, 0x14, 0,
10127 AC_VERB_GET_PIN_SENSE, 0);
10128 /* need to execute and sync at first */
10129 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10130 /* check docking HP jack */
10131 present |= snd_hda_codec_read(codec, 0x1b, 0,
10132 AC_VERB_GET_PIN_SENSE, 0);
10133 if (present & AC_PINSENSE_PRESENCE)
10134 spec->jack_present = 1;
10135 else
10136 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010137 spec->sense_updated = 1;
10138 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010139 /* unmute internal speaker only if both HPs are unplugged and
10140 * master switch is on
10141 */
10142 if (spec->jack_present)
10143 mute = HDA_AMP_MUTE;
10144 else
Takashi Iwai834be882006-03-01 14:16:17 +010010145 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010146 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10147 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010148}
10149
10150/* unsolicited event for HP jack sensing */
10151static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10152 unsigned int res)
10153{
10154 if ((res >> 26) != ALC_HP_EVENT)
10155 return;
10156 alc262_fujitsu_automute(codec, 1);
10157}
10158
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010159static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10160{
10161 alc262_fujitsu_automute(codec, 1);
10162}
10163
Takashi Iwai834be882006-03-01 14:16:17 +010010164/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010165static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10166 .ops = &snd_hda_bind_vol,
10167 .values = {
10168 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10169 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10170 0
10171 },
10172};
Takashi Iwai834be882006-03-01 14:16:17 +010010173
Jiang zhe0e31daf2008-03-20 12:12:39 +010010174/* mute/unmute internal speaker according to the hp jack and mute state */
10175static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10176{
10177 struct alc_spec *spec = codec->spec;
10178 unsigned int mute;
10179
10180 if (force || !spec->sense_updated) {
10181 unsigned int present_int_hp;
10182 /* need to execute and sync at first */
10183 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10184 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10185 AC_VERB_GET_PIN_SENSE, 0);
10186 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10187 spec->sense_updated = 1;
10188 }
10189 if (spec->jack_present) {
10190 /* mute internal speaker */
10191 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10192 HDA_AMP_MUTE, HDA_AMP_MUTE);
10193 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10194 HDA_AMP_MUTE, HDA_AMP_MUTE);
10195 } else {
10196 /* unmute internal speaker if necessary */
10197 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10198 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10199 HDA_AMP_MUTE, mute);
10200 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10201 HDA_AMP_MUTE, mute);
10202 }
10203}
10204
10205/* unsolicited event for HP jack sensing */
10206static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10207 unsigned int res)
10208{
10209 if ((res >> 26) != ALC_HP_EVENT)
10210 return;
10211 alc262_lenovo_3000_automute(codec, 1);
10212}
10213
Takashi Iwai834be882006-03-01 14:16:17 +010010214/* bind hp and internal speaker mute (with plug check) */
10215static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10216 struct snd_ctl_elem_value *ucontrol)
10217{
10218 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10219 long *valp = ucontrol->value.integer.value;
10220 int change;
10221
Tony Vroon5d9fab22008-03-14 17:09:18 +010010222 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10223 HDA_AMP_MUTE,
10224 valp ? 0 : HDA_AMP_MUTE);
10225 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10226 HDA_AMP_MUTE,
10227 valp ? 0 : HDA_AMP_MUTE);
10228
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010229 if (change)
10230 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010231 return change;
10232}
10233
10234static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010235 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010236 {
10237 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10238 .name = "Master Playback Switch",
10239 .info = snd_hda_mixer_amp_switch_info,
10240 .get = snd_hda_mixer_amp_switch_get,
10241 .put = alc262_fujitsu_master_sw_put,
10242 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10243 },
10244 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10245 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10246 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10247 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10248 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010249 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10250 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10251 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010252 { } /* end */
10253};
10254
Jiang zhe0e31daf2008-03-20 12:12:39 +010010255/* bind hp and internal speaker mute (with plug check) */
10256static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10257 struct snd_ctl_elem_value *ucontrol)
10258{
10259 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10260 long *valp = ucontrol->value.integer.value;
10261 int change;
10262
10263 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10264 HDA_AMP_MUTE,
10265 valp ? 0 : HDA_AMP_MUTE);
10266
10267 if (change)
10268 alc262_lenovo_3000_automute(codec, 0);
10269 return change;
10270}
10271
10272static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10273 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10274 {
10275 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10276 .name = "Master Playback Switch",
10277 .info = snd_hda_mixer_amp_switch_info,
10278 .get = snd_hda_mixer_amp_switch_get,
10279 .put = alc262_lenovo_3000_master_sw_put,
10280 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10281 },
10282 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10283 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10284 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10285 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10286 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10287 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10288 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10289 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10290 { } /* end */
10291};
10292
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010293static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10294 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010295 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010296 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10297 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10298 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10299 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10300 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10301 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10302 { } /* end */
10303};
10304
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010305/* additional init verbs for Benq laptops */
10306static struct hda_verb alc262_EAPD_verbs[] = {
10307 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10308 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10309 {}
10310};
10311
Kailang Yang83c34212007-07-05 11:43:05 +020010312static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10313 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10314 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10315
10316 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10317 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10318 {}
10319};
10320
Tobin Davisf651b502007-10-26 12:40:47 +020010321/* Samsung Q1 Ultra Vista model setup */
10322static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010323 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10324 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010325 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10326 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10327 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010328 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010329 { } /* end */
10330};
10331
10332static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010333 /* output mixer */
10334 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10335 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10336 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10337 /* speaker */
10338 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10339 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10340 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10341 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10342 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010343 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010344 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10345 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10346 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10347 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10348 /* internal mic */
10349 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10350 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10351 /* ADC, choose mic */
10352 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10354 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10355 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10356 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10357 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10358 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10359 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10360 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10361 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010362 {}
10363};
10364
Tobin Davisf651b502007-10-26 12:40:47 +020010365/* mute/unmute internal speaker according to the hp jack and mute state */
10366static void alc262_ultra_automute(struct hda_codec *codec)
10367{
10368 struct alc_spec *spec = codec->spec;
10369 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010370
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010371 mute = 0;
10372 /* auto-mute only when HP is used as HP */
10373 if (!spec->cur_mux[0]) {
10374 unsigned int present;
10375 /* need to execute and sync at first */
10376 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10377 present = snd_hda_codec_read(codec, 0x15, 0,
10378 AC_VERB_GET_PIN_SENSE, 0);
10379 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10380 if (spec->jack_present)
10381 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010382 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010383 /* mute/unmute internal speaker */
10384 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10385 HDA_AMP_MUTE, mute);
10386 /* mute/unmute HP */
10387 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10388 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010389}
10390
10391/* unsolicited event for HP jack sensing */
10392static void alc262_ultra_unsol_event(struct hda_codec *codec,
10393 unsigned int res)
10394{
10395 if ((res >> 26) != ALC880_HP_EVENT)
10396 return;
10397 alc262_ultra_automute(codec);
10398}
10399
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010400static struct hda_input_mux alc262_ultra_capture_source = {
10401 .num_items = 2,
10402 .items = {
10403 { "Mic", 0x1 },
10404 { "Headphone", 0x7 },
10405 },
10406};
10407
10408static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10409 struct snd_ctl_elem_value *ucontrol)
10410{
10411 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10412 struct alc_spec *spec = codec->spec;
10413 int ret;
10414
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010415 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010416 if (!ret)
10417 return 0;
10418 /* reprogram the HP pin as mic or HP according to the input source */
10419 snd_hda_codec_write_cache(codec, 0x15, 0,
10420 AC_VERB_SET_PIN_WIDGET_CONTROL,
10421 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10422 alc262_ultra_automute(codec); /* mute/unmute HP */
10423 return ret;
10424}
10425
10426static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10427 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10428 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10429 {
10430 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10431 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010432 .info = alc_mux_enum_info,
10433 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010434 .put = alc262_ultra_mux_enum_put,
10435 },
10436 { } /* end */
10437};
10438
Kailang Yangdf694da2005-12-05 19:42:22 +010010439/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010440static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10441 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010442{
10443 hda_nid_t nid;
10444 int err;
10445
10446 spec->multiout.num_dacs = 1; /* only use one dac */
10447 spec->multiout.dac_nids = spec->private_dac_nids;
10448 spec->multiout.dac_nids[0] = 2;
10449
10450 nid = cfg->line_out_pins[0];
10451 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010452 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10453 "Front Playback Volume",
10454 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10455 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010456 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010457 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10458 "Front Playback Switch",
10459 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10460 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010461 return err;
10462 }
10463
Takashi Iwai82bc9552006-03-21 11:24:42 +010010464 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010465 if (nid) {
10466 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010467 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10468 "Speaker Playback Volume",
10469 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10470 HDA_OUTPUT));
10471 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010472 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010473 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10474 "Speaker Playback Switch",
10475 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10476 HDA_OUTPUT));
10477 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010478 return err;
10479 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010480 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10481 "Speaker Playback Switch",
10482 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10483 HDA_OUTPUT));
10484 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010485 return err;
10486 }
10487 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010488 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010489 if (nid) {
10490 /* spec->multiout.hp_nid = 2; */
10491 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010492 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10493 "Headphone Playback Volume",
10494 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10495 HDA_OUTPUT));
10496 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010497 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010498 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10499 "Headphone Playback Switch",
10500 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10501 HDA_OUTPUT));
10502 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010503 return err;
10504 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010505 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10506 "Headphone Playback Switch",
10507 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10508 HDA_OUTPUT));
10509 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010510 return err;
10511 }
10512 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010513 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010514}
10515
10516/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010517#define alc262_auto_create_analog_input_ctls \
10518 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010519
10520/*
10521 * generic initialization of ADC, input mixers and output mixers
10522 */
10523static struct hda_verb alc262_volume_init_verbs[] = {
10524 /*
10525 * Unmute ADC0-2 and set the default input to mic-in
10526 */
10527 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10528 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10529 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10530 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10531 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10532 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10533
Takashi Iwaicb53c622007-08-10 17:21:45 +020010534 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010535 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010536 * Note: PASD motherboards uses the Line In 2 as the input for
10537 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010538 */
10539 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010545
10546 /*
10547 * Set up output mixers (0x0c - 0x0f)
10548 */
10549 /* set vol=0 to output mixers */
10550 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10551 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10552 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010553
Kailang Yangdf694da2005-12-05 19:42:22 +010010554 /* set up input amps for analog loopback */
10555 /* Amp Indices: DAC = 0, mixer = 1 */
10556 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10557 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10558 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10559 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10560 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10561 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10562
10563 /* FIXME: use matrix-type input source selection */
10564 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10565 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10566 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10567 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10568 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10569 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10570 /* Input mixer2 */
10571 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10572 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10573 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10574 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10575 /* Input mixer3 */
10576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10580
10581 { }
10582};
10583
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010584static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10585 /*
10586 * Unmute ADC0-2 and set the default input to mic-in
10587 */
10588 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10589 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10590 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10591 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10592 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10593 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10594
Takashi Iwaicb53c622007-08-10 17:21:45 +020010595 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010596 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010597 * Note: PASD motherboards uses the Line In 2 as the input for
10598 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010599 */
10600 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010601 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10602 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10603 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10604 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10605 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10606 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10607 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010608
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010609 /*
10610 * Set up output mixers (0x0c - 0x0e)
10611 */
10612 /* set vol=0 to output mixers */
10613 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10614 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10615 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10616
10617 /* set up input amps for analog loopback */
10618 /* Amp Indices: DAC = 0, mixer = 1 */
10619 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10620 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10621 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10622 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10623 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10624 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10625
Takashi Iwaice875f02008-01-28 18:17:43 +010010626 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010627 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10628 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10629
10630 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10631 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10632
10633 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10634 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10635
10636 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10637 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10638 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10639 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10640 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10641
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010642 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010643 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10644 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010645 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010646 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10647 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10648
10649
10650 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010651 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
10652 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010653 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010654 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10655 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10656 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10657 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10658 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10659 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10660 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10661 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010662 /* Input mixer2 */
10663 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010664 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10667 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10668 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10669 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10670 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10671 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010672 /* Input mixer3 */
10673 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010674 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10675 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10676 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10677 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10678 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10680 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010682
Takashi Iwaice875f02008-01-28 18:17:43 +010010683 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10684
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010685 { }
10686};
10687
Kailang Yangcd7509a2007-01-26 18:33:17 +010010688static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10689 /*
10690 * Unmute ADC0-2 and set the default input to mic-in
10691 */
10692 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10693 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10694 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10695 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10696 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10697 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10698
Takashi Iwaicb53c622007-08-10 17:21:45 +020010699 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010700 * mixer widget
10701 * Note: PASD motherboards uses the Line In 2 as the input for front
10702 * panel mic (mic 2)
10703 */
10704 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010705 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10706 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10707 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10708 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10709 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10710 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10711 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10712 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010713 /*
10714 * Set up output mixers (0x0c - 0x0e)
10715 */
10716 /* set vol=0 to output mixers */
10717 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10718 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10719 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10720
10721 /* set up input amps for analog loopback */
10722 /* Amp Indices: DAC = 0, mixer = 1 */
10723 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10725 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10726 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10727 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10728 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10729
10730
10731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10732 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10733 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10734 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10735 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10736 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10737 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10738
10739 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10740 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10741
10742 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10743 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10744
10745 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10746 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10747 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10748 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10749 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10750 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10751
10752 /* FIXME: use matrix-type input source selection */
10753 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10754 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10755 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10756 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10757 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10758 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10759 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10760 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10761 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10762 /* Input mixer2 */
10763 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10764 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10765 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10766 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10767 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10768 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10769 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10770 /* Input mixer3 */
10771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10772 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10773 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10774 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10775 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10776 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10778
Takashi Iwaice875f02008-01-28 18:17:43 +010010779 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10780
Kailang Yangcd7509a2007-01-26 18:33:17 +010010781 { }
10782};
10783
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010784static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10785
10786 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10787 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10788 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10789
10790 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10791 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10792 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10793 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10794
10795 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10796 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10797 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10798 {}
10799};
10800
10801
Takashi Iwaicb53c622007-08-10 17:21:45 +020010802#ifdef CONFIG_SND_HDA_POWER_SAVE
10803#define alc262_loopbacks alc880_loopbacks
10804#endif
10805
Kailang Yangdf694da2005-12-05 19:42:22 +010010806/* pcm configuration: identiacal with ALC880 */
10807#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10808#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10809#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10810#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10811
10812/*
10813 * BIOS auto configuration
10814 */
10815static int alc262_parse_auto_config(struct hda_codec *codec)
10816{
10817 struct alc_spec *spec = codec->spec;
10818 int err;
10819 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10820
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010821 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10822 alc262_ignore);
10823 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010824 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010825 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010826 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010827 spec->multiout.max_channels = 2;
10828 spec->no_analog = 1;
10829 goto dig_only;
10830 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010831 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010832 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010833 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10834 if (err < 0)
10835 return err;
10836 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10837 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010838 return err;
10839
10840 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10841
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010842 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010843 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010844 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010845 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010846 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010847 if (spec->autocfg.dig_in_pin)
10848 spec->dig_in_nid = ALC262_DIGIN_NID;
10849
Takashi Iwai603c4012008-07-30 15:01:44 +020010850 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010851 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010852
Takashi Iwaid88897e2008-10-31 15:01:37 +010010853 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010854 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010855 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010856
Takashi Iwai776e1842007-08-29 15:07:11 +020010857 err = alc_auto_add_mic_boost(codec);
10858 if (err < 0)
10859 return err;
10860
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010861 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
10862
Kailang Yangdf694da2005-12-05 19:42:22 +010010863 return 1;
10864}
10865
10866#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10867#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10868#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010869#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010870
10871
10872/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010873static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010874{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010875 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010876 alc262_auto_init_multi_out(codec);
10877 alc262_auto_init_hp_out(codec);
10878 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010879 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010880 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010881 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010882}
10883
10884/*
10885 * configuration and preset
10886 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010887static const char *alc262_models[ALC262_MODEL_LAST] = {
10888 [ALC262_BASIC] = "basic",
10889 [ALC262_HIPPO] = "hippo",
10890 [ALC262_HIPPO_1] = "hippo_1",
10891 [ALC262_FUJITSU] = "fujitsu",
10892 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010893 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010894 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010895 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010896 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010897 [ALC262_BENQ_T31] = "benq-t31",
10898 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010899 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010900 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010901 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010902 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010903 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010904 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010905 [ALC262_AUTO] = "auto",
10906};
10907
10908static struct snd_pci_quirk alc262_cfg_tbl[] = {
10909 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010910 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010911 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10912 ALC262_HP_BPC),
10913 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10914 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010010915 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
10916 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010917 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010918 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010919 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010920 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010921 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010922 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010923 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010924 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010925 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10926 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10927 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010928 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10929 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010930 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010931 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010932 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010933 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010010934 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwaif872a912009-02-26 00:57:01 +010010935 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
10936 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010937 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010938 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010939 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010940 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010941 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000010942 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010943 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10944 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010945 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010946 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010947 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010948 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010949 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010950 {}
10951};
10952
10953static struct alc_config_preset alc262_presets[] = {
10954 [ALC262_BASIC] = {
10955 .mixers = { alc262_base_mixer },
10956 .init_verbs = { alc262_init_verbs },
10957 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10958 .dac_nids = alc262_dac_nids,
10959 .hp_nid = 0x03,
10960 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10961 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010962 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010963 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010964 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010965 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020010966 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10967 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10968 .dac_nids = alc262_dac_nids,
10969 .hp_nid = 0x03,
10970 .dig_out_nid = ALC262_DIGOUT_NID,
10971 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10972 .channel_mode = alc262_modes,
10973 .input_mux = &alc262_capture_source,
10974 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020010975 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020010976 },
10977 [ALC262_HIPPO_1] = {
10978 .mixers = { alc262_hippo1_mixer },
10979 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10980 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10981 .dac_nids = alc262_dac_nids,
10982 .hp_nid = 0x02,
10983 .dig_out_nid = ALC262_DIGOUT_NID,
10984 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10985 .channel_mode = alc262_modes,
10986 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020010987 .unsol_event = alc262_hippo_unsol_event,
10988 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020010989 },
Takashi Iwai834be882006-03-01 14:16:17 +010010990 [ALC262_FUJITSU] = {
10991 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010992 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10993 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010994 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10995 .dac_nids = alc262_dac_nids,
10996 .hp_nid = 0x03,
10997 .dig_out_nid = ALC262_DIGOUT_NID,
10998 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10999 .channel_mode = alc262_modes,
11000 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011001 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011002 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011003 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011004 [ALC262_HP_BPC] = {
11005 .mixers = { alc262_HP_BPC_mixer },
11006 .init_verbs = { alc262_HP_BPC_init_verbs },
11007 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11008 .dac_nids = alc262_dac_nids,
11009 .hp_nid = 0x03,
11010 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11011 .channel_mode = alc262_modes,
11012 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011013 .unsol_event = alc262_hp_bpc_unsol_event,
11014 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011015 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011016 [ALC262_HP_BPC_D7000_WF] = {
11017 .mixers = { alc262_HP_BPC_WildWest_mixer },
11018 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11019 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11020 .dac_nids = alc262_dac_nids,
11021 .hp_nid = 0x03,
11022 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11023 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011024 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011025 .unsol_event = alc262_hp_wildwest_unsol_event,
11026 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011027 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011028 [ALC262_HP_BPC_D7000_WL] = {
11029 .mixers = { alc262_HP_BPC_WildWest_mixer,
11030 alc262_HP_BPC_WildWest_option_mixer },
11031 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11032 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11033 .dac_nids = alc262_dac_nids,
11034 .hp_nid = 0x03,
11035 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11036 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011037 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011038 .unsol_event = alc262_hp_wildwest_unsol_event,
11039 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011040 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011041 [ALC262_HP_TC_T5735] = {
11042 .mixers = { alc262_hp_t5735_mixer },
11043 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11044 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11045 .dac_nids = alc262_dac_nids,
11046 .hp_nid = 0x03,
11047 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11048 .channel_mode = alc262_modes,
11049 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011050 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011051 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011052 },
11053 [ALC262_HP_RP5700] = {
11054 .mixers = { alc262_hp_rp5700_mixer },
11055 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11056 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11057 .dac_nids = alc262_dac_nids,
11058 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11059 .channel_mode = alc262_modes,
11060 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011061 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011062 [ALC262_BENQ_ED8] = {
11063 .mixers = { alc262_base_mixer },
11064 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11065 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11066 .dac_nids = alc262_dac_nids,
11067 .hp_nid = 0x03,
11068 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11069 .channel_mode = alc262_modes,
11070 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011071 },
Kailang Yang272a5272007-05-14 11:00:38 +020011072 [ALC262_SONY_ASSAMD] = {
11073 .mixers = { alc262_sony_mixer },
11074 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11075 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11076 .dac_nids = alc262_dac_nids,
11077 .hp_nid = 0x02,
11078 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11079 .channel_mode = alc262_modes,
11080 .input_mux = &alc262_capture_source,
11081 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011082 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011083 },
11084 [ALC262_BENQ_T31] = {
11085 .mixers = { alc262_benq_t31_mixer },
11086 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11087 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11088 .dac_nids = alc262_dac_nids,
11089 .hp_nid = 0x03,
11090 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11091 .channel_mode = alc262_modes,
11092 .input_mux = &alc262_capture_source,
11093 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011094 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011095 },
Tobin Davisf651b502007-10-26 12:40:47 +020011096 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011097 .mixers = { alc262_ultra_mixer },
11098 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011099 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011100 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11101 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011102 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11103 .channel_mode = alc262_modes,
11104 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011105 .adc_nids = alc262_adc_nids, /* ADC0 */
11106 .capsrc_nids = alc262_capsrc_nids,
11107 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011108 .unsol_event = alc262_ultra_unsol_event,
11109 .init_hook = alc262_ultra_automute,
11110 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011111 [ALC262_LENOVO_3000] = {
11112 .mixers = { alc262_lenovo_3000_mixer },
11113 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11114 alc262_lenovo_3000_unsol_verbs },
11115 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11116 .dac_nids = alc262_dac_nids,
11117 .hp_nid = 0x03,
11118 .dig_out_nid = ALC262_DIGOUT_NID,
11119 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11120 .channel_mode = alc262_modes,
11121 .input_mux = &alc262_fujitsu_capture_source,
11122 .unsol_event = alc262_lenovo_3000_unsol_event,
11123 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011124 [ALC262_NEC] = {
11125 .mixers = { alc262_nec_mixer },
11126 .init_verbs = { alc262_nec_verbs },
11127 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11128 .dac_nids = alc262_dac_nids,
11129 .hp_nid = 0x03,
11130 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11131 .channel_mode = alc262_modes,
11132 .input_mux = &alc262_capture_source,
11133 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011134 [ALC262_TOSHIBA_S06] = {
11135 .mixers = { alc262_toshiba_s06_mixer },
11136 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11137 alc262_eapd_verbs },
11138 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11139 .capsrc_nids = alc262_dmic_capsrc_nids,
11140 .dac_nids = alc262_dac_nids,
11141 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11142 .dig_out_nid = ALC262_DIGOUT_NID,
11143 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11144 .channel_mode = alc262_modes,
11145 .input_mux = &alc262_dmic_capture_source,
11146 .unsol_event = alc262_toshiba_s06_unsol_event,
11147 .init_hook = alc262_toshiba_s06_init_hook,
11148 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011149 [ALC262_TOSHIBA_RX1] = {
11150 .mixers = { alc262_toshiba_rx1_mixer },
11151 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11152 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11153 .dac_nids = alc262_dac_nids,
11154 .hp_nid = 0x03,
11155 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11156 .channel_mode = alc262_modes,
11157 .input_mux = &alc262_capture_source,
11158 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011159 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011160 },
Tony Vroonba340e82009-02-02 19:01:30 +000011161 [ALC262_TYAN] = {
11162 .mixers = { alc262_tyan_mixer },
11163 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11164 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11165 .dac_nids = alc262_dac_nids,
11166 .hp_nid = 0x02,
11167 .dig_out_nid = ALC262_DIGOUT_NID,
11168 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11169 .channel_mode = alc262_modes,
11170 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011171 .unsol_event = alc_automute_amp_unsol_event,
11172 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011173 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011174};
11175
11176static int patch_alc262(struct hda_codec *codec)
11177{
11178 struct alc_spec *spec;
11179 int board_config;
11180 int err;
11181
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011182 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011183 if (spec == NULL)
11184 return -ENOMEM;
11185
11186 codec->spec = spec;
11187#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011188 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11189 * under-run
11190 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011191 {
11192 int tmp;
11193 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11194 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11195 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11196 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11197 }
11198#endif
11199
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011200 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11201
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011202 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11203 alc262_models,
11204 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011205
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011206 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020011207 printk(KERN_INFO "hda_codec: Unknown model for %s, "
11208 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011209 board_config = ALC262_AUTO;
11210 }
11211
11212 if (board_config == ALC262_AUTO) {
11213 /* automatic parse from the BIOS config */
11214 err = alc262_parse_auto_config(codec);
11215 if (err < 0) {
11216 alc_free(codec);
11217 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011218 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011219 printk(KERN_INFO
11220 "hda_codec: Cannot set up configuration "
11221 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011222 board_config = ALC262_BASIC;
11223 }
11224 }
11225
Takashi Iwai07eba612009-02-19 08:06:35 +010011226 if (!spec->no_analog) {
11227 err = snd_hda_attach_beep_device(codec, 0x1);
11228 if (err < 0) {
11229 alc_free(codec);
11230 return err;
11231 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011232 }
11233
Kailang Yangdf694da2005-12-05 19:42:22 +010011234 if (board_config != ALC262_AUTO)
11235 setup_preset(spec, &alc262_presets[board_config]);
11236
Kailang Yangdf694da2005-12-05 19:42:22 +010011237 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11238 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011239
Kailang Yangdf694da2005-12-05 19:42:22 +010011240 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11241 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11242
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011243 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011244 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011245 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011246 unsigned int wcap = get_wcaps(codec, 0x07);
11247
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011248 /* get type */
11249 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011250 if (wcap != AC_WID_AUD_IN) {
11251 spec->adc_nids = alc262_adc_nids_alt;
11252 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011253 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011254 } else {
11255 spec->adc_nids = alc262_adc_nids;
11256 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011257 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011258 }
11259 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011260 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011261 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011262 if (!spec->no_analog)
11263 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011264
Takashi Iwai2134ea42008-01-10 16:53:55 +010011265 spec->vmaster_nid = 0x0c;
11266
Kailang Yangdf694da2005-12-05 19:42:22 +010011267 codec->patch_ops = alc_patch_ops;
11268 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011269 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011270#ifdef CONFIG_SND_HDA_POWER_SAVE
11271 if (!spec->loopback.amplist)
11272 spec->loopback.amplist = alc262_loopbacks;
11273#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011274 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011275
Kailang Yangdf694da2005-12-05 19:42:22 +010011276 return 0;
11277}
11278
Kailang Yangdf694da2005-12-05 19:42:22 +010011279/*
Kailang Yanga361d842007-06-05 12:30:55 +020011280 * ALC268 channel source setting (2 channel)
11281 */
11282#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11283#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011284
Kailang Yanga361d842007-06-05 12:30:55 +020011285static hda_nid_t alc268_dac_nids[2] = {
11286 /* front, hp */
11287 0x02, 0x03
11288};
11289
11290static hda_nid_t alc268_adc_nids[2] = {
11291 /* ADC0-1 */
11292 0x08, 0x07
11293};
11294
11295static hda_nid_t alc268_adc_nids_alt[1] = {
11296 /* ADC0 */
11297 0x08
11298};
11299
Takashi Iwaie1406342008-02-11 18:32:32 +010011300static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11301
Kailang Yanga361d842007-06-05 12:30:55 +020011302static struct snd_kcontrol_new alc268_base_mixer[] = {
11303 /* output mixer control */
11304 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11305 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11306 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11307 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011308 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11309 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11310 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011311 { }
11312};
11313
Takashi Iwai42171c12009-05-08 14:11:43 +020011314static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11315 /* output mixer control */
11316 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11317 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11318 ALC262_HIPPO_MASTER_SWITCH,
11319 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11320 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11321 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11322 { }
11323};
11324
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011325/* bind Beep switches of both NID 0x0f and 0x10 */
11326static struct hda_bind_ctls alc268_bind_beep_sw = {
11327 .ops = &snd_hda_bind_sw,
11328 .values = {
11329 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11330 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11331 0
11332 },
11333};
11334
11335static struct snd_kcontrol_new alc268_beep_mixer[] = {
11336 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11337 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11338 { }
11339};
11340
Kailang Yangd1a991a2007-08-15 16:21:59 +020011341static struct hda_verb alc268_eapd_verbs[] = {
11342 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11343 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11344 { }
11345};
11346
Takashi Iwaid2738092007-08-16 14:59:45 +020011347/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011348static struct hda_verb alc268_toshiba_verbs[] = {
11349 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11350 { } /* end */
11351};
11352
Kailang Yang8ef355d2008-08-26 13:10:22 +020011353static struct hda_input_mux alc268_acer_lc_capture_source = {
11354 .num_items = 2,
11355 .items = {
11356 { "i-Mic", 0x6 },
11357 { "E-Mic", 0x0 },
11358 },
11359};
11360
Takashi Iwaid2738092007-08-16 14:59:45 +020011361/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011362/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011363static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11364 .ops = &snd_hda_bind_vol,
11365 .values = {
11366 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11367 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11368 0
11369 },
11370};
11371
Takashi Iwai889c4392007-08-23 18:56:52 +020011372/* mute/unmute internal speaker according to the hp jack and mute state */
11373static void alc268_acer_automute(struct hda_codec *codec, int force)
11374{
11375 struct alc_spec *spec = codec->spec;
11376 unsigned int mute;
11377
11378 if (force || !spec->sense_updated) {
11379 unsigned int present;
11380 present = snd_hda_codec_read(codec, 0x14, 0,
11381 AC_VERB_GET_PIN_SENSE, 0);
11382 spec->jack_present = (present & 0x80000000) != 0;
11383 spec->sense_updated = 1;
11384 }
11385 if (spec->jack_present)
11386 mute = HDA_AMP_MUTE; /* mute internal speaker */
11387 else /* unmute internal speaker if necessary */
11388 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11389 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11390 HDA_AMP_MUTE, mute);
11391}
11392
11393
11394/* bind hp and internal speaker mute (with plug check) */
11395static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11396 struct snd_ctl_elem_value *ucontrol)
11397{
11398 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11399 long *valp = ucontrol->value.integer.value;
11400 int change;
11401
11402 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11403 HDA_AMP_MUTE,
11404 valp[0] ? 0 : HDA_AMP_MUTE);
11405 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11406 HDA_AMP_MUTE,
11407 valp[1] ? 0 : HDA_AMP_MUTE);
11408 if (change)
11409 alc268_acer_automute(codec, 0);
11410 return change;
11411}
Takashi Iwaid2738092007-08-16 14:59:45 +020011412
Kailang Yang8ef355d2008-08-26 13:10:22 +020011413static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11414 /* output mixer control */
11415 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11416 {
11417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11418 .name = "Master Playback Switch",
11419 .info = snd_hda_mixer_amp_switch_info,
11420 .get = snd_hda_mixer_amp_switch_get,
11421 .put = alc268_acer_master_sw_put,
11422 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11423 },
11424 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11425 { }
11426};
11427
Takashi Iwaid2738092007-08-16 14:59:45 +020011428static struct snd_kcontrol_new alc268_acer_mixer[] = {
11429 /* output mixer control */
11430 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11431 {
11432 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11433 .name = "Master Playback Switch",
11434 .info = snd_hda_mixer_amp_switch_info,
11435 .get = snd_hda_mixer_amp_switch_get,
11436 .put = alc268_acer_master_sw_put,
11437 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11438 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011439 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11440 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11441 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011442 { }
11443};
11444
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011445static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11446 /* output mixer control */
11447 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11448 {
11449 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11450 .name = "Master Playback Switch",
11451 .info = snd_hda_mixer_amp_switch_info,
11452 .get = snd_hda_mixer_amp_switch_get,
11453 .put = alc268_acer_master_sw_put,
11454 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11455 },
11456 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11457 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11458 { }
11459};
11460
Kailang Yang8ef355d2008-08-26 13:10:22 +020011461static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11462 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11463 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11464 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11465 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11466 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11467 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11468 { }
11469};
11470
Takashi Iwaid2738092007-08-16 14:59:45 +020011471static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011472 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11473 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11475 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011476 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11477 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011478 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11479 { }
11480};
11481
11482/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011483#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11484#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011485
11486static void alc268_acer_unsol_event(struct hda_codec *codec,
11487 unsigned int res)
11488{
Takashi Iwai889c4392007-08-23 18:56:52 +020011489 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011490 return;
11491 alc268_acer_automute(codec, 1);
11492}
11493
Takashi Iwai889c4392007-08-23 18:56:52 +020011494static void alc268_acer_init_hook(struct hda_codec *codec)
11495{
11496 alc268_acer_automute(codec, 1);
11497}
11498
Kailang Yang8ef355d2008-08-26 13:10:22 +020011499/* toggle speaker-output according to the hp-jack state */
11500static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11501{
11502 unsigned int present;
11503 unsigned char bits;
11504
11505 present = snd_hda_codec_read(codec, 0x15, 0,
11506 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11507 bits = present ? AMP_IN_MUTE(0) : 0;
11508 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11509 AMP_IN_MUTE(0), bits);
11510 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11511 AMP_IN_MUTE(0), bits);
11512}
11513
11514
11515static void alc268_acer_mic_automute(struct hda_codec *codec)
11516{
11517 unsigned int present;
11518
11519 present = snd_hda_codec_read(codec, 0x18, 0,
11520 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11521 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11522 present ? 0x0 : 0x6);
11523}
11524
11525static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11526 unsigned int res)
11527{
11528 if ((res >> 26) == ALC880_HP_EVENT)
11529 alc268_aspire_one_speaker_automute(codec);
11530 if ((res >> 26) == ALC880_MIC_EVENT)
11531 alc268_acer_mic_automute(codec);
11532}
11533
11534static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11535{
11536 alc268_aspire_one_speaker_automute(codec);
11537 alc268_acer_mic_automute(codec);
11538}
11539
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011540static struct snd_kcontrol_new alc268_dell_mixer[] = {
11541 /* output mixer control */
11542 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11543 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11544 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11545 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11546 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11547 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11548 { }
11549};
11550
11551static struct hda_verb alc268_dell_verbs[] = {
11552 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11553 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11554 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11555 { }
11556};
11557
11558/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011559static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011560{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011561 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011562
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011563 spec->autocfg.hp_pins[0] = 0x15;
11564 spec->autocfg.speaker_pins[0] = 0x14;
11565 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011566}
11567
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011568static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11569 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11570 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11571 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11572 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11573 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11574 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11575 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11576 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11577 { }
11578};
11579
11580static struct hda_verb alc267_quanta_il1_verbs[] = {
11581 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11582 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11583 { }
11584};
11585
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011586static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11587{
11588 unsigned int present;
11589
11590 present = snd_hda_codec_read(codec, 0x18, 0,
11591 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11592 snd_hda_codec_write(codec, 0x23, 0,
11593 AC_VERB_SET_CONNECT_SEL,
11594 present ? 0x00 : 0x01);
11595}
11596
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011597static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011598{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011599 struct alc_spec *spec = codec->spec;
11600
11601 spec->autocfg.hp_pins[0] = 0x15;
11602 spec->autocfg.speaker_pins[0] = 0x14;
11603 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011604 alc267_quanta_il1_mic_automute(codec);
11605}
11606
11607static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11608 unsigned int res)
11609{
11610 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011611 case ALC880_MIC_EVENT:
11612 alc267_quanta_il1_mic_automute(codec);
11613 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011614 default:
11615 alc_sku_unsol_event(codec, res);
11616 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011617 }
11618}
11619
Kailang Yanga361d842007-06-05 12:30:55 +020011620/*
11621 * generic initialization of ADC, input mixers and output mixers
11622 */
11623static struct hda_verb alc268_base_init_verbs[] = {
11624 /* Unmute DAC0-1 and set vol = 0 */
11625 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011626 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011627
11628 /*
11629 * Set up output mixers (0x0c - 0x0e)
11630 */
11631 /* set vol=0 to output mixers */
11632 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011633 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11634
11635 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11636 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11637
11638 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11639 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11640 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11641 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11642 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11643 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11644 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11645 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11646
11647 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11648 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11649 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11650 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011651 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011652
11653 /* set PCBEEP vol = 0, mute connections */
11654 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11655 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11656 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011657
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011658 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011659
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011660 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11661 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11662 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11663 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011664
Kailang Yanga361d842007-06-05 12:30:55 +020011665 { }
11666};
11667
11668/*
11669 * generic initialization of ADC, input mixers and output mixers
11670 */
11671static struct hda_verb alc268_volume_init_verbs[] = {
11672 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011673 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11674 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011675
11676 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11677 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11678 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11679 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11680 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11681
Kailang Yanga361d842007-06-05 12:30:55 +020011682 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011683 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11684 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11685
11686 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011687 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011688
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011689 /* set PCBEEP vol = 0, mute connections */
11690 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11691 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11692 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011693
11694 { }
11695};
11696
Kailang Yanga361d842007-06-05 12:30:55 +020011697static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11698 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11699 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11700 {
11701 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11702 /* The multiple "Capture Source" controls confuse alsamixer
11703 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011704 */
11705 /* .name = "Capture Source", */
11706 .name = "Input Source",
11707 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011708 .info = alc_mux_enum_info,
11709 .get = alc_mux_enum_get,
11710 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011711 },
11712 { } /* end */
11713};
11714
11715static struct snd_kcontrol_new alc268_capture_mixer[] = {
11716 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11717 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11718 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11719 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11720 {
11721 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11722 /* The multiple "Capture Source" controls confuse alsamixer
11723 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011724 */
11725 /* .name = "Capture Source", */
11726 .name = "Input Source",
11727 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011728 .info = alc_mux_enum_info,
11729 .get = alc_mux_enum_get,
11730 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011731 },
11732 { } /* end */
11733};
11734
11735static struct hda_input_mux alc268_capture_source = {
11736 .num_items = 4,
11737 .items = {
11738 { "Mic", 0x0 },
11739 { "Front Mic", 0x1 },
11740 { "Line", 0x2 },
11741 { "CD", 0x3 },
11742 },
11743};
11744
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011745static struct hda_input_mux alc268_acer_capture_source = {
11746 .num_items = 3,
11747 .items = {
11748 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011749 { "Internal Mic", 0x1 },
11750 { "Line", 0x2 },
11751 },
11752};
11753
11754static struct hda_input_mux alc268_acer_dmic_capture_source = {
11755 .num_items = 3,
11756 .items = {
11757 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011758 { "Internal Mic", 0x6 },
11759 { "Line", 0x2 },
11760 },
11761};
11762
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011763#ifdef CONFIG_SND_DEBUG
11764static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011765 /* Volume widgets */
11766 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11767 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11768 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11769 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11770 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11771 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11772 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11773 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11774 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11775 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11776 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11777 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11778 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011779 /* The below appears problematic on some hardwares */
11780 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011781 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11782 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11783 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11784 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11785
11786 /* Modes for retasking pin widgets */
11787 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11788 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11789 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11790 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11791
11792 /* Controls for GPIO pins, assuming they are configured as outputs */
11793 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11794 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11795 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11796 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11797
11798 /* Switches to allow the digital SPDIF output pin to be enabled.
11799 * The ALC268 does not have an SPDIF input.
11800 */
11801 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11802
11803 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11804 * this output to turn on an external amplifier.
11805 */
11806 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11807 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11808
11809 { } /* end */
11810};
11811#endif
11812
Kailang Yanga361d842007-06-05 12:30:55 +020011813/* create input playback/capture controls for the given pin */
11814static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11815 const char *ctlname, int idx)
11816{
11817 char name[32];
11818 int err;
11819
11820 sprintf(name, "%s Playback Volume", ctlname);
11821 if (nid == 0x14) {
11822 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11823 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11824 HDA_OUTPUT));
11825 if (err < 0)
11826 return err;
11827 } else if (nid == 0x15) {
11828 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11829 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11830 HDA_OUTPUT));
11831 if (err < 0)
11832 return err;
11833 } else
11834 return -1;
11835 sprintf(name, "%s Playback Switch", ctlname);
11836 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11837 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11838 if (err < 0)
11839 return err;
11840 return 0;
11841}
11842
11843/* add playback controls from the parsed DAC table */
11844static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11845 const struct auto_pin_cfg *cfg)
11846{
11847 hda_nid_t nid;
11848 int err;
11849
11850 spec->multiout.num_dacs = 2; /* only use one dac */
11851 spec->multiout.dac_nids = spec->private_dac_nids;
11852 spec->multiout.dac_nids[0] = 2;
11853 spec->multiout.dac_nids[1] = 3;
11854
11855 nid = cfg->line_out_pins[0];
11856 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011857 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011858
11859 nid = cfg->speaker_pins[0];
11860 if (nid == 0x1d) {
11861 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11862 "Speaker Playback Volume",
11863 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11864 if (err < 0)
11865 return err;
11866 }
11867 nid = cfg->hp_pins[0];
11868 if (nid)
11869 alc268_new_analog_output(spec, nid, "Headphone", 0);
11870
11871 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11872 if (nid == 0x16) {
11873 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11874 "Mono Playback Switch",
11875 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11876 if (err < 0)
11877 return err;
11878 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011879 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011880}
11881
11882/* create playback/capture controls for input pins */
11883static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11884 const struct auto_pin_cfg *cfg)
11885{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011886 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011887 int i, idx1;
11888
11889 for (i = 0; i < AUTO_PIN_LAST; i++) {
11890 switch(cfg->input_pins[i]) {
11891 case 0x18:
11892 idx1 = 0; /* Mic 1 */
11893 break;
11894 case 0x19:
11895 idx1 = 1; /* Mic 2 */
11896 break;
11897 case 0x1a:
11898 idx1 = 2; /* Line In */
11899 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011900 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011901 idx1 = 3; /* CD */
11902 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011903 case 0x12:
11904 case 0x13:
11905 idx1 = 6; /* digital mics */
11906 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011907 default:
11908 continue;
11909 }
11910 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11911 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011912 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011913 }
11914 return 0;
11915}
11916
11917static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11918{
11919 struct alc_spec *spec = codec->spec;
11920 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11921 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11922 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11923 unsigned int dac_vol1, dac_vol2;
11924
11925 if (speaker_nid) {
11926 snd_hda_codec_write(codec, speaker_nid, 0,
11927 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11928 snd_hda_codec_write(codec, 0x0f, 0,
11929 AC_VERB_SET_AMP_GAIN_MUTE,
11930 AMP_IN_UNMUTE(1));
11931 snd_hda_codec_write(codec, 0x10, 0,
11932 AC_VERB_SET_AMP_GAIN_MUTE,
11933 AMP_IN_UNMUTE(1));
11934 } else {
11935 snd_hda_codec_write(codec, 0x0f, 0,
11936 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11937 snd_hda_codec_write(codec, 0x10, 0,
11938 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11939 }
11940
11941 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011942 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011943 dac_vol2 = AMP_OUT_ZERO;
11944 else if (line_nid == 0x15)
11945 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011946 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011947 dac_vol2 = AMP_OUT_ZERO;
11948 else if (hp_nid == 0x15)
11949 dac_vol1 = AMP_OUT_ZERO;
11950 if (line_nid != 0x16 || hp_nid != 0x16 ||
11951 spec->autocfg.line_out_pins[1] != 0x16 ||
11952 spec->autocfg.line_out_pins[2] != 0x16)
11953 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11954
11955 snd_hda_codec_write(codec, 0x02, 0,
11956 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11957 snd_hda_codec_write(codec, 0x03, 0,
11958 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11959}
11960
11961/* pcm configuration: identiacal with ALC880 */
11962#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11963#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011964#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011965#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11966
11967/*
11968 * BIOS auto configuration
11969 */
11970static int alc268_parse_auto_config(struct hda_codec *codec)
11971{
11972 struct alc_spec *spec = codec->spec;
11973 int err;
11974 static hda_nid_t alc268_ignore[] = { 0 };
11975
11976 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11977 alc268_ignore);
11978 if (err < 0)
11979 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011980 if (!spec->autocfg.line_outs) {
11981 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11982 spec->multiout.max_channels = 2;
11983 spec->no_analog = 1;
11984 goto dig_only;
11985 }
Kailang Yanga361d842007-06-05 12:30:55 +020011986 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011987 }
Kailang Yanga361d842007-06-05 12:30:55 +020011988 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11989 if (err < 0)
11990 return err;
11991 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11992 if (err < 0)
11993 return err;
11994
11995 spec->multiout.max_channels = 2;
11996
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011997 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020011998 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011999 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012000 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012001 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12002 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012003 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012004 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012005
Takashi Iwai892981f2009-03-02 08:04:35 +010012006 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012007 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012008
Takashi Iwaid88897e2008-10-31 15:01:37 +010012009 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012010 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012011 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012012
Takashi Iwai776e1842007-08-29 15:07:11 +020012013 err = alc_auto_add_mic_boost(codec);
12014 if (err < 0)
12015 return err;
12016
Kailang Yanga361d842007-06-05 12:30:55 +020012017 return 1;
12018}
12019
12020#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12021#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12022#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12023
12024/* init callback for auto-configuration model -- overriding the default init */
12025static void alc268_auto_init(struct hda_codec *codec)
12026{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012027 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012028 alc268_auto_init_multi_out(codec);
12029 alc268_auto_init_hp_out(codec);
12030 alc268_auto_init_mono_speaker_out(codec);
12031 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012032 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012033 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012034}
12035
12036/*
12037 * configuration and preset
12038 */
12039static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012040 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012041 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012042 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012043 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012044 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012045 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012046 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012047 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012048#ifdef CONFIG_SND_DEBUG
12049 [ALC268_TEST] = "test",
12050#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012051 [ALC268_AUTO] = "auto",
12052};
12053
12054static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012055 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012056 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012057 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012058 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012059 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012060 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12061 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012062 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012063 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012064 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Adam Williamson87488952009-05-21 18:32:59 -040012065 SND_PCI_QUIRK(0x103c, 0x30f1, "HP TX25xx series", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012066 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020012067 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020012068 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020012069 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012070 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012071 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012072 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012073 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012074 {}
12075};
12076
12077static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012078 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012079 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012080 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12081 alc267_quanta_il1_verbs },
12082 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12083 .dac_nids = alc268_dac_nids,
12084 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12085 .adc_nids = alc268_adc_nids_alt,
12086 .hp_nid = 0x03,
12087 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12088 .channel_mode = alc268_modes,
12089 .input_mux = &alc268_capture_source,
12090 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012091 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012092 },
Kailang Yanga361d842007-06-05 12:30:55 +020012093 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012094 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12095 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012096 .init_verbs = { alc268_base_init_verbs },
12097 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12098 .dac_nids = alc268_dac_nids,
12099 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12100 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012101 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012102 .hp_nid = 0x03,
12103 .dig_out_nid = ALC268_DIGOUT_NID,
12104 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12105 .channel_mode = alc268_modes,
12106 .input_mux = &alc268_capture_source,
12107 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012108 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012109 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012110 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012111 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12112 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012113 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12114 .dac_nids = alc268_dac_nids,
12115 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12116 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012117 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012118 .hp_nid = 0x03,
12119 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12120 .channel_mode = alc268_modes,
12121 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012122 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012123 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012124 },
12125 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012126 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12127 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012128 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12129 alc268_acer_verbs },
12130 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12131 .dac_nids = alc268_dac_nids,
12132 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12133 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012134 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012135 .hp_nid = 0x02,
12136 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12137 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012138 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012139 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012140 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012141 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012142 [ALC268_ACER_DMIC] = {
12143 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12144 alc268_beep_mixer },
12145 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12146 alc268_acer_verbs },
12147 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12148 .dac_nids = alc268_dac_nids,
12149 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12150 .adc_nids = alc268_adc_nids_alt,
12151 .capsrc_nids = alc268_capsrc_nids,
12152 .hp_nid = 0x02,
12153 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12154 .channel_mode = alc268_modes,
12155 .input_mux = &alc268_acer_dmic_capture_source,
12156 .unsol_event = alc268_acer_unsol_event,
12157 .init_hook = alc268_acer_init_hook,
12158 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012159 [ALC268_ACER_ASPIRE_ONE] = {
12160 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012161 alc268_beep_mixer,
12162 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012163 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12164 alc268_acer_aspire_one_verbs },
12165 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12166 .dac_nids = alc268_dac_nids,
12167 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12168 .adc_nids = alc268_adc_nids_alt,
12169 .capsrc_nids = alc268_capsrc_nids,
12170 .hp_nid = 0x03,
12171 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12172 .channel_mode = alc268_modes,
12173 .input_mux = &alc268_acer_lc_capture_source,
12174 .unsol_event = alc268_acer_lc_unsol_event,
12175 .init_hook = alc268_acer_lc_init_hook,
12176 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012177 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012178 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012179 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12180 alc268_dell_verbs },
12181 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12182 .dac_nids = alc268_dac_nids,
12183 .hp_nid = 0x02,
12184 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12185 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012186 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012187 .init_hook = alc268_dell_init_hook,
12188 .input_mux = &alc268_capture_source,
12189 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012190 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012191 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12192 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012193 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12194 alc268_toshiba_verbs },
12195 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12196 .dac_nids = alc268_dac_nids,
12197 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12198 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012199 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012200 .hp_nid = 0x03,
12201 .dig_out_nid = ALC268_DIGOUT_NID,
12202 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12203 .channel_mode = alc268_modes,
12204 .input_mux = &alc268_capture_source,
12205 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012206 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012207 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012208#ifdef CONFIG_SND_DEBUG
12209 [ALC268_TEST] = {
12210 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12211 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12212 alc268_volume_init_verbs },
12213 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12214 .dac_nids = alc268_dac_nids,
12215 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12216 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012217 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012218 .hp_nid = 0x03,
12219 .dig_out_nid = ALC268_DIGOUT_NID,
12220 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12221 .channel_mode = alc268_modes,
12222 .input_mux = &alc268_capture_source,
12223 },
12224#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012225};
12226
12227static int patch_alc268(struct hda_codec *codec)
12228{
12229 struct alc_spec *spec;
12230 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012231 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012232
12233 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12234 if (spec == NULL)
12235 return -ENOMEM;
12236
12237 codec->spec = spec;
12238
12239 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12240 alc268_models,
12241 alc268_cfg_tbl);
12242
12243 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020012244 printk(KERN_INFO "hda_codec: Unknown model for %s, "
12245 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012246 board_config = ALC268_AUTO;
12247 }
12248
12249 if (board_config == ALC268_AUTO) {
12250 /* automatic parse from the BIOS config */
12251 err = alc268_parse_auto_config(codec);
12252 if (err < 0) {
12253 alc_free(codec);
12254 return err;
12255 } else if (!err) {
12256 printk(KERN_INFO
12257 "hda_codec: Cannot set up configuration "
12258 "from BIOS. Using base mode...\n");
12259 board_config = ALC268_3ST;
12260 }
12261 }
12262
12263 if (board_config != ALC268_AUTO)
12264 setup_preset(spec, &alc268_presets[board_config]);
12265
Kailang Yanga361d842007-06-05 12:30:55 +020012266 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12267 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012268 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012269
Kailang Yanga361d842007-06-05 12:30:55 +020012270 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12271
Takashi Iwai22971e32009-02-10 11:56:44 +010012272 has_beep = 0;
12273 for (i = 0; i < spec->num_mixers; i++) {
12274 if (spec->mixers[i] == alc268_beep_mixer) {
12275 has_beep = 1;
12276 break;
12277 }
12278 }
12279
12280 if (has_beep) {
12281 err = snd_hda_attach_beep_device(codec, 0x1);
12282 if (err < 0) {
12283 alc_free(codec);
12284 return err;
12285 }
12286 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12287 /* override the amp caps for beep generator */
12288 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012289 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12290 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12291 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12292 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012293 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012294
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012295 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012296 /* check whether NID 0x07 is valid */
12297 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012298 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012299
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012300 /* get type */
12301 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012302 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012303 spec->adc_nids = alc268_adc_nids_alt;
12304 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012305 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012306 } else {
12307 spec->adc_nids = alc268_adc_nids;
12308 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012309 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012310 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012311 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012312 /* set default input source */
12313 for (i = 0; i < spec->num_adc_nids; i++)
12314 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12315 0, AC_VERB_SET_CONNECT_SEL,
12316 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012317 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012318
12319 spec->vmaster_nid = 0x02;
12320
Kailang Yanga361d842007-06-05 12:30:55 +020012321 codec->patch_ops = alc_patch_ops;
12322 if (board_config == ALC268_AUTO)
12323 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012324
Takashi Iwaidaead532008-11-28 12:55:36 +010012325 codec->proc_widget_hook = print_realtek_coef;
12326
Kailang Yanga361d842007-06-05 12:30:55 +020012327 return 0;
12328}
12329
12330/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012331 * ALC269 channel source setting (2 channel)
12332 */
12333#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12334
12335#define alc269_dac_nids alc260_dac_nids
12336
12337static hda_nid_t alc269_adc_nids[1] = {
12338 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012339 0x08,
12340};
12341
Takashi Iwaie01bf502008-08-21 16:25:07 +020012342static hda_nid_t alc269_capsrc_nids[1] = {
12343 0x23,
12344};
12345
12346/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12347 * not a mux!
12348 */
12349
Kailang Yangf53281e2008-07-18 12:36:43 +020012350static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12351 .num_items = 2,
12352 .items = {
12353 { "i-Mic", 0x5 },
12354 { "e-Mic", 0x0 },
12355 },
12356};
12357
12358static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12359 .num_items = 2,
12360 .items = {
12361 { "i-Mic", 0x1 },
12362 { "e-Mic", 0x0 },
12363 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012364};
12365
12366#define alc269_modes alc260_modes
12367#define alc269_capture_source alc880_lg_lw_capture_source
12368
12369static struct snd_kcontrol_new alc269_base_mixer[] = {
12370 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12371 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12372 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12373 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12374 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12375 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12376 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12377 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12378 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12379 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12380 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12381 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12382 { } /* end */
12383};
12384
Kailang Yang60db6b52008-08-26 13:13:00 +020012385static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12386 /* output mixer control */
12387 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12388 {
12389 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12390 .name = "Master Playback Switch",
12391 .info = snd_hda_mixer_amp_switch_info,
12392 .get = snd_hda_mixer_amp_switch_get,
12393 .put = alc268_acer_master_sw_put,
12394 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12395 },
12396 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12397 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12398 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12399 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12400 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12401 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012402 { }
12403};
12404
Tony Vroon64154832008-11-06 15:08:49 +000012405static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12406 /* output mixer control */
12407 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12408 {
12409 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12410 .name = "Master Playback Switch",
12411 .info = snd_hda_mixer_amp_switch_info,
12412 .get = snd_hda_mixer_amp_switch_get,
12413 .put = alc268_acer_master_sw_put,
12414 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12415 },
12416 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12417 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12418 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12419 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12420 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12421 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12422 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12423 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12424 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012425 { }
12426};
12427
Kailang Yangf53281e2008-07-18 12:36:43 +020012428/* bind volumes of both NID 0x0c and 0x0d */
12429static struct hda_bind_ctls alc269_epc_bind_vol = {
12430 .ops = &snd_hda_bind_vol,
12431 .values = {
12432 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12433 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12434 0
12435 },
12436};
12437
12438static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12439 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12440 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12441 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12442 { } /* end */
12443};
12444
Kailang Yangf6a92242007-12-13 16:52:54 +010012445/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012446static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12447 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12448 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012449 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12450 { } /* end */
12451};
12452
12453/* FSC amilo */
12454static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12455 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12456 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12457 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012458 { } /* end */
12459};
12460
Kailang Yang60db6b52008-08-26 13:13:00 +020012461static struct hda_verb alc269_quanta_fl1_verbs[] = {
12462 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12463 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12465 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12466 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12467 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12468 { }
12469};
12470
Tony Vroon64154832008-11-06 15:08:49 +000012471static struct hda_verb alc269_lifebook_verbs[] = {
12472 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12473 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12474 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12475 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12476 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12477 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12478 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12479 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12480 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12481 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12482 { }
12483};
12484
Kailang Yang60db6b52008-08-26 13:13:00 +020012485/* toggle speaker-output according to the hp-jack state */
12486static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12487{
12488 unsigned int present;
12489 unsigned char bits;
12490
12491 present = snd_hda_codec_read(codec, 0x15, 0,
12492 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12493 bits = present ? AMP_IN_MUTE(0) : 0;
12494 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12495 AMP_IN_MUTE(0), bits);
12496 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12497 AMP_IN_MUTE(0), bits);
12498
12499 snd_hda_codec_write(codec, 0x20, 0,
12500 AC_VERB_SET_COEF_INDEX, 0x0c);
12501 snd_hda_codec_write(codec, 0x20, 0,
12502 AC_VERB_SET_PROC_COEF, 0x680);
12503
12504 snd_hda_codec_write(codec, 0x20, 0,
12505 AC_VERB_SET_COEF_INDEX, 0x0c);
12506 snd_hda_codec_write(codec, 0x20, 0,
12507 AC_VERB_SET_PROC_COEF, 0x480);
12508}
12509
Tony Vroon64154832008-11-06 15:08:49 +000012510/* toggle speaker-output according to the hp-jacks state */
12511static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12512{
12513 unsigned int present;
12514 unsigned char bits;
12515
12516 /* Check laptop headphone socket */
12517 present = snd_hda_codec_read(codec, 0x15, 0,
12518 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12519
12520 /* Check port replicator headphone socket */
12521 present |= snd_hda_codec_read(codec, 0x1a, 0,
12522 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12523
12524 bits = present ? AMP_IN_MUTE(0) : 0;
12525 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12526 AMP_IN_MUTE(0), bits);
12527 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12528 AMP_IN_MUTE(0), bits);
12529
12530 snd_hda_codec_write(codec, 0x20, 0,
12531 AC_VERB_SET_COEF_INDEX, 0x0c);
12532 snd_hda_codec_write(codec, 0x20, 0,
12533 AC_VERB_SET_PROC_COEF, 0x680);
12534
12535 snd_hda_codec_write(codec, 0x20, 0,
12536 AC_VERB_SET_COEF_INDEX, 0x0c);
12537 snd_hda_codec_write(codec, 0x20, 0,
12538 AC_VERB_SET_PROC_COEF, 0x480);
12539}
12540
Kailang Yang60db6b52008-08-26 13:13:00 +020012541static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12542{
12543 unsigned int present;
12544
12545 present = snd_hda_codec_read(codec, 0x18, 0,
12546 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12547 snd_hda_codec_write(codec, 0x23, 0,
12548 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12549}
12550
Tony Vroon64154832008-11-06 15:08:49 +000012551static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12552{
12553 unsigned int present_laptop;
12554 unsigned int present_dock;
12555
12556 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12557 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12558
12559 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12560 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12561
12562 /* Laptop mic port overrides dock mic port, design decision */
12563 if (present_dock)
12564 snd_hda_codec_write(codec, 0x23, 0,
12565 AC_VERB_SET_CONNECT_SEL, 0x3);
12566 if (present_laptop)
12567 snd_hda_codec_write(codec, 0x23, 0,
12568 AC_VERB_SET_CONNECT_SEL, 0x0);
12569 if (!present_dock && !present_laptop)
12570 snd_hda_codec_write(codec, 0x23, 0,
12571 AC_VERB_SET_CONNECT_SEL, 0x1);
12572}
12573
Kailang Yang60db6b52008-08-26 13:13:00 +020012574static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12575 unsigned int res)
12576{
12577 if ((res >> 26) == ALC880_HP_EVENT)
12578 alc269_quanta_fl1_speaker_automute(codec);
12579 if ((res >> 26) == ALC880_MIC_EVENT)
12580 alc269_quanta_fl1_mic_automute(codec);
12581}
12582
Tony Vroon64154832008-11-06 15:08:49 +000012583static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12584 unsigned int res)
12585{
12586 if ((res >> 26) == ALC880_HP_EVENT)
12587 alc269_lifebook_speaker_automute(codec);
12588 if ((res >> 26) == ALC880_MIC_EVENT)
12589 alc269_lifebook_mic_autoswitch(codec);
12590}
12591
Kailang Yang60db6b52008-08-26 13:13:00 +020012592static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12593{
12594 alc269_quanta_fl1_speaker_automute(codec);
12595 alc269_quanta_fl1_mic_automute(codec);
12596}
12597
Tony Vroon64154832008-11-06 15:08:49 +000012598static void alc269_lifebook_init_hook(struct hda_codec *codec)
12599{
12600 alc269_lifebook_speaker_automute(codec);
12601 alc269_lifebook_mic_autoswitch(codec);
12602}
12603
Kailang Yang60db6b52008-08-26 13:13:00 +020012604static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12605 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12606 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12607 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12608 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12609 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12610 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12611 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12612 {}
12613};
12614
12615static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12616 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12617 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12618 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12619 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12620 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12621 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12622 {}
12623};
12624
12625/* toggle speaker-output according to the hp-jack state */
12626static void alc269_speaker_automute(struct hda_codec *codec)
12627{
12628 unsigned int present;
12629 unsigned char bits;
12630
12631 present = snd_hda_codec_read(codec, 0x15, 0,
12632 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12633 bits = present ? AMP_IN_MUTE(0) : 0;
12634 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12635 AMP_IN_MUTE(0), bits);
12636 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12637 AMP_IN_MUTE(0), bits);
12638}
12639
12640static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12641{
12642 unsigned int present;
12643
12644 present = snd_hda_codec_read(codec, 0x18, 0,
12645 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12646 snd_hda_codec_write(codec, 0x23, 0,
12647 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12648}
12649
12650static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12651{
12652 unsigned int present;
12653
12654 present = snd_hda_codec_read(codec, 0x18, 0,
12655 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12656 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12657 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12658 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12659 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12660}
12661
12662/* unsolicited event for HP jack sensing */
12663static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12664 unsigned int res)
12665{
12666 if ((res >> 26) == ALC880_HP_EVENT)
12667 alc269_speaker_automute(codec);
12668
12669 if ((res >> 26) == ALC880_MIC_EVENT)
12670 alc269_eeepc_dmic_automute(codec);
12671}
12672
12673static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12674{
12675 alc269_speaker_automute(codec);
12676 alc269_eeepc_dmic_automute(codec);
12677}
12678
12679/* unsolicited event for HP jack sensing */
12680static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12681 unsigned int res)
12682{
12683 if ((res >> 26) == ALC880_HP_EVENT)
12684 alc269_speaker_automute(codec);
12685
12686 if ((res >> 26) == ALC880_MIC_EVENT)
12687 alc269_eeepc_amic_automute(codec);
12688}
12689
12690static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12691{
12692 alc269_speaker_automute(codec);
12693 alc269_eeepc_amic_automute(codec);
12694}
12695
Kailang Yangf6a92242007-12-13 16:52:54 +010012696/*
12697 * generic initialization of ADC, input mixers and output mixers
12698 */
12699static struct hda_verb alc269_init_verbs[] = {
12700 /*
12701 * Unmute ADC0 and set the default input to mic-in
12702 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012703 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012704
12705 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12706 * analog-loopback mixer widget
12707 * Note: PASD motherboards uses the Line In 2 as the input for
12708 * front panel mic (mic 2)
12709 */
12710 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12711 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12712 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12713 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12714 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12715 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12716
12717 /*
12718 * Set up output mixers (0x0c - 0x0e)
12719 */
12720 /* set vol=0 to output mixers */
12721 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12722 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12723
12724 /* set up input amps for analog loopback */
12725 /* Amp Indices: DAC = 0, mixer = 1 */
12726 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12727 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12728 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12729 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12730 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12731 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12732
12733 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12734 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12735 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12736 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12737 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12738 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12739 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12740
12741 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12742 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12743 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12744 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12745 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12746 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12747 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12748
12749 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12750 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12751
12752 /* FIXME: use matrix-type input source selection */
12753 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12754 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012755 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12756 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012757 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12758 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12759
12760 /* set EAPD */
12761 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12762 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12763 { }
12764};
12765
12766/* add playback controls from the parsed DAC table */
12767static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12768 const struct auto_pin_cfg *cfg)
12769{
12770 hda_nid_t nid;
12771 int err;
12772
12773 spec->multiout.num_dacs = 1; /* only use one dac */
12774 spec->multiout.dac_nids = spec->private_dac_nids;
12775 spec->multiout.dac_nids[0] = 2;
12776
12777 nid = cfg->line_out_pins[0];
12778 if (nid) {
12779 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12780 "Front Playback Volume",
12781 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12782 if (err < 0)
12783 return err;
12784 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12785 "Front Playback Switch",
12786 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12787 if (err < 0)
12788 return err;
12789 }
12790
12791 nid = cfg->speaker_pins[0];
12792 if (nid) {
12793 if (!cfg->line_out_pins[0]) {
12794 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12795 "Speaker Playback Volume",
12796 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12797 HDA_OUTPUT));
12798 if (err < 0)
12799 return err;
12800 }
12801 if (nid == 0x16) {
12802 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12803 "Speaker Playback Switch",
12804 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12805 HDA_OUTPUT));
12806 if (err < 0)
12807 return err;
12808 } else {
12809 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12810 "Speaker Playback Switch",
12811 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12812 HDA_OUTPUT));
12813 if (err < 0)
12814 return err;
12815 }
12816 }
12817 nid = cfg->hp_pins[0];
12818 if (nid) {
12819 /* spec->multiout.hp_nid = 2; */
12820 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12821 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12822 "Headphone Playback Volume",
12823 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12824 HDA_OUTPUT));
12825 if (err < 0)
12826 return err;
12827 }
12828 if (nid == 0x16) {
12829 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12830 "Headphone Playback Switch",
12831 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12832 HDA_OUTPUT));
12833 if (err < 0)
12834 return err;
12835 } else {
12836 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12837 "Headphone Playback Switch",
12838 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12839 HDA_OUTPUT));
12840 if (err < 0)
12841 return err;
12842 }
12843 }
12844 return 0;
12845}
12846
Takashi Iwaiee956e02008-10-31 17:16:31 +010012847static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12848 const struct auto_pin_cfg *cfg)
12849{
12850 int err;
12851
12852 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12853 if (err < 0)
12854 return err;
12855 /* digital-mic input pin is excluded in alc880_auto_create..()
12856 * because it's under 0x18
12857 */
12858 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12859 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012860 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012861 imux->items[imux->num_items].label = "Int Mic";
12862 imux->items[imux->num_items].index = 0x05;
12863 imux->num_items++;
12864 }
12865 return 0;
12866}
Kailang Yangf6a92242007-12-13 16:52:54 +010012867
12868#ifdef CONFIG_SND_HDA_POWER_SAVE
12869#define alc269_loopbacks alc880_loopbacks
12870#endif
12871
12872/* pcm configuration: identiacal with ALC880 */
12873#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12874#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12875#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12876#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12877
Takashi Iwaif03d3112009-03-05 14:18:16 +010012878static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
12879 .substreams = 1,
12880 .channels_min = 2,
12881 .channels_max = 8,
12882 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12883 /* NID is set in alc_build_pcms */
12884 .ops = {
12885 .open = alc880_playback_pcm_open,
12886 .prepare = alc880_playback_pcm_prepare,
12887 .cleanup = alc880_playback_pcm_cleanup
12888 },
12889};
12890
12891static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
12892 .substreams = 1,
12893 .channels_min = 2,
12894 .channels_max = 2,
12895 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12896 /* NID is set in alc_build_pcms */
12897};
12898
Kailang Yangf6a92242007-12-13 16:52:54 +010012899/*
12900 * BIOS auto configuration
12901 */
12902static int alc269_parse_auto_config(struct hda_codec *codec)
12903{
12904 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012905 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012906 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12907
12908 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12909 alc269_ignore);
12910 if (err < 0)
12911 return err;
12912
12913 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12914 if (err < 0)
12915 return err;
12916 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12917 if (err < 0)
12918 return err;
12919
12920 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12921
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012922 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010012923 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12924
Takashi Iwai603c4012008-07-30 15:01:44 +020012925 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012926 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012927
Takashi Iwaid88897e2008-10-31 15:01:37 +010012928 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012929 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012930 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012931 /* set default input source */
12932 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12933 0, AC_VERB_SET_CONNECT_SEL,
12934 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012935
12936 err = alc_auto_add_mic_boost(codec);
12937 if (err < 0)
12938 return err;
12939
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012940 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012941 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012942
Kailang Yangf6a92242007-12-13 16:52:54 +010012943 return 1;
12944}
12945
12946#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12947#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12948#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12949
12950
12951/* init callback for auto-configuration model -- overriding the default init */
12952static void alc269_auto_init(struct hda_codec *codec)
12953{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012954 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012955 alc269_auto_init_multi_out(codec);
12956 alc269_auto_init_hp_out(codec);
12957 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012958 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012959 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012960}
12961
12962/*
12963 * configuration and preset
12964 */
12965static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012966 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012967 [ALC269_QUANTA_FL1] = "quanta",
12968 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012969 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012970 [ALC269_FUJITSU] = "fujitsu",
12971 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012972};
12973
12974static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012975 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012976 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12977 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020012978 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
12979 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
12980 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
12981 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
12982 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
12983 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020012984 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12985 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012986 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12987 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020012988 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012989 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012990 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012991 {}
12992};
12993
12994static struct alc_config_preset alc269_presets[] = {
12995 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012996 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012997 .init_verbs = { alc269_init_verbs },
12998 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12999 .dac_nids = alc269_dac_nids,
13000 .hp_nid = 0x03,
13001 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13002 .channel_mode = alc269_modes,
13003 .input_mux = &alc269_capture_source,
13004 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013005 [ALC269_QUANTA_FL1] = {
13006 .mixers = { alc269_quanta_fl1_mixer },
13007 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13008 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13009 .dac_nids = alc269_dac_nids,
13010 .hp_nid = 0x03,
13011 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13012 .channel_mode = alc269_modes,
13013 .input_mux = &alc269_capture_source,
13014 .unsol_event = alc269_quanta_fl1_unsol_event,
13015 .init_hook = alc269_quanta_fl1_init_hook,
13016 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013017 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013018 .mixers = { alc269_eeepc_mixer },
13019 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013020 .init_verbs = { alc269_init_verbs,
13021 alc269_eeepc_amic_init_verbs },
13022 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13023 .dac_nids = alc269_dac_nids,
13024 .hp_nid = 0x03,
13025 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13026 .channel_mode = alc269_modes,
13027 .input_mux = &alc269_eeepc_amic_capture_source,
13028 .unsol_event = alc269_eeepc_amic_unsol_event,
13029 .init_hook = alc269_eeepc_amic_inithook,
13030 },
13031 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013032 .mixers = { alc269_eeepc_mixer },
13033 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013034 .init_verbs = { alc269_init_verbs,
13035 alc269_eeepc_dmic_init_verbs },
13036 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13037 .dac_nids = alc269_dac_nids,
13038 .hp_nid = 0x03,
13039 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13040 .channel_mode = alc269_modes,
13041 .input_mux = &alc269_eeepc_dmic_capture_source,
13042 .unsol_event = alc269_eeepc_dmic_unsol_event,
13043 .init_hook = alc269_eeepc_dmic_inithook,
13044 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013045 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013046 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013047 .cap_mixer = alc269_epc_capture_mixer,
13048 .init_verbs = { alc269_init_verbs,
13049 alc269_eeepc_dmic_init_verbs },
13050 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13051 .dac_nids = alc269_dac_nids,
13052 .hp_nid = 0x03,
13053 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13054 .channel_mode = alc269_modes,
13055 .input_mux = &alc269_eeepc_dmic_capture_source,
13056 .unsol_event = alc269_eeepc_dmic_unsol_event,
13057 .init_hook = alc269_eeepc_dmic_inithook,
13058 },
Tony Vroon64154832008-11-06 15:08:49 +000013059 [ALC269_LIFEBOOK] = {
13060 .mixers = { alc269_lifebook_mixer },
13061 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13062 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13063 .dac_nids = alc269_dac_nids,
13064 .hp_nid = 0x03,
13065 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13066 .channel_mode = alc269_modes,
13067 .input_mux = &alc269_capture_source,
13068 .unsol_event = alc269_lifebook_unsol_event,
13069 .init_hook = alc269_lifebook_init_hook,
13070 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013071};
13072
13073static int patch_alc269(struct hda_codec *codec)
13074{
13075 struct alc_spec *spec;
13076 int board_config;
13077 int err;
13078
13079 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13080 if (spec == NULL)
13081 return -ENOMEM;
13082
13083 codec->spec = spec;
13084
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013085 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13086
Kailang Yangf6a92242007-12-13 16:52:54 +010013087 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13088 alc269_models,
13089 alc269_cfg_tbl);
13090
13091 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020013092 printk(KERN_INFO "hda_codec: Unknown model for %s, "
13093 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013094 board_config = ALC269_AUTO;
13095 }
13096
13097 if (board_config == ALC269_AUTO) {
13098 /* automatic parse from the BIOS config */
13099 err = alc269_parse_auto_config(codec);
13100 if (err < 0) {
13101 alc_free(codec);
13102 return err;
13103 } else if (!err) {
13104 printk(KERN_INFO
13105 "hda_codec: Cannot set up configuration "
13106 "from BIOS. Using base mode...\n");
13107 board_config = ALC269_BASIC;
13108 }
13109 }
13110
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013111 err = snd_hda_attach_beep_device(codec, 0x1);
13112 if (err < 0) {
13113 alc_free(codec);
13114 return err;
13115 }
13116
Kailang Yangf6a92242007-12-13 16:52:54 +010013117 if (board_config != ALC269_AUTO)
13118 setup_preset(spec, &alc269_presets[board_config]);
13119
Takashi Iwaif03d3112009-03-05 14:18:16 +010013120 if (codec->subsystem_id == 0x17aa3bf8) {
13121 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13122 * fix the sample rate of analog I/O to 44.1kHz
13123 */
13124 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13125 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13126 } else {
13127 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13128 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13129 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013130 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13131 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13132
13133 spec->adc_nids = alc269_adc_nids;
13134 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013135 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013136 if (!spec->cap_mixer)
13137 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013138 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013139
13140 codec->patch_ops = alc_patch_ops;
13141 if (board_config == ALC269_AUTO)
13142 spec->init_hook = alc269_auto_init;
13143#ifdef CONFIG_SND_HDA_POWER_SAVE
13144 if (!spec->loopback.amplist)
13145 spec->loopback.amplist = alc269_loopbacks;
13146#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013147 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013148
13149 return 0;
13150}
13151
13152/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013153 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13154 */
13155
13156/*
13157 * set the path ways for 2 channel output
13158 * need to set the codec line out and mic 1 pin widgets to inputs
13159 */
13160static struct hda_verb alc861_threestack_ch2_init[] = {
13161 /* set pin widget 1Ah (line in) for input */
13162 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013163 /* set pin widget 18h (mic1/2) for input, for mic also enable
13164 * the vref
13165 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013166 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13167
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013168 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13169#if 0
13170 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13171 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13172#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013173 { } /* end */
13174};
13175/*
13176 * 6ch mode
13177 * need to set the codec line out and mic 1 pin widgets to outputs
13178 */
13179static struct hda_verb alc861_threestack_ch6_init[] = {
13180 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13181 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13182 /* set pin widget 18h (mic1) for output (CLFE)*/
13183 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13184
13185 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013186 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013187
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013188 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13189#if 0
13190 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13191 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13192#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013193 { } /* end */
13194};
13195
13196static struct hda_channel_mode alc861_threestack_modes[2] = {
13197 { 2, alc861_threestack_ch2_init },
13198 { 6, alc861_threestack_ch6_init },
13199};
Takashi Iwai22309c32006-08-09 16:57:28 +020013200/* Set mic1 as input and unmute the mixer */
13201static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13202 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13203 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13204 { } /* end */
13205};
13206/* Set mic1 as output and mute mixer */
13207static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13208 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13209 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13210 { } /* end */
13211};
13212
13213static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13214 { 2, alc861_uniwill_m31_ch2_init },
13215 { 4, alc861_uniwill_m31_ch4_init },
13216};
Kailang Yangdf694da2005-12-05 19:42:22 +010013217
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013218/* Set mic1 and line-in as input and unmute the mixer */
13219static struct hda_verb alc861_asus_ch2_init[] = {
13220 /* set pin widget 1Ah (line in) for input */
13221 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013222 /* set pin widget 18h (mic1/2) for input, for mic also enable
13223 * the vref
13224 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013225 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13226
13227 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13228#if 0
13229 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13230 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13231#endif
13232 { } /* end */
13233};
13234/* Set mic1 nad line-in as output and mute mixer */
13235static struct hda_verb alc861_asus_ch6_init[] = {
13236 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13237 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13238 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13239 /* set pin widget 18h (mic1) for output (CLFE)*/
13240 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13241 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13242 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13243 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13244
13245 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13246#if 0
13247 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13248 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13249#endif
13250 { } /* end */
13251};
13252
13253static struct hda_channel_mode alc861_asus_modes[2] = {
13254 { 2, alc861_asus_ch2_init },
13255 { 6, alc861_asus_ch6_init },
13256};
13257
Kailang Yangdf694da2005-12-05 19:42:22 +010013258/* patch-ALC861 */
13259
13260static struct snd_kcontrol_new alc861_base_mixer[] = {
13261 /* output mixer control */
13262 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13263 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13264 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13265 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13266 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13267
13268 /*Input mixer control */
13269 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13270 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13271 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13272 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13273 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13274 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13275 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13276 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13277 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13278 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013279
Kailang Yangdf694da2005-12-05 19:42:22 +010013280 { } /* end */
13281};
13282
13283static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13284 /* output mixer control */
13285 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13286 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13287 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13288 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13289 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13290
13291 /* Input mixer control */
13292 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13293 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13294 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13295 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13296 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13297 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13298 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13299 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13300 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13301 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013302
Kailang Yangdf694da2005-12-05 19:42:22 +010013303 {
13304 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13305 .name = "Channel Mode",
13306 .info = alc_ch_mode_info,
13307 .get = alc_ch_mode_get,
13308 .put = alc_ch_mode_put,
13309 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13310 },
13311 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013312};
13313
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013314static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013315 /* output mixer control */
13316 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13318 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013319
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013320 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013321};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013322
Takashi Iwai22309c32006-08-09 16:57:28 +020013323static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13324 /* output mixer control */
13325 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13326 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13327 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13328 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13329 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13330
13331 /* Input mixer control */
13332 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13333 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13334 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13335 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13336 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13337 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13338 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13339 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13340 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13341 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013342
Takashi Iwai22309c32006-08-09 16:57:28 +020013343 {
13344 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13345 .name = "Channel Mode",
13346 .info = alc_ch_mode_info,
13347 .get = alc_ch_mode_get,
13348 .put = alc_ch_mode_put,
13349 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13350 },
13351 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013352};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013353
13354static struct snd_kcontrol_new alc861_asus_mixer[] = {
13355 /* output mixer control */
13356 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13357 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13358 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13359 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13360 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13361
13362 /* Input mixer control */
13363 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13364 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13365 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13366 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13367 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13368 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13369 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13370 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13371 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013372 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13373
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013374 {
13375 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13376 .name = "Channel Mode",
13377 .info = alc_ch_mode_info,
13378 .get = alc_ch_mode_get,
13379 .put = alc_ch_mode_put,
13380 .private_value = ARRAY_SIZE(alc861_asus_modes),
13381 },
13382 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013383};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013384
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013385/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013386static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013387 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13388 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013389 { }
13390};
13391
Kailang Yangdf694da2005-12-05 19:42:22 +010013392/*
13393 * generic initialization of ADC, input mixers and output mixers
13394 */
13395static struct hda_verb alc861_base_init_verbs[] = {
13396 /*
13397 * Unmute ADC0 and set the default input to mic-in
13398 */
13399 /* port-A for surround (rear panel) */
13400 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13401 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13402 /* port-B for mic-in (rear panel) with vref */
13403 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13404 /* port-C for line-in (rear panel) */
13405 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13406 /* port-D for Front */
13407 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13408 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13409 /* port-E for HP out (front panel) */
13410 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13411 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013412 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013413 /* port-F for mic-in (front panel) with vref */
13414 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13415 /* port-G for CLFE (rear panel) */
13416 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13417 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13418 /* port-H for side (rear panel) */
13419 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13420 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13421 /* CD-in */
13422 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13423 /* route front mic to ADC1*/
13424 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13425 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013426
Kailang Yangdf694da2005-12-05 19:42:22 +010013427 /* Unmute DAC0~3 & spdif out*/
13428 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13429 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13430 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13431 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013433
Kailang Yangdf694da2005-12-05 19:42:22 +010013434 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13435 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13436 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13437 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13438 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013439
Kailang Yangdf694da2005-12-05 19:42:22 +010013440 /* Unmute Stereo Mixer 15 */
13441 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13442 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13443 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013444 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013445
13446 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13447 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13448 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13449 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13450 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13451 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13452 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13453 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013454 /* hp used DAC 3 (Front) */
13455 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013456 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13457
13458 { }
13459};
13460
13461static struct hda_verb alc861_threestack_init_verbs[] = {
13462 /*
13463 * Unmute ADC0 and set the default input to mic-in
13464 */
13465 /* port-A for surround (rear panel) */
13466 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13467 /* port-B for mic-in (rear panel) with vref */
13468 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13469 /* port-C for line-in (rear panel) */
13470 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13471 /* port-D for Front */
13472 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13473 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13474 /* port-E for HP out (front panel) */
13475 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13476 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013477 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013478 /* port-F for mic-in (front panel) with vref */
13479 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13480 /* port-G for CLFE (rear panel) */
13481 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13482 /* port-H for side (rear panel) */
13483 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13484 /* CD-in */
13485 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13486 /* route front mic to ADC1*/
13487 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13488 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13489 /* Unmute DAC0~3 & spdif out*/
13490 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13491 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13492 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13493 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13494 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013495
Kailang Yangdf694da2005-12-05 19:42:22 +010013496 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13497 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13498 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13499 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13500 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013501
Kailang Yangdf694da2005-12-05 19:42:22 +010013502 /* Unmute Stereo Mixer 15 */
13503 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13504 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13505 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013506 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013507
13508 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13509 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13510 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13511 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13512 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13513 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13514 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13515 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013516 /* hp used DAC 3 (Front) */
13517 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013518 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13519 { }
13520};
Takashi Iwai22309c32006-08-09 16:57:28 +020013521
13522static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13523 /*
13524 * Unmute ADC0 and set the default input to mic-in
13525 */
13526 /* port-A for surround (rear panel) */
13527 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13528 /* port-B for mic-in (rear panel) with vref */
13529 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13530 /* port-C for line-in (rear panel) */
13531 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13532 /* port-D for Front */
13533 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13534 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13535 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013536 /* this has to be set to VREF80 */
13537 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013538 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013539 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013540 /* port-F for mic-in (front panel) with vref */
13541 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13542 /* port-G for CLFE (rear panel) */
13543 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13544 /* port-H for side (rear panel) */
13545 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13546 /* CD-in */
13547 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13548 /* route front mic to ADC1*/
13549 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13550 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13551 /* Unmute DAC0~3 & spdif out*/
13552 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13553 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13554 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13555 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13556 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013557
Takashi Iwai22309c32006-08-09 16:57:28 +020013558 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13559 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13560 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13561 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13562 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013563
Takashi Iwai22309c32006-08-09 16:57:28 +020013564 /* Unmute Stereo Mixer 15 */
13565 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13566 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13567 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013568 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013569
13570 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13571 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13572 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13573 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13574 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13575 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13576 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13577 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013578 /* hp used DAC 3 (Front) */
13579 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013580 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13581 { }
13582};
13583
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013584static struct hda_verb alc861_asus_init_verbs[] = {
13585 /*
13586 * Unmute ADC0 and set the default input to mic-in
13587 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013588 /* port-A for surround (rear panel)
13589 * according to codec#0 this is the HP jack
13590 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013591 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13592 /* route front PCM to HP */
13593 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13594 /* port-B for mic-in (rear panel) with vref */
13595 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13596 /* port-C for line-in (rear panel) */
13597 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13598 /* port-D for Front */
13599 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13600 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13601 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013602 /* this has to be set to VREF80 */
13603 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013604 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013605 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013606 /* port-F for mic-in (front panel) with vref */
13607 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13608 /* port-G for CLFE (rear panel) */
13609 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13610 /* port-H for side (rear panel) */
13611 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13612 /* CD-in */
13613 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13614 /* route front mic to ADC1*/
13615 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13616 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13617 /* Unmute DAC0~3 & spdif out*/
13618 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13619 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13620 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13621 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13622 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13623 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13624 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13625 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13626 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13627 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013628
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013629 /* Unmute Stereo Mixer 15 */
13630 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13631 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13632 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013633 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013634
13635 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13636 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13637 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13638 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13639 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13640 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13641 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13642 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013643 /* hp used DAC 3 (Front) */
13644 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013645 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13646 { }
13647};
13648
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013649/* additional init verbs for ASUS laptops */
13650static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13651 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13652 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13653 { }
13654};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013655
Kailang Yangdf694da2005-12-05 19:42:22 +010013656/*
13657 * generic initialization of ADC, input mixers and output mixers
13658 */
13659static struct hda_verb alc861_auto_init_verbs[] = {
13660 /*
13661 * Unmute ADC0 and set the default input to mic-in
13662 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013663 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013664 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013665
Kailang Yangdf694da2005-12-05 19:42:22 +010013666 /* Unmute DAC0~3 & spdif out*/
13667 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13668 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13669 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13670 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013672
Kailang Yangdf694da2005-12-05 19:42:22 +010013673 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13674 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13675 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13676 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13677 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013678
Kailang Yangdf694da2005-12-05 19:42:22 +010013679 /* Unmute Stereo Mixer 15 */
13680 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13681 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13682 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13683 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13684
13685 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13686 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13687 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13688 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13689 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13690 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13691 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13692 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13693
13694 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13695 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013696 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13697 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013698 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13699 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013700 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13701 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013702
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013703 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013704
13705 { }
13706};
13707
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013708static struct hda_verb alc861_toshiba_init_verbs[] = {
13709 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013710
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013711 { }
13712};
13713
13714/* toggle speaker-output according to the hp-jack state */
13715static void alc861_toshiba_automute(struct hda_codec *codec)
13716{
13717 unsigned int present;
13718
13719 present = snd_hda_codec_read(codec, 0x0f, 0,
13720 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013721 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13722 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13723 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13724 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013725}
13726
13727static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13728 unsigned int res)
13729{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013730 if ((res >> 26) == ALC880_HP_EVENT)
13731 alc861_toshiba_automute(codec);
13732}
13733
Kailang Yangdf694da2005-12-05 19:42:22 +010013734/* pcm configuration: identiacal with ALC880 */
13735#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13736#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13737#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13738#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13739
13740
13741#define ALC861_DIGOUT_NID 0x07
13742
13743static struct hda_channel_mode alc861_8ch_modes[1] = {
13744 { 8, NULL }
13745};
13746
13747static hda_nid_t alc861_dac_nids[4] = {
13748 /* front, surround, clfe, side */
13749 0x03, 0x06, 0x05, 0x04
13750};
13751
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013752static hda_nid_t alc660_dac_nids[3] = {
13753 /* front, clfe, surround */
13754 0x03, 0x05, 0x06
13755};
13756
Kailang Yangdf694da2005-12-05 19:42:22 +010013757static hda_nid_t alc861_adc_nids[1] = {
13758 /* ADC0-2 */
13759 0x08,
13760};
13761
13762static struct hda_input_mux alc861_capture_source = {
13763 .num_items = 5,
13764 .items = {
13765 { "Mic", 0x0 },
13766 { "Front Mic", 0x3 },
13767 { "Line", 0x1 },
13768 { "CD", 0x4 },
13769 { "Mixer", 0x5 },
13770 },
13771};
13772
13773/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013774static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13775 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013776{
13777 int i;
13778 hda_nid_t nid;
13779
13780 spec->multiout.dac_nids = spec->private_dac_nids;
13781 for (i = 0; i < cfg->line_outs; i++) {
13782 nid = cfg->line_out_pins[i];
13783 if (nid) {
13784 if (i >= ARRAY_SIZE(alc861_dac_nids))
13785 continue;
13786 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13787 }
13788 }
13789 spec->multiout.num_dacs = cfg->line_outs;
13790 return 0;
13791}
13792
13793/* add playback controls from the parsed DAC table */
13794static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13795 const struct auto_pin_cfg *cfg)
13796{
13797 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013798 static const char *chname[4] = {
13799 "Front", "Surround", NULL /*CLFE*/, "Side"
13800 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013801 hda_nid_t nid;
13802 int i, idx, err;
13803
13804 for (i = 0; i < cfg->line_outs; i++) {
13805 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013806 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013807 continue;
13808 if (nid == 0x05) {
13809 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013810 err = add_control(spec, ALC_CTL_BIND_MUTE,
13811 "Center Playback Switch",
13812 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13813 HDA_OUTPUT));
13814 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013815 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013816 err = add_control(spec, ALC_CTL_BIND_MUTE,
13817 "LFE Playback Switch",
13818 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13819 HDA_OUTPUT));
13820 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013821 return err;
13822 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013823 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13824 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013825 if (nid == alc861_dac_nids[idx])
13826 break;
13827 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013828 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13829 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13830 HDA_OUTPUT));
13831 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013832 return err;
13833 }
13834 }
13835 return 0;
13836}
13837
13838static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13839{
13840 int err;
13841 hda_nid_t nid;
13842
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013843 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013844 return 0;
13845
13846 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13847 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013848 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13849 "Headphone Playback Switch",
13850 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13851 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013852 return err;
13853 spec->multiout.hp_nid = nid;
13854 }
13855 return 0;
13856}
13857
13858/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013859static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13860 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013861{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013862 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013863 int i, err, idx, idx1;
13864
13865 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013866 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013867 case 0x0c:
13868 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013869 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013870 break;
13871 case 0x0f:
13872 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013873 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013874 break;
13875 case 0x0d:
13876 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013877 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013878 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013879 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013880 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013881 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013882 break;
13883 case 0x11:
13884 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013885 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013886 break;
13887 default:
13888 continue;
13889 }
13890
Takashi Iwai4a471b72005-12-07 13:56:29 +010013891 err = new_analog_input(spec, cfg->input_pins[i],
13892 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013893 if (err < 0)
13894 return err;
13895
Takashi Iwai4a471b72005-12-07 13:56:29 +010013896 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013897 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013898 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013899 }
13900 return 0;
13901}
13902
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013903static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13904 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013905 int pin_type, int dac_idx)
13906{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013907 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13908 pin_type);
13909 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13910 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013911}
13912
13913static void alc861_auto_init_multi_out(struct hda_codec *codec)
13914{
13915 struct alc_spec *spec = codec->spec;
13916 int i;
13917
13918 for (i = 0; i < spec->autocfg.line_outs; i++) {
13919 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013920 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013921 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013922 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013923 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013924 }
13925}
13926
13927static void alc861_auto_init_hp_out(struct hda_codec *codec)
13928{
13929 struct alc_spec *spec = codec->spec;
13930 hda_nid_t pin;
13931
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013932 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013933 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013934 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13935 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013936 pin = spec->autocfg.speaker_pins[0];
13937 if (pin)
13938 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013939}
13940
13941static void alc861_auto_init_analog_input(struct hda_codec *codec)
13942{
13943 struct alc_spec *spec = codec->spec;
13944 int i;
13945
13946 for (i = 0; i < AUTO_PIN_LAST; i++) {
13947 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010013948 if (nid >= 0x0c && nid <= 0x11)
13949 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010013950 }
13951}
13952
13953/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013954/* return 1 if successful, 0 if the proper config is not found,
13955 * or a negative error code
13956 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013957static int alc861_parse_auto_config(struct hda_codec *codec)
13958{
13959 struct alc_spec *spec = codec->spec;
13960 int err;
13961 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13962
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013963 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13964 alc861_ignore);
13965 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013966 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013967 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013968 return 0; /* can't find valid BIOS pin config */
13969
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013970 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13971 if (err < 0)
13972 return err;
13973 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13974 if (err < 0)
13975 return err;
13976 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13977 if (err < 0)
13978 return err;
13979 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13980 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013981 return err;
13982
13983 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13984
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013985 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013986 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13987
Takashi Iwai603c4012008-07-30 15:01:44 +020013988 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013989 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013990
Takashi Iwaid88897e2008-10-31 15:01:37 +010013991 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013992
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013993 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013994 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013995
13996 spec->adc_nids = alc861_adc_nids;
13997 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013998 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013999
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014000 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14001
Kailang Yangdf694da2005-12-05 19:42:22 +010014002 return 1;
14003}
14004
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014005/* additional initialization for auto-configuration model */
14006static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014007{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014008 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014009 alc861_auto_init_multi_out(codec);
14010 alc861_auto_init_hp_out(codec);
14011 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014012 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014013 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014014}
14015
Takashi Iwaicb53c622007-08-10 17:21:45 +020014016#ifdef CONFIG_SND_HDA_POWER_SAVE
14017static struct hda_amp_list alc861_loopbacks[] = {
14018 { 0x15, HDA_INPUT, 0 },
14019 { 0x15, HDA_INPUT, 1 },
14020 { 0x15, HDA_INPUT, 2 },
14021 { 0x15, HDA_INPUT, 3 },
14022 { } /* end */
14023};
14024#endif
14025
Kailang Yangdf694da2005-12-05 19:42:22 +010014026
14027/*
14028 * configuration and preset
14029 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014030static const char *alc861_models[ALC861_MODEL_LAST] = {
14031 [ALC861_3ST] = "3stack",
14032 [ALC660_3ST] = "3stack-660",
14033 [ALC861_3ST_DIG] = "3stack-dig",
14034 [ALC861_6ST_DIG] = "6stack-dig",
14035 [ALC861_UNIWILL_M31] = "uniwill-m31",
14036 [ALC861_TOSHIBA] = "toshiba",
14037 [ALC861_ASUS] = "asus",
14038 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14039 [ALC861_AUTO] = "auto",
14040};
14041
14042static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014043 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014044 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14045 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14046 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014047 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014048 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014049 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014050 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14051 * Any other models that need this preset?
14052 */
14053 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014054 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14055 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014056 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14057 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14058 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14059 /* FIXME: the below seems conflict */
14060 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14061 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14062 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014063 {}
14064};
14065
14066static struct alc_config_preset alc861_presets[] = {
14067 [ALC861_3ST] = {
14068 .mixers = { alc861_3ST_mixer },
14069 .init_verbs = { alc861_threestack_init_verbs },
14070 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14071 .dac_nids = alc861_dac_nids,
14072 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14073 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014074 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014075 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14076 .adc_nids = alc861_adc_nids,
14077 .input_mux = &alc861_capture_source,
14078 },
14079 [ALC861_3ST_DIG] = {
14080 .mixers = { alc861_base_mixer },
14081 .init_verbs = { alc861_threestack_init_verbs },
14082 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14083 .dac_nids = alc861_dac_nids,
14084 .dig_out_nid = ALC861_DIGOUT_NID,
14085 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14086 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014087 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014088 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14089 .adc_nids = alc861_adc_nids,
14090 .input_mux = &alc861_capture_source,
14091 },
14092 [ALC861_6ST_DIG] = {
14093 .mixers = { alc861_base_mixer },
14094 .init_verbs = { alc861_base_init_verbs },
14095 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14096 .dac_nids = alc861_dac_nids,
14097 .dig_out_nid = ALC861_DIGOUT_NID,
14098 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14099 .channel_mode = alc861_8ch_modes,
14100 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14101 .adc_nids = alc861_adc_nids,
14102 .input_mux = &alc861_capture_source,
14103 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014104 [ALC660_3ST] = {
14105 .mixers = { alc861_3ST_mixer },
14106 .init_verbs = { alc861_threestack_init_verbs },
14107 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14108 .dac_nids = alc660_dac_nids,
14109 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14110 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014111 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014112 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14113 .adc_nids = alc861_adc_nids,
14114 .input_mux = &alc861_capture_source,
14115 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014116 [ALC861_UNIWILL_M31] = {
14117 .mixers = { alc861_uniwill_m31_mixer },
14118 .init_verbs = { alc861_uniwill_m31_init_verbs },
14119 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14120 .dac_nids = alc861_dac_nids,
14121 .dig_out_nid = ALC861_DIGOUT_NID,
14122 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14123 .channel_mode = alc861_uniwill_m31_modes,
14124 .need_dac_fix = 1,
14125 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14126 .adc_nids = alc861_adc_nids,
14127 .input_mux = &alc861_capture_source,
14128 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014129 [ALC861_TOSHIBA] = {
14130 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014131 .init_verbs = { alc861_base_init_verbs,
14132 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014133 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14134 .dac_nids = alc861_dac_nids,
14135 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14136 .channel_mode = alc883_3ST_2ch_modes,
14137 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14138 .adc_nids = alc861_adc_nids,
14139 .input_mux = &alc861_capture_source,
14140 .unsol_event = alc861_toshiba_unsol_event,
14141 .init_hook = alc861_toshiba_automute,
14142 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014143 [ALC861_ASUS] = {
14144 .mixers = { alc861_asus_mixer },
14145 .init_verbs = { alc861_asus_init_verbs },
14146 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14147 .dac_nids = alc861_dac_nids,
14148 .dig_out_nid = ALC861_DIGOUT_NID,
14149 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14150 .channel_mode = alc861_asus_modes,
14151 .need_dac_fix = 1,
14152 .hp_nid = 0x06,
14153 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14154 .adc_nids = alc861_adc_nids,
14155 .input_mux = &alc861_capture_source,
14156 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014157 [ALC861_ASUS_LAPTOP] = {
14158 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14159 .init_verbs = { alc861_asus_init_verbs,
14160 alc861_asus_laptop_init_verbs },
14161 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14162 .dac_nids = alc861_dac_nids,
14163 .dig_out_nid = ALC861_DIGOUT_NID,
14164 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14165 .channel_mode = alc883_3ST_2ch_modes,
14166 .need_dac_fix = 1,
14167 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14168 .adc_nids = alc861_adc_nids,
14169 .input_mux = &alc861_capture_source,
14170 },
14171};
Kailang Yangdf694da2005-12-05 19:42:22 +010014172
14173
14174static int patch_alc861(struct hda_codec *codec)
14175{
14176 struct alc_spec *spec;
14177 int board_config;
14178 int err;
14179
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014180 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014181 if (spec == NULL)
14182 return -ENOMEM;
14183
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014184 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014185
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014186 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14187 alc861_models,
14188 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014189
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014190 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020014191 printk(KERN_INFO "hda_codec: Unknown model for %s, "
14192 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014193 board_config = ALC861_AUTO;
14194 }
14195
14196 if (board_config == ALC861_AUTO) {
14197 /* automatic parse from the BIOS config */
14198 err = alc861_parse_auto_config(codec);
14199 if (err < 0) {
14200 alc_free(codec);
14201 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014202 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014203 printk(KERN_INFO
14204 "hda_codec: Cannot set up configuration "
14205 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014206 board_config = ALC861_3ST_DIG;
14207 }
14208 }
14209
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014210 err = snd_hda_attach_beep_device(codec, 0x23);
14211 if (err < 0) {
14212 alc_free(codec);
14213 return err;
14214 }
14215
Kailang Yangdf694da2005-12-05 19:42:22 +010014216 if (board_config != ALC861_AUTO)
14217 setup_preset(spec, &alc861_presets[board_config]);
14218
Kailang Yangdf694da2005-12-05 19:42:22 +010014219 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14220 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14221
Kailang Yangdf694da2005-12-05 19:42:22 +010014222 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14223 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14224
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014225 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14226
Takashi Iwai2134ea42008-01-10 16:53:55 +010014227 spec->vmaster_nid = 0x03;
14228
Kailang Yangdf694da2005-12-05 19:42:22 +010014229 codec->patch_ops = alc_patch_ops;
14230 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014231 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014232#ifdef CONFIG_SND_HDA_POWER_SAVE
14233 if (!spec->loopback.amplist)
14234 spec->loopback.amplist = alc861_loopbacks;
14235#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014236 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014237
Kailang Yangdf694da2005-12-05 19:42:22 +010014238 return 0;
14239}
14240
14241/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014242 * ALC861-VD support
14243 *
14244 * Based on ALC882
14245 *
14246 * In addition, an independent DAC
14247 */
14248#define ALC861VD_DIGOUT_NID 0x06
14249
14250static hda_nid_t alc861vd_dac_nids[4] = {
14251 /* front, surr, clfe, side surr */
14252 0x02, 0x03, 0x04, 0x05
14253};
14254
14255/* dac_nids for ALC660vd are in a different order - according to
14256 * Realtek's driver.
14257 * This should probably tesult in a different mixer for 6stack models
14258 * of ALC660vd codecs, but for now there is only 3stack mixer
14259 * - and it is the same as in 861vd.
14260 * adc_nids in ALC660vd are (is) the same as in 861vd
14261 */
14262static hda_nid_t alc660vd_dac_nids[3] = {
14263 /* front, rear, clfe, rear_surr */
14264 0x02, 0x04, 0x03
14265};
14266
14267static hda_nid_t alc861vd_adc_nids[1] = {
14268 /* ADC0 */
14269 0x09,
14270};
14271
Takashi Iwaie1406342008-02-11 18:32:32 +010014272static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14273
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014274/* input MUX */
14275/* FIXME: should be a matrix-type input source selection */
14276static struct hda_input_mux alc861vd_capture_source = {
14277 .num_items = 4,
14278 .items = {
14279 { "Mic", 0x0 },
14280 { "Front Mic", 0x1 },
14281 { "Line", 0x2 },
14282 { "CD", 0x4 },
14283 },
14284};
14285
Kailang Yang272a5272007-05-14 11:00:38 +020014286static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014287 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014288 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014289 { "Ext Mic", 0x0 },
14290 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014291 },
14292};
14293
Kailang Yangd1a991a2007-08-15 16:21:59 +020014294static struct hda_input_mux alc861vd_hp_capture_source = {
14295 .num_items = 2,
14296 .items = {
14297 { "Front Mic", 0x0 },
14298 { "ATAPI Mic", 0x1 },
14299 },
14300};
14301
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014302/*
14303 * 2ch mode
14304 */
14305static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14306 { 2, NULL }
14307};
14308
14309/*
14310 * 6ch mode
14311 */
14312static struct hda_verb alc861vd_6stack_ch6_init[] = {
14313 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14314 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14315 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14316 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14317 { } /* end */
14318};
14319
14320/*
14321 * 8ch mode
14322 */
14323static struct hda_verb alc861vd_6stack_ch8_init[] = {
14324 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14325 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14326 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14327 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14328 { } /* end */
14329};
14330
14331static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14332 { 6, alc861vd_6stack_ch6_init },
14333 { 8, alc861vd_6stack_ch8_init },
14334};
14335
14336static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14337 {
14338 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14339 .name = "Channel Mode",
14340 .info = alc_ch_mode_info,
14341 .get = alc_ch_mode_get,
14342 .put = alc_ch_mode_put,
14343 },
14344 { } /* end */
14345};
14346
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014347/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14348 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14349 */
14350static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14351 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14352 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14353
14354 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14355 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14356
14357 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14358 HDA_OUTPUT),
14359 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14360 HDA_OUTPUT),
14361 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14362 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14363
14364 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14365 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14366
14367 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14368
14369 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14370 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14371 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14372
14373 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14374 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14375 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14376
14377 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14378 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14379
14380 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14381 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14382
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014383 { } /* end */
14384};
14385
14386static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14387 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14388 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14389
14390 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14391
14392 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14393 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14395
14396 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14397 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14398 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14399
14400 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14401 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14402
14403 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14404 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14405
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014406 { } /* end */
14407};
14408
Kailang Yangbdd148a2007-05-08 15:19:08 +020014409static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14410 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14411 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14412 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14413
14414 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14415
14416 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14417 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14418 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14419
14420 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14421 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14422 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14423
14424 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14425 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14426
14427 { } /* end */
14428};
14429
Tobin Davisb419f342008-03-07 11:57:51 +010014430/* Pin assignment: Speaker=0x14, HP = 0x15,
14431 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014432 */
14433static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014434 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14435 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014436 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14437 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014438 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14439 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14440 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14441 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14442 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14443 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014444 { } /* end */
14445};
14446
Kailang Yangd1a991a2007-08-15 16:21:59 +020014447/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14448 * Front Mic=0x18, ATAPI Mic = 0x19,
14449 */
14450static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14451 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14452 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14453 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14454 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14455 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14456 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14457 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14458 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014459
Kailang Yangd1a991a2007-08-15 16:21:59 +020014460 { } /* end */
14461};
14462
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014463/*
14464 * generic initialization of ADC, input mixers and output mixers
14465 */
14466static struct hda_verb alc861vd_volume_init_verbs[] = {
14467 /*
14468 * Unmute ADC0 and set the default input to mic-in
14469 */
14470 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14471 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14472
14473 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14474 * the analog-loopback mixer widget
14475 */
14476 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014477 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14478 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14479 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14480 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14481 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014482
14483 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014484 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14485 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14486 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014487 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014488
14489 /*
14490 * Set up output mixers (0x02 - 0x05)
14491 */
14492 /* set vol=0 to output mixers */
14493 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14494 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14495 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14496 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14497
14498 /* set up input amps for analog loopback */
14499 /* Amp Indices: DAC = 0, mixer = 1 */
14500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14502 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14503 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14504 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14505 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14506 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14507 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14508
14509 { }
14510};
14511
14512/*
14513 * 3-stack pin configuration:
14514 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14515 */
14516static struct hda_verb alc861vd_3stack_init_verbs[] = {
14517 /*
14518 * Set pin mode and muting
14519 */
14520 /* set front pin widgets 0x14 for output */
14521 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14522 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14523 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14524
14525 /* Mic (rear) pin: input vref at 80% */
14526 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14527 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14528 /* Front Mic pin: input vref at 80% */
14529 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14530 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14531 /* Line In pin: input */
14532 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14533 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14534 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14535 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14536 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14537 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14538 /* CD pin widget for input */
14539 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14540
14541 { }
14542};
14543
14544/*
14545 * 6-stack pin configuration:
14546 */
14547static struct hda_verb alc861vd_6stack_init_verbs[] = {
14548 /*
14549 * Set pin mode and muting
14550 */
14551 /* set front pin widgets 0x14 for output */
14552 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14553 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14554 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14555
14556 /* Rear Pin: output 1 (0x0d) */
14557 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14558 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14559 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14560 /* CLFE Pin: output 2 (0x0e) */
14561 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14562 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14563 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14564 /* Side Pin: output 3 (0x0f) */
14565 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14566 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14567 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14568
14569 /* Mic (rear) pin: input vref at 80% */
14570 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14571 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14572 /* Front Mic pin: input vref at 80% */
14573 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14574 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14575 /* Line In pin: input */
14576 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14577 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14578 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14579 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14580 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14581 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14582 /* CD pin widget for input */
14583 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14584
14585 { }
14586};
14587
Kailang Yangbdd148a2007-05-08 15:19:08 +020014588static struct hda_verb alc861vd_eapd_verbs[] = {
14589 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14590 { }
14591};
14592
Kailang Yangf9423e72008-05-27 12:32:25 +020014593static struct hda_verb alc660vd_eapd_verbs[] = {
14594 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14595 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14596 { }
14597};
14598
Kailang Yangbdd148a2007-05-08 15:19:08 +020014599static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14600 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14601 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14602 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14603 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014604 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014605 {}
14606};
14607
Kailang Yangbdd148a2007-05-08 15:19:08 +020014608static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14609{
14610 unsigned int present;
14611 unsigned char bits;
14612
14613 present = snd_hda_codec_read(codec, 0x18, 0,
14614 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014615 bits = present ? HDA_AMP_MUTE : 0;
14616 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14617 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014618}
14619
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014620static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020014621{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014622 struct alc_spec *spec = codec->spec;
14623
14624 spec->autocfg.hp_pins[0] = 0x1b;
14625 spec->autocfg.speaker_pins[0] = 0x14;
14626 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014627 alc861vd_lenovo_mic_automute(codec);
14628}
14629
14630static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14631 unsigned int res)
14632{
14633 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020014634 case ALC880_MIC_EVENT:
14635 alc861vd_lenovo_mic_automute(codec);
14636 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014637 default:
14638 alc_automute_amp_unsol_event(codec, res);
14639 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020014640 }
14641}
14642
Kailang Yang272a5272007-05-14 11:00:38 +020014643static struct hda_verb alc861vd_dallas_verbs[] = {
14644 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14645 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14646 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14647 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14648
14649 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14650 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14651 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14652 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14653 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14654 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14655 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14656 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014657
Kailang Yang272a5272007-05-14 11:00:38 +020014658 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14660 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14661 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14662 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14663 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14664 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14665 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14666
14667 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14668 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14669 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14670 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14671 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14672 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14673 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14674 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14675
14676 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14677 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14678 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14680
14681 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014682 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014683 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14684
14685 { } /* end */
14686};
14687
14688/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014689static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020014690{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014691 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020014692
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014693 spec->autocfg.hp_pins[0] = 0x15;
14694 spec->autocfg.speaker_pins[0] = 0x14;
14695 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020014696}
14697
Takashi Iwaicb53c622007-08-10 17:21:45 +020014698#ifdef CONFIG_SND_HDA_POWER_SAVE
14699#define alc861vd_loopbacks alc880_loopbacks
14700#endif
14701
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014702/* pcm configuration: identiacal with ALC880 */
14703#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14704#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14705#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14706#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14707
14708/*
14709 * configuration and preset
14710 */
14711static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14712 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014713 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014714 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014715 [ALC861VD_3ST] = "3stack",
14716 [ALC861VD_3ST_DIG] = "3stack-digout",
14717 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014718 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014719 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014720 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014721 [ALC861VD_AUTO] = "auto",
14722};
14723
14724static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014725 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14726 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014727 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014728 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014729 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014730 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014731 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014732 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014733 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014734 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014735 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014736 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014737 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014738 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014739 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014740 {}
14741};
14742
14743static struct alc_config_preset alc861vd_presets[] = {
14744 [ALC660VD_3ST] = {
14745 .mixers = { alc861vd_3st_mixer },
14746 .init_verbs = { alc861vd_volume_init_verbs,
14747 alc861vd_3stack_init_verbs },
14748 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14749 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014750 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14751 .channel_mode = alc861vd_3stack_2ch_modes,
14752 .input_mux = &alc861vd_capture_source,
14753 },
Mike Crash6963f842007-06-25 12:12:51 +020014754 [ALC660VD_3ST_DIG] = {
14755 .mixers = { alc861vd_3st_mixer },
14756 .init_verbs = { alc861vd_volume_init_verbs,
14757 alc861vd_3stack_init_verbs },
14758 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14759 .dac_nids = alc660vd_dac_nids,
14760 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014761 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14762 .channel_mode = alc861vd_3stack_2ch_modes,
14763 .input_mux = &alc861vd_capture_source,
14764 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014765 [ALC861VD_3ST] = {
14766 .mixers = { alc861vd_3st_mixer },
14767 .init_verbs = { alc861vd_volume_init_verbs,
14768 alc861vd_3stack_init_verbs },
14769 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14770 .dac_nids = alc861vd_dac_nids,
14771 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14772 .channel_mode = alc861vd_3stack_2ch_modes,
14773 .input_mux = &alc861vd_capture_source,
14774 },
14775 [ALC861VD_3ST_DIG] = {
14776 .mixers = { alc861vd_3st_mixer },
14777 .init_verbs = { alc861vd_volume_init_verbs,
14778 alc861vd_3stack_init_verbs },
14779 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14780 .dac_nids = alc861vd_dac_nids,
14781 .dig_out_nid = ALC861VD_DIGOUT_NID,
14782 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14783 .channel_mode = alc861vd_3stack_2ch_modes,
14784 .input_mux = &alc861vd_capture_source,
14785 },
14786 [ALC861VD_6ST_DIG] = {
14787 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14788 .init_verbs = { alc861vd_volume_init_verbs,
14789 alc861vd_6stack_init_verbs },
14790 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14791 .dac_nids = alc861vd_dac_nids,
14792 .dig_out_nid = ALC861VD_DIGOUT_NID,
14793 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14794 .channel_mode = alc861vd_6stack_modes,
14795 .input_mux = &alc861vd_capture_source,
14796 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014797 [ALC861VD_LENOVO] = {
14798 .mixers = { alc861vd_lenovo_mixer },
14799 .init_verbs = { alc861vd_volume_init_verbs,
14800 alc861vd_3stack_init_verbs,
14801 alc861vd_eapd_verbs,
14802 alc861vd_lenovo_unsol_verbs },
14803 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14804 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014805 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14806 .channel_mode = alc861vd_3stack_2ch_modes,
14807 .input_mux = &alc861vd_capture_source,
14808 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014809 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014810 },
Kailang Yang272a5272007-05-14 11:00:38 +020014811 [ALC861VD_DALLAS] = {
14812 .mixers = { alc861vd_dallas_mixer },
14813 .init_verbs = { alc861vd_dallas_verbs },
14814 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14815 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014816 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14817 .channel_mode = alc861vd_3stack_2ch_modes,
14818 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014819 .unsol_event = alc_automute_amp_unsol_event,
14820 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014821 },
14822 [ALC861VD_HP] = {
14823 .mixers = { alc861vd_hp_mixer },
14824 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14825 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14826 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014827 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014828 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14829 .channel_mode = alc861vd_3stack_2ch_modes,
14830 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014831 .unsol_event = alc_automute_amp_unsol_event,
14832 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020014833 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014834 [ALC660VD_ASUS_V1S] = {
14835 .mixers = { alc861vd_lenovo_mixer },
14836 .init_verbs = { alc861vd_volume_init_verbs,
14837 alc861vd_3stack_init_verbs,
14838 alc861vd_eapd_verbs,
14839 alc861vd_lenovo_unsol_verbs },
14840 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14841 .dac_nids = alc660vd_dac_nids,
14842 .dig_out_nid = ALC861VD_DIGOUT_NID,
14843 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14844 .channel_mode = alc861vd_3stack_2ch_modes,
14845 .input_mux = &alc861vd_capture_source,
14846 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014847 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010014848 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014849};
14850
14851/*
14852 * BIOS auto configuration
14853 */
14854static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14855 hda_nid_t nid, int pin_type, int dac_idx)
14856{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014857 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014858}
14859
14860static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14861{
14862 struct alc_spec *spec = codec->spec;
14863 int i;
14864
14865 for (i = 0; i <= HDA_SIDE; i++) {
14866 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014867 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014868 if (nid)
14869 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014870 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014871 }
14872}
14873
14874
14875static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14876{
14877 struct alc_spec *spec = codec->spec;
14878 hda_nid_t pin;
14879
14880 pin = spec->autocfg.hp_pins[0];
14881 if (pin) /* connect to front and use dac 0 */
14882 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014883 pin = spec->autocfg.speaker_pins[0];
14884 if (pin)
14885 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014886}
14887
14888#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14889#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14890
14891static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14892{
14893 struct alc_spec *spec = codec->spec;
14894 int i;
14895
14896 for (i = 0; i < AUTO_PIN_LAST; i++) {
14897 hda_nid_t nid = spec->autocfg.input_pins[i];
14898 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010014899 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010014900 if (nid != ALC861VD_PIN_CD_NID &&
14901 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014902 snd_hda_codec_write(codec, nid, 0,
14903 AC_VERB_SET_AMP_GAIN_MUTE,
14904 AMP_OUT_MUTE);
14905 }
14906 }
14907}
14908
Takashi Iwaif511b012008-08-15 16:46:42 +020014909#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14910
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014911#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14912#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14913
14914/* add playback controls from the parsed DAC table */
14915/* Based on ALC880 version. But ALC861VD has separate,
14916 * different NIDs for mute/unmute switch and volume control */
14917static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14918 const struct auto_pin_cfg *cfg)
14919{
14920 char name[32];
14921 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14922 hda_nid_t nid_v, nid_s;
14923 int i, err;
14924
14925 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014926 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014927 continue;
14928 nid_v = alc861vd_idx_to_mixer_vol(
14929 alc880_dac_to_idx(
14930 spec->multiout.dac_nids[i]));
14931 nid_s = alc861vd_idx_to_mixer_switch(
14932 alc880_dac_to_idx(
14933 spec->multiout.dac_nids[i]));
14934
14935 if (i == 2) {
14936 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014937 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14938 "Center Playback Volume",
14939 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14940 HDA_OUTPUT));
14941 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014942 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014943 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14944 "LFE Playback Volume",
14945 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14946 HDA_OUTPUT));
14947 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014948 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014949 err = add_control(spec, ALC_CTL_BIND_MUTE,
14950 "Center Playback Switch",
14951 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14952 HDA_INPUT));
14953 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014954 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014955 err = add_control(spec, ALC_CTL_BIND_MUTE,
14956 "LFE Playback Switch",
14957 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14958 HDA_INPUT));
14959 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014960 return err;
14961 } else {
14962 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014963 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14964 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14965 HDA_OUTPUT));
14966 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014967 return err;
14968 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014969 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014970 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014971 HDA_INPUT));
14972 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014973 return err;
14974 }
14975 }
14976 return 0;
14977}
14978
14979/* add playback controls for speaker and HP outputs */
14980/* Based on ALC880 version. But ALC861VD has separate,
14981 * different NIDs for mute/unmute switch and volume control */
14982static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14983 hda_nid_t pin, const char *pfx)
14984{
14985 hda_nid_t nid_v, nid_s;
14986 int err;
14987 char name[32];
14988
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014989 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014990 return 0;
14991
14992 if (alc880_is_fixed_pin(pin)) {
14993 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14994 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014995 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014996 spec->multiout.hp_nid = nid_v;
14997 else
14998 spec->multiout.extra_out_nid[0] = nid_v;
14999 /* control HP volume/switch on the output mixer amp */
15000 nid_v = alc861vd_idx_to_mixer_vol(
15001 alc880_fixed_pin_idx(pin));
15002 nid_s = alc861vd_idx_to_mixer_switch(
15003 alc880_fixed_pin_idx(pin));
15004
15005 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015006 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15007 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15008 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015009 return err;
15010 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015011 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15012 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15013 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015014 return err;
15015 } else if (alc880_is_multi_pin(pin)) {
15016 /* set manual connection */
15017 /* we have only a switch on HP-out PIN */
15018 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015019 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15020 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15021 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015022 return err;
15023 }
15024 return 0;
15025}
15026
15027/* parse the BIOS configuration and set up the alc_spec
15028 * return 1 if successful, 0 if the proper config is not found,
15029 * or a negative error code
15030 * Based on ALC880 version - had to change it to override
15031 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15032static int alc861vd_parse_auto_config(struct hda_codec *codec)
15033{
15034 struct alc_spec *spec = codec->spec;
15035 int err;
15036 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15037
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015038 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15039 alc861vd_ignore);
15040 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015041 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015042 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015043 return 0; /* can't find valid BIOS pin config */
15044
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015045 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15046 if (err < 0)
15047 return err;
15048 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15049 if (err < 0)
15050 return err;
15051 err = alc861vd_auto_create_extra_out(spec,
15052 spec->autocfg.speaker_pins[0],
15053 "Speaker");
15054 if (err < 0)
15055 return err;
15056 err = alc861vd_auto_create_extra_out(spec,
15057 spec->autocfg.hp_pins[0],
15058 "Headphone");
15059 if (err < 0)
15060 return err;
15061 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15062 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015063 return err;
15064
15065 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15066
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015067 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015068 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15069
Takashi Iwai603c4012008-07-30 15:01:44 +020015070 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015071 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015072
Takashi Iwaid88897e2008-10-31 15:01:37 +010015073 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015074
15075 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015076 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015077
Takashi Iwai776e1842007-08-29 15:07:11 +020015078 err = alc_auto_add_mic_boost(codec);
15079 if (err < 0)
15080 return err;
15081
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015082 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15083
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015084 return 1;
15085}
15086
15087/* additional initialization for auto-configuration model */
15088static void alc861vd_auto_init(struct hda_codec *codec)
15089{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015090 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015091 alc861vd_auto_init_multi_out(codec);
15092 alc861vd_auto_init_hp_out(codec);
15093 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015094 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015095 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015096 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015097}
15098
15099static int patch_alc861vd(struct hda_codec *codec)
15100{
15101 struct alc_spec *spec;
15102 int err, board_config;
15103
15104 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15105 if (spec == NULL)
15106 return -ENOMEM;
15107
15108 codec->spec = spec;
15109
15110 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15111 alc861vd_models,
15112 alc861vd_cfg_tbl);
15113
15114 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020015115 printk(KERN_INFO "hda_codec: Unknown model for %s, "
15116 "trying auto-probe from BIOS...\n", codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015117 board_config = ALC861VD_AUTO;
15118 }
15119
15120 if (board_config == ALC861VD_AUTO) {
15121 /* automatic parse from the BIOS config */
15122 err = alc861vd_parse_auto_config(codec);
15123 if (err < 0) {
15124 alc_free(codec);
15125 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015126 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015127 printk(KERN_INFO
15128 "hda_codec: Cannot set up configuration "
15129 "from BIOS. Using base mode...\n");
15130 board_config = ALC861VD_3ST;
15131 }
15132 }
15133
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015134 err = snd_hda_attach_beep_device(codec, 0x23);
15135 if (err < 0) {
15136 alc_free(codec);
15137 return err;
15138 }
15139
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015140 if (board_config != ALC861VD_AUTO)
15141 setup_preset(spec, &alc861vd_presets[board_config]);
15142
Kailang Yang2f893282008-05-27 12:14:47 +020015143 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015144 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015145 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015146 }
15147
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015148 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15149 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15150
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015151 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15152 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15153
15154 spec->adc_nids = alc861vd_adc_nids;
15155 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015156 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015157 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015158
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015159 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015160 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015161
Takashi Iwai2134ea42008-01-10 16:53:55 +010015162 spec->vmaster_nid = 0x02;
15163
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015164 codec->patch_ops = alc_patch_ops;
15165
15166 if (board_config == ALC861VD_AUTO)
15167 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015168#ifdef CONFIG_SND_HDA_POWER_SAVE
15169 if (!spec->loopback.amplist)
15170 spec->loopback.amplist = alc861vd_loopbacks;
15171#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015172 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015173
15174 return 0;
15175}
15176
15177/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015178 * ALC662 support
15179 *
15180 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15181 * configuration. Each pin widget can choose any input DACs and a mixer.
15182 * Each ADC is connected from a mixer of all inputs. This makes possible
15183 * 6-channel independent captures.
15184 *
15185 * In addition, an independent DAC for the multi-playback (not used in this
15186 * driver yet).
15187 */
15188#define ALC662_DIGOUT_NID 0x06
15189#define ALC662_DIGIN_NID 0x0a
15190
15191static hda_nid_t alc662_dac_nids[4] = {
15192 /* front, rear, clfe, rear_surr */
15193 0x02, 0x03, 0x04
15194};
15195
Kailang Yang622e84c2009-04-21 07:39:04 +020015196static hda_nid_t alc272_dac_nids[2] = {
15197 0x02, 0x03
15198};
15199
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015200static hda_nid_t alc662_adc_nids[1] = {
15201 /* ADC1-2 */
15202 0x09,
15203};
Takashi Iwaie1406342008-02-11 18:32:32 +010015204
Kailang Yang622e84c2009-04-21 07:39:04 +020015205static hda_nid_t alc272_adc_nids[1] = {
15206 /* ADC1-2 */
15207 0x08,
15208};
15209
Kailang Yang77a261b2008-02-19 11:38:05 +010015210static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015211static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15212
Takashi Iwaie1406342008-02-11 18:32:32 +010015213
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015214/* input MUX */
15215/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015216static struct hda_input_mux alc662_capture_source = {
15217 .num_items = 4,
15218 .items = {
15219 { "Mic", 0x0 },
15220 { "Front Mic", 0x1 },
15221 { "Line", 0x2 },
15222 { "CD", 0x4 },
15223 },
15224};
15225
15226static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15227 .num_items = 2,
15228 .items = {
15229 { "Mic", 0x1 },
15230 { "Line", 0x2 },
15231 },
15232};
Kailang Yang291702f2007-10-16 14:28:03 +020015233
15234static struct hda_input_mux alc662_eeepc_capture_source = {
15235 .num_items = 2,
15236 .items = {
15237 { "i-Mic", 0x1 },
15238 { "e-Mic", 0x0 },
15239 },
15240};
15241
Kailang Yang6dda9f42008-05-27 12:05:31 +020015242static struct hda_input_mux alc663_capture_source = {
15243 .num_items = 3,
15244 .items = {
15245 { "Mic", 0x0 },
15246 { "Front Mic", 0x1 },
15247 { "Line", 0x2 },
15248 },
15249};
15250
15251static struct hda_input_mux alc663_m51va_capture_source = {
15252 .num_items = 2,
15253 .items = {
15254 { "Ext-Mic", 0x0 },
15255 { "D-Mic", 0x9 },
15256 },
15257};
15258
Chris Pockelé9541ba12009-05-12 08:08:53 +020015259#if 1 /* set to 0 for testing other input sources below */
15260static struct hda_input_mux alc272_nc10_capture_source = {
15261 .num_items = 2,
15262 .items = {
15263 { "Autoselect Mic", 0x0 },
15264 { "Internal Mic", 0x1 },
15265 },
15266};
15267#else
15268static struct hda_input_mux alc272_nc10_capture_source = {
15269 .num_items = 16,
15270 .items = {
15271 { "Autoselect Mic", 0x0 },
15272 { "Internal Mic", 0x1 },
15273 { "In-0x02", 0x2 },
15274 { "In-0x03", 0x3 },
15275 { "In-0x04", 0x4 },
15276 { "In-0x05", 0x5 },
15277 { "In-0x06", 0x6 },
15278 { "In-0x07", 0x7 },
15279 { "In-0x08", 0x8 },
15280 { "In-0x09", 0x9 },
15281 { "In-0x0a", 0x0a },
15282 { "In-0x0b", 0x0b },
15283 { "In-0x0c", 0x0c },
15284 { "In-0x0d", 0x0d },
15285 { "In-0x0e", 0x0e },
15286 { "In-0x0f", 0x0f },
15287 },
15288};
15289#endif
15290
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015291/*
15292 * 2ch mode
15293 */
15294static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15295 { 2, NULL }
15296};
15297
15298/*
15299 * 2ch mode
15300 */
15301static struct hda_verb alc662_3ST_ch2_init[] = {
15302 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15303 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15304 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15305 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15306 { } /* end */
15307};
15308
15309/*
15310 * 6ch mode
15311 */
15312static struct hda_verb alc662_3ST_ch6_init[] = {
15313 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15314 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15315 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15316 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15317 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15318 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15319 { } /* end */
15320};
15321
15322static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15323 { 2, alc662_3ST_ch2_init },
15324 { 6, alc662_3ST_ch6_init },
15325};
15326
15327/*
15328 * 2ch mode
15329 */
15330static struct hda_verb alc662_sixstack_ch6_init[] = {
15331 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15332 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15333 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15334 { } /* end */
15335};
15336
15337/*
15338 * 6ch mode
15339 */
15340static struct hda_verb alc662_sixstack_ch8_init[] = {
15341 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15342 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15343 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15344 { } /* end */
15345};
15346
15347static struct hda_channel_mode alc662_5stack_modes[2] = {
15348 { 2, alc662_sixstack_ch6_init },
15349 { 6, alc662_sixstack_ch8_init },
15350};
15351
15352/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15353 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15354 */
15355
15356static struct snd_kcontrol_new alc662_base_mixer[] = {
15357 /* output mixer control */
15358 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015359 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015360 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015361 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015362 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15363 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015364 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15365 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015366 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15367
15368 /*Input mixer control */
15369 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15370 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15371 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15372 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15373 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15374 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15375 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15376 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015377 { } /* end */
15378};
15379
15380static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15381 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015382 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015383 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15384 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15385 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15386 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15387 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15388 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15389 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15390 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15391 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015392 { } /* end */
15393};
15394
15395static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15396 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015397 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015398 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015399 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015400 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15401 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015402 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15403 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015404 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15405 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15406 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15407 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15408 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15409 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15410 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15411 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15412 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015413 { } /* end */
15414};
15415
15416static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15417 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15418 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015419 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15420 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015421 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15422 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15423 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15424 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15425 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015426 { } /* end */
15427};
15428
Kailang Yang291702f2007-10-16 14:28:03 +020015429static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015430 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15431 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015432
15433 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15434 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15435 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15436
15437 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15438 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15439 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15440 { } /* end */
15441};
15442
Kailang Yang8c427222008-01-10 13:03:59 +010015443static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015444 ALC262_HIPPO_MASTER_SWITCH,
15445 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015446 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015447 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15448 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015449 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15450 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15451 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15452 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15453 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15454 { } /* end */
15455};
15456
Kailang Yangf1d4e282008-08-26 14:03:29 +020015457static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15458 .ops = &snd_hda_bind_vol,
15459 .values = {
15460 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15461 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15462 0
15463 },
15464};
15465
15466static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15467 .ops = &snd_hda_bind_sw,
15468 .values = {
15469 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15470 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15471 0
15472 },
15473};
15474
Kailang Yang6dda9f42008-05-27 12:05:31 +020015475static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015476 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15477 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15478 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15479 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15480 { } /* end */
15481};
15482
15483static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15484 .ops = &snd_hda_bind_sw,
15485 .values = {
15486 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15487 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15488 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15489 0
15490 },
15491};
15492
15493static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15494 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15495 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15496 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15497 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15498 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15499 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15500
15501 { } /* end */
15502};
15503
15504static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15505 .ops = &snd_hda_bind_sw,
15506 .values = {
15507 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15508 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15509 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15510 0
15511 },
15512};
15513
15514static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15515 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15516 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15517 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15518 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15519 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15520 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15521 { } /* end */
15522};
15523
15524static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015525 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15526 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015527 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15528 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15529 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15530 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15531 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15532 { } /* end */
15533};
15534
15535static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15536 .ops = &snd_hda_bind_vol,
15537 .values = {
15538 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15539 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15540 0
15541 },
15542};
15543
15544static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15545 .ops = &snd_hda_bind_sw,
15546 .values = {
15547 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15548 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15549 0
15550 },
15551};
15552
15553static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15554 HDA_BIND_VOL("Master Playback Volume",
15555 &alc663_asus_two_bind_master_vol),
15556 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15557 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015558 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15559 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15560 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015561 { } /* end */
15562};
15563
15564static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15565 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15566 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15567 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15568 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15569 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15570 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015571 { } /* end */
15572};
15573
15574static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15575 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15576 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15577 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15578 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15579 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15580
15581 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15582 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15583 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15584 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15585 { } /* end */
15586};
15587
15588static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15589 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15590 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15591 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15592
15593 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15594 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15595 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15596 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15597 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15598 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15599 { } /* end */
15600};
15601
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015602static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15603 {
15604 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15605 .name = "Channel Mode",
15606 .info = alc_ch_mode_info,
15607 .get = alc_ch_mode_get,
15608 .put = alc_ch_mode_put,
15609 },
15610 { } /* end */
15611};
15612
15613static struct hda_verb alc662_init_verbs[] = {
15614 /* ADC: mute amp left and right */
15615 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15616 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15617 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15618
Takashi Iwaicb53c622007-08-10 17:21:45 +020015619 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15620 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15621 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15622 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15623 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015624
Kailang Yangb60dd392007-09-20 12:50:29 +020015625 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15626 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15627 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15628 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15629 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15630 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015631
15632 /* Front Pin: output 0 (0x0c) */
15633 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15634 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15635
15636 /* Rear Pin: output 1 (0x0d) */
15637 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15638 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15639
15640 /* CLFE Pin: output 2 (0x0e) */
15641 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15642 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15643
15644 /* Mic (rear) pin: input vref at 80% */
15645 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15646 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15647 /* Front Mic pin: input vref at 80% */
15648 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15649 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15650 /* Line In pin: input */
15651 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15652 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15653 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15654 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15655 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15656 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15657 /* CD pin widget for input */
15658 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15659
15660 /* FIXME: use matrix-type input source selection */
15661 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15662 /* Input mixer */
15663 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015664 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015665
15666 /* always trun on EAPD */
15667 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15668 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15669
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015670 { }
15671};
15672
15673static struct hda_verb alc662_sue_init_verbs[] = {
15674 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15675 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015676 {}
15677};
15678
15679static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15680 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15681 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15682 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015683};
15684
Kailang Yang8c427222008-01-10 13:03:59 +010015685/* Set Unsolicited Event*/
15686static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15687 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15688 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15689 {}
15690};
15691
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015692/*
15693 * generic initialization of ADC, input mixers and output mixers
15694 */
15695static struct hda_verb alc662_auto_init_verbs[] = {
15696 /*
15697 * Unmute ADC and set the default input to mic-in
15698 */
15699 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15700 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15701
15702 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15703 * mixer widget
15704 * Note: PASD motherboards uses the Line In 2 as the input for front
15705 * panel mic (mic 2)
15706 */
15707 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015708 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15709 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15710 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15711 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15712 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015713
15714 /*
15715 * Set up output mixers (0x0c - 0x0f)
15716 */
15717 /* set vol=0 to output mixers */
15718 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15719 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15720 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15721
15722 /* set up input amps for analog loopback */
15723 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15725 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15726 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15727 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15728 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15729 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015730
15731
15732 /* FIXME: use matrix-type input source selection */
15733 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15734 /* Input mixer */
15735 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015736 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015737 { }
15738};
15739
Takashi Iwai24fb9172008-09-02 14:48:20 +020015740/* additional verbs for ALC663 */
15741static struct hda_verb alc663_auto_init_verbs[] = {
15742 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15743 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15744 { }
15745};
15746
Kailang Yang6dda9f42008-05-27 12:05:31 +020015747static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015748 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15749 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015750 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15751 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015752 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15753 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15754 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015755 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15756 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15757 {}
15758};
15759
Kailang Yangf1d4e282008-08-26 14:03:29 +020015760static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15761 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15762 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15763 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15764 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15765 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15766 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15767 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15768 {}
15769};
15770
15771static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15772 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15773 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15774 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15775 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15778 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15779 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15780 {}
15781};
15782
15783static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15784 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15785 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15786 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15787 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15788 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15789 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15790 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15791 {}
15792};
15793
15794static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15795 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15796 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15797 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15798 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15799 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15801 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15803 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15804 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15805 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15806 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15807 {}
15808};
15809
15810static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15811 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15812 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15813 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15814 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15815 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15816 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15817 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15818 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15819 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15820 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15821 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15822 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15823 {}
15824};
15825
Kailang Yang6dda9f42008-05-27 12:05:31 +020015826static struct hda_verb alc663_g71v_init_verbs[] = {
15827 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15828 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15829 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15830
15831 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15832 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15833 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15834
15835 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15836 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15837 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15838 {}
15839};
15840
15841static struct hda_verb alc663_g50v_init_verbs[] = {
15842 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15843 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15844 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15845
15846 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15847 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15848 {}
15849};
15850
Kailang Yangf1d4e282008-08-26 14:03:29 +020015851static struct hda_verb alc662_ecs_init_verbs[] = {
15852 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15853 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15854 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15855 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15856 {}
15857};
15858
Kailang Yang622e84c2009-04-21 07:39:04 +020015859static struct hda_verb alc272_dell_zm1_init_verbs[] = {
15860 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15861 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15862 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15863 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15864 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15865 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15866 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15867 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15868 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15869 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15870 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15871 {}
15872};
15873
15874static struct hda_verb alc272_dell_init_verbs[] = {
15875 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15876 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15877 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15878 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15879 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15880 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15881 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15882 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15883 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
15884 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15885 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15886 {}
15887};
15888
Kailang Yangf1d4e282008-08-26 14:03:29 +020015889static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15890 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15891 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15892 { } /* end */
15893};
15894
Kailang Yang622e84c2009-04-21 07:39:04 +020015895static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
15896 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
15897 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
15898 { } /* end */
15899};
15900
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015901static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15902{
15903 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015904 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015905
15906 present = snd_hda_codec_read(codec, 0x14, 0,
15907 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015908 bits = present ? HDA_AMP_MUTE : 0;
15909 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15910 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015911}
15912
15913static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15914{
15915 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015916 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015917
15918 present = snd_hda_codec_read(codec, 0x1b, 0,
15919 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015920 bits = present ? HDA_AMP_MUTE : 0;
15921 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15922 HDA_AMP_MUTE, bits);
15923 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15924 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015925}
15926
15927static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15928 unsigned int res)
15929{
15930 if ((res >> 26) == ALC880_HP_EVENT)
15931 alc662_lenovo_101e_all_automute(codec);
15932 if ((res >> 26) == ALC880_FRONT_EVENT)
15933 alc662_lenovo_101e_ispeaker_automute(codec);
15934}
15935
Kailang Yang291702f2007-10-16 14:28:03 +020015936static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15937{
15938 unsigned int present;
15939
15940 present = snd_hda_codec_read(codec, 0x18, 0,
15941 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15942 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15943 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15944 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15945 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15946 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15947 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15948 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15949 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15950}
15951
15952/* unsolicited event for HP jack sensing */
15953static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15954 unsigned int res)
15955{
Kailang Yang291702f2007-10-16 14:28:03 +020015956 if ((res >> 26) == ALC880_MIC_EVENT)
15957 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020015958 else
15959 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020015960}
15961
15962static void alc662_eeepc_inithook(struct hda_codec *codec)
15963{
Takashi Iwai42171c12009-05-08 14:11:43 +020015964 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020015965 alc662_eeepc_mic_automute(codec);
15966}
15967
Kailang Yang8c427222008-01-10 13:03:59 +010015968static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15969{
Takashi Iwai42171c12009-05-08 14:11:43 +020015970 struct alc_spec *spec = codec->spec;
15971
15972 spec->autocfg.hp_pins[0] = 0x14;
15973 spec->autocfg.speaker_pins[0] = 0x1b;
15974 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010015975}
15976
Kailang Yang6dda9f42008-05-27 12:05:31 +020015977static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15978{
15979 unsigned int present;
15980 unsigned char bits;
15981
15982 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015983 AC_VERB_GET_PIN_SENSE, 0)
15984 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015985 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015986 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15987 AMP_IN_MUTE(0), bits);
15988 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15989 AMP_IN_MUTE(0), bits);
15990}
15991
15992static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15993{
15994 unsigned int present;
15995 unsigned char bits;
15996
15997 present = snd_hda_codec_read(codec, 0x21, 0,
15998 AC_VERB_GET_PIN_SENSE, 0)
15999 & AC_PINSENSE_PRESENCE;
16000 bits = present ? HDA_AMP_MUTE : 0;
16001 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16002 AMP_IN_MUTE(0), bits);
16003 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16004 AMP_IN_MUTE(0), bits);
16005 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16006 AMP_IN_MUTE(0), bits);
16007 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16008 AMP_IN_MUTE(0), bits);
16009}
16010
16011static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16012{
16013 unsigned int present;
16014 unsigned char bits;
16015
16016 present = snd_hda_codec_read(codec, 0x15, 0,
16017 AC_VERB_GET_PIN_SENSE, 0)
16018 & AC_PINSENSE_PRESENCE;
16019 bits = present ? HDA_AMP_MUTE : 0;
16020 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16021 AMP_IN_MUTE(0), bits);
16022 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16023 AMP_IN_MUTE(0), bits);
16024 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16025 AMP_IN_MUTE(0), bits);
16026 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16027 AMP_IN_MUTE(0), bits);
16028}
16029
16030static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16031{
16032 unsigned int present;
16033 unsigned char bits;
16034
16035 present = snd_hda_codec_read(codec, 0x1b, 0,
16036 AC_VERB_GET_PIN_SENSE, 0)
16037 & AC_PINSENSE_PRESENCE;
16038 bits = present ? 0 : PIN_OUT;
16039 snd_hda_codec_write(codec, 0x14, 0,
16040 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16041}
16042
16043static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16044{
16045 unsigned int present1, present2;
16046
16047 present1 = snd_hda_codec_read(codec, 0x21, 0,
16048 AC_VERB_GET_PIN_SENSE, 0)
16049 & AC_PINSENSE_PRESENCE;
16050 present2 = snd_hda_codec_read(codec, 0x15, 0,
16051 AC_VERB_GET_PIN_SENSE, 0)
16052 & AC_PINSENSE_PRESENCE;
16053
16054 if (present1 || present2) {
16055 snd_hda_codec_write_cache(codec, 0x14, 0,
16056 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16057 } else {
16058 snd_hda_codec_write_cache(codec, 0x14, 0,
16059 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16060 }
16061}
16062
16063static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16064{
16065 unsigned int present1, present2;
16066
16067 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16068 AC_VERB_GET_PIN_SENSE, 0)
16069 & AC_PINSENSE_PRESENCE;
16070 present2 = snd_hda_codec_read(codec, 0x15, 0,
16071 AC_VERB_GET_PIN_SENSE, 0)
16072 & AC_PINSENSE_PRESENCE;
16073
16074 if (present1 || present2) {
16075 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16076 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16077 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16078 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16079 } else {
16080 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16081 AMP_IN_MUTE(0), 0);
16082 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16083 AMP_IN_MUTE(0), 0);
16084 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016085}
16086
16087static void alc663_m51va_mic_automute(struct hda_codec *codec)
16088{
16089 unsigned int present;
16090
16091 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016092 AC_VERB_GET_PIN_SENSE, 0)
16093 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016094 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016095 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016096 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016097 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016098 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016099 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016100 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016101 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016102}
16103
16104static void alc663_m51va_unsol_event(struct hda_codec *codec,
16105 unsigned int res)
16106{
16107 switch (res >> 26) {
16108 case ALC880_HP_EVENT:
16109 alc663_m51va_speaker_automute(codec);
16110 break;
16111 case ALC880_MIC_EVENT:
16112 alc663_m51va_mic_automute(codec);
16113 break;
16114 }
16115}
16116
16117static void alc663_m51va_inithook(struct hda_codec *codec)
16118{
16119 alc663_m51va_speaker_automute(codec);
16120 alc663_m51va_mic_automute(codec);
16121}
16122
Kailang Yangf1d4e282008-08-26 14:03:29 +020016123/* ***************** Mode1 ******************************/
16124static void alc663_mode1_unsol_event(struct hda_codec *codec,
16125 unsigned int res)
16126{
16127 switch (res >> 26) {
16128 case ALC880_HP_EVENT:
16129 alc663_m51va_speaker_automute(codec);
16130 break;
16131 case ALC880_MIC_EVENT:
16132 alc662_eeepc_mic_automute(codec);
16133 break;
16134 }
16135}
16136
16137static void alc663_mode1_inithook(struct hda_codec *codec)
16138{
16139 alc663_m51va_speaker_automute(codec);
16140 alc662_eeepc_mic_automute(codec);
16141}
16142/* ***************** Mode2 ******************************/
16143static void alc662_mode2_unsol_event(struct hda_codec *codec,
16144 unsigned int res)
16145{
16146 switch (res >> 26) {
16147 case ALC880_HP_EVENT:
16148 alc662_f5z_speaker_automute(codec);
16149 break;
16150 case ALC880_MIC_EVENT:
16151 alc662_eeepc_mic_automute(codec);
16152 break;
16153 }
16154}
16155
16156static void alc662_mode2_inithook(struct hda_codec *codec)
16157{
16158 alc662_f5z_speaker_automute(codec);
16159 alc662_eeepc_mic_automute(codec);
16160}
16161/* ***************** Mode3 ******************************/
16162static void alc663_mode3_unsol_event(struct hda_codec *codec,
16163 unsigned int res)
16164{
16165 switch (res >> 26) {
16166 case ALC880_HP_EVENT:
16167 alc663_two_hp_m1_speaker_automute(codec);
16168 break;
16169 case ALC880_MIC_EVENT:
16170 alc662_eeepc_mic_automute(codec);
16171 break;
16172 }
16173}
16174
16175static void alc663_mode3_inithook(struct hda_codec *codec)
16176{
16177 alc663_two_hp_m1_speaker_automute(codec);
16178 alc662_eeepc_mic_automute(codec);
16179}
16180/* ***************** Mode4 ******************************/
16181static void alc663_mode4_unsol_event(struct hda_codec *codec,
16182 unsigned int res)
16183{
16184 switch (res >> 26) {
16185 case ALC880_HP_EVENT:
16186 alc663_21jd_two_speaker_automute(codec);
16187 break;
16188 case ALC880_MIC_EVENT:
16189 alc662_eeepc_mic_automute(codec);
16190 break;
16191 }
16192}
16193
16194static void alc663_mode4_inithook(struct hda_codec *codec)
16195{
16196 alc663_21jd_two_speaker_automute(codec);
16197 alc662_eeepc_mic_automute(codec);
16198}
16199/* ***************** Mode5 ******************************/
16200static void alc663_mode5_unsol_event(struct hda_codec *codec,
16201 unsigned int res)
16202{
16203 switch (res >> 26) {
16204 case ALC880_HP_EVENT:
16205 alc663_15jd_two_speaker_automute(codec);
16206 break;
16207 case ALC880_MIC_EVENT:
16208 alc662_eeepc_mic_automute(codec);
16209 break;
16210 }
16211}
16212
16213static void alc663_mode5_inithook(struct hda_codec *codec)
16214{
16215 alc663_15jd_two_speaker_automute(codec);
16216 alc662_eeepc_mic_automute(codec);
16217}
16218/* ***************** Mode6 ******************************/
16219static void alc663_mode6_unsol_event(struct hda_codec *codec,
16220 unsigned int res)
16221{
16222 switch (res >> 26) {
16223 case ALC880_HP_EVENT:
16224 alc663_two_hp_m2_speaker_automute(codec);
16225 break;
16226 case ALC880_MIC_EVENT:
16227 alc662_eeepc_mic_automute(codec);
16228 break;
16229 }
16230}
16231
16232static void alc663_mode6_inithook(struct hda_codec *codec)
16233{
16234 alc663_two_hp_m2_speaker_automute(codec);
16235 alc662_eeepc_mic_automute(codec);
16236}
16237
Kailang Yang6dda9f42008-05-27 12:05:31 +020016238static void alc663_g71v_hp_automute(struct hda_codec *codec)
16239{
16240 unsigned int present;
16241 unsigned char bits;
16242
16243 present = snd_hda_codec_read(codec, 0x21, 0,
16244 AC_VERB_GET_PIN_SENSE, 0)
16245 & AC_PINSENSE_PRESENCE;
16246 bits = present ? HDA_AMP_MUTE : 0;
16247 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16248 HDA_AMP_MUTE, bits);
16249 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16250 HDA_AMP_MUTE, bits);
16251}
16252
16253static void alc663_g71v_front_automute(struct hda_codec *codec)
16254{
16255 unsigned int present;
16256 unsigned char bits;
16257
16258 present = snd_hda_codec_read(codec, 0x15, 0,
16259 AC_VERB_GET_PIN_SENSE, 0)
16260 & AC_PINSENSE_PRESENCE;
16261 bits = present ? HDA_AMP_MUTE : 0;
16262 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16263 HDA_AMP_MUTE, bits);
16264}
16265
16266static void alc663_g71v_unsol_event(struct hda_codec *codec,
16267 unsigned int res)
16268{
16269 switch (res >> 26) {
16270 case ALC880_HP_EVENT:
16271 alc663_g71v_hp_automute(codec);
16272 break;
16273 case ALC880_FRONT_EVENT:
16274 alc663_g71v_front_automute(codec);
16275 break;
16276 case ALC880_MIC_EVENT:
16277 alc662_eeepc_mic_automute(codec);
16278 break;
16279 }
16280}
16281
16282static void alc663_g71v_inithook(struct hda_codec *codec)
16283{
16284 alc663_g71v_front_automute(codec);
16285 alc663_g71v_hp_automute(codec);
16286 alc662_eeepc_mic_automute(codec);
16287}
16288
16289static void alc663_g50v_unsol_event(struct hda_codec *codec,
16290 unsigned int res)
16291{
16292 switch (res >> 26) {
16293 case ALC880_HP_EVENT:
16294 alc663_m51va_speaker_automute(codec);
16295 break;
16296 case ALC880_MIC_EVENT:
16297 alc662_eeepc_mic_automute(codec);
16298 break;
16299 }
16300}
16301
16302static void alc663_g50v_inithook(struct hda_codec *codec)
16303{
16304 alc663_m51va_speaker_automute(codec);
16305 alc662_eeepc_mic_automute(codec);
16306}
16307
Kailang Yangf1d4e282008-08-26 14:03:29 +020016308static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16309 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016310 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016311
16312 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16313 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16314 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16315
16316 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16317 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16318 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16319 { } /* end */
16320};
16321
Chris Pockelé9541ba12009-05-12 08:08:53 +020016322static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16323 /* Master Playback automatically created from Speaker and Headphone */
16324 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16325 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16326 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16327 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16328
16329 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16330 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16331 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16332
16333 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16334 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16335 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16336 { } /* end */
16337};
16338
Takashi Iwaicb53c622007-08-10 17:21:45 +020016339#ifdef CONFIG_SND_HDA_POWER_SAVE
16340#define alc662_loopbacks alc880_loopbacks
16341#endif
16342
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016343
16344/* pcm configuration: identiacal with ALC880 */
16345#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16346#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16347#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16348#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16349
16350/*
16351 * configuration and preset
16352 */
16353static const char *alc662_models[ALC662_MODEL_LAST] = {
16354 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16355 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16356 [ALC662_3ST_6ch] = "3stack-6ch",
16357 [ALC662_5ST_DIG] = "6stack-dig",
16358 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016359 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016360 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016361 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016362 [ALC663_ASUS_M51VA] = "m51va",
16363 [ALC663_ASUS_G71V] = "g71v",
16364 [ALC663_ASUS_H13] = "h13",
16365 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016366 [ALC663_ASUS_MODE1] = "asus-mode1",
16367 [ALC662_ASUS_MODE2] = "asus-mode2",
16368 [ALC663_ASUS_MODE3] = "asus-mode3",
16369 [ALC663_ASUS_MODE4] = "asus-mode4",
16370 [ALC663_ASUS_MODE5] = "asus-mode5",
16371 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016372 [ALC272_DELL] = "dell",
16373 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016374 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016375 [ALC662_AUTO] = "auto",
16376};
16377
16378static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016379 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016380 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16381 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016382 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16383 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16384 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16385 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16386 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16387 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16388 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16389 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16390 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16391 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16392 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16393 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016394 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16395 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16396 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016397 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16398 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16399 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16400 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016401 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016402 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16403 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016404 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016405 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16406 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16407 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016408 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16409 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16410 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016411 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16412 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16413 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016414 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016415 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16416 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016417 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016418 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016419 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016420 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16421 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16422 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016423 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016424 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16425 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016426 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016427 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016428 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016429 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016430 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16431 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016432 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016433 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16434 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016435 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016436 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016437 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016438 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016439 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016440 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16441 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016442 {}
16443};
16444
16445static struct alc_config_preset alc662_presets[] = {
16446 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016447 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016448 .init_verbs = { alc662_init_verbs },
16449 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16450 .dac_nids = alc662_dac_nids,
16451 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016452 .dig_in_nid = ALC662_DIGIN_NID,
16453 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16454 .channel_mode = alc662_3ST_2ch_modes,
16455 .input_mux = &alc662_capture_source,
16456 },
16457 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016458 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016459 .init_verbs = { alc662_init_verbs },
16460 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16461 .dac_nids = alc662_dac_nids,
16462 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016463 .dig_in_nid = ALC662_DIGIN_NID,
16464 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16465 .channel_mode = alc662_3ST_6ch_modes,
16466 .need_dac_fix = 1,
16467 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016468 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016469 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016470 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016471 .init_verbs = { alc662_init_verbs },
16472 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16473 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016474 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16475 .channel_mode = alc662_3ST_6ch_modes,
16476 .need_dac_fix = 1,
16477 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016478 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016479 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016480 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016481 .init_verbs = { alc662_init_verbs },
16482 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16483 .dac_nids = alc662_dac_nids,
16484 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016485 .dig_in_nid = ALC662_DIGIN_NID,
16486 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16487 .channel_mode = alc662_5stack_modes,
16488 .input_mux = &alc662_capture_source,
16489 },
16490 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016491 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016492 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16493 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16494 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016495 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16496 .channel_mode = alc662_3ST_2ch_modes,
16497 .input_mux = &alc662_lenovo_101e_capture_source,
16498 .unsol_event = alc662_lenovo_101e_unsol_event,
16499 .init_hook = alc662_lenovo_101e_all_automute,
16500 },
Kailang Yang291702f2007-10-16 14:28:03 +020016501 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016502 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016503 .init_verbs = { alc662_init_verbs,
16504 alc662_eeepc_sue_init_verbs },
16505 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16506 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016507 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16508 .channel_mode = alc662_3ST_2ch_modes,
16509 .input_mux = &alc662_eeepc_capture_source,
16510 .unsol_event = alc662_eeepc_unsol_event,
16511 .init_hook = alc662_eeepc_inithook,
16512 },
Kailang Yang8c427222008-01-10 13:03:59 +010016513 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016514 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016515 alc662_chmode_mixer },
16516 .init_verbs = { alc662_init_verbs,
16517 alc662_eeepc_ep20_sue_init_verbs },
16518 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16519 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016520 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16521 .channel_mode = alc662_3ST_6ch_modes,
16522 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016523 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016524 .init_hook = alc662_eeepc_ep20_inithook,
16525 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016526 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016527 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016528 .init_verbs = { alc662_init_verbs,
16529 alc662_ecs_init_verbs },
16530 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16531 .dac_nids = alc662_dac_nids,
16532 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16533 .channel_mode = alc662_3ST_2ch_modes,
16534 .input_mux = &alc662_eeepc_capture_source,
16535 .unsol_event = alc662_eeepc_unsol_event,
16536 .init_hook = alc662_eeepc_inithook,
16537 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016538 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016539 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016540 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16541 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16542 .dac_nids = alc662_dac_nids,
16543 .dig_out_nid = ALC662_DIGOUT_NID,
16544 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16545 .channel_mode = alc662_3ST_2ch_modes,
16546 .input_mux = &alc663_m51va_capture_source,
16547 .unsol_event = alc663_m51va_unsol_event,
16548 .init_hook = alc663_m51va_inithook,
16549 },
16550 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016551 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016552 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16553 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16554 .dac_nids = alc662_dac_nids,
16555 .dig_out_nid = ALC662_DIGOUT_NID,
16556 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16557 .channel_mode = alc662_3ST_2ch_modes,
16558 .input_mux = &alc662_eeepc_capture_source,
16559 .unsol_event = alc663_g71v_unsol_event,
16560 .init_hook = alc663_g71v_inithook,
16561 },
16562 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016563 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016564 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16565 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16566 .dac_nids = alc662_dac_nids,
16567 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16568 .channel_mode = alc662_3ST_2ch_modes,
16569 .input_mux = &alc663_m51va_capture_source,
16570 .unsol_event = alc663_m51va_unsol_event,
16571 .init_hook = alc663_m51va_inithook,
16572 },
16573 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016574 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016575 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16576 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16577 .dac_nids = alc662_dac_nids,
16578 .dig_out_nid = ALC662_DIGOUT_NID,
16579 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16580 .channel_mode = alc662_3ST_6ch_modes,
16581 .input_mux = &alc663_capture_source,
16582 .unsol_event = alc663_g50v_unsol_event,
16583 .init_hook = alc663_g50v_inithook,
16584 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016585 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016586 .mixers = { alc663_m51va_mixer },
16587 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016588 .init_verbs = { alc662_init_verbs,
16589 alc663_21jd_amic_init_verbs },
16590 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16591 .hp_nid = 0x03,
16592 .dac_nids = alc662_dac_nids,
16593 .dig_out_nid = ALC662_DIGOUT_NID,
16594 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16595 .channel_mode = alc662_3ST_2ch_modes,
16596 .input_mux = &alc662_eeepc_capture_source,
16597 .unsol_event = alc663_mode1_unsol_event,
16598 .init_hook = alc663_mode1_inithook,
16599 },
16600 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016601 .mixers = { alc662_1bjd_mixer },
16602 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016603 .init_verbs = { alc662_init_verbs,
16604 alc662_1bjd_amic_init_verbs },
16605 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16606 .dac_nids = alc662_dac_nids,
16607 .dig_out_nid = ALC662_DIGOUT_NID,
16608 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16609 .channel_mode = alc662_3ST_2ch_modes,
16610 .input_mux = &alc662_eeepc_capture_source,
16611 .unsol_event = alc662_mode2_unsol_event,
16612 .init_hook = alc662_mode2_inithook,
16613 },
16614 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016615 .mixers = { alc663_two_hp_m1_mixer },
16616 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016617 .init_verbs = { alc662_init_verbs,
16618 alc663_two_hp_amic_m1_init_verbs },
16619 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16620 .hp_nid = 0x03,
16621 .dac_nids = alc662_dac_nids,
16622 .dig_out_nid = ALC662_DIGOUT_NID,
16623 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16624 .channel_mode = alc662_3ST_2ch_modes,
16625 .input_mux = &alc662_eeepc_capture_source,
16626 .unsol_event = alc663_mode3_unsol_event,
16627 .init_hook = alc663_mode3_inithook,
16628 },
16629 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016630 .mixers = { alc663_asus_21jd_clfe_mixer },
16631 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016632 .init_verbs = { alc662_init_verbs,
16633 alc663_21jd_amic_init_verbs},
16634 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16635 .hp_nid = 0x03,
16636 .dac_nids = alc662_dac_nids,
16637 .dig_out_nid = ALC662_DIGOUT_NID,
16638 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16639 .channel_mode = alc662_3ST_2ch_modes,
16640 .input_mux = &alc662_eeepc_capture_source,
16641 .unsol_event = alc663_mode4_unsol_event,
16642 .init_hook = alc663_mode4_inithook,
16643 },
16644 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016645 .mixers = { alc663_asus_15jd_clfe_mixer },
16646 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016647 .init_verbs = { alc662_init_verbs,
16648 alc663_15jd_amic_init_verbs },
16649 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16650 .hp_nid = 0x03,
16651 .dac_nids = alc662_dac_nids,
16652 .dig_out_nid = ALC662_DIGOUT_NID,
16653 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16654 .channel_mode = alc662_3ST_2ch_modes,
16655 .input_mux = &alc662_eeepc_capture_source,
16656 .unsol_event = alc663_mode5_unsol_event,
16657 .init_hook = alc663_mode5_inithook,
16658 },
16659 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016660 .mixers = { alc663_two_hp_m2_mixer },
16661 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016662 .init_verbs = { alc662_init_verbs,
16663 alc663_two_hp_amic_m2_init_verbs },
16664 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16665 .hp_nid = 0x03,
16666 .dac_nids = alc662_dac_nids,
16667 .dig_out_nid = ALC662_DIGOUT_NID,
16668 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16669 .channel_mode = alc662_3ST_2ch_modes,
16670 .input_mux = &alc662_eeepc_capture_source,
16671 .unsol_event = alc663_mode6_unsol_event,
16672 .init_hook = alc663_mode6_inithook,
16673 },
Kailang Yang622e84c2009-04-21 07:39:04 +020016674 [ALC272_DELL] = {
16675 .mixers = { alc663_m51va_mixer },
16676 .cap_mixer = alc272_auto_capture_mixer,
16677 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16678 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16679 .dac_nids = alc662_dac_nids,
16680 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16681 .adc_nids = alc272_adc_nids,
16682 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16683 .capsrc_nids = alc272_capsrc_nids,
16684 .channel_mode = alc662_3ST_2ch_modes,
16685 .input_mux = &alc663_m51va_capture_source,
16686 .unsol_event = alc663_m51va_unsol_event,
16687 .init_hook = alc663_m51va_inithook,
16688 },
16689 [ALC272_DELL_ZM1] = {
16690 .mixers = { alc663_m51va_mixer },
16691 .cap_mixer = alc662_auto_capture_mixer,
16692 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16693 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16694 .dac_nids = alc662_dac_nids,
16695 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16696 .adc_nids = alc662_adc_nids,
16697 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
16698 .capsrc_nids = alc662_capsrc_nids,
16699 .channel_mode = alc662_3ST_2ch_modes,
16700 .input_mux = &alc663_m51va_capture_source,
16701 .unsol_event = alc663_m51va_unsol_event,
16702 .init_hook = alc663_m51va_inithook,
16703 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020016704 [ALC272_SAMSUNG_NC10] = {
16705 .mixers = { alc272_nc10_mixer },
16706 .init_verbs = { alc662_init_verbs,
16707 alc663_21jd_amic_init_verbs },
16708 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16709 .dac_nids = alc272_dac_nids,
16710 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16711 .channel_mode = alc662_3ST_2ch_modes,
16712 .input_mux = &alc272_nc10_capture_source,
16713 .unsol_event = alc663_mode4_unsol_event,
16714 .init_hook = alc663_mode4_inithook,
16715 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016716};
16717
16718
16719/*
16720 * BIOS auto configuration
16721 */
16722
16723/* add playback controls from the parsed DAC table */
16724static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16725 const struct auto_pin_cfg *cfg)
16726{
16727 char name[32];
16728 static const char *chname[4] = {
16729 "Front", "Surround", NULL /*CLFE*/, "Side"
16730 };
16731 hda_nid_t nid;
16732 int i, err;
16733
16734 for (i = 0; i < cfg->line_outs; i++) {
16735 if (!spec->multiout.dac_nids[i])
16736 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016737 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016738 if (i == 2) {
16739 /* Center/LFE */
16740 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16741 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016742 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16743 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016744 if (err < 0)
16745 return err;
16746 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16747 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016748 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16749 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016750 if (err < 0)
16751 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016752 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016753 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016754 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016755 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016756 if (err < 0)
16757 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016758 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016759 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016760 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016761 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016762 if (err < 0)
16763 return err;
16764 } else {
16765 sprintf(name, "%s Playback Volume", chname[i]);
16766 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016767 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16768 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016769 if (err < 0)
16770 return err;
16771 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016772 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16773 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16774 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016775 if (err < 0)
16776 return err;
16777 }
16778 }
16779 return 0;
16780}
16781
16782/* add playback controls for speaker and HP outputs */
16783static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16784 const char *pfx)
16785{
16786 hda_nid_t nid;
16787 int err;
16788 char name[32];
16789
16790 if (!pin)
16791 return 0;
16792
Takashi Iwai24fb9172008-09-02 14:48:20 +020016793 if (pin == 0x17) {
16794 /* ALC663 has a mono output pin on 0x17 */
16795 sprintf(name, "%s Playback Switch", pfx);
16796 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16797 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16798 return err;
16799 }
16800
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016801 if (alc880_is_fixed_pin(pin)) {
16802 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016803 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016804 /* specify the DAC as the extra output */
16805 if (!spec->multiout.hp_nid)
16806 spec->multiout.hp_nid = nid;
16807 else
16808 spec->multiout.extra_out_nid[0] = nid;
16809 /* control HP volume/switch on the output mixer amp */
16810 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16811 sprintf(name, "%s Playback Volume", pfx);
16812 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16813 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16814 if (err < 0)
16815 return err;
16816 sprintf(name, "%s Playback Switch", pfx);
16817 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16818 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16819 if (err < 0)
16820 return err;
16821 } else if (alc880_is_multi_pin(pin)) {
16822 /* set manual connection */
16823 /* we have only a switch on HP-out PIN */
16824 sprintf(name, "%s Playback Switch", pfx);
16825 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16826 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16827 if (err < 0)
16828 return err;
16829 }
16830 return 0;
16831}
16832
Takashi Iwai2d864c42009-03-20 12:52:47 +010016833/* return the index of the src widget from the connection list of the nid.
16834 * return -1 if not found
16835 */
16836static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
16837 hda_nid_t src)
16838{
16839 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
16840 int i, conns;
16841
16842 conns = snd_hda_get_connections(codec, nid, conn_list,
16843 ARRAY_SIZE(conn_list));
16844 if (conns < 0)
16845 return -1;
16846 for (i = 0; i < conns; i++)
16847 if (conn_list[i] == src)
16848 return i;
16849 return -1;
16850}
16851
16852static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
16853{
Takashi Iwai1327a322009-03-23 13:07:47 +010016854 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010016855 return (pincap & AC_PINCAP_IN) != 0;
16856}
16857
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016858/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010016859static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016860 const struct auto_pin_cfg *cfg)
16861{
Takashi Iwai2d864c42009-03-20 12:52:47 +010016862 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016863 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016864 int i, err, idx;
16865
16866 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010016867 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
16868 idx = alc662_input_pin_idx(codec, 0x0b,
16869 cfg->input_pins[i]);
16870 if (idx >= 0) {
16871 err = new_analog_input(spec, cfg->input_pins[i],
16872 auto_pin_cfg_labels[i],
16873 idx, 0x0b);
16874 if (err < 0)
16875 return err;
16876 }
16877 idx = alc662_input_pin_idx(codec, 0x22,
16878 cfg->input_pins[i]);
16879 if (idx >= 0) {
16880 imux->items[imux->num_items].label =
16881 auto_pin_cfg_labels[i];
16882 imux->items[imux->num_items].index = idx;
16883 imux->num_items++;
16884 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016885 }
16886 }
16887 return 0;
16888}
16889
16890static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16891 hda_nid_t nid, int pin_type,
16892 int dac_idx)
16893{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016894 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016895 /* need the manual connection? */
16896 if (alc880_is_multi_pin(nid)) {
16897 struct alc_spec *spec = codec->spec;
16898 int idx = alc880_multi_pin_idx(nid);
16899 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16900 AC_VERB_SET_CONNECT_SEL,
16901 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16902 }
16903}
16904
16905static void alc662_auto_init_multi_out(struct hda_codec *codec)
16906{
16907 struct alc_spec *spec = codec->spec;
16908 int i;
16909
16910 for (i = 0; i <= HDA_SIDE; i++) {
16911 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016912 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016913 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016914 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016915 i);
16916 }
16917}
16918
16919static void alc662_auto_init_hp_out(struct hda_codec *codec)
16920{
16921 struct alc_spec *spec = codec->spec;
16922 hda_nid_t pin;
16923
16924 pin = spec->autocfg.hp_pins[0];
16925 if (pin) /* connect to front */
16926 /* use dac 0 */
16927 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016928 pin = spec->autocfg.speaker_pins[0];
16929 if (pin)
16930 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016931}
16932
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016933#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16934
16935static void alc662_auto_init_analog_input(struct hda_codec *codec)
16936{
16937 struct alc_spec *spec = codec->spec;
16938 int i;
16939
16940 for (i = 0; i < AUTO_PIN_LAST; i++) {
16941 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010016942 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016943 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010016944 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010016945 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016946 snd_hda_codec_write(codec, nid, 0,
16947 AC_VERB_SET_AMP_GAIN_MUTE,
16948 AMP_OUT_MUTE);
16949 }
16950 }
16951}
16952
Takashi Iwaif511b012008-08-15 16:46:42 +020016953#define alc662_auto_init_input_src alc882_auto_init_input_src
16954
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016955static int alc662_parse_auto_config(struct hda_codec *codec)
16956{
16957 struct alc_spec *spec = codec->spec;
16958 int err;
16959 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16960
16961 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16962 alc662_ignore);
16963 if (err < 0)
16964 return err;
16965 if (!spec->autocfg.line_outs)
16966 return 0; /* can't find valid BIOS pin config */
16967
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016968 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16969 if (err < 0)
16970 return err;
16971 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16972 if (err < 0)
16973 return err;
16974 err = alc662_auto_create_extra_out(spec,
16975 spec->autocfg.speaker_pins[0],
16976 "Speaker");
16977 if (err < 0)
16978 return err;
16979 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16980 "Headphone");
16981 if (err < 0)
16982 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010016983 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016984 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016985 return err;
16986
16987 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16988
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016989 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016990 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16991
Takashi Iwai603c4012008-07-30 15:01:44 +020016992 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016993 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016994
16995 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016996 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020016997
Takashi Iwaid88897e2008-10-31 15:01:37 +010016998 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016999 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017000 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017001
17002 err = alc_auto_add_mic_boost(codec);
17003 if (err < 0)
17004 return err;
17005
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017006 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17007
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017008 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017009}
17010
17011/* additional initialization for auto-configuration model */
17012static void alc662_auto_init(struct hda_codec *codec)
17013{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017014 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017015 alc662_auto_init_multi_out(codec);
17016 alc662_auto_init_hp_out(codec);
17017 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017018 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017019 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017020 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017021}
17022
17023static int patch_alc662(struct hda_codec *codec)
17024{
17025 struct alc_spec *spec;
17026 int err, board_config;
17027
17028 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17029 if (!spec)
17030 return -ENOMEM;
17031
17032 codec->spec = spec;
17033
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017034 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17035
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017036 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17037 alc662_models,
17038 alc662_cfg_tbl);
17039 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020017040 printk(KERN_INFO "hda_codec: Unknown model for %s, "
17041 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017042 board_config = ALC662_AUTO;
17043 }
17044
17045 if (board_config == ALC662_AUTO) {
17046 /* automatic parse from the BIOS config */
17047 err = alc662_parse_auto_config(codec);
17048 if (err < 0) {
17049 alc_free(codec);
17050 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017051 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017052 printk(KERN_INFO
17053 "hda_codec: Cannot set up configuration "
17054 "from BIOS. Using base mode...\n");
17055 board_config = ALC662_3ST_2ch_DIG;
17056 }
17057 }
17058
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017059 err = snd_hda_attach_beep_device(codec, 0x1);
17060 if (err < 0) {
17061 alc_free(codec);
17062 return err;
17063 }
17064
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017065 if (board_config != ALC662_AUTO)
17066 setup_preset(spec, &alc662_presets[board_config]);
17067
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017068 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17069 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17070
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017071 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17072 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17073
Takashi Iwaie1406342008-02-11 18:32:32 +010017074 spec->adc_nids = alc662_adc_nids;
17075 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17076 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017077 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017078
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017079 if (!spec->cap_mixer)
17080 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017081 if (codec->vendor_id == 0x10ec0662)
17082 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17083 else
17084 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017085
Takashi Iwai2134ea42008-01-10 16:53:55 +010017086 spec->vmaster_nid = 0x02;
17087
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017088 codec->patch_ops = alc_patch_ops;
17089 if (board_config == ALC662_AUTO)
17090 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017091#ifdef CONFIG_SND_HDA_POWER_SAVE
17092 if (!spec->loopback.amplist)
17093 spec->loopback.amplist = alc662_loopbacks;
17094#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017095 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017096
17097 return 0;
17098}
17099
17100/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017101 * patch entries
17102 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017103static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017104 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017105 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017106 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017107 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017108 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017109 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017110 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017111 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017112 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17113 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17114 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017115 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17116 .patch = patch_alc883 },
17117 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17118 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017119 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017120 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017121 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020017122 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020017123 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17124 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020017125 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020017126 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010017127 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020017128 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017129 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17130 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017131 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017132 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017133 {} /* terminator */
17134};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017135
17136MODULE_ALIAS("snd-hda-codec-id:10ec*");
17137
17138MODULE_LICENSE("GPL");
17139MODULE_DESCRIPTION("Realtek HD-audio codec");
17140
17141static struct hda_codec_preset_list realtek_list = {
17142 .preset = snd_hda_preset_realtek,
17143 .owner = THIS_MODULE,
17144};
17145
17146static int __init patch_realtek_init(void)
17147{
17148 return snd_hda_add_codec_preset(&realtek_list);
17149}
17150
17151static void __exit patch_realtek_exit(void)
17152{
17153 snd_hda_delete_codec_preset(&realtek_list);
17154}
17155
17156module_init(patch_realtek_init)
17157module_exit(patch_realtek_exit)